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.

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