gcc.spec 9.4 KB

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