gcc.spec 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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 information
  26. Name: gcc
  27. Summary: GNU Compiler Collection
  28. URL: http://gcc.gnu.org/
  29. Vendor: Free Software Foundation
  30. Packager: The OpenPKG Project
  31. Distribution: OpenPKG [CORE]
  32. Group: Language
  33. License: GPL
  34. Version: 3.2.2
  35. Release: 20030309
  36. # package options
  37. %option with_cxx yes
  38. %option with_optimize yes
  39. %option with_binutils yes
  40. %option with_threads yes
  41. # list of sources
  42. Source0: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{version}/gcc-%{version}.tar.bz2
  43. Patch0: gcc.patch
  44. # build information
  45. Prefix: %{l_prefix}
  46. BuildRoot: %{l_buildroot}
  47. BuildPreReq: OpenPKG, openpkg >= 20030103, make
  48. PreReq: OpenPKG, openpkg >= 20030103
  49. %if "%{with_binutils}" == "yes"
  50. BuildPreReq: binutils >= 2.13
  51. PreReq: binutils >= 2.13
  52. %endif
  53. AutoReq: no
  54. AutoReqProv: no
  55. %description
  56. The GNU Compiler Collection (GCC) provides a standard conforming and
  57. highly portable ISO C and ISO C++ compiler.
  58. %prep
  59. %setup -q -n gcc-%{version}
  60. %patch -p0
  61. %{l_shtool} subst -v -s \
  62. -e "s;PREFIX_INCLUDE_DIR;PREFIX_INCLUDE_DIR_DISABLED;g" \
  63. gcc/configure
  64. %build
  65. # create build sub-directory
  66. mkdir obj
  67. cd obj
  68. # determine ld(1) and as(1) usage
  69. l_with_gnu_ld_as=""
  70. %if "%{with_binutils}" == "yes"
  71. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-ld --with-ld=%{l_prefix}/bin/ld"
  72. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-as --with-as=%{l_prefix}/bin/as"
  73. %else
  74. case "%{l_target}" in
  75. *-linux* | *-freebsd* )
  76. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-as --with-gnu-ld"
  77. ;;
  78. esac
  79. %endif
  80. # determine threads usage
  81. %if "%{with_threads}" == "yes"
  82. l_enable_threads="posix"
  83. %else
  84. l_enable_threads="single"
  85. %endif
  86. # determine language usage
  87. l_enable_languages="c"
  88. %if "%{with_cxx}" == "yes"
  89. l_enable_languages="${l_enable_languages},c++"
  90. %endif
  91. # configure the package
  92. CC="%{l_cc}" \
  93. CFLAGS="%{l_cflags}" \
  94. ../configure \
  95. --prefix=%{l_prefix} \
  96. --exec-prefix=%{l_prefix} \
  97. --includedir=%{l_prefix}/include/gcc \
  98. --with-gxx-include-dir=%{l_prefix}/include/g++ \
  99. --with-local-prefix=%{l_prefix}/lib/gcc-lib \
  100. --enable-languages="${l_enable_languages}" \
  101. --enable-threads="${l_enable_threads}" \
  102. --disable-maintainer-mode \
  103. --disable-shared \
  104. --disable-nls \
  105. ${l_with_gnu_ld_as}
  106. # determine build flags
  107. l_cflags=""
  108. l_boot_cflags=""
  109. l_libcflags="-g"
  110. l_libcxxflags="-g"
  111. %if "%{with_binutils}" == "yes"
  112. # at least GNU as from GNU binutils supports -pipe always
  113. l_boot_cflags="$l_boot_cflags -pipe"
  114. l_libcflags="$l_libcflags -pipe"
  115. l_libcxxflags="$l_libcxxflags -pipe"
  116. %endif
  117. %if "%{with_optimize}" == "yes"
  118. # conservatively optimize the generated program code
  119. # (also _tune_ for particular CPUs, but _without_ requiring these CPUs!)
  120. l_cflags="$l_cflags -O"
  121. l_boot_cflags="$l_boot_cflags -O2 -fomit-frame-pointer -funroll-loops"
  122. case "%{l_target}" in
  123. *x86-* ) l_boot_cflags="$l_boot_cflags -mcpu=pentium3" ;;
  124. *sparc64* ) l_boot_cflags="$l_boot_cflags -mtune=v9" ;;
  125. esac
  126. l_libcflags="$l_libcflags -O2"
  127. l_libcxxflags="$l_libcxxflags -O2 -fno-implicit-templates"
  128. %else
  129. # else do no optimizations at all to reduce problems to minimum in advance
  130. l_boot_cflags="$l_boot_cflags -O0"
  131. l_libcflags="$l_libcflags -O0"
  132. l_libcxxflags="$l_libcxxflags -O0"
  133. %endif
  134. # build the package
  135. %{l_make} %{l_mflags} \
  136. MAKE="%{l_make} %{l_mflags}" \
  137. BOOT_CFLAGS="${l_boot_cflags}" \
  138. CFLAGS="${l_cflags}" \
  139. LIBCFLAGS="${l_libcflags}" \
  140. LIBCXXFLAGS="${l_libcxxflags}" \
  141. bootstrap-lean
  142. %install
  143. rm -rf $RPM_BUILD_ROOT
  144. # fetch GNU platform triple
  145. triple=`./config.guess`
  146. triple=`./config.sub ${triple}`
  147. # perform the standard installation procedure
  148. ( cd obj
  149. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT )
  150. # cleanup installation tree
  151. mv $RPM_BUILD_ROOT%{l_prefix}/lib/lib*.a \
  152. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc-lib/${triple}/%{version}/
  153. mv $RPM_BUILD_ROOT%{l_prefix}/${triple}/include/* \
  154. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc-lib/${triple}/%{version}/include/ \
  155. >/dev/null 2>&1 || true
  156. # strip installation tree
  157. rm -rf $RPM_BUILD_ROOT%{l_prefix}/${triple}
  158. rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man7 >/dev/null 2>&1 || true
  159. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.la >/dev/null 2>&1 || true
  160. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc >/dev/null 2>&1 || true
  161. %if "%{with_cxx}" == "yes"
  162. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++ >/dev/null 2>&1 || true
  163. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++ >/dev/null 2>&1 || true
  164. %endif
  165. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  166. for prog in cc1 cc1plus collect2 cpp; do
  167. strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc-lib/${triple}/%{version}/${prog} \
  168. >/dev/null 2>&1 || true
  169. done
  170. # bump up installation tree
  171. ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc \
  172. $RPM_BUILD_ROOT%{l_prefix}/bin/cc
  173. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \
  174. $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1
  175. %if "%{with_cxx}" == "yes"
  176. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \
  177. $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1
  178. %endif
  179. # determine installation file list
  180. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
  181. %files -f files
  182. %clean
  183. rm -rf $RPM_BUILD_ROOT