gcc.spec 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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-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: 20030912
  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. RPM ERROR: options with_bounds and with_ssp 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 >= 20030909, make
  65. PreReq: OpenPKG, openpkg >= 20030909
  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. %build
  93. # create build sub-directory
  94. mkdir obj
  95. cd obj
  96. # determine ld(1) and as(1) usage
  97. l_with_gnu_ld_as=""
  98. %if "%{with_binutils}" == "yes"
  99. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-ld --with-ld=%{l_prefix}/bin/ld"
  100. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-as --with-as=%{l_prefix}/bin/as"
  101. %else
  102. case "%{l_platform -t}" in
  103. *-linux* | *-freebsd* )
  104. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-as --with-gnu-ld"
  105. ;;
  106. esac
  107. %endif
  108. # determine threads usage
  109. %if "%{with_threads}" == "yes"
  110. l_enable_threads="posix"
  111. %else
  112. l_enable_threads="single"
  113. %endif
  114. # determine language usage
  115. l_enable_languages="c"
  116. %if "%{with_cxx}" == "yes"
  117. l_enable_languages="${l_enable_languages},c++"
  118. %endif
  119. %if "%{with_objc}" == "yes"
  120. l_enable_languages="${l_enable_languages},objc"
  121. %endif
  122. %if "%{with_java}" == "yes"
  123. l_enable_languages="${l_enable_languages},java"
  124. %endif
  125. %if "%{with_f77}" == "yes"
  126. l_enable_languages="${l_enable_languages},f77"
  127. %endif
  128. # configure the package
  129. CC="%{l_cc}" \
  130. CFLAGS="%{l_cflags}" \
  131. ../configure \
  132. --prefix=%{l_prefix} \
  133. --exec-prefix=%{l_prefix} \
  134. --includedir=%{l_prefix}/include/gcc%{V_comp} \
  135. --with-gxx-include-dir=%{l_prefix}/include/g++%{V_comp} \
  136. --with-local-prefix=%{l_prefix}/lib/gcc%{V_comp}-lib \
  137. --enable-languages="${l_enable_languages}" \
  138. --enable-threads="${l_enable_threads}" \
  139. --disable-maintainer-mode \
  140. --disable-shared \
  141. --disable-nls \
  142. ${l_with_gnu_ld_as}
  143. # explicitly redirect remaining gcc-lib directories
  144. %{l_shtool} subst -v -s \
  145. -e "s;/gcc-lib/;/gcc%{V_comp}-lib/;" \
  146. `find . -name Makefile -type f -print`
  147. # determine build flags
  148. l_cflags=""
  149. l_boot_cflags=""
  150. l_libcflags="-g"
  151. l_libcxxflags="-g"
  152. %if "%{with_binutils}" == "yes"
  153. # at least GNU as from GNU binutils supports -pipe always
  154. l_boot_cflags="$l_boot_cflags -pipe"
  155. l_libcxxflags="$l_libcxxflags -pipe"
  156. %endif
  157. %if "%{with_optimize}" == "yes"
  158. # conservatively optimize the generated program code
  159. # (also _tune_ for particular CPUs, but _without_ requiring these CPUs!)
  160. l_cflags="$l_cflags -O"
  161. l_boot_cflags="$l_boot_cflags -O2 -fomit-frame-pointer -funroll-loops"
  162. case "%{l_platform -t}" in
  163. *i?86-* ) l_boot_cflags="$l_boot_cflags -mcpu=pentium3" ;;
  164. *sun4u-* ) l_boot_cflags="$l_boot_cflags -mtune=v9" ;;
  165. esac
  166. l_libcxxflags="$l_libcxxflags -O2 -fno-implicit-templates"
  167. %else
  168. # else do no optimizations at all to reduce problems to minimum in advance
  169. l_boot_cflags="$l_boot_cflags -O0"
  170. l_libcxxflags="$l_libcxxflags -O0"
  171. %endif
  172. # build the package
  173. %{l_make} %{l_mflags} \
  174. MAKE="%{l_make} %{l_mflags}" \
  175. BOOT_CFLAGS="${l_boot_cflags}" \
  176. CFLAGS="${l_cflags}" \
  177. LIBCFLAGS="${l_libcflags}" \
  178. LIBCXXFLAGS="${l_libcxxflags}" \
  179. bootstrap-lean
  180. %install
  181. rm -rf $RPM_BUILD_ROOT
  182. # fetch GNU platform triple
  183. triple=`./config.guess`
  184. triple=`./config.sub ${triple}`
  185. # perform the standard installation procedure
  186. ( cd obj
  187. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  188. ) || exit $?
  189. # cleanup installation tree
  190. mv $RPM_BUILD_ROOT%{l_prefix}/lib/lib*.a \
  191. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}-lib/${triple}/%{V_full}/
  192. for multilib in `$RPM_BUILD_ROOT%{l_prefix}/bin/gcc --print-multi-lib`; do
  193. subdir=`echo "$multilib" | sed -e 's/;.*$//'`
  194. [ ".$subdir" = .. ] && continue
  195. mv $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir/lib*.a \
  196. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}-lib/${triple}/%{V_full}/$subdir/
  197. rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir
  198. done
  199. mv $RPM_BUILD_ROOT%{l_prefix}/${triple}/include/* \
  200. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}-lib/${triple}/%{V_full}/include/ \
  201. >/dev/null 2>&1 || true
  202. %if "%{with_java}" == "yes"
  203. mv $RPM_BUILD_ROOT%{l_prefix}/share/java \
  204. $RPM_BUILD_ROOT%{l_prefix}/share/gcc
  205. %endif
  206. # strip installation tree
  207. rm -rf $RPM_BUILD_ROOT%{l_prefix}/${triple}
  208. rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man7 >/dev/null 2>&1 || true
  209. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.la >/dev/null 2>&1 || true
  210. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc* >/dev/null 2>&1 || true
  211. %if "%{with_cxx}" == "yes"
  212. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++ >/dev/null 2>&1 || true
  213. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++ >/dev/null 2>&1 || true
  214. %endif
  215. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  216. for prog in cc1 cc1plus collect2 cpp; do
  217. strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}-lib/${triple}/%{V_full}/${prog} \
  218. >/dev/null 2>&1 || true
  219. done
  220. # bump up installation tree
  221. ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc \
  222. $RPM_BUILD_ROOT%{l_prefix}/bin/cc
  223. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \
  224. $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1
  225. %if "%{with_cxx}" == "yes"
  226. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \
  227. $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1
  228. %endif
  229. # resolve filename conflicts
  230. %if "%{with_gcc}" != "yes" && "%{V_comp}" != ""
  231. ( cd $RPM_BUILD_ROOT%{l_prefix}/bin
  232. for file in *; do
  233. mv ${file} ${file}%{V_comp}
  234. done
  235. ) || exit $?
  236. ( cd $RPM_BUILD_ROOT%{l_prefix}/info
  237. for file in *; do
  238. mv ${file} `echo ${file} | sed -e 's;^\([^.]*\)\(\..*\)$;\1%{V_comp}\2;'`
  239. done
  240. ) || exit $?
  241. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man1
  242. for file in *; do
  243. mv ${file} `echo ${file} | sed -e 's;^\([^.]*\)\(\..*\)$;\1%{V_comp}\2;'`
  244. done
  245. ) || exit $?
  246. %endif
  247. # determine installation file list
  248. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
  249. %files -f files
  250. %clean
  251. rm -rf $RPM_BUILD_ROOT