1 # Copyright 2009 Michael F. Witten
3 # This file is part of the gcc-svn PKGBUILD system.
5 # The gcc-svn PKGBUILD system is free software: you can redistribute it
6 # and/or modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation, either version 3 of the
8 # License, or (at your option) any later version.
10 # The gcc-svn PKGBUILD system is distributed in the hope that it will be
11 # useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with the gcc-svn PKGBUILD system. If not, see
17 # <http://www.gnu.org/licenses/>.
19 # Maintainer/Author : Michael Witten <mfwitten>
21 ######################
22 #### Parse Config ####
23 ######################
27 _with_phase_source_flag=1
28 _with_phase_source_revision=$1
33 _with_phase_clean_flag=1
38 _with_phase_config_flag=1
43 _with_phase_compile_flag=1
48 _with_phase_test_flag=1
49 _with_phase_test_makedepends=(dejagnu=1.5 expect tcl)
54 _with_phase_install_flag=1
57 _with_graphite_loops()
59 local ppl='ppl=0.11.2' # gcc docs say >=0.10
60 local cloog='cloog=0.16.2' # gcc docs say >=0.15
62 _with_graphite_loops_makedepends=("$ppl" "$cloog")
63 _with_graphite_loops_depends=("${_with_graphite_loops_makedepends[@]}")
68 _with_docs_info_makedepends=(texinfo=4.13a) # gnu docs say >=4.7
75 _with_docs_pdf_makedepends=(
76 texinfo=4.31a # gnu docs say >=4.8
77 texlive-core=2009.1557
80 _with_docs_pdf_target_compile=pdf
81 _with_docs_pdf_target_install=install-pdf
84 # Currently, there is no rule to install the DVI docs
85 # So this code can remain dormant (probably forever)
89 # _with_docs_pdf_flag=1
91 # _with_docs_dvi_makedepends=(
92 # texinfo=4.31a # gnu docs say >=4.8
93 # texlive-core=2009.1557
96 # _with_docs_dvi_target_compile=dvi
97 # _with_docs_dvi_target_install=install-dvi
102 _with_docs_html_flag=1
104 _with_docs_html_makedepends=(texinfo=4.13a) # gnu docs say >=4.7
106 _with_docs_html_target_compile=html
107 _with_docs_html_target_install=install-html
112 _with_multilib_config=--disable-multilib
118 _with_prefix_config="--prefix=$1"
121 _with_program_prefix()
123 _with_program_prefix_config="--program-prefix=$1"
126 _with_program_suffix()
128 _with_program_suffix_config="--program-suffix=$1"
131 _with_program_transform_name()
133 _with_program_transform_name_config="--program-transform-name=$1"
136 _with_append_paths_script()
138 if [ "$_with_prepend_paths_script_flag" ]; then
139 error "'_with_append_paths_script' is silly when '_with_prepend_paths_script' is in effect. Please choose one."
143 _with_append_paths_script_flag=1
144 _install_paths_script_func=_phase_install_paths_script_for_appending
147 _with_prepend_paths_script()
149 if [ "$_with_append_paths_script_flag" ]; then
150 error "'_with_prepend_paths_script' is silly when '_with_append_paths_script' is in effect. Please choose one."
154 _with_prepend_paths_script_flag=1
155 _install_paths_script_func=_phase_install_paths_script_for_prepending
160 _with_threads_config="--enable-threads=$1"
166 _with_language_set_add "$i"
167 _with_language_`echo "$i" | tr +- p_`
173 _with_language_config="--enable-languages=${_with_language_set[*]}"
178 _with_gnu_unique_object()
180 if ! _with_language_set_has c++; then
181 error '_with_gnu_unique_object' requires '_with_language c++'
184 # http://gcc.gnu.org/install/configure.html
185 local glibc=$_package_glibc # gnu docs say >=2.11
187 _with_gnu_unique_object_makedepends=("$glibc")
188 _with_gnu_unique_object_depends=("${_with_gnu_unique_object_makedepends[@]}")
190 _with_gnu_unique_object_config=--enable-gnu-unique-object
195 local elfutils='elfutils=0.152' # gnu docs say >=0.8.12
197 _with_lto_makedepends=("$elfutils")
198 _with_lto_depends=("${_with_lto_makedepends[@]}")
200 _with_lto_config=--with-lto
203 _without_error_on_warning()
205 _with_error_on_warning_config=--disable-werror
208 _with_compiler_bootstrap()
210 _with_compiler_bootstrap_config=--enable-bootstrap
211 _with_compiler_bootstrap_make_args="$1"
214 _with_bootstrap_lean()
216 _with_compiler_bootstrap bootstrap-lean
219 _with_bootstrap_profiled()
221 _with_compiler_bootstrap profiledbootstrap
224 _with_ignore_phase_test_failure()
226 _with_ignore_phase_test_failure_flag=1
233 IFS=`echo -ne ' \t\n'`
234 _with_boot_cflags_make_args="BOOT_CFLAGS=$*"
243 IFS=`echo -ne ' \t\n'`
244 _with_build_config_make_args="BUILD_CONFIG=$*"
249 ########################
250 #### Language Setup ####
251 ########################
253 _with_language_set_has()
255 in_array $1 "${_with_language_set[@]}"
258 _with_language_set_add()
260 _with_language_set_has $1 ||
261 _with_language_set[${#_with_language_set[*]}]=$1
266 local glibc=$_package_glibc
268 _with_language_c_makedepends=("$glibc")
269 _with_language_c_depends=("${_with_language_c_makedepends[@]}")
274 # http://gcc.gnu.org/install/specific.html#x-x-linux-gnu
275 local glibc=$_package_glibc # gnu docs say >=2.2.5
277 _with_language_cpp_makedepends=("$glibc")
278 _with_language_cpp_depends=("${_with_language_cpp_makedepends[@]}")
287 local pattern="$1" element
292 [[ $element = $pattern ]] && return 0
303 _pkgbuild_setup_makedepends()
309 ###################################################
310 ## http://gcc.gnu.org/install/prerequisites.html ##
311 ###################################################
313 #### "Tools/packages necessary for building GCC"
316 gawk=3.1.8 # gcc docs say >=3.1.5
318 make=3.82 # gcc docs say >=3.80
324 ${_with_graphite_loops_makedepends[*]}
326 ${_with_lto_makedepends[*]}
328 #### "Tools/packages necessary for modifying GCC"
330 autoconf-2.64 # gcc docs say =2.64
331 m4=1.4.16 # gcc docs say >=1.4.6
332 automake=1.11.1 # gcc docs say =1.11
333 gettext=0.18.1.1 # gcc docs say >=0.14.5
334 gperf=3.0.4 # gcc docs say >=2.7.2
335 ${_with_phase_test_makedepends[*]}
336 autogen=5.9.9 # gcc docs say >=5.5.4
337 guile=1.8.8 # gcc docs say >=1.4.1
338 flex=2.5.35 # gcc docs say >=2.5.4
339 ${_with_docs_info[*]}
341 #${_with_docs_dvi[*]} # No rule to install dvi docs
342 ${_with_docs_html[*]}
344 perl=5.12.3 # gcc docs say >=5.6.1
345 diffutils=3.0 # gcc docs say >=2.7
346 patch=2.6.1 # gcc docs say >=2.5.4
348 #### Not listed in those places
349 ${_with_language_c_makedepends[*]}
350 ${_with_language_cpp_makedepends[*]}
351 ${_with_gnu_unique_object_makedepends[*]}
356 _pkgbuild_setup_depends()
361 ${_with_graphite_loops_depends[*]}
365 ${_with_gnu_unique_object_depends[*]}
366 ${_with_language_c_depends[*]}
367 ${_with_language_cpp_depends[*]}
368 ${_with_lto_depends[*]}
375 _phase_source_if_necessary()
377 cd "$srcdir" || return 1
379 if [ ! $_with_phase_source_flag ]; then
381 cd "$_svnmod" || return 1
385 msg "Connecting to server...."
387 if [ -d "$_svnmod" ] ; then
389 cd "$_svnmod" || return 1
390 svn update -r $_with_phase_source_revision || return 1
392 msg "The local files are updated."
397 -r $_with_phase_source_revision \
398 "$_svntrunk" "$_svnmod" || return 1
402 msg "Checkout done or server timeout"
406 cd "$srcdir" && mkdir -p build || return 1
411 _phase_clean_if_necessary()
413 if [ $_with_phase_clean_flag ]; then
416 rm -rf "$srcdir"/build/* || return 1
423 _phase_config_if_necessary()
425 if [ $_with_phase_config_flag ]; then
427 msg "Configuring ..."
429 cd "$srcdir/build" && "../$_svnmod/configure" \
430 $_with_prefix_config \
431 $_with_program_prefix_config \
432 $_with_program_suffix_config \
433 $_with_program_transform_name_config \
434 $_with_multilib_config \
435 $_with_threads_config \
436 --enable-maintainer-mode \
437 $_with_language_config \
438 $_with_gnu_unique_object_config \
440 $_with_error_on_warning_config \
441 $_with_compiler_bootstrap_config || return 1
448 _phase_compile_if_necessary()
450 if [ $_with_phase_compile_flag ]; then
456 msg2 "Compiling main payload..."
459 $_with_boot_cflags_make_args \
460 $_with_build_config_make_args \
461 $_with_compiler_bootstrap_make_args || return 1
463 _phase_compile_docs_if_necessary || return 1
468 _phase_compile_docs_if_necessary()
470 cd "$srcdir/build" || return 1
472 # info/man pages are created automatically by
473 # `make' if the tools are available.
475 if [ $_with_docs_pdf_target_compile ]; then
476 msg2 "Compiling PDF docs..."
477 make $_with_docs_pdf_target_compile || return 1
480 # Currently there is no rule for installing DVI docs,
481 # so this code can remain dormant (probably forever):
483 #if [ $_with_docs_dvi_target_compile ]; then
484 # msg2 "Compiling DVI docs..."
485 # make $_with_docs_dvi_target_compile || return 1
488 if [ $_with_docs_html_target_compile ]; then
489 msg2 "Compiling HTML docs..."
490 make $_with_docs_html_target_compile || return 1
496 _phase_test_if_necessary()
498 if [ $_with_phase_test_flag ]; then
502 cd "$srcdir/build" || return 1
503 make -k check || _phase_test_should_ignore_errors || return 1
508 _phase_test_should_ignore_errors()
510 warning "Testing wasn't (completely?) successful."
512 [ $_with_ignore_phase_test_failure_flag ] &&
513 { msg2 "Ignoring..."; return 0; }
515 local message="Ignore? [y/n] "
520 read -p "$message" reply
523 y) msg2 "Ignoring..." ; return 0 ;;
524 n) msg2 "Failing..." ; return 1 ;;
532 _phase_install_if_necessary()
534 if [ $_with_phase_install_flag ]; then
538 cd "$srcdir/build" || return 1
540 msg2 "Installing main payload..."
541 make DESTDIR="$pkgdir" install || return 1
543 _phase_install_docs_if_necessary || return 1
544 _phase_install_paths_script_if_necessary || return 1
549 _phase_install_docs_if_necessary()
551 cd "$srcdir/build" || return 1
553 # info/man pages are installed automatically
554 # if they were created.
556 if [ $_with_docs_pdf_target_install ]; then
557 msg2 "Installing PDF docs..."
558 make DESTDIR="$pkgdir" $_with_docs_pdf_target_install || return 1
561 # Currently there is no rule for installing DVI docs,
562 # so this code can remain dormant (probably forever):
564 #if [ $_with_docs_dvi_target_install ]; then
565 # msg2 "Installing DVI docs..."
566 # make DESTDIR="$pkgdir" $_with_docs_dvi_target_install || return 1
569 if [ $_with_docs_html_target_install ]; then
570 msg2 "Installing HTML docs..."
571 make DESTDIR="$pkgdir" $_with_docs_html_target_install || return 1
575 _phase_install_paths_script_for_appending()
577 echo "export PATH=\"\$PATH:$_with_prefix_path/bin\"" > "$1"
580 _phase_install_paths_script_for_prepending()
582 echo "export PATH=\"$_with_prefix_path/bin:\$PATH\"" > "$1"
585 _phase_install_paths_script_if_necessary()
587 [ "$_install_paths_script_func" ] || return 0
589 script_dir="$pkgdir/etc/profile.d"
590 script_path="$script_dir/gcc-svn.sh"
592 install -d "$script_dir" || return 1
594 $_install_paths_script_func "$script_path" || return 1
596 chmod 755 "$script_path" || return 1
604 export PATH="/opt/autoconf/2.64/bin:$PATH"
606 _phase_source_if_necessary || return 1
607 _phase_clean_if_necessary || return 1
608 _phase_config_if_necessary || return 1
609 _phase_compile_if_necessary || return 1
610 _phase_test_if_necessary || return 1
612 export PATH=$PATH_OLD
618 export PATH="/opt/autoconf/2.64/bin:$PATH"
620 _phase_install_if_necessary || return 1
622 export PATH=$PATH_OLD
625 #######################
626 #### Miscellaneous ####
627 #######################
628 # http://gcc.gnu.org/install/specific.html#x86-x-linux
629 _package_binutils='binutils=2.21.1' # gnu docs say >=2.13.1
631 _package_gmp='gmp=5.0.2' # gnu docs say >=4.2
633 _package_mpfr='mpfr=3.0.1.p4' # gnu docs say >=2.3.2
635 _package_libmpc='libmpc=0.9' # gnu docs say >=0.7.0; complex number optimizations
637 _package_glibc='glibc=2.14' # gnu docs vary; see local usage of this variable
639 _svntrunk=svn://gcc.gnu.org/svn/gcc/trunk