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.

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