1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # cross-lfs native zlib build
|
---|
4 | # ---------------------------
|
---|
5 | # $LastChangedBy$
|
---|
6 | # $LastChangedDate$
|
---|
7 | # $LastChangedRevision$
|
---|
8 | # $HeadURL$
|
---|
9 | #
|
---|
10 |
|
---|
11 | LOG=zlib-native.log
|
---|
12 |
|
---|
13 | SELF=`basename ${0}`
|
---|
14 | set_buildenv
|
---|
15 | set_libdirname
|
---|
16 | setup_multiarch
|
---|
17 | if [ ! "${libdirname}" = "lib" ]; then
|
---|
18 | extra_conf="--libdir=/usr/${libdirname}"
|
---|
19 | fi
|
---|
20 |
|
---|
21 | cd ${SRC}
|
---|
22 | unpack_tarball zlib-${ZLIB_VER}
|
---|
23 | cd ${PKGDIR}
|
---|
24 |
|
---|
25 | #TODO - fix this for later zlibs
|
---|
26 | test "1.1.4" = "${ZLIB_VER}" &&
|
---|
27 | {
|
---|
28 | # Fix up zlibs Makefile so we can properly pass in LDFLAGS from
|
---|
29 | # the env without clobbering existing settings for zlib build
|
---|
30 | test -f Makefile.in-ORIG ||
|
---|
31 | cp Makefile.in Makefile.in-ORIG
|
---|
32 |
|
---|
33 | # make LDFLAGS in Makefile.in empty and move existing LDFLAGS
|
---|
34 | # to ZLIB_LDFLAGS. Append $(ZLIB_LDFLAGS) wherever $(LDFLAGS) exists
|
---|
35 | sed -e 's@LDFLAGS=.*@ZLIB_&@' \
|
---|
36 | -e '/ZLIB_LDFLAGS=/i\
|
---|
37 | LDFLAGS=' \
|
---|
38 | -e 's@$(LDFLAGS)@& $(ZLIB_LDFLAGS)@g' \
|
---|
39 | Makefile.in-ORIG > Makefile.in
|
---|
40 | }
|
---|
41 |
|
---|
42 | max_log_init Zlib ${ZLIB_VER} "target (shared)" ${CONFLOGS} ${LOG}
|
---|
43 |
|
---|
44 | # Check to see if we are on alpha
|
---|
45 | # Req's a fix as specified on Kelledins Alpha page
|
---|
46 | # Pointed out by J.Schmelling
|
---|
47 | case "${TGT_ARCH}" in
|
---|
48 | alpha | x86_64 ) extra_cflags="-fPIC" ;;
|
---|
49 | esac
|
---|
50 | # NOTE: It's probably not a bad idea in general to enable -fPIC...
|
---|
51 |
|
---|
52 | test "1.1.4" = "${ZLIB_VER}" &&
|
---|
53 | {
|
---|
54 | # Apply Kelledin's vsnprintf patch
|
---|
55 | # see http://archive.linuxfromscratch.org/lfs-dev/2003/02/.....
|
---|
56 | apply_patch zlib-${ZLIB_VER}-vsnprintf
|
---|
57 | CC="${CC-gcc} ${ARCH_CFLAGS}" \
|
---|
58 | CXX="${CXX-g++} ${ARCH_CFLAGS}" \
|
---|
59 | CFLAGS="-O2 -pipe ${extra_cflags} ${TGT_CFLAGS}" \
|
---|
60 | CPPFLAGS="-DHAS_vsnprintf" \
|
---|
61 | ./configure --prefix=/usr --shared ${extra_conf} \
|
---|
62 | >> ${LOGFILE} 2>&1
|
---|
63 | } || {
|
---|
64 | CC="${CC-gcc} ${ARCH_CFLAGS}" \
|
---|
65 | CXX="${CXX-g++} ${ARCH_CFLAGS}" \
|
---|
66 | CFLAGS="-O2 -pipe ${extra_cflags} ${TGT_CFLAGS}" \
|
---|
67 | ./configure --prefix=/usr \
|
---|
68 | --shared ${extra_conf} \
|
---|
69 | >> ${LOGFILE} 2>&1
|
---|
70 | }
|
---|
71 | echo " o Configure OK" &&
|
---|
72 |
|
---|
73 | min_log_init ${BUILDLOGS} &&
|
---|
74 | make ${PMFLAGS} \
|
---|
75 | >> ${LOGFILE} 2>&1 &&
|
---|
76 | echo " o Build OK" || barf
|
---|
77 |
|
---|
78 | min_log_init ${TESTLOGS} &&
|
---|
79 | make test \
|
---|
80 | >> ${LOGFILE} 2>&1 &&
|
---|
81 | echo " o Test OK" || errmsg
|
---|
82 |
|
---|
83 | min_log_init ${INSTLOGS} &&
|
---|
84 | make LIBS="libz.so.${ZLIB_VER} libz.a" install \
|
---|
85 | >> ${LOGFILE} 2>&1 &&
|
---|
86 | echo " o Install OK" || barf
|
---|
87 |
|
---|
88 | mv /usr/${libdirname}/libz.so.* /${libdirname}
|
---|
89 | ln -sf ../../${libdirname}/libz.so.1 /usr/${libdirname}/libz.so
|
---|
90 | cp -f zlib.3 /usr/share/man/man3
|
---|
91 |
|
---|
92 | ldconfig
|
---|