gcc42.spec 11 KB

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