forked from NOAA-EMC/NCEPLIBS-landsfcutil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_landsfcutil.sh
executable file
·134 lines (124 loc) · 4.45 KB
/
build_landsfcutil.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
129
130
131
132
133
#!/bin/bash
: ${THISDIR:=$(dirname $(readlink -f -n ${BASH_SOURCE[0]}))}
CDIR=$PWD; cd $THISDIR
source ./Conf/Analyse_args.sh
source ./Conf/Collect_info.sh
source ./Conf/Gen_cfunction.sh
source ./Conf/Reset_version.sh
if [[ ${sys} == "intel_general" ]]; then
sys6=${sys:6}
source ./Conf/Landsfcutil_${sys:0:5}_${sys6^}.sh
rinst=false
elif [[ ${sys} == "gnu_general" ]]; then
sys4=${sys:4}
source ./Conf/Landsfcutil_${sys:0:3}_${sys4^}.sh
rinst=false
else
source ./Conf/Landsfcutil_intel_${sys^}.sh
fi
$CC --version &> /dev/null || {
echo "??? LANDSFCUTIL: compilers not set." >&2
exit 1
}
[[ -z ${LANDSFCUTIL_VER+x} || -z ${LANDSFCUTIL_LIB4+x} ]] && {
[[ -z ${libver+x} || -z ${libver} ]] && {
echo "??? LANDSFCUTIL: \"libver\" not set." >&2
exit
}
LANDSFCUTIL_INC4=${libver}_4
LANDSFCUTIL_INCd=${libver}_d
LANDSFCUTIL_LIB4=lib${libver}_4.a
LANDSFCUTIL_LIBd=lib${libver}_d.a
LANDSFCUTIL_VER=v${libver##*_v}
}
set -x
landsfcutilLib4=$(basename ${LANDSFCUTIL_LIB4})
landsfcutilLibd=$(basename ${LANDSFCUTIL_LIBd})
landsfcutilInc4=$(basename ${LANDSFCUTIL_INC4})
landsfcutilIncd=$(basename ${LANDSFCUTIL_INCd})
#################
cd src
#################
#-------------------------------------------------------------------
# Start building libraries
#
echo
echo " ... build (i4/r4) landsfcutil library ..."
echo
make clean LIB=$landsfcutilLib4 MOD=$landsfcutilInc4
mkdir -p $landsfcutilInc4
FFLAGS4="$I4R4 $FFLAGS ${MODPATH}$landsfcutilInc4"
collect_info landsfcutil 4 OneLine4 LibInfo4
landsfcutilInfo4=landsfcutil_info_and_log4.txt
$debg && make debug FFLAGS="$FFLAGS4" LIB=$landsfcutilLib4 \
&> $landsfcutilInfo4 \
|| make build FFLAGS="$FFLAGS4" LIB=$landsfcutilLib4 \
&> $landsfcutilInfo4
make message MSGSRC="$(gen_cfunction $landsfcutilInfo4 OneLine4 LibInfo4)" \
LIB=$landsfcutilLib4
echo
echo " ... build (i4/r8) landsfcutil library ..."
echo
make clean LIB=$landsfcutilLibd MOD=$landsfcutilIncd
mkdir -p $landsfcutilIncd
FFLAGSd="$I4R8 $FFLAGS ${MODPATH}$landsfcutilIncd"
collect_info landsfcutil d OneLined LibInfod
landsfcutilInfod=landsfcutil_info_and_logd.txt
$debg && make debug FFLAGS="$FFLAGSd" LIB=$landsfcutilLibd \
&> $landsfcutilInfod \
|| make build FFLAGS="$FFLAGSd" LIB=$landsfcutilLibd \
&> $landsfcutilInfod
make message MSGSRC="$(gen_cfunction $landsfcutilInfod OneLined LibInfod)" \
LIB=$landsfcutilLibd
$inst && {
#
# Install libraries and source files
#
$local && {
instloc=..
LIB_DIR=$instloc/lib
INCP_DIR=$instloc/include
[ -d $LIB_DIR ] || { mkdir -p $LIB_DIR; }
[ -d $INCP_DIR ] || { mkdir -p $INCP_DIR; }
LIB_DIR4=$LIB_DIR
LIB_DIRd=$LIB_DIR
INCP_DIR4=$INCP_DIR
INCP_DIRd=$INCP_DIR
SRC_DIR=
} || {
$rinst && {
LIB_DIR4=$(dirname ${LANDSFCUTIL_LIB4})
LIB_DIRd=$(dirname ${LANDSFCUTIL_LIBd})
INCP_DIR4=$(dirname $LANDSFCUTIL_INC4)
INCP_DIRd=$(dirname $LANDSFCUTIL_INCd)
[ -d $LANDSFCUTIL_INC4 ] && { rm -rf $LANDSFCUTIL_INC4; } \
|| { mkdir -p $INCP_DIR4; }
[ -d $LANDSFCUTIL_INCd ] && { rm -rf $LANDSFCUTIL_INCd; } \
|| { mkdir -p $INCP_DIRd; }
SRC_DIR=$LANDSFCUTIL_SRC
} || {
LIB_DIR=$instloc/lib
LIB_DIR4=$LIB_DIR
LIB_DIRd=$LIB_DIR
INCP_DIR=$instloc/include
INCP_DIR4=$INCP_DIR
INCP_DIRd=$INCP_DIR
LANDSFCUTIL_INC4=$INCP_DIR4/$LANDSFCUTIL_INC4
LANDSFCUTIL_INCd=$INCP_DIRd/$LANDSFCUTIL_INCd
[ -d $LANDSFCUTIL_INC4 ] && { rm -rf $LANDSFCUTIL_INC4; } \
|| { mkdir -p $INCP_DIR4; }
[ -d $LANDSFCUTIL_INCd ] && { rm -rf $LANDSFCUTIL_INCd; } \
|| { mkdir -p $INCP_DIRd; }
SRC_DIR=$instloc/src/${libver}
[[ $instloc == .. ]] && SRC_DIR=
}
[ -d $LIB_DIR4 ] || mkdir -p $LIB_DIR4
[ -d $LIB_DIRd ] || mkdir -p $LIB_DIRd
[ -z $SRC_DIR ] || { [ -d $SRC_DIR ] || mkdir -p $SRC_DIR; }
}
make clean LIB=
make install LIB=$landsfcutilLib4 MOD=$landsfcutilInc4 \
LIB_DIR=$LIB_DIR4 INC_DIR=$INCP_DIR4 SRC_DIR=
make install LIB=$landsfcutilLibd MOD=$landsfcutilIncd \
LIB_DIR=$LIB_DIRd INC_DIR=$INCP_DIRd SRC_DIR=$SRC_DIR
}