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.

277 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 - 2012 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. var_append confopt " " "--disable-libquadmath"
  112. # use the native libraries we build in the toolchain directory
  113. var_append extraconfopt ' ' '--with-gmp=$root'
  114. var_append extraconfopt ' ' '--with-mpfr=$root --with-mpfr-lib=$root/$libdir'
  115. var_append extraconfopt ' ' '--with-ppl=$root'
  116. var_append extraconfopt ' ' '--with-cloog=$root'
  117. export LDFLAGS="-Wl,-rpath,${root}${libdir}"
  118. fi
  119. if atstage cross; then
  120. # for gcc versions 4.3 and upwards we have to explicitely specifiy the
  121. # target architecture at cross-compiling stage
  122. var_append confopt ' ' '--target=$arch_target'
  123. # some configure tests of gcc > 4.3 need some help for linking
  124. var_append GCC_WRAPPER_APPEND ' ' "-Wl,-rpath,${root}/lib"
  125. fi
  126. if ! atstage native; then
  127. var_append confopt " " "--disable-libmudflap"
  128. else
  129. var_append confopt " " "--with-gnu-as"
  130. var_append confopt " " "--with-gnu-ld"
  131. var_append confopt " " "--enable-threads=posix"
  132. if [ "$SDECFG_PKG_GCC_JAVA" != 1 ] ; then
  133. var_append confopt " " "--disable-libgcj"
  134. else
  135. var_append confopt ' ' "--enable-libgcj"
  136. var_append confopt ' ' "--with-ecj-jar=$(match_source_file -p ecj)"
  137. var_append languages ',' 'java'
  138. if pkginstalled fastjar; then
  139. var_append confopt ' ' "--disable-fastjar"
  140. fi
  141. fi
  142. if [ "$SDECFG_PKG_GCC_OBJC" != 0 ] ; then
  143. var_append languages ',' 'objc'
  144. fi
  145. if [ "$SDECFG_PKG_GCC_F77" != 1 ] ; then
  146. var_append confopt " " "--disable-libgfortran"
  147. elif pkginstalled -f mpfr; then
  148. var_append languages ',' 'fortran'
  149. else
  150. echo_warning 'Fortran Compiler disabled, mpfr not found.'
  151. var_append confopt " " "--disable-libgfortran"
  152. fi
  153. if [ "$SDECFG_PKG_GCC_GO" != 1 ] ; then
  154. var_append confopt " " "--disable-libgo"
  155. else
  156. var_append languages ',' 'go'
  157. fi
  158. # Set enable-shared
  159. if [ "$diet_dynamic_static" == "static" ] ; then
  160. var_append confopt " " "--disable-shared"
  161. else
  162. var_append confopt " " "--enable-shared"
  163. fi
  164. fi
  165. var_append confopt " " "--enable-languages=$languages"
  166. gcc_premake() {
  167. # create and set up the xgcc cmd_wrapper
  168. setup_xgcc_wrapper
  169. if [ $arch = powerpc ] ; then
  170. ln -s ppc-nocross-linux-gnu powerpc-nocross-linux-gnu
  171. fi
  172. if atstage toolchain; then
  173. mkdir -p $root/$prefix/$arch_target/{bin,lib}
  174. rm -f $root/$prefix/$arch_target/include
  175. if [ -f $root/$prefix/include/stdio.h ]; then
  176. ln -s ../include $root/$prefix/$arch_target/include
  177. elif [ -f $root/$prefix/diet-include/stdio.h ]; then
  178. ln -s ../diet-include $root/$prefix/$arch_target/include
  179. fi
  180. fi
  181. }
  182. gcc_postmake()
  183. {
  184. # force a tools rebuild
  185. rm -fv $base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/.lastupdate
  186. # only minimal adaptions for stage0
  187. if atstage toolchain; then
  188. ${arch_target}-ranlib \
  189. $root/$libdir/${gcc_lib_dir}/libgcc.a
  190. for x in gcc-${ver:0:1} kcc{,-${ver:0:1}} cc; do
  191. ln -svf ${arch_target}-gcc \
  192. $root/$prefix/crosscc/${arch_target}-$x
  193. done
  194. ln -svf ${arch_target}-gcc $root/$prefix/crosscc/${arch_target}-cc
  195. rm -vf "$root/$prefix/crosscc/{gcc,gcj}"
  196. return
  197. fi
  198. if atstage cross; then
  199. # This stuff needs manual installation
  200. #
  201. echo "Creating /$prefix/${arch_target} ..."
  202. mkdir -p $root/$prefix/${arch_target}/lib
  203. # FIXME! temporal hack to install libgcc_s (Ticket #100)
  204. if [ "$SDECFG_MULTILIB" = 1 -a "$SDECFG_SPARC64_32BIT" != 1 ]; then
  205. rm -rf $root$libdir/libgcc_s*
  206. pushd $builddir/gcc-*/objdir/gcc/
  207. for x in libgcc_s*.so ; do
  208. cp -v $x $root$libdir/$x.1
  209. ln -sfv $x.1 $root$libdir/$x
  210. done
  211. popd
  212. fi
  213. else
  214. # Fix the location of any improperly installed (F77) libraries
  215. mv -vf $root/$libdir/$gcc_lib_dir/../lib* \
  216. $root/$libdir/$gcc_lib_dir || true
  217. fi
  218. # Create various symlinks for cc, c++, cpp and f77.
  219. #
  220. rm -f $root/$prefix/bin/cc
  221. ln -sfv gcc $root/$prefix/bin/cc
  222. ln -sfv ../$prefix/bin/cpp $root/lib/cpp
  223. ln -sfv gcc $root/$prefix/bin/kcc-${ver:0:1}
  224. ln -sfv gcc $root/$prefix/bin/kcc
  225. if [ -f $root/$prefix/bin/gfortran ] ; then
  226. rm -fv $root/$prefix/bin/f77
  227. ln -sfv gfortran $root/$prefix/bin/f77
  228. fi
  229. true
  230. }
  231. # Apply the respective gcc-2 or gcc-3 stack protector patch.
  232. hook_add prepatch 3 ". $base/package/*/gcc/apply-protector.sh"
  233. hook_add premake 5 "gcc_premake"
  234. hook_add postmake 5 "gcc_postmake"