1 diff --git a/Makefile.in b/Makefile.in
2 index 2fd6e45..eb980dc 100755
5 @@ -28,10 +28,14 @@ LDFLAGS=libz.a
12 SHAREDLIBV=libz.so.1.2.3
15 +SHAREDLIBPOST='(rm -f $(SHAREDLIB) $(SHAREDLIBM); ln -s $@ $(SHAREDLIB) ; ln -s $@ $(SHAREDLIBM) )'
16 +SHAREDTARGET=$(SHAREDLIBV)
21 @@ -42,6 +46,7 @@ EXE=
23 exec_prefix = ${prefix}
24 libdir = ${exec_prefix}/lib
25 +bindir = ${exec_prefix}/bin
26 includedir = ${prefix}/include
27 mandir = ${prefix}/share/man
28 man3dir = ${mandir}/man3
29 @@ -67,7 +72,7 @@ test: all
30 echo ' *** zlib test FAILED ***'; \
33 -libz.a: $(OBJS) $(OBJA)
34 +$(STATICLIB): $(OBJS) $(OBJA)
35 $(AR) $@ $(OBJS) $(OBJA)
36 -@ ($(RANLIB) $@ || true) >/dev/null 2>&1
38 @@ -77,11 +82,9 @@ match.o: match.S
42 -$(SHAREDLIBV): $(OBJS)
43 +$(SHAREDTARGET): $(OBJS)
44 $(LDSHARED) -o $@ $(OBJS)
45 - rm -f $(SHAREDLIB) $(SHAREDLIBM)
46 - ln -s $@ $(SHAREDLIB)
47 - ln -s $@ $(SHAREDLIBM)
50 example$(EXE): example.o $(LIBS)
51 $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
52 @@ -90,37 +93,58 @@ minigzip$(EXE): minigzip.o $(LIBS)
53 $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
56 - -@if [ ! -d $(exec_prefix) ]; then mkdir -p $(exec_prefix); fi
57 - -@if [ ! -d $(includedir) ]; then mkdir -p $(includedir); fi
58 - -@if [ ! -d $(libdir) ]; then mkdir -p $(libdir); fi
59 - -@if [ ! -d $(man3dir) ]; then mkdir -p $(man3dir); fi
60 - cp zlib.h zconf.h $(includedir)
61 - chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h
62 - cp $(LIBS) $(libdir)
63 - cd $(libdir); chmod 755 $(LIBS)
64 - -@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
65 - cd $(libdir); if test -f $(SHAREDLIBV); then \
66 - rm -f $(SHAREDLIB) $(SHAREDLIBM); \
67 - ln -s $(SHAREDLIBV) $(SHAREDLIB); \
68 - ln -s $(SHAREDLIBV) $(SHAREDLIBM); \
69 - (ldconfig || true) >/dev/null 2>&1; \
71 - cp zlib.3 $(man3dir)
72 - chmod 644 $(man3dir)/zlib.3
73 + -@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
74 + -@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi
75 + -@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi
76 + -@if [ ! -d $(DESTDIR)$(bindir) ]; then mkdir -p $(DESTDIR)$(bindir); fi
77 + -@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi
78 + cp zlib.h zconf.h $(DESTDIR)$(includedir)
79 + chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
80 + cp zlib.3 $(DESTDIR)$(man3dir)
81 + chmod 644 $(DESTDIR)$(man3dir)/zlib.3
82 +# Install static lib (and import lib, if set) into libdir
83 # The ranlib in install is needed on NeXTSTEP which checks file times
84 + -cp $(STATICLIB) $(IMPORTLIB) $(DESTDIR)$(libdir)
85 + -@(cd $(DESTDIR)$(libdir); \
86 + $(RANLIB) libz.a || true; \
87 + chmod 755 $(STATICLIB) $(IMPORTLIB)) >/dev/null 2>&1
88 +# Install shared lib -- if IMPORTLIB is set, then sharedlib goes into bindir
89 # ldconfig is for Linux
90 + if test -z "$(IMPORTLIB)" ; then \
91 + if test -n "$(SHAREDTARGET)" ; then \
92 + if test -f "$(SHAREDTARGET)" ; then \
93 + cp $(SHAREDTARGET) $(DESTDIR)$(libdir); \
96 + cd $(DESTDIR)$(libdir); \
97 + if test -n "$(SHAREDLIBV)" ; then \
98 + if test -f "$(SHAREDLIBV)" ; then \
99 + rm -f $(SHAREDLIB) $(SHAREDLIBM); \
100 + ln -s $(SHAREDLIBV) $(SHAREDLIB); \
101 + ln -s $(SHAREDLIBV) $(SHAREDLIBM); \
102 + (ldconfig || true) >/dev/null 2>&1; \
106 + cp $(SHAREDTARGET) $(DESTDIR)$(bindir); \
107 + (cd $(DESTDIR)$(bindir); chmod 755 $(SHAREDTARGET)); \
111 - cd $(includedir); \
112 - cd $(libdir); rm -f libz.a; \
113 - if test -f $(SHAREDLIBV); then \
114 - rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
115 + cd $(DESTDIR)$(includedir); \
116 + cd $(DESTDIR)$(libdir); rm -f $(STATICLIB) $(IMPORTLIB); \
117 + if test -f "$(SHAREDLIBV)"; then \
118 + if test -f "$(SHAREDLIBV)"; then \
119 + rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
122 - cd $(man3dir); rm -f zlib.3
123 + cd $(DESTDIR)$(man3dir); rm -f zlib.3
124 + cd $(DESTDIR)$(bindir); (rm -f $(SHAREDLIB) || true) > /dev/null 2>&1
128 rm -f *.o *~ example$(EXE) minigzip$(EXE) \
129 + $(STATICLIB) $(IMPORTLIB) $(SHAREDLIBV) $(SHAREDLIBV) $(SHAREDLIBM) \
130 libz.* foo.gz so_locations \
131 _match.s maketree contrib/infback9/*.o
133 diff --git a/configure b/configure
134 index d7ffdc3..b81ed63 100755
138 # If you have problems, try without defining CC and CFLAGS before reporting
142 -LDFLAGS="-L. ${LIBS}"
144 +old_ldflags="$LDFLAGS"
145 +LDFLAGS="-L. ${STATICLIB}"
146 VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
147 VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
148 VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
149 @@ -28,6 +29,7 @@ RANLIB=${RANLIB-"ranlib"}
150 prefix=${prefix-/usr/local}
151 exec_prefix=${exec_prefix-'${prefix}'}
152 libdir=${libdir-'${exec_prefix}/lib'}
153 +bindir=${bindir-'${exec_prefix}/bin'}
154 includedir=${includedir-'${prefix}/include'}
155 mandir=${mandir-'${prefix}/share/man'}
157 @@ -71,13 +73,32 @@ case "$cc" in
161 +BUILDPLATFORM=`(uname -s || echo unknown) 2>/dev/null`;
162 +TARGETPLATFORM=${target-${BUILDPLATFORM}}
164 if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
166 SFLAGS=${CFLAGS-"-fPIC -O3"}
168 - case `(uname -s || echo unknown) 2>/dev/null` in
169 + case ${TARGETPLATFORM} in
170 Linux | linux | GNU | GNU/*) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};;
171 - CYGWIN* | Cygwin* | cygwin* | OS/2* )
174 + *CYGWIN* | *Cygwin* | *cygwin* )
176 + LDFLAGS="-L. -lz ${old_ldflags}"
178 + SHAREDLIB='cygz.dll'
179 + IMPORTLIB='libz.dll.a'
180 + LDSHARED=${LDSHARED-"${CC} -shared -Wl,-export-all -Wl,--enable-auto-image-base -Wl,--out-implib=${IMPORTLIB}"}
182 + *MINGW* | *Mingw* | *mingw* )
184 + LDFLAGS="-L. -lz ${old_ldflags}"
186 + SHAREDLIB='libz.dll'
187 + IMPORTLIB='libz.dll.a'
188 + LDSHARED=${LDSHARED-"${CC} -shared -Wl,-export-all -Wl,--enable-auto-image-base -Wl,--out-implib=${IMPORTLIB}"}
190 QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
191 # (alain.bonnefoy@icbt.com)
192 @@ -163,6 +184,20 @@ else
193 LDSHARED=${LDSHARED-"cc -shared"};;
196 +case ${TARGETPLATFORM} in
197 + *CYGWIN* | *Cygwin* | *cygwin* )
198 + # On cygwin, we always build both shared and static libs
199 + LIBS="${SHAREDLIB} ${STATICLIB}"
200 + SHAREDLIBPOST='/bin/true'
201 + SHAREDTARGET=${SHAREDLIB}
203 + *MINGW* | *Mingw* | *mingw* )
204 + # On Mingw-cygwin-special, we always build both shared and static libs
205 + LIBS="${SHAREDLIB} ${STATICLIB}"
206 + SHAREDLIBPOST='/bin/true'
207 + SHAREDTARGET=${SHAREDLIB}
211 SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
212 SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
213 @@ -186,10 +221,14 @@ if test $shared -eq 1; then
215 if test $shared -eq 0; then
217 - echo Building static library $LIBS version $VER with $CC.
219 + LDFLAGS="-L. ${STATICLIB}"
220 + echo Building static library $STATICLIB version $VER with $CC.
222 LDFLAGS="-L. ${SHAREDLIBV}"
229 @@ -444,15 +483,20 @@ sed < Makefile.in "
230 /^CPP *=/s#=.*#=$CPP#
231 /^LDSHARED *=/s#=.*#=$LDSHARED#
232 /^LIBS *=/s#=.*#=$LIBS#
233 +/^STATICLIB *=/s#=.*#=$STATICLIB#
234 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
235 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
236 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
237 +/^IMPORTLIB *=/s#=.*#=$IMPORTLIB#
238 +/^SHAREDLIBPOST *=/s#=.*#=$SHAREDLIBPOST#
239 +/^SHAREDTARGET *=/s#=.*#=$SHAREDTARGET#
241 /^RANLIB *=/s#=.*#=$RANLIB#
242 /^EXE *=/s#=.*#=$EXE#
243 /^prefix *=/s#=.*#=$prefix#
244 /^exec_prefix *=/s#=.*#=$exec_prefix#
245 /^libdir *=/s#=.*#=$libdir#
246 +/^bindir *=/s#=.*#=$bindir#
247 /^includedir *=/s#=.*#=$includedir#
248 /^mandir *=/s#=.*#=$mandir#
249 /^LDFLAGS *=/s#=.*#=$LDFLAGS#