Submitted By: Tushar Teredesai <tushar@linuxfromscratch.org>
Date: 2005-06-14
Initial Package Version: 1.2.2
Origin: Gentoo ebuild?
Upstream Status: Not submitted
Description:
1. Build shared and static lib in one pass
2. Always add -fPIC when building shared lib, don't expect the user to set it.
To build the shared and static library:
./configure --prefix=<prefix> --shared &&
make &&
make install
Remove the --shared if you don't want the shared lib.
diff -Naur zlib-1.2.2.orig/configure zlib-1.2.2/configure
old
|
new
|
|
73 | 73 | |
74 | 74 | if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then |
75 | 75 | CC="$cc" |
76 | | SFLAGS=${CFLAGS-"-fPIC -O3"} |
| 76 | #SFLAGS=${CFLAGS-"-fPIC -O3"} |
| 77 | # the above is horribly wrong on a few archs where -fPIC should ALWAYS be |
| 78 | # used in the creation of shared libraries. without the following, the |
| 79 | # shared lib test will sometimes fail even when shared libs -can- be created. |
| 80 | SFLAGS="${CFLAGS-"-O3"} -fPIC" |
77 | 81 | CFLAGS="$cflags" |
78 | 82 | case `(uname -s || echo unknown) 2>/dev/null` in |
79 | 83 | Linux | linux | GNU | GNU/*) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};; |
… |
… |
|
158 | 162 | if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" && |
159 | 163 | test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then |
160 | 164 | CFLAGS="$SFLAGS" |
161 | | LIBS="$SHAREDLIBV" |
| 165 | LIBS="$LIBS $SHAREDLIBV" |
162 | 166 | echo Building shared library $SHAREDLIBV with $CC. |
163 | 167 | elif test -z "$old_cc" -a -z "$old_cflags"; then |
164 | 168 | echo No shared library support. |
diff -Naur zlib-1.2.2.orig/Makefile.in zlib-1.2.2/Makefile.in
old
|
new
|
|
49 | 49 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ |
50 | 50 | zutil.o inflate.o infback.o inftrees.o inffast.o |
51 | 51 | |
| 52 | PIC_OBJS = $(OBJS:%.o=%.lo) |
| 53 | |
52 | 54 | OBJA = |
53 | 55 | # to use the asm code: make OBJA=match.o |
54 | 56 | |
… |
… |
|
77 | 79 | mv _match.o match.o |
78 | 80 | rm -f _match.s |
79 | 81 | |
80 | | $(SHAREDLIBV): $(OBJS) |
81 | | $(LDSHARED) -o $@ $(OBJS) |
| 82 | %.lo: %.c |
| 83 | $(CC) $(CFLAGS) -DPIC -fPIC -c $< -o $@ |
| 84 | |
| 85 | $(SHAREDLIBV): $(PIC_OBJS) |
| 86 | $(LDSHARED) -o $@ $(PIC_OBJS) -lc |
82 | 87 | rm -f $(SHAREDLIB) $(SHAREDLIBM) |
83 | 88 | ln -s $@ $(SHAREDLIB) |
84 | 89 | ln -s $@ $(SHAREDLIBM) |
… |
… |
|
89 | 94 | minigzip$(EXE): minigzip.o $(LIBS) |
90 | 95 | $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) |
91 | 96 | |
92 | | install: $(LIBS) |
| 97 | install-libs: $(LIBS) |
93 | 98 | -@if [ ! -d $(exec_prefix) ]; then mkdir -p $(exec_prefix); fi |
94 | | -@if [ ! -d $(includedir) ]; then mkdir -p $(includedir); fi |
95 | 99 | -@if [ ! -d $(libdir) ]; then mkdir -p $(libdir); fi |
96 | 100 | -@if [ ! -d $(man3dir) ]; then mkdir -p $(man3dir); fi |
97 | | cp zlib.h zconf.h $(includedir) |
98 | | chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h |
99 | 101 | cp $(LIBS) $(libdir) |
100 | 102 | cd $(libdir); chmod 755 $(LIBS) |
101 | 103 | -@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1 |
… |
… |
|
110 | 112 | # The ranlib in install is needed on NeXTSTEP which checks file times |
111 | 113 | # ldconfig is for Linux |
112 | 114 | |
| 115 | install: install-libs |
| 116 | -@if [ ! -d $(includedir) ]; then mkdir $(includedir); fi |
| 117 | cp zlib.h zconf.h $(includedir) |
| 118 | chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h |
| 119 | |
113 | 120 | uninstall: |
114 | 121 | cd $(includedir); \ |
115 | 122 | cd $(libdir); rm -f libz.a; \ |