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.

185 lines
5.1 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}g77 ${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. var_append GCC_WRAPPER_APPEND " " "$ROCKCFG_C_FLAGS"
  55. # Passing -I/usr{/local/}include creates a warning in gcc3 which is confusing
  56. # some of the configure scripts and Makefiles.
  57. #
  58. var_insert GCC3_WRAPPER_REMOVE " " "-I/usr/include"
  59. var_insert GCC3_WRAPPER_REMOVE " " "-I/usr/local/include"
  60. # Compile (i.e. link) all bins statically
  61. #
  62. if [ "$ROCKCFG_STATIC" = 1 ]; then
  63. var_insert GCC_WRAPPER_INSERT " " "-static"
  64. fi
  65. # Use the GCC 4.x stack protector
  66. #
  67. if [ $pkg != glibc23 -a $pkg != glibc22 -a \
  68. $pkg != grub -a $pkg != dietlibc -a $pkg != glibc ]
  69. then
  70. if [ "$ROCKCFG_PKG_GCC_STACKPRO" = 1 ] ; then
  71. var_append GCC4_WRAPPER_INSERT " " "-fstack-protector"
  72. fi
  73. fi
  74. # Compile with no exceptions or rtti, gcc itself must support both
  75. #
  76. if [ "$ROCKCFG_LIMITCXX" = 1 ] && [[ $pkg != gcc* ]] ; then
  77. var_append CXX_WRAPPER_APPEND " " "-fno-exceptions -fno-rtti"
  78. fi
  79. # Use automatically precompiled C++ headers
  80. #
  81. if [ "$ROCKCFG_AUTOPCH" = 1 ] ; then
  82. [ -n "$CXX" -a -n "`type -p g++-autopch`" ] && \
  83. CXX="eval AUTOPCHCXX=\"$CXX\" g++-autopch"
  84. fi
  85. # maybe we add something more later. But imo it's better to
  86. # let the options of KCC unmodified for gcc[23]. (Clifford)
  87. #
  88. if [[ $ROCKCFG_DEFAULT_KCC = gcc* ]] ; then
  89. if [ "$ROCKCFG_OPT" = "size" ] ; then
  90. var_insert KCC_WRAPPER_REMOVE " " "-O -O[0-9]"
  91. var_insert KCC_WRAPPER_INSERT " " "-Os"
  92. fi
  93. fi
  94. # Add the usual gcc optimization options
  95. # Strip or add debug information
  96. #
  97. if [ "$ROCKCFG_DEBUG" = 0 ] ; then
  98. var_append GCC_WRAPPER_APPEND " " "-s"
  99. var_insert GCC_WRAPPER_REMOVE " " "-g*"
  100. else
  101. if [[ $pkg != glibc* ]] ; then
  102. var_append GCC_WRAPPER_APPEND " " "-ggdb"
  103. fi
  104. var_insert GCC_WRAPPER_REMOVE " " "-s -g*"
  105. fi
  106. # remove other -O options from the argument list
  107. #
  108. if [ "$ROCKCFG_OPT" != default ] ; then
  109. var_insert GCC_WRAPPER_REMOVE " " "-O -O[0-9s]"
  110. fi
  111. case "$pkg" in
  112. glibc*)
  113. # do not mess with glibc -O options other than this
  114. var_insert GCC_WRAPPER_INSERT " " "-O2 -pipe"
  115. ;;
  116. *)
  117. case "$ROCKCFG_OPT" in
  118. smart)
  119. var_insert GCC_WRAPPER_INSERT " " "-SPEED-O2 -SIZE-Os -pipe"
  120. var_insert GCC_WRAPPER_FILTER "|" "gawk -f $base/misc/tools-source/smartwr.awk $base/scripts/smart_db.txt -"
  121. ;;
  122. bizarre)
  123. var_insert GCC_WRAPPER_INSERT " " "-SPEED-Os -SIZE-O2 -pipe"
  124. var_insert GCC_WRAPPER_FILTER "|" "gawk -f $base/misc/tools-source/smartwr.awk $base/scripts/smart_db.txt -"
  125. ;;
  126. speed)
  127. var_insert GCC_WRAPPER_INSERT " " "-O2 -pipe"
  128. ;;
  129. size)
  130. var_insert GCC_WRAPPER_INSERT " " "-Os -pipe"
  131. ;;
  132. lazy)
  133. var_insert GCC_WRAPPER_INSERT " " "-O1 -pipe"
  134. ;;
  135. test)
  136. case "$pkg" in
  137. gcc*|binutils*|make|bzip2|gzip|coreutils|bash*|gawk|sed)
  138. var_insert GCC_WRAPPER_INSERT " " "-Os -pipe"
  139. ;;
  140. *)
  141. var_insert GCC_WRAPPER_INSERT " " "-O1 -pipe"
  142. ;;
  143. esac
  144. ;;
  145. default)
  146. ;;
  147. esac
  148. ;;
  149. esac
  150. # Add the architecture gcc optimisation options
  151. #
  152. if [ -f architecture/$arch/gcc-options ] ; then
  153. . architecture/$arch/gcc-options
  154. fi
  155. # Use our chroot specs file for pseudonative
  156. #
  157. # if [ $stagelevel -gt 2 -a "$ROCKCFG_PSEUDONATIVE" = 1 ]; then
  158. # var_insert GCC_WRAPPER_INSERT " " "--specs=specs.chroot"
  159. # fi
  160. # register the forcefpic handler
  161. gcc_force_fpic_handler() {
  162. if [ "$forcefpic" = 1 ]; then
  163. # echo_status "Enabling force -fPIC mechanism for gcc."
  164. var_insert GCC_WRAPPER_INSERT " " "-fPIC"
  165. fi
  166. }
  167. hook_add prepare 7 'gcc_force_fpic_handler'
  168. fi # [ $stagelevel -ge 2 ]