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