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.

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