gcc41.spec 11 KB

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