You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

configure 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. # Incorrect settings of CC or CFLAGS may prevent creating a shared library.
  17. # If you have problems, try without defining CC and CFLAGS before reporting
  18. # an error.
  19. LIBS=libz.a
  20. SHAREDLIB=libz.so
  21. VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
  22. AR=${AR-"ar rc"}
  23. RANLIB=${RANLIB-"ranlib"}
  24. prefix=${prefix-/usr/local}
  25. exec_prefix=${exec_prefix-'${prefix}'}
  26. libdir=${libdir-'${exec_prefix}/lib'}
  27. includedir=${includedir-'${prefix}/include'}
  28. shared_ext='.so'
  29. shared=0
  30. gcc=0
  31. old_cc="$CC"
  32. old_cflags="$CFLAGS"
  33. while test $# -ge 1
  34. do
  35. case "$1" in
  36. -h* | --h*)
  37. echo 'usage:'
  38. echo ' configure [--shared] [--prefix=PREFIX] [--exec_prefix=EXPREFIX]'
  39. echo ' [--libdir=LIBDIR] [--includedir=INCLUDEDIR]'
  40. exit 0;;
  41. -p*=* | --p*=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
  42. -e*=* | --e*=*) exec_prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
  43. -l*=* | --libdir=*) libdir=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
  44. -i*=* | --includedir=*) includedir=`echo $1 | sed 's/[-a-z_]*=//'`;shift;;
  45. -p* | --p*) prefix="$2"; shift; shift;;
  46. -e* | --e*) exec_prefix="$2"; shift; shift;;
  47. -l* | --l*) libdir="$2"; shift; shift;;
  48. -i* | --i*) includedir="$2"; shift; shift;;
  49. -s* | --s*) shared=1; shift;;
  50. *) shift;;
  51. esac
  52. done
  53. test=ztest$$
  54. cat > $test.c <<EOF
  55. extern int getchar();
  56. int hello() {return getchar();}
  57. EOF
  58. test -z "$CC" && echo Checking for gcc...
  59. cc=${CC-gcc}
  60. cflags=${CFLAGS-"-O3"}
  61. # to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
  62. case "$cc" in
  63. *gcc*) gcc=1;;
  64. esac
  65. if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
  66. CC="$cc"
  67. SFLAGS=${CFLAGS-"-fPIC -O3"}
  68. CFLAGS="$cflags"
  69. case `(uname -s || echo unknown) 2>/dev/null` in
  70. Linux | linux) LDSHARED=${LDSHARED-"gcc -shared -Wl,-soname,libz.so.1"};;
  71. *) LDSHARED=${LDSHARED-"gcc -shared"};;
  72. esac
  73. else
  74. # find system name and corresponding cc options
  75. CC=${CC-cc}
  76. case `(uname -sr || echo unknown) 2>/dev/null` in
  77. HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
  78. CFLAGS=${CFLAGS-"-O"}
  79. # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
  80. LDSHARED=${LDSHARED-"ld -b"}
  81. shared_ext='.sl'
  82. SHAREDLIB='libz.sl';;
  83. IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
  84. CFLAGS=${CFLAGS-"-ansi -O2"}
  85. LDSHARED=${LDSHARED-"cc -shared"};;
  86. OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
  87. CFLAGS=${CFLAGS-"-O -std1"}
  88. LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,$SHAREDLIB -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"};;
  89. OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
  90. CFLAGS=${CFLAGS-"-O -std1"}
  91. LDSHARED=${LDSHARED-"cc -shared"};;
  92. QNX*) SFLAGS=${CFLAGS-"-4 -O"}
  93. CFLAGS=${CFLAGS-"-4 -O"}
  94. LDSHARED=${LDSHARED-"cc"}
  95. RANLIB=${RANLIB-"true"}
  96. AR="cc -A";;
  97. SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
  98. CFLAGS=${CFLAGS-"-O3"}
  99. LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};;
  100. SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."}
  101. CFLAGS=${CFLAGS-"-fast -xcg89"}
  102. LDSHARED=${LDSHARED-"cc -G"};;
  103. SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
  104. CFLAGS=${CFLAGS-"-O2"}
  105. LDSHARED=${LDSHARED-"ld"};;
  106. UNIX_System_V\ 4.2.0)
  107. SFLAGS=${CFLAGS-"-KPIC -O"}
  108. CFLAGS=${CFLAGS-"-O"}
  109. LDSHARED=${LDSHARED-"cc -G"};;
  110. UNIX_SV\ 4.2MP)
  111. SFLAGS=${CFLAGS-"-Kconform_pic -O"}
  112. CFLAGS=${CFLAGS-"-O"}
  113. LDSHARED=${LDSHARED-"cc -G"};;
  114. # send working options for other systems to support@gzip.org
  115. *) SFLAGS=${CFLAGS-"-O"}
  116. CFLAGS=${CFLAGS-"-O"}
  117. LDSHARED=${LDSHARED-"cc -shared"};;
  118. esac
  119. fi
  120. if test $shared -eq 1; then
  121. echo Checking for shared library support...
  122. # we must test in two steps (cc then ld), required at least on SunOS 4.x
  123. if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
  124. test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
  125. CFLAGS="$SFLAGS"
  126. LIBS="$SHAREDLIB.$VER"
  127. echo Building shared library $SHAREDLIB.$VER with $CC.
  128. elif test -z "$old_cc" -a -z "$old_cflags"; then
  129. echo No shared library suppport.
  130. shared=0;
  131. else
  132. echo 'No shared library suppport; try without defining CC and CFLAGS'
  133. shared=0;
  134. fi
  135. fi
  136. if test $shared -eq 0; then
  137. LDSHARED="$CC"
  138. echo Building static library $LIBS version $VER with $CC.
  139. fi
  140. cat > $test.c <<EOF
  141. #include <unistd.h>
  142. int main() { return 0; }
  143. EOF
  144. if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
  145. CFLAGS="$CFLAGS -DHAVE_UNISTD_H"
  146. echo "Checking for unistd.h... Yes."
  147. else
  148. echo "Checking for unistd.h... No."
  149. fi
  150. cat > $test.c <<EOF
  151. #include <errno.h>
  152. int main() { return 0; }
  153. EOF
  154. if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
  155. echo "Checking for errno.h... Yes."
  156. else
  157. echo "Checking for errno.h... No."
  158. CFLAGS="$CFLAGS -DNO_ERRNO_H"
  159. fi
  160. cat > $test.c <<EOF
  161. #include <sys/types.h>
  162. #include <sys/mman.h>
  163. #include <sys/stat.h>
  164. caddr_t hello() {
  165. return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
  166. }
  167. EOF
  168. if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
  169. CFLAGS="$CFLAGS -DUSE_MMAP"
  170. echo Checking for mmap support... Yes.
  171. else
  172. echo Checking for mmap support... No.
  173. fi
  174. CPP=${CPP-"$CC -E"}
  175. case $CFLAGS in
  176. *ASMV*)
  177. if test "`nm $test.o | grep _hello`" = ""; then
  178. CPP="$CPP -DNO_UNDERLINE"
  179. echo Checking for underline in external names... No.
  180. else
  181. echo Checking for underline in external names... Yes.
  182. fi;;
  183. esac
  184. rm -f $test.[co] $test$shared_ext
  185. # udpate Makefile
  186. sed < Makefile.in "
  187. /^CC *=/s%=.*%=$CC%
  188. /^CFLAGS *=/s%=.*%=$CFLAGS%
  189. /^CPP *=/s%=.*%=$CPP%
  190. /^LDSHARED *=/s%=.*%=$LDSHARED%
  191. /^LIBS *=/s%=.*%=$LIBS%
  192. /^SHAREDLIB *=/s%=.*%=$SHAREDLIB%
  193. /^AR *=/s%=.*%=$AR%
  194. /^RANLIB *=/s%=.*%=$RANLIB%
  195. /^VER *=/s%=.*%=$VER%
  196. /^prefix *=/s%=.*%=$prefix%
  197. /^exec_prefix *=/s%=.*%=$exec_prefix%
  198. /^libdir *=/s%=.*%=$libdir%
  199. /^includedir *=/s%=.*%=$includedir%
  200. " > Makefile