|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License: |
| 4 | +# OpenCoarrays -- A transport layer for coarray parallel programming |
| 5 | +# Copyright (c) 2012-2015, Sourcery, Inc. |
| 6 | +# Copyright (c) 2015, Sourcery Institute |
| 7 | +# All rights reserved. |
| 8 | +# Redistribution and use in source and binary forms, with or without modification, |
| 9 | +# are permitted provided that the following conditions are met: |
| 10 | +# |
| 11 | +# 1. Redistributions of source code must retain the above copyright notice, this |
| 12 | +# list of conditions and the following disclaimer. |
| 13 | +# 2. Redistributions in binary form must reproduce the above copyright notice, this |
| 14 | +# list of conditions and the following disclaimer in the documentation and/or |
| 15 | +# other materials provided with the distribution. |
| 16 | +# 3. Neither the names of the copyright holders nor the names of their contributors |
| 17 | +# may be used to endorse or promote products derived from this software without |
| 18 | +# specific prior written permission. |
| 19 | +# |
| 20 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 21 | +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 22 | +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 23 | +# IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
| 24 | +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 25 | +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 26 | +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 27 | +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 | +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 | +# POSSIBILITY OF SUCH DAMAGE. |
| 30 | + |
| 31 | +cmd=`basename $0` |
| 32 | +usage() |
| 33 | +{ |
| 34 | + echo "" |
| 35 | + echo " $cmd - Bash script for building GCC from source" |
| 36 | + echo "" |
| 37 | + echo " Usage: $cmd <branch-name> <install-path> <number-of-threads> [options] ..." |
| 38 | + echo "" |
| 39 | + echo " Options:" |
| 40 | + echo " --help, -h Show this help message" |
| 41 | + echo " --version, -v, -V Report version and copyright information" |
| 42 | + echo "" |
| 43 | + echo " Example usage:" |
| 44 | + echo "" |
| 45 | + echo " $cmd trunk /opt/gnu/6.0 4" |
| 46 | + echo " $cmd gcc-5-branch /opt/gnu/5.2 4" |
| 47 | + echo " $cmd -v" |
| 48 | + echo " $cmd --help" |
| 49 | + echo "" |
| 50 | + echo " Note: use svn ls svn://gcc.gnu.org/svn/gcc/branches" |
| 51 | + echo " to list all available branches." |
| 52 | + echo "" |
| 53 | + exit 1 |
| 54 | +} |
| 55 | + |
| 56 | +build() |
| 57 | +{ |
| 58 | + cd $1 && |
| 59 | + ./contrib/download_prerequisites && |
| 60 | + cd .. && |
| 61 | + mkdir -p $1-build && |
| 62 | + cd $1\-build && |
| 63 | + ../$1/configure --prefix=$2 --enable-languages=c,c++,fortran,lto --disable-multilib --disable-werror && |
| 64 | + make -j $num_threads bootstrap |
| 65 | +} |
| 66 | + |
| 67 | + |
| 68 | +# Default to 2 threads if no specified thread count: |
| 69 | +if [ -z $3 ]; then |
| 70 | + num_threads=2 |
| 71 | +else |
| 72 | + num_threads=$3 |
| 73 | +fi |
| 74 | + |
| 75 | +if [ $# == 0 ]; then |
| 76 | + # Print usage information if script is invoked without arguments |
| 77 | + usage | less |
| 78 | +elif [[ $1 == '--help' || $1 == '-h' ]]; then |
| 79 | + # Print usage information if script is invoked with --help or -h argument |
| 80 | + usage | less |
| 81 | +elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then |
| 82 | + # Print script copyright if invoked with -v, -V, or --version argument |
| 83 | + echo "" |
| 84 | + echo "GCC Build Script" |
| 85 | + echo "Copyright (C) 2015 Sourcery, Inc." |
| 86 | + echo "" |
| 87 | + echo "$cmd comes with NO WARRANTY, to the extent permitted by law." |
| 88 | + echo "You may redistribute copies of $cmd under the terms of the" |
| 89 | + echo "BSD 3-Clause License. For more information about these matters, see" |
| 90 | + echo "http://www.sourceryinstitute.org/license.html" |
| 91 | + echo "" |
| 92 | +elif [[ $1 == 'trunk' ]]; then |
| 93 | + time \ |
| 94 | + { |
| 95 | + svn co svn://gcc.gnu.org/svn/gcc/$1 && |
| 96 | + build $1 $2 $3 |
| 97 | + } >&1 | tee build.log |
| 98 | +else |
| 99 | + # Build gcc |
| 100 | + time \ |
| 101 | + { |
| 102 | + svn co svn://gcc.gnu.org/svn/gcc/branches/$1 && |
| 103 | + build $1 $2 $3 |
| 104 | + } >&1 | tee build.log |
| 105 | + echo "Check build.log for results. If the build was successful," |
| 106 | + echo "type 'make install' (or 'sudo make install') to complete" |
| 107 | + echo "the installation." |
| 108 | +fi |
0 commit comments