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.

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