aboutsummaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2015-08-02 14:46:58 -0700
committerMark Adler <madler@alumni.caltech.edu>2015-08-02 21:35:50 -0700
commit55d98b4c302c74b619968bd02cf3b5e18d845977 (patch)
treeffdbc1f067646102925b013ebd52ab058b03aa44 /configure
parentbfcace04f91bd27c8c7c040da2396fe4b7724422 (diff)
downloadzlib-55d98b4c302c74b619968bd02cf3b5e18d845977.tar.gz
zlib-55d98b4c302c74b619968bd02cf3b5e18d845977.tar.bz2
zlib-55d98b4c302c74b619968bd02cf3b5e18d845977.zip
Allow building zlib outside of the source directory.
To build, simply run configure from the source directory by specifying its path. That path will be used to find the source files. The source directory will not be touched. All new and modified files will be made in the current directory. Discovered in the process that not all makes understand % or $<, and not all compilers understand -include or -I-. This required a larger Makefile.in with explicit dependencies.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure37
1 files changed, 28 insertions, 9 deletions
diff --git a/configure b/configure
index b77a8a8..6438438 100755
--- a/configure
+++ b/configure
@@ -18,6 +18,18 @@ echo -------------------- >> configure.log
18echo $0 $* >> configure.log 18echo $0 $* >> configure.log
19date >> configure.log 19date >> configure.log
20 20
21# get source directory
22SRCDIR=`dirname $0`
23if test $SRCDIR = "."; then
24 ZINC=""
25 ZINCOUT="-I."
26 SRCDIR=""
27else
28 ZINC='-include zconf.h'
29 ZINCOUT='-I. -I$(SRCDIR)'
30 SRCDIR="$SRCDIR/"
31fi
32
21# set command prefix for cross-compilation 33# set command prefix for cross-compilation
22if [ -n "${CHOST}" ]; then 34if [ -n "${CHOST}" ]; then
23 uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`" 35 uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`"
@@ -28,10 +40,10 @@ fi
28STATICLIB=libz.a 40STATICLIB=libz.a
29 41
30# extract zlib version numbers from zlib.h 42# extract zlib version numbers from zlib.h
31VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h` 43VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h`
32VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h` 44VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}zlib.h`
33VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h` 45VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
34VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h` 46VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
35 47
36# establish commands for library building 48# establish commands for library building
37if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then 49if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
@@ -184,9 +196,9 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
184 fi 196 fi
185 case "$uname" in 197 case "$uname" in
186 Linux* | linux* | GNU | GNU/* | solaris*) 198 Linux* | linux* | GNU | GNU/* | solaris*)
187 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;; 199 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
188 *BSD | *bsd* | DragonFly) 200 *BSD | *bsd* | DragonFly)
189 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} 201 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
190 LDCONFIG="ldconfig -m" ;; 202 LDCONFIG="ldconfig -m" ;;
191 CYGWIN* | Cygwin* | cygwin* | OS/2*) 203 CYGWIN* | Cygwin* | cygwin* | OS/2*)
192 EXE='.exe' ;; 204 EXE='.exe' ;;
@@ -287,6 +299,9 @@ else
287 esac 299 esac
288 fi 300 fi
289 fi 301 fi
302 if test -n "$ZINC"; then
303 ZINC='-I- -I. -I$(SRCDIR)'
304 fi
290 ;; 305 ;;
291 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"} 306 SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
292 CFLAGS=${CFLAGS-"-O2"} 307 CFLAGS=${CFLAGS-"-O2"}
@@ -470,7 +485,7 @@ else
470fi 485fi
471 486
472# copy clean zconf.h for subsequent edits 487# copy clean zconf.h for subsequent edits
473cp -p zconf.h.in zconf.h 488cp -p ${SRCDIR}zconf.h.in zconf.h
474 489
475echo >> configure.log 490echo >> configure.log
476 491
@@ -764,6 +779,7 @@ echo STATICLIB = $STATICLIB >> configure.log
764echo TEST = $TEST >> configure.log 779echo TEST = $TEST >> configure.log
765echo VER = $VER >> configure.log 780echo VER = $VER >> configure.log
766echo Z_U4 = $Z_U4 >> configure.log 781echo Z_U4 = $Z_U4 >> configure.log
782echo SRCDIR = $SRCDIR >> configure.log
767echo exec_prefix = $exec_prefix >> configure.log 783echo exec_prefix = $exec_prefix >> configure.log
768echo includedir = $includedir >> configure.log 784echo includedir = $includedir >> configure.log
769echo libdir = $libdir >> configure.log 785echo libdir = $libdir >> configure.log
@@ -773,7 +789,7 @@ echo sharedlibdir = $sharedlibdir >> configure.log
773echo uname = $uname >> configure.log 789echo uname = $uname >> configure.log
774 790
775# udpate Makefile with the configure results 791# udpate Makefile with the configure results
776sed < Makefile.in " 792sed < ${SRCDIR}Makefile.in "
777/^CC *=/s#=.*#=$CC# 793/^CC *=/s#=.*#=$CC#
778/^CFLAGS *=/s#=.*#=$CFLAGS# 794/^CFLAGS *=/s#=.*#=$CFLAGS#
779/^SFLAGS *=/s#=.*#=$SFLAGS# 795/^SFLAGS *=/s#=.*#=$SFLAGS#
@@ -790,6 +806,9 @@ sed < Makefile.in "
790/^LDCONFIG *=/s#=.*#=$LDCONFIG# 806/^LDCONFIG *=/s#=.*#=$LDCONFIG#
791/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC# 807/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
792/^EXE *=/s#=.*#=$EXE# 808/^EXE *=/s#=.*#=$EXE#
809/^SRCDIR *=/s#=.*#=$SRCDIR#
810/^ZINC *=/s#=.*#=$ZINC#
811/^ZINCOUT *=/s#=.*#=$ZINCOUT#
793/^prefix *=/s#=.*#=$prefix# 812/^prefix *=/s#=.*#=$prefix#
794/^exec_prefix *=/s#=.*#=$exec_prefix# 813/^exec_prefix *=/s#=.*#=$exec_prefix#
795/^libdir *=/s#=.*#=$libdir# 814/^libdir *=/s#=.*#=$libdir#
@@ -803,7 +822,7 @@ sed < Makefile.in "
803" > Makefile 822" > Makefile
804 823
805# create zlib.pc with the configure results 824# create zlib.pc with the configure results
806sed < zlib.pc.in " 825sed < ${SRCDIR}zlib.pc.in "
807/^CC *=/s#=.*#=$CC# 826/^CC *=/s#=.*#=$CC#
808/^CFLAGS *=/s#=.*#=$CFLAGS# 827/^CFLAGS *=/s#=.*#=$CFLAGS#
809/^CPP *=/s#=.*#=$CPP# 828/^CPP *=/s#=.*#=$CPP#