netcdfcxx_legacy/config.sh
2021-08-02 22:13:24 +08:00

65 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
package=NULL
runtype=configure
buildtype=Release
netcdflib=/usr/local
prefixdir=/opt/stow
targetdir=/usr/local
while getopts "hr:p:b:n:d:t:" arg
do
case $arg in
h)
echo "Install and manage packages with the Stow software."
echo "-r running type: configure (default), build or install."
echo "-p package name."
echo "-b build type: Release (default) or Debug."
echo "-n netCDF library address: /usr/local (default)."
echo "-d install prefix: /opt/stow (default)."
echo "-t target prefix: /opt (default)."
exit 0;;
r)
runtype=${OPTARG};;
p)
package=${OPTARG};;
b)
buildtype=${OPTARG};;
n)
netcdflib=${OPTARG};;
d)
prefixdir=${OPTARG};;
t)
targetdir=${OPTARG};;
?)
echo "Error: unknow argument."
echo "Use -h option to see help information."
exit 1;;
esac
done
if [[ ${runtype} == "configure" && ! -d "build/" ]]; then
if [[ ${package} == "NULL" ]]; then
echo "Error: no package name."
echo "Use -h option to see help information."
exit 1
fi
mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=${prefixdir}/${package} -DCMAKE_BUILD_TYPE=${buildtype} -DLIB_NETCDF=${netcdflib}
elif [[ ${runtype} == "configure" ]]; then
if [[ ${package} == "NULL" ]]; then
echo "Error: no package name."
echo "Use -h option to see help information."
exit 1
fi
cd build && rm -rf * && cmake .. -DCMAKE_INSTALL_PREFIX=${prefixdir}/${package} -DCMAKE_BUILD_TYPE=${buildtype} -DLIB_NETCDF=${netcdflib}
elif [[ ${runtype} == "build" ]]; then
cd build && make
elif [[ ${runtype} == "install" ]]; then
if [[ ${package} == "NULL" ]]; then
echo "Error: no package name."
echo "Use -h option to see help information."
exit 1
fi
cd build && sudo make install
sudo stow --dir=${prefixdir} --target=${targetdir} ${package}
fi