2
# --------------------------------------------------------------
3
# (C) Copyright 2001,2007,
4
# International Business Machines Corporation,
7
# --------------------------------------------------------------
9
#------------------------------------------------------------------------
10
# cellsdk_select_compiler
12
# This script selects the compiler in make.env
14
#------------------------------------------------------------------------
17
# Miscellaneous variables
19
if [ -f ${CELL_TOP}/buildutils/make.env ] ; then
20
CELL_BUILD_DIR=$CELL_TOP
22
CELL_BUILD_DIR=/opt/cell/sdk
24
CELL_MAKE_ENV=${CELL_BUILD_DIR}/buildutils/make.env
25
CELL_MAKE_FOOTER=${CELL_BUILD_DIR}/buildutils/make.footer
27
#--------------------------------------------------------------------------
28
# Switches to the gcc compiler
31
function switch_to_gcc()
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."
46
echo "Default compiler is already set to GNU gcc."
50
#--------------------------------------------------------------------------
51
# Switches to the gfortran
53
function switch_to_gfortran()
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."
68
echo "Default compiler is already set to GNU gfortran."
72
#--------------------------------------------------------------------------
73
# Switches to the xlc compiler
75
function switch_to_xlc()
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."
90
echo "Default compiler is already set to IBM xlc."
94
#--------------------------------------------------------------------------
95
# Switches to the xlf compiler
97
function switch_to_xlf()
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."
112
echo "Default compiler is already set to IBM xlf."
117
#--------------------------------------------------------------------------
118
# Displays the usage statement
122
echo "Usage: $SELF <gcc | gfortran | gnu | xlc | xlf | xl> "
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"
134
#--------------------------------------------------------------------------
135
# Continue with main line execution of script
141
# Ensure we have at least one argument
142
if [ $# -lt 1 ] ; then
147
# Pop the first argument as the task
152
gcc|gfortran|gnu|xlc|xlf|xl)
153
if [ ! -w ${CELL_MAKE_ENV} ] ; then
154
echo ${CELL_MAKE_ENV} "not writable"
159
-?|-h|--help|--usage)
165
echo "$SELF: unknown option '$TASK'"