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.

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