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.

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