mirror of the now-defunct rocklinux.org
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.

188 lines
5.3 KiB

  1. #!/bin/bash
  2. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  3. #
  4. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  5. # Please add additional copyright information _after_ the line containing
  6. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  7. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  8. #
  9. # ROCK Linux: rock-src/package/base/gcc/parse-config
  10. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  11. #
  12. # This program is free software; you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; either version 2 of the License, or
  15. # (at your option) any later version. A copy of the GNU General Public
  16. # License can be found at Documentation/COPYING.
  17. #
  18. # Many people helped and are helping developing ROCK Linux. Please
  19. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  20. # file for details.
  21. #
  22. # --- ROCK-COPYRIGHT-NOTE-END ---
  23. if [ $stagelevel -ge 2 -o $stagelevel -eq 1 -a $pkg != gcc ]
  24. then
  25. # set CC, CXX and F77 environment variables
  26. #
  27. for x in CC CXX F77 ; do
  28. eval "y=\$ROCKCFG_DEFAULT_$x"
  29. if [[ $y = gcc* ]] ; then
  30. case "$x" in
  31. KCC)
  32. z="${archprefix}kcc ${archprefix}kcc-${y#gcc}" ;;
  33. CC)
  34. z="${archprefix}gcc ${archprefix}gcc-${y#gcc}" ;;
  35. CXX)
  36. z="${archprefix}g++ ${archprefix}g++-${y#gcc}" ;;
  37. F77)
  38. z="${archprefix}gfortran ${archprefix}g77 ${archprefix}gfortran-${y#gcc} ${archprefix}g77-${y#gcc}" ;;
  39. esac
  40. export $x=${x}_not_available_in_stage_${stagelevel}
  41. for y in $z ; do
  42. [ "`type -p $y`" ] && export $x=$y
  43. done
  44. fi
  45. done
  46. unset x y z
  47. if [ $stagelevel -ge 1 ] ; then
  48. if [[ "$xpkg" = *-32bit ]] ; then
  49. export CC="${CC} ${BUILD32}" CXX="${CXX} ${BUILD32}"
  50. elif [ "$ROCKCFG_MULTILIB" = 1 ] ; then
  51. export CC="${CC} ${BUILD64}" CXX="${CXX} ${BUILD64}"
  52. fi
  53. fi
  54. # Append all custom options so the gcc -V option always comes first.
  55. # The order of most other options doesn't matter; notable exceptions
  56. # are -L and -l (library).
  57. var_append GCC_WRAPPER_APPEND " " "$ROCKCFG_C_FLAGS"
  58. # Passing -I/usr{/local/}include creates a warning in gcc3 which is confusing
  59. # some of the configure scripts and Makefiles.
  60. #
  61. var_insert GCC3_WRAPPER_REMOVE " " "-I/usr/include"
  62. var_insert GCC3_WRAPPER_REMOVE " " "-I/usr/local/include"
  63. # Compile (i.e. link) all bins statically
  64. #
  65. if [ "$ROCKCFG_STATIC" = 1 ]; then
  66. var_insert GCC_WRAPPER_APPEND " " "-static"
  67. fi
  68. # Use the GCC 4.x stack protector
  69. #
  70. if [ $pkg != glibc23 -a $pkg != glibc22 -a \
  71. $pkg != grub -a $pkg != dietlibc -a $pkg != glibc ]
  72. then
  73. if [ "$ROCKCFG_PKG_GCC_STACKPRO" = 1 ] ; then
  74. var_append GCC4_WRAPPER_APPEND " " "-fstack-protector"
  75. fi
  76. fi
  77. # Compile with no exceptions or rtti, gcc itself must support both
  78. #
  79. if [ "$ROCKCFG_LIMITCXX" = 1 ] && [[ $pkg != gcc* ]] ; then
  80. var_append CXX_WRAPPER_APPEND " " "-fno-exceptions -fno-rtti"
  81. fi
  82. # Use automatically precompiled C++ headers
  83. #
  84. if [ "$ROCKCFG_AUTOPCH" = 1 ] ; then
  85. [ -n "$CXX" -a -n "`type -p g++-autopch`" ] && \
  86. CXX="eval AUTOPCHCXX=\"$CXX\" g++-autopch"
  87. fi
  88. # maybe we add something more later. But imo it's better to
  89. # let the options of KCC unmodified for gcc[23]. (Clifford)
  90. #
  91. if [[ $ROCKCFG_DEFAULT_KCC = gcc* ]] ; then
  92. if [ "$ROCKCFG_OPT" = "size" ] ; then
  93. var_insert KCC_WRAPPER_REMOVE " " "-O -O[0-9]"
  94. var_insert KCC_WRAPPER_APPEND " " "-Os"
  95. fi
  96. fi
  97. # Add the usual gcc optimization options
  98. # Strip or add debug information
  99. #
  100. if [ "$ROCKCFG_DEBUG" = 0 ] ; then
  101. var_append GCC_WRAPPER_APPEND " " "-s"
  102. var_insert GCC_WRAPPER_REMOVE " " "-g*"
  103. else
  104. if [[ $pkg != glibc* ]] ; then
  105. var_append GCC_WRAPPER_APPEND " " "-ggdb"
  106. fi
  107. var_insert GCC_WRAPPER_REMOVE " " "-s -g*"
  108. fi
  109. # remove other -O options from the argument list
  110. #
  111. if [ "$ROCKCFG_OPT" != default ] ; then
  112. var_insert GCC_WRAPPER_REMOVE " " "-O -O[0-9s]"
  113. fi
  114. case "$pkg" in
  115. glibc*)
  116. # do not mess with glibc -O options other than this
  117. var_insert GCC_WRAPPER_APPEND " " "-O2 -pipe"
  118. ;;
  119. *)
  120. case "$ROCKCFG_OPT" in
  121. smart)
  122. var_insert GCC_WRAPPER_APPEND " " "-SPEED-O2 -SIZE-Os -pipe"
  123. var_insert GCC_WRAPPER_FILTER "|" "gawk -f $base/misc/tools-source/smartwr.awk $base/scripts/smart_db.txt -"
  124. ;;
  125. bizarre)
  126. var_insert GCC_WRAPPER_APPEND " " "-SPEED-Os -SIZE-O2 -pipe"
  127. var_insert GCC_WRAPPER_FILTER "|" "gawk -f $base/misc/tools-source/smartwr.awk $base/scripts/smart_db.txt -"
  128. ;;
  129. speed)
  130. var_insert GCC_WRAPPER_APPEND " " "-O2 -pipe"
  131. ;;
  132. size)
  133. var_insert GCC_WRAPPER_APPEND " " "-Os -pipe"
  134. ;;
  135. lazy)
  136. var_insert GCC_WRAPPER_APPEND " " "-O1 -pipe"
  137. ;;
  138. test)
  139. case "$pkg" in
  140. gcc*|binutils*|make|bzip2|gzip|coreutils|bash*|gawk|sed)
  141. var_insert GCC_WRAPPER_APPEND " " "-Os -pipe"
  142. ;;
  143. *)
  144. var_insert GCC_WRAPPER_APPEND " " "-O1 -pipe"
  145. ;;
  146. esac
  147. ;;
  148. default)
  149. ;;
  150. esac
  151. ;;
  152. esac
  153. # Add the architecture gcc optimisation options
  154. #
  155. if [ -f architecture/$arch/gcc-options ] ; then
  156. . architecture/$arch/gcc-options
  157. fi
  158. # Use our chroot specs file for pseudonative
  159. #
  160. # if [ $stagelevel -gt 2 -a "$ROCKCFG_PSEUDONATIVE" = 1 ]; then
  161. # var_insert GCC_WRAPPER_INSERT " " "--specs=specs.chroot"
  162. # fi
  163. # register the forcefpic handler
  164. gcc_force_fpic_handler() {
  165. if [ "$forcefpic" = 1 ]; then
  166. # echo_status "Enabling force -fPIC mechanism for gcc."
  167. var_insert GCC_WRAPPER_APPEND " " "-fPIC"
  168. fi
  169. }
  170. hook_add prepare 7 'gcc_force_fpic_handler'
  171. fi # [ $stagelevel -ge 2 ]