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.

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