gcc42.spec 11 KB

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