diff --git a/Makefile.in b/Makefile.in index 5a77949ff0..e69f2cac66 100644 --- a/Makefile.in +++ b/Makefile.in @@ -47,12 +47,13 @@ EXE= prefix = /usr/local exec_prefix = ${prefix} -libdir = ${exec_prefix}/lib -sharedlibdir = ${libdir} +staticlibdir = ${exec_prefix}/lib +sharedlibdir = ${exec_prefix}/lib includedir = ${prefix}/include mandir = ${prefix}/share/man man3dir = ${mandir}/man3 -pkgconfigdir = ${libdir}/pkgconfig +staticpkgconfigdir = ${staticlibdir}/pkgconfig +sharedpkgconfigdir = ${sharedlibdir}/pkgconfig SRCDIR= ZINC= ZINCOUT=-I. @@ -305,14 +306,15 @@ minigzip64$(EXE): minigzip64.o $(STATICLIB) install-libs: $(LIBS) -@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi - -@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi + -@if [ ! -d $(DESTDIR)$(staticlibdir) ]; then mkdir -p $(DESTDIR)$(staticlibdir); fi -@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi -@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi - -@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi - rm -f $(DESTDIR)$(libdir)/$(STATICLIB) - cp $(STATICLIB) $(DESTDIR)$(libdir) - chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB) - -@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1 + -@if [ ! -d $(DESTDIR)$(staticpkgconfigdir) ]; then mkdir -p $(DESTDIR)$(staticpkgconfigdir); fi + -@if [ ! -d $(DESTDIR)$(sharedpkgconfigdir) ]; then mkdir -p $(DESTDIR)$(sharedpkgconfigdir); fi + rm -f $(DESTDIR)$(staticlibdir)/$(STATICLIB) + cp $(STATICLIB) $(DESTDIR)$(staticlibdir) + chmod 644 $(DESTDIR)$(staticlibdir)/$(STATICLIB) + -@($(RANLIB) $(DESTDIR)$(staticlibdir)/libz.a || true) >/dev/null 2>&1 -@if test -n "$(SHAREDLIBV)"; then \ rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \ cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \ @@ -327,9 +329,12 @@ install-libs: $(LIBS) rm -f $(DESTDIR)$(man3dir)/zlib.3 cp $(SRCDIR)zlib.3 $(DESTDIR)$(man3dir) chmod 644 $(DESTDIR)$(man3dir)/zlib.3 - rm -f $(DESTDIR)$(pkgconfigdir)/zlib.pc - cp zlib.pc $(DESTDIR)$(pkgconfigdir) - chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc + rm -f $(DESTDIR)$(staticpkgconfigdir)/zlib.pc + cp zlib.pc.static $(DESTDIR)$(staticpkgconfigdir) + chmod 644 $(DESTDIR)$(staticpkgconfigdir)/zlib.pc + rm -f $(DESTDIR)$(sharedpkgconfigdir)/zlib.pc + cp zlib.pc.shared $(DESTDIR)$(sharedpkgconfigdir) + chmod 644 $(DESTDIR)$(sharedpkgconfigdir)/zlib.pc # The ranlib in install is needed on NeXTSTEP which checks file times # ldconfig is for Linux @@ -341,12 +346,13 @@ install: install-libs uninstall: cd $(DESTDIR)$(includedir) && rm -f zlib.h zconf.h - cd $(DESTDIR)$(libdir) && rm -f libz.a; \ + cd $(DESTDIR)$(staticlibdir) && rm -f libz.a; \ if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \ rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \ fi cd $(DESTDIR)$(man3dir) && rm -f zlib.3 - cd $(DESTDIR)$(pkgconfigdir) && rm -f zlib.pc + cd $(DESTDIR)$(staticpkgconfigdir) && rm -f zlib.pc + cd $(DESTDIR)$(sharedpkgconfigdir) && rm -f zlib.pc docs: zlib.3.pdf @@ -377,7 +383,7 @@ clean: maintainer-clean: distclean distclean: clean zconf zconf.h.cmakein docs - rm -f Makefile zlib.pc configure.log + rm -f Makefile zlib.pc.static zlib.pc.shared configure.log -@rm -f .DS_Store @if [ -f Makefile.in ]; then \ printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile ; \ diff --git a/configure b/configure index e974d1fd79..83438d7225 100755 --- a/configure +++ b/configure @@ -2,7 +2,7 @@ # configure script for zlib. # # Normally configure builds both a static and a shared library. -# If you want to build just a static library, use: ./configure --static +# If you want to build just a static library, use: ./configure --disable-shared # # To impose specific compiler or flags or install directory, use for example: # prefix=$HOME CC=cc CFLAGS="-O4" ./configure @@ -74,11 +74,11 @@ ARCHS= prefix=${prefix-/usr/local} exec_prefix=${exec_prefix-'${prefix}'} libdir=${libdir-'${exec_prefix}/lib'} -sharedlibdir=${sharedlibdir-'${libdir}'} includedir=${includedir-'${prefix}/include'} mandir=${mandir-'${prefix}/share/man'} shared_ext='.so' shared=1 +static=1 solo=0 cover=0 zprefix=0 @@ -112,12 +112,15 @@ case "$1" in -h* | --help) echo 'usage:' | tee -a configure.log echo ' configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log - echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log + echo ' [--64] [--libdir=LIBDIR]' | tee -a configure.log + echo ' [--[enable-|disable-|]static] [--staticlibdir=LIBDIR]' | tee -a configure.log + echo ' [--[enable-|disable-|]shared] [--sharedlibdir=LIBDIR]' | tee -a configure.log echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log exit 0 ;; -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;; -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;; -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;; + --staticlibdir=*) staticlibdir=`echo $1 | sed 's/.*=//'`; shift ;; --sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;; -i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;; -u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;; @@ -125,8 +128,12 @@ case "$1" in -e* | --eprefix) exec_prefix="$2"; shift; shift ;; -l* | --libdir) libdir="$2"; shift; shift ;; -i* | --includedir) includedir="$2"; shift; shift ;; - -s* | --shared | --enable-shared) shared=1; shift ;; - -t | --static) shared=0; shift ;; + -t | --static) shared=0; static=1; shift ;; # probably should deprecate + --disable-static) static=0; shift ;; + --enable-static) static=1; shift ;; + -s* | --shared) shared=1; shift ;; # probably should deprecate + --disable-shared) shared=0; shift ;; + --enable-shared) shared=1; shift ;; --solo) solo=1; shift ;; --cover) cover=1; shift ;; -z* | --zprefix) zprefix=1; shift ;; @@ -144,6 +151,10 @@ case "$1" in esac done +# Process these after since their default is influenced by other flags +staticlibdir=${staticlibdir-'${libdir}'} +sharedlibdir=${sharedlibdir-'${libdir}'} + # temporary file name test=ztest$$ @@ -240,7 +251,7 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then SHAREDLIB=libz$shared_ext SHAREDLIBV=libz.$VER$shared_ext SHAREDLIBM=libz.$VER1$shared_ext - LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} + LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $sharedlibdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} if libtool -V 2>&1 | grep Apple > /dev/null; then AR="libtool" else @@ -276,7 +287,7 @@ else OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"} CFLAGS=${CFLAGS-"-O -std1"} LDFLAGS="${LDFLAGS} -Wl,-rpath,." - LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;; + LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(sharedlibdir) -Wl,-set_version,${VER}:1.0"} ;; OSF1*) SFLAGS=${CFLAGS-"-O -std1"} CFLAGS=${CFLAGS-"-O -std1"} LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;; @@ -853,9 +864,9 @@ echo Z_U4 = $Z_U4 >> configure.log echo SRCDIR = $SRCDIR >> configure.log echo exec_prefix = $exec_prefix >> configure.log echo includedir = $includedir >> configure.log -echo libdir = $libdir >> configure.log echo mandir = $mandir >> configure.log echo prefix = $prefix >> configure.log +echo staticlibdir = $staticlibdir >> configure.log echo sharedlibdir = $sharedlibdir >> configure.log echo uname = $uname >> configure.log @@ -882,7 +893,7 @@ sed < ${SRCDIR}Makefile.in " /^ZINCOUT *=/s#=.*#=$ZINCOUT# /^prefix *=/s#=.*#=$prefix# /^exec_prefix *=/s#=.*#=$exec_prefix# -/^libdir *=/s#=.*#=$libdir# +/^staticlibdir *=/s#=.*#=$staticlibdir# /^sharedlibdir *=/s#=.*#=$sharedlibdir# /^includedir *=/s#=.*#=$includedir# /^mandir *=/s#=.*#=$mandir# @@ -893,29 +904,37 @@ sed < ${SRCDIR}Makefile.in " " > Makefile # create zlib.pc with the configure results -sed < ${SRCDIR}zlib.pc.in " -/^CC *=/s#=.*#=$CC# -/^CFLAGS *=/s#=.*#=$CFLAGS# -/^CPP *=/s#=.*#=$CPP# -/^LDSHARED *=/s#=.*#=$LDSHARED# -/^STATICLIB *=/s#=.*#=$STATICLIB# -/^SHAREDLIB *=/s#=.*#=$SHAREDLIB# -/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV# -/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM# -/^AR *=/s#=.*#=$AR# -/^ARFLAGS *=/s#=.*#=$ARFLAGS# -/^RANLIB *=/s#=.*#=$RANLIB# -/^EXE *=/s#=.*#=$EXE# -/^prefix *=/s#=.*#=$prefix# -/^exec_prefix *=/s#=.*#=$exec_prefix# -/^libdir *=/s#=.*#=$libdir# -/^sharedlibdir *=/s#=.*#=$sharedlibdir# -/^includedir *=/s#=.*#=$includedir# -/^mandir *=/s#=.*#=$mandir# -/^LDFLAGS *=/s#=.*#=$LDFLAGS# -" | sed -e " -s/\@VERSION\@/$VER/g; -" > zlib.pc +function mkPkgConfig() { + libdir=$1 + outfile=$2 + sed < ${SRCDIR}zlib.pc.in " + /^CC *=/s#=.*#=$CC# + /^CFLAGS *=/s#=.*#=$CFLAGS# + /^CPP *=/s#=.*#=$CPP# + /^LDSHARED *=/s#=.*#=$LDSHARED# + /^STATICLIB *=/s#=.*#=$STATICLIB# + /^SHAREDLIB *=/s#=.*#=$SHAREDLIB# + /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV# + /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM# + /^AR *=/s#=.*#=$AR# + /^ARFLAGS *=/s#=.*#=$ARFLAGS# + /^RANLIB *=/s#=.*#=$RANLIB# + /^EXE *=/s#=.*#=$EXE# + /^prefix *=/s#=.*#=$prefix# + /^exec_prefix *=/s#=.*#=$exec_prefix# + /^libdir *=/s#=.*#=$libdir# + /^includedir *=/s#=.*#=$includedir# + /^mandir *=/s#=.*#=$mandir# + /^LDFLAGS *=/s#=.*#=$LDFLAGS# + " | sed -e " + s/\@VERSION\@/$VER/g; + " > "$outfile" +} + +# If the two directories are the same, these will be installed on top of each +# other. But they'll also have the same content, so all will be well. +mkPkgConfig "$sharedlibdir" zlib.pc.shared +mkPkgConfig "$staticlibdir" zlib.pc.static # done leave 0 diff --git a/zlib.pc.in b/zlib.pc.in index 7e5acf9c77..b4f98e5e61 100644 --- a/zlib.pc.in +++ b/zlib.pc.in @@ -1,7 +1,6 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ -sharedlibdir=@sharedlibdir@ includedir=@includedir@ Name: zlib @@ -9,5 +8,5 @@ Description: zlib compression library Version: @VERSION@ Requires: -Libs: -L${libdir} -L${sharedlibdir} -lz +Libs: -L${libdir} -lz Cflags: -I${includedir}