I am trying to write a bash script that automates the installation (I know, I know, I have to use it make), and it should have been general: support for different compilers and build flags.
For example, I have the following lines:
$FORTRAN_COMPILER $LINKERFLAGS lagrit_main.o lagrit_main.f
$FORTRAN_COMPILER $LINKERFLAGS lagrit_fdate.o lagrit_fdate.f
make $MAKEFLAG lib
$FORTRAN_COMPILER $BUILDFLAGS $LAGRIT_NAME $BUILDLIBS $BUILDSUFFIX
with variables set as
FORTRAN_COMPILER=gfortran
LINKERFLAGS="-O -fcray-pointer -fdefault-integer-8 -m64 -Dlinx64 -c -o"
BUILDFLAGS="-O -Dlinx64 -fcray-pointer -fdefault-integer-8 -fno-sign-zero -o"
BUILDLIBS="lagrit_main.o lagrit_fdate.o lagrit_ulin64_o_gcc.a $LAGRIT_UTIL_DIR/util_ulin64_o_gcc.a"
BUILDSUFFIX="-L$ACCESS -lexodus -lexoIIv2for -lnetcdf -lm -lstdc++"
MAKEFLAG="MOPT=64"
What returns these errors:
gfortran: error: lagrit_main.o: No such file or directory
gfortran: error: lagrit_fdate.o: No such file or directory
gfortran: error: lagrit: No such file or directory
gfortran: error: lagrit_main.o lagrit_fdate.o lagrit_ulin64_o_gcc.a /scratch/sft/livingston/build/shared/LaGriT/lg_util/src/util_ulin64_o_gcc.a: No such file or directory
But, when I run the same commands in long-form (i.e. gfortran -O -fcray-pointer -fdefault-integer-8 -m64 -Dlinx64 -c -o lagrit_main.o lagrit_main.f), it builds without problems.
What am I missing here? I tried various permutations of variable strings, including:
gfortran $LINKERFLAGS lagrit_main.o lagrit_main.f
"$FORTRAN_COMPILER" "$LINKER_FLAGS" lagrit_main.o lagrit_main.f
${FORTRAN_COMPILER} ${LINKER_FLAGS} lagrit_main.o lagrit_main.f
which all lead to the same error.
EDIT : for clarification, this is on Ubuntu 16.04
source
share