gcc.spec 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. ##
  2. ## gcc.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2003 Cable & Wireless Deutschland GmbH
  4. ## Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
  5. ## Copyright (c) 2000-2003 Ralf S. Engelschall <rse@engelschall.com>
  6. ##
  7. ## Permission to use, copy, modify, and distribute this software for
  8. ## any purpose with or without fee is hereby granted, provided that
  9. ## the above copyright notice and this permission notice appear in all
  10. ## copies.
  11. ##
  12. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  13. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  16. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  19. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  21. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. ## SUCH DAMAGE.
  24. ##
  25. # package version
  26. %define V_full 3.3
  27. %define V_comp %nil
  28. %define V_bounds 1.01
  29. %define V_spp 1
  30. # package information
  31. Name: gcc
  32. Summary: GNU Compiler Collection
  33. URL: http://gcc.gnu.org/
  34. Vendor: Free Software Foundation
  35. Packager: The OpenPKG Project
  36. Distribution: OpenPKG [CORE]
  37. Group: Language
  38. License: GPL
  39. Version: %{V_full}
  40. Release: 20030702
  41. # package options
  42. %option with_cxx yes
  43. %option with_optimize yes
  44. %option with_binutils yes
  45. %option with_threads yes
  46. %option with_bounds no
  47. %option with_spp no
  48. %option with_gcc no
  49. # list of sources
  50. Source0: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{version}/gcc-%{version}.tar.bz2
  51. Patch0: gcc.patch
  52. Patch1: http://web.inter.nl.net/hcc/Haj.Ten.Brugge/bounds-checking-gcc-%{version}-%{V_bounds}.patch.bz2
  53. Patch2: http://www.trl.ibm.com/projects/security/ssp/gcc3_3/protector-%{version}-%{V_spp}.tar.gz
  54. # build information
  55. Prefix: %{l_prefix}
  56. BuildRoot: %{l_buildroot}
  57. BuildPreReq: OpenPKG, openpkg >= 20030103, make
  58. PreReq: OpenPKG, openpkg >= 20030103
  59. %if "%{with_binutils}" == "yes"
  60. BuildPreReq: binutils >= 2.13
  61. PreReq: binutils >= 2.13
  62. %endif
  63. AutoReq: no
  64. AutoReqProv: no
  65. %if "%{with_gcc}" == "yes"
  66. Provides: gcc = %{version}-%{release}
  67. %endif
  68. %description
  69. The GNU Compiler Collection (GCC) provides a standard conforming and
  70. highly portable ISO C and ISO C++ compiler.
  71. %prep
  72. %setup -q -n gcc-%{version}
  73. %patch0 -p0
  74. %if "%{with_bounds}" == "yes"
  75. %patch1 -p1
  76. %endif
  77. %if "%{with_spp}" == "yes"
  78. ( cd gcc
  79. %{l_gzip} -d -c %{SOURCE protector-%{version}-%{V_spp}.tar.gz} | %{l_tar} xf -
  80. %{l_patch} -p1 <protector.dif )
  81. %endif
  82. %{l_shtool} subst -v -s \
  83. -e "s;PREFIX_INCLUDE_DIR;PREFIX_INCLUDE_DIR_DISABLED;g" \
  84. gcc/configure
  85. %build
  86. # create build sub-directory
  87. mkdir obj
  88. cd obj
  89. # determine ld(1) and as(1) usage
  90. l_with_gnu_ld_as=""
  91. %if "%{with_binutils}" == "yes"
  92. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-ld --with-ld=%{l_prefix}/bin/ld"
  93. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-as --with-as=%{l_prefix}/bin/as"
  94. %else
  95. case "%{l_target}" in
  96. *-linux* | *-freebsd* )
  97. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-as --with-gnu-ld"
  98. ;;
  99. esac
  100. %endif
  101. # determine threads usage
  102. %if "%{with_threads}" == "yes"
  103. l_enable_threads="posix"
  104. %else
  105. l_enable_threads="single"
  106. %endif
  107. # determine language usage
  108. l_enable_languages="c"
  109. %if "%{with_cxx}" == "yes"
  110. l_enable_languages="${l_enable_languages},c++"
  111. %endif
  112. # configure the package
  113. CC="%{l_cc}" \
  114. CFLAGS="%{l_cflags}" \
  115. ../configure \
  116. --prefix=%{l_prefix} \
  117. --exec-prefix=%{l_prefix} \
  118. --includedir=%{l_prefix}/include/gcc%{V_comp} \
  119. --with-gxx-include-dir=%{l_prefix}/include/g++%{V_comp} \
  120. --with-local-prefix=%{l_prefix}/lib/gcc%{V_comp}-lib \
  121. --enable-languages="${l_enable_languages}" \
  122. --enable-threads="${l_enable_threads}" \
  123. --disable-maintainer-mode \
  124. --disable-shared \
  125. --disable-nls \
  126. ${l_with_gnu_ld_as}
  127. # explicitly redirect remaining gcc-lib directories
  128. %{l_shtool} subst -v -s \
  129. -e "s;/gcc-lib/;/gcc%{V_comp}-lib/;" \
  130. `find . -name Makefile -type f -print`
  131. # determine build flags
  132. l_cflags=""
  133. l_boot_cflags=""
  134. l_libcflags="-g"
  135. l_libcxxflags="-g"
  136. %if "%{with_binutils}" == "yes"
  137. # at least GNU as from GNU binutils supports -pipe always
  138. l_boot_cflags="$l_boot_cflags -pipe"
  139. l_libcxxflags="$l_libcxxflags -pipe"
  140. %endif
  141. %if "%{with_optimize}" == "yes"
  142. # conservatively optimize the generated program code
  143. # (also _tune_ for particular CPUs, but _without_ requiring these CPUs!)
  144. l_cflags="$l_cflags -O"
  145. l_boot_cflags="$l_boot_cflags -O2 -fomit-frame-pointer -funroll-loops"
  146. case "%{l_target}" in
  147. *x86-* ) l_boot_cflags="$l_boot_cflags -mcpu=pentium3" ;;
  148. *sparc64-* ) l_boot_cflags="$l_boot_cflags -mtune=v9" ;;
  149. esac
  150. l_libcxxflags="$l_libcxxflags -O2 -fno-implicit-templates"
  151. %else
  152. # else do no optimizations at all to reduce problems to minimum in advance
  153. l_boot_cflags="$l_boot_cflags -O0"
  154. l_libcxxflags="$l_libcxxflags -O0"
  155. %endif
  156. # build the package
  157. %{l_make} %{l_mflags} \
  158. MAKE="%{l_make} %{l_mflags}" \
  159. BOOT_CFLAGS="${l_boot_cflags}" \
  160. CFLAGS="${l_cflags}" \
  161. LIBCFLAGS="${l_libcflags}" \
  162. LIBCXXFLAGS="${l_libcxxflags}" \
  163. bootstrap-lean
  164. %install
  165. rm -rf $RPM_BUILD_ROOT
  166. # fetch GNU platform triple
  167. triple=`./config.guess`
  168. triple=`./config.sub ${triple}`
  169. # perform the standard installation procedure
  170. ( cd obj
  171. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT )
  172. # cleanup installation tree
  173. mv $RPM_BUILD_ROOT%{l_prefix}/lib/lib*.a \
  174. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}-lib/${triple}/%{V_full}/
  175. mv $RPM_BUILD_ROOT%{l_prefix}/${triple}/include/* \
  176. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}-lib/${triple}/%{V_full}/include/ \
  177. >/dev/null 2>&1 || true
  178. # strip installation tree
  179. rm -rf $RPM_BUILD_ROOT%{l_prefix}/${triple}
  180. rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man7 >/dev/null 2>&1 || true
  181. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.la >/dev/null 2>&1 || true
  182. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc* >/dev/null 2>&1 || true
  183. %if "%{with_cxx}" == "yes"
  184. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++ >/dev/null 2>&1 || true
  185. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++ >/dev/null 2>&1 || true
  186. %endif
  187. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  188. for prog in cc1 cc1plus collect2 cpp; do
  189. strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}-lib/${triple}/%{V_full}/${prog} \
  190. >/dev/null 2>&1 || true
  191. done
  192. # bump up installation tree
  193. ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc \
  194. $RPM_BUILD_ROOT%{l_prefix}/bin/cc
  195. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \
  196. $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1
  197. %if "%{with_cxx}" == "yes"
  198. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \
  199. $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1
  200. %endif
  201. # resolve filename conflicts
  202. %if "%{with_gcc}" != "yes" && "%{V_comp}" != ""
  203. ( cd $RPM_BUILD_ROOT%{l_prefix}/bin
  204. for file in *; do
  205. mv ${file} ${file}%{V_comp}
  206. done )
  207. ( cd $RPM_BUILD_ROOT%{l_prefix}/info
  208. for file in *; do
  209. mv ${file} `echo ${file} | sed -e 's;^\([^.]*\)\(\..*\)$;\1%{V_comp}\2;'`
  210. done )
  211. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man1
  212. for file in *; do
  213. mv ${file} `echo ${file} | sed -e 's;^\([^.]*\)\(\..*\)$;\1%{V_comp}\2;'`
  214. done )
  215. %endif
  216. # determine installation file list
  217. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
  218. %files -f files
  219. %clean
  220. rm -rf $RPM_BUILD_ROOT