diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2015-08-02 14:46:58 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2015-08-02 21:35:50 -0700 |
commit | 55d98b4c302c74b619968bd02cf3b5e18d845977 (patch) | |
tree | ffdbc1f067646102925b013ebd52ab058b03aa44 /configure | |
parent | bfcace04f91bd27c8c7c040da2396fe4b7724422 (diff) | |
download | zlib-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-x | configure | 37 |
1 files changed, 28 insertions, 9 deletions
@@ -18,6 +18,18 @@ echo -------------------- >> configure.log | |||
18 | echo $0 $* >> configure.log | 18 | echo $0 $* >> configure.log |
19 | date >> configure.log | 19 | date >> configure.log |
20 | 20 | ||
21 | # get source directory | ||
22 | SRCDIR=`dirname $0` | ||
23 | if test $SRCDIR = "."; then | ||
24 | ZINC="" | ||
25 | ZINCOUT="-I." | ||
26 | SRCDIR="" | ||
27 | else | ||
28 | ZINC='-include zconf.h' | ||
29 | ZINCOUT='-I. -I$(SRCDIR)' | ||
30 | SRCDIR="$SRCDIR/" | ||
31 | fi | ||
32 | |||
21 | # set command prefix for cross-compilation | 33 | # set command prefix for cross-compilation |
22 | if [ -n "${CHOST}" ]; then | 34 | if [ -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 | |||
28 | STATICLIB=libz.a | 40 | STATICLIB=libz.a |
29 | 41 | ||
30 | # extract zlib version numbers from zlib.h | 42 | # extract zlib version numbers from zlib.h |
31 | VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h` | 43 | VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h` |
32 | VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h` | 44 | VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}zlib.h` |
33 | VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h` | 45 | VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h` |
34 | VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h` | 46 | VER1=`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 |
37 | if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then | 49 | if "${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 | |||
470 | fi | 485 | fi |
471 | 486 | ||
472 | # copy clean zconf.h for subsequent edits | 487 | # copy clean zconf.h for subsequent edits |
473 | cp -p zconf.h.in zconf.h | 488 | cp -p ${SRCDIR}zconf.h.in zconf.h |
474 | 489 | ||
475 | echo >> configure.log | 490 | echo >> configure.log |
476 | 491 | ||
@@ -764,6 +779,7 @@ echo STATICLIB = $STATICLIB >> configure.log | |||
764 | echo TEST = $TEST >> configure.log | 779 | echo TEST = $TEST >> configure.log |
765 | echo VER = $VER >> configure.log | 780 | echo VER = $VER >> configure.log |
766 | echo Z_U4 = $Z_U4 >> configure.log | 781 | echo Z_U4 = $Z_U4 >> configure.log |
782 | echo SRCDIR = $SRCDIR >> configure.log | ||
767 | echo exec_prefix = $exec_prefix >> configure.log | 783 | echo exec_prefix = $exec_prefix >> configure.log |
768 | echo includedir = $includedir >> configure.log | 784 | echo includedir = $includedir >> configure.log |
769 | echo libdir = $libdir >> configure.log | 785 | echo libdir = $libdir >> configure.log |
@@ -773,7 +789,7 @@ echo sharedlibdir = $sharedlibdir >> configure.log | |||
773 | echo uname = $uname >> configure.log | 789 | echo uname = $uname >> configure.log |
774 | 790 | ||
775 | # udpate Makefile with the configure results | 791 | # udpate Makefile with the configure results |
776 | sed < Makefile.in " | 792 | sed < ${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 |
806 | sed < zlib.pc.in " | 825 | sed < ${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# |