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.

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