gcc.spec 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. ##
  2. ## gcc.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
  4. ## Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
  5. ## Copyright (c) 2000-2002 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 versions
  26. %define V_major 3.1.1
  27. %define V_short 3.1.1
  28. %define V_long 3.1.1
  29. # package options
  30. %ifndef with_cxx
  31. %define with_cxx yes
  32. %endif
  33. %ifndef with_optimize
  34. %define with_optimize yes
  35. %endif
  36. %ifndef with_binutils
  37. %define with_binutils %(if [ -f %{SOURCE gcc.sh} ]; then sh %{SOURCE gcc.sh} require-binutils %{l_target}; else echo "no"; fi)
  38. %endif
  39. # package information
  40. Name: gcc
  41. Summary: GNU Compiler Collection
  42. URL: http://gcc.gnu.org/
  43. Vendor: Free Software Foundation
  44. Packager: The OpenPKG Project
  45. Distribution: OpenPKG [REL]
  46. Group: Language
  47. License: GPL
  48. Version: %{V_short}
  49. Release: 20020809
  50. # list of sources
  51. Source0: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_long}/gcc-%{V_long}.tar.bz2
  52. Source1: gcc.sh
  53. Patch0: gcc.patch
  54. # build information
  55. Prefix: %{l_prefix}
  56. BuildRoot: %{l_buildroot}
  57. BuildPreReq: OpenPKG, openpkg >= 20020206, make
  58. PreReq: OpenPKG, openpkg >= 20020206
  59. %if "%{with_binutils}" == "yes"
  60. BuildPreReq: binutils >= 2.13
  61. PreReq: binutils >= 2.13
  62. %endif
  63. AutoReq: no
  64. AutoReqProv: no
  65. %description
  66. The GNU Compiler Collection (GCC) provides a standard conforming and
  67. highly portable ISO C and ISO C++ compiler.
  68. Options:
  69. --define 'with_cxx %{with_cxx}' \
  70. --define 'with_optimize %{with_optimize}' \
  71. --define 'with_binutils %{with_binutils}' \
  72. %prep
  73. %setup -q -n gcc-%{V_long}
  74. %patch -p0
  75. %{l_shtool} subst -v -s \
  76. -e "s;PREFIX_INCLUDE_DIR;PREFIX_INCLUDE_DIR_DISABLED;g" \
  77. gcc/configure
  78. %build
  79. # configure the package
  80. mkdir obj
  81. cd obj
  82. options=""
  83. case "%{l_target}" in
  84. *-linux* | *-freebsd* ) options="--with-gnu-as --with-gnu-ld" ;;
  85. esac
  86. CC="%{l_cc}" \
  87. CFLAGS="%{l_cflags}" \
  88. ../configure \
  89. --prefix=%{l_prefix} \
  90. --exec-prefix=%{l_prefix} \
  91. --includedir=%{l_prefix}/include/gcc \
  92. --with-gxx-include-dir=%{l_prefix}/include/g++ \
  93. --with-local-prefix=%{l_prefix}/lib/gcc-lib \
  94. %if "%{with_cxx}" == "yes"
  95. --enable-languages="c,c++" \
  96. %else
  97. --enable-languages="c" \
  98. %endif
  99. --enable-threads \
  100. --disable-maintainer-mode \
  101. --disable-shared \
  102. --disable-nls \
  103. %if "%{with_optimize}" == "yes"
  104. --with-gnu-ld --with-ld=%{l_prefix}/bin/ld \
  105. --with-gnu-as --with-as=%{l_prefix}/bin/as \
  106. %endif
  107. $options
  108. # build the package
  109. %if "%{with_optimize}" == "yes"
  110. l_boot_cflags="-O2"
  111. l_cflags="-O"
  112. l_libcflags="-g -O2"
  113. l_libcxxflags="-g -O2 -fno-implicit-templates"
  114. case "%{l_target}" in
  115. *-osf* ) l_boot_cflags="-O" ;;
  116. esac
  117. %else
  118. l_boot_cflags=""
  119. l_cflags=""
  120. l_libcflags="-g"
  121. l_libcxxflags="-g"
  122. %endif
  123. %{l_make} %{l_mflags} \
  124. MAKE="%{l_make} %{l_mflags}" \
  125. BOOT_CFLAGS="$l_boot_cflags" \
  126. CFLAGS="$l_cflags" \
  127. LIBCFLAGS="$l_libcflags" \
  128. LIBCXXFLAGS="$l_libcxxflags" \
  129. bootstrap-lean
  130. %install
  131. rm -rf $RPM_BUILD_ROOT
  132. triple=`./config.guess`
  133. triple=`./config.sub $triple | sed -e 's;-unknown-;--;'`
  134. cd obj
  135. # redirect to temporary build root
  136. %{l_shtool} subst -v -s \
  137. -e "s;^\\(prefix[ ]*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};" \
  138. -e "s;^\\(exec_prefix[ ]*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};" \
  139. -e "s;^\\(gcc_gxx_include_dir[ ]*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix}/include/g++;" \
  140. -e "s;^\\(gxx_include_dir[ ]*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix}/include/g++;" \
  141. -e "s;^\\(glibcppinstalldir[ ]*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix}/include/g++;" \
  142. -e "s;^\\(local_prefix[ ]*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc-lib;" \
  143. `find . -name Makefile -type f -print`
  144. # make sure the install procedure doesn't compile anything
  145. # (or else we would have wrong paths hard-coded in the programs)
  146. %{l_shtool} subst -v -s \
  147. -e 's;^install-cpp:.*;install-cpp:;' \
  148. -e 's;^install-common:.*;install-common: installdirs lang.install-common;' \
  149. -e 's;^install-driver:.*;install-driver:;' \
  150. -e 's;^install-libgcc:.*;install-libgcc: installdirs;' \
  151. -e 's;^install-build:.*;install-build:;' \
  152. -e 's;^install-collect2:.*;install-collect2: installdirs;' \
  153. -e 's;^install-assert-h:.*;install-assert-h: installdirs;' \
  154. -e 's;^install: stmp-dirs ./libgcc.a;install: stmp-dirs;' \
  155. -e 's;^\(install-.*:.*\) all *\(.*\)$;\1\2;' \
  156. gcc/Makefile gcc/libgcc.mk gcc/*/Makefile
  157. # make sure the Makefiles are not re-generated
  158. for file in `find . -name config.status -print`; do
  159. ( echo "#!/bin/sh"
  160. echo ":"
  161. ) >$file
  162. done
  163. # run the standard installation procedure
  164. %{l_make} %{l_mflags} install
  165. # strip the installation
  166. mv $RPM_BUILD_ROOT%{l_prefix}/$triple/include/* \
  167. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc-lib/$triple/%{V_major}/include/ >/dev/null 2>&1 || true
  168. rm -rf $RPM_BUILD_ROOT%{l_prefix}/$triple
  169. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.la >/dev/null 2>&1 || true
  170. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc >/dev/null 2>&1 || true
  171. %if "%{with_cxx}" == "yes"
  172. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++ >/dev/null 2>&1 || true
  173. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++ >/dev/null 2>&1 || true
  174. %endif
  175. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  176. for prog in cc1 cc1plus collect2 cpp; do
  177. strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc-lib/$triple/%{V_major}/$prog >/dev/null 2>&1 || true
  178. done
  179. # make additional links
  180. ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc $RPM_BUILD_ROOT%{l_prefix}/bin/cc
  181. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \
  182. $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1
  183. %if "%{with_cxx}" == "yes"
  184. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \
  185. $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1
  186. %endif
  187. # create file list
  188. %{l_rpmtool} files -v -o$RPM_BUILD_DIR/gcc-%{V_long}/files -r$RPM_BUILD_ROOT %{l_files_std}
  189. %files -f files
  190. %clean
  191. rm -rf $RPM_BUILD_ROOT