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.

358 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" = 0 ] ; 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 [ $pkg = gcc3 -a "$ROCKCFG_PKG_GCC3_NO_JAVA" = 1 ] || \
  138. [ $pkg = gcc33 -a "$ROCKCFG_PKG_GCC33_NO_JAVA" = 1 ] || \
  139. [ $pkg = gccx -a "$ROCKCFG_PKG_GCCX_NO_JAVA" = 1 ] ; then
  140. # gcc-3.x contains no chill compiler
  141. confopt="$confopt --enable-languages=c,c++,objc,f77"
  142. elif [ "$arch" = mips ] ; then
  143. # MIPS doesn't like the Java compiler
  144. confopt="$confopt --disable-libgcj"
  145. fi
  146. # See http://gcc.gnu.org/gcc-3.2/c++-abi.html
  147. # and http://www.codesourcery.com/cxx-abi/.
  148. if [ $pkg != gcc2 ] ; then
  149. confopt="$confopt --enable-__cxa_atexit"
  150. fi
  151. # Configure, build and install as usual
  152. #
  153. eval $configprefix ../configure $confopt --with-gnu-as \
  154. --enable-version-specific-runtime-libs \
  155. --with-gnu-ld --enable-threads=posix \
  156. --enable-shared
  157. hook_eval premake
  158. eval "$MAKE GCJFLAGS=\"$CXXFLAGS\" all"
  159. hook_eval inmake
  160. eval "$MAKE $makeinstopt install"
  161. # Fix the location of any improperly installed (F77) libraries
  162. mv -vf $root/$prefix/lib/$gcc_lib_dir/../lib* \
  163. $root/$prefix/lib/$gcc_lib_dir || true
  164. fi
  165. hook_eval postmake
  166. # Rename and install binaries
  167. #
  168. cd $builddir/inst_bin ; mkdir -p $root/$prefix/bin
  169. for y in c++ c++filt g++ cpp f77 g77 gcc gcov ; do
  170. for x in $y ${arch_target}-$y ; do
  171. if [ -f "$x" ] ; then
  172. mv -v $x $root/$prefix/bin/${x}-${pkg#gcc}
  173. fi
  174. done
  175. done
  176. if [ "$pkg" = gcc2 ] ; then
  177. ln -vsf $root/$prefix/bin/c++filt-2 c++filt-binutils
  178. fi
  179. # Rename and install info-files
  180. #
  181. cd $builddir/inst_info ; mkdir -p $root/$prefix/info
  182. for x in * ; do
  183. [ ! -f $x ] && continue # e.g. if $x becomes '*' somehow
  184. fn=$( echo $x | sed "s,\([a-z0-9]*\),\1-${pkg#gcc}," )
  185. infoname=$( echo $x | sed "s,\([a-z0-9]*\).*,\1," )
  186. echo "$x -> $root/$prefix/info/$fn"
  187. sed "s,$infoname.info,$infoname-${pkg#gcc}.info," < $x \
  188. > $root/$prefix/info/$fn
  189. if [ $ROCKCFG_DEFAULT_CC = $pkg ] ; then
  190. cp -v $x $root/$prefix/info/$x
  191. fi
  192. true
  193. done
  194. # Rename and install man-pages
  195. #
  196. cd $builddir/inst_man/man1
  197. mkdir -p $root/$prefix/man/man1
  198. for x in * ; do
  199. [ ! -f $x ] && continue # e.g. if $x becomes '*' somehow
  200. mv -v $x $root/$prefix/man/man1/${x%.1}-${pkg#gcc}.1
  201. if [ $ROCKCFG_DEFAULT_CC = $pkg ] ; then
  202. ln -sf ${x%.1}-${pkg#gcc}.1 $root/$prefix/man/man1/$x
  203. fi
  204. true
  205. done
  206. hook_eval postdoc
  207. # Create various symlinks for cc, c++, cpp and f77.
  208. #
  209. if [ $ROCKCFG_DEFAULT_CC = $pkg ] ; then
  210. create_links gcc cpp gcov
  211. rm -f $root/$prefix/bin/cc
  212. if [ "$ROCKCFG_DIETLIBC_ALL" = 1 ]; then
  213. cat <<- 'EOT' > $root/$prefix/bin/cc
  214. #!/bin/sh
  215. exec diet gcc "$@"
  216. EOT
  217. chmod +x $root/$prefix/bin/cc
  218. else
  219. ln -svf gcc $root/$prefix/bin/cc
  220. fi
  221. ln -vsf ../$prefix/bin/cpp $root/lib/cpp
  222. fi
  223. ln -sf gcc-${pkg#gcc} $root/$prefix/bin/kcc-${pkg#gcc}
  224. if [ $ROCKCFG_DEFAULT_KCC = $pkg ] ; then
  225. ln -vsf gcc-${pkg#gcc} $root/$prefix/bin/kcc
  226. fi
  227. if [ $ROCKCFG_DEFAULT_CXX = $pkg ] ; then
  228. create_links c++ c++filt g++
  229. fi
  230. if [ $ROCKCFG_DEFAULT_F77 = $pkg ] ; then
  231. create_links g77
  232. rm -vf $root/$prefix/bin/f77
  233. ln -vsf g77 $root/$prefix/bin/f77
  234. fi
  235. # Create symlinks for runtime libraries so they can be found by
  236. # the dynamic loader and force rebuilding of the wrapper links
  237. #
  238. if [ $stagelevel -gt 1 ] ; then
  239. ( cd $root/$prefix/lib ; ln -vfs ${gcc_lib_dir}/*.so.* . ; )
  240. rm -fv $base/build/$ROCKCFG_ID/$toolsdir/.lastupdate
  241. fi
  242. true
  243. }
  244. gcc_stage0() {
  245. # Apply the respective gcc-2 or gcc-3 stack protector patch.
  246. . $base/package/base/gcc3/apply-protector.sh $base $pkg "$desc_D"
  247. mkdir -p $root/$prefix/$arch_target/{bin,lib}
  248. rm -f $root/$prefix/$arch_target/include
  249. if [ -f $root/$prefix/include/stdio.h ]; then
  250. ln -s ../include $root/$prefix/$arch_target/include
  251. elif [ -f $root/$prefix/diet-include/stdio.h ]; then
  252. ln -s ../diet-include $root/$prefix/$arch_target/include
  253. fi
  254. mkdir objdir ; cd objdir
  255. bindir="$root/$prefix/crosscc"; mkdir -p $root/$prefix/crosscc
  256. [ "$pkg" != "gcc2" ] && \
  257. confopt="$confopt --enable-languages=c"
  258. hook_eval preconf
  259. eval ../configure --program-prefix=${arch_target}- --disable-cpp \
  260. --disable-shared --disable-multilib $confopt
  261. make -C libiberty
  262. if [ -d texinfo ] ; then make -C texinfo ; fi
  263. hook_eval premake
  264. if [ "$pkg" = "gcc2" ] ; then
  265. make -C gcc all LANGUAGES="c"
  266. hook_eval inmake
  267. make -C gcc install LANGUAGES="c"
  268. else
  269. # workaround for at least gcc-3.2.3
  270. mkdir -p $root/$prefix/lib/${gcc_lib_dir}
  271. make -C gcc all
  272. hook_eval inmake
  273. make -C gcc install
  274. fi
  275. hook_eval postmake
  276. ${arch_target}-ranlib \
  277. $root/$prefix/lib/${gcc_lib_dir}/libgcc.a
  278. x="$root/$prefix/crosscc/${arch_target}"
  279. ln -svf ${arch_target}-gcc $x-gcc-${pkg#gcc}
  280. ln -svf ${arch_target}-gcc $x-kcc-${pkg#gcc}
  281. ln -svf ${arch_target}-gcc $x-kcc
  282. ln -svf ${arch_target}-gcc $x-cc
  283. rm -vf "$root/$prefix/crosscc/gcc"
  284. rm -vf "$root/$prefix/crosscc/gcj"
  285. cd $root/$prefix/$arch_target/lib
  286. for x in Mcrt1.o crt1.o crti.o crtn.o gcrt1.o \
  287. libc.a libc.so libc_nonshared.a
  288. do ln -fvs $root/../root/usr/lib/$x $x ; done
  289. for x in ld-linux{,-$arch_machine}.so.2 ld.so.1 libc.so.{6,6.1}
  290. do ln -fvs $root/../root/lib/$x $x ; done
  291. echo "Adapting gcc specs file..."
  292. cd $root/$prefix/lib/${gcc_lib_dir}
  293. mv specs specs.orig
  294. x="$base/build/$ROCKCFG_ID/root"
  295. tr '\n' '@' < specs.orig | \
  296. sed -e "s|@\\*link:@|@*link:@-L $x/lib |" \
  297. -e "s|@\\*link:@|@*link:@-L $x/usr/lib |" \
  298. -e "s|@\\*link:@|@*link:@-L $x/usr/local/lib |" \
  299. -e "s|@\\*link:@|@*link:@-L $x/usr/$arch_target/lib |" \
  300. -e "s|@\\*link:@|@*link:@-L /usr/$arch_target/lib |" \
  301. -e "s|@\\*cpp:@|@*cpp:@-I $x/usr/include |" \
  302. -e "s|@\\*cpp:@|@*cpp:@-I $x/usr/local/include |" \
  303. -e "s|@\\*cpp:@|@*cpp:@-I $x/usr/$arch_target/include |" \
  304. -e "s|@\\*cpp:@|@*cpp:@-I $x/usr/$arch_target/include |" \
  305. -e "s|@\\*cpp:@|@*cpp:@-I /usr/$arch_target/include |" |
  306. tr '@' '\n' > specs
  307. rm -f $root/$prefix/.lastupdate
  308. }
  309. if [ "$stagelevel" -eq 0 ]; then
  310. custmain="gcc_stage0"
  311. else
  312. custmain="custmain"
  313. fi
  314. gcc_lib_dir="gcc-lib/${arch_target}/${ver%%-*}"