gcc35.spec 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. ##
  2. ## gcc35.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2004 The OpenPKG Project <http://www.openpkg.org/>
  4. ## Copyright (c) 2000-2004 Ralf S. Engelschall <rse@engelschall.com>
  5. ## Copyright (c) 2000-2004 Cable & Wireless <http://www.cw.com/>
  6. ##
  7. ## Permission to use, copy, modify, and distribute this software for
  8. ## any purpose with or without fee is hereby granted, provided that
  9. ## the above copyright notice and this permission notice appear in all
  10. ## copies.
  11. ##
  12. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  13. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  16. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  19. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  21. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. ## SUCH DAMAGE.
  24. ##
  25. # package version
  26. %define V_full 3.5
  27. %define V_comp 35
  28. %define V_snap 20040613
  29. # package information
  30. Name: gcc35
  31. Summary: GNU Compiler Collection
  32. URL: http://gcc.gnu.org/
  33. Vendor: Free Software Foundation
  34. Packager: The OpenPKG Project
  35. Distribution: OpenPKG
  36. Class: EVAL
  37. Group: Compiler
  38. License: GPL
  39. Version: %{V_full}s%{V_snap}
  40. Release: 20040616
  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 yes
  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: gcc35.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.13
  61. PreReq: binutils >= 2.13
  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 gcc35 = {
  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;@l_openpkg_release@;%{l_openpkg_release -F "OpenPKG-%s"};' \
  87. gcc/version.c
  88. %build
  89. # create build sub-directory
  90. mkdir obj
  91. cd obj
  92. # determine ld(1) and as(1) usage
  93. l_with_gnu_ld_as=""
  94. %if "%{with_binutils}" == "yes"
  95. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-ld --with-ld=%{l_prefix}/bin/ld"
  96. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-as --with-as=%{l_prefix}/bin/as"
  97. %else
  98. case "%{l_platform -t}" in
  99. *-linux* | *-freebsd* )
  100. l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-as --with-gnu-ld"
  101. ;;
  102. esac
  103. %endif
  104. # determine threads usage
  105. %if "%{with_threads}" == "yes"
  106. l_enable_threads="posix"
  107. %else
  108. l_enable_threads="single"
  109. %endif
  110. # determine language usage
  111. l_enable_languages="c"
  112. %if "%{with_cxx}" == "yes"
  113. l_enable_languages="${l_enable_languages},c++"
  114. %endif
  115. %if "%{with_objc}" == "yes"
  116. l_enable_languages="${l_enable_languages},objc"
  117. %endif
  118. %if "%{with_java}" == "yes"
  119. l_enable_languages="${l_enable_languages},java"
  120. %endif
  121. %if "%{with_f77}" == "yes"
  122. l_enable_languages="${l_enable_languages},f77"
  123. %endif
  124. # disable GNU iconv usage
  125. ( echo "am_cv_func_iconv=no"
  126. echo "am_cv_lib_iconv=no"
  127. ) >config.cache
  128. # configure the package
  129. CC="%{l_cc}" \
  130. CFLAGS="%{l_cflags}" \
  131. CONFIG_SHELL="%{l_bash}" \
  132. ../configure \
  133. --cache-file=./config.cache \
  134. --srcdir=`pwd`/.. \
  135. --prefix=%{l_prefix} \
  136. --exec-prefix=%{l_prefix} \
  137. --includedir=%{l_prefix}/include/gcc%{V_comp} \
  138. --libexecdir=%{l_prefix}/libexec/gcc%{V_comp} \
  139. --with-gxx-include-dir=%{l_prefix}/include/g++%{V_comp} \
  140. --with-local-prefix=%{l_prefix}/lib/gcc%{V_comp} \
  141. --enable-languages="${l_enable_languages}" \
  142. --enable-threads="${l_enable_threads}" \
  143. --disable-maintainer-mode \
  144. --disable-shared \
  145. --disable-nls \
  146. ${l_with_gnu_ld_as}
  147. # explicitly redirect remaining gcc library directories
  148. %{l_shtool} subst -v -s \
  149. -e "s;(libdir)/gcc/;(libdir)/gcc%{V_comp}/;" \
  150. `find . -name Makefile -type f -print`
  151. # determine build flags
  152. l_ccisgcc=no
  153. if [ ".`(%{l_cc} -v; %{l_cc} --version) </dev/null 2>&1 | grep -i 'gcc'`" != . ]; then
  154. l_ccisgcc=yes
  155. fi
  156. l_cflags=""
  157. l_boot_cflags=""
  158. l_libcflags="-g"
  159. l_libcxxflags="-g"
  160. case "%{l_platform -t}" in
  161. alpha*-tru64* ) if [ ".$l_ccisgcc" = .no ]; then l_libcflags="$l_libcflags -ieee"; fi ;;
  162. esac
  163. %if "%{with_binutils}" == "yes"
  164. # at least GNU as from GNU binutils supports -pipe always
  165. l_boot_cflags="$l_boot_cflags -pipe"
  166. l_libcxxflags="$l_libcxxflags -pipe"
  167. %endif
  168. %if "%{with_optimize}" == "yes"
  169. # conservatively optimize the generated program code
  170. # (also _tune_ for particular CPUs, but _without_ requiring these CPUs!)
  171. l_cflags="$l_cflags -O"
  172. l_boot_cflags="$l_boot_cflags -O2 -fomit-frame-pointer -funroll-loops"
  173. case "%{l_platform -t}" in
  174. *i?86-* ) l_boot_cflags="$l_boot_cflags -mtune=pentium3" ;;
  175. *sun4u-* ) l_boot_cflags="$l_boot_cflags -mtune=v9" ;;
  176. esac
  177. l_libcxxflags="$l_libcxxflags -O2 -fno-implicit-templates"
  178. %else
  179. # else do no optimizations at all to reduce problems to minimum in advance
  180. l_boot_cflags="$l_boot_cflags -O0"
  181. l_libcxxflags="$l_libcxxflags -O0"
  182. %endif
  183. maketarget="bootstrap-lean"
  184. %if "%{with_profile}" == "yes"
  185. # GCC >= 3.4 supports a "profiledbootstrap" target to build an
  186. # optimized version of itself through profiling. Because this
  187. # requires a (bootstrapping) C compiler with 64-bit arithmetic,
  188. # the whole approach is currently supported only if already
  189. # building with GCC as the bootstrapping C compiler.
  190. if [ ".$l_ccisgcc" = .yes ]; then
  191. maketarget="profiledbootstrap"
  192. fi
  193. %endif
  194. # build the package
  195. %{l_make} %{l_mflags} \
  196. MAKE="%{l_make} %{l_mflags}" \
  197. BOOT_CFLAGS="${l_boot_cflags}" \
  198. CFLAGS="${l_cflags}" \
  199. LIBCFLAGS="${l_libcflags}" \
  200. LIBCXXFLAGS="${l_libcxxflags}" \
  201. $maketarget
  202. %install
  203. rm -rf $RPM_BUILD_ROOT
  204. # fetch GNU platform triple
  205. triple=`./config.guess`
  206. triple=`./config.sub ${triple}`
  207. # perform the standard installation procedure
  208. ( cd obj
  209. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  210. ) || exit $?
  211. # cleanup installation tree
  212. mv $RPM_BUILD_ROOT%{l_prefix}/lib/lib*.a \
  213. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/
  214. for multilib in `$RPM_BUILD_ROOT%{l_prefix}/bin/gcc --print-multi-lib`; do
  215. subdir=`echo "$multilib" | sed -e 's/;.*$//'`
  216. [ ".$subdir" = .. ] && continue
  217. mv $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir/lib*.a \
  218. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/
  219. rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir
  220. done
  221. mv $RPM_BUILD_ROOT%{l_prefix}/${triple}/include/* \
  222. $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/include/ \
  223. >/dev/null 2>&1 || true
  224. %if "%{with_java}" == "yes"
  225. mv $RPM_BUILD_ROOT%{l_prefix}/share/java \
  226. $RPM_BUILD_ROOT%{l_prefix}/share/gcc
  227. %endif
  228. # strip installation tree
  229. rm -rf $RPM_BUILD_ROOT%{l_prefix}/${triple}
  230. rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man7 >/dev/null 2>&1 || true
  231. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.la >/dev/null 2>&1 || true
  232. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc* >/dev/null 2>&1 || true
  233. %if "%{with_cxx}" == "yes"
  234. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++ >/dev/null 2>&1 || true
  235. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++ >/dev/null 2>&1 || true
  236. %endif
  237. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  238. for prog in cc1 cc1plus collect2 cpp; do
  239. strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/${prog} \
  240. >/dev/null 2>&1 || true
  241. done
  242. # bump up installation tree
  243. ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc \
  244. $RPM_BUILD_ROOT%{l_prefix}/bin/cc
  245. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \
  246. $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1
  247. %if "%{with_cxx}" == "yes"
  248. ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \
  249. $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1
  250. %endif
  251. # resolve filename conflicts
  252. %if "%{with_gcc}" != "yes" && "%{V_comp}" != ""
  253. ( cd $RPM_BUILD_ROOT%{l_prefix}/bin
  254. for file in *; do
  255. [ ".$file" = ".*" ] && continue
  256. mv ${file} ${file}%{V_comp}
  257. done
  258. ) || exit $?
  259. ( cd $RPM_BUILD_ROOT%{l_prefix}/info
  260. for file in *; do
  261. [ ".$file" = ".*" ] && continue
  262. mv ${file} `echo ${file} | sed -e 's;^\([^.]*\)\(\..*\)$;\1%{V_comp}\2;'`
  263. done
  264. ) || exit $?
  265. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man1
  266. for file in *; do
  267. [ ".$file" = ".*" ] && continue
  268. mv ${file} `echo ${file} | sed -e 's;^\([^.]*\)\(\..*\)$;\1%{V_comp}\2;'`
  269. done
  270. ) || exit $?
  271. %endif
  272. # determine installation file list
  273. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
  274. %files -f files
  275. %clean
  276. rm -rf $RPM_BUILD_ROOT