minor fixups
[grimoire-planeshift.git] / libgcc
blob7a516f910e60d7cc55826fcd4db9a293cc821913
1 #!/bin/bash
2 #---------------------------------------------------------------------
3 ##
4 ## @Synopsis Set of functions for dealing with the problem of having to
5 ## @Synopsis use different version of the gcc compilers.
6 ##
7 ## The basic usage is as follows:
8 ## <pre>
9 ## - If a spell works with the latest version of gcc, do nothing.
10 ## - To change the compiler version for a spell, add a GCC_VERSION field
11 ## to the spells DETAILS specifying major.minor version of gcc it needs,
12 ## e.g. GCC_VERSION=3.4
13 ## - add a 'depends gccXX' to the spell where XX == majorminor,
14 ## e.g. 'depends gcc34'
15 ## - add 'invoke_gcc' to the top of PRE_BUILD if the spell has a
16 ## custom PRE_BUILD file
17 ## </pre>
19 ## @Implementation These functions were added to allow the use of
20 ## @Implementation several versions of gcc in parallel.
23 ## @Copyright Copyright 2005 by the Source Mage Team
26 #---------------------------------------------------------------------
29 #---------------------------------------------------------------------
30 ## @param gcc version
31 ## @return 0 if that gcc version is being used
32 ## @return 1 otherwise
33 #---------------------------------------------------------------------
34 function use_gcc() {
36 gcc -dumpversion | grep -q $(esc_str $1) > /dev/null
40 #---------------------------------------------------------------------
41 ## @param new path to add
42 ## @param old path
43 ## @Stdout new path
44 ## Echos the old path with new path prepended, separated with a ':'
45 #---------------------------------------------------------------------
46 function gcc_prepend_path() {
48 if test -z $2
49 then echo $1
50 else echo $1:$2
56 #---------------------------------------------------------------------
57 ## @param path
59 ## Alters the environment so that the gcc in the specified directory
60 ## will be used for compiling
62 #---------------------------------------------------------------------
63 function gcc_add_paths() {
65 export PATH=$( gcc_prepend_path $1/bin $PATH )
66 export LD_LIBRARY_PATH=$( gcc_prepend_path $1/lib $LD_LIBRARY_PATH )
67 export LD_RUN_PATH=$( gcc_prepend_path $1/lib $LD_RUN_PATH )
68 export INFOPATH=$( gcc_prepend_path $1/info $INFOPATH )
69 export CPPFLAGS="-I $1/include $CPPFLAGS"
74 #---------------------------------------------------------------------
76 ## Determines if the spell specifies a gcc version to use. If so, it
77 ## alters the environment so that that gcc version is used for compilation.
79 #---------------------------------------------------------------------
80 function invoke_gcc() {
82 if [[ "$GCC_VERSION" ]] && ! use_gcc $GCC_VERSION; then
83 gcc_add_paths /opt/gcc${GCC_VERSION//.}
84 echo "Overriding gcc version: `gcc -dumpversion`"
90 #---------------------------------------------------------------------
92 ## This software is free software; you can redistribute it and/or modify
93 ## it under the terms of the GNU General Public License as published by
94 ## the Free Software Foundation; either version 2 of the License, or
95 ## (at your option) any later version.
97 ## This software is distributed in the hope that it will be useful,
98 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
99 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
100 ## GNU General Public License for more details.
102 ## You should have received a copy of the GNU General Public License
103 ## along with this software; if not, write to the Free Software
104 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
106 #---------------------------------------------------------------------