2014-11-07 06:48:28 +08:00
|
|
|
#!/bin/bash
|
|
|
|
# Script to automatically build, install netcdf-fortran.
|
|
|
|
# Very rought draft.
|
|
|
|
|
2014-11-08 02:22:04 +08:00
|
|
|
DOCMAKE=""
|
2014-11-20 05:29:32 +08:00
|
|
|
DOAUTOTOOL=""
|
|
|
|
DOACTION=""
|
2018-09-15 05:56:28 +08:00
|
|
|
TARGVERSION="v4.4.4"
|
2014-11-20 05:29:32 +08:00
|
|
|
|
2014-11-08 02:22:04 +08:00
|
|
|
MARG=""
|
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
echo ""
|
|
|
|
echo "WARNING! THIS SCRIPT IS NOT MEANT TO BE RUN MANUALLY."
|
|
|
|
echo "WARNING! THIS SCRIPT IS NOT MEANT TO BE RUN MANUALLY."
|
|
|
|
echo ""
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-11-20 07:57:51 +08:00
|
|
|
|
|
|
|
##
|
|
|
|
# Check for 'git', exit if it's not found.
|
|
|
|
##
|
2020-08-07 03:27:20 +08:00
|
|
|
hash git 2>/dev/null
|
2014-11-20 07:57:51 +08:00
|
|
|
if [ $? -eq 1 ]; then
|
|
|
|
echo "ERROR: 'git' is required to install netcdf-fortran automatically"
|
|
|
|
echo "through this method. Please reinstall git and try again."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-11-20 05:29:32 +08:00
|
|
|
while getopts "a:t:" o; do
|
2014-11-08 02:22:04 +08:00
|
|
|
case "${o}" in
|
|
|
|
t)
|
|
|
|
MARG=${OPTARG}
|
|
|
|
;;
|
2014-11-20 05:29:32 +08:00
|
|
|
a)
|
|
|
|
DOACTION=${OPTARG}
|
|
|
|
;;
|
2014-11-08 02:22:04 +08:00
|
|
|
*)
|
|
|
|
echo "Specify type with -t. Types are autotools or cmake."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2014-11-20 05:29:32 +08:00
|
|
|
|
|
|
|
###
|
|
|
|
# Make sure we're specifying an allowed
|
|
|
|
# build system.
|
|
|
|
###
|
2014-11-08 02:22:04 +08:00
|
|
|
case ${MARG} in
|
|
|
|
cmake)
|
|
|
|
DOCMAKE="TRUE"
|
|
|
|
;;
|
|
|
|
autotools)
|
2014-11-20 05:29:32 +08:00
|
|
|
DOAUTOTOOL="TRUE"
|
2014-11-08 02:22:04 +08:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Illegal type. Types are autotools or cmake."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2014-11-20 05:29:32 +08:00
|
|
|
###
|
|
|
|
# Make sure we're performing a valid action.
|
|
|
|
###
|
|
|
|
case ${DOACTION} in
|
|
|
|
build)
|
|
|
|
;;
|
|
|
|
install)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Illegal action."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2014-11-08 02:22:04 +08:00
|
|
|
|
2014-11-07 06:48:28 +08:00
|
|
|
|
|
|
|
###
|
2014-11-08 02:22:04 +08:00
|
|
|
# Fetch netcdf-fortran from git if need be.
|
2014-11-07 06:48:28 +08:00
|
|
|
###
|
2014-11-08 02:22:04 +08:00
|
|
|
|
|
|
|
if [ ! -d "netcdf-fortran" ]; then
|
|
|
|
git clone http://github.com/unidata/netcdf-fortran
|
2015-02-03 06:30:40 +08:00
|
|
|
|
2014-11-08 02:22:04 +08:00
|
|
|
fi
|
2014-11-07 06:48:28 +08:00
|
|
|
|
2014-11-19 03:52:41 +08:00
|
|
|
cd netcdf-fortran
|
2015-02-03 06:30:40 +08:00
|
|
|
git checkout $TARGVERSION
|
2014-11-19 03:52:41 +08:00
|
|
|
|
2014-11-07 06:48:28 +08:00
|
|
|
###
|
|
|
|
# Invoke cmake to build netcdf-fortran
|
|
|
|
###
|
2014-11-08 02:22:04 +08:00
|
|
|
|
|
|
|
if [ "x$DOCMAKE" = "xTRUE" ]; then
|
|
|
|
|
|
|
|
mkdir -p build
|
|
|
|
cd build
|
|
|
|
|
2014-11-20 05:29:32 +08:00
|
|
|
if [ "x$DOACTION" = "xbuild" ]; then
|
|
|
|
cmake .. -DCMAKE_PREFIX_PATH=@CMAKE_INSTALL_PREFIX@ -DCMAKE_INSTALL_PREFIX=@CMAKE_INSTALL_PREFIX@ -DBUILD_SHARED_LIBS=@BUILD_SHARED_LIBS@ -DTEST_PARALLEL=@ENABLE_PARALLEL@ &&
|
|
|
|
make && make test
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "x$DOACTION" = "xinstall" ]; then
|
|
|
|
make install
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "x$DOAUTOTOOL" = "xTRUE" ]; then
|
|
|
|
|
|
|
|
if [ "x$DOACTION" = "xbuild" ]; then
|
2014-11-20 07:57:51 +08:00
|
|
|
if [ ! -f "configure" ]; then
|
|
|
|
autoreconf -if
|
|
|
|
fi
|
|
|
|
|
|
|
|
STATIC_BUILD="--disable-static"
|
|
|
|
if [ "x@enable_static@" = "xyes" ]; then
|
|
|
|
STATIC_BUILD="--enable-static"
|
|
|
|
fi
|
|
|
|
|
|
|
|
SHARED_BUILD="--disable-shared"
|
|
|
|
if [ "x@enable_shared@" = "xyes" ]; then
|
|
|
|
SHARED_BUILD="--enable-shared"
|
|
|
|
fi
|
|
|
|
|
|
|
|
LIBS="@LIBS@" CFLAGS="-I@prefix@/include" LDFLAGS="-L@prefix@/lib" ./configure --prefix=@prefix@ $STATIC_BUILD $SHARED_BUILD
|
|
|
|
LIBS="@LIBS@" make
|
|
|
|
LIBS="@LIBS@" make check
|
2014-11-20 05:29:32 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "x$DOACTION" = "xinstall" ]; then
|
|
|
|
make install
|
|
|
|
fi
|
|
|
|
|
2014-11-08 02:22:04 +08:00
|
|
|
fi
|