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.

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