-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathbuild_app.sh
executable file
·128 lines (108 loc) · 2.56 KB
/
build_app.sh
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
#!/usr/bin/env bash
THIS_FILE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $THIS_FILE_DIR/lib/fun.bash
# Check for Environmental varables.
sourceme_sourced
# change list.
app_list=(
ZLIB
SZIP
JPEG
# LIBPNG
JASPER
UDUNITS2
MPICH
HDF5
NETCDF4
NETCDFF4
NETCDF4CXX
# NCVIEW
WRF
WPS)
#
function usage()
{
cat <<EOF
USAGE:
$0 -options <all|appname>
Where 'appname' is one of the following.
---------------------------------------
EOF
for app in ${app_list[@]}; do
echo $app
done
cat <<EOF
---------------------------------------
IMPORTANT:
The order of building apps may need be altered in your case since
this package doesn't resolve dependencies (yet). So change app_list
variable in this file to control order of building or call the above
options one by one manually.
NOTE:
This script is just a wrapper for indivial builing scripts which are
located in "build" directory. So how please read them and change them
freely according to your needs.
EOF
exit 4
}
function build_app()
{
export LANG=C
blue_echo "Building \"$1\" .... "
. $appsdir/${1}.env
# is app download yet?
case $APP in
WRF* )
;;
WPS* )
;;
*)
if [ -d $WRF_BASE/src/${DIR} ]; then
cd $WRF_BASE/src/${DIR}
else
red_echo "WARNING: Seems $1 hasn't been downloaded yet."
blue_echo "Trying to initiate download"
$SCRIPTS_DIR/download_app.sh ${1}
if [ $? -ne 0 ]; then
red_echo Failed to download: ${1}.
exit 2
fi
cd $WRF_BASE/src/${DIR}
fi
esac
for dep in ${DEP[@]}; do # soruce dep envs
source $appsdir/$dep.env
done
. $appsdir/${1}.env
blue_echo "Entering $(pwd) to build ${1}"
. ${SCRIPTS_DIR}/build/${1}.sh
if [ $? -ne 0 ]; then
red_echo Failed building ${1}.
exit
else
green_echo "Successfully built ${1} \n\n"
fi
}
if [ $# -lt 1 ]
then
echo "${#} arguments."
usage $0
fi
counter=0
nofargs=$#
while [ $counter -lt $nofargs ]; do
case $1 in
all|ALL)
for app in ${app_list[@]};
do
build_app ${app}
done
;;
*)
app="${1%.[^.]*}" # strip out ".sh" if available
build_app $(echo $1 | tr '[:lower:]' '[:upper:]')
;;
esac
shift
let counter=counter+1
done