gcc41.spec 10 KB

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