This repository has been archived by the owner on Apr 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGMT-installer.sh
executable file
·82 lines (71 loc) · 2.62 KB
/
GMT-installer.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
#!/bin/bash
# Basic Information
GMT_VERSION=5.4.3
GSHHG_VERSION=2.3.7
DCW_VERSION=1.1.2
GMT_INSTALL=/opt/GMT-${GMT_VERSION}
#GMT_MIRROR=ftp://ftp.soest.hawaii.edu/gmt
GMT_MIRROR=http://mirrors.ustc.edu.cn/gmt/
CURL_OPTIONS="-C - -O --fail -#"
# download files
echo "Downloading gmt-${GMT_VERSION}-src.tar.gz:"
if ! curl ${CURL_OPTIONS} ${GMT_MIRROR}/gmt-${GMT_VERSION}-src.tar.gz; then
curl ${CURL_OPTIONS} ${GMT_MIRROR}/legacy/gmt-${GMT_VERSION}-src.tar.gz
fi
echo "Downloading gshhg-gmt-${GSHHG_VERSION}.tar.gz:"
if ! curl ${CURL_OPTIONS} ${GMT_MIRROR}/gshhg-gmt-${GSHHG_VERSION}.tar.gz; then
curl ${CURL_OPTIONS} ${GMT_MIRROR}/legacy/gshhg-gmt-${GSHHG_VERSION}.tar.gz
fi
echo "Downloading dcw-gmt-${DCW_VERSION}.tar.gz:"
if ! curl ${CURL_OPTIONS} ${GMT_MIRROR}/dcw-gmt-${DCW_VERSION}.tar.gz; then
curl ${CURL_OPTIONS} ${GMT_MIRROR}/legacy/dcw-gmt-${DCW_VERSION}.tar.gz
fi
# write md5sum value to file
cat << EOF > md5sums.md5
45c99d30026742dbc0b1644ea64f496d dcw-gmt-${DCW_VERSION}.tar.gz
ff36a14b78d938e42d85046082d6ddeb gmt-${GMT_VERSION}-src.tar.gz
8ee2653f9daf84d49fefbf990bbfa1e7 gshhg-gmt-${GSHHG_VERSION}.tar.gz
EOF
# Verify the integrity of files
if ! md5sum --status -c md5sums.md5; then
echo "#############################################################"
echo "# Error in downloading files! #"
echo "#############################################################"
exit
fi
# Now start to install
tar -xf gmt-${GMT_VERSION}-src.tar.gz
tar -xf gshhg-gmt-${GSHHG_VERSION}.tar.gz
tar -xf dcw-gmt-${DCW_VERSION}.tar.gz
mv gshhg-gmt-${GSHHG_VERSION} gmt-${GMT_VERSION}/share/gshhg
mv dcw-gmt-${DCW_VERSION} gmt-${GMT_VERSION}/share/dcw-gmt
cd gmt-${GMT_VERSION}
cat > cmake/ConfigUser.cmake << EOF
set (CMAKE_INSTALL_PREFIX "${GMT_INSTALL}")
set (GMT_INSTALL_MODULE_LINKS FALSE)
set (COPY_GSHHG TRUE)
set (COPY_DCW TRUE)
set (GMT_USE_THREADS TRUE)
EOF
mkdir build
cd build
cmake ..
make
sudo make install
cd ../..
# Add enviromental variables to shell startup file
current_shell=$(basename $SHELL)
if [ $current_shell == "bash" ]; then
startup_file="${HOME}/.bashrc"
elif [ $current_shell == "zsh" ]; then
startup_file="${HOME}/.zshrc"
else
startup_file="${HOME}/.bashrc"
fi
echo "Adding GMT related enviromental variables to $startup_file"
echo " export GMT5HOME=${GMT_INSTALL}"
echo ' export PATH=${GMT5HOME}/bin:$PATH'
echo ' export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GMT5HOME}/lib64'
echo "export GMT5HOME=${GMT_INSTALL}" >> $startup_file
echo 'export PATH=${GMT5HOME}/bin:$PATH' >> $startup_file
echo 'export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GMT5HOME}/lib64' >> $startup_file