VirtualBox

source: vbox/trunk/src/libs/zlib-1.2.1/configure@ 13005

最後變更 在這個檔案從13005是 6390,由 vboxsync 提交於 17 年 前

export libpng and zlib so Windows and OS/2 builds cleanly.

  • 屬性 svn:eol-style 設為 native
檔案大小: 12.4 KB
 
1#!/bin/sh
2# configure script for zlib. This script is needed only if
3# you wish to build a shared library and your system supports them,
4# of if you need special compiler, flags or install directory.
5# Otherwise, you can just use directly "make test; make install"
6#
7# To create a shared library, use "configure --shared"; by default a static
8# library is created. If the primitive shared library support provided here
9# does not work, use ftp://prep.ai.mit.edu/pub/gnu/libtool-*.tar.gz
10#
11# To impose specific compiler or flags or install directory, use for example:
12# prefix=$HOME CC=cc CFLAGS="-O4" ./configure
13# or for csh/tcsh users:
14# (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
15# LDSHARED is the command to be used to create a shared library
16
17# Incorrect settings of CC or CFLAGS may prevent creating a shared library.
18# If you have problems, try without defining CC and CFLAGS before reporting
19# an error.
20
21LIBS=libz.a
22LDFLAGS="-L. ${LIBS}"
23VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
24VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
25VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
26AR=${AR-"ar rc"}
27RANLIB=${RANLIB-"ranlib"}
28prefix=${prefix-/usr/local}
29exec_prefix=${exec_prefix-'${prefix}'}
30libdir=${libdir-'${exec_prefix}/lib'}
31includedir=${includedir-'${prefix}/include'}
32mandir=${mandir-'${prefix}/share/man'}
33shared_ext='.so'
34shared=0
35gcc=0
36old_cc="$CC"
37old_cflags="$CFLAGS"
38
39while test $# -ge 1
40do
41case "$1" in
42 -h* | --h*)
43 echo 'usage:'
44 echo ' configure [--shared] [--prefix=PREFIX] [--exec_prefix=EXPREFIX]'
45 echo ' [--libdir=LIBDIR] [--includedir=INCLUDEDIR]'
46 exit 0;;
47 -p*=* | --p*=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
48 -e*=* | --e*=*) exec_prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
49 -l*=* | --libdir=*) libdir=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
50 -i*=* | --includedir=*) includedir=`echo $1 | sed 's/[-a-z_]*=//'`;shift;;
51 -p* | --p*) prefix="$2"; shift; shift;;
52 -e* | --e*) exec_prefix="$2"; shift; shift;;
53 -l* | --l*) libdir="$2"; shift; shift;;
54 -i* | --i*) includedir="$2"; shift; shift;;
55 -s* | --s*) shared=1; shift;;
56 *) echo "unknown option: $1"; echo "$0 --help for help"; exit 1;;
57 esac
58done
59
60test=ztest$$
61cat > $test.c <<EOF
62extern int getchar();
63int hello() {return getchar();}
64EOF
65
66test -z "$CC" && echo Checking for gcc...
67cc=${CC-gcc}
68cflags=${CFLAGS-"-O3"}
69# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
70case "$cc" in
71 *gcc*) gcc=1;;
72esac
73
74if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
75 CC="$cc"
76 SFLAGS=${CFLAGS-"-fPIC -O3"}
77 CFLAGS="$cflags"
78 case `(uname -s || echo unknown) 2>/dev/null` in
79 Linux | linux | GNU | GNU/*) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};;
80 CYGWIN* | Cygwin* | cygwin* )
81 EXE='.exe';;
82 QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
83 # ([email protected])
84 LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"};;
85 HP-UX*) LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
86 shared_ext='.sl'
87 SHAREDLIB='libz.sl';;
88 Darwin*) shared_ext='.dylib'
89 SHAREDLIB=libz$shared_ext
90 SHAREDLIBV=libz.$VER$shared_ext
91 SHAREDLIBM=libz.$VER1$shared_ext
92 LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name /usr/lib/$SHAREDLIBV -compatibility_version $VER2 -current_version $VER"}
93 libdir='/usr/lib'
94 includedir='/usr/include';;
95 *) LDSHARED=${LDSHARED-"$cc -shared"};;
96 esac
97else
98 # find system name and corresponding cc options
99 CC=${CC-cc}
100 case `(uname -sr || echo unknown) 2>/dev/null` in
101 HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
102 CFLAGS=${CFLAGS-"-O"}
103# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
104 LDSHARED=${LDSHARED-"ld -b"}
105 shared_ext='.sl'
106 SHAREDLIB='libz.sl';;
107 IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
108 CFLAGS=${CFLAGS-"-ansi -O2"}
109 LDSHARED=${LDSHARED-"cc -shared"};;
110 OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
111 CFLAGS=${CFLAGS-"-O -std1"}
112 LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"};;
113 OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
114 CFLAGS=${CFLAGS-"-O -std1"}
115 LDSHARED=${LDSHARED-"cc -shared"};;
116 QNX*) SFLAGS=${CFLAGS-"-4 -O"}
117 CFLAGS=${CFLAGS-"-4 -O"}
118 LDSHARED=${LDSHARED-"cc"}
119 RANLIB=${RANLIB-"true"}
120 AR="cc -A";;
121 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
122 CFLAGS=${CFLAGS-"-O3"}
123 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};;
124 SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."}
125 CFLAGS=${CFLAGS-"-fast -xcg89"}
126 LDSHARED=${LDSHARED-"cc -G"};;
127 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
128 CFLAGS=${CFLAGS-"-O2"}
129 LDSHARED=${LDSHARED-"ld"};;
130 UNIX_System_V\ 4.2.0)
131 SFLAGS=${CFLAGS-"-KPIC -O"}
132 CFLAGS=${CFLAGS-"-O"}
133 LDSHARED=${LDSHARED-"cc -G"};;
134 UNIX_SV\ 4.2MP)
135 SFLAGS=${CFLAGS-"-Kconform_pic -O"}
136 CFLAGS=${CFLAGS-"-O"}
137 LDSHARED=${LDSHARED-"cc -G"};;
138 OpenUNIX\ 5)
139 SFLAGS=${CFLAGS-"-KPIC -O"}
140 CFLAGS=${CFLAGS-"-O"}
141 LDSHARED=${LDSHARED-"cc -G"};;
142 AIX*) # Courtesy of [email protected]
143 SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
144 CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
145 LDSHARED=${LDSHARED-"xlc -G"};;
146 # send working options for other systems to [email protected]
147 *) SFLAGS=${CFLAGS-"-O"}
148 CFLAGS=${CFLAGS-"-O"}
149 LDSHARED=${LDSHARED-"cc -shared"};;
150 esac
151fi
152
153SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
154SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
155SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
156
157if test $shared -eq 1; then
158 echo Checking for shared library support...
159 # we must test in two steps (cc then ld), required at least on SunOS 4.x
160 if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
161 test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
162 CFLAGS="$SFLAGS"
163 LIBS="$SHAREDLIBV"
164 echo Building shared library $SHAREDLIBV with $CC.
165 elif test -z "$old_cc" -a -z "$old_cflags"; then
166 echo No shared library support.
167 shared=0;
168 else
169 echo 'No shared library support; try without defining CC and CFLAGS'
170 shared=0;
171 fi
172fi
173if test $shared -eq 0; then
174 LDSHARED="$CC"
175 echo Building static library $LIBS version $VER with $CC.
176else
177 LDFLAGS="-L. ${SHAREDLIBV}"
178fi
179
180cat > $test.c <<EOF
181#include <unistd.h>
182int main() { return 0; }
183EOF
184if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
185 sed < zconf.in.h "/HAVE_UNISTD_H/s%0%1%" > zconf.h
186 echo "Checking for unistd.h... Yes."
187else
188 cp -p zconf.in.h zconf.h
189 echo "Checking for unistd.h... No."
190fi
191
192cat > $test.c <<EOF
193#include <stdio.h>
194#include <stdarg.h>
195#include "zconf.h"
196
197int main()
198{
199#ifndef STDC
200 choke me
201#endif
202
203 return 0;
204}
205EOF
206
207if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
208 echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()"
209
210 cat > $test.c <<EOF
211#include <stdio.h>
212#include <stdarg.h>
213
214int mytest(char *fmt, ...)
215{
216 char buf[20];
217 va_list ap;
218
219 va_start(ap, fmt);
220 vsnprintf(buf, sizeof(buf), fmt, ap);
221 va_end(ap);
222 return 0;
223}
224
225int main()
226{
227 return (mytest("Hello%d\n", 1));
228}
229EOF
230
231 if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
232 echo "Checking for vsnprintf() in stdio.h... Yes."
233
234 cat >$test.c <<EOF
235#include <stdio.h>
236#include <stdarg.h>
237
238int mytest(char *fmt, ...)
239{
240 int n;
241 char buf[20];
242 va_list ap;
243
244 va_start(ap, fmt);
245 n = vsnprintf(buf, sizeof(buf), fmt, ap);
246 va_end(ap);
247 return n;
248}
249
250int main()
251{
252 return (mytest("Hello%d\n", 1));
253}
254EOF
255
256 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
257 echo "Checking for return value of vsnprintf()... Yes."
258 else
259 CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
260 echo "Checking for return value of vsnprintf()... No."
261 echo " WARNING: apparently vsnprintf() does not return a value. zlib"
262 echo " can build but will be open to possible string-format security"
263 echo " vulnerabilities."
264 fi
265 else
266 CFLAGS="$CFLAGS -DNO_vsnprintf"
267 echo "Checking for vsnprintf() in stdio.h... No."
268 echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib"
269 echo " can build but will be open to possible buffer-overflow security"
270 echo " vulnerabilities."
271
272 cat >$test.c <<EOF
273#include <stdio.h>
274#include <stdarg.h>
275
276int mytest(char *fmt, ...)
277{
278 int n;
279 char buf[20];
280 va_list ap;
281
282 va_start(ap, fmt);
283 n = vsprintf(buf, fmt, ap);
284 va_end(ap);
285 return n;
286}
287
288int main()
289{
290 return (mytest("Hello%d\n", 1));
291}
292EOF
293
294 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
295 echo "Checking for return value of vsprintf()... Yes."
296 else
297 CFLAGS="$CFLAGS -DHAS_vsprintf_void"
298 echo "Checking for return value of vsprintf()... No."
299 echo " WARNING: apparently vsprintf() does not return a value. zlib"
300 echo " can build but will be open to possible string-format security"
301 echo " vulnerabilities."
302 fi
303 fi
304else
305 echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()"
306
307 cat >$test.c <<EOF
308#include <stdio.h>
309
310int mytest()
311{
312 char buf[20];
313
314 snprintf(buf, sizeof(buf), "%s", "foo");
315 return 0;
316}
317
318int main()
319{
320 return (mytest());
321}
322EOF
323
324 if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
325 echo "Checking for snprintf() in stdio.h... Yes."
326
327 cat >$test.c <<EOF
328#include <stdio.h>
329
330int mytest()
331{
332 char buf[20];
333
334 return snprintf(buf, sizeof(buf), "%s", "foo");
335}
336
337int main()
338{
339 return (mytest());
340}
341EOF
342
343 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
344 echo "Checking for return value of snprintf()... Yes."
345 else
346 CFLAGS="$CFLAGS -DHAS_snprintf_void"
347 echo "Checking for return value of snprintf()... No."
348 echo " WARNING: apparently snprintf() does not return a value. zlib"
349 echo " can build but will be open to possible string-format security"
350 echo " vulnerabilities."
351 fi
352 else
353 CFLAGS="$CFLAGS -DNO_snprintf"
354 echo "Checking for snprintf() in stdio.h... No."
355 echo " WARNING: snprintf() not found, falling back to sprintf(). zlib"
356 echo " can build but will be open to possible buffer-overflow security"
357 echo " vulnerabilities."
358
359 cat >$test.c <<EOF
360#include <stdio.h>
361
362int mytest()
363{
364 char buf[20];
365
366 return sprintf(buf, "%s", "foo");
367}
368
369int main()
370{
371 return (mytest());
372}
373EOF
374
375 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
376 echo "Checking for return value of sprintf()... Yes."
377 else
378 CFLAGS="$CFLAGS -DHAS_sprintf_void"
379 echo "Checking for return value of sprintf()... No."
380 echo " WARNING: apparently sprintf() does not return a value. zlib"
381 echo " can build but will be open to possible string-format security"
382 echo " vulnerabilities."
383 fi
384 fi
385fi
386
387cat >$test.c <<EOF
388#include <errno.h>
389int main() { return 0; }
390EOF
391if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
392 echo "Checking for errno.h... Yes."
393else
394 echo "Checking for errno.h... No."
395 CFLAGS="$CFLAGS -DNO_ERRNO_H"
396fi
397
398cat > $test.c <<EOF
399#include <sys/types.h>
400#include <sys/mman.h>
401#include <sys/stat.h>
402caddr_t hello() {
403 return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
404}
405EOF
406if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
407 CFLAGS="$CFLAGS -DUSE_MMAP"
408 echo Checking for mmap support... Yes.
409else
410 echo Checking for mmap support... No.
411fi
412
413CPP=${CPP-"$CC -E"}
414case $CFLAGS in
415 *ASMV*)
416 if test "`nm $test.o | grep _hello`" = ""; then
417 CPP="$CPP -DNO_UNDERLINE"
418 echo Checking for underline in external names... No.
419 else
420 echo Checking for underline in external names... Yes.
421 fi;;
422esac
423
424rm -f $test.[co] $test $test$shared_ext
425
426# udpate Makefile
427sed < Makefile.in "
428/^CC *=/s#=.*#=$CC#
429/^CFLAGS *=/s#=.*#=$CFLAGS#
430/^CPP *=/s#=.*#=$CPP#
431/^LDSHARED *=/s#=.*#=$LDSHARED#
432/^LIBS *=/s#=.*#=$LIBS#
433/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
434/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
435/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
436/^AR *=/s#=.*#=$AR#
437/^RANLIB *=/s#=.*#=$RANLIB#
438/^EXE *=/s#=.*#=$EXE#
439/^prefix *=/s#=.*#=$prefix#
440/^exec_prefix *=/s#=.*#=$exec_prefix#
441/^libdir *=/s#=.*#=$libdir#
442/^includedir *=/s#=.*#=$includedir#
443/^mandir *=/s#=.*#=$mandir#
444/^LDFLAGS *=/s#=.*#=$LDFLAGS#
445" > Makefile
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette