gcc.spec 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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.2.0
  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: 20070608
  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_threads yes
  47. %option with_multilib no
  48. # list of sources
  49. Source0: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{version}/gcc-%{version}.tar.bz2
  50. Patch0: gcc.patch
  51. # build information
  52. Prefix: %{l_prefix}
  53. BuildRoot: %{l_buildroot}
  54. BuildPreReq: OpenPKG, openpkg >= 20060622, make
  55. PreReq: OpenPKG, openpkg >= 20060622
  56. BuildPreReq: binutils >= 2.14
  57. PreReq: binutils >= 2.14
  58. %if "%{with_fortran}" == "yes"
  59. BuildPreReq: mpfr
  60. PreReq: mpfr
  61. %endif
  62. %if "%{with_java}" == "yes"
  63. BuildPreReq: zlib
  64. PreReq: zlib
  65. %endif
  66. AutoReq: no
  67. AutoReqProv: no
  68. %description
  69. The GNU Compiler Collection (GCC) provides a standard conforming and
  70. highly portable ISO C and ISO C++ compiler.
  71. %track
  72. prog gcc = {
  73. version = %{V_full}
  74. url = ftp://gcc.gnu.org/pub/gcc/releases/
  75. regex = (4\.2(\.\d+)?)
  76. url = ftp://gcc.gnu.org/pub/gcc/releases/gcc-__NEWVER__/
  77. regex = gcc-(__VER__)\.tar\.bz2
  78. }
  79. %prep
  80. %setup -q
  81. %patch -p0
  82. %{l_shtool} subst -v -s \
  83. -e 's;PREFIX_INCLUDE_DIR;PREFIX_INCLUDE_DIR_DISABLED;g' \
  84. gcc/configure
  85. %{l_shtool} subst -v -s \
  86. -e 's;\(VERSUFFIX "\)\("\);\1 (%{l_openpkg_release -F "OpenPKG-%%t"})\2;' \
  87. -e 's;\(bug_report_url\[\] = "\)[^"]*;\1<URL:http://www.openpkg.org/>;' \
  88. gcc/version.c
  89. if [ ".%{V_comp}" != . ]; then
  90. %{l_shtool} subst -v -s \
  91. -e 's;(libdir)/gcc/;(libdir)/gcc%{V_comp}/;' \
  92. `find . -name Makefile.in -type f -print`
  93. fi
  94. case "%{l_platform -t}" in
  95. amd64*-linux* )
  96. %{l_shtool} subst \
  97. -e 's/GLIBCXX_IS_NATIVE=false/GLIBCXX_IS_NATIVE=true/g' \
  98. -e 's/test x.gcc_no_link = xyes/false/g' \
  99. libstdc++-v3/configure
  100. ;;
  101. esac
  102. %build
  103. # create build sub-directory
  104. %{l_shtool} mkdir -p obj
  105. cd obj
  106. # determine ld(1) and as(1) usage
  107. l_with_gnu_ld_as=""
  108. LD="%{l_tool_locate ld ld}"
  109. AS="%{l_tool_locate as as}"
  110. echo "$LD" | grep "^/" >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-ld=\"$LD\""
  111. echo "$AS" | grep "^/" >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-as=\"$AS\""
  112. "$LD" --version </dev/null 2>/dev/null | grep "^GNU ld " >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-ld"
  113. "$AS" --version </dev/null 2>/dev/null | grep "^GNU assembler " >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-as"
  114. # determine threads usage
  115. %if "%{with_threads}" == "yes"
  116. l_enable_threads="posix"
  117. %else
  118. l_enable_threads="single"
  119. %endif
  120. # determine language usage
  121. l_enable_languages="c"
  122. %if "%{with_cxx}" == "yes"
  123. l_enable_languages="${l_enable_languages},c++"
  124. %endif
  125. %if "%{with_objc}" == "yes"
  126. l_enable_languages="${l_enable_languages},objc"
  127. %endif
  128. %if "%{with_java}" == "yes"
  129. l_enable_languages="${l_enable_languages},java"
  130. %endif
  131. %if "%{with_fortran}" == "yes"
  132. l_enable_languages="${l_enable_languages},f95"
  133. %endif
  134. # disable GNU iconv usage
  135. ( echo "am_cv_func_iconv=no"
  136. echo "am_cv_lib_iconv=no"
  137. ) >config.cache
  138. # configure the package
  139. CC="%{l_cc}" \
  140. CFLAGS="%{l_cflags}" \
  141. %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes"
  142. CPPFLAGS="%{l_cppflags}" \
  143. LDFLAGS="%{l_ldflags}" \
  144. %endif
  145. CONFIG_SHELL="%{l_bash}" \
  146. ../configure \
  147. --cache-file=./config.cache \
  148. --srcdir=`pwd`/.. \
  149. --prefix=%{l_prefix} \
  150. --exec-prefix=%{l_prefix} \
  151. --includedir=%{l_prefix}/include/gcc%{V_comp} \
  152. --libexecdir=%{l_prefix}/libexec/gcc%{V_comp} \
  153. --with-gxx-include-dir=%{l_prefix}/include/g++%{V_comp} \
  154. --with-local-prefix=%{l_prefix}/lib/gcc%{V_comp} \
  155. --enable-languages="${l_enable_languages}" \
  156. --enable-threads="${l_enable_threads}" \
  157. --disable-maintainer-mode \
  158. --disable-shared \
  159. --disable-nls \
  160. %if "%{with_java}" == "yes"
  161. --with-system-zlib \
  162. %endif
  163. %if "%{with_multilib}" == "yes"
  164. --enable-multilib \
  165. %else
  166. --disable-multilib \
  167. %endif
  168. ${l_with_gnu_ld_as}
  169. # determine build flags
  170. l_ccisgcc=no
  171. if [ ".`(%{l_cc} -v; %{l_cc} --version) </dev/null 2>&1 | grep -i 'gcc'`" != . ]; then
  172. l_ccisgcc=yes
  173. fi
  174. l_cflags=""
  175. l_boot_cflags=""
  176. l_libcflags="-g"
  177. l_libcxxflags="-g"
  178. # at least GNU as from GNU binutils supports -pipe always
  179. AS="%{l_tool_locate as as}"
  180. "$AS" --version 2>/dev/null | grep "^GNU assembler " >/dev/null && {
  181. l_boot_cflags="$l_boot_cflags -pipe";
  182. l_libcxxflags="$l_libcxxflags -pipe";
  183. }
  184. %if "%{with_optimize}" == "yes"
  185. # conservatively optimize the generated program code
  186. # (also _tune_ for particular CPUs, but _without_ requiring these CPUs!)
  187. l_cflags="$l_cflags -O"
  188. l_boot_cflags="$l_boot_cflags -O2 -fomit-frame-pointer"
  189. case "%{l_platform -t}" in
  190. *i?86-* ) l_boot_cflags="$l_boot_cflags -mtune=pentium3" ;;
  191. *sun4[uv]-* ) l_boot_cflags="$l_boot_cflags -mtune=v9" ;;
  192. esac
  193. l_libcxxflags="$l_libcxxflags -O2 -fno-implicit-templates"
  194. %else
  195. # else do no optimizations at all to reduce problems to minimum in advance
  196. l_boot_cflags="$l_boot_cflags -O0"
  197. l_libcxxflags="$l_libcxxflags -O0"
  198. %endif
  199. maketarget="bootstrap-lean"
  200. %if "%{with_profile}" == "yes"
  201. # GCC >= 3.4 supports a "profiledbootstrap" target to build an
  202. # optimized version of itself through profiling. Because this
  203. # requires a (bootstrapping) C compiler with 64-bit arithmetic,
  204. # the whole approach is currently supported only if already
  205. # building with GCC as the bootstrapping C compiler.
  206. if [ ".$l_ccisgcc" = .yes ]; then
  207. maketarget="profiledbootstrap"
  208. fi
  209. %endif
  210. # build the package
  211. %{l_make} %{l_mflags} \
  212. MAKE="%{l_make} %{l_mflags}" \
  213. BOOT_CFLAGS="${l_boot_cflags}" \
  214. CFLAGS="${l_cflags}" \
  215. LIBCFLAGS="${l_libcflags}" \
  216. LIBCXXFLAGS="${l_libcxxflags}" \
  217. $maketarget
  218. %install
  219. rm -rf $RPM_BUILD_ROOT
  220. # fetch GNU platform triple
  221. triple=`./config.guess`
  222. # perform the standard installation procedure
  223. ( cd obj
  224. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  225. ) || exit $?
  226. # cleanup installation tree
  227. mv $RPM_BUILD_ROOT%{l_prefix}/lib/lib*.a \
  228. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \
  229. >/dev/null 2>&1 || true
  230. dirs=""
  231. for multilib in `$RPM_BUILD_ROOT%{l_prefix}/bin/gcc --print-multi-lib`; do
  232. subdir=`echo "$multilib" | sed -e 's/;.*$//'`
  233. [ ".$subdir" = .. ] && continue
  234. mv $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir/lib*.a \
  235. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \
  236. >/dev/null 2>&1 || true
  237. dirs="$dirs $subdir"
  238. done
  239. for subdir in $dirs; do
  240. rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir >/dev/null 2>&1 || true
  241. done
  242. mv $RPM_BUILD_ROOT%{l_prefix}/${triple}/include/* \
  243. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/include/ \
  244. >/dev/null 2>&1 || true
  245. # strip installation tree
  246. rm -rf $RPM_BUILD_ROOT%{l_prefix}/${triple}
  247. rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
  248. rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man7 >/dev/null 2>&1 || true
  249. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.la >/dev/null 2>&1 || true
  250. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc* >/dev/null 2>&1 || true
  251. %if "%{with_cxx}" == "yes"
  252. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++ >/dev/null 2>&1 || true
  253. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++ >/dev/null 2>&1 || true
  254. %endif
  255. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  256. for prog in cc1 cc1plus collect2 cpp; do
  257. strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/${prog} \
  258. >/dev/null 2>&1 || true
  259. done
  260. # bump up installation tree
  261. ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc \
  262. $RPM_BUILD_ROOT%{l_prefix}/bin/cc
  263. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \
  264. $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1
  265. %if "%{with_cxx}" == "yes"
  266. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \
  267. $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1
  268. %endif
  269. # determine installation file list
  270. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
  271. %files -f files
  272. %clean
  273. rm -rf $RPM_BUILD_ROOT