8 |
# modified by aja 01/00 |
# modified by aja 01/00 |
9 |
# rewritten in bash by eh3 08/03 |
# rewritten in bash by eh3 08/03 |
10 |
|
|
11 |
|
# Search for particular CPP #cmds associated with packages |
12 |
|
# usage: test_for_package_in_cpp_options CPP_file package_name |
13 |
|
test_for_package_in_cpp_options() { |
14 |
|
cpp_options=$1 |
15 |
|
pkg=$2 |
16 |
|
grep -i "#define.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1 |
17 |
|
RETVAL=$? |
18 |
|
if test "x${RETVAL}" = x0 ; then |
19 |
|
echo "Error: In $cpp_options there is an illegal line: #define ALLOW_$pkg" |
20 |
|
exit 99 |
21 |
|
fi |
22 |
|
grep -i "#undef.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1 |
23 |
|
RETVAL=$? |
24 |
|
if test "x${RETVAL}" = x0 ; then |
25 |
|
echo "Error: In $cpp_options there is an illegal line: #undef ALLOW_$pkg" |
26 |
|
exit 99 |
27 |
|
fi |
28 |
|
grep -i "#define.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1 |
29 |
|
RETVAL=$? |
30 |
|
if test "x${RETVAL}" = x0 ; then |
31 |
|
echo "Error: In $cpp_options there is an illegal line: #define DISABLE_$pkg" |
32 |
|
exit 99 |
33 |
|
fi |
34 |
|
grep -i "#undef.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1 |
35 |
|
RETVAL=$? |
36 |
|
if test "x${RETVAL}" = x0 ; then |
37 |
|
echo "Error: In $cpp_options there is an illegal line: #undef DISABLE_$pkg" |
38 |
|
exit 99 |
39 |
|
fi |
40 |
|
} |
41 |
|
|
42 |
|
# Read the $ROOTDIR/pkg/pkg_groups file and expand any references to |
43 |
|
# the package list. |
44 |
|
expand_pkg_groups() { |
45 |
|
new_packages= |
46 |
|
PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups" |
47 |
|
if test -r $PKG_GROUPS ; then |
48 |
|
cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp |
49 |
|
cat ./p1.tmp | awk '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp |
50 |
|
matched=0 |
51 |
|
for i in $PACKAGES ; do |
52 |
|
line=`grep $i ./p2.tmp` |
53 |
|
RETVAL=$? |
54 |
|
if test "x$RETVAL" = x0 ; then |
55 |
|
matched=1 |
56 |
|
replace=`echo $line | awk '{ $1=""; $2=""; print $0 }'` |
57 |
|
echo " replacing \"$i\" with: $replace" |
58 |
|
new_packages="$new_packages $replace" |
59 |
|
else |
60 |
|
new_packages="$new_packages $i" |
61 |
|
fi |
62 |
|
done |
63 |
|
PACKAGES=$new_packages |
64 |
|
rm -f ./p[1,2].tmp |
65 |
|
else |
66 |
|
echo "Warning: can't read package groups definition file: $PKG_GROUPS" |
67 |
|
fi |
68 |
|
} |
69 |
|
|
70 |
# Guess possible config options for this host |
# Guess possible config options for this host |
71 |
find_possible_configs() { |
find_possible_configs() { |
72 |
|
|
73 |
p_PLATFORM=`uname`"-"`uname -m` |
tmp1=`uname`"_"`uname -m` |
74 |
echo "The platform appears to be:" |
tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` |
75 |
echo " "$p_PLATFORM |
PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/'` |
76 |
|
OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")` |
77 |
p_LN= |
echo " The platform appears to be: $PLATFORM" |
78 |
|
# if test "x$OFLIST" = x ; then |
79 |
|
# echo " No pre-defined options files were found matching this platform" |
80 |
|
# echo " but examples for other platforms can be found in:" |
81 |
|
# echo " $ROOTDIR/tools/build_options" |
82 |
|
# else |
83 |
|
# echo " Options files (located in $ROOTDIR/tools/build_options) that" |
84 |
|
# echo " may work with this machine are:" |
85 |
|
# for i in $OFLIST ; do |
86 |
|
# echo " $i" |
87 |
|
# done |
88 |
|
# fi |
89 |
|
|
90 |
echo "test" > test |
echo "test" > test |
91 |
ln -s ./test link |
ln -s ./test link |
92 |
RETVAL=$? |
RETVAL=$? |
93 |
if test "x${RETVAL}" = x0 ; then |
if test "x${RETVAL}" = x0 ; then |
94 |
p_LN="ln -s" |
LN="ln -s" |
95 |
|
else |
96 |
|
echo "Error: \"ln -s\" does not appear to work on this system!" |
97 |
|
echo " For help, please contact <MITgcm-support@mitgcm.org>." |
98 |
|
exit 1 |
99 |
fi |
fi |
100 |
rm -f test link |
rm -f test link |
101 |
|
|
102 |
p_CPP=`which cpp` |
if test "x$CPP" = x ; then |
103 |
|
CPP="cpp -traditional -P" |
|
RETVAL=$? |
|
|
if test "x${RETVAL}" = x0 ; then |
|
|
p_LN="ln -s" |
|
104 |
fi |
fi |
|
rm -f test link |
|
105 |
|
|
106 |
# look for possible fortran compilers |
# look for possible fortran compilers |
107 |
|
tmp="$MITGCM_FC $FC g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95" |
108 |
p_FC= |
p_FC= |
109 |
for c in f77 g77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 ; do |
for c in $tmp ; do |
110 |
which $c > /dev/null 2>&1 |
rm -f ./hello.f ./hello |
111 |
|
cat >> hello.f <<EOF |
112 |
|
program hello |
113 |
|
do i=1,3 |
114 |
|
print *, 'hello world : ', i |
115 |
|
enddo |
116 |
|
end |
117 |
|
EOF |
118 |
|
$c -o hello hello.f > /dev/null 2>&1 |
119 |
RETVAL=$? |
RETVAL=$? |
120 |
if test "x${RETVAL}" = x0 ; then |
if test "x${RETVAL}" = x0 ; then |
121 |
p_FC="$p_FC $c" |
p_FC="$p_FC $c" |
122 |
fi |
fi |
123 |
done |
done |
|
echo "Possible FORTRAN compilers appear to be: " |
|
124 |
if test "x${p_FC}" = x ; then |
if test "x${p_FC}" = x ; then |
125 |
echo " None found!!!" |
cat 1>&2 <<EOF |
126 |
else |
|
127 |
echo " "$p_FC |
Error: No Fortran compilers were found in your path. Please specify one using: |
128 |
fi |
|
129 |
|
1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"), |
130 |
|
2) a command-line option (eg. "-fc NAME"), or |
131 |
|
3) the MITGCM_FC environment variable. |
132 |
|
|
|
# look for possible MPI libraries |
|
|
mpi_libs= |
|
|
mpi_fort=`which mpif77 2>/dev/null` |
|
|
RETVAL=$? |
|
|
if test "x${RETVAL}" = x0 ; then |
|
|
cat >>test.f <<EOF |
|
|
PROGRAM HELLO |
|
|
DO 10, I=1,10 |
|
|
PRINT *,'Hello World' |
|
|
10 CONTINUE |
|
|
STOP |
|
|
END |
|
133 |
EOF |
EOF |
134 |
eval "$mpi_fort -showme test.f > out" |
exit 1 |
135 |
RETVAL=$? |
else |
136 |
if test "x${RETVAL}" = x0 ; then |
echo " The possible FORTRAN compilers found in your path are:" |
137 |
a=`cat out` |
echo " "$p_FC |
138 |
for i in $a ; do |
if test "x$FC" = x ; then |
139 |
case $i in |
FC=`echo $p_FC | awk '{print $1}'` |
|
-*) |
|
|
mpi_libs="$mpi_libs $i" ;; |
|
|
esac |
|
|
done |
|
|
echo "The MPI libs appear to be:" |
|
|
echo " "$mpi_libs |
|
140 |
fi |
fi |
|
rm -f test.f out |
|
141 |
fi |
fi |
142 |
|
|
143 |
} |
for i in $p_FC ; do |
144 |
|
p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i |
145 |
|
if test -r $p_OF ; then |
146 |
|
OPTFILE=$p_OF |
147 |
|
echo " The options file: $p_OF" |
148 |
|
echo " appears to match so we'll use it." |
149 |
|
break |
150 |
|
fi |
151 |
|
done |
152 |
|
if test "x$OPTFILE" = x ; then |
153 |
|
cat 1>&2 <<EOF |
154 |
|
|
155 |
parse_options() { |
Error: No options file was found in: $ROOTDIR/tools/build_options/ |
156 |
|
that matches this platform ("$PLATFORM") and the compilers found in |
157 |
|
your path. Please specify an "optfile" using: |
158 |
|
|
159 |
ac_prev= |
1) the command line (eg. "-optfile=path/to/OPTFILE"), or |
160 |
for ac_option in "${OPTIONS[@]}" ; do |
2) the MITGCM_OF environment variable. |
161 |
|
|
162 |
|
If you need help, please contact the developers at <MITgcm-support@mitgcm.org>. |
163 |
|
|
164 |
|
EOF |
165 |
|
exit 1 |
166 |
|
fi |
167 |
|
|
168 |
|
# # look for possible MPI libraries |
169 |
|
# mpi_libs= |
170 |
|
# mpi_fort=`which mpif77 2>/dev/null` |
171 |
|
# RETVAL=$? |
172 |
|
# if test "x${RETVAL}" = x0 ; then |
173 |
|
# cat >>test.f <<EOF |
174 |
|
# PROGRAM HELLO |
175 |
|
# DO 10, I=1,10 |
176 |
|
# PRINT *,'Hello World' |
177 |
|
# 10 CONTINUE |
178 |
|
# STOP |
179 |
|
# END |
180 |
|
# EOF |
181 |
|
# eval "$mpi_fort -showme test.f > out" |
182 |
|
# RETVAL=$? |
183 |
|
# if test "x${RETVAL}" = x0 ; then |
184 |
|
# a=`cat out` |
185 |
|
# for i in $a ; do |
186 |
|
# case $i in |
187 |
|
# -*) |
188 |
|
# mpi_libs="$mpi_libs $i" ;; |
189 |
|
# esac |
190 |
|
# done |
191 |
|
# echo "The MPI libs appear to be:" |
192 |
|
# echo " "$mpi_libs |
193 |
|
# fi |
194 |
|
# rm -f test.f out |
195 |
|
# fi |
196 |
|
|
|
# echo "ac_option = :$ac_option:" |
|
|
|
|
|
# If the previous option needs an argument, assign it. |
|
|
if test -n "$ac_prev"; then |
|
|
eval "$ac_prev=\$ac_option" |
|
|
ac_prev= |
|
|
continue |
|
|
fi |
|
|
|
|
|
ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` |
|
|
|
|
|
case $ac_option in |
|
|
|
|
|
-help | --help | -h | --h) |
|
|
usage ;; |
|
|
|
|
|
-nooptfile | --nooptfile) |
|
|
OPTFILE="NONE" ;; |
|
|
-optfile | --optfile | -of | --of) |
|
|
ac_prev=optfile ;; |
|
|
-optfile=* | --optfile=* | -of=* | --of=*) |
|
|
OPTFILE=$ac_optarg ;; |
|
|
|
|
|
-pdepend | --pdepend) |
|
|
ac_prev=pdepend ;; |
|
|
-pdepend=* | --pdepend=*) |
|
|
PDEPEND=$ac_optarg ;; |
|
|
|
|
|
-pdefault | --pdefault) |
|
|
ac_prev=pdefault ;; |
|
|
-pdefault=* | --pdefault=*) |
|
|
PDEFAULT=$ac_optarg ;; |
|
|
|
|
|
-makefile | -ma) |
|
|
ac_prev=makefile ;; |
|
|
--makefile=* | -ma=*) |
|
|
MAKEFILE=$ac_optarg ;; |
|
|
|
|
|
-platform | --platform | -pl | --pl) |
|
|
ac_prev=platform ;; |
|
|
-platform=* | --platform=* | -pl=* | --pl=*) |
|
|
PLATFORM=$ac_optarg ;; |
|
|
|
|
|
-rootdir | --rootdir | -rd | --rd) |
|
|
ac_prev=rootdir ;; |
|
|
-rootdir=* | --rootdir=* | -rd=* | --rd=*) |
|
|
ROOTDIR=$ac_optarg ;; |
|
|
|
|
|
-mods | --mods | -mo | --mo) |
|
|
ac_prev=mods ;; |
|
|
-mods=* | --mods=* | -mo=* | --mo=*) |
|
|
MODS=$ac_optarg ;; |
|
|
|
|
|
-disable | --disable) |
|
|
ac_prev=disable ;; |
|
|
-disable=* | --disable=*) |
|
|
DISABLE=$ac_optarg ;; |
|
|
|
|
|
-enable | --enable) |
|
|
ac_prev=enable ;; |
|
|
-enable=* | --enable=*) |
|
|
ENABLE=$ac_optarg ;; |
|
|
|
|
|
-noopt | --noopt) |
|
|
ac_prev=noopt ;; |
|
|
-noopt=* | --noopt=*) |
|
|
NOOPT=$ac_optarg ;; |
|
|
|
|
|
# -cpp | --cpp) |
|
|
# ac_prev=cpp ;; |
|
|
# -cpp=* | --cpp=*) |
|
|
# CPP=$ac_optarg ;; |
|
|
|
|
|
-fortran | --fortran | -fc | --fc) |
|
|
ac_prev=fc ;; |
|
|
-fc=* | --fc=*) |
|
|
FC=$ac_optarg ;; |
|
|
|
|
|
-ieee | --ieee) |
|
|
IEEE=1 ;; |
|
|
-noieee | --noieee) |
|
|
IEEE=0 ;; |
|
|
|
|
|
-mpi | --mpi) |
|
|
MPI=1 ;; |
|
|
-nompi | --nompi) |
|
|
MPI=0 ;; |
|
|
|
|
|
-jam | --jam) |
|
|
JAM=1 ;; |
|
|
-nojam | --nojam) |
|
|
JAM=0 ;; |
|
|
|
|
|
-*) |
|
|
echo "Error: unrecognized option: "$ac_option |
|
|
usage |
|
|
;; |
|
|
|
|
|
*) |
|
|
echo "Error: unrecognized argument: "$ac_option |
|
|
usage |
|
|
;; |
|
|
|
|
|
esac |
|
|
|
|
|
done |
|
197 |
} |
} |
198 |
|
|
199 |
# Parse the package dependency information |
# Parse the package dependency information |
213 |
|
|
214 |
# Explain usage |
# Explain usage |
215 |
usage() { |
usage() { |
216 |
echo "" |
echo |
217 |
echo "Usage: "$0" [OPTIONS]" |
echo "Usage: "$0" [OPTIONS]" |
218 |
echo " where [OPTIONS] can be:"$'\n' |
echo " where [OPTIONS] can be:" |
219 |
|
echo |
220 |
echo " -help | --help | -h | --h" |
echo " -help | --help | -h | --h" |
221 |
echo " -nooptfile | --nooptfile" |
echo " -nooptfile | --nooptfile" |
222 |
echo " -optfile NAME | --optfile NAME | -of NAME | --of NAME" |
echo " -optfile NAME | --optfile NAME | -of NAME | --of NAME" |
225 |
echo " -pdepend=NAME | --pdepend=NAME" |
echo " -pdepend=NAME | --pdepend=NAME" |
226 |
echo " -pdefault NAME | --pdefault NAME" |
echo " -pdefault NAME | --pdefault NAME" |
227 |
echo " -pdefault=NAME | --pdefault=NAME" |
echo " -pdefault=NAME | --pdefault=NAME" |
228 |
echo " -makefile NAME | -ma NAME" |
echo " -make NAME | -m NAME" |
229 |
echo " --makefile=NAME | -ma=NAME" |
echo " --make=NAME | -m=NAME" |
230 |
|
echo " -makefile NAME | -mf NAME" |
231 |
|
echo " --makefile=NAME | -mf=NAME" |
232 |
echo " -platform NAME | --platform NAME | -pl NAME | --pl NAME" |
echo " -platform NAME | --platform NAME | -pl NAME | --pl NAME" |
233 |
echo " -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME" |
echo " -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME" |
234 |
echo " -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME" |
echo " -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME" |
247 |
echo " -fc=NAME | --fc=NAME" |
echo " -fc=NAME | --fc=NAME" |
248 |
echo " -[no]ieee | --[no]ieee" |
echo " -[no]ieee | --[no]ieee" |
249 |
echo " -[no]mpi | --[no]mpi" |
echo " -[no]mpi | --[no]mpi" |
250 |
echo " -[no]jam | --[no]jam"$'\n' |
echo " -[no]jam | --[no]jam" |
251 |
echo " and NAME is a string such as:"$'\n' |
echo |
252 |
|
echo " and NAME is a string such as:" |
253 |
|
echo |
254 |
echo " --enable pkg1 --enable 'pkg1 pkg2' --enable 'pkg1 pkg2 pkg3'" |
echo " --enable pkg1 --enable 'pkg1 pkg2' --enable 'pkg1 pkg2 pkg3'" |
255 |
echo " -mods=dir1 -mods='dir1' -mods='dir1 dir2 dir3'" |
echo " -mods=dir1 -mods='dir1' -mods='dir1 dir2 dir3'" |
256 |
echo " -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'"$'\n' |
echo " -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'" |
257 |
|
echo |
258 |
echo " which, depending upon your shell, may need to be single-quoted" |
echo " which, depending upon your shell, may need to be single-quoted" |
259 |
echo " if it contains spaces, dashes, or other special characters." |
echo " if it contains spaces, dashes, or other special characters." |
260 |
exit 1 |
exit 1 |
261 |
} |
} |
262 |
|
|
|
# Dump all important state |
|
|
dump_state() { |
|
|
fname=$1 |
|
|
echo " " > $fname |
|
|
RETVAL=$? |
|
|
if test "x${RETVAL}" = x ; then |
|
|
echo "Error: cannot write to $fname" |
|
|
exit 1 |
|
|
fi |
|
|
echo "makefile "$makefile > $fname |
|
|
} |
|
|
|
|
|
|
|
263 |
#eh3 # This is the generic configuration. |
#eh3 # This is the generic configuration. |
264 |
#eh3 set LN = ( 'ln -s' ) |
#eh3 set LN = ( 'ln -s' ) |
265 |
#eh3 set CPP = ( '/lib/cpp -P' ) |
#eh3 set CPP = ( '/lib/cpp -P' ) |
280 |
#eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = ( ) |
#eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = ( ) |
281 |
|
|
282 |
# Set defaults here |
# Set defaults here |
283 |
|
COMMANDL="$0 $@" |
284 |
|
|
285 |
PLATFORM= |
PLATFORM= |
286 |
LN= |
LN= |
287 |
S64= |
S64= |
288 |
KPP= |
KPP= |
289 |
FC= |
FC= |
290 |
LINK= |
LINK= |
291 |
|
DEFINES="-DWORDLENGTH=4" |
292 |
PACKAGES= |
PACKAGES= |
293 |
ENABLE= |
ENABLE= |
294 |
DISABLE= |
DISABLE= |
295 |
MAKEFILE= |
MAKEFILE= |
296 |
MAKEDEPEND= |
MAKEDEPEND= |
297 |
PDEPEND= |
PDEPEND= |
298 |
|
DUMPSTATE=t |
299 |
PDEFAULT= |
PDEFAULT= |
300 |
OPTFILE= |
OPTFILE= |
301 |
INCLUDES=-I. |
INCLUDES="-I." |
302 |
FFLAGS= |
FFLAGS= |
303 |
FOPTIM= |
FOPTIM= |
304 |
CFLAGS= |
CFLAGS= |
320 |
THISCWD=`pwd` |
THISCWD=`pwd` |
321 |
THISDATE=`date` |
THISDATE=`date` |
322 |
MACHINE=`uname -a` |
MACHINE=`uname -a` |
323 |
|
EXECUTABLE= |
324 |
|
EXEHOOK= |
325 |
|
EXEDIR= |
326 |
|
|
327 |
|
# The following state can be set directly by command-line switches |
328 |
|
gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT" |
329 |
|
gm_s2="FC IEEE MPI JAM DUMPSTATE" |
330 |
|
|
331 |
|
# The following state is not directly set by command-line switches |
332 |
|
gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM " |
333 |
|
gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS" |
334 |
|
gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE" |
335 |
|
gm_s6="EXECUTABLE EXEHOOK EXEDIR" |
336 |
|
|
337 |
|
gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6" |
338 |
|
|
339 |
echo $'\n'"=== Processing options files and arguments ===" |
|
340 |
|
echo |
341 |
|
echo "=== Processing options files and arguments ===" |
342 |
gm_local="./gm_local" |
gm_local="./gm_local" |
343 |
echo -n " getting local config information: " |
echo -n " getting local config information: " |
344 |
if test -e $gm_local ; then |
if test -e $gm_local ; then |
345 |
echo "using $gm_local" |
echo "using $gm_local" |
346 |
source $gm_local |
source $gm_local |
347 |
echo "DISABLE=$DISABLE"$'\n'"ENABLE=$ENABLE" |
# echo "DISABLE=$DISABLE" |
348 |
|
# echo "ENABLE=$ENABLE" |
349 |
else |
else |
350 |
echo "none found" |
echo "none found" |
351 |
fi |
fi |
352 |
|
|
353 |
# echo "$0::$1:$2:$3:$4:$5:$6:$7:" |
# echo "$0::$1:$2:$3:$4:$5:$6:$7:" |
354 |
OPTIONS=() |
#OPTIONS= |
355 |
n=0 |
#n=0 |
356 |
for i ; do |
#for i ; do |
357 |
setvar="OPTIONS[$n]='$i'" |
# echo "$i $n" |
358 |
# echo " $setvar" |
# setvar="OPTIONS[$n]='$i'" |
359 |
eval "$setvar" |
# # echo " $setvar" |
360 |
n=$(( $n + 1 )) |
# eval "$setvar" |
361 |
|
# n=$(( $n + 1 )) |
362 |
|
#done |
363 |
|
#parse_options |
364 |
|
|
365 |
|
ac_prev= |
366 |
|
for ac_option ; do |
367 |
|
|
368 |
|
# If the previous option needs an argument, assign it. |
369 |
|
if test -n "$ac_prev"; then |
370 |
|
eval "$ac_prev=\$ac_option" |
371 |
|
ac_prev= |
372 |
|
continue |
373 |
|
fi |
374 |
|
|
375 |
|
ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` |
376 |
|
|
377 |
|
case $ac_option in |
378 |
|
|
379 |
|
-help | --help | -h | --h) |
380 |
|
usage ;; |
381 |
|
|
382 |
|
-nooptfile | --nooptfile) |
383 |
|
OPTFILE="NONE" ;; |
384 |
|
-optfile | --optfile | -of | --of) |
385 |
|
ac_prev=OPTFILE ;; |
386 |
|
-optfile=* | --optfile=* | -of=* | --of=*) |
387 |
|
OPTFILE=$ac_optarg ;; |
388 |
|
|
389 |
|
-pdepend | --pdepend) |
390 |
|
ac_prev=PDEPEND ;; |
391 |
|
-pdepend=* | --pdepend=*) |
392 |
|
PDEPEND=$ac_optarg ;; |
393 |
|
|
394 |
|
-pdefault | --pdefault) |
395 |
|
ac_prev=PDEFAULT ;; |
396 |
|
-pdefault=* | --pdefault=*) |
397 |
|
PDEFAULT=$ac_optarg ;; |
398 |
|
|
399 |
|
-make | --make | -m | --m) |
400 |
|
ac_prev=MAKE ;; |
401 |
|
-make=* | --make=* | -m=* | --m=*) |
402 |
|
MAKE=$ac_optarg ;; |
403 |
|
|
404 |
|
-makefile | --makefile | -ma | --ma) |
405 |
|
ac_prev=MAKEFILE ;; |
406 |
|
-makefile=* | --makefile=* | -ma=* | --ma=*) |
407 |
|
MAKEFILE=$ac_optarg ;; |
408 |
|
|
409 |
|
-platform | --platform | -pl | --pl) |
410 |
|
ac_prev=PLATFORM ;; |
411 |
|
-platform=* | --platform=* | -pl=* | --pl=*) |
412 |
|
PLATFORM=$ac_optarg ;; |
413 |
|
|
414 |
|
-rootdir | --rootdir | -rd | --rd) |
415 |
|
ac_prev=ROOTDIR ;; |
416 |
|
-rootdir=* | --rootdir=* | -rd=* | --rd=*) |
417 |
|
ROOTDIR=$ac_optarg ;; |
418 |
|
|
419 |
|
-mods | --mods | -mo | --mo) |
420 |
|
ac_prev=MODS ;; |
421 |
|
-mods=* | --mods=* | -mo=* | --mo=*) |
422 |
|
MODS=$ac_optarg ;; |
423 |
|
|
424 |
|
-disable | --disable) |
425 |
|
ac_prev=DISABLE ;; |
426 |
|
-disable=* | --disable=*) |
427 |
|
DISABLE=$ac_optarg ;; |
428 |
|
|
429 |
|
-enable | --enable) |
430 |
|
ac_prev=ENABLE ;; |
431 |
|
-enable=* | --enable=*) |
432 |
|
ENABLE=$ac_optarg ;; |
433 |
|
|
434 |
|
-noopt | --noopt) |
435 |
|
ac_prev=NOOPT ;; |
436 |
|
-noopt=* | --noopt=*) |
437 |
|
NOOPT=$ac_optarg ;; |
438 |
|
|
439 |
|
# -cpp | --cpp) |
440 |
|
# ac_prev=cpp ;; |
441 |
|
# -cpp=* | --cpp=*) |
442 |
|
# CPP=$ac_optarg ;; |
443 |
|
|
444 |
|
-fortran | --fortran | -fc | --fc) |
445 |
|
ac_prev=FC ;; |
446 |
|
-fc=* | --fc=*) |
447 |
|
FC=$ac_optarg ;; |
448 |
|
|
449 |
|
-ieee | --ieee) |
450 |
|
IEEE=1 ;; |
451 |
|
-noieee | --noieee) |
452 |
|
IEEE=0 ;; |
453 |
|
|
454 |
|
-mpi | --mpi) |
455 |
|
MPI=1 ;; |
456 |
|
-nompi | --nompi) |
457 |
|
MPI=0 ;; |
458 |
|
|
459 |
|
-jam | --jam) |
460 |
|
JAM=1 ;; |
461 |
|
-nojam | --nojam) |
462 |
|
JAM=0 ;; |
463 |
|
|
464 |
|
-ds | --ds) |
465 |
|
DUMPSTATE=t ;; |
466 |
|
|
467 |
|
-*) |
468 |
|
echo "Error: unrecognized option: "$ac_option |
469 |
|
usage |
470 |
|
;; |
471 |
|
|
472 |
|
*) |
473 |
|
echo "Error: unrecognized argument: "$ac_option |
474 |
|
usage |
475 |
|
;; |
476 |
|
|
477 |
|
esac |
478 |
|
|
479 |
done |
done |
480 |
parse_options |
|
481 |
|
if test "x${ROOTDIR}" = x ; then |
482 |
|
if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then |
483 |
|
ROOTDIR=".." |
484 |
|
else |
485 |
|
for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do |
486 |
|
if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then |
487 |
|
ROOTDIR=$d |
488 |
|
echo -n "Warning: ROOTDIR was not specified but there appears to be" |
489 |
|
echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it." |
490 |
|
break |
491 |
|
fi |
492 |
|
done |
493 |
|
fi |
494 |
|
fi |
495 |
|
if test "x${ROOTDIR}" = x ; then |
496 |
|
echo "Error: Cannot determine ROOTDIR for MITgcm code." |
497 |
|
echo " Please specify a ROOTDIR using either an options " |
498 |
|
echo " file or a command-line option." |
499 |
|
exit 1 |
500 |
|
fi |
501 |
|
if test ! -d ${ROOTDIR} ; then |
502 |
|
echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!" |
503 |
|
exit 1 |
504 |
|
fi |
505 |
|
|
506 |
echo " getting OPTFILE information: " |
echo " getting OPTFILE information: " |
507 |
if test "x${OPTFILE}" = x ; then |
if test "x${OPTFILE}" = x ; then |
508 |
echo "Warning: no OPTFILE specified so we'll look for possible settings" |
if test "x$MITGCM_OF" = x ; then |
509 |
echo $'\n'"=== Searching for possible settings for OPTFILE ===" |
echo "Warning: no OPTFILE specified so we'll look for possible settings" |
510 |
find_possible_configs |
printf "\n=== Searching for possible settings for OPTFILE ===\n" |
511 |
else |
find_possible_configs |
|
if test "x$OPTFILE" = xNONE ; then |
|
|
echo " OPTFILE=NONE so we'll try to use default settings" |
|
512 |
else |
else |
513 |
if test -f "$OPTFILE" -a -r "$OPTFILE" ; then |
OPTFILE=$MITGCM_OF |
514 |
echo " using OPTFILE=\"$OPTFILE\"" |
fi |
515 |
source "$OPTFILE" |
fi |
516 |
RETVAL=$? |
if test "x$OPTFILE" != xNONE ; then |
517 |
if test "x$RETVAL" != x0 ; then |
if test -f "$OPTFILE" -a -r "$OPTFILE" ; then |
518 |
echo -n "Error: failed to source OPTFILE \"$OPTFILE\"" |
echo " using OPTFILE=\"$OPTFILE\"" |
519 |
echo "--please check that variable syntax is bash-compatible" |
source "$OPTFILE" |
520 |
exit 1 |
RETVAL=$? |
521 |
fi |
if test "x$RETVAL" != x0 ; then |
522 |
else |
echo -n "Error: failed to source OPTFILE \"$OPTFILE\"" |
523 |
echo "Error: can't read OPTFILE=\"$OPTFILE\"" |
echo "--please check that variable syntax is bash-compatible" |
524 |
exit 1 |
exit 1 |
525 |
fi |
fi |
526 |
|
if test "x$DUMPSTATE" != xf ; then |
527 |
|
cp -f $OPTFILE "gm_optfile" |
528 |
|
fi |
529 |
|
else |
530 |
|
echo "Error: can't read OPTFILE=\"$OPTFILE\"" |
531 |
|
exit 1 |
532 |
fi |
fi |
533 |
fi |
fi |
534 |
|
|
535 |
echo $'\n'"=== Setting defaults ===" |
# Check that FC, LINK, CPP, and S64 are defined. If not, complain |
536 |
|
# and abort! |
537 |
|
if test "x$FC" = x ; then |
538 |
|
cat <<EOF 1>&2 |
539 |
|
|
540 |
|
Error: no Fortran compiler: please specify using one of the following: |
541 |
|
1) within the options file ("FC=...") as specified by "-of=OPTFILE" |
542 |
|
2) the "-fc=XXX" command-line option |
543 |
|
3) the "./gm_local" file |
544 |
|
EOF |
545 |
|
exit 1 |
546 |
|
fi |
547 |
|
if test "x$LINK" = x ; then |
548 |
|
LINK=$FC |
549 |
|
fi |
550 |
|
if test "x$CPP" = x ; then |
551 |
|
CPP="cpp" |
552 |
|
fi |
553 |
|
echo "#define A a" | cpp > test_cpp 2>&1 |
554 |
|
RETVAL=$? |
555 |
|
if test "x$RETVAL" != x0 ; then |
556 |
|
cat <<EOF 1>&2 |
557 |
|
|
558 |
|
Error: C pre-processor "$CPP" failed the test case: please specify using: |
559 |
|
|
560 |
|
1) within the options file ("CPP=...") as specified by "-of=OPTFILE" |
561 |
|
2) the "./gm_local" file |
562 |
|
|
563 |
|
EOF |
564 |
|
exit 1 |
565 |
|
else |
566 |
|
rm -f test_cpp |
567 |
|
fi |
568 |
|
if test "x$MAKEDEPEND" = x ; then |
569 |
|
MAKEDEPEND=makedepend |
570 |
|
fi |
571 |
|
|
572 |
|
printf "\n=== Setting defaults ===\n" |
573 |
echo -n " Adding MODS directories: " |
echo -n " Adding MODS directories: " |
574 |
for d in $MODS ; do |
for d in $MODS ; do |
575 |
if test ! -d $d ; then |
if test ! -d $d ; then |
576 |
echo $'\n\n'"Error: MODS directory \"$d\" not found!" |
echo |
577 |
|
echo "Error: MODS directory \"$d\" not found!" |
578 |
exit 1 |
exit 1 |
579 |
else |
else |
580 |
echo -n " $d" |
echo -n " $d" |
591 |
PLATFORM=$p_PLATFORM |
PLATFORM=$p_PLATFORM |
592 |
fi |
fi |
593 |
|
|
|
if test "x${ROOTDIR}" = x ; then |
|
|
if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then |
|
|
ROOTDIR=".." |
|
|
else |
|
|
for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do |
|
|
if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then |
|
|
ROOTDIR=$d |
|
|
echo -n "Warning: ROOTDIR was not specified but there appears to be" |
|
|
echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it." |
|
|
break |
|
|
fi |
|
|
done |
|
|
fi |
|
|
fi |
|
|
if test "x${ROOTDIR}" = x ; then |
|
|
echo "Error: Cannot determine ROOTDIR for MITgcm code." |
|
|
echo " Please specify a ROOTDIR using either an options " |
|
|
echo " file or a command-line option." |
|
|
exit 1 |
|
|
fi |
|
|
if test ! -d ${ROOTDIR} ; then |
|
|
echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!" |
|
|
exit 1 |
|
|
fi |
|
|
|
|
594 |
if test "x${EXEDIR}" = x ; then |
if test "x${EXEDIR}" = x ; then |
595 |
if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then |
if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then |
596 |
EXEDIR=../exe |
EXEDIR=../exe |
610 |
echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!" |
echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!" |
611 |
exit 1 |
exit 1 |
612 |
fi |
fi |
613 |
|
if test "x$S64" = x ; then |
614 |
|
S64='$(TOOLSDIR)/set64bitConst.sh' |
615 |
|
fi |
616 |
|
|
617 |
EXECUTABLE=${EXECUTABLE:-mitgcmuv} |
EXECUTABLE=${EXECUTABLE:-mitgcmuv} |
618 |
|
|
623 |
echo " Making source files in eesupp from templates" |
echo " Making source files in eesupp from templates" |
624 |
$MAKE -C $ROOTDIR"/eesupp/src/" > make_eesupp.errors 2>&1 |
$MAKE -C $ROOTDIR"/eesupp/src/" > make_eesupp.errors 2>&1 |
625 |
RETVAL=$? |
RETVAL=$? |
626 |
if test "x${RETVAL}" == "x0" ; then |
if test "x${RETVAL}" = x0 ; then |
627 |
rm -f make_eesupp.errors |
rm -f make_eesupp.errors |
628 |
else |
else |
629 |
echo "Error: problem encountered while building source files in eesupp:" |
echo "Error: problem encountered while building source files in eesupp:" |
632 |
fi |
fi |
633 |
fi |
fi |
634 |
|
|
635 |
echo $'\n'"=== Determining package settings ===" |
printf "\n=== Determining package settings ===\n" |
636 |
if test "x${PDEPEND}" = x ; then |
if test "x${PDEPEND}" = x ; then |
637 |
tmp=$ROOTDIR"/pkg/pkg_depend" |
tmp=$ROOTDIR"/pkg/pkg_depend" |
638 |
if test -r $tmp ; then |
if test -r $tmp ; then |
651 |
# Strip the comments and then convert the dependency file into |
# Strip the comments and then convert the dependency file into |
652 |
# two arrays: PNAME, DNAME |
# two arrays: PNAME, DNAME |
653 |
cat $PDEPEND | sed -e 's/#.*$//g' \ |
cat $PDEPEND | sed -e 's/#.*$//g' \ |
654 |
| awk 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \ |
| awk 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \ |
655 |
> ./.pd_tmp |
> ./.pd_tmp |
656 |
RETVAL=$? |
RETVAL=$? |
657 |
if test ! "x${RETVAL}" = x0 ; then |
if test ! "x${RETVAL}" = x0 ; then |
661 |
source ./.pd_tmp |
source ./.pd_tmp |
662 |
rm -f ./.pd_tmp |
rm -f ./.pd_tmp |
663 |
|
|
664 |
|
# Search for default packages. Note that a "$ROOTDIR/pkg/pkg_groups" |
665 |
|
# file should eventually be added so that, for convenience, one can |
666 |
|
# specify groups of packages using names like "ocean" and "atmosphere". |
667 |
echo -n " checking default package list: " |
echo -n " checking default package list: " |
668 |
if test "x${PDEFAULT}" = x ; then |
if test "x${PDEFAULT}" = x ; then |
669 |
|
for i in "." $MODS ; do |
670 |
|
if test -r $i"/packages.conf" ; then |
671 |
|
PDEFAULT=$i"/packages.conf" |
672 |
|
break |
673 |
|
fi |
674 |
|
done |
675 |
|
fi |
676 |
|
if test "x${PDEFAULT}" = x ; then |
677 |
PDEFAULT="$ROOTDIR/pkg/pkg_default" |
PDEFAULT="$ROOTDIR/pkg/pkg_default" |
678 |
fi |
fi |
679 |
if test "x${PDEFAULT}" = xNONE ; then |
if test "x${PDEFAULT}" = xNONE ; then |
695 |
for i in $def ; do |
for i in $def ; do |
696 |
PACKAGES="$PACKAGES $i" |
PACKAGES="$PACKAGES $i" |
697 |
done |
done |
698 |
echo " packages are: $PACKAGES" |
echo " before group expansion packages are: $PACKAGES" |
699 |
|
expand_pkg_groups |
700 |
|
echo " after group expansion packages are: $PACKAGES" |
701 |
fi |
fi |
702 |
fi |
fi |
703 |
|
|
716 |
done |
done |
717 |
PACKAGES="$pack" |
PACKAGES="$pack" |
718 |
echo " applying ENABLE settings" |
echo " applying ENABLE settings" |
719 |
rm -f ./.tmp_pack |
echo "" > ./.tmp_pack |
720 |
PACKAGES="$PACKAGES $ENABLE" |
PACKAGES="$PACKAGES $ENABLE" |
721 |
for i in $PACKAGES ; do |
for i in $PACKAGES ; do |
722 |
if test ! -d "$ROOTDIR/pkg/$i" ; then |
if test ! -d "$ROOTDIR/pkg/$i" ; then |
737 |
ck= |
ck= |
738 |
while test "x$ck" != xtt ; do |
while test "x$ck" != xtt ; do |
739 |
i=0 |
i=0 |
740 |
rtot=${#PNAME[@]} |
# rtot=${#PNAME[@]} |
741 |
|
rtot=$nname |
742 |
while test $i -lt $rtot ; do |
while test $i -lt $rtot ; do |
743 |
|
|
744 |
# Is $pname in the current $PACKAGES list? |
# Is $pname in the current $PACKAGES list? |
745 |
pname=${PNAME[$i]} |
# pname=${PNAME[$i]} |
746 |
|
tmp="pname=\"\$PNAME_$i\"" |
747 |
|
eval $tmp |
748 |
pin="f" |
pin="f" |
749 |
for p in $PACKAGES ; do |
for p in $PACKAGES ; do |
750 |
if test "x$p" = "x$pname" ; then |
if test "x$p" = "x$pname" ; then |
753 |
done |
done |
754 |
|
|
755 |
# Is the DNAME entry a (+) or (-) rule ? |
# Is the DNAME entry a (+) or (-) rule ? |
756 |
|
tmp="dname=\"\$DNAME_$i\"" |
757 |
|
eval $tmp |
758 |
plus="-" |
plus="-" |
759 |
echo "${DNAME[$i]}" | grep '^+' > /dev/null 2>&1 |
echo $dname | grep '^+' > /dev/null 2>&1 |
760 |
RETVAL=$? |
RETVAL=$? |
761 |
if test "x$RETVAL" = x0 ; then |
if test "x$RETVAL" = x0 ; then |
762 |
plus="+" |
plus="+" |
763 |
fi |
fi |
764 |
|
|
765 |
# Is $dname in the current $PACKAGES list? |
# Is $dname in the current $PACKAGES list? |
766 |
dname=`echo ${DNAME[$i]} | sed -e 's/^[+-]//'` |
dname=`echo $dname | sed -e 's/^[+-]//'` |
767 |
din="f" |
din="f" |
768 |
for p in $PACKAGES ; do |
for p in $PACKAGES ; do |
769 |
if test "x$p" = "x$dname" ; then |
if test "x$p" = "x$dname" ; then |
832 |
# done |
# done |
833 |
# echo |
# echo |
834 |
|
|
835 |
echo " Setting package-specific CPP flags in CPP_OPTIONS.h:" |
# Create a list of #define and #undef to enable/disable packages |
836 |
CPP_OPTIONS= |
PACKAGES_DOT_H=PACKAGES_CONFIG.h |
837 |
spaths=". $SOURCEDIRS" |
cat <<EOF >$PACKAGES_DOT_H".tmp" |
|
for i in $spaths ; do |
|
|
try="$i/CPP_OPTIONS.h" |
|
|
# echo -n " trying $try : " |
|
|
if test -f $try -a -r $try ; then |
|
|
echo " found CPP_OPTIONS=\"$try\"" |
|
|
CPP_OPTIONS="$try" |
|
|
if test "x$i" != "x." ; then |
|
|
cp -f $CPP_OPTIONS . |
|
|
fi |
|
|
break |
|
|
fi |
|
|
done |
|
|
if test "x$CPP_OPTIONS" = x ; then |
|
|
echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths" |
|
|
exit 1 |
|
|
fi |
|
|
if test -e CPP_OPTIONS.h ; then |
|
|
if test ! -e CPP_OPTIONS.h.bak ; then |
|
|
cp -f CPP_OPTIONS.h CPP_OPTIONS.h.bak |
|
|
fi |
|
|
cat CPP_OPTIONS.h \ |
|
|
| awk 'BEGIN{p=1;} ($1=="C===" && $2=="GENMAKE"){p=0;} {if (p==1) print $0}' \ |
|
|
> CPP_OPTIONS.h.tmp |
|
|
fi |
|
|
cat <<EOF >>CPP_OPTIONS.h.tmp |
|
838 |
C=== GENMAKE v2 === |
C=== GENMAKE v2 === |
839 |
C The following defines have been set by GENMAKE, so please edit |
C The following defines have been set by GENMAKE, so please do not |
840 |
C them only if you know what you're doing. In general, you should |
C edit anything below these comments. In general, you should |
841 |
C add or remove packages by re-running genmake with different |
C add or remove packages by re-running genmake with different |
842 |
C "-enable" and/or "-disable" options. |
C "-enable" and/or "-disable" options. |
843 |
|
|
844 |
|
#ifndef PACKAGES_H |
845 |
|
#define PACKAGES_H |
846 |
|
|
847 |
C Packages disabled by genmake: |
C Packages disabled by genmake: |
848 |
EOF |
EOF |
849 |
# The following UGLY HACK sets multiple "#undef"s and it needs to go |
# The following UGLY HACK sets multiple "#undef"s and it needs to go |
863 |
done |
done |
864 |
if test "x$has_pack" = xf ; then |
if test "x$has_pack" = xf ; then |
865 |
undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'` |
undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'` |
866 |
echo "#undef $undef" >> CPP_OPTIONS.h.tmp |
echo "#undef $undef" >> $PACKAGES_DOT_H".tmp" |
867 |
|
# DEFINES="$DEFINES -U$undef" |
868 |
|
|
869 |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
870 |
case $n in |
case $n in |
874 |
mom_vecinv) |
mom_vecinv) |
875 |
DEFINES="$DEFINES -DDISABLE_MOM_VECINV" |
DEFINES="$DEFINES -DDISABLE_MOM_VECINV" |
876 |
;; |
;; |
|
generic_advdiff) |
|
|
DEFINES="$DEFINES -DDISABLE_GENERIC_ADVDIFF" |
|
|
;; |
|
877 |
debug) |
debug) |
878 |
DEFINES="$DEFINES -DDISABLE_DEBUGMODE" |
DEFINES="$DEFINES -DDISABLE_DEBUGMODE" |
879 |
;; |
;; |
883 |
fi |
fi |
884 |
fi |
fi |
885 |
done |
done |
886 |
cat <<EOF >>CPP_OPTIONS.h.tmp |
cat <<EOF >>$PACKAGES_DOT_H".tmp" |
887 |
|
|
888 |
C Packages enabled by genmake: |
C Packages enabled by genmake: |
889 |
EOF |
EOF |
890 |
for i in $PACKAGES ; do |
for i in $PACKAGES ; do |
891 |
def=`echo "ALLOW_$i" | awk '{print toupper($0)}'` |
def=`echo "ALLOW_$i" | awk '{print toupper($0)}'` |
892 |
echo "#define $def" >> CPP_OPTIONS.h.tmp |
echo "#define $def" >> $PACKAGES_DOT_H".tmp" |
893 |
|
#eh3 DEFINES="$DEFINES -D$def" |
894 |
|
|
895 |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
896 |
case $i in |
case $i in |
897 |
aim_v23) |
aim_v23) |
898 |
echo "#define ALLOW_AIM" >> CPP_OPTIONS.h.tmp |
echo "#define ALLOW_AIM" >> $PACKAGES_DOT_H".tmp" |
899 |
|
DEFINES="$DEFINES -DALLOW_AIM" |
900 |
|
echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)" |
901 |
;; |
;; |
902 |
esac |
esac |
903 |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
904 |
|
|
905 |
done |
done |
906 |
mv -f CPP_OPTIONS.h.tmp CPP_OPTIONS.h |
cat <<EOF >>$PACKAGES_DOT_H".tmp" |
907 |
|
|
908 |
|
#endif /* PACKAGES_H */ |
909 |
|
EOF |
910 |
|
|
911 |
|
if test ! -f $PACKAGES_DOT_H ; then |
912 |
|
mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
913 |
|
else |
914 |
|
cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
915 |
|
RETVAL=$? |
916 |
|
if test "x$RETVAL" = x0 ; then |
917 |
|
rm -f $PACKAGES_DOT_H".tmp" |
918 |
|
else |
919 |
|
mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak" |
920 |
|
mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
921 |
|
fi |
922 |
|
fi |
923 |
|
|
924 |
echo " Adding STANDARDDIRS" |
echo " Adding STANDARDDIRS" |
925 |
BUILDDIR=${BUILDDIR:-.} |
BUILDDIR=${BUILDDIR:-.} |
943 |
fi |
fi |
944 |
done |
done |
945 |
|
|
946 |
|
echo " Searching for CPP_OPTIONS.h in order to warn about the presence" |
947 |
|
echo " of \"#define ALLOW_PKGNAME\"-type statements:" |
948 |
|
CPP_OPTIONS= |
949 |
|
spaths=". $INCLUDEDIRS" |
950 |
|
for i in $spaths ; do |
951 |
|
try="$i/CPP_OPTIONS.h" |
952 |
|
# echo -n " trying $try : " |
953 |
|
if test -f $try -a -r $try ; then |
954 |
|
echo " found CPP_OPTIONS=\"$try\"" |
955 |
|
CPP_OPTIONS="$try" |
956 |
|
break |
957 |
|
fi |
958 |
|
done |
959 |
|
if test "x$CPP_OPTIONS" = x ; then |
960 |
|
echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths" |
961 |
|
exit 1 |
962 |
|
fi |
963 |
|
# New safety test: make sure packages are not mentioned in CPP_OPTIONS.h |
964 |
|
names=`ls -1 "$ROOTDIR/pkg"` |
965 |
|
for n in $names ; do |
966 |
|
test_for_package_in_cpp_options $CPP_OPTIONS $n |
967 |
|
done |
968 |
|
|
969 |
|
|
970 |
echo $'\n'"=== Creating the Makefile ===" |
echo |
971 |
|
echo "=== Creating the Makefile ===" |
972 |
echo " setting INCLUDES" |
echo " setting INCLUDES" |
973 |
for i in $INCLUDEDIRS ; do |
for i in $INCLUDEDIRS ; do |
974 |
if test -d $i ; then |
if ! test -d $i ; then |
975 |
INCLUDES="$INCLUDES -I$i" |
# INCLUDES="$INCLUDES -I$i" |
976 |
else |
# else |
977 |
echo "Warning: can't find INCLUDEDIRS=\"$i\"" |
echo "Warning: can't find INCLUDEDIRS=\"$i\"" |
978 |
fi |
fi |
979 |
done |
done |
983 |
mkdir .links.tmp |
mkdir .links.tmp |
984 |
echo "# This section creates symbolic links" > srclinks.tmp |
echo "# This section creates symbolic links" > srclinks.tmp |
985 |
echo "" >> srclinks.tmp |
echo "" >> srclinks.tmp |
986 |
echo -n 'SRCFILES = ' > srclist.inc |
echo -n 'SRCFILES = ' > srclist.inc |
987 |
echo -n 'CSRCFILES = ' > csrclist.inc |
echo -n 'CSRCFILES = ' > csrclist.inc |
988 |
|
echo -n 'F90SRCFILES = ' > f90srclist.inc |
989 |
echo -n 'HEADERFILES = ' > hlist.inc |
echo -n 'HEADERFILES = ' > hlist.inc |
990 |
alldirs=". $SOURCEDIRS $INCLUDEDIRS" |
alldirs="$SOURCEDIRS $INCLUDEDIRS ." |
991 |
for d in $alldirs ; do |
for d in $alldirs ; do |
992 |
deplist= |
deplist= |
993 |
sfiles=`( cd $d; echo *.[h,c,F] )` |
sfiles=`( cd $d; echo *.[h,c,F] )` |
994 |
|
sfiles=`( echo $sfiles; cd $d; echo *.F90 )` |
995 |
for sf in $sfiles ; do |
for sf in $sfiles ; do |
996 |
if test ! -r ".links.tmp/$sf" ; then |
if test ! -r ".links.tmp/$sf" ; then |
997 |
if test -f "$d/$sf" ; then |
if test -f "$d/$sf" ; then |
1003 |
echo " \\" >> srclist.inc |
echo " \\" >> srclist.inc |
1004 |
echo -n " $sf" >> srclist.inc |
echo -n " $sf" >> srclist.inc |
1005 |
;; |
;; |
1006 |
|
F90) |
1007 |
|
echo " \\" >> f90srclist.inc |
1008 |
|
echo -n " $sf" >> f90srclist.inc |
1009 |
|
;; |
1010 |
c) |
c) |
1011 |
echo " \\" >> csrclist.inc |
echo " \\" >> csrclist.inc |
1012 |
echo -n " $sf" >> csrclist.inc |
echo -n " $sf" >> csrclist.inc |
1020 |
fi |
fi |
1021 |
done |
done |
1022 |
if test "x$deplist" != x ; then |
if test "x$deplist" != x ; then |
1023 |
echo $'\n'"# These files are linked from $d" >> srclinks.tmp |
echo "" >> srclinks.tmp |
1024 |
|
echo "# These files are linked from $d" >> srclinks.tmp |
1025 |
echo "$deplist :" >> srclinks.tmp |
echo "$deplist :" >> srclinks.tmp |
1026 |
echo $'\t$(LN) '$d'/$@ $@' >> srclinks.tmp |
printf "\t\$(LN) %s/\$@ \$@\n" $d >> srclinks.tmp |
1027 |
fi |
fi |
1028 |
done |
done |
1029 |
rm -rf .links.tmp |
rm -rf .links.tmp |
1030 |
echo "" >> srclist.inc |
echo "" >> srclist.inc |
1031 |
echo "" >> csrclist.inc |
echo "" >> csrclist.inc |
1032 |
|
echo "" >> f90srclist.inc |
1033 |
echo "" >> hlist.inc |
echo "" >> hlist.inc |
1034 |
|
|
1035 |
if test -e $MAKEFILE ; then |
if test -e $MAKEFILE ; then |
1087 |
KPP = ${KPP} |
KPP = ${KPP} |
1088 |
# Fortran compiler |
# Fortran compiler |
1089 |
FC = ${FC} |
FC = ${FC} |
1090 |
|
# Fortran compiler |
1091 |
|
F90C = ${F90C} |
1092 |
# Link editor |
# Link editor |
1093 |
LINK = ${LINK} |
LINK = ${LINK} |
1094 |
|
|
1102 |
# Optim./debug for FC |
# Optim./debug for FC |
1103 |
FFLAGS = ${FFLAGS} |
FFLAGS = ${FFLAGS} |
1104 |
FOPTIM = ${FOPTIM} |
FOPTIM = ${FOPTIM} |
1105 |
|
# Optim./debug for FC |
1106 |
|
F90FLAGS = ${F90FLAGS} |
1107 |
|
F90OPTIM = ${F90OPTIM} |
1108 |
# Flags for CC |
# Flags for CC |
1109 |
CFLAGS = ${CFLAGS} |
CFLAGS = ${CFLAGS} |
1110 |
# Files that should not be optimized |
# Files that should not be optimized |
1112 |
NOOPTFLAGS = ${NOOPTFLAGS} |
NOOPTFLAGS = ${NOOPTFLAGS} |
1113 |
# Flags and libraries needed for linking |
# Flags and libraries needed for linking |
1114 |
LIBS = ${LIBS} \$(XLIBS) |
LIBS = ${LIBS} \$(XLIBS) |
1115 |
|
# Name of the Mekfile |
1116 |
|
MAKEFILE=${MAKEFILE} |
1117 |
|
|
1118 |
EOF |
EOF |
1119 |
|
|
1120 |
cat srclist.inc >> $MAKEFILE |
cat srclist.inc >> $MAKEFILE |
1121 |
cat csrclist.inc >> $MAKEFILE |
cat csrclist.inc >> $MAKEFILE |
1122 |
cat hlist.inc >> $MAKEFILE |
cat f90srclist.inc >> $MAKEFILE |
1123 |
echo 'F77FILES = $(SRCFILES:.F=.f)' >> $MAKEFILE |
cat hlist.inc >> $MAKEFILE |
1124 |
echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o)' >> $MAKEFILE |
echo 'F77FILES = $(SRCFILES:.F=.f)' >> $MAKEFILE |
1125 |
|
echo 'F90FILES = $(F90SRCFILES:.F90=.f90)' >> $MAKEFILE |
1126 |
|
echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE |
1127 |
|
|
1128 |
rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp |
rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc |
1129 |
|
|
1130 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
1131 |
|
|
1132 |
.SUFFIXES: |
.SUFFIXES: |
1133 |
.SUFFIXES: .o .f .p .F .c |
.SUFFIXES: .o .f .p .F .c .F90 .f90 |
1134 |
|
|
1135 |
all: \$(EXECUTABLE) |
all: \$(EXECUTABLE) |
1136 |
\$(EXECUTABLE): \$(OBJFILES) |
\$(EXECUTABLE): \$(OBJFILES) |
1138 |
depend: |
depend: |
1139 |
@make links |
@make links |
1140 |
\$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES) |
\$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES) |
1141 |
|
${TOOLSDIR}/f90mkdepend >> \$(MAKEFILE) |
1142 |
|
|
1143 |
links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) |
links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) |
1144 |
|
|
1145 |
small_f: \$(F77FILES) |
small_f: \$(F77FILES) \$(F90FILES) |
1146 |
|
|
1147 |
output.txt: \$(EXECUTABLE) |
output.txt: \$(EXECUTABLE) |
1148 |
@printf 'running ... ' |
@printf 'running ... ' |
1149 |
@\$(EXECUTABLE) > \$@ |
@\$(EXECUTABLE) > \$@ |
1150 |
|
|
1151 |
clean: |
clean: |
1152 |
-rm -rf *.o *.f *.p ${RMFILES} work.{pc,pcl} |
-rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} |
1153 |
Clean: |
Clean: |
1154 |
@make clean |
@make clean |
1155 |
@make cleanlinks |
@make cleanlinks |
1156 |
-rm -f Makefile.bak |
-rm -f Makefile.bak gm_state gm_optfile make.log |
1157 |
CLEAN: |
CLEAN: |
1158 |
@make Clean |
@make Clean |
1159 |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
1160 |
-find \$(EXEDIR) -name "*.data" -exec rm {} \; |
-find \$(EXEDIR) -name "*.data" -exec rm {} \; |
1161 |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
1162 |
-rm -f \$(EXECUTABLE) |
-rm -f \$(EXECUTABLE) output.txt |
1163 |
|
|
1164 |
makefile: |
makefile: |
1165 |
${0} $@ |
${0} $@ |
1171 |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
1172 |
.f.o: |
.f.o: |
1173 |
\$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< |
\$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< |
1174 |
|
.F90.f90: |
1175 |
|
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
1176 |
|
.f90.o: |
1177 |
|
\$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$< |
1178 |
.c.o: |
.c.o: |
1179 |
\$(CC) \$(CFLAGS) -c \$< |
\$(CC) \$(CFLAGS) -c \$< |
1180 |
|
|
1186 |
|
|
1187 |
EOF |
EOF |
1188 |
|
|
1189 |
|
if test "x$EXEHOOK" != x ; then |
1190 |
|
printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE |
1191 |
|
fi |
1192 |
|
|
1193 |
echo " Making list of \"exceptions\" that need \".p\" files" |
echo " Making list of \"exceptions\" that need \".p\" files" |
1194 |
for i in $KPPFILES ; do |
for i in $KPPFILES ; do |
1195 |
base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'` |
base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'` |
1208 |
echo "Error: unable to add file \"$i\" to the exceptions list" |
echo "Error: unable to add file \"$i\" to the exceptions list" |
1209 |
fi |
fi |
1210 |
echo "$base.o: $base.f" >> $MAKEFILE |
echo "$base.o: $base.f" >> $MAKEFILE |
1211 |
echo $'\t$(FC) $(FFLAGS) $(NOOPTFLAGS) -c $<' >> $MAKEFILE |
printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE |
1212 |
done |
done |
1213 |
|
|
1214 |
echo " Add rules for links" |
echo " Add rules for links" |
1216 |
rm -f srclinks.tmp |
rm -f srclinks.tmp |
1217 |
|
|
1218 |
echo " Adding makedepend marker" |
echo " Adding makedepend marker" |
1219 |
echo $'\n\n'"# DO NOT DELETE" >> $MAKEFILE |
printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE |
1220 |
|
|
1221 |
echo $'\n'"=== Done ===" |
printf "\n=== Done ===\n" |
1222 |
|
|
1223 |
|
|
1224 |
|
# Write the "state" for future records |
1225 |
|
if test "x$DUMPSTATE" != xf ; then |
1226 |
|
echo -n "" > gm_state |
1227 |
|
for i in $gm_state ; do |
1228 |
|
t1="t2=\$$i" |
1229 |
|
eval $t1 |
1230 |
|
echo "$i='$t2'" >> gm_state |
1231 |
|
done |
1232 |
|
fi |