forked from Unidata/netcdf-c
-
Notifications
You must be signed in to change notification settings - Fork 1
/
postinstall.sh.in
136 lines (110 loc) · 2.66 KB
/
postinstall.sh.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
# Script to automatically build, install netcdf-fortran.
# Very rought draft.
DOCMAKE=""
DOAUTOTOOL=""
DOACTION=""
TARGVERSION="v4.4.4"
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
##
# Check for 'git', exit if it's not found.
##
hash git 2>/dev/null1
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
while getopts "a:t:" o; do
case "${o}" in
t)
MARG=${OPTARG}
;;
a)
DOACTION=${OPTARG}
;;
*)
echo "Specify type with -t. Types are autotools or cmake."
exit 1
;;
esac
done
###
# Make sure we're specifying an allowed
# build system.
###
case ${MARG} in
cmake)
DOCMAKE="TRUE"
;;
autotools)
DOAUTOTOOL="TRUE"
;;
*)
echo "Illegal type. Types are autotools or cmake."
exit 1
;;
esac
###
# Make sure we're performing a valid action.
###
case ${DOACTION} in
build)
;;
install)
;;
*)
echo "Illegal action."
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
cd netcdf-fortran
git checkout $TARGVERSION
###
# Invoke cmake to build netcdf-fortran
###
if [ "x$DOCMAKE" = "xTRUE" ]; then
mkdir -p build
cd build
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
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
fi
if [ "x$DOACTION" = "xinstall" ]; then
make install
fi
fi