mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

570 lines
18 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/base/gcc/gcc.conf
  9. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; either version 2 of the License, or
  14. # (at your option) any later version. A copy of the GNU General Public
  15. # License can be found at Documentation/COPYING.
  16. #
  17. # Many people helped and are helping developing ROCK Linux. Please
  18. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  19. # file for details.
  20. #
  21. # --- ROCK-COPYRIGHT-NOTE-END ---
  22. pkg_gcc_version=${xpkg#gcc}
  23. pkg_gcc_target=${arch_target}
  24. pkg_gcc_cross=""
  25. case "$xpkg" in
  26. gcc?-cross-*|gcc??-cross-*)
  27. pkg_gcc_cross="${xpkg#gcc*-cross-}"
  28. pkg_gcc_version=${pkg_gcc_version%-cross-*}
  29. pkg_gcc_target="${pkg_gcc_cross}-unknown-linux-gnu"
  30. var_append confopt " " "--target=$pkg_gcc_target"
  31. echo_status "Preparing to build a cross-gcc package for $pkg_gcc_cross."
  32. var_append INSTALL_WRAPPER_FILTER "|" 'sed -r "\,/share/(info|locale)/, d"'
  33. ;;
  34. gcc?|gcc??)
  35. ;;
  36. *)
  37. echo_error "Not supported $pkg package name: $xpkg"
  38. exit 1
  39. ;;
  40. esac
  41. patchfiles="`ls $confdir/gcc$pkg_gcc_version/*.patch \
  42. $confdir/gcc$pkg_gcc_version/*.patch.$arch 2>/dev/null | tr '\n' ' '` $patchfiles"
  43. create_links() {
  44. for x ; do
  45. if [ -f "$root/$prefix/bin/$x-${pkg_gcc_version}" ] ; then
  46. rm -vf $root/$prefix/bin/$x
  47. ln -vs $x-${pkg_gcc_version} $root/$prefix/bin/$x
  48. fi
  49. x="${pkg_gcc_target}-$x"
  50. if [ -f $root/$prefix/bin/$x-${pkg_gcc_version} ] ; then
  51. rm -vf $root/$prefix/bin/$x
  52. ln -vs $x-${pkg_gcc_version} $root/$prefix/bin/$x
  53. fi
  54. done
  55. }
  56. genrockspecs() {
  57. # Hint for the reader:
  58. # The options are listed in _inverse_ order here.
  59. x="$base/build/$ROCKCFG_ID"
  60. tr '\n' '@' < specs | sed \
  61. -e "s|@\\*link:@|@*link:@-L $x/usr/$arch_target/lib |" \
  62. -e "s|@\\*link:@|@*link:@-L $x/usr/local/lib |" \
  63. -e "s|@\\*link:@|@*link:@-L $x/usr/lib |" \
  64. -e "s|@\\*link:@|@*link:@-L $x/lib |" \
  65. -e "s|@\\*link:@|@*link:@-L $x/ROCK/tools.cross/$arch_target/lib |" \
  66. -e "s|@\\*link:@|@*link:@-rpath-link $x/lib:$x/usr/lib |" \
  67. -e "s|@\\*cpp:@|@*cpp:@-I $x/usr/$arch_target/include |" \
  68. -e "s|@\\*cpp:@|@*cpp:@-I $x/usr/local/include |" \
  69. -e "s|@\\*cpp:@|@*cpp:@-I $x/usr/include |" \
  70. | tr '@' '\n' > specs.cross
  71. tr '\n' '@' < specs | sed \
  72. -e "s|@\\*link_libgcc:@|@*link_libgcc:@-L /ROCK/tools.cross/$arch_target/lib |" \
  73. -e "s|@\\*link_libgcc:@|@*link_libgcc:@-L /usr/$arch_target/lib |" \
  74. -e "s|@\\*link_libgcc:@|@*link_libgcc:@-L /usr/local/lib |" \
  75. -e "s|@\\*link_libgcc:@|@*link_libgcc:@-L /usr/lib |" \
  76. -e "s|@\\*link_libgcc:@|@*link_libgcc:@-L /lib |" \
  77. -e "s|@\\*link:@|@*link:@-rpath-link /lib:/usr/lib |" \
  78. -e "s|@\\*cpp:@|@*cpp:@-I $x/usr/$arch_target/include |" \
  79. -e "s|@\\*cpp:@|@*cpp:@-I $x/usr/local/include |" \
  80. -e "s|@\\*cpp:@|@*cpp:@-I $x/usr/include |" \
  81. | tr '@' '\n' > specs.chroot
  82. }
  83. custmain() {
  84. # Apply the respective gcc-2 or gcc-3 stack protector patch.
  85. . $base/package/base/gcc/apply-protector.sh $base gcc${pkg_gcc_version} "$desc_D"
  86. hook_eval preconf
  87. # In stage 1 we only build a normal c compiler (no c++, etc)
  88. #
  89. if [ $stagelevel -le 1 ] ; then
  90. echo 'Setting LANGUAGES="c" in Makefile.in.'
  91. sed -i -e 's/LANGUAGES="[^"]*"/LANGUAGES="c"/g' \
  92. Makefile.in
  93. elif [ "$ROCKCFG_DEBUG" = 1 ] ; then
  94. if [ -f libstdc++*/configure ] ; then
  95. echo "Setting DEBUG_FLAGS='-s' in libstdc++ configure."
  96. sed -i -e "s/DEBUG_FLAGS='-g'/DEBUG_FLAGS='-s'/g" libstdc++*/configure
  97. fi
  98. MAKE="$MAKE LIBGCC2_DEBUG_CFLAGS=-s LDFLAGS=-Wl,-s JCFLAGS=-s"
  99. fi
  100. # GCC rebuilds itself using the xgcc which is build first. xgcc
  101. # should also use the cc-wrapper. It might be better to patch big
  102. # amounts of the gcc sources - but this should also do the job.
  103. #
  104. export CFLAGS="$(exec -a echo bash \
  105. -c ". gcc-${pkg_gcc_version}" 2> /dev/null)"
  106. export CXXFLAGS="$(exec -a echo bash \
  107. -c ". g++-${pkg_gcc_version}" 2> /dev/null)"
  108. #
  109. echo "Setting \$CFLAGS to '$CFLAGS'."
  110. echo "Setting \$CXXFLAGS to '$CXXFLAGS'."
  111. mkdir objdir ; cd objdir
  112. # We install binaries, info-files and man-pages in temporary
  113. # directories so we can rename it (adding version suffix) before
  114. # moving them to their final directories.
  115. #
  116. makeinstopt=""
  117. for x in bin info man data ; do
  118. mkdir -p $builddir/inst_$x
  119. makeinstopt="$makeinstopt ${x}dir=$builddir/inst_$x"
  120. done
  121. # NAMING VARIANT!? INTRODUCED IN GCC-3.2.1
  122. if [ $arch = powerpc ] ; then
  123. ln -s ppc-nocross-linux-gnu powerpc-nocross-linux-gnu
  124. fi
  125. # add the multi-lib config
  126. if [ "$ROCKCFG_MULTILIB" = 1 ] ; then
  127. confopt="$confopt --enable-multilib"
  128. else
  129. confopt="$confopt --disable-multilib"
  130. fi
  131. # do not install gc headers
  132. if [ "$xpkg" != "gcc2" ] ; then
  133. sed -i 's, install-includeHEADERS,,;' ../boehm-gc/include/Makefile.in
  134. fi
  135. # In stage 1 everything is a little bit more complicated
  136. #
  137. if [ $stagelevel -le 1 ] ; then
  138. create_config_cache > config.cache
  139. eval $configprefix bash ../configure $confopt --enable-languages=c
  140. # creating native libiberty for build system
  141. # (needed to build helper apps like gengenrtl)
  142. #
  143. mkdir -p $arch_build ; cd $arch_build
  144. CC=$BUILDCC bash ../../configure
  145. make all-libiberty ; cd ..
  146. MAKE="$MAKE LANGUAGES=c"
  147. # GCC thinks it can share object files between build and
  148. # target if the CPUs are compatible, which isn't true if we
  149. # are cross-building from glibc to dietlibc. So we also build
  150. # helper programs with dietlibc if this is not a cross build
  151. # between cpu architectures.
  152. #
  153. if ! [ "$pkg_dietlibc_useit" = 1 -a "$ROCKCFG_CROSSBUILD" = 0 ]
  154. then
  155. MAKE="$MAKE CC_FOR_BUILD='$BUILDCC'"
  156. fi
  157. # Fixincludes doesn't run when cross-building, but we
  158. # need a syslimits.h for a working gcc
  159. #
  160. mkdir -p gcc/include
  161. echo '#include "/usr/include/limits.h"' > gcc/include/syslimits.h
  162. hook_eval premake
  163. # Build and install
  164. #
  165. eval $MAKE prefix=/$prefix libdir=/$prefix/lib
  166. hook_eval inmake
  167. eval $MAKE prefix=$root/$prefix $makeinstopt install
  168. # This stuff needs manual installation
  169. #
  170. echo "Creating /$prefix/${pkg_gcc_target} ..."
  171. mkdir -p $root/$prefix/${pkg_gcc_target}/lib
  172. cd $root/$prefix/${pkg_gcc_target}/lib
  173. for x in Mcrt1.o crti.o gcrt1.o crt1.o crtn.o
  174. do ln -sf ../../lib/$x . ; done
  175. if [ -f ../../../lib/ld-linux-$arch_machine.so.2 ] ; then
  176. ln -sf ../../../lib/ld-linux-$arch_machine.so.2 .
  177. elif [ -f ../../../lib/ld-linux.so.2 ] ; then
  178. ln -sf ../../../lib/ld-linux.so.2 .
  179. fi
  180. else
  181. if [ $xpkg = gcc2 -a "$ROCKCFG_PKG_GCC2_NO_CHILL" != 0 ] ; then
  182. # gcc-2.x contains no 'java' compiler
  183. confopt="$confopt --enable-languages=c,c++,objc,f77"
  184. elif [ "$ROCKCFG_DIETLIBC_ALL" = 1 -o "$ROCKCFG_DIETLIBC_gcc3" = 1 ] ; then
  185. # FIXME: c++ and java are not working with dietlibc
  186. confopt="$confopt --enable-languages=c,objc"
  187. elif [ $xpkg = gcc32 -a "$ROCKCFG_PKG_GCC32_NO_JAVA" != 0 ] || \
  188. [ $xpkg = gcc33 -a "$ROCKCFG_PKG_GCC33_NO_JAVA" != 0 ] || \
  189. [ $xpkg = gcc34 -a "$ROCKCFG_PKG_GCC34_NO_JAVA" != 0 ]; then
  190. confopt="$confopt --enable-languages=c,c++,objc,f77"
  191. elif [ $xpkg = gcc40 -a "$ROCKCFG_PKG_GCC40_NO_JAVA" != 0 ] || \
  192. [ $xpkg = gcc41 -a "$ROCKCFG_PKG_GCC41_NO_JAVA" != 0 ]; then
  193. confopt="$confopt --enable-languages=c,c++,objc,f95"
  194. elif [ "$arch" = mips ] ; then
  195. # FIXME: MIPS doesn't like the Java compiler
  196. confopt="$confopt --disable-libgcj"
  197. fi
  198. # See http://gcc.gnu.org/gcc-3.2/c++-abi.html
  199. # and http://www.codesourcery.com/cxx-abi/.
  200. if [ $xpkg != gcc2 ] ; then
  201. confopt="$confopt --enable-__cxa_atexit"
  202. fi
  203. # Set enable-shared
  204. if [ "$diet_dynamic_static" == "static" ] ; then
  205. confopt="$confopt --enable-shared=no"
  206. else
  207. confopt="$confopt --enable-shared=yes"
  208. fi
  209. # Configure, build and install as usual
  210. #
  211. eval $configprefix bash ../configure $confopt --with-gnu-as \
  212. --enable-version-specific-runtime-libs \
  213. --with-gnu-ld --enable-threads=posix
  214. hook_eval premake
  215. if [ $xpkg = gcc34 -a "$ROCKCFG_PKG_GCC34_PROFILED" != 0 ]; then
  216. eval "$MAKE GCJFLAGS=\"$CXXFLAGS\" profiledbootstrap"
  217. elif [ $xpkg = gcc40 -a "$ROCKCFG_PKG_GCC40_PROFILED" != 0 ]; then
  218. eval "$MAKE GCJFLAGS=\"$CXXFLAGS\" profiledbootstrap"
  219. elif [ $xpkg = gcc41 -a "$ROCKCFG_PKG_GCC41_PROFILED" != 0 ]; then
  220. eval "$MAKE GCJFLAGS=\"$CXXFLAGS\" profiledbootstrap"
  221. else
  222. eval "$MAKE GCJFLAGS=\"$CXXFLAGS\" all"
  223. fi
  224. hook_eval inmake
  225. eval "$MAKE $makeinstopt install"
  226. # Fix the location of any improperly installed (F77) libraries
  227. mv -vf $root/$prefix/lib/$gcc_lib_dir/../lib* \
  228. $root/$prefix/lib/$gcc_lib_dir || true
  229. fi
  230. hook_eval postmake
  231. # GCC 4 does not install a specs file and removes old ones.
  232. # Regenerate the file with -dumpspecs.
  233. #
  234. cd $builddir/inst_bin
  235. for x in gcc ${pkg_gcc_target}-gcc ; do
  236. [ -f "$x" -a "${pkg_gcc_version:0:1}" -ge "4" ] && \
  237. ./$x -dumpspecs > $root/$prefix/lib/$gcc_lib_dir/specs
  238. done
  239. # Rename and install binaries
  240. #
  241. cd $builddir/inst_bin ; mkdir -p $root/$prefix/bin
  242. for y in c++ c++filt g++ cpp f77 g77 gfortran gcc gcov ; do
  243. for x in $y ${pkg_gcc_target}-$y ; do
  244. if [ -f "$x" ] ; then
  245. mv -v $x $root/$prefix/bin/${x}-${pkg_gcc_version}
  246. fi
  247. done
  248. done
  249. # gcc2 does not contain an own c++filt ... - so use the binutils one
  250. #
  251. if [ "$xpkg" = gcc2 ] ; then
  252. ln -vsf $root/$prefix/bin/c++filt-2 c++filt-binutils
  253. fi
  254. # Rename and install info-files
  255. #
  256. cd $builddir/inst_info ; mkdir -p $root/$prefix/info
  257. for x in * ; do
  258. [ ! -f $x ] && continue # e.g. if $x becomes '*' somehow
  259. fn=$( echo $x | sed "s,\([a-z0-9]*\),\1-${pkg_gcc_version}," )
  260. infoname=$( echo $x | sed "s,\([a-z0-9]*\).*,\1," )
  261. echo "$x -> $root/$prefix/info/$fn"
  262. sed "s,$infoname.info,$infoname-${pkg_gcc_version}.info," < $x \
  263. > $root/$prefix/info/$fn
  264. if [ $ROCKCFG_DEFAULT_CC = $xpkg ] ; then
  265. cp -v $x $root/$prefix/info/$x
  266. fi
  267. true
  268. done
  269. # Rename and install man-pages
  270. #
  271. cd $builddir/inst_man/man1
  272. mkdir -p $root/$prefix/man/man1
  273. for x in * ; do
  274. [ ! -f $x ] && continue # e.g. if $x becomes '*' somehow
  275. mv -v $x $root/$prefix/man/man1/${x%.1}-${pkg_gcc_version}.1
  276. if [ $ROCKCFG_DEFAULT_CC = $xpkg ] ; then
  277. ln -sf ${x%.1}-${pkg_gcc_version}.1 $root/$prefix/man/man1/$x
  278. fi
  279. true
  280. done
  281. # Rename and install locales
  282. #
  283. if [ -d "$builddir/inst_data/locale" ] ; then
  284. cd $builddir/inst_data/locale
  285. for x in */LC_MESSAGES/*.mo ; do
  286. [ ! -f "$x" ] && continue # e.g. if $x becomes '*' somehow
  287. y="$root/$prefix/share/locale/$x"
  288. y="${y%.mo}-${pkg_gcc_version}.mo"
  289. mkdir -p ${y%/*}
  290. echo "$x -> $y"
  291. mv $x $y
  292. if [ $ROCKCFG_DEFAULT_CC = $xpkg ] ; then
  293. echo "symlink $x -> $y"
  294. ln -svf ${y##*/} $root/$prefix/share/locale/$x
  295. fi
  296. true
  297. done
  298. fi
  299. hook_eval postdoc
  300. # Create various symlinks for cc, c++, cpp and f77.
  301. #
  302. if [ $ROCKCFG_DEFAULT_CC = $xpkg ] ; then
  303. create_links gcc cpp gcov
  304. rm -f $root/$prefix/bin/cc
  305. if [ "$ROCKCFG_DIETLIBC_ALL" = 1 ]; then
  306. cat <<- 'EOT' > $root/$prefix/bin/cc
  307. #!/bin/sh
  308. exec diet gcc "$@"
  309. EOT
  310. chmod +x $root/$prefix/bin/cc
  311. else
  312. ln -svf gcc $root/$prefix/bin/cc
  313. fi
  314. ln -vsf ../$prefix/bin/cpp $root/lib/cpp
  315. fi
  316. ln -sf gcc-${pkg_gcc_version} $root/$prefix/bin/kcc-${pkg_gcc_version}
  317. if [ $ROCKCFG_DEFAULT_KCC = $xpkg ] ; then
  318. ln -vsf gcc-${pkg_gcc_version} $root/$prefix/bin/kcc
  319. fi
  320. if [ $ROCKCFG_DEFAULT_CXX = $xpkg ] ; then
  321. create_links c++ c++filt g++
  322. fi
  323. if [ $ROCKCFG_DEFAULT_F77 = $xpkg ] ; then
  324. create_links g77
  325. if [ -f $root/$prefix/bin/g77 ] ; then
  326. rm -vf $root/$prefix/bin/f77
  327. ln -vsf g77 $root/$prefix/bin/f77
  328. fi
  329. fi
  330. if [ $ROCKCFG_DEFAULT_F95 = $xpkg ] ; then
  331. create_links gfortran
  332. fi
  333. # Inject our default optimisation options so when the user calls
  334. # gcc/g++ they match the ones used to precompile the headers ...
  335. # Save the options affecting optimization only.
  336. #
  337. if [ $ROCKCFG_DEFAULT_CC = $xpkg ]; then
  338. echo "Creating /etc/profile.d/gcc ..."
  339. {
  340. echo "export CFLAGS_SIZE=\"$(echo $(
  341. eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \
  342. \$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \
  343. tr ' ' '\n' | sed -e 's/^-SIZE-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \
  344. -e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd'
  345. ))\""
  346. echo "export CFLAGS_SPEED=\"$(echo $(
  347. eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \
  348. \$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \
  349. tr ' ' '\n' | sed -e 's/^-SPEED-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \
  350. -e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd'
  351. ))\""
  352. echo "export CFLAGS=\"\$CFLAGS_SIZE\""
  353. } > $root/etc/profile.d/gcc
  354. fi
  355. if [ $ROCKCFG_DEFAULT_CXX = $xpkg ]; then
  356. echo "Creating /etc/profile.d/gxx ..."
  357. {
  358. echo "export CXXFLAGS_SIZE=\"$(echo $(
  359. eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \
  360. \$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \
  361. tr ' ' '\n' | sed -e 's/^-SIZE-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \
  362. -e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd'
  363. ))\""
  364. echo "export CXXFLAGS_SPEED=\"$(echo $(
  365. eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \
  366. \$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \
  367. tr ' ' '\n' | sed -e 's/^-SPEED-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \
  368. -e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd'
  369. ))\""
  370. echo "export CXXFLAGS=\"\$CFLAGS_SIZE\""
  371. } > $root/etc/profile.d/gxx
  372. fi
  373. # Create symlinks for runtime libraries so they can be found by
  374. # the dynamic loader and force rebuilding of the wrapper links
  375. #
  376. if [ $stagelevel -gt 1 ] ; then
  377. [ $ROCKCFG_DEFAULT_CC = $xpkg ] && \
  378. ( mkdir -p $root/$prefix/lib ; cd $root/$prefix/lib ; \
  379. ln -vfs ${gcc_lib_dir}/*.so.* . ; )
  380. rm -fv $base/build/$ROCKCFG_ID/ROCK/$toolsdir/.lastupdate
  381. fi
  382. if [ "$ROCKCFG_PSEUDONATIVE" = 1 ]; then
  383. echo "Adapting gcc specs file..."
  384. cd $root/$prefix/lib/${gcc_lib_dir}
  385. genrockspecs
  386. # echo "Linking gcc libs to tools.cross..."
  387. # cd $root/ROCK/tools.cross/lib/${gcc_lib_dir}/
  388. # ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.a .
  389. # ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.la .
  390. # ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.so .
  391. # ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.so.* .
  392. fi
  393. true
  394. }
  395. gcc_cross() {
  396. # Apply the respective gcc-2 or gcc-3 stack protector patch.
  397. . $base/package/base/gcc/apply-protector.sh $base gcc${pkg_gcc_version} "$desc_D"
  398. mkdir -p $root/$prefix/$pkg_gcc_target/{bin,lib}
  399. if [ "$stagelevel" -eq 0 ]
  400. then
  401. rm -f $root/$prefix/$pkg_gcc_target/include
  402. if [ -f $root/$prefix/include/stdio.h ]; then
  403. ln -s ../include $root/$prefix/$pkg_gcc_target/include
  404. elif [ -f $root/$prefix/diet-include/stdio.h ]; then
  405. ln -s ../diet-include $root/$prefix/$pkg_gcc_target/include
  406. fi
  407. bindir="$root/$prefix/crosscc"
  408. mkdir -p $root/$prefix/crosscc
  409. fi
  410. if [ "$pkg_gcc_version" != "2" ]; then
  411. if [ "$ROCKCFG_PSEUDONATIVE" = 1 ]; then
  412. confopt="$confopt --enable-languages=c,c++"
  413. else
  414. confopt="$confopt --enable-languages=c"
  415. fi
  416. fi
  417. mkdir objdir ; cd objdir ; hook_eval preconf
  418. eval bash ../configure --program-prefix=${pkg_gcc_target}- --disable-cpp \
  419. --disable-shared --disable-multilib $confopt
  420. if [ -d libiberty ]; then make -C libiberty; fi
  421. if [ -d texinfo ]; then make -C texinfo; fi
  422. hook_eval premake
  423. if [ "$xpkg" = "gcc2" ] ; then
  424. make -C gcc all LANGUAGES="c"
  425. hook_eval inmake
  426. make -C gcc install LANGUAGES="c"
  427. else
  428. # workaround for at least gcc-3.2.3
  429. mkdir -p $root/$prefix/lib/${gcc_lib_dir}
  430. if [ -d gcc ]; then
  431. make -C gcc all
  432. hook_eval inmake
  433. make -C gcc install
  434. else
  435. make all-gcc
  436. hook_eval inmake
  437. make install-gcc
  438. fi
  439. fi
  440. hook_eval postmake
  441. if [ -f $root/$prefix/lib/${gcc_lib_dir}/libgcc.a ]; then
  442. ${pkg_gcc_target}-ranlib \
  443. $root/$prefix/lib/${gcc_lib_dir}/libgcc.a
  444. fi
  445. if [ "$stagelevel" -eq 0 ]; then
  446. x="$root/$prefix/crosscc/${arch_target}"
  447. ln -svf ${arch_target}-gcc $x-gcc-${pkg_gcc_version}
  448. ln -svf ${arch_target}-g++ $x-g++-${pkg_gcc_version}
  449. ln -svf ${arch_target}-gcc $x-kcc-${pkg_gcc_version}
  450. ln -svf ${arch_target}-gcc $x-kcc
  451. ln -svf ${arch_target}-gcc $x-cc
  452. rm -vf "$root/$prefix/crosscc/gcc"
  453. rm -vf "$root/$prefix/crosscc/gcj"
  454. cd $root/$prefix/$arch_target/lib
  455. for x in Mcrt1.o crt1.o crti.o crtn.o gcrt1.o \
  456. libc.a libc.so libc_nonshared.a
  457. do
  458. if [ ! -e $x ]; then
  459. ln -fvs $root/../../usr/lib/$x $x
  460. fi
  461. done
  462. for x in ld-linux{,-$arch_machine}.so.2 ld.so.1 libc.so.{6,6.1}
  463. do ln -fvs $root/../../lib/$x $x ; done
  464. # glibc uses -lgcc_s with --as-needed, which fails if libgcc_s.{so,a}
  465. # is not even there. -- clifford & fake
  466. #
  467. # the shared object is not really needed.
  468. #if [ ! -e $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.so ]; then
  469. # ${pkg_gcc_target}-gcc -shared -nostdlib \
  470. # -o $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.so -x c /dev/null
  471. #fi
  472. if [ ! -e $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.a ]; then
  473. ${pkg_gcc_target}-gcc -x c /dev/null -c -o null.o
  474. ${pkg_gcc_target}-ar q null.a null.o; rm -f null.o
  475. ${pkg_gcc_target}-ranlib null.a
  476. mv null.a $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.a
  477. fi
  478. rm -f $root/$prefix/.lastupdate
  479. fi
  480. # GCC 4 does not install a specs file and removes old ones.
  481. # Regenerate the file with -dumpspecs.
  482. #
  483. if [ "${pkg_gcc_version:0:1}" -ge "4" ]; then
  484. [ "$stagelevel" -eq 0 ] && $root/$prefix/crosscc/${pkg_gcc_target}-gcc -dumpspecs > $root/$prefix/lib/${gcc_lib_dir}/specs
  485. [ "$stagelevel" -ne 0 ] && $root/$prefix/bin/${pkg_gcc_target}-gcc -dumpspecs > $root/$prefix/lib/${gcc_lib_dir}/specs
  486. fi
  487. if [ "$stagelevel" -eq 0 -o "$ROCKCFG_PSEUDONATIVE" = 1 ]; then
  488. echo "Adapting gcc specs file..."
  489. cd $root/$prefix/lib/${gcc_lib_dir}
  490. genrockspecs
  491. fi
  492. true
  493. }
  494. if [ "$stagelevel" -eq 0 -o -n "$pkg_gcc_cross" ]
  495. then
  496. custmain="gcc_cross"
  497. else
  498. custmain="custmain"
  499. fi
  500. case "$pkg_gcc_version" in
  501. 34|4*)
  502. gcc_lib_dir="gcc/${pkg_gcc_target}/${ver%%-*}"
  503. ;;
  504. *)
  505. gcc_lib_dir="gcc-lib/${pkg_gcc_target}/${ver%%-*}"
  506. ;;
  507. esac