gcc8.spec 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. ##
  2. ## gcc8.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2017 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 8
  25. %define V_comp 8
  26. %define V_snap 20170910
  27. # package information
  28. Name: gcc8
  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: 20170911
  39. # package options
  40. %option with_binutils yes
  41. %option with_cxx yes
  42. %option with_objc no
  43. %option with_go no
  44. %option with_java no
  45. %option with_fortran no
  46. %option with_optimize no
  47. %option with_profile no
  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.xz
  53. Patch0: gcc8.patch
  54. # build information
  55. # (actually also likes "flex", "bison" and "texinfo", but is able
  56. # to build without it -- which is also important for bootstrapping)
  57. BuildPreReq: OpenPKG, openpkg >= 20160101, make
  58. PreReq: OpenPKG, openpkg >= 20160101
  59. %if "%{with_binutils}" == "yes"
  60. BuildPreReq: binutils >= 2.14
  61. PreReq: binutils >= 2.14
  62. %endif
  63. BuildPreReq: mpc, mpfr, gmp
  64. PreReq: mpc, mpfr, gmp
  65. %if "%{with_cxx}" == "yes"
  66. BuildPreReq: libiconv
  67. PreReq: libiconv
  68. %endif
  69. %if "%{with_java}" == "yes"
  70. BuildPreReq: zlib
  71. PreReq: zlib
  72. %endif
  73. %if "%{with_gcc}" == "yes"
  74. Provides: gcc = %{version}-%{release}
  75. Provides: gcc = %{version}-%{release}
  76. Provides: gcc::with_binutils = %{with_binutils}
  77. Provides: gcc::with_cxx = %{with_cxx}
  78. Provides: gcc::with_objc = %{with_objc}
  79. Provides: gcc::with_java = %{with_java}
  80. Provides: gcc::with_fortran = %{with_fortran}
  81. Provides: gcc::with_profile = %{with_profile}
  82. Provides: gcc::with_threads = %{with_threads}
  83. Provides: gcc::with_multilib = %{with_multilib}
  84. Provides: gcc::with_gcc = %{with_gcc}
  85. %endif
  86. %description
  87. The GNU Compiler Collection (GCC) provides standard conforming and
  88. highly portable compilers for the ISO C, ISO C++, Objective-C,
  89. Fortran, Java and Go languages.
  90. %track
  91. prog gcc8 = {
  92. version = %{V_full}-%{V_snap}
  93. url = ftp://gcc.gnu.org/pub/gcc/snapshots/
  94. regex = (%{V_full}-\d{8})
  95. }
  96. %prep
  97. %setup -q -n gcc-%{V_full}-%{V_snap}
  98. %patch -p0
  99. %{l_shtool} subst -v -s \
  100. -e 's;PREFIX_INCLUDE_DIR;PREFIX_INCLUDE_DIR_DISABLED;g' \
  101. gcc/configure
  102. if [ ".%{V_comp}" != . ]; then
  103. %{l_shtool} subst -v -s \
  104. -e 's;(libdir)/gcc/;(libdir)/gcc%{V_comp}/;' \
  105. `find . -name Makefile.in -type f -print`
  106. fi
  107. case "%{l_platform -t}" in
  108. amd64*-linux* )
  109. %{l_shtool} subst \
  110. -e 's/GLIBCXX_IS_NATIVE=false/GLIBCXX_IS_NATIVE=true/g' \
  111. -e 's/test x.gcc_no_link = xyes/false/g' \
  112. libstdc++-v3/configure
  113. ;;
  114. esac
  115. %{l_shtool} subst \
  116. -e 's;<iconv\.h>;"%{l_prefix}/include/iconv.h";' \
  117. libstdc++-v3/include/ext/codecvt_specializations.h
  118. %build
  119. # support bootstrapping GCC on systems without C++ compiler
  120. # (requires OpenPKG package "gcc-bootstrap")
  121. if [ -d %{l_prefix}/libexec/gcc-bootstrap/bin-bootstrap ]; then
  122. PATH="%{l_prefix}/libexec/gcc-bootstrap/bin-bootstrap:$PATH"
  123. fi
  124. # create build sub-directory
  125. %{l_shtool} mkdir -p obj
  126. cd obj
  127. # determine ld(1) and as(1) usage
  128. l_with_gnu_ld_as=""
  129. LD=%{l_tool_locate ld ld}
  130. AS=%{l_tool_locate as as}
  131. echo $LD | grep '^/' >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-ld=$LD"
  132. echo $AS | grep '^/' >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-as=$AS"
  133. $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"
  134. $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"
  135. unset LD
  136. unset AS
  137. # determine threads usage
  138. %if "%{with_threads}" == "yes"
  139. l_enable_threads="posix"
  140. %else
  141. l_enable_threads="no"
  142. %endif
  143. # determine language usage
  144. l_enable_languages="c"
  145. %if "%{with_cxx}" == "yes"
  146. l_enable_languages="${l_enable_languages},c++"
  147. %endif
  148. %if "%{with_objc}" == "yes"
  149. l_enable_languages="${l_enable_languages},objc"
  150. %endif
  151. %if "%{with_go}" == "yes"
  152. l_enable_languages="${l_enable_languages},go"
  153. %endif
  154. %if "%{with_java}" == "yes"
  155. l_enable_languages="${l_enable_languages},java"
  156. %endif
  157. %if "%{with_fortran}" == "yes"
  158. l_enable_languages="${l_enable_languages},f95"
  159. %endif
  160. # disable GNU gettext usage
  161. ( echo "ac_cv_header_libintl_h=no"
  162. echo "ac_cv_search_gettext=no"
  163. ) >config.cache
  164. %if "%{with_cxx}" != "yes"
  165. # disable GNU iconv usage
  166. ( echo "am_cv_func_iconv=no"
  167. echo "am_cv_lib_iconv=no"
  168. ) >>config.cache
  169. %endif
  170. # configure the package
  171. clocale="auto"
  172. case "%{l_platform -t}" in
  173. *-linux* ) clocale="generic" ;;
  174. esac
  175. CC="%{l_cc}" \
  176. CXX="%{l_cxx}" \
  177. CFLAGS="%{l_cflags}" \
  178. CXXFLAGS="%{l_cxxflags}" \
  179. %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes" || "%{with_cxx}" == "yes"
  180. CPPFLAGS="%{l_cppflags}" \
  181. LDFLAGS="%{l_ldflags}" \
  182. %endif
  183. CONFIG_SHELL="%{l_bash}" \
  184. ../configure \
  185. --cache-file=./config.cache \
  186. --with-bugurl="http://openpkg.org/" \
  187. --with-pkgversion="GCC %{l_openpkg_release -F "OpenPKG-%%t"}" \
  188. --srcdir=`pwd`/.. \
  189. --prefix=%{l_prefix} \
  190. --exec-prefix=%{l_prefix} \
  191. --mandir=%{l_prefix}/man \
  192. --infodir=%{l_prefix}/info \
  193. --includedir=%{l_prefix}/include/gcc%{V_comp} \
  194. --libexecdir=%{l_prefix}/libexec/gcc%{V_comp} \
  195. --with-gxx-include-dir=%{l_prefix}/include/g++%{V_comp} \
  196. --with-local-prefix=%{l_prefix}/lib/gcc%{V_comp} \
  197. --enable-languages="${l_enable_languages}" \
  198. --enable-threads="${l_enable_threads}" \
  199. --disable-werror \
  200. --disable-maintainer-mode \
  201. --disable-shared \
  202. --disable-nls \
  203. --enable-clocale=$clocale \
  204. --with-pic \
  205. %if "%{with_java}" == "yes"
  206. --with-system-zlib \
  207. %endif
  208. %if "%{with_multilib}" == "yes"
  209. --enable-multilib \
  210. %else
  211. --disable-multilib \
  212. %endif
  213. %if "%{with_cxx}" == "yes"
  214. --with-libiconv-prefix=%{l_prefix} \
  215. %else
  216. --without-libiconv-prefix \
  217. %endif
  218. --with-gmp=%{l_prefix} \
  219. --with-mpfr=%{l_prefix} \
  220. --with-mpc=%{l_prefix} \
  221. ${l_with_gnu_ld_as}
  222. # determine build flags
  223. l_ccisgcc=no
  224. if [ ".`(%{l_cc} -v; %{l_cc} --version) </dev/null 2>&1 | grep -i 'gcc'`" != . ]; then
  225. l_ccisgcc=yes
  226. fi
  227. l_cflags=""
  228. l_cxxflags=""
  229. l_boot_cflags=""
  230. l_libcflags="-g"
  231. l_libcxxflags="-g"
  232. # at least GNU as from GNU binutils supports -pipe always
  233. AS="%{l_tool_locate as as}"
  234. "$AS" --version </dev/null 2>/dev/null | grep "^GNU assembler " >/dev/null && {
  235. l_boot_cflags="$l_boot_cflags -pipe"
  236. l_libcxxflags="$l_libcxxflags -pipe"
  237. }
  238. %if "%{with_optimize}" == "yes"
  239. # conservatively optimize the generated program code
  240. # (also _tune_ for particular CPUs, but _without_ requiring these CPUs!)
  241. l_cflags="$l_cflags -O"
  242. l_boot_cflags="$l_boot_cflags -O2 -fomit-frame-pointer"
  243. case "%{l_platform -t}" in
  244. *i?86-* ) l_boot_cflags="$l_boot_cflags -mtune=pentium3" ;;
  245. *sun4[uv]-* ) l_boot_cflags="$l_boot_cflags -mtune=v9" ;;
  246. esac
  247. l_libcxxflags="$l_libcxxflags -O2 -fno-implicit-templates"
  248. %else
  249. # else do no optimizations at all to reduce problems to minimum in advance
  250. l_boot_cflags="$l_boot_cflags -O0"
  251. l_libcxxflags="$l_libcxxflags -O0"
  252. %endif
  253. maketarget="bootstrap2-lean"
  254. %if "%{with_profile}" == "yes"
  255. # GCC >= 3.4 supports a "profiledbootstrap" target to build an
  256. # optimized version of itself through profiling. Because this
  257. # requires a (bootstrapping) C compiler with 64-bit arithmetic,
  258. # the whole approach is currently supported only if already
  259. # building with GCC as the bootstrapping C compiler.
  260. if [ ".$l_ccisgcc" = .yes ]; then
  261. maketarget="profiledbootstrap"
  262. fi
  263. %endif
  264. case "%{l_platform -t}" in
  265. amd64-* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC"; l_libcflags="$l_libcflags -fPIC"; l_libcxxflags="$l_libcxxflags -fPIC" ;;
  266. ia64-* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC"; l_libcflags="$l_libcflags -fPIC"; l_libcxxflags="$l_libcxxflags -fPIC" ;;
  267. sparc64-freebsd* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC"; l_libcflags="$l_libcflags -fPIC"; l_libcxxflags="$l_libcxxflags -fPIC" ;;
  268. esac
  269. %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes" || "%{with_cxx}" == "yes"
  270. l_cflags="$l_cflags %{l_cppflags}"
  271. l_cxxflags="$l_cxxflags %{l_cppflags}"
  272. l_libcflags="$l_libcflags %{l_cppflags}"
  273. l_libcxxflags="$l_libcxxflags %{l_cppflags}"
  274. %endif
  275. # build the package
  276. MAKE="%{l_make} %{l_mflags}" \
  277. %{l_make} %{l_mflags} \
  278. MAKE="%{l_make} %{l_mflags}" \
  279. BOOT_CFLAGS="${l_boot_cflags}" \
  280. CFLAGS="${l_cflags}" \
  281. CXXFLAGS="${l_cxxflags}" \
  282. LIBCFLAGS="${l_libcflags}" \
  283. LIBCXXFLAGS="${l_libcxxflags}" \
  284. $maketarget
  285. %install
  286. # support bootstrapping GCC on systems without C++ compiler
  287. # (requires OpenPKG package "gcc-bootstrap")
  288. if [ -d %{l_prefix}/libexec/gcc-bootstrap/bin-bootstrap ]; then
  289. PATH="%{l_prefix}/libexec/gcc-bootstrap/bin-bootstrap:$PATH"
  290. fi
  291. # fetch GNU platform triple
  292. triple=`./config.guess`
  293. # perform the standard installation procedure
  294. ( cd obj
  295. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  296. ) || exit $?
  297. # cleanup installation tree
  298. mv $RPM_BUILD_ROOT%{l_prefix}/lib/{lib*.a,*.spec} \
  299. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \
  300. >/dev/null 2>&1 || true
  301. mv $RPM_BUILD_ROOT%{l_prefix}/lib64/{lib*.a,*.spec} \
  302. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \
  303. >/dev/null 2>&1 || true
  304. dirs=""
  305. for multilib in `$RPM_BUILD_ROOT%{l_prefix}/bin/gcc --print-multi-lib`; do
  306. subdir=`echo "$multilib" | sed -e 's/;.*$//'`
  307. [ ".$subdir" = .. ] && continue
  308. mv $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir/lib*.a \
  309. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \
  310. >/dev/null 2>&1 || true
  311. mv $RPM_BUILD_ROOT%{l_prefix}/lib64/$subdir/lib*.a \
  312. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \
  313. >/dev/null 2>&1 || true
  314. dirs="$dirs $subdir"
  315. done
  316. for subdir in $dirs; do
  317. rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir >/dev/null 2>&1 || true
  318. done
  319. mv $RPM_BUILD_ROOT%{l_prefix}/${triple}/include/* \
  320. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/include/ \
  321. >/dev/null 2>&1 || true
  322. # strip installation tree
  323. rm -rf $RPM_BUILD_ROOT%{l_prefix}/${triple}
  324. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/gcc-*/python >/dev/null 2>&1 || true
  325. rmdir $RPM_BUILD_ROOT%{l_prefix}/share/gcc-* >/dev/null 2>&1 || true
  326. rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
  327. rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man7 >/dev/null 2>&1 || true
  328. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.la >/dev/null 2>&1 || true
  329. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/libstdc++.a-gdb.py >/dev/null 2>&1 || true
  330. rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib64 >/dev/null 2>&1 || true
  331. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc* >/dev/null 2>&1 || true
  332. %if "%{with_cxx}" == "yes"
  333. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++ >/dev/null 2>&1 || true
  334. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++ >/dev/null 2>&1 || true
  335. %endif
  336. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  337. for prog in cc1 cc1plus collect2 cpp; do
  338. strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/${prog} \
  339. >/dev/null 2>&1 || true
  340. done
  341. # bump up installation tree
  342. ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc \
  343. $RPM_BUILD_ROOT%{l_prefix}/bin/cc
  344. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \
  345. $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1
  346. %if "%{with_cxx}" == "yes"
  347. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \
  348. $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1
  349. %endif
  350. # resolve filename conflicts
  351. %if "%{with_gcc}" != "yes" && "%{V_comp}" != ""
  352. ( cd $RPM_BUILD_ROOT%{l_prefix}/bin
  353. for file in *; do
  354. [ ".$file" = ".*" ] && continue
  355. mv ${file} ${file}%{V_comp}
  356. done
  357. ) || exit $?
  358. ( cd $RPM_BUILD_ROOT%{l_prefix}/info
  359. for file in *; do
  360. [ ".$file" = ".*" ] && continue
  361. mv ${file} `echo ${file} | sed -e 's;^\([^.]*\)\(\..*\)$;\1%{V_comp}\2;'`
  362. done
  363. ) || exit $?
  364. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man1
  365. for file in *; do
  366. [ ".$file" = ".*" ] && continue
  367. mv ${file} `echo ${file} | sed -e 's;^\([^.]*\)\(\..*\)$;\1%{V_comp}\2;'`
  368. done
  369. ) || exit $?
  370. %endif
  371. # determine installation file list
  372. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
  373. %files -f files
  374. %clean