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.

592 lines
19 KiB

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