updated on Thu Jan 26 00:18:00 UTC 2012
[aur-mirror.git] / gcc-svn / PKGBUILD_tools
blobbc98d90291031bbca7f5fee04bc64a64a6630f8c
1 # Copyright 2009 Michael F. Witten
3 # This file is part of the gcc-svn PKGBUILD system.
4
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.
9
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.
14
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 ######################
25 _with_phase_source()
27   _with_phase_source_flag=1
28   _with_phase_source_revision=$1
31 _with_phase_clean()
33   _with_phase_clean_flag=1
36 _with_phase_config()
38   _with_phase_config_flag=1
41 _with_phase_compile()
43   _with_phase_compile_flag=1
46 _with_phase_test()
48   _with_phase_test_flag=1
49   _with_phase_test_makedepends=(dejagnu=1.5 expect tcl)
52 _with_phase_install()
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[@]}")
66 _with_docs_info()
68   _with_docs_info_makedepends=(texinfo=4.13a)            # gnu docs say >=4.7
71 _with_docs_pdf()
73   _with_docs_pdf_flag=1
75   _with_docs_pdf_makedepends=(
76      texinfo=4.31a                                       # gnu docs say >=4.8
77      texlive-core=2009.1557
78   ) 
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)
87 #_with_docs_dvi()
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
94 #  ) 
96 #  _with_docs_dvi_target_compile=dvi
97 #  _with_docs_dvi_target_install=install-dvi
100 _with_docs_html()
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
110 _without_multilib()
112   _with_multilib_config=--disable-multilib
115 _with_prefix()
117   _with_prefix_path=$1
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."
140     exit 1
141   fi
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."
151     exit 1
152   fi
154   _with_prepend_paths_script_flag=1
155   _install_paths_script_func=_phase_install_paths_script_for_prepending
158 _with_threads()
160   _with_threads_config="--enable-threads=$1"
163 _with_language()
165   for i in "$@"; do
166     _with_language_set_add "$i"
167     _with_language_`echo "$i" | tr +- p_`
168   done
170   IFS_OLD=$IFS
172     IFS=,
173     _with_language_config="--enable-languages=${_with_language_set[*]}"
175   IFS=$IFS_OLD
178 _with_gnu_unique_object()
180   if ! _with_language_set_has c++; then
181     error '_with_gnu_unique_object' requires '_with_language c++'
182     exit 1
183   fi
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
193 _with_lto()
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
229 _with_boot_cflags()
231   IFS_OLD=$IFS
233     IFS=`echo -ne ' \t\n'`
234     _with_boot_cflags_make_args="BOOT_CFLAGS=$*"
236   IFS=$IFS_OLD
239 _with_build_config()
241   IFS_OLD=$IFS
243     IFS=`echo -ne ' \t\n'`
244     _with_build_config_make_args="BUILD_CONFIG=$*"
246   IFS=$IFS_OLD
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
264 _with_language_c()
266   local glibc=$_package_glibc
268   _with_language_c_makedepends=("$glibc")
269   _with_language_c_depends=("${_with_language_c_makedepends[@]}")
272 _with_language_cpp()
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[@]}")
281 ###################
282 #### Utilities ####
283 ###################
285 in_array()
287   local pattern="$1" element
288   shift
290   for element
291   do
292      [[ $element = $pattern ]] && return 0
293   done
295   return 1
298 ################
299 #### Phases ####
300 ################
302 #### PKGBUILD Setup
303 _pkgbuild_setup_makedepends()
305   makedepends=(
306   
307     coreutils
308   
309     ###################################################
310     ## http://gcc.gnu.org/install/prerequisites.html ##
311     ###################################################
312   
313     #### "Tools/packages necessary for building GCC"
314   
315       bash=4.2.010
316       gawk=3.1.8                                           # gcc docs say >=3.1.5
317      ${_package_binutils}
318       make=3.82                                            # gcc docs say >=3.80
319       gcc=4.6.1
320       flex=2.5.35
321       bison=2.5
322      ${_package_gmp}
323      ${_package_mpfr}
324      ${_with_graphite_loops_makedepends[*]}
325      ${_package_libmpc}
326      ${_with_lto_makedepends[*]}
327     
328     #### "Tools/packages necessary for modifying GCC"
329   
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[*]}
340      ${_with_docs_pdf[*]}
341      #${_with_docs_dvi[*]}                                 # No rule to install dvi docs
342      ${_with_docs_html[*]}
343      'subversion>=1.6.6'
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
347   
348     #### Not listed in those places
349      ${_with_language_c_makedepends[*]}
350      ${_with_language_cpp_makedepends[*]}
351      ${_with_gnu_unique_object_makedepends[*]}
352   
353   )
356 _pkgbuild_setup_depends()
358   depends=(
359   
360     ${_package_binutils}
361     ${_with_graphite_loops_depends[*]}
362     ${_package_gmp}
363     ${_package_mpfr}
364     ${_package_libmpc}
365     ${_with_gnu_unique_object_depends[*]}
366     ${_with_language_c_depends[*]}
367     ${_with_language_cpp_depends[*]}
368     ${_with_lto_depends[*]}
369   
370   )
373 #### Source
375 _phase_source_if_necessary()
377   cd "$srcdir"                                           || return 1
379   if [ ! $_with_phase_source_flag ]; then
381     cd "$_svnmod"                                        || return 1
383   else
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."
394     else
396       svn checkout                                       \
397         -r $_with_phase_source_revision                  \
398         "$_svntrunk" "$_svnmod"                          || return 1
400     fi
402     msg "Checkout done or server timeout"
404   fi
406   cd "$srcdir" && mkdir -p build                         || return 1
409 #### Clean
411 _phase_clean_if_necessary()
413   if [ $_with_phase_clean_flag ]; then
415     msg "Cleaning ..."
416     rm -rf "$srcdir"/build/*                             || return 1
418   fi
421 #### Config
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                    \
439       $_with_lto_config                                  \
440       $_with_error_on_warning_config                     \
441       $_with_compiler_bootstrap_config                   || return 1
443   fi
446 #### Compile
448 _phase_compile_if_necessary()
450   if [ $_with_phase_compile_flag ]; then
452     msg "Compiling ..."
454     cd "$srcdir/build"
456     msg2 "Compiling main payload..."
458     make                                                 \
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
465   fi
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
478   fi
480   # Currently there is no rule for installing DVI docs,
481   # so this code can remain dormant (probably forever):
482   #
483   #if [ $_with_docs_dvi_target_compile ]; then
484   #  msg2 "Compiling DVI docs..."
485   #  make $_with_docs_dvi_target_compile                 || return 1
486   #fi
488   if [ $_with_docs_html_target_compile ]; then
489     msg2 "Compiling HTML docs..."
490     make $_with_docs_html_target_compile                 || return 1
491   fi
494 #### Test
496 _phase_test_if_necessary()
498   if [ $_with_phase_test_flag ]; then
500     msg "Testing ..."
502     cd "$srcdir/build"                                   || return 1
503     make -k check || _phase_test_should_ignore_errors    || return 1
505   fi
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] "
516   local reply
518   while true; do
520     read -p "$message" reply
522     case "$reply" in
523       y) msg2 "Ignoring..." ; return 0 ;;
524       n) msg2 "Failing..."  ; return 1 ;;
525     esac
527   done
530 #### Install
532 _phase_install_if_necessary()
534   if [ $_with_phase_install_flag ]; then
536     msg "Installing ..."
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
546   fi
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
559   fi
561   # Currently there is no rule for installing DVI docs,
562   # so this code can remain dormant (probably forever):
563   #
564   #if [ $_with_docs_dvi_target_install ]; then
565   #  msg2 "Installing DVI docs..."
566   #  make DESTDIR="$pkgdir" $_with_docs_dvi_target_install  || return 1
567   #fi
569   if [ $_with_docs_html_target_install ]; then
570     msg2 "Installing HTML docs..."
571     make DESTDIR="$pkgdir" $_with_docs_html_target_install || return 1
572   fi
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
599 #### Build
601 _pkgbuild_build()
603   local PATH_OLD=$PATH
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
611     
612   export PATH=$PATH_OLD
615 package()
617   local PATH_OLD=$PATH
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
640 _svnmod=repo