Mercurial > hg > aboriginal
comparison root-filesystem.sh @ 820:d1a88d878e18
Factor out and unify binutils, gcc, and ccwrap builds.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 17 Sep 2009 04:06:02 -0500 |
parents | da1ebb2e22d3 |
children | 18fa21056b01 f80c47e8991d |
comparison
equal
deleted
inserted
replaced
819:da1ebb2e22d3 | 820:d1a88d878e18 |
---|---|
47 mkdir -p "$STAGE_DIR/bin" || dienow | 47 mkdir -p "$STAGE_DIR/bin" || dienow |
48 fi | 48 fi |
49 | 49 |
50 # Build uClibc | 50 # Build uClibc |
51 | 51 |
52 STAGE_DIR="$ROOT_TOPDIR" . "$SOURCES"/sections/uClibc.sh | 52 STAGE_DIR="$ROOT_TOPDIR" build_section uClibc |
53 | 53 |
54 if [ "$NATIVE_TOOLCHAIN" == "none" ] | 54 if [ "$NATIVE_TOOLCHAIN" == "none" ] |
55 then | 55 then |
56 # If we're not installing a compiler, delete the headers, static libs, | 56 # If we're not installing a compiler, delete the headers, static libs, |
57 # and example source code. | 57 # and example source code. |
67 # so do nothing here. | 67 # so do nothing here. |
68 echo | 68 echo |
69 | 69 |
70 else | 70 else |
71 | 71 |
72 # Build and install native binutils | 72 # Build binutils, gcc, and ccwrap |
73 | 73 |
74 setupfor binutils build-binutils | 74 STAGE_DIR="$ROOT_TOPDIR" build_section binutils-gcc |
75 CC="${FROM_ARCH}-cc" AR="${FROM_ARCH}-ar" "${CURSRC}/configure" --prefix="$ROOT_TOPDIR" \ | |
76 --build="${CROSS_HOST}" --host="${FROM_HOST}" --target="${CROSS_TARGET}" \ | |
77 --disable-nls --disable-shared --disable-multilib --disable-werror \ | |
78 --program-prefix="$PROGRAM_PREFIX" $BINUTILS_FLAGS && | |
79 make -j $CPUS configure-host && | |
80 make -j $CPUS CFLAGS="-O2 $STATIC_FLAGS" && | |
81 make -j $CPUS install && | |
82 mkdir -p "$ROOT_TOPDIR/include" && | |
83 cp "$CURSRC/include/libiberty.h" "$ROOT_TOPDIR/include" | |
84 | |
85 cleanup build-binutils | |
86 | |
87 # Build and install native gcc, with c++ support this time. | |
88 | |
89 setupfor gcc-core build-gcc | |
90 setupfor gcc-g++ build-gcc gcc-core | |
91 # GCC tries to "help out in the kitchen" by screwing up the linux include | |
92 # files. Cut out those bits with sed and throw them away. | |
93 sed -i 's@^STMP_FIX.*@@' "${CURSRC}/gcc/Makefile.in" && | |
94 # GCC has some deep assumptions about the name of the cross-compiler it should | |
95 # be using. These assumptions are wrong, and lots of redundant corrections | |
96 # are required to make it stop. | |
97 CC="${FROM_ARCH}-cc" AR="${FROM_ARCH}-ar" AS="${FROM_ARCH}-as" \ | |
98 LD="${FROM_ARCH}-ld" NM="${FROM_ARCH}-nm" \ | |
99 CC_FOR_TARGET="${ARCH}-cc" AR_FOR_TARGET="${ARCH}-ar" \ | |
100 NM_FOR_TARGET="${ARCH}-nm" GCC_FOR_TARGET="${ARCH}-cc" \ | |
101 AS_FOR_TARGET="${ARCH}-as" LD_FOR_TARGET="${ARCH}-ld" \ | |
102 CXX_FOR_TARGET="${ARCH}-g++" \ | |
103 ac_cv_path_AR_FOR_TARGET="${ARCH}-ar" \ | |
104 ac_cv_path_RANLIB_FOR_TARGET="${ARCH}-ranlib" \ | |
105 ac_cv_path_NM_FOR_TARGET="${ARCH}-nm" \ | |
106 ac_cv_path_AS_FOR_TARGET="${ARCH}-as" \ | |
107 ac_cv_path_LD_FOR_TARGET="${ARCH}-ld" \ | |
108 "${CURSRC}/configure" --prefix="$ROOT_TOPDIR" --disable-multilib \ | |
109 --build="${CROSS_HOST}" --host="${CROSS_TARGET}" --target="${CROSS_TARGET}" \ | |
110 --enable-long-long --enable-c99 --enable-shared --enable-threads=posix \ | |
111 --enable-__cxa_atexit --disable-nls --enable-languages=c,c++ \ | |
112 --disable-libstdcxx-pch --program-prefix="$PROGRAM_PREFIX" \ | |
113 $GCC_FLAGS && | |
114 mkdir gcc && | |
115 ln -s `which "${ARCH}-gcc"` gcc/xgcc && | |
116 make -j $CPUS configure-host && | |
117 make -j $CPUS all-gcc LDFLAGS="$STATIC_FLAGS" && | |
118 # Work around gcc bug; we disabled multilib but it doesn't always notice. | |
119 ln -s lib "$ROOT_TOPDIR/lib64" && | |
120 make -j $CPUS install-gcc && | |
121 rm "$ROOT_TOPDIR/lib64" && | |
122 ln -s "${PROGRAM_PREFIX}gcc" "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}cc" && | |
123 # Now we need to beat libsupc++ out of gcc (which uClibc++ needs to build). | |
124 # But don't want to build the whole of libstdc++-v3 because | |
125 # A) we're using uClibc++ instead, B) the build breaks. | |
126 make -j $CPUS configure-target-libstdc++-v3 && | |
127 cd "$CROSS_TARGET"/libstdc++-v3/libsupc++ && | |
128 make -j $CPUS && | |
129 mv .libs/libsupc++.a "$ROOT_TOPDIR"/lib && | |
130 | |
131 # We're done with that source and could theoretically cleanup gcc-core and | |
132 # build-gcc here, but we still need the timestamps if we do binary packaging. | |
133 | |
134 # Move the gcc internal libraries and headers somewhere sane | |
135 | |
136 mkdir -p "$ROOT_TOPDIR"/gcc && | |
137 mv "$ROOT_TOPDIR"/lib/gcc/*/*/include "$ROOT_TOPDIR"/gcc/include && | |
138 mv "$ROOT_TOPDIR"/lib/gcc/*/* "$ROOT_TOPDIR"/gcc/lib && | |
139 | |
140 # Rub gcc's nose in the binutils output. | |
141 cd "$ROOT_TOPDIR"/libexec/gcc/*/*/ && | |
142 cp -s "../../../../$CROSS_TARGET/bin/"* . && | |
143 | |
144 # build and install gcc wrapper script. | |
145 mv "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}gcc" "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}rawgcc" && | |
146 "${FROM_ARCH}-cc" "${SOURCES}"/toys/ccwrap.c -Os -s \ | |
147 -o "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}gcc" -DGIMME_AN_S $STATIC_FLAGS \ | |
148 -DGCC_UNWRAPPED_NAME='"'"${PROGRAM_PREFIX}rawgcc"'"' && | |
149 | |
150 # Wrap C++ | |
151 mv "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}g++" "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}rawg++" && | |
152 ln "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}gcc" "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}g++" && | |
153 rm "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}c++" && | |
154 ln -s "${PROGRAM_PREFIX}g++" "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}c++" && | |
155 | |
156 # When tarring up individual binary packages, we want this one to be called | |
157 # "gcc" and that's not what we fed to setupfor, so rename it. | |
158 | |
159 mv "$WORK"/{gcc-core,gcc} | |
160 PACKAGE=gcc cleanup build-gcc \ | |
161 "$ROOT_TOPDIR"/{lib/gcc,gcc/lib/install-tools,bin/${ARCH}-unknown-*} | |
162 | 75 |
163 # Tell future packages to link against the libraries in the new root filesystem, | 76 # Tell future packages to link against the libraries in the new root filesystem, |
164 # rather than the ones in the cross compiler directory. | 77 # rather than the ones in the cross compiler directory. |
165 | 78 |
166 export ${ARCH}_WRAPPER_TOPDIR="$ROOT_TOPDIR" | 79 export ${ARCH}_WRAPPER_TOPDIR="$ROOT_TOPDIR" |