77# Exit immediately if a command exits with a non-zero status.
88set -e
99
10- # This requires one command-line option, the installation path
10+ # echo all commands (used for debugging)
11+ # set -x
12+
13+ # This shell script requires one or two command-line options: prefx_path and
14+ # optinal destdir_path
1115if [ " x$1 " = x ] ; then
12- echo " Usage: $0 /pnetcdf/install/path "
16+ echo " Usage: $0 prefx_path [destdir_path] "
1317 exit 1
1418fi
1519
16- installation_path=$1
20+ # Note command "make install prefix=/path/of/install DESTDIR=/path/to/dest"
21+ # does not install the library. It copies all install files into folder
22+ # "$DESTDIR/$prefix", so one can cd to $DESTDIR and pack the folder $prefix
23+ # there into a tar ball.
1724
18- # check if folder installation_path exists
19- if [ ! -d $installation_path ]; then
20- echo " Error: folder $installation_path cannot be found"
21- exit 1
22- fi
25+ prefx_path=$1
26+ destdir_path=$2
2327
2428# remove trailing '/' character
25- # Note on Mac OSX, realpath does not support option -s
26- # Ideally, -s should be used to avoid expanding a symlink
27- installation_path=$( realpath $installation_path )
29+ prefx_path=$( echo " $prefx_path " | sed ' s:/*$::' )
30+ if [ " x$destdir_path " != x ] ; then
31+ destdir_path=$( echo " $destdir_path " | sed ' s:/*$::' )
32+ fi
33+
34+ installation_path=$destdir_path$prefx_path
35+
36+ # echo "prefx_path=$prefx_path"
37+ # echo "destdir_path=$destdir_path"
38+ # echo "installation_path=$installation_path"
2839
2940# check if pnetcdf_version exists in the install folder
3041if [ ! -x $installation_path /bin/pnetcdf_version ]; then
@@ -45,20 +56,20 @@ if [ ! -x $installation_path/bin/pnetcdf-config ]; then
4556else
4657 # check if --prefix is correctly reflecting the install path
4758 prefixdir=` $installation_path /bin/pnetcdf-config --prefix`
48- if [ $prefixdir != $installation_path ] ; then
49- echo " Error: expecting '$installation_path ' from 'pnetcdf-config --prefix' but got $prefixdir "
59+ if [ $prefixdir != $prefx_path ] ; then
60+ echo " Error: expecting '$prefx_path ' from 'pnetcdf-config --prefix' but got $prefixdir "
5061 exit 1
5162 fi
5263 # check if --libdir is correctly reflecting the install path
5364 libdir=` $installation_path /bin/pnetcdf-config --libdir`
54- if [ $libdir != $installation_path /lib ] ; then
55- echo " Error: expecting '$installation_path /lib' from 'pnetcdf-config --libdir' but got $libdir "
65+ if [ $libdir != $prefx_path /lib ] ; then
66+ echo " Error: expecting '$prefx_path /lib' from 'pnetcdf-config --libdir' but got $libdir "
5667 exit 1
5768 fi
5869 # check if --includedir is correctly reflecting the install path
5970 incdir=` $installation_path /bin/pnetcdf-config --includedir`
60- if [ $incdir != $installation_path /include ] ; then
61- echo " Error: expecting '$installation_path /include' from 'pnetcdf-config --includedir' but got $incdir "
71+ if [ $incdir != $prefx_path /include ] ; then
72+ echo " Error: expecting '$prefx_path /include' from 'pnetcdf-config --includedir' but got $incdir "
6273 exit 1
6374 fi
6475fi
0 commit comments