1 |
#!/bin/sh |
#! /usr/bin/env bash |
2 |
# |
# |
3 |
# $Header$ |
# $Header$ |
4 |
# |
# |
13 |
test_for_package_in_cpp_options() { |
test_for_package_in_cpp_options() { |
14 |
cpp_options=$1 |
cpp_options=$1 |
15 |
pkg=$2 |
pkg=$2 |
16 |
grep -i "#define.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1 |
test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg" || exit 99 |
17 |
RETVAL=$? |
test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg" || exit 99 |
18 |
if test "x${RETVAL}" = x0 ; then |
test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg" || exit 99 |
19 |
echo "Error: In $cpp_options there is an illegal line: #define ALLOW_$pkg" |
test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg" || exit 99 |
20 |
exit 99 |
} |
21 |
fi |
|
22 |
grep -i "#undef.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1 |
# Search for particular CPP #cmds associated with MPI |
23 |
RETVAL=$? |
# usage: test_for_mpi_in_cpp_eeoptions CPP_file |
24 |
if test "x${RETVAL}" = x0 ; then |
test_for_mpi_in_cpp_eeoptions() { |
25 |
echo "Error: In $cpp_options there is an illegal line: #undef ALLOW_$pkg" |
cpp_options=$1 |
26 |
exit 99 |
test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI" || exit 99 |
27 |
fi |
test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI" || exit 99 |
28 |
grep -i "#define.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1 |
test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI" || exit 99 |
29 |
|
test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI" || exit 99 |
30 |
|
} |
31 |
|
|
32 |
|
# Search for particular string in a file. Return 1 if detected, 0 if not |
33 |
|
# usage: test_for_string_in_file file string |
34 |
|
test_for_string_in_file() { |
35 |
|
file=$1 |
36 |
|
strng=$2 |
37 |
|
grep -i "$strng" $file > /dev/null 2>&1 |
38 |
RETVAL=$? |
RETVAL=$? |
39 |
if test "x${RETVAL}" = x0 ; then |
if test "x${RETVAL}" = x0 ; then |
40 |
echo "Error: In $cpp_options there is an illegal line: #define DISABLE_$pkg" |
echo -n "Error: In $file there is an illegal line: " |
41 |
exit 99 |
grep -i "$strng" $file |
42 |
|
return 1 |
43 |
fi |
fi |
44 |
grep -i "#undef.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1 |
return 0 |
|
RETVAL=$? |
|
|
if test "x${RETVAL}" = x0 ; then |
|
|
echo "Error: In $cpp_options there is an illegal line: #undef DISABLE_$pkg" |
|
|
exit 99 |
|
|
fi |
|
45 |
} |
} |
46 |
|
|
47 |
# Read the $ROOTDIR/pkg/pkg_groups file and expand any references to |
# Read the $ROOTDIR/pkg/pkg_groups file and expand any references to |
78 |
tmp1=`uname`"_"`uname -m` |
tmp1=`uname`"_"`uname -m` |
79 |
tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` |
tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` |
80 |
tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'` |
tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'` |
81 |
PLATFORM=`echo $tmp3 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'` |
tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'` |
82 |
|
tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'` |
83 |
|
PLATFORM=$tmp2 |
84 |
OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")` |
OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")` |
85 |
echo " The platform appears to be: $PLATFORM" |
echo " The platform appears to be: $PLATFORM" |
86 |
|
|
593 |
-optfile=* | --optfile=* | -of=* | --of=*) |
-optfile=* | --optfile=* | -of=* | --of=*) |
594 |
OPTFILE=$ac_optarg ;; |
OPTFILE=$ac_optarg ;; |
595 |
|
|
596 |
-adoptfile | --adoptfile | -ad | --ad) |
-adoptfile | --adoptfile | -adof | --adof) |
597 |
ac_prev=AD_OPTFILE ;; |
ac_prev=AD_OPTFILE ;; |
598 |
-adoptfile=* | --adoptfile=* | -adof=* | --adof=*) |
-adoptfile=* | --adoptfile=* | -adof=* | --adof=*) |
599 |
AD_OPTFILE=$ac_optarg ;; |
AD_OPTFILE=$ac_optarg ;; |
895 |
else |
else |
896 |
echo "no" |
echo "no" |
897 |
fi |
fi |
|
echo "$FC_NAMEMANGLE" > FC_NAMEMANGLE.h.template |
|
|
cmp FC_NAMEMANGLE.h FC_NAMEMANGLE.h.template > /dev/null 2>&1 |
|
|
RETVAL=$? |
|
|
if test "x$RETVAL" != x0 ; then |
|
|
mv -f FC_NAMEMANGLE.h.template FC_NAMEMANGLE.h |
|
|
fi |
|
898 |
rm -f genmake_t* |
rm -f genmake_t* |
899 |
|
|
900 |
|
|
1179 |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
1180 |
case $i in |
case $i in |
1181 |
aim_v23) |
aim_v23) |
|
DEFINES="$DEFINES -DALLOW_AIM" |
|
1182 |
ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM" |
ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM" |
1183 |
echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)" |
echo "Warning: ALLOW_AIM is set to enable aim_v23." |
1184 |
;; |
;; |
1185 |
esac |
esac |
1186 |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
1211 |
fi |
fi |
1212 |
done |
done |
1213 |
|
|
1214 |
echo " Searching for CPP_OPTIONS.h in order to warn about the presence" |
echo " Searching for *OPTIONS.h files in order to warn about the presence" |
1215 |
echo " of \"#define ALLOW_PKGNAME\"-type statements:" |
echo " of \"#define \"-type statements that are no longer allowed:" |
1216 |
CPP_OPTIONS= |
CPP_OPTIONS= |
1217 |
|
CPP_EEOPTIONS= |
1218 |
spaths=". $INCLUDEDIRS" |
spaths=". $INCLUDEDIRS" |
1219 |
|
names=`ls -1 "$ROOTDIR/pkg"` |
1220 |
for i in $spaths ; do |
for i in $spaths ; do |
1221 |
try="$i/CPP_OPTIONS.h" |
try="$i/CPP_OPTIONS.h" |
1222 |
# echo -n " trying $try : " |
if test -f $try -a -r $try -a "x$CPP_OPTIONS" = x ; then |
|
if test -f $try -a -r $try ; then |
|
1223 |
echo " found CPP_OPTIONS=\"$try\"" |
echo " found CPP_OPTIONS=\"$try\"" |
1224 |
CPP_OPTIONS="$try" |
CPP_OPTIONS="$try" |
1225 |
break |
# New safety test: make sure packages are not mentioned in CPP_OPTIONS.h |
1226 |
|
for n in $names ; do |
1227 |
|
test_for_package_in_cpp_options $CPP_OPTIONS $n |
1228 |
|
done |
1229 |
|
fi |
1230 |
|
try="$i/CPP_EEOPTIONS.h" |
1231 |
|
if test -f $try -a -r $try -a "x$CPP_EEOPTIONS" = x ; then |
1232 |
|
echo " found CPP_EEOPTIONS=\"$try\"" |
1233 |
|
# New safety test: make sure MPI is not determined by CPP_EEOPTIONS.h |
1234 |
|
#**** not yet enabled **** |
1235 |
|
# test_for_mpi_in_cpp_eeoptions $try |
1236 |
|
#**** not yet enabled **** |
1237 |
|
CPP_EEOPTIONS="$try" |
1238 |
fi |
fi |
1239 |
done |
done |
1240 |
if test "x$CPP_OPTIONS" = x ; then |
if test "x$CPP_OPTIONS" = x ; then |
1241 |
echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths" |
echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths" |
1242 |
exit 1 |
exit 1 |
1243 |
fi |
fi |
|
# New safety test: make sure packages are not mentioned in CPP_OPTIONS.h |
|
|
names=`ls -1 "$ROOTDIR/pkg"` |
|
|
for n in $names ; do |
|
|
test_for_package_in_cpp_options $CPP_OPTIONS $n |
|
|
done |
|
|
|
|
1244 |
|
|
1245 |
# Here, we build the list of files to be "run through" the adjoint |
# Here, we build the list of files to be "run through" the adjoint |
1246 |
# compiler. |
# compiler. |
1354 |
EXE_SVD=$EXECUTABLE"_svd" |
EXE_SVD=$EXECUTABLE"_svd" |
1355 |
|
|
1356 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
1357 |
|
# |
1358 |
|
# OPTFILE="$OPTFILE" |
1359 |
# |
# |
1360 |
# BUILDDIR : Directory where object files are written |
# BUILDDIR : Directory where object files are written |
1361 |
# SOURCEDIRS : Directories containing the source (.F) files |
# SOURCEDIRS : Directories containing the source (.F) files |
1392 |
ENABLED_PACKAGES = ${ENABLED_PACKAGES} |
ENABLED_PACKAGES = ${ENABLED_PACKAGES} |
1393 |
DISABLED_PACKAGES = ${DISABLED_PACKAGES} |
DISABLED_PACKAGES = ${DISABLED_PACKAGES} |
1394 |
|
|
1395 |
|
# These files are created by Makefile |
1396 |
|
SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h |
1397 |
|
|
1398 |
EOF |
EOF |
1399 |
|
|
1400 |
# Note: figure out some way to add Hyades JAM libraries here |
# Note: figure out some way to add Hyades JAM libraries here |
1459 |
.SUFFIXES: .o .f .p .F .c .F90 .f90 |
.SUFFIXES: .o .f .p .F .c .F90 .f90 |
1460 |
|
|
1461 |
all: \$(EXECUTABLE) |
all: \$(EXECUTABLE) |
1462 |
\$(EXECUTABLE): links \$(OBJFILES) |
\$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES) |
1463 |
@echo Creating \$@ ... |
@echo Creating \$@ ... |
1464 |
\$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS) |
\$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS) |
1465 |
depend: |
depend: |
1467 |
\$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES) |
\$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES) |
1468 |
\$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE) |
\$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE) |
1469 |
|
|
1470 |
links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) ${PACKAGES_DOT_H} AD_CONFIG.h |
links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES) |
1471 |
|
|
1472 |
small_f: \$(F77FILES) \$(F90FILES) |
small_f: \$(F77FILES) \$(F90FILES) |
1473 |
|
|
1480 |
Clean: |
Clean: |
1481 |
@make clean |
@make clean |
1482 |
@make cleanlinks |
@make cleanlinks |
1483 |
-rm -f ${PACKAGES_DOT_H} AD_CONFIG.h |
-rm -f \$(SPECIAL_FILES) |
1484 |
-rm -f Makefile.bak genmake_state genmake_*optfile genmake_warnings make.log |
-rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log *.bak |
1485 |
CLEAN: |
CLEAN: |
1486 |
@make Clean |
@make Clean |
1487 |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
1495 |
cleanlinks: |
cleanlinks: |
1496 |
-find . -type l -exec rm {} \; |
-find . -type l -exec rm {} \; |
1497 |
|
|
1498 |
# Special targets |
# Special targets ($SPECIAL_FILES) which are create by make |
1499 |
${PACKAGES_DOT_H}: |
${PACKAGES_DOT_H}: |
1500 |
@echo Creating \$@ ... |
@echo Creating \$@ ... |
1501 |
@\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@ |
@\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@ |
1502 |
AD_CONFIG.h: |
AD_CONFIG.h: |
1503 |
@echo Creating \$@ ... |
@echo Creating \$@ ... |
1504 |
@\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > \$@ |
@\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > \$@ |
1505 |
|
FC_NAMEMANGLE.h: |
1506 |
|
@echo Creating \$@ ... |
1507 |
|
echo "$FC_NAMEMANGLE" > \$@ |
1508 |
|
|
1509 |
# The normal chain of rules is ( .F - .f - .o ) |
# The normal chain of rules is ( .F - .f - .o ) |
1510 |
.F.f: |
.F.f: |