1
1
#! /bin/bash
2
- HOST=' http://www.gaia-gis.it/gaia-sins/libspatialite-sources'
3
- RELEASE=' libspatialite-5.0.0-beta0'
4
-
5
2
mkdir -p tmp
6
3
cd tmp
7
4
8
- [[ -f " ${RELEASE} .tar.gz" ]] || curl -LO " ${HOST} /${RELEASE} .tar.gz"
9
- [[ -d " ${RELEASE} " ]] || tar xvzf " ${RELEASE} .tar.gz"
5
+ # loocation of dependencies
6
+ # note: if you are having trouble, check these first!
7
+ SQLITE3=' /usr/local/opt/sqlite'
8
+ PROJ6=' /usr/local/Cellar/proj/6.1.0'
9
+ LIBXML2=' /usr/local/Cellar/libxml2/2.9.9_2'
10
+
11
+ # download a stable release
12
+ function download(){
13
+ HOST=' http://www.gaia-gis.it/gaia-sins/libspatialite-sources' ;
14
+ RELEASE=" $1 " ;
15
+ [[ -f " ${RELEASE} .tar.gz" ]] || curl -LO " ${HOST} /${RELEASE} .tar.gz"
16
+ [[ -d " ${RELEASE} " ]] || tar xvzf " ${RELEASE} .tar.gz"
17
+ }
18
+
19
+ # clone a fossil source
20
+ function clone(){
21
+ REPO=" $1 " ;
22
+ rm -rf $REPO $REPO .fossil* ;
23
+ fossil clone https://www.gaia-gis.it/fossil/$REPO $REPO .fossil;
24
+ mkdir -p $REPO ;
25
+ cd $REPO ;
26
+ fossil open ../$REPO .fossil;
27
+ cd -;
28
+ }
29
+
30
+ function checkSqliteCompileOptions(){
31
+ # check sqlite was compiled with 'ENABLE_RTREE'
32
+ " ${SQLITE3} /bin/sqlite3" :memory: ' PRAGMA compile_options' | grep -q ENABLE_RTREE
33
+ if [[ $? != 0 ]]; then
34
+ 2>&1 echo ' sqlite3 was not compiled with the ENABLE_RTREE extension'
35
+ exit 1
36
+ fi
37
+
38
+ # check sqlite was compiled with 'ENABLE_COLUMN_METADATA'
39
+ " ${SQLITE3} /bin/sqlite3" :memory: ' PRAGMA compile_options' | grep -q ENABLE_COLUMN_METADATA
40
+ if [[ $? != 0 ]]; then
41
+ 2>&1 echo ' sqlite3 was not compiled with the ENABLE_COLUMN_METADATA extension'
42
+ exit 1
43
+ fi
44
+ }
45
+
46
+ # ensure sqlite was compiled using the required compiler options
47
+ checkSqliteCompileOptions;
48
+
49
+ # clone cutting-edge from fossil
50
+ clone ' libspatialite'
51
+ RELEASE=' libspatialite'
52
+
53
+ # download a stable release
54
+ # download 'libspatialite-5.0.0-beta0'
55
+ # RELEASE='libspatialite-5.0.0-beta0'
10
56
11
57
cd " ${RELEASE} "
12
58
make clean
@@ -15,37 +61,20 @@ make clean
15
61
export CPPFLAGS=" "
16
62
export LDFLAGS=" "
17
63
18
- # location of sqlite
19
- SQLITE3=' /usr/local/opt/sqlite'
64
+ # link sqlite
20
65
export CPPFLAGS=" ${CPPFLAGS} -I${SQLITE3} /include"
21
66
export LDFLAGS=" ${LDFLAGS} -L${SQLITE3} /lib"
22
67
23
- # check sqlite was compiled with 'ENABLE_RTREE'
24
- " ${SQLITE3} /bin/sqlite3" :memory: ' PRAGMA compile_options' | grep -q ENABLE_RTREE
25
- if [[ $? != 0 ]]; then
26
- 2>&1 echo ' sqlite3 was not compiled with the ENABLE_RTREE extension'
27
- exit 1
28
- fi
29
-
30
- # check sqlite was compiled with 'ENABLE_COLUMN_METADATA'
31
- " ${SQLITE3} /bin/sqlite3" :memory: ' PRAGMA compile_options' | grep -q ENABLE_COLUMN_METADATA
32
- if [[ $? != 0 ]]; then
33
- 2>&1 echo ' sqlite3 was not compiled with the ENABLE_COLUMN_METADATA extension'
34
- exit 1
35
- fi
36
-
37
- # location of proj
38
- PROJ6=' /usr/local/Cellar/proj/6.1.0'
68
+ # link proj
39
69
export CPPFLAGS=" ${CPPFLAGS} -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H" # required flag to use proj6
40
70
export CPPFLAGS=" ${CPPFLAGS} -I${PROJ6} /include"
41
71
export LDFLAGS=" -L${PROJ6} /lib"
42
72
43
- # location of libxml2
44
- LIBXML2=' /usr/local/Cellar/libxml2/2.9.9_2'
73
+ # link libxml2
45
74
export CPPFLAGS=" ${CPPFLAGS} -I${LIBXML2} /include/libxml2"
46
75
export LDFLAGS=" ${LDFLAGS} -L${LIBXML2} /lib"
47
76
48
- # # location of rttopo
77
+ # # link rttopo
49
78
# RTTOPO="$(pwd)/librttopo"
50
79
# export CPPFLAGS="${CPPFLAGS} -DGEOS_USE_ONLY_R_API" # required flag to use rttopo?
51
80
# export CPPFLAGS="${CPPFLAGS} -I${RTTOPO}/headers"
@@ -62,6 +91,17 @@ export LDFLAGS="${LDFLAGS} -L${LIBXML2}/lib"
62
91
make -j8
63
92
make install
64
93
94
+ # generate additional symlink for MacOS
95
+ # this allows sqlite to find the extension using: load_extension('mod_spatialite')
96
+ if [[ " $OSTYPE " == " darwin" * ]]; then
97
+ OSX_LIB_DIR=' /usr/local/lib'
98
+ if [[ -f " ${OSX_LIB_DIR} /mod_spatialite.7.so" ]]; then
99
+ if [[ ! -e " ${OSX_LIB_DIR} /mod_spatialite.dylib" ]]; then
100
+ ln -s " ${OSX_LIB_DIR} /mod_spatialite.7.so" " ${OSX_LIB_DIR} /mod_spatialite.dylib" ;
101
+ fi
102
+ fi
103
+ fi
104
+
65
105
" ${SQLITE3} /bin/sqlite3" :memory: << SQL
66
106
SELECT 'sqlite_version', sqlite_version();
67
107
0 commit comments