OpenSDE Packages Database (without history before r20070)
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.

279 lines
8.7 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../gcc/gcc.conf
  5. # Copyright (C) 2006 - 2010 The OpenSDE Project
  6. # Copyright (C) 2004 - 2006 The T2 SDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- SDE-COPYRIGHT-NOTE-END ---
  15. # provide same settings we use for -m{arch,cpu,tune} via configure options
  16. # so they are default compiler settings on the final target machine
  17. if [ "${ver:0:3}" = "4.4" ]; then
  18. for x in $GCC_WRAPPER_INSERT $GCC_WRAPPER_APPEND; do
  19. case "$x" in
  20. -march=*|-mcpu=*|-mtune=*) var_append confopt " " "${x/-m/--with-}" ;;
  21. esac
  22. done
  23. fi
  24. # create and set up cmd_wrapper for xgcc
  25. function setup_xgcc_wrapper() {
  26. mkdir gcc ; pushd gcc
  27. cat <<-EOF > xgcc-wrapper
  28. #!/bin/bash
  29. # place the xgcc in the path
  30. export PATH="$PWD:\$PATH"
  31. [ "\$GCC_WRAPPER_DEBUG" = 1 ] && export CMD_WRAPPER_DEBUG=1
  32. mycmd=\$1
  33. if [ "\${mycmd%gcj}" != "\$mycmd" ]; then
  34. export CMD_WRAPPER_OTHERS="\$GCJ_WRAPPER_OTHERS"
  35. export CMD_WRAPPER_INSERT="\$GCJ_WRAPPER_INSERT"
  36. export CMD_WRAPPER_REMOVE="\$GCJ_WRAPPER_REMOVE"
  37. export CMD_WRAPPER_APPEND="\$GCJ_WRAPPER_APPEND"
  38. export CMD_WRAPPER_FILTER="\$GCJ_WRAPPER_FILTER"
  39. elif [ "\${mycmd%gfortran}" != "\$mycmd" ]; then
  40. export CMD_WRAPPER_OTHERS="\$F95_WRAPPER_OTHERS"
  41. export CMD_WRAPPER_INSERT="\$F95_WRAPPER_INSERT"
  42. export CMD_WRAPPER_REMOVE="\$F95_WRAPPER_REMOVE"
  43. export CMD_WRAPPER_APPEND="\$F95_WRAPPER_APPEND"
  44. export CMD_WRAPPER_FILTER="\$F95_WRAPPER_FILTER"
  45. else
  46. export CMD_WRAPPER_OTHERS="\$CC_WRAPPER_OTHERS:\$GCC_WRAPPER_OTHERS:\$GCC3_WRAPPER_OTHERS"
  47. export CMD_WRAPPER_INSERT="\$CC_WRAPPER_INSERT \$GCC_WRAPPER_INSERT \$GCC3_WRAPPER_INSERT"
  48. export CMD_WRAPPER_REMOVE="\$CC_WRAPPER_REMOVE \$GCC_WRAPPER_REMOVE \$GCC3_WRAPPER_REMOVE"
  49. export CMD_WRAPPER_APPEND="\$CC_WRAPPER_APPEND \$GCC_WRAPPER_APPEND \$GCC3_WRAPPER_APPEND"
  50. export CMD_WRAPPER_FILTER="\$CC_WRAPPER_FILTER|\$GCC_WRAPPER_FILTER|\$GCC3_WRAPPER_FILTER"
  51. fi
  52. exec cmd_wrapper "\$@"
  53. EOF
  54. chmod 0755 xgcc-wrapper
  55. export STAGE_CC_WRAPPER=$PWD/xgcc-wrapper
  56. popd
  57. }
  58. # We must use an 'objdir' directory for building gcc.
  59. hook_add preconf 9 "mkdir -p objdir; cd objdir"
  60. configscript="../configure"
  61. # See http://gcc.gnu.org/gcc-3.2/c++-abi.html
  62. # and http://www.codesourcery.com/cxx-abi/.
  63. if [ "$SDECFG_CROSSBUILD" = 1 ]; then
  64. # FIXME: stage 1 c++ packages fail if this is enabled
  65. var_append confopt ' ' "--disable-__cxa_atexit"
  66. elif [ "$arch_machine" != "i386" ]; then
  67. var_append confopt ' ' "--enable-__cxa_atexit"
  68. else
  69. var_append confopt ' ' "--disable-__cxa_atexit"
  70. fi
  71. # we might build a SVN or prereleases, disable checking
  72. var_append confopt ' ' '--disable-checking'
  73. # we build a cross compiler in stage0 and later use known good GCCs, no bstrap
  74. var_append confopt ' ' '--disable-bootstrap'
  75. # build version specific runtime libraries (default 0)
  76. # needed if multiple versions of gcc are installed
  77. [ "$SDECFG_PKG_GCC_VERSION_LIBS" = 1 ] && \
  78. var_append confopt " " "--enable-version-specific-runtime-libs"
  79. # build pre-compiled header (PCH) for libstdc++ (default 0)
  80. [ "$SDECFG_PKG_GCC_CXX_PCH" = 1 ] || \
  81. var_append confopt ' ' "--disable-libstdcxx-pch"
  82. # add the multi-lib config
  83. if [ "$SDECFG_MULTILIB" = 1 ]; then
  84. var_append confopt ' ' "--enable-multilib"
  85. if [ -n "$SDECFG_MULTILIBLIST" ]; then
  86. var_append confopt ' ' "--with-multilib-list=$SDECFG_MULTILIBLIST"
  87. fi
  88. else
  89. var_append confopt ' ' "--disable-multilib"
  90. fi
  91. if [ "${ver:0:3}" = "3.4" -o "${ver:0:1}" = "4" ]; then
  92. gcc_lib_dir="gcc/${arch_target}/${ver%%-*}"
  93. else
  94. gcc_lib_dir="gcc-lib/${arch_target}/${ver%%-*}"
  95. fi
  96. # available languages:
  97. # grep ^language= gcc/*/config-lang.in | cut -d\" -f2 | sort | tr '\n' ' '
  98. # ada c++ fortran java obj-c++ objc treelang
  99. # only C and C++ by default, and on every stage
  100. languages="c,c++"
  101. if atstage toolchain; then
  102. bindir="/$prefix/crosscc"
  103. var_append confopt " " "--with-sysroot=$sysroot"
  104. var_append confopt " " "--program-prefix=${arch_target}-"
  105. var_append confopt " " "--disable-cpp"
  106. var_append confopt " " "--disable-shared"
  107. var_append confopt " " "--disable-libssp"
  108. var_append confopt " " "--disable-libgomp"
  109. # use the native libraries we build in the toolchain directory
  110. var_append extraconfopt ' ' '--with-gmp=$root'
  111. var_append extraconfopt ' ' '--with-mpfr=$root --with-mpfr-lib=$root/$libdir'
  112. var_append extraconfopt ' ' '--with-ppl=$root'
  113. var_append extraconfopt ' ' '--with-cloog=$root'
  114. export LDFLAGS="-Wl,-rpath,${root}${libdir}"
  115. fi
  116. if atstage cross; then
  117. # for gcc versions 4.3 and upwards we have to explicitely specifiy the
  118. # target architecture at cross-compiling stage
  119. var_append confopt ' ' '--target=$arch_target'
  120. # some configure tests of gcc > 4.3 need some help for linking
  121. var_append GCC_WRAPPER_APPEND ' ' "-Wl,-rpath,${root}/lib"
  122. fi
  123. if ! atstage native; then
  124. var_append confopt " " "--disable-libmudflap"
  125. else
  126. var_append confopt " " "--with-gnu-as"
  127. var_append confopt " " "--with-gnu-ld"
  128. var_append confopt " " "--enable-threads=posix"
  129. if [ "$SDECFG_PKG_GCC_JAVA" != 1 ] ; then
  130. var_append confopt " " "--disable-libgcj"
  131. else
  132. var_append confopt ' ' "--enable-libgcj"
  133. var_append confopt ' ' "--with-ecj-jar=$(match_source_file -p ecj)"
  134. var_append languages ',' 'java'
  135. if pkginstalled fastjar; then
  136. var_append confopt ' ' "--disable-fastjar"
  137. fi
  138. fi
  139. if [ "$SDECFG_PKG_GCC_OBJC" != 0 ] ; then
  140. var_append languages ',' 'objc'
  141. fi
  142. if [ "$SDECFG_PKG_GCC_F77" != 1 ] ; then
  143. var_append confopt " " "--disable-libgfortran"
  144. elif pkginstalled -f mpfr; then
  145. var_append languages ',' 'fortran'
  146. else
  147. echo_warning 'Fortran Compiler disabled, mpfr not found.'
  148. var_append confopt " " "--disable-libgfortran"
  149. fi
  150. # Set enable-shared
  151. if [ "$diet_dynamic_static" == "static" ] ; then
  152. var_append confopt " " "--disable-shared"
  153. else
  154. var_append confopt " " "--enable-shared"
  155. fi
  156. fi
  157. var_append confopt " " "--enable-languages=$languages"
  158. gcc_premake() {
  159. # create and set up the xgcc cmd_wrapper
  160. setup_xgcc_wrapper
  161. if [ $arch = powerpc ] ; then
  162. ln -s ppc-nocross-linux-gnu powerpc-nocross-linux-gnu
  163. fi
  164. if atstage toolchain; then
  165. mkdir -p $root/$prefix/$arch_target/{bin,lib}
  166. rm -f $root/$prefix/$arch_target/include
  167. if [ -f $root/$prefix/include/stdio.h ]; then
  168. ln -s ../include $root/$prefix/$arch_target/include
  169. elif [ -f $root/$prefix/diet-include/stdio.h ]; then
  170. ln -s ../diet-include $root/$prefix/$arch_target/include
  171. fi
  172. fi
  173. }
  174. gcc_postmake()
  175. {
  176. # force a tools rebuild
  177. rm -fv $base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/.lastupdate
  178. # only minimal adaptions for stage0
  179. if atstage toolchain; then
  180. ${arch_target}-ranlib \
  181. $root/$libdir/${gcc_lib_dir}/libgcc.a
  182. for x in gcc-${ver:0:1} kcc{,-${ver:0:1}} cc; do
  183. ln -svf ${arch_target}-gcc \
  184. $root/$prefix/crosscc/${arch_target}-$x
  185. done
  186. ln -svf ${arch_target}-gcc $root/$prefix/crosscc/${arch_target}-cc
  187. rm -vf "$root/$prefix/crosscc/{gcc,gcj}"
  188. return
  189. fi
  190. if atstage cross; then
  191. # This stuff needs manual installation
  192. #
  193. echo "Creating /$prefix/${arch_target} ..."
  194. mkdir -p $root/$prefix/${arch_target}/lib
  195. # FIXME! temporal hack to install libgcc_s (Ticket #100)
  196. if [ "$SDECFG_MULTILIB" = 1 -a "$SDECFG_SPARC64_32BIT" != 1 ]; then
  197. rm -rf $root$libdir/libgcc_s*
  198. pushd $builddir/gcc-*/objdir/gcc/
  199. for x in libgcc_s*.so ; do
  200. cp -v $x $root$libdir/$x.1
  201. ln -sfv $x.1 $root$libdir/$x
  202. done
  203. popd
  204. fi
  205. else
  206. # Fix the location of any improperly installed (F77) libraries
  207. mv -vf $root/$libdir/$gcc_lib_dir/../lib* \
  208. $root/$libdir/$gcc_lib_dir || true
  209. fi
  210. # Create various symlinks for cc, c++, cpp and f77.
  211. #
  212. rm -f $root/$prefix/bin/cc
  213. ln -sfv gcc $root/$prefix/bin/cc
  214. ln -sfv ../$prefix/bin/cpp $root/lib/cpp
  215. ln -sfv gcc $root/$prefix/bin/kcc-${ver:0:1}
  216. ln -sfv gcc $root/$prefix/bin/kcc
  217. if [ -f $root/$prefix/bin/gfortran ] ; then
  218. rm -fv $root/$prefix/bin/f77
  219. ln -sfv gfortran $root/$prefix/bin/f77
  220. fi
  221. # Create symlinks for runtime libraries so they can be found by
  222. # the dynamic loader and force rebuilding of the wrapper links
  223. #
  224. if atstage native; then
  225. ( cd $root/$libdir ; ln -sfv ${gcc_lib_dir}/*.so.* . )
  226. # multilib w/ 32bit - we do just check for the output dir ...
  227. [ -e $root/$libdir/${gcc_lib_dir}/32 ] && (
  228. cd $root/$libdir/../lib/
  229. ln -sfv ../lib64/${gcc_lib_dir}/32/*.so.* .
  230. )
  231. fi
  232. true
  233. }
  234. # Apply the respective gcc-2 or gcc-3 stack protector patch.
  235. hook_add prepatch 3 ". $base/package/*/gcc/apply-protector.sh"
  236. hook_add premake 5 "gcc_premake"
  237. hook_add postmake 5 "gcc_postmake"