forked from NCAR/lrose-netcdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_and_install_netcdf
executable file
·146 lines (119 loc) · 3.48 KB
/
build_and_install_netcdf
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
137
138
139
140
141
142
143
144
145
#! /bin/bash
#
# Building and installing NETCDF and HDF5 as required by LROSE
# ============================================================
#
# The latest tar files reside in the 'tar_files' subdirectory.
#
# By default the libraries and applications will be installed in:
#
# $HOME/lrose/include
# $HOME/lrose/lib
# $HOME/lrose/bin
#
# You can change the install location by specifying it as
# a single argument to this script.
#
# For example:
#
# build_and_install_netcdf /usr/local/lrose
#
# will install in:
#
# /usr/local/lrose/include
# /usr/local/lrose/lib
# /usr/local/lrose/bin
#
#--------------------------------------------------------------------
# usage function
#
function usage() {
echo
echo "Usage: build_and_install_netcdf [ -h ] [ prefix ]"
echo
echo " -h: produce this usage list"
echo " optionally set the prefix"
echo
}
# set the path
#export PATH=.:/bin:/usr/bin:/sbin:/usr/sbin:/usr/bin/X11:/usr/local/bin:/usr/local/sbin
# set the install prefix
prefix=$HOME/lrose
if [ $# -gt 0 ]
then
if [ "$1" == -h -o "$2" == -h ]
then
usage
exit 0
fi
prefix=$1
fi
echo "Installing in prefix: $prefix"
# start in the netcdf_tar_files directory
cd tar_files || exit 1
# Building HDF5
# -------------
tar xvfz hdf5-*.tar.gz # this may untar over a previous directory
cd hdf5-*/
export FC=gfortran
export F90=gfortran
export F77=gfortran
./configure --prefix=${prefix} --enable-cxx --enable-fortran || exit 1
make clean || exit 1 # remove files from previous builds, if any
make -j 8 || exit 1
make install || exit 1
cd ..
# Building udunits2
# -----------------
tar xvfz udunits-*.tar.gz # this may untar over a previous directory
cd udunits-*/
./configure --prefix=${prefix} || exit 1
make clean || exit 1 # remove files from previous builds, if any
make -j 8 || exit 1
make install || exit 1
cd ..
# When building the netCDF libraries below, make sure we use
# the hdf5 libraries we installed above
export CPPFLAGS=-I${prefix}/include
export LDFLAGS="-L${prefix}/lib -Wl,-rpath=${prefix}/lib"
# Building netcdf C
# -----------------
tar xvfz netcdf-4*.tar.gz # this may untar over a previous directory
cd netcdf-4*/
./configure --enable-netcdf4 --enable-shared --prefix=${prefix} || exit 1
make clean || exit 1 # remove files from previous builds, if any
make -j 8 || exit 1
make install || exit 1
cd ..
# ---------------------------
# append USE_NETCDF4 to FLAGS
export CFLAGS="$CFLAGS -DUSE_NETCDF4"
export CPPFLAGS="$CPPFLAGS -DUSE_NETCDF4"
export LDFLAGS="$LDFLAGS -DUSE_NETCDF4"
# Building netcdf Fortran
# ------------------------
tar xvfz netcdf-fortran*.tar.gz # this may untar over a previous directory
cd netcdf-fortran*/
./configure --enable-shared --prefix=${prefix} || exit 1
make clean || exit 1 # remove files from previous builds, if any
make -j 8 || exit 1
make install || exit 1
cd ..
# Building netcdf C++ legacy
# --------------------------
tar xvfz netcdf-cxx-4*.tar.gz # this may untar over a previous directory
cd netcdf-cxx-4*/
./configure --enable-shared --prefix=${prefix} || exit 1
make clean || exit 1 # remove files from previous builds, if any
make -j 8 || exit 1
make install || exit 1
cd ..
# Building netcdf C++ 4
# ---------------------
tar xvfz netcdf-cxx4-4*.tar.gz # this may untar over a previous directory
cd netcdf-cxx4-4*/
./configure --enable-shared --prefix=${prefix} || exit 1
make clean || exit 1 # remove files from previous builds, if any
make -j 8 || exit 1
make install || exit 1
cd ..