netcdf-c/postinstall.sh.in

67 lines
1.4 KiB
Bash
Raw Normal View History

#!/bin/bash
# Script to automatically build, install netcdf-fortran.
# Very rought draft.
DOCMAKE=""
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
while getopts "t:" o; do
case "${o}" in
t)
MARG=${OPTARG}
;;
*)
echo "Specify type with -t. Types are autotools or cmake."
exit 1
;;
esac
done
case ${MARG} in
cmake)
DOCMAKE="TRUE"
;;
autotools)
;;
*)
echo "Illegal type. Types are autotools or cmake."
exit 1
;;
esac
###
# Fetch netcdf-fortran from git if need be.
###
if [ ! -d "netcdf-fortran" ]; then
git clone http://github.com/unidata/netcdf-fortran
fi
2014-11-19 03:52:41 +08:00
cd netcdf-fortran
git checkout v4.4.1
###
# Invoke cmake to build netcdf-fortran
###
if [ "x$DOCMAKE" = "xTRUE" ]; then
mkdir -p build
cd build
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 && make install
else
CFLAGS="-I@abs_top_builddir@/include" LDFLAGS="-L@abs_top_builddir@/liblib/.libs" ./configure --prefix=@prefix@
make && make check && make install
fi