1 | #!/bin/bash |
---|
2 | |
---|
3 | # cross-lfs target binutils build |
---|
4 | # ------------------------------- |
---|
5 | # $LastChangedBy$ |
---|
6 | # $LastChangedDate$ |
---|
7 | # $LastChangedRevision$ |
---|
8 | # $HeadURL$ |
---|
9 | # |
---|
10 | |
---|
11 | cd ${SRC} |
---|
12 | LOG="binutils-target.log" |
---|
13 | |
---|
14 | set_libdirname |
---|
15 | setup_multiarch |
---|
16 | |
---|
17 | if [ "${USE_SYSROOT}" = "Y" ]; then |
---|
18 | BUILD_PREFIX=/usr |
---|
19 | INSTALL_PREFIX="${LFS}${BUILD_PREFIX}" |
---|
20 | INSTALL_OPTIONS="DESTDIR=${LFS}" |
---|
21 | else |
---|
22 | BUILD_PREFIX=${TGT_TOOLS} |
---|
23 | INSTALL_PREFIX="${TGT_TOOLS}" |
---|
24 | INSTALL_OPTIONS="" |
---|
25 | fi |
---|
26 | |
---|
27 | if [ ! "${libdirname}" = "lib" ]; then |
---|
28 | extra_conf="--libdir=${BUILD_PREFIX}/${libdirname}" |
---|
29 | fi |
---|
30 | |
---|
31 | |
---|
32 | # HACK |
---|
33 | if [ ! "X${TGT_CFLAGS}" = "X" ]; then |
---|
34 | ARCH_CFLAGS="${TGT_CFLAGS} ${ARCH_CFLAGS}" |
---|
35 | fi |
---|
36 | |
---|
37 | # if target is same as build host, adjust build slightly to avoid running |
---|
38 | # configure checks which we cannot run |
---|
39 | if [ "${TARGET}" = "${BUILD}" ]; then |
---|
40 | BUILD=`echo ${BUILD} | sed 's@\([_a-zA-Z0-9]*\)\(-[_a-zA-Z0-9]*\)\(.*\)@\1\2x\3@'` |
---|
41 | fi |
---|
42 | |
---|
43 | unpack_tarball binutils-${BINUTILS_VER} && |
---|
44 | |
---|
45 | # Determine whether this binutils requires |
---|
46 | # 'make configure-host' and whether |
---|
47 | # ld search path can be set with --with-lib-path. |
---|
48 | # Returned in ${BINUTILS_CONF_HOST} and |
---|
49 | # ${BINUTILS_WITH_LIB_PATH} respectively |
---|
50 | |
---|
51 | # TODO: check for architecture specific patches in check_binutils |
---|
52 | # ( alpha ) |
---|
53 | check_binutils |
---|
54 | |
---|
55 | cd ${SRC}/${PKGDIR} |
---|
56 | |
---|
57 | case ${BINUTILS_VER} in |
---|
58 | # 20031015 - fix static linking issues during testsuite |
---|
59 | # with current CVS glibc. kernel 2.5.68+ |
---|
60 | # Will only patch HJL 2.14.90.0.[6-7] |
---|
61 | 2.14.90.0.[6-7] ) apply_patch binutils-2.14.90.0.7-fix-static-link ;; |
---|
62 | |
---|
63 | # Issue with HJL binutils 2.15.94.0.1 stripping needed information |
---|
64 | # one manifestation is with stripping TLS info from libc.a |
---|
65 | 2.15.94.0.1 ) apply_patch binutils-2.15.94.0.1-fix-strip-1 ;; |
---|
66 | esac |
---|
67 | |
---|
68 | ## Check if we have sysroot set |
---|
69 | if [ ! "${USE_SYSROOT}" = "Y" ]; then |
---|
70 | # sysroot not set, just set libpath |
---|
71 | test Y == "${BINUTILS_WITH_LIB_PATH}" && |
---|
72 | BINUTILS_LIB_PATH="--with-lib-path=${TGT_TOOLS}/lib" || |
---|
73 | BINUTILS_LIB_PATH="" |
---|
74 | fi |
---|
75 | |
---|
76 | # These are probably not required for sysrooted builds, but |
---|
77 | # they don't hurt... |
---|
78 | case ${BINUTILS_VER} in |
---|
79 | 2.14 ) |
---|
80 | apply_patch binutils-2.14-genscripts-multilib |
---|
81 | ;; |
---|
82 | 2.14.90.0.8 ) |
---|
83 | apply_patch binutils-2.14.90.0.8-genscripts-multilib |
---|
84 | ;; |
---|
85 | 2.15.9[0124].0.* | 2.15 ) |
---|
86 | apply_patch binutils-2.15.91.0.1-genscripts-multilib-2 |
---|
87 | ;; |
---|
88 | 2.16* ) |
---|
89 | apply_patch binutils-2.15.91.0.1-genscripts-multilib-2 |
---|
90 | ;; |
---|
91 | esac |
---|
92 | |
---|
93 | cd ${SRC} |
---|
94 | |
---|
95 | # Remove pre-existing build directory and recreate |
---|
96 | test -d binutils-${BINUTILS_VER}-target-build && |
---|
97 | rm -rf binutils-${BINUTILS_VER}-target-build |
---|
98 | |
---|
99 | mkdir binutils-${BINUTILS_VER}-target-build |
---|
100 | cd binutils-${BINUTILS_VER}-target-build |
---|
101 | |
---|
102 | max_log_init Binutils ${BINUTILS_VER} target ${CONFLOGS} ${LOG} |
---|
103 | CC="${TARGET}-gcc ${ARCH_CFLAGS}" ../${PKGDIR}/configure \ |
---|
104 | --prefix=${BUILD_PREFIX} \ |
---|
105 | --build=${BUILD} \ |
---|
106 | --host=${TARGET} \ |
---|
107 | --target=${TARGET} \ |
---|
108 | --disable-nls ${extra_conf} \ |
---|
109 | --enable-shared \ |
---|
110 | --enable-64-bit-bfd ${BINUTILS_LIB_PATH} \ |
---|
111 | >> ${LOGFILE} 2>&1 && |
---|
112 | { |
---|
113 | # Run make configure-host if required |
---|
114 | test Y != "${BINUTILS_CONF_HOST}" || |
---|
115 | { |
---|
116 | echo -e "\nmake configure-host\n${BRKLN}" >> ${LOGFILE} |
---|
117 | make configure-host >> ${LOGFILE} 2>&1 |
---|
118 | } |
---|
119 | } && |
---|
120 | echo " o Configure OK" && |
---|
121 | |
---|
122 | min_log_init ${BUILDLOGS} && |
---|
123 | make headers -C bfd \ |
---|
124 | >> ${LOGFILE} 2>&1 && |
---|
125 | make \ |
---|
126 | >> ${LOGFILE} 2>&1 && |
---|
127 | echo " o Build OK" || barf |
---|
128 | |
---|
129 | min_log_init ${INSTLOGS} && |
---|
130 | make ${INSTALL_OPTIONS} install \ |
---|
131 | >> ${LOGFILE} 2>&1 && |
---|
132 | echo " o All OK" || barf |
---|
133 | |
---|
134 | # Copy over libiberty.h |
---|
135 | cp -p ${SRC}/${PKGDIR}/include/libiberty.h ${INSTALL_PREFIX}/include/libiberty.h |
---|