summaryrefslogtreecommitdiffstats
path: root/scripts/get-dep-lib.sh
blob: 96af5c1516d13e1c62551cc007e05c2c9dcf1117 (plain) (blame)
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#!/bin/bash
#

# set version of 3rd party libraries
CURRENT_LIBZIP="1.2.0"
CURRENT_LIBGIT2="v0.26.0"
CURRENT_HIDAPI="hidapi-0.7.0"
CURRENT_LIBCURL="curl-7_54_1"
CURRENT_LIBUSB="v1.0.21"
CURRENT_OPENSSL="OpenSSL_1_1_0h"
CURRENT_LIBSSH2="libssh2-1.8.0"
CURRENT_XSLT="v1.1.29"
CURRENT_SQLITE="3190200"
CURRENT_LIBXML2="v2.9.4"
CURRENT_LIBFTDI="1.3"
CURRENT_KIRIGAMI="70c025ef6f6dc63c85180867f70f5e00ba5a8dba"
CURRENT_BREEZE_ICONS=""

# deal with all the command line arguments
if [[ $# -ne 2 && $# -ne 3 ]] ; then
	echo "wrong number of parameters, format:"
	echo "get-dep-lib.sh <platform> <install dir>"
	echo "get-dep-lib.sh single <install dir> <lib>"
	echo "get-dep-lib.sh singleAndroid <install dir> <lib>"
	echo "where"
	echo "<platform> is one of scripts, ios or android"
	echo "(the name of the directory where build.sh resides)"
	echo "<install dir> is the directory to clone in"
	echo "<lib> is the name to be cloned"
	exit -1
fi

PLATFORM=$1
INSTDIR=$2
if [ ! -d ${INSTDIR} ] ; then
	echo "creating dir"
	mkdir -p ${INSTDIR}
fi

# FIX FOR ANDROID,
if [ "$PLATFORM" == "singleAndroid" ] ; then
	CURRENT_LIBZIP="1.1.3"
	CURRENT_OPENSSL="OpenSSL_1_0_2o"
fi
# no curl and old libs (never version breaks)
# check whether to use curl or wget
if [ "`which curl`" == "" ] ; then
	CURL="wget "
else
	CURL="curl -O "
fi
BUILD_COMMON="libzip libgit2 googlemaps"
case ${PLATFORM} in
	scripts)
		BUILD="${BUILD_COMMON} hidapi libcurl libusb openssl libssh2"
		;;
	ios)
		BUILD="${BUILD_COMMON} libxslt"
		;;
	android)
		BUILD="${BUILD_COMMON} libxslt sqlite libxml2 openssl libftdi libusb"
		;;
	single)
		BUILD="$3"
		;;
	singleAndroid)
		BUILD="$3"
		;;
	*)
		echo "Unknown platform ${PLATFORM}, choose between native, ios or android"
		;;
esac

# show what you are doing and stop when things break
set -x
set -e

# get ready to download needed sources
cd ${INSTDIR}

if [[ "$BUILD" = *"libcurl"* && ! -d libcurl ]]; then
	git clone https://github.com/curl/curl.git libcurl
	pushd libcurl
	git fetch origin
	if ! git checkout $CURRENT_LIBCURL ; then
		echo "Can't find the right tag in libcurl - giving up"
		exit -1
	fi
	popd
fi

if [[ "$BUILD" = *"libftdi"* && ! -d libftdi1 ]]; then
	${CURL} https://www.intra2net.com/en/developer/libftdi/download/libftdi1-${CURRENT_LIBFTDI}.tar.bz2
	tar -jxf libftdi1-${CURRENT_LIBFTDI}.tar.bz2
	mv libftdi1-${CURRENT_LIBFTDI} libftdi1
fi

if [[ "$BUILD" = *"libgit2"* && ! -d libgit2 ]]; then
	git clone https://github.com/libgit2/libgit2.git
	pushd libgit2
	git fetch origin
	if ! git checkout ${CURRENT_LIBGIT2} ; then
		echo "Can't find the right tag in libgit2 - giving up"
		exit -1
	fi
	popd
fi

if [[ "$BUILD" = *"libssh2"* && ! -d libssh2 ]]; then
	git clone https://github.com/libssh2/libssh2.git
	pushd libssh2
	git fetch origin
	if ! git checkout $CURRENT_LIBSSH2 ; then
		echo "Can't find the right tag in libssh2 - giving up"
		exit -1
	fi
	popd
fi

if [[ "$BUILD" = *"libusb"* && ! -d libusb ]]; then
	git clone https://github.com/libusb/libusb.git
	pushd libusb
	git fetch origin
	if ! git checkout $CURRENT_LIBUSB ; then
		echo "Can't find the right tag in libusb - giving up"
		exit -1
	fi
	popd
fi

if [[ "$BUILD" = *"libxml2"* && ! -d libxml2 ]]; then
	git clone https://github.com/GNOME/libxml2.git
	pushd libxml2
	git fetch origin
	if ! git checkout $CURRENT_LIBXML2 ; then
		echo "Can't find the right tag in libxml2 - giving up"
		exit -1
	fi
	popd
fi

if [[ "$BUILD" = *"libxslt"* && ! -d libxslt ]]; then
	git clone https://github.com/GNOME/libxslt.git
	pushd libxslt
	git fetch origin
	if ! git checkout $CURRENT_LIBXSLT ; then
		echo "Can't find the right tag in libxslt - giving up"
		exit -1
	fi
	popd
fi

if [[ "$BUILD" = *"libzip"* && ! -d libzip ]]; then
	${CURL} https://subsurface-divelog.org/downloads/libzip-${CURRENT_LIBZIP}.tar.xz
	tar xJf libzip-${CURRENT_LIBZIP}.tar.xz
	mv libzip-${CURRENT_LIBZIP} libzip
fi

if [[ "$BUILD" = *"breeze-icons"* && ! -d breeze-icons ]]; then
	git clone https://github.com/kde/breeze-icons.git
	pushd breeze-icons
	git pull --rebase
	popd
fi

if [[ "$BUILD" = *"googlemaps"* && ! -d googlemaps ]]; then
	git clone https://github.com/Subsurface-divelog/googlemaps.git
	pushd googlemaps
	git fetch origin
	git checkout master
	git pull --rebase
	popd
fi

if [[ "$BUILD" = *"hidapi"* && ! -d hidapi ]]; then
	git clone https://github.com/signal11/hidapi.git
	pushd hidapi
	git fetch origin
	# there is no good tag, so just build master
#	if ! git checkout $CURRENT_HIDAPI ; then
#		echo "Can't find the right tag in hidapi - giving up"
#		exit -1
#	fi
	popd
fi

if [[ "$BUILD" = *"kirigami"* && ! -d kirigami ]]; then
	git clone -b master https://github.com/KDE/kirigami.git
	pushd kirigami
	if ! git checkout $CURRENT_KIRIGAMI ; then
		echo "Can't find the right tag in openssl - giving up"
		exit -1
	fi
	popd
fi

if [[ "$BUILD" = *"openssl"* && ! -d openssl ]]; then
	git clone https://github.com/openssl/openssl.git
	pushd openssl
	git fetch origin
	if ! git checkout $CURRENT_OPENSSL ; then
		echo "Can't find the right tag in openssl - giving up"
		exit -1
	fi
	popd
fi

if [[ "$BUILD" = *"sqlite"* && ! -d sqlite ]]; then
	${CURL} http://www.sqlite.org/2017/sqlite-autoconf-${CURRENT_SQLITE}.tar.gz
	tar -zxf sqlite-autoconf-${CURRENT_SQLITE}.tar.gz
	mv sqlite-autoconf-${CURRENT_SQLITE} sqlite
fi