gcc46.spec 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. ##
  2. ## gcc46.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2011 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ##
  5. ## Permission to use, copy, modify, and distribute this software for
  6. ## any purpose with or without fee is hereby granted, provided that
  7. ## the above copyright notice and this permission notice appear in all
  8. ## copies.
  9. ##
  10. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  11. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  12. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  13. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  14. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  15. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  16. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  17. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  19. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  20. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  21. ## SUCH DAMAGE.
  22. ##
  23. # package version
  24. %define V_full 4.6
  25. %define V_comp 46
  26. %define V_snap 20110101
  27. # package information
  28. Name: gcc46
  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: EVAL
  35. Group: Compiler
  36. License: GPL
  37. Version: %{V_full}s%{V_snap}
  38. Release: 20110102
  39. # package options
  40. %option with_binutils yes
  41. %option with_cxx yes
  42. %option with_objc no
  43. %option with_java no
  44. %option with_fortran no
  45. %option with_optimize no
  46. %option with_profile no
  47. %option with_threads yes
  48. %option with_multilib no
  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: gcc46.patch
  53. # build information
  54. BuildPreReq: OpenPKG, openpkg >= 20100101, make, flex, bison, texinfo
  55. PreReq: OpenPKG, openpkg >= 20100101
  56. %if "%{with_binutils}" == "yes"
  57. BuildPreReq: binutils >= 2.14
  58. PreReq: binutils >= 2.14
  59. %endif
  60. BuildPreReq: mpc, mpfr, gmp
  61. PreReq: mpc, mpfr, gmp
  62. %if "%{with_cxx}" == "yes"
  63. BuildPreReq: libiconv
  64. PreReq: libiconv
  65. %endif
  66. %if "%{with_java}" == "yes"
  67. BuildPreReq: zlib
  68. PreReq: zlib
  69. %endif
  70. %if "%{with_gcc}" == "yes"
  71. Provides: gcc = %{version}-%{release}
  72. Provides: gcc = %{version}-%{release}
  73. Provides: gcc::with_binutils = %{with_binutils}
  74. Provides: gcc::with_cxx = %{with_cxx}
  75. Provides: gcc::with_objc = %{with_objc}
  76. Provides: gcc::with_java = %{with_java}
  77. Provides: gcc::with_fortran = %{with_fortran}
  78. Provides: gcc::with_profile = %{with_profile}
  79. Provides: gcc::with_threads = %{with_threads}
  80. Provides: gcc::with_multilib = %{with_multilib}
  81. Provides: gcc::with_gcc = %{with_gcc}
  82. %endif
  83. %description
  84. The GNU Compiler Collection (GCC) provides a standard conforming and
  85. highly portable ISO C and ISO C++ compiler.
  86. %track
  87. prog gcc46 = {
  88. version = %{V_full}-%{V_snap}
  89. url = ftp://gcc.gnu.org/pub/gcc/snapshots/
  90. regex = (%{V_full}-\d{8})
  91. url = ftp://gcc.gnu.org/pub/gcc/snapshots/__NEWVER__/
  92. regex = gcc-(\d+\.\d+-\d{8})\.tar\.bz2
  93. }
  94. %prep
  95. %setup -q -n gcc-%{V_full}-%{V_snap}
  96. %patch -p0
  97. %{l_shtool} subst -v -s \
  98. -e 's;PREFIX_INCLUDE_DIR;PREFIX_INCLUDE_DIR_DISABLED;g' \
  99. gcc/configure
  100. if [ ".%{V_comp}" != . ]; then
  101. %{l_shtool} subst -v -s \
  102. -e 's;(libdir)/gcc/;(libdir)/gcc%{V_comp}/;' \
  103. `find . -name Makefile.in -type f -print`
  104. fi
  105. case "%{l_platform -t}" in
  106. amd64*-linux* )
  107. %{l_shtool} subst \
  108. -e 's/GLIBCXX_IS_NATIVE=false/GLIBCXX_IS_NATIVE=true/g' \
  109. -e 's/test x.gcc_no_link = xyes/false/g' \
  110. libstdc++-v3/configure
  111. ;;
  112. esac
  113. %{l_shtool} subst \
  114. -e 's;<iconv\.h>;"%{l_prefix}/include/iconv.h";' \
  115. libstdc++-v3/include/ext/codecvt_specializations.h
  116. %build
  117. # create build sub-directory
  118. %{l_shtool} mkdir -p obj
  119. cd obj
  120. # determine ld(1) and as(1) usage
  121. l_with_gnu_ld_as=""
  122. LD=%{l_tool_locate ld ld}
  123. AS=%{l_tool_locate as as}
  124. echo $LD | grep '^/' >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-ld=$LD"
  125. echo $AS | grep '^/' >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-as=$AS"
  126. $LD --version </dev/null 2>/dev/null | grep "^GNU ld " >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-ld"
  127. $AS --version </dev/null 2>/dev/null | grep "^GNU assembler " >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-as"
  128. unset LD
  129. unset AS
  130. # determine threads usage
  131. %if "%{with_threads}" == "yes"
  132. l_enable_threads="posix"
  133. %else
  134. l_enable_threads="single"
  135. %endif
  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" || "%{with_cxx}" == "yes"
  158. CPPFLAGS="%{l_cppflags}" \
  159. LDFLAGS="%{l_ldflags}" \
  160. %endif
  161. CONFIG_SHELL="%{l_bash}" \
  162. ../configure \
  163. --with-bugurl="http://openpkg.org/" \
  164. --with-pkgversion="%{l_openpkg_release -F "OpenPKG-%%t"}" \
  165. --cache-file=./config.cache \
  166. --srcdir=`pwd`/.. \
  167. --prefix=%{l_prefix} \
  168. --exec-prefix=%{l_prefix} \
  169. --mandir=%{l_prefix}/man \
  170. --infodir=%{l_prefix}/info \
  171. --includedir=%{l_prefix}/include/gcc%{V_comp} \
  172. --libexecdir=%{l_prefix}/libexec/gcc%{V_comp} \
  173. --with-gxx-include-dir=%{l_prefix}/include/g++%{V_comp} \
  174. --with-local-prefix=%{l_prefix}/lib/gcc%{V_comp} \
  175. --enable-languages="${l_enable_languages}" \
  176. --enable-threads="${l_enable_threads}" \
  177. --disable-maintainer-mode \
  178. --disable-shared \
  179. --disable-nls \
  180. %if "%{with_java}" == "yes"
  181. --with-system-zlib \
  182. %endif
  183. %if "%{with_multilib}" == "yes"
  184. --enable-multilib \
  185. %else
  186. --disable-multilib \
  187. %endif
  188. %if "%{with_cxx}" == "yes"
  189. --with-libiconv-prefix=%{l_prefix} \
  190. %endif
  191. --with-gmp=%{l_prefix} \
  192. --with-mpfr=%{l_prefix} \
  193. --with-mpc=%{l_prefix} \
  194. ${l_with_gnu_ld_as}
  195. # determine build flags
  196. l_ccisgcc=no
  197. if [ ".`(%{l_cc} -v; %{l_cc} --version) </dev/null 2>&1 | grep -i 'gcc'`" != . ]; then
  198. l_ccisgcc=yes
  199. fi
  200. l_cflags=""
  201. l_cxxflags=""
  202. l_boot_cflags=""
  203. l_libcflags="-g"
  204. l_libcxxflags="-g"
  205. # at least GNU as from GNU binutils supports -pipe always
  206. AS="%{l_tool_locate as as}"
  207. "$AS" --version </dev/null 2>/dev/null | grep "^GNU assembler " >/dev/null && {
  208. l_boot_cflags="$l_boot_cflags -pipe"
  209. l_libcxxflags="$l_libcxxflags -pipe"
  210. }
  211. %if "%{with_optimize}" == "yes"
  212. # conservatively optimize the generated program code
  213. # (also _tune_ for particular CPUs, but _without_ requiring these CPUs!)
  214. l_cflags="$l_cflags -O"
  215. l_boot_cflags="$l_boot_cflags -O2 -fomit-frame-pointer"
  216. case "%{l_platform -t}" in
  217. *i?86-* ) l_boot_cflags="$l_boot_cflags -mtune=pentium3" ;;
  218. *sun4[uv]-* ) l_boot_cflags="$l_boot_cflags -mtune=v9" ;;
  219. esac
  220. l_libcxxflags="$l_libcxxflags -O2 -fno-implicit-templates"
  221. %else
  222. # else do no optimizations at all to reduce problems to minimum in advance
  223. l_boot_cflags="$l_boot_cflags -O0"
  224. l_libcxxflags="$l_libcxxflags -O0"
  225. %endif
  226. maketarget="bootstrap2-lean"
  227. %if "%{with_profile}" == "yes"
  228. # GCC >= 3.4 supports a "profiledbootstrap" target to build an
  229. # optimized version of itself through profiling. Because this
  230. # requires a (bootstrapping) C compiler with 64-bit arithmetic,
  231. # the whole approach is currently supported only if already
  232. # building with GCC as the bootstrapping C compiler.
  233. if [ ".$l_ccisgcc" = .yes ]; then
  234. maketarget="profiledbootstrap"
  235. fi
  236. %endif
  237. case "%{l_platform -t}" in
  238. amd64-* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;;
  239. ia64-* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;;
  240. sparc64-freebsd* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;;
  241. esac
  242. %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes" || "%{with_cxx}" == "yes"
  243. l_cflags="$l_cflags %{l_cppflags}"
  244. l_cxxflags="$l_cxxflags %{l_cppflags}"
  245. l_libcflags="$l_libcflags %{l_cppflags}"
  246. l_libcxxflags="$l_libcxxflags %{l_cppflags}"
  247. %endif
  248. # build the package
  249. MAKE="%{l_make} %{l_mflags}" \
  250. %{l_make} %{l_mflags} \
  251. MAKE="%{l_make} %{l_mflags}" \
  252. BOOT_CFLAGS="${l_boot_cflags}" \
  253. CFLAGS="${l_cflags}" \
  254. CXXFLAGS="${l_cxxflags}" \
  255. LIBCFLAGS="${l_libcflags}" \
  256. LIBCXXFLAGS="${l_libcxxflags}" \
  257. $maketarget
  258. %install
  259. # fetch GNU platform triple
  260. triple=`./config.guess`
  261. # perform the standard installation procedure
  262. ( cd obj
  263. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  264. ) || exit $?
  265. # cleanup installation tree
  266. mv $RPM_BUILD_ROOT%{l_prefix}/lib/{lib*.a,*.spec} \
  267. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \
  268. >/dev/null 2>&1 || true
  269. mv $RPM_BUILD_ROOT%{l_prefix}/lib64/{lib*.a,*.spec} \
  270. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \
  271. >/dev/null 2>&1 || true
  272. dirs=""
  273. for multilib in `$RPM_BUILD_ROOT%{l_prefix}/bin/gcc --print-multi-lib`; do
  274. subdir=`echo "$multilib" | sed -e 's/;.*$//'`
  275. [ ".$subdir" = .. ] && continue
  276. mv $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir/lib*.a \
  277. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \
  278. >/dev/null 2>&1 || true
  279. mv $RPM_BUILD_ROOT%{l_prefix}/lib64/$subdir/lib*.a \
  280. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \
  281. >/dev/null 2>&1 || true
  282. dirs="$dirs $subdir"
  283. done
  284. for subdir in $dirs; do
  285. rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir >/dev/null 2>&1 || true
  286. done
  287. mv $RPM_BUILD_ROOT%{l_prefix}/${triple}/include/* \
  288. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/include/ \
  289. >/dev/null 2>&1 || true
  290. # strip installation tree
  291. rm -rf $RPM_BUILD_ROOT%{l_prefix}/${triple}
  292. rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
  293. rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man7 >/dev/null 2>&1 || true
  294. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.la >/dev/null 2>&1 || true
  295. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib64/*.la >/dev/null 2>&1 || true
  296. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc* >/dev/null 2>&1 || true
  297. %if "%{with_cxx}" == "yes"
  298. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++ >/dev/null 2>&1 || true
  299. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++ >/dev/null 2>&1 || true
  300. %endif
  301. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  302. for prog in cc1 cc1plus collect2 cpp; do
  303. strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/${prog} \
  304. >/dev/null 2>&1 || true
  305. done
  306. # bump up installation tree
  307. ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc \
  308. $RPM_BUILD_ROOT%{l_prefix}/bin/cc
  309. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \
  310. $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1
  311. %if "%{with_cxx}" == "yes"
  312. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \
  313. $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1
  314. %endif
  315. # resolve filename conflicts
  316. %if "%{with_gcc}" != "yes" && "%{V_comp}" != ""
  317. ( cd $RPM_BUILD_ROOT%{l_prefix}/bin
  318. for file in *; do
  319. [ ".$file" = ".*" ] && continue
  320. mv ${file} ${file}%{V_comp}
  321. done
  322. ) || exit $?
  323. ( cd $RPM_BUILD_ROOT%{l_prefix}/info
  324. for file in *; do
  325. [ ".$file" = ".*" ] && continue
  326. mv ${file} `echo ${file} | sed -e 's;^\([^.]*\)\(\..*\)$;\1%{V_comp}\2;'`
  327. done
  328. ) || exit $?
  329. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man1
  330. for file in *; do
  331. [ ".$file" = ".*" ] && continue
  332. mv ${file} `echo ${file} | sed -e 's;^\([^.]*\)\(\..*\)$;\1%{V_comp}\2;'`
  333. done
  334. ) || exit $?
  335. %endif
  336. # determine installation file list
  337. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
  338. %files -f files
  339. %clean