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.

278 lines
8.6 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 languages ',' 'java'
  134. if pkginstalled fastjar; then
  135. var_append confopt ' ' "--disable-fastjar"
  136. fi
  137. fi
  138. if [ "$SDECFG_PKG_GCC_OBJC" != 0 ] ; then
  139. var_append languages ',' 'objc'
  140. fi
  141. if [ "$SDECFG_PKG_GCC_F77" != 1 ] ; then
  142. var_append confopt " " "--disable-libgfortran"
  143. elif pkginstalled -f mpfr; then
  144. var_append languages ',' 'fortran'
  145. else
  146. echo_warning 'Fortran Compiler disabled, mpfr not found.'
  147. var_append confopt " " "--disable-libgfortran"
  148. fi
  149. # Set enable-shared
  150. if [ "$diet_dynamic_static" == "static" ] ; then
  151. var_append confopt " " "--disable-shared"
  152. else
  153. var_append confopt " " "--enable-shared"
  154. fi
  155. fi
  156. var_append confopt " " "--enable-languages=$languages"
  157. gcc_premake() {
  158. # create and set up the xgcc cmd_wrapper
  159. setup_xgcc_wrapper
  160. if [ $arch = powerpc ] ; then
  161. ln -s ppc-nocross-linux-gnu powerpc-nocross-linux-gnu
  162. fi
  163. if atstage toolchain; then
  164. mkdir -p $root/$prefix/$arch_target/{bin,lib}
  165. rm -f $root/$prefix/$arch_target/include
  166. if [ -f $root/$prefix/include/stdio.h ]; then
  167. ln -s ../include $root/$prefix/$arch_target/include
  168. elif [ -f $root/$prefix/diet-include/stdio.h ]; then
  169. ln -s ../diet-include $root/$prefix/$arch_target/include
  170. fi
  171. fi
  172. }
  173. gcc_postmake()
  174. {
  175. # force a tools rebuild
  176. rm -fv $base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/.lastupdate
  177. # only minimal adaptions for stage0
  178. if atstage toolchain; then
  179. ${arch_target}-ranlib \
  180. $root/$libdir/${gcc_lib_dir}/libgcc.a
  181. for x in gcc-${ver:0:1} kcc{,-${ver:0:1}} cc; do
  182. ln -svf ${arch_target}-gcc \
  183. $root/$prefix/crosscc/${arch_target}-$x
  184. done
  185. ln -svf ${arch_target}-gcc $root/$prefix/crosscc/${arch_target}-cc
  186. rm -vf "$root/$prefix/crosscc/{gcc,gcj}"
  187. return
  188. fi
  189. if atstage cross; then
  190. # This stuff needs manual installation
  191. #
  192. echo "Creating /$prefix/${arch_target} ..."
  193. mkdir -p $root/$prefix/${arch_target}/lib
  194. # FIXME! temporal hack to install libgcc_s (Ticket #100)
  195. if [ "$SDECFG_MULTILIB" = 1 -a "$SDECFG_SPARC64_32BIT" != 1 ]; then
  196. rm -rf $root$libdir/libgcc_s*
  197. pushd $builddir/gcc-*/objdir/gcc/
  198. for x in libgcc_s*.so ; do
  199. cp -v $x $root$libdir/$x.1
  200. ln -sfv $x.1 $root$libdir/$x
  201. done
  202. popd
  203. fi
  204. else
  205. # Fix the location of any improperly installed (F77) libraries
  206. mv -vf $root/$libdir/$gcc_lib_dir/../lib* \
  207. $root/$libdir/$gcc_lib_dir || true
  208. fi
  209. # Create various symlinks for cc, c++, cpp and f77.
  210. #
  211. rm -f $root/$prefix/bin/cc
  212. ln -sfv gcc $root/$prefix/bin/cc
  213. ln -sfv ../$prefix/bin/cpp $root/lib/cpp
  214. ln -sfv gcc $root/$prefix/bin/kcc-${ver:0:1}
  215. ln -sfv gcc $root/$prefix/bin/kcc
  216. if [ -f $root/$prefix/bin/gfortran ] ; then
  217. rm -fv $root/$prefix/bin/f77
  218. ln -sfv gfortran $root/$prefix/bin/f77
  219. fi
  220. # Create symlinks for runtime libraries so they can be found by
  221. # the dynamic loader and force rebuilding of the wrapper links
  222. #
  223. if atstage native; then
  224. ( cd $root/$libdir ; ln -sfv ${gcc_lib_dir}/*.so.* . )
  225. # multilib w/ 32bit - we do just check for the output dir ...
  226. [ -e $root/$libdir/${gcc_lib_dir}/32 ] && (
  227. cd $root/$libdir/../lib/
  228. ln -sfv ../lib64/${gcc_lib_dir}/32/*.so.* .
  229. )
  230. fi
  231. true
  232. }
  233. # Apply the respective gcc-2 or gcc-3 stack protector patch.
  234. hook_add prepatch 3 ". $base/package/*/gcc/apply-protector.sh"
  235. hook_add premake 5 "gcc_premake"
  236. hook_add postmake 5 "gcc_postmake"