gcc.spec 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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: 20070517
  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\.1(\.\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 2>/dev/null | grep "^GNU ld " >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-ld"
  113. "$AS" --version 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. # override threads setting for platforms with known limitations
  121. case "%{l_platform -t}" in
  122. *-netbsd1.6* ) l_enable_threads="single" ;;
  123. esac
  124. # determine language usage
  125. l_enable_languages="c"
  126. %if "%{with_cxx}" == "yes"
  127. l_enable_languages="${l_enable_languages},c++"
  128. %endif
  129. %if "%{with_objc}" == "yes"
  130. l_enable_languages="${l_enable_languages},objc"
  131. %endif
  132. %if "%{with_java}" == "yes"
  133. l_enable_languages="${l_enable_languages},java"
  134. %endif
  135. %if "%{with_fortran}" == "yes"
  136. l_enable_languages="${l_enable_languages},f95"
  137. %endif
  138. # disable GNU iconv usage
  139. ( echo "am_cv_func_iconv=no"
  140. echo "am_cv_lib_iconv=no"
  141. ) >config.cache
  142. # configure the package
  143. CC="%{l_cc}" \
  144. CFLAGS="%{l_cflags}" \
  145. %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes"
  146. CPPFLAGS="%{l_cppflags}" \
  147. LDFLAGS="%{l_ldflags}" \
  148. %endif
  149. CONFIG_SHELL="%{l_bash}" \
  150. ../configure \
  151. --cache-file=./config.cache \
  152. --srcdir=`pwd`/.. \
  153. --prefix=%{l_prefix} \
  154. --exec-prefix=%{l_prefix} \
  155. --includedir=%{l_prefix}/include/gcc%{V_comp} \
  156. --libexecdir=%{l_prefix}/libexec/gcc%{V_comp} \
  157. --with-gxx-include-dir=%{l_prefix}/include/g++%{V_comp} \
  158. --with-local-prefix=%{l_prefix}/lib/gcc%{V_comp} \
  159. --enable-languages="${l_enable_languages}" \
  160. --enable-threads="${l_enable_threads}" \
  161. --disable-maintainer-mode \
  162. --disable-shared \
  163. --disable-nls \
  164. %if "%{with_java}" == "yes"
  165. --with-system-zlib \
  166. %endif
  167. %if "%{with_multilib}" == "yes"
  168. --enable-multilib \
  169. %else
  170. --disable-multilib \
  171. %endif
  172. ${l_with_gnu_ld_as}
  173. # determine build flags
  174. l_ccisgcc=no
  175. if [ ".`(%{l_cc} -v; %{l_cc} --version) </dev/null 2>&1 | grep -i 'gcc'`" != . ]; then
  176. l_ccisgcc=yes
  177. fi
  178. l_cflags=""
  179. l_boot_cflags=""
  180. l_libcflags="-g"
  181. l_libcxxflags="-g"
  182. # at least GNU as from GNU binutils supports -pipe always
  183. AS="%{l_tool_locate as as}"
  184. "$AS" --version 2>/dev/null | grep "^GNU assembler " >/dev/null && {
  185. l_boot_cflags="$l_boot_cflags -pipe";
  186. l_libcxxflags="$l_libcxxflags -pipe";
  187. }
  188. %if "%{with_optimize}" == "yes"
  189. # conservatively optimize the generated program code
  190. # (also _tune_ for particular CPUs, but _without_ requiring these CPUs!)
  191. l_cflags="$l_cflags -O"
  192. l_boot_cflags="$l_boot_cflags -O2 -fomit-frame-pointer"
  193. case "%{l_platform -t}" in
  194. *i?86-* ) l_boot_cflags="$l_boot_cflags -mtune=pentium3" ;;
  195. *sun4[uv]-* ) l_boot_cflags="$l_boot_cflags -mtune=v9" ;;
  196. esac
  197. l_libcxxflags="$l_libcxxflags -O2 -fno-implicit-templates"
  198. %else
  199. # else do no optimizations at all to reduce problems to minimum in advance
  200. l_boot_cflags="$l_boot_cflags -O0"
  201. l_libcxxflags="$l_libcxxflags -O0"
  202. %endif
  203. maketarget="bootstrap-lean"
  204. %if "%{with_profile}" == "yes"
  205. # GCC >= 3.4 supports a "profiledbootstrap" target to build an
  206. # optimized version of itself through profiling. Because this
  207. # requires a (bootstrapping) C compiler with 64-bit arithmetic,
  208. # the whole approach is currently supported only if already
  209. # building with GCC as the bootstrapping C compiler.
  210. if [ ".$l_ccisgcc" = .yes ]; then
  211. maketarget="profiledbootstrap"
  212. fi
  213. %endif
  214. # build the package
  215. %{l_make} %{l_mflags} \
  216. MAKE="%{l_make} %{l_mflags}" \
  217. BOOT_CFLAGS="${l_boot_cflags}" \
  218. CFLAGS="${l_cflags}" \
  219. LIBCFLAGS="${l_libcflags}" \
  220. LIBCXXFLAGS="${l_libcxxflags}" \
  221. $maketarget
  222. %install
  223. rm -rf $RPM_BUILD_ROOT
  224. # fetch GNU platform triple
  225. triple=`./config.guess`
  226. # perform the standard installation procedure
  227. ( cd obj
  228. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  229. ) || exit $?
  230. # cleanup installation tree
  231. mv $RPM_BUILD_ROOT%{l_prefix}/lib/lib*.a \
  232. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/
  233. dirs=""
  234. for multilib in `$RPM_BUILD_ROOT%{l_prefix}/bin/gcc --print-multi-lib`; do
  235. subdir=`echo "$multilib" | sed -e 's/;.*$//'`
  236. [ ".$subdir" = .. ] && continue
  237. mv $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir/lib*.a \
  238. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/
  239. dirs="$dirs $subdir"
  240. done
  241. for subdir in $dirs; do
  242. rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir
  243. done
  244. mv $RPM_BUILD_ROOT%{l_prefix}/${triple}/include/* \
  245. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/include/ \
  246. >/dev/null 2>&1 || true
  247. # strip installation tree
  248. rm -rf $RPM_BUILD_ROOT%{l_prefix}/${triple}
  249. rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
  250. rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man7 >/dev/null 2>&1 || true
  251. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.la >/dev/null 2>&1 || true
  252. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc* >/dev/null 2>&1 || true
  253. %if "%{with_cxx}" == "yes"
  254. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++ >/dev/null 2>&1 || true
  255. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++ >/dev/null 2>&1 || true
  256. %endif
  257. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  258. for prog in cc1 cc1plus collect2 cpp; do
  259. strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/${prog} \
  260. >/dev/null 2>&1 || true
  261. done
  262. # bump up installation tree
  263. ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc \
  264. $RPM_BUILD_ROOT%{l_prefix}/bin/cc
  265. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \
  266. $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1
  267. %if "%{with_cxx}" == "yes"
  268. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \
  269. $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1
  270. %endif
  271. # determine installation file list
  272. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
  273. %files -f files
  274. %clean
  275. rm -rf $RPM_BUILD_ROOT