gcc.spec 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. ##
  2. ## gcc.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
  4. ## Copyright (c) 2000-2003 Ralf S. Engelschall <rse@engelschall.com>
  5. ## Copyright (c) 2000-2003 Cable & Wireless <http://www.cw.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.1
  27. %define V_comp %nil
  28. %define V_bounds 3.3.1-1.00
  29. %define V_spp 3.3-3
  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: Compiler
  38. License: GPL
  39. Version: %{V_full}
  40. Release: 20030809
  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. # options sanity check
  50. %if "%{with_bounds}" == "yes" && "%{with_spp}" == "yes"
  51. RPM ERROR: options with_bounds and with_ssp conflict
  52. %endif
  53. # list of sources
  54. Source0: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{version}/gcc-%{version}.tar.bz2
  55. Patch0: gcc.patch
  56. Patch1: http://web.inter.nl.net/hcc/Haj.Ten.Brugge/bounds-checking-gcc-%{V_bounds}.patch.bz2
  57. Patch2: http://www.trl.ibm.com/projects/security/ssp/gcc3_3/protector-%{V_spp}.tar.gz
  58. # build information
  59. Prefix: %{l_prefix}
  60. BuildRoot: %{l_buildroot}
  61. BuildPreReq: OpenPKG, openpkg >= 20030103, make
  62. PreReq: OpenPKG, openpkg >= 20030103
  63. %if "%{with_binutils}" == "yes"
  64. BuildPreReq: binutils >= 2.13
  65. PreReq: binutils >= 2.13
  66. %endif
  67. AutoReq: no
  68. AutoReqProv: no
  69. %if "%{with_gcc}" == "yes"
  70. Provides: gcc = %{version}-%{release}
  71. %endif
  72. %description
  73. The GNU Compiler Collection (GCC) provides a standard conforming and
  74. highly portable ISO C and ISO C++ compiler.
  75. %prep
  76. %setup -q -n gcc-%{version}
  77. %patch0 -p0
  78. %if "%{with_bounds}" == "yes"
  79. %patch1 -p1
  80. %endif
  81. %if "%{with_spp}" == "yes"
  82. ( cd gcc
  83. %{l_gzip} -d -c %{PATCH protector-%{V_spp}.tar.gz} | %{l_tar} xf -
  84. %{l_patch} -p1 <protector.dif ) || exit $?
  85. %endif
  86. %{l_shtool} subst -v -s \
  87. -e "s;PREFIX_INCLUDE_DIR;PREFIX_INCLUDE_DIR_DISABLED;g" \
  88. gcc/configure
  89. %build
  90. # create build sub-directory
  91. mkdir obj
  92. cd obj
  93. # determine ld(1) and as(1) usage
  94. l_with_gnu_ld_as=""
  95. %if "%{with_binutils}" == "yes"
  96. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-ld --with-ld=%{l_prefix}/bin/ld"
  97. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-as --with-as=%{l_prefix}/bin/as"
  98. %else
  99. case "%{l_target}" in
  100. *-linux* | *-freebsd* )
  101. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-as --with-gnu-ld"
  102. ;;
  103. esac
  104. %endif
  105. # determine threads usage
  106. %if "%{with_threads}" == "yes"
  107. l_enable_threads="posix"
  108. %else
  109. l_enable_threads="single"
  110. %endif
  111. # determine language usage
  112. l_enable_languages="c"
  113. %if "%{with_cxx}" == "yes"
  114. l_enable_languages="${l_enable_languages},c++"
  115. %endif
  116. # configure the package
  117. CC="%{l_cc}" \
  118. CFLAGS="%{l_cflags}" \
  119. ../configure \
  120. --prefix=%{l_prefix} \
  121. --exec-prefix=%{l_prefix} \
  122. --includedir=%{l_prefix}/include/gcc%{V_comp} \
  123. --with-gxx-include-dir=%{l_prefix}/include/g++%{V_comp} \
  124. --with-local-prefix=%{l_prefix}/lib/gcc%{V_comp}-lib \
  125. --enable-languages="${l_enable_languages}" \
  126. --enable-threads="${l_enable_threads}" \
  127. --disable-maintainer-mode \
  128. --disable-shared \
  129. --disable-nls \
  130. ${l_with_gnu_ld_as}
  131. # explicitly redirect remaining gcc-lib directories
  132. %{l_shtool} subst -v -s \
  133. -e "s;/gcc-lib/;/gcc%{V_comp}-lib/;" \
  134. `find . -name Makefile -type f -print`
  135. # determine build flags
  136. l_cflags=""
  137. l_boot_cflags=""
  138. l_libcflags="-g"
  139. l_libcxxflags="-g"
  140. %if "%{with_binutils}" == "yes"
  141. # at least GNU as from GNU binutils supports -pipe always
  142. l_boot_cflags="$l_boot_cflags -pipe"
  143. l_libcxxflags="$l_libcxxflags -pipe"
  144. %endif
  145. %if "%{with_optimize}" == "yes"
  146. # conservatively optimize the generated program code
  147. # (also _tune_ for particular CPUs, but _without_ requiring these CPUs!)
  148. l_cflags="$l_cflags -O"
  149. l_boot_cflags="$l_boot_cflags -O2 -fomit-frame-pointer -funroll-loops"
  150. case "%{l_target}" in
  151. *x86-* ) l_boot_cflags="$l_boot_cflags -mcpu=pentium3" ;;
  152. *sparc64-* ) l_boot_cflags="$l_boot_cflags -mtune=v9" ;;
  153. esac
  154. l_libcxxflags="$l_libcxxflags -O2 -fno-implicit-templates"
  155. %else
  156. # else do no optimizations at all to reduce problems to minimum in advance
  157. l_boot_cflags="$l_boot_cflags -O0"
  158. l_libcxxflags="$l_libcxxflags -O0"
  159. %endif
  160. # build the package
  161. %{l_make} %{l_mflags} \
  162. MAKE="%{l_make} %{l_mflags}" \
  163. BOOT_CFLAGS="${l_boot_cflags}" \
  164. CFLAGS="${l_cflags}" \
  165. LIBCFLAGS="${l_libcflags}" \
  166. LIBCXXFLAGS="${l_libcxxflags}" \
  167. bootstrap-lean
  168. %install
  169. rm -rf $RPM_BUILD_ROOT
  170. # fetch GNU platform triple
  171. triple=`./config.guess`
  172. triple=`./config.sub ${triple}`
  173. # perform the standard installation procedure
  174. ( cd obj
  175. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  176. ) || exit $?
  177. # cleanup installation tree
  178. mv $RPM_BUILD_ROOT%{l_prefix}/lib/lib*.a \
  179. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}-lib/${triple}/%{V_full}/
  180. for multilib in `$RPM_BUILD_ROOT%{l_prefix}/bin/gcc --print-multi-lib`; do
  181. subdir=`echo "$multilib" | sed -e 's/;.*$//'`
  182. [ ".$subdir" = .. ] && continue
  183. mv $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir/lib*.a \
  184. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}-lib/${triple}/%{V_full}/$subdir/
  185. rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir
  186. done
  187. mv $RPM_BUILD_ROOT%{l_prefix}/${triple}/include/* \
  188. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}-lib/${triple}/%{V_full}/include/ \
  189. >/dev/null 2>&1 || true
  190. # strip installation tree
  191. rm -rf $RPM_BUILD_ROOT%{l_prefix}/${triple}
  192. rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man7 >/dev/null 2>&1 || true
  193. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.la >/dev/null 2>&1 || true
  194. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc* >/dev/null 2>&1 || true
  195. %if "%{with_cxx}" == "yes"
  196. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++ >/dev/null 2>&1 || true
  197. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++ >/dev/null 2>&1 || true
  198. %endif
  199. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  200. for prog in cc1 cc1plus collect2 cpp; do
  201. strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}-lib/${triple}/%{V_full}/${prog} \
  202. >/dev/null 2>&1 || true
  203. done
  204. # bump up installation tree
  205. ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc \
  206. $RPM_BUILD_ROOT%{l_prefix}/bin/cc
  207. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \
  208. $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1
  209. %if "%{with_cxx}" == "yes"
  210. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \
  211. $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1
  212. %endif
  213. # resolve filename conflicts
  214. %if "%{with_gcc}" != "yes" && "%{V_comp}" != ""
  215. ( cd $RPM_BUILD_ROOT%{l_prefix}/bin
  216. for file in *; do
  217. mv ${file} ${file}%{V_comp}
  218. done
  219. ) || exit $?
  220. ( cd $RPM_BUILD_ROOT%{l_prefix}/info
  221. for file in *; do
  222. mv ${file} `echo ${file} | sed -e 's;^\([^.]*\)\(\..*\)$;\1%{V_comp}\2;'`
  223. done
  224. ) || exit $?
  225. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man1
  226. for file in *; do
  227. mv ${file} `echo ${file} | sed -e 's;^\([^.]*\)\(\..*\)$;\1%{V_comp}\2;'`
  228. done
  229. ) || exit $?
  230. %endif
  231. # determine installation file list
  232. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
  233. %files -f files
  234. %clean
  235. rm -rf $RPM_BUILD_ROOT