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.

156 lines
4.8 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: package/.../gcc/parse-config
  6. # Copyright (C) 2004 - 2006 The T2 SDE Project
  7. # Copyright (C) 1998 - 2003 Clifford Wolf
  8. #
  9. # More information can be found in the files COPYING and README.
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; version 2 of the License. A copy of the
  14. # GNU General Public License can be found in the file COPYING.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. # Use the stack protector patch, if not disabled for the pkg
  17. #
  18. if [ "${SDECFG_DEFAULT_CC:0:3}" = "gcc" -a "$SDECFG_PKG_GCC_STACKPRO" = 1 ]; then
  19. if ! hasflag NO-SSP; then
  20. var_append GCC_WRAPPER_INSERT ' ' '-fstack-protector'
  21. else
  22. echo_warning 'Package incompatible with GCC stack-protector, disabled'
  23. fi
  24. fi
  25. # maybe we add something more later. But imo it's better to
  26. # let the options of KCC unmodified for gcc[23]. (Clifford)
  27. #
  28. if [[ $SDECFG_DEFAULT_KCC = gcc* ]] ; then
  29. export KCC="${archprefix}kcc"
  30. if [ "$SDECFG_OPT" = "size" ] ; then
  31. var_insert KCC_WRAPPER_REMOVE " " "-O -O[0-9]"
  32. var_insert KCC_WRAPPER_INSERT " " "-Os"
  33. fi
  34. fi
  35. # set CC, CXX and F77 environment variables
  36. #
  37. for x in CC CXX F77 ; do
  38. eval "y=\$SDECFG_DEFAULT_$x"
  39. if [[ $y = gcc* ]] ; then
  40. case "$x-$stagelevel" in
  41. CC-*)
  42. z="${archprefix}gcc ${archprefix}gcc" ;;
  43. CXX-[1-9])
  44. z="${archprefix}g++ ${archprefix}g++" ;;
  45. F77-[2-9])
  46. z="${archprefix}g77 ${archprefix}g77" ;;
  47. *)
  48. export $x=${x}_not_available_in_stage_${stagelevel}
  49. continue ;;
  50. esac
  51. for y in $z ; do
  52. [ "`type -p $y`" ] && export $x=$y
  53. done
  54. fi
  55. done
  56. # Add the usual gcc optimazation options
  57. # Strip or add debug information
  58. #
  59. if [ "$SDECFG_DEBUG" = 0 ] ; then
  60. var_append GCC_WRAPPER_APPEND " " "-s"
  61. var_append SYSGCC_WRAPPER_APPEND " " "-s"
  62. var_insert GCC_WRAPPER_REMOVE " " "-g*"
  63. var_insert SYSGCC_WRAPPER_REMOVE " " "-g*"
  64. else
  65. if [[ $pkg != glibc* ]] ; then
  66. var_append GCC_WRAPPER_APPEND " " "-ggdb"
  67. var_insert GCC_WRAPPER_REMOVE " " "-s -g*"
  68. fi
  69. fi
  70. # Remove the optimization options, since we pass generic ones ... In ROCK
  71. # history this has been -m*, but this caused -msse and -maltivec style options
  72. # to get lost. So we better explicitly only remove some -m options ... -ReneR
  73. var_insert GCC_WRAPPER_REMOVE " " "-O -O[0-9s] -mtune* -march* -mcpu*"
  74. var_insert SYSGCC_WRAPPER_REMOVE " " "-O -O[0-9s] -mtune* -march* -mcpu*"
  75. case "$SDECFG_OPT" in
  76. smart)
  77. var_insert GCC_WRAPPER_INSERT " " "-SPEED-O2 -SIZE-Os"
  78. var_insert GCC_WRAPPER_FILTER "|" "gawk -f $base/misc/tools-source/smartwr.awk $base/scripts/smart_db.txt -"
  79. #SYSGCC - though smart is phasing out
  80. ;;
  81. speed)
  82. var_insert GCC_WRAPPER_INSERT " " "-O2"
  83. var_insert SYSGCC_WRAPPER_INSERT " " "-O2"
  84. ;;
  85. size)
  86. var_insert GCC_WRAPPER_INSERT " " "-Os"
  87. var_insert SYSGCC_WRAPPER_INSERT " " "-Os"
  88. ;;
  89. lazy)
  90. var_insert GCC_WRAPPER_INSERT " " "-O"
  91. var_insert SYSGCC_WRAPPER_INSERT " " "-O"
  92. ;;
  93. esac
  94. # gcc-4.1.0 hangs with -v --help -pipe, thus we do not add it in that case
  95. var_insert GCC_WRAPPER_INSERT ' ' '--help?:-pipe'
  96. var_insert SYSGCC_WRAPPER_INSERT ' ' '--help?:-pipe'
  97. [ "$SDECFG_LD_AS_NEEDED" != 0 ] &&
  98. var_append GCC_WRAPPER_INSERT " " "-c?:-Wl,--as-needed"
  99. [ "$SDECFG_PIE" != 0 ] &&
  100. var_append GCC_WRAPPER_INSERT " " "-c?-fPIE:-pie"
  101. var_append GCC_WRAPPER_APPEND " " "$SDECFG_C_FLAGS"
  102. # Compile (i.e. link) all bins statically
  103. #
  104. if [ "$SDECFG_STATIC" = 1 ]; then
  105. var_insert GCC_WRAPPER_INSERT " " "-static"
  106. fi
  107. # Compile with no exceptions or rtti, gcc itself must support both
  108. #
  109. if [ "$SDECFG_LIMITCXX" = 1 ] && [[ $pkg != gcc* ]] ; then
  110. var_append CXX_WRAPPER_APPEND " " "-fno-exceptions -fno-rtti"
  111. fi
  112. # Passing -I/usr{/local/}include creates a warning in gcc3 which is confusing
  113. # some of the configure scripts and Makefiles.
  114. #
  115. var_insert GCC3_WRAPPER_REMOVE " " "-I/usr/include"
  116. var_insert GCC3_WRAPPER_REMOVE " " "-I/usr/local/include"
  117. # pkg-config and other output or hardcoded configure assumption
  118. # do not include the "DESTDIR" we need to adapt the pathes accordingly
  119. if atstage cross; then
  120. var_append GCC_WRAPPER_FILTER '|' \
  121. "sed -e 's,^\(-[LI]\)*\(/\|/usr/\|/usr/[^/]*/\|/opt/[^/]*/\)\(include\|lib\),\1$root\2\3,'"
  122. fi
  123. # Add the architecture gcc optimisation options
  124. #
  125. if [ -f architecture/$arch/gcc-options.in ] ; then
  126. . architecture/$arch/gcc-options.in
  127. fi
  128. # Inject -fPIC if the package is marked to need a quirk ...
  129. #
  130. hasflag FPIC-QUIRK && var_append GCC_WRAPPER_APPEND ' ' '-fPIC'
  131. # Remove -W,l,--as-needed, some packages throw up with it...
  132. #
  133. if hasflag NO-AS-NEEDED; then
  134. var_remove_regex GCC_WRAPPER_INSERT ' ' ".*-Wl,--as-needed"
  135. var_append GCC_WRAPPER_REMOVE ' ' "-Wl,--as-needed"
  136. fi