1 Submitted By: Tushar Teredesai <tushar@linuxfromscratch.org>
3 Initial Package Version: 1.2.2
5 Upstream Status: Not submitted
7 1. Build shared and static lib in one pass
8 2. Always add -fPIC when building shared lib, don't expect the user to set it.
10 To build the shared and static library:
11 ./configure --prefix=<prefix> --shared &&
14 Remove the --shared if you don't want the shared lib.
16 diff -Naur zlib-1.2.2.orig/configure zlib-1.2.2/configure
17 --- zlib-1.2.2.orig/configure 2004-09-07 00:50:06.000000000 -0500
18 +++ zlib-1.2.2/configure 2005-02-05 01:34:08.553292416 -0600
21 if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
23 - SFLAGS=${CFLAGS-"-fPIC -O3"}
24 + #SFLAGS=${CFLAGS-"-fPIC -O3"}
25 + # the above is horribly wrong on a few archs where -fPIC should ALWAYS be
26 + # used in the creation of shared libraries. without the following, the
27 + # shared lib test will sometimes fail even when shared libs -can- be created.
28 + SFLAGS="${CFLAGS-"-O3"} -fPIC"
30 case `(uname -s || echo unknown) 2>/dev/null` in
31 Linux | linux | GNU | GNU/*) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};;
33 if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
34 test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
37 + LIBS="$LIBS $SHAREDLIBV"
38 echo Building shared library $SHAREDLIBV with $CC.
39 elif test -z "$old_cc" -a -z "$old_cflags"; then
40 echo No shared library support.
41 diff -Naur zlib-1.2.2.orig/Makefile.in zlib-1.2.2/Makefile.in
42 --- zlib-1.2.2.orig/Makefile.in 2004-09-15 09:27:20.000000000 -0500
43 +++ zlib-1.2.2/Makefile.in 2005-02-05 01:33:49.703158072 -0600
45 OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
46 zutil.o inflate.o infback.o inftrees.o inffast.o
48 +PIC_OBJS = $(OBJS:%.o=%.lo)
51 # to use the asm code: make OBJA=match.o
57 -$(SHAREDLIBV): $(OBJS)
58 - $(LDSHARED) -o $@ $(OBJS)
60 + $(CC) $(CFLAGS) -DPIC -fPIC -c $< -o $@
62 +$(SHAREDLIBV): $(PIC_OBJS)
63 + $(LDSHARED) -o $@ $(PIC_OBJS) -lc
64 rm -f $(SHAREDLIB) $(SHAREDLIBM)
66 ln -s $@ $(SHAREDLIBM)
68 minigzip$(EXE): minigzip.o $(LIBS)
69 $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
72 +install-libs: $(LIBS)
73 -@if [ ! -d $(exec_prefix) ]; then mkdir -p $(exec_prefix); fi
74 - -@if [ ! -d $(includedir) ]; then mkdir -p $(includedir); fi
75 -@if [ ! -d $(libdir) ]; then mkdir -p $(libdir); fi
76 -@if [ ! -d $(man3dir) ]; then mkdir -p $(man3dir); fi
77 - cp zlib.h zconf.h $(includedir)
78 - chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h
80 cd $(libdir); chmod 755 $(LIBS)
81 -@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
83 # The ranlib in install is needed on NeXTSTEP which checks file times
84 # ldconfig is for Linux
86 +install: install-libs
87 + -@if [ ! -d $(includedir) ]; then mkdir $(includedir); fi
88 + cp zlib.h zconf.h $(includedir)
89 + chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h
93 cd $(libdir); rm -f libz.a; \