2021-08-01 14:37:01 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-08-01 19:22:30 +08:00
|
|
|
package=NULL
|
|
|
|
runtype=configure
|
|
|
|
buildtype=Release
|
|
|
|
netcdflib=/usr/local
|
|
|
|
prefixdir=/opt/stow
|
|
|
|
targetdir=/opt
|
2021-08-01 14:37:01 +08:00
|
|
|
|
2021-08-01 19:22:30 +08:00
|
|
|
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
|
2021-08-01 14:37:01 +08:00
|
|
|
cd build && make
|
2021-08-01 19:22:30 +08:00
|
|
|
elif [[ ${runtype} == "install" ]]; then
|
|
|
|
if [[ ${package} == "NULL" ]]; then
|
|
|
|
echo "Error: no package name."
|
|
|
|
echo "Use -h option to see help information."
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-08-01 14:37:01 +08:00
|
|
|
cd build && sudo make install
|
2021-08-01 19:22:30 +08:00
|
|
|
sudo stow --dir=${prefixdir} --target=${targetdir} ${package}
|
2021-08-01 14:37:01 +08:00
|
|
|
fi
|