-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-ncl.sh
executable file
·61 lines (49 loc) · 1.54 KB
/
build-ncl.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
#!/usr/bin/env bash
set -e
# get location of script
ECOEVOLITY_BASE_DIR=""
this_dir=`dirname "$0"`
if [ "$this_dir" = "." ]
then
ECOEVOLITY_BASE_DIR="$(pwd)"
else
cd "$this_dir"
ECOEVOLITY_BASE_DIR="$(pwd)"
fi
NCL_BUILD_DIR="${ECOEVOLITY_BASE_DIR}/ncl-build"
INSTALL_DIR="${NCL_BUILD_DIR}/installed"
if [ -d "$NCL_BUILD_DIR" ]
then
echo "ERROR: build directory '$NCL_BUILD_DIR' already exists."
echo "To recompile, please remove this directory and re-run this script."
exit 1
else
mkdir -p "${NCL_BUILD_DIR}/build"
mkdir -p "$INSTALL_DIR"
fi
NCL_TAR_BALL="ncl-2.1.18.tar.gz"
NCL_TAR_BALL_PATH="${NCL_BUILD_DIR}/${NCL_TAR_BALL}"
curl -L -o "$NCL_TAR_BALL_PATH" "https://sourceforge.net/projects/ncl/files/NCL/ncl-2.1.18/${NCL_TAR_BALL}"
NCL_DIR="${NCL_TAR_BALL_PATH%.tar.gz}"
tar -xzf "$NCL_TAR_BALL_PATH" -C "$NCL_BUILD_DIR"
# number of cpus to use during compile
COMPILETHREADS=4
cd "${NCL_BUILD_DIR}/build"
$NCL_DIR/configure --prefix="$INSTALL_DIR"
make clean
make -j $COMPILETHREADS
make install
cd "$ECOEVOLITY_BASE_DIR"
echo
echo
echo NCL headers and binaries are in:
echo " $INSTALL_DIR"
env_path="${NCL_BUILD_DIR}/ncl-env.sh"
echo "#!/bin/sh" > "$env_path"
echo export PATH="${INSTALL_DIR}/bin:\${PATH}" >> "$env_path"
echo export LD_LIBRARY_PATH="${INSTALL_DIR}/lib:\${LD_LIBRARY_PATH}" >> "$env_path"
echo export PKG_CONFIG_PATH="${INSTALL_DIR}/lib/pkgconfig:\${PKG_CONFIG_PATH}" >> "$env_path"
echo export NCL_PREFIX="${INSTALL_DIR}" >> "$env_path"
rm "$NCL_TAR_BALL_PATH"
rm -r "${NCL_BUILD_DIR}/build"
rm -r "$NCL_DIR"