gcc.spec 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. ##
  2. ## gcc.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ## Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/>
  5. ##
  6. ## Permission to use, copy, modify, and distribute this software for
  7. ## any purpose with or without fee is hereby granted, provided that
  8. ## the above copyright notice and this permission notice appear in all
  9. ## copies.
  10. ##
  11. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  12. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  15. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  17. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  18. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  20. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  21. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  22. ## SUCH DAMAGE.
  23. ##
  24. # package version
  25. %define V_full 4.1.2
  26. %define V_comp %nil
  27. # package information
  28. Name: gcc
  29. Summary: GNU Compiler Collection
  30. URL: http://gcc.gnu.org/
  31. Vendor: Free Software Foundation
  32. Packager: OpenPKG Foundation e.V.
  33. Distribution: OpenPKG Community
  34. Class: CORE
  35. Group: Compiler
  36. License: GPL
  37. Version: %{V_full}
  38. Release: 20070214
  39. # package options
  40. %option with_cxx yes
  41. %option with_objc no
  42. %option with_java no
  43. %option with_fortran no
  44. %option with_optimize yes
  45. %option with_profile no
  46. %option with_binutils yes
  47. %option with_threads yes
  48. %option with_multilib no
  49. # list of sources
  50. Source0: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{version}/gcc-%{version}.tar.bz2
  51. Patch0: gcc.patch
  52. # build information
  53. Prefix: %{l_prefix}
  54. BuildRoot: %{l_buildroot}
  55. BuildPreReq: OpenPKG, openpkg >= 20060622, make
  56. PreReq: OpenPKG, openpkg >= 20060622
  57. %if "%{with_binutils}" == "yes"
  58. BuildPreReq: binutils >= 2.14
  59. PreReq: binutils >= 2.14
  60. %endif
  61. %if "%{with_fortran}" == "yes"
  62. BuildPreReq: mpfr
  63. PreReq: mpfr
  64. %endif
  65. %if "%{with_java}" == "yes"
  66. BuildPreReq: zlib
  67. PreReq: zlib
  68. %endif
  69. AutoReq: no
  70. AutoReqProv: no
  71. %description
  72. The GNU Compiler Collection (GCC) provides a standard conforming and
  73. highly portable ISO C and ISO C++ compiler.
  74. %track
  75. prog gcc = {
  76. version = %{V_full}
  77. url = ftp://gcc.gnu.org/pub/gcc/releases/
  78. regex = (4\.1(\.\d+)?)
  79. url = ftp://gcc.gnu.org/pub/gcc/releases/gcc-__NEWVER__/
  80. regex = gcc-(__VER__)\.tar\.bz2
  81. }
  82. %prep
  83. %setup -q
  84. %patch -p0
  85. %{l_shtool} subst -v -s \
  86. -e 's;PREFIX_INCLUDE_DIR;PREFIX_INCLUDE_DIR_DISABLED;g' \
  87. gcc/configure
  88. %{l_shtool} subst -v -s \
  89. -e 's;\(VERSUFFIX "\)\("\);\1 (%{l_openpkg_release -F "OpenPKG-%%t"})\2;' \
  90. -e 's;\(bug_report_url\[\] = "\)[^"]*;\1<URL:http://www.openpkg.org/>;' \
  91. gcc/version.c
  92. if [ ".%{V_comp}" != . ]; then
  93. %{l_shtool} subst -v -s \
  94. -e 's;(libdir)/gcc/;(libdir)/gcc%{V_comp}/;' \
  95. `find . -name Makefile.in -type f -print`
  96. fi
  97. case "%{l_platform -t}" in
  98. amd64*-linux* )
  99. %{l_shtool} subst \
  100. -e 's/GLIBCXX_IS_NATIVE=false/GLIBCXX_IS_NATIVE=true/g' \
  101. -e 's/test x.gcc_no_link = xyes/false/g' \
  102. libstdc++-v3/configure
  103. ;;
  104. esac
  105. %build
  106. # create build sub-directory
  107. %{l_shtool} mkdir -p obj
  108. cd obj
  109. # determine ld(1) and as(1) usage
  110. l_with_gnu_ld_as=""
  111. %if "%{with_binutils}" == "yes"
  112. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-ld --with-ld=%{l_prefix}/bin/ld"
  113. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-as --with-as=%{l_prefix}/bin/as"
  114. %else
  115. case "%{l_platform -t}" in
  116. *-linux* | *-freebsd* )
  117. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-as --with-gnu-ld"
  118. ;;
  119. esac
  120. %endif
  121. # determine threads usage
  122. %if "%{with_threads}" == "yes"
  123. l_enable_threads="posix"
  124. %else
  125. l_enable_threads="single"
  126. %endif
  127. # override threads setting for platforms with known limitations
  128. case "%{l_platform -t}" in
  129. *-netbsd1.6* ) l_enable_threads="single" ;;
  130. esac
  131. # determine language usage
  132. l_enable_languages="c"
  133. %if "%{with_cxx}" == "yes"
  134. l_enable_languages="${l_enable_languages},c++"
  135. %endif
  136. %if "%{with_objc}" == "yes"
  137. l_enable_languages="${l_enable_languages},objc"
  138. %endif
  139. %if "%{with_java}" == "yes"
  140. l_enable_languages="${l_enable_languages},java"
  141. %endif
  142. %if "%{with_fortran}" == "yes"
  143. l_enable_languages="${l_enable_languages},f95"
  144. %endif
  145. # disable GNU iconv usage
  146. ( echo "am_cv_func_iconv=no"
  147. echo "am_cv_lib_iconv=no"
  148. ) >config.cache
  149. # configure the package
  150. CC="%{l_cc}" \
  151. CFLAGS="%{l_cflags}" \
  152. %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes"
  153. CPPFLAGS="%{l_cppflags}" \
  154. LDFLAGS="%{l_ldflags}" \
  155. %endif
  156. CONFIG_SHELL="%{l_bash}" \
  157. ../configure \
  158. --cache-file=./config.cache \
  159. --srcdir=`pwd`/.. \
  160. --prefix=%{l_prefix} \
  161. --exec-prefix=%{l_prefix} \
  162. --includedir=%{l_prefix}/include/gcc%{V_comp} \
  163. --libexecdir=%{l_prefix}/libexec/gcc%{V_comp} \
  164. --with-gxx-include-dir=%{l_prefix}/include/g++%{V_comp} \
  165. --with-local-prefix=%{l_prefix}/lib/gcc%{V_comp} \
  166. --enable-languages="${l_enable_languages}" \
  167. --enable-threads="${l_enable_threads}" \
  168. --disable-maintainer-mode \
  169. --disable-shared \
  170. --disable-nls \
  171. %if "%{with_java}" == "yes"
  172. --with-system-zlib \
  173. %endif
  174. %if "%{with_multilib}" == "yes"
  175. --enable-multilib \
  176. %else
  177. --disable-multilib \
  178. %endif
  179. ${l_with_gnu_ld_as}
  180. # determine build flags
  181. l_ccisgcc=no
  182. if [ ".`(%{l_cc} -v; %{l_cc} --version) </dev/null 2>&1 | grep -i 'gcc'`" != . ]; then
  183. l_ccisgcc=yes
  184. fi
  185. l_cflags=""
  186. l_boot_cflags=""
  187. l_libcflags="-g"
  188. l_libcxxflags="-g"
  189. case "%{l_platform -t}" in
  190. alpha*-tru64* ) if [ ".$l_ccisgcc" = .no ]; then l_libcflags="$l_libcflags -ieee"; fi ;;
  191. esac
  192. %if "%{with_binutils}" == "yes"
  193. # at least GNU as from GNU binutils supports -pipe always
  194. l_boot_cflags="$l_boot_cflags -pipe"
  195. l_libcxxflags="$l_libcxxflags -pipe"
  196. %endif
  197. %if "%{with_optimize}" == "yes"
  198. # conservatively optimize the generated program code
  199. # (also _tune_ for particular CPUs, but _without_ requiring these CPUs!)
  200. l_cflags="$l_cflags -O"
  201. l_boot_cflags="$l_boot_cflags -O2 -fomit-frame-pointer"
  202. case "%{l_platform -t}" in
  203. *i?86-* ) l_boot_cflags="$l_boot_cflags -mtune=pentium3" ;;
  204. *sun4[uv]-* ) l_boot_cflags="$l_boot_cflags -mtune=v9" ;;
  205. esac
  206. l_libcxxflags="$l_libcxxflags -O2 -fno-implicit-templates"
  207. %else
  208. # else do no optimizations at all to reduce problems to minimum in advance
  209. l_boot_cflags="$l_boot_cflags -O0"
  210. l_libcxxflags="$l_libcxxflags -O0"
  211. %endif
  212. maketarget="bootstrap-lean"
  213. %if "%{with_profile}" == "yes"
  214. # GCC >= 3.4 supports a "profiledbootstrap" target to build an
  215. # optimized version of itself through profiling. Because this
  216. # requires a (bootstrapping) C compiler with 64-bit arithmetic,
  217. # the whole approach is currently supported only if already
  218. # building with GCC as the bootstrapping C compiler.
  219. if [ ".$l_ccisgcc" = .yes ]; then
  220. maketarget="profiledbootstrap"
  221. fi
  222. %endif
  223. # build the package
  224. %{l_make} %{l_mflags} \
  225. MAKE="%{l_make} %{l_mflags}" \
  226. BOOT_CFLAGS="${l_boot_cflags}" \
  227. CFLAGS="${l_cflags}" \
  228. LIBCFLAGS="${l_libcflags}" \
  229. LIBCXXFLAGS="${l_libcxxflags}" \
  230. $maketarget
  231. %install
  232. rm -rf $RPM_BUILD_ROOT
  233. # fetch GNU platform triple
  234. triple=`./config.guess`
  235. # perform the standard installation procedure
  236. ( cd obj
  237. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  238. ) || exit $?
  239. # cleanup installation tree
  240. mv $RPM_BUILD_ROOT%{l_prefix}/lib/lib*.a \
  241. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/
  242. dirs=""
  243. for multilib in `$RPM_BUILD_ROOT%{l_prefix}/bin/gcc --print-multi-lib`; do
  244. subdir=`echo "$multilib" | sed -e 's/;.*$//'`
  245. [ ".$subdir" = .. ] && continue
  246. mv $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir/lib*.a \
  247. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/
  248. dirs="$dirs $subdir"
  249. done
  250. for subdir in $dirs; do
  251. rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir
  252. done
  253. mv $RPM_BUILD_ROOT%{l_prefix}/${triple}/include/* \
  254. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/include/ \
  255. >/dev/null 2>&1 || true
  256. # strip installation tree
  257. rm -rf $RPM_BUILD_ROOT%{l_prefix}/${triple}
  258. rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
  259. rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man7 >/dev/null 2>&1 || true
  260. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.la >/dev/null 2>&1 || true
  261. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc* >/dev/null 2>&1 || true
  262. %if "%{with_cxx}" == "yes"
  263. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++ >/dev/null 2>&1 || true
  264. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++ >/dev/null 2>&1 || true
  265. %endif
  266. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  267. for prog in cc1 cc1plus collect2 cpp; do
  268. strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/${prog} \
  269. >/dev/null 2>&1 || true
  270. done
  271. # bump up installation tree
  272. ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc \
  273. $RPM_BUILD_ROOT%{l_prefix}/bin/cc
  274. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \
  275. $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1
  276. %if "%{with_cxx}" == "yes"
  277. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \
  278. $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1
  279. %endif
  280. # determine installation file list
  281. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
  282. %files -f files
  283. %clean
  284. rm -rf $RPM_BUILD_ROOT