bzr branch
http://suren.me/webbzr/ani/mrses
1
by Suren A. Chilingaryan
Initial import |
1 |
#!/bin/sh
|
2 |
# --------------------------------------------------------------
|
|
3 |
# (C) Copyright 2001,2007,
|
|
4 |
# International Business Machines Corporation,
|
|
5 |
#
|
|
6 |
# All Rights Reserved.
|
|
7 |
# --------------------------------------------------------------
|
|
8 |
||
9 |
#------------------------------------------------------------------------
|
|
10 |
# cellsdk_select_compiler
|
|
11 |
#
|
|
12 |
# This script selects the compiler in make.env
|
|
13 |
#
|
|
14 |
#------------------------------------------------------------------------
|
|
15 |
||
16 |
#
|
|
17 |
# Miscellaneous variables
|
|
18 |
#
|
|
19 |
if [ -f ${CELL_TOP}/buildutils/make.env ] ; then |
|
20 |
CELL_BUILD_DIR=$CELL_TOP |
|
21 |
else
|
|
22 |
CELL_BUILD_DIR=/opt/cell/sdk |
|
23 |
fi
|
|
24 |
CELL_MAKE_ENV=${CELL_BUILD_DIR}/buildutils/make.env |
|
25 |
CELL_MAKE_FOOTER=${CELL_BUILD_DIR}/buildutils/make.footer |
|
26 |
||
27 |
#--------------------------------------------------------------------------
|
|
28 |
# Switches to the gcc compiler
|
|
29 |
#
|
|
30 |
# return: none
|
|
31 |
function switch_to_gcc() |
|
32 |
{
|
|
33 |
# abort if gcc is not installed
|
|
34 |
which `PROGRAM_ppu=foo PPU_COMPILER=gcc make --no-print-directory CCACHE="" -f ${CELL_MAKE_FOOTER} listenv_c 2>/dev/null` >/dev/null 2>&1 |
|
35 |
if [ $? -ne 0 ] ; then |
|
36 |
echo "gcc is not installed - can't change default to gcc." |
|
37 |
elif [ "`grep "^ .*_COMPILER.*:= gcc" ${CELL_MAKE_ENV}`" == "" ] ; then |
|
38 |
sed -i -e 's/^ PPU32_COMPILER := xlc/# PPU32_COMPILER := xlc/' \ |
|
39 |
-e 's/^# PPU32_COMPILER := gcc/ PPU32_COMPILER := gcc/' \ |
|
40 |
-e 's/^ PPU64_COMPILER := xlc/# PPU64_COMPILER := xlc/' \ |
|
41 |
-e 's/^# PPU64_COMPILER := gcc/ PPU64_COMPILER := gcc/' \ |
|
42 |
-e 's/^ SPU_COMPILER := xlc/# SPU_COMPILER := xlc/' \ |
|
43 |
-e 's/^# SPU_COMPILER := gcc/ SPU_COMPILER := gcc/' \ |
|
44 |
${CELL_MAKE_ENV} && echo "Default compiler changed to GNU gcc." |
|
45 |
else
|
|
46 |
echo "Default compiler is already set to GNU gcc." |
|
47 |
fi
|
|
48 |
}
|
|
49 |
||
50 |
#--------------------------------------------------------------------------
|
|
51 |
# Switches to the gfortran
|
|
52 |
#
|
|
53 |
function switch_to_gfortran() |
|
54 |
{
|
|
55 |
# abort if gfortran is not installed
|
|
56 |
which `PROGRAM_ppu=foo FTN_PPU32_COMPILER=gfortran FTN_PPU64_COMPILER=gfortran make --no-print-directory -f ${CELL_MAKE_FOOTER} listenv_f 2>/dev/null` >/dev/null 2>&1 |
|
57 |
if [ $? -ne 0 ] ; then |
|
58 |
echo "gfortran is not installed - can't change default to gfortran." |
|
59 |
elif [ "`grep "^ .*_COMPILER.*:= gfortran" ${CELL_MAKE_ENV}`" == "" ] ; then |
|
60 |
sed -i -e 's/^ FTN_PPU32_COMPILER := xlf/# FTN_PPU32_COMPILER := xlf/' \ |
|
61 |
-e 's/^# FTN_PPU32_COMPILER := gfortran/ FTN_PPU32_COMPILER := gfortran/' \ |
|
62 |
-e 's/^ FTN_PPU64_COMPILER := xlf/# FTN_PPU64_COMPILER := xlf/' \ |
|
63 |
-e 's/^# FTN_PPU64_COMPILER := gfortran/ FTN_PPU64_COMPILER := gfortran/' \ |
|
64 |
-e 's/^ FTN_SPU_COMPILER := xlf/# FTN_SPU_COMPILER := xlf/' \ |
|
65 |
-e 's/^# FTN_SPU_COMPILER := gfortran/ FTN_SPU_COMPILER := gfortran/' \ |
|
66 |
${CELL_MAKE_ENV} && echo "Default compiler changed to GNU gfortran." |
|
67 |
else
|
|
68 |
echo "Default compiler is already set to GNU gfortran." |
|
69 |
fi
|
|
70 |
}
|
|
71 |
||
72 |
#--------------------------------------------------------------------------
|
|
73 |
# Switches to the xlc compiler
|
|
74 |
#
|
|
75 |
function switch_to_xlc() |
|
76 |
{
|
|
77 |
# abort if xlc is not installed
|
|
78 |
which `PROGRAM_ppu=foo PPU_COMPILER=xlc make --no-print-directory -f ${CELL_MAKE_FOOTER} listenv_c 2>/dev/null` >/dev/null 2>&1 |
|
79 |
if [ $? -ne 0 ] ; then |
|
80 |
echo "xlc is not installed - can't change default to xlc." |
|
81 |
elif [ "`grep "^ .*_COMPILER.*:= xlc" ${CELL_MAKE_ENV}`" == "" ] ; then |
|
82 |
sed -i -e 's/^# PPU32_COMPILER := xlc/ PPU32_COMPILER := xlc/' \ |
|
83 |
-e 's/^ PPU32_COMPILER := gcc/# PPU32_COMPILER := gcc/' \ |
|
84 |
-e 's/^# PPU64_COMPILER := xlc/ PPU64_COMPILER := xlc/' \ |
|
85 |
-e 's/^ PPU64_COMPILER := gcc/# PPU64_COMPILER := gcc/' \ |
|
86 |
-e 's/^# SPU_COMPILER := xlc/ SPU_COMPILER := xlc/' \ |
|
87 |
-e 's/^ SPU_COMPILER := gcc/# SPU_COMPILER := gcc/' \ |
|
88 |
${CELL_MAKE_ENV} && echo "Default compiler changed to IBM xlc." |
|
89 |
else
|
|
90 |
echo "Default compiler is already set to IBM xlc." |
|
91 |
fi
|
|
92 |
}
|
|
93 |
||
94 |
#--------------------------------------------------------------------------
|
|
95 |
# Switches to the xlf compiler
|
|
96 |
#
|
|
97 |
function switch_to_xlf() |
|
98 |
{
|
|
99 |
# warn if xlf is not installed
|
|
100 |
which `PROGRAM_ppu=foo FTN_PPU32_COMPILER=xlf FTN_PPU64_COMPILER=xlf make --no-print-directory -f ${CELL_MAKE_FOOTER} listenv_f 2>/dev/null` >/dev/null 2>&1 |
|
101 |
if [ $? -ne 0 ] ; then |
|
102 |
echo "xlf is not installed - can't change default to xlf." |
|
103 |
elif [ "`grep "^ .*_COMPILER.*:= xlf" ${CELL_MAKE_ENV}`" == "" ] ; then |
|
104 |
sed -i -e 's/^# FTN_PPU32_COMPILER := xlf/ FTN_PPU32_COMPILER := xlf/' \ |
|
105 |
-e 's/^ FTN_PPU32_COMPILER := gfortran/# FTN_PPU32_COMPILER := gfortran/' \ |
|
106 |
-e 's/^# FTN_PPU64_COMPILER := xlf/ FTN_PPU64_COMPILER := xlf/' \ |
|
107 |
-e 's/^ FTN_PPU64_COMPILER := gfortran/# FTN_PPU64_COMPILER := gfortran/' \ |
|
108 |
-e 's/^# FTN_SPU_COMPILER := xlf/ FTN_SPU_COMPILER := xlf/' \ |
|
109 |
-e 's/^ FTN_SPU_COMPILER := gfortran/# FTN_SPU_COMPILER := gfortran/' \ |
|
110 |
${CELL_MAKE_ENV} && echo "Default compiler changed to IBM xlf." |
|
111 |
else
|
|
112 |
echo "Default compiler is already set to IBM xlf." |
|
113 |
fi
|
|
114 |
}
|
|
115 |
||
116 |
||
117 |
#--------------------------------------------------------------------------
|
|
118 |
# Displays the usage statement
|
|
119 |
#
|
|
120 |
function usage() |
|
121 |
{
|
|
122 |
echo "Usage: $SELF <gcc | gfortran | gnu | xlc | xlf | xl> " |
|
123 |
echo "" |
|
124 |
echo " gcc: set GNU gcc as default c/c++ compiler in make.footer (default)" |
|
125 |
echo " gfortran: set GNU gfortran as default fortran compiler in make.footer (default)" |
|
126 |
echo " gnu: set both GNU gcc and gfortran as default compilers in make.footer (default)" |
|
127 |
echo " xlc: set IBM xlc as default c/c++ compiler in make.footer" |
|
128 |
echo " xlf: set IBM xlf as default fortran compiler in make.footer" |
|
129 |
echo " xl: set IBM xlc and xlf as default compilers in make.footer" |
|
130 |
echo "" |
|
131 |
}
|
|
132 |
||
133 |
||
134 |
#--------------------------------------------------------------------------
|
|
135 |
# Continue with main line execution of script
|
|
136 |
||
137 |
||
138 |
# Set our name
|
|
139 |
SELF=`basename $0` |
|
140 |
||
141 |
# Ensure we have at least one argument
|
|
142 |
if [ $# -lt 1 ] ; then |
|
143 |
usage |
|
144 |
exit 1 |
|
145 |
fi
|
|
146 |
||
147 |
# Pop the first argument as the task
|
|
148 |
TASK=$1 |
|
149 |
shift
|
|
150 |
||
151 |
case $TASK in |
|
152 |
gcc|gfortran|gnu|xlc|xlf|xl) |
|
153 |
if [ ! -w ${CELL_MAKE_ENV} ] ; then |
|
154 |
echo ${CELL_MAKE_ENV} "not writable" |
|
155 |
exit 1 |
|
156 |
fi
|
|
157 |
;;
|
|
158 |
||
159 |
-?|-h|--help|--usage) |
|
160 |
usage |
|
161 |
exit 0 |
|
162 |
;;
|
|
163 |
||
164 |
*)
|
|
165 |
echo "$SELF: unknown option '$TASK'" |
|
166 |
usage |
|
167 |
exit 1 |
|
168 |
;;
|
|
169 |
||
170 |
esac
|
|
171 |
||
172 |
case $TASK in |
|
173 |
gcc)
|
|
174 |
switch_to_gcc |
|
175 |
;;
|
|
176 |
gfortran)
|
|
177 |
switch_to_gfortran |
|
178 |
;;
|
|
179 |
gnu)
|
|
180 |
switch_to_gcc |
|
181 |
switch_to_gfortran |
|
182 |
;;
|
|
183 |
||
184 |
xlc)
|
|
185 |
switch_to_xlc |
|
186 |
;;
|
|
187 |
xlf)
|
|
188 |
switch_to_xlf |
|
189 |
;;
|
|
190 |
xl)
|
|
191 |
switch_to_xlc |
|
192 |
switch_to_xlf |
|
193 |
;;
|
|
194 |
*)
|
|
195 |
usage |
|
196 |
exit 1 |
|
197 |
;;
|
|
198 |
esac
|
|
199 |
||
200 |
# end of script
|