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.

566 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 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. # Inject our default optimisation options so when the user calls
  331. # gcc/g++ they match the ones used to precompile the headers ...
  332. # Save the options affecting optimization only.
  333. #
  334. if [ $ROCKCFG_DEFAULT_CC = $xpkg ]; then
  335. echo "Creating /etc/profile.d/gcc ..."
  336. {
  337. echo "export CFLAGS_SIZE=\"$(echo $(
  338. eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \
  339. \$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \
  340. tr ' ' '\n' | sed -e 's/^-SIZE-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \
  341. -e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd'
  342. ))\""
  343. echo "export CFLAGS_SPEED=\"$(echo $(
  344. eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \
  345. \$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \
  346. tr ' ' '\n' | sed -e 's/^-SPEED-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \
  347. -e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd'
  348. ))\""
  349. echo "export CFLAGS=\"\$CFLAGS_SIZE\""
  350. } > $root/etc/profile.d/gcc
  351. fi
  352. if [ $ROCKCFG_DEFAULT_CXX = $xpkg ]; then
  353. echo "Creating /etc/profile.d/gxx ..."
  354. {
  355. echo "export CXXFLAGS_SIZE=\"$(echo $(
  356. eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \
  357. \$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \
  358. tr ' ' '\n' | sed -e 's/^-SIZE-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \
  359. -e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd'
  360. ))\""
  361. echo "export CXXFLAGS_SPEED=\"$(echo $(
  362. eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \
  363. \$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \
  364. tr ' ' '\n' | sed -e 's/^-SPEED-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \
  365. -e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd'
  366. ))\""
  367. echo "export CXXFLAGS=\"\$CFLAGS_SIZE\""
  368. } > $root/etc/profile.d/gxx
  369. fi
  370. # Create symlinks for runtime libraries so they can be found by
  371. # the dynamic loader and force rebuilding of the wrapper links
  372. #
  373. if [ $stagelevel -gt 1 ] ; then
  374. [ $ROCKCFG_DEFAULT_CC = $xpkg ] && \
  375. ( mkdir -p $root/$prefix/lib ; cd $root/$prefix/lib ; \
  376. ln -vfs ${gcc_lib_dir}/*.so.* . ; )
  377. rm -fv $base/build/$ROCKCFG_ID/ROCK/$toolsdir/.lastupdate
  378. fi
  379. if [ "$ROCKCFG_PSEUDONATIVE" = 1 ]; then
  380. echo "Adapting gcc specs file..."
  381. cd $root/$prefix/lib/${gcc_lib_dir}
  382. genrockspecs
  383. # echo "Linking gcc libs to tools.cross..."
  384. # cd $root/ROCK/tools.cross/lib/${gcc_lib_dir}/
  385. # ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.a .
  386. # ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.la .
  387. # ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.so .
  388. # ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.so.* .
  389. fi
  390. true
  391. }
  392. gcc_cross() {
  393. # Apply the respective gcc-2 or gcc-3 stack protector patch.
  394. . $base/package/base/gcc/apply-protector.sh $base gcc${pkg_gcc_version} "$desc_D"
  395. mkdir -p $root/$prefix/$pkg_gcc_target/{bin,lib}
  396. if [ "$stagelevel" -eq 0 ]
  397. then
  398. rm -f $root/$prefix/$pkg_gcc_target/include
  399. if [ -f $root/$prefix/include/stdio.h ]; then
  400. ln -s ../include $root/$prefix/$pkg_gcc_target/include
  401. elif [ -f $root/$prefix/diet-include/stdio.h ]; then
  402. ln -s ../diet-include $root/$prefix/$pkg_gcc_target/include
  403. fi
  404. bindir="$root/$prefix/crosscc"
  405. mkdir -p $root/$prefix/crosscc
  406. fi
  407. if [ "$pkg_gcc_version" != "2" ]; then
  408. if [ "$ROCKCFG_PSEUDONATIVE" = 1 ]; then
  409. confopt="$confopt --enable-languages=c,c++"
  410. else
  411. confopt="$confopt --enable-languages=c"
  412. fi
  413. fi
  414. mkdir objdir ; cd objdir ; hook_eval preconf
  415. eval bash ../configure --program-prefix=${pkg_gcc_target}- --disable-cpp \
  416. --disable-shared --disable-multilib $confopt
  417. if [ -d libiberty ]; then make -C libiberty; fi
  418. if [ -d texinfo ]; then make -C texinfo; fi
  419. hook_eval premake
  420. if [ "$xpkg" = "gcc2" ] ; then
  421. make -C gcc all LANGUAGES="c"
  422. hook_eval inmake
  423. make -C gcc install LANGUAGES="c"
  424. else
  425. # workaround for at least gcc-3.2.3
  426. mkdir -p $root/$prefix/lib/${gcc_lib_dir}
  427. if [ -d gcc ]; then
  428. make -C gcc all
  429. hook_eval inmake
  430. make -C gcc install
  431. else
  432. make all-gcc
  433. hook_eval inmake
  434. make install-gcc
  435. fi
  436. fi
  437. hook_eval postmake
  438. if [ -f $root/$prefix/lib/${gcc_lib_dir}/libgcc.a ]; then
  439. ${pkg_gcc_target}-ranlib \
  440. $root/$prefix/lib/${gcc_lib_dir}/libgcc.a
  441. fi
  442. if [ "$stagelevel" -eq 0 ]; then
  443. x="$root/$prefix/crosscc/${arch_target}"
  444. ln -svf ${arch_target}-gcc $x-gcc-${pkg_gcc_version}
  445. ln -svf ${arch_target}-g++ $x-g++-${pkg_gcc_version}
  446. ln -svf ${arch_target}-gcc $x-kcc-${pkg_gcc_version}
  447. ln -svf ${arch_target}-gcc $x-kcc
  448. ln -svf ${arch_target}-gcc $x-cc
  449. rm -vf "$root/$prefix/crosscc/gcc"
  450. rm -vf "$root/$prefix/crosscc/gcj"
  451. cd $root/$prefix/$arch_target/lib
  452. for x in Mcrt1.o crt1.o crti.o crtn.o gcrt1.o \
  453. libc.a libc.so libc_nonshared.a
  454. do
  455. if [ ! -e $x ]; then
  456. ln -fvs $root/../../usr/lib/$x $x
  457. fi
  458. done
  459. for x in ld-linux{,-$arch_machine}.so.2 ld.so.1 libc.so.{6,6.1}
  460. do ln -fvs $root/../../lib/$x $x ; done
  461. # glibc uses -lgcc_s with --as-needed, which fails if libgcc_s.{so,a}
  462. # is not even there. -- clifford & fake
  463. #
  464. # the shared object is not really needed.
  465. #if [ ! -e $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.so ]; then
  466. # ${pkg_gcc_target}-gcc -shared -nostdlib \
  467. # -o $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.so -x c /dev/null
  468. #fi
  469. if [ ! -e $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.a ]; then
  470. ${pkg_gcc_target}-gcc -x c /dev/null -c -o null.o
  471. ${pkg_gcc_target}-ar q null.a null.o; rm -f null.o
  472. ${pkg_gcc_target}-ranlib null.a
  473. mv null.a $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.a
  474. fi
  475. rm -f $root/$prefix/.lastupdate
  476. fi
  477. # GCC 4 does not install a specs file and removes old ones.
  478. # Regenerate the file with -dumpspecs.
  479. #
  480. [ "${pkg_gcc_version:0:1}" -ge "4" ] && \
  481. $root/$prefix/crosscc/${arch_target}-gcc -dumpspecs > \
  482. $root/$prefix/lib/${gcc_lib_dir}/specs
  483. if [ "$stagelevel" -eq 0 -o "$ROCKCFG_PSEUDONATIVE" = 1 ]; then
  484. echo "Adapting gcc specs file..."
  485. cd $root/$prefix/lib/${gcc_lib_dir}
  486. genrockspecs
  487. fi
  488. true
  489. }
  490. if [ "$stagelevel" -eq 0 -o -n "$pkg_gcc_cross" ]
  491. then
  492. custmain="gcc_cross"
  493. else
  494. custmain="custmain"
  495. fi
  496. case "$pkg_gcc_version" in
  497. 34|4*)
  498. gcc_lib_dir="gcc/${pkg_gcc_target}/${ver%%-*}"
  499. ;;
  500. *)
  501. gcc_lib_dir="gcc-lib/${pkg_gcc_target}/${ver%%-*}"
  502. ;;
  503. esac