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.

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