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.

586 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 $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 [ $xpkg = gcc42 -a "$ROCKCFG_PKG_GCC42_NO_JAVA" != 0 ]; then
  197. confopt="$confopt --enable-languages=c,c++,objc,fortran"
  198. elif [ "$arch" = mips ] ; then
  199. # FIXME: MIPS doesn't like the Java compiler
  200. confopt="$confopt --disable-libgcj"
  201. fi
  202. # See http://gcc.gnu.org/gcc-3.2/c++-abi.html
  203. # and http://www.codesourcery.com/cxx-abi/.
  204. if [ $xpkg != gcc2 ] ; then
  205. confopt="$confopt --enable-__cxa_atexit"
  206. fi
  207. # Set enable-shared
  208. if [ "$diet_dynamic_static" == "static" ] ; then
  209. confopt="$confopt --enable-shared=no"
  210. else
  211. confopt="$confopt --enable-shared=yes"
  212. fi
  213. # Configure, build and install as usual
  214. #
  215. eval $configprefix bash ../configure $confopt --with-gnu-as \
  216. --enable-version-specific-runtime-libs \
  217. --with-gnu-ld --enable-threads=posix
  218. hook_eval premake
  219. if [ $xpkg = gcc34 -a "$ROCKCFG_PKG_GCC34_PROFILED" != 0 ]; then
  220. eval "$MAKE GCJFLAGS=\"$CXXFLAGS\" profiledbootstrap"
  221. elif [ $xpkg = gcc40 -a "$ROCKCFG_PKG_GCC40_PROFILED" != 0 ]; then
  222. eval "$MAKE GCJFLAGS=\"$CXXFLAGS\" profiledbootstrap"
  223. elif [ $xpkg = gcc41 -a "$ROCKCFG_PKG_GCC41_PROFILED" != 0 ]; then
  224. eval "$MAKE GCJFLAGS=\"$CXXFLAGS\" profiledbootstrap"
  225. elif [ $xpkg = gcc42 -a "$ROCKCFG_PKG_GCC42_PROFILED" != 0 ]; then
  226. eval "$MAKE GCJFLAGS=\"$CXXFLAGS\" profiledbootstrap"
  227. else
  228. eval "$MAKE GCJFLAGS=\"$CXXFLAGS\" all"
  229. fi
  230. hook_eval inmake
  231. eval "$MAKE $makeinstopt install"
  232. # Fix the location of any improperly installed (F77) libraries
  233. mv -vf $root/$prefix/lib/$gcc_lib_dir/../lib* \
  234. $root/$prefix/lib/$gcc_lib_dir || true
  235. fi
  236. hook_eval postmake
  237. # GCC 4 does not install a specs file and removes old ones.
  238. # Regenerate the file with -dumpspecs.
  239. #
  240. cd $builddir/inst_bin
  241. if [ "${pkg_gcc_version:0:1}" -ge "4" ]; then
  242. if [ "$ROCKCFG_CROSSBUILD" == 1 ]; then
  243. $root/ROCK/tools.cross/crosscc/${pkg_gcc_target}-gcc -dumpspecs > \
  244. $root/${prefix}/lib/${gcc_lib_dir}/specs
  245. else
  246. for x in gcc ${pkg_gcc_target}-gcc ; do
  247. [ -f "${x}" ] && ./${x} -dumpspecs > \
  248. $root/${prefix}/lib/${gcc_lib_dir}/specs
  249. done
  250. fi
  251. fi
  252. # Rename and install binaries
  253. #
  254. cd $builddir/inst_bin ; mkdir -p $root/$prefix/bin
  255. for y in c++ c++filt g++ cpp f77 g77 gfortran gcc gcov ; do
  256. for x in $y ${pkg_gcc_target}-$y ; do
  257. if [ -f "$x" ] ; then
  258. mv -v $x $root/$prefix/bin/${x}-${pkg_gcc_version}
  259. fi
  260. done
  261. done
  262. # gcc2 does not contain an own c++filt ... - so use the binutils one
  263. #
  264. if [ "$xpkg" = gcc2 ] ; then
  265. ln -vsf $root/$prefix/bin/c++filt-2 c++filt-binutils
  266. fi
  267. # Rename and install info-files
  268. #
  269. cd $builddir/inst_info ; mkdir -p $root/$prefix/info
  270. for x in * ; do
  271. [ ! -f $x ] && continue # e.g. if $x becomes '*' somehow
  272. fn=$( echo $x | sed "s,\([a-z0-9]*\),\1-${pkg_gcc_version}," )
  273. infoname=$( echo $x | sed "s,\([a-z0-9]*\).*,\1," )
  274. echo "$x -> $root/$prefix/info/$fn"
  275. sed "s,$infoname.info,$infoname-${pkg_gcc_version}.info," < $x \
  276. > $root/$prefix/info/$fn
  277. if [ $ROCKCFG_DEFAULT_CC = $xpkg ] ; then
  278. cp -v $x $root/$prefix/info/$x
  279. fi
  280. true
  281. done
  282. # Rename and install man-pages
  283. #
  284. cd $builddir/inst_man/man1
  285. mkdir -p $root/$prefix/man/man1
  286. for x in * ; do
  287. [ ! -f $x ] && continue # e.g. if $x becomes '*' somehow
  288. mv -v $x $root/$prefix/man/man1/${x%.1}-${pkg_gcc_version}.1
  289. if [ $ROCKCFG_DEFAULT_CC = $xpkg ] ; then
  290. ln -sf ${x%.1}-${pkg_gcc_version}.1 $root/$prefix/man/man1/$x
  291. fi
  292. true
  293. done
  294. # Rename and install locales
  295. #
  296. if [ -d "$builddir/inst_data/locale" ] ; then
  297. cd $builddir/inst_data/locale
  298. for x in */LC_MESSAGES/*.mo ; do
  299. [ ! -f "$x" ] && continue # e.g. if $x becomes '*' somehow
  300. y="$root/$prefix/share/locale/$x"
  301. y="${y%.mo}-${pkg_gcc_version}.mo"
  302. mkdir -p ${y%/*}
  303. echo "$x -> $y"
  304. mv $x $y
  305. if [ $ROCKCFG_DEFAULT_CC = $xpkg ] ; then
  306. echo "symlink $x -> $y"
  307. ln -svf ${y##*/} $root/$prefix/share/locale/$x
  308. fi
  309. true
  310. done
  311. fi
  312. hook_eval postdoc
  313. # Create various symlinks for cc, c++, cpp and f77.
  314. #
  315. if [ $ROCKCFG_DEFAULT_CC = $xpkg ] ; then
  316. create_links gcc cpp gcov
  317. rm -f $root/$prefix/bin/cc
  318. if [ "$ROCKCFG_DIETLIBC_ALL" = 1 ]; then
  319. cat <<- 'EOT' > $root/$prefix/bin/cc
  320. #!/bin/sh
  321. exec diet gcc "$@"
  322. EOT
  323. chmod +x $root/$prefix/bin/cc
  324. else
  325. ln -svf gcc $root/$prefix/bin/cc
  326. fi
  327. ln -vsf ../$prefix/bin/cpp $root/lib/cpp
  328. fi
  329. ln -sf gcc-${pkg_gcc_version} $root/$prefix/bin/kcc-${pkg_gcc_version}
  330. if [ $ROCKCFG_DEFAULT_KCC = $xpkg ] ; then
  331. ln -vsf gcc-${pkg_gcc_version} $root/$prefix/bin/kcc
  332. fi
  333. if [ $ROCKCFG_DEFAULT_CXX = $xpkg ] ; then
  334. create_links c++ c++filt g++
  335. cp -a $confdir/g++-autopch.sh $root/$prefix/bin/g++-autopch
  336. chmod +x $root/$prefix/bin/g++-autopch
  337. fi
  338. if [ $ROCKCFG_DEFAULT_F77 = $xpkg ] ; then
  339. create_links g77
  340. if [ -f $root/$prefix/bin/g77 ] ; then
  341. rm -vf $root/$prefix/bin/f77
  342. ln -vsf g77 $root/$prefix/bin/f77
  343. fi
  344. fi
  345. if [ $ROCKCFG_DEFAULT_F95 = $xpkg ] ; then
  346. create_links gfortran
  347. fi
  348. # Inject our default optimisation options so when the user calls
  349. # gcc/g++ they match the ones used to precompile the headers ...
  350. # Save the options affecting optimization only.
  351. #
  352. if [ $ROCKCFG_DEFAULT_CC = $xpkg ]; then
  353. echo "Creating /etc/profile.d/gcc ..."
  354. {
  355. echo "export CFLAGS_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 CFLAGS_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 CFLAGS=\"\$CFLAGS_SIZE\""
  368. } > $root/etc/profile.d/gcc
  369. fi
  370. if [ $ROCKCFG_DEFAULT_CXX = $xpkg ]; then
  371. echo "Creating /etc/profile.d/gxx ..."
  372. {
  373. echo "export CXXFLAGS_SIZE=\"$(echo $(
  374. eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \
  375. \$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \
  376. tr ' ' '\n' | sed -e 's/^-SIZE-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \
  377. -e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd'
  378. ))\""
  379. echo "export CXXFLAGS_SPEED=\"$(echo $(
  380. eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \
  381. \$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \
  382. tr ' ' '\n' | sed -e 's/^-SPEED-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \
  383. -e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd'
  384. ))\""
  385. echo "export CXXFLAGS=\"\$CFLAGS_SIZE\""
  386. } > $root/etc/profile.d/gxx
  387. fi
  388. # Create symlinks for runtime libraries so they can be found by
  389. # the dynamic loader and force rebuilding of the wrapper links
  390. #
  391. if [ $stagelevel -gt 1 ] ; then
  392. [ $ROCKCFG_DEFAULT_CC = $xpkg ] && \
  393. ( mkdir -p $root/$prefix/lib ; cd $root/$prefix/lib ; \
  394. ln -vfs ${gcc_lib_dir}/*.so.* . ; )
  395. rm -fv $base/build/$ROCKCFG_ID/ROCK/$toolsdir/.lastupdate
  396. fi
  397. if [ "$ROCKCFG_PSEUDONATIVE" = 1 ]; then
  398. echo "Adapting gcc specs file..."
  399. cd $root/$prefix/lib/${gcc_lib_dir}
  400. genrockspecs
  401. # echo "Linking gcc libs to tools.cross..."
  402. # cd $root/ROCK/tools.cross/lib/${gcc_lib_dir}/
  403. # ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.a .
  404. # ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.la .
  405. # ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.so .
  406. # ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.so.* .
  407. fi
  408. true
  409. }
  410. gcc_cross() {
  411. # Apply the respective gcc-2 or gcc-3 stack protector patch.
  412. . $base/package/base/gcc/apply-protector.sh $base gcc${pkg_gcc_version} "$desc_D"
  413. mkdir -p $root/$prefix/$pkg_gcc_target/{bin,lib}
  414. if [ "$stagelevel" -eq 0 ]
  415. then
  416. rm -f $root/$prefix/$pkg_gcc_target/include
  417. if [ -f $root/$prefix/include/stdio.h ]; then
  418. ln -s ../include $root/$prefix/$pkg_gcc_target/include
  419. elif [ -f $root/$prefix/diet-include/stdio.h ]; then
  420. ln -s ../diet-include $root/$prefix/$pkg_gcc_target/include
  421. fi
  422. bindir="$root/$prefix/crosscc"
  423. mkdir -p $root/$prefix/crosscc
  424. fi
  425. if [ "$pkg_gcc_version" != "2" ]; then
  426. if [ "$ROCKCFG_PSEUDONATIVE" = 1 ]; then
  427. confopt="$confopt --enable-languages=c,c++"
  428. else
  429. confopt="$confopt --enable-languages=c"
  430. fi
  431. fi
  432. mkdir objdir ; cd objdir ; hook_eval preconf
  433. eval bash ../configure --program-prefix=${pkg_gcc_target}- --disable-cpp \
  434. --disable-shared --disable-multilib $confopt
  435. if [ -d libiberty ]; then make -C libiberty; fi
  436. if [ -d texinfo ]; then make -C texinfo; fi
  437. hook_eval premake
  438. if [ "$xpkg" = "gcc2" ] ; then
  439. make -C gcc all LANGUAGES="c"
  440. hook_eval inmake
  441. make -C gcc install LANGUAGES="c"
  442. else
  443. # workaround for at least gcc-3.2.3
  444. mkdir -p $root/$prefix/lib/${gcc_lib_dir}
  445. if [ -d gcc ]; then
  446. make -C gcc all
  447. hook_eval inmake
  448. make -C gcc install
  449. else
  450. make all-gcc
  451. hook_eval inmake
  452. make install-gcc
  453. fi
  454. fi
  455. hook_eval postmake
  456. if [ -f $root/$prefix/lib/${gcc_lib_dir}/libgcc.a ]; then
  457. ${pkg_gcc_target}-ranlib \
  458. $root/$prefix/lib/${gcc_lib_dir}/libgcc.a
  459. fi
  460. if [ "$stagelevel" -eq 0 ]; then
  461. x="$root/$prefix/crosscc/${arch_target}"
  462. ln -svf ${arch_target}-gcc $x-gcc-${pkg_gcc_version}
  463. ln -svf ${arch_target}-g++ $x-g++-${pkg_gcc_version}
  464. ln -svf ${arch_target}-gcc $x-kcc-${pkg_gcc_version}
  465. ln -svf ${arch_target}-gcc $x-kcc
  466. ln -svf ${arch_target}-gcc $x-cc
  467. rm -vf "$root/$prefix/crosscc/gcc"
  468. rm -vf "$root/$prefix/crosscc/gcj"
  469. cd $root/$prefix/$arch_target/lib
  470. for x in Mcrt1.o crt1.o crti.o crtn.o gcrt1.o \
  471. libc.a libc.so libc_nonshared.a
  472. do
  473. if [ ! -e $x ]; then
  474. ln -fvs $root/../../usr/lib/$x $x
  475. fi
  476. done
  477. for x in ld-linux{,-$arch_machine}.so.2 ld.so.1 libc.so.{6,6.1}
  478. do ln -fvs $root/../../lib/$x $x ; done
  479. # glibc uses -lgcc_s with --as-needed, which fails if libgcc_s.{so,a}
  480. # is not even there. -- clifford & fake
  481. #
  482. # the shared object is not really needed.
  483. #if [ ! -e $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.so ]; then
  484. # ${pkg_gcc_target}-gcc -shared -nostdlib \
  485. # -o $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.so -x c /dev/null
  486. #fi
  487. if [ ! -e $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.a ]; then
  488. ${pkg_gcc_target}-gcc -x c /dev/null -c -o null.o
  489. ${pkg_gcc_target}-ar q null.a null.o; rm -f null.o
  490. ${pkg_gcc_target}-ranlib null.a
  491. mv null.a $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.a
  492. fi
  493. rm -f $root/$prefix/.lastupdate
  494. fi
  495. # GCC 4 does not install a specs file and removes old ones.
  496. # Regenerate the file with -dumpspecs.
  497. #
  498. if [ "${pkg_gcc_version:0:1}" -ge "4" ]; then
  499. [ "$stagelevel" -eq 0 ] && $root/$prefix/crosscc/${pkg_gcc_target}-gcc -dumpspecs > $root/$prefix/lib/${gcc_lib_dir}/specs
  500. [ "$stagelevel" -ne 0 ] && $root/$prefix/bin/${pkg_gcc_target}-gcc -dumpspecs > $root/$prefix/lib/${gcc_lib_dir}/specs
  501. fi
  502. if [ "$stagelevel" -eq 0 -o "$ROCKCFG_PSEUDONATIVE" = 1 ]; then
  503. echo "Adapting gcc specs file..."
  504. cd $root/$prefix/lib/${gcc_lib_dir}
  505. genrockspecs
  506. fi
  507. true
  508. }
  509. if [ "$stagelevel" -eq 0 -o -n "$pkg_gcc_cross" ]
  510. then
  511. custmain="gcc_cross"
  512. else
  513. custmain="custmain"
  514. fi
  515. case "$pkg_gcc_version" in
  516. 34|4*)
  517. gcc_lib_dir="gcc/${pkg_gcc_target}/${ver%%-*}"
  518. ;;
  519. *)
  520. gcc_lib_dir="gcc-lib/${pkg_gcc_target}/${ver%%-*}"
  521. ;;
  522. esac