Skip to content

Commit f0934b3

Browse files
committed
feat(spatialite5): upgrade to 5.0.0-beta1
1 parent 7e43a6b commit f0934b3

File tree

2 files changed

+70
-29
lines changed

2 files changed

+70
-29
lines changed

build/spatialite-tools4.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ export CPPFLAGS="${CPPFLAGS} -I${SQLITE3}/include"
2424
export LDFLAGS="${LDFLAGS} -L${SQLITE3}/lib"
2525

2626
# location of spatialite
27-
SPATIALITE="$(pwd)/libspatialite-5.0.0-beta0"
28-
export CPPFLAGS="${CPPFLAGS} -I${SQLITE3}/include"
29-
export LDFLAGS="${LDFLAGS} -L${SQLITE3}/lib"
27+
SPATIALITE="$(pwd)/../libspatialite-5.0.0-beta0"
28+
export CPPFLAGS="${CPPFLAGS} -I${SPATIALITE}/src/headers"
29+
export LDFLAGS="${LDFLAGS} -L${SPATIALITE}/src"
3030

3131
# # location of proj
3232
# PROJ6='/usr/local/Cellar/proj/6.1.0'
@@ -42,6 +42,7 @@ export LDFLAGS="${LDFLAGS} -L${LIBXML2}/lib"
4242
./configure --disable-dependency-tracking
4343
make -j8
4444

45+
# export LD_LIBRARY_PATH="/usr/local/lib"
4546
./spatialite -silent :memory: <<SQL
4647
SELECT 'sqlite_version', sqlite_version();
4748
SELECT 'spatialite_version', spatialite_version();

build/spatialite5.sh

+66-26
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,58 @@
11
#!/bin/bash
2-
HOST='http://www.gaia-gis.it/gaia-sins/libspatialite-sources'
3-
RELEASE='libspatialite-5.0.0-beta0'
4-
52
mkdir -p tmp
63
cd tmp
74

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'
1056

1157
cd "${RELEASE}"
1258
make clean
@@ -15,37 +61,20 @@ make clean
1561
export CPPFLAGS=""
1662
export LDFLAGS=""
1763

18-
# location of sqlite
19-
SQLITE3='/usr/local/opt/sqlite'
64+
# link sqlite
2065
export CPPFLAGS="${CPPFLAGS} -I${SQLITE3}/include"
2166
export LDFLAGS="${LDFLAGS} -L${SQLITE3}/lib"
2267

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
3969
export CPPFLAGS="${CPPFLAGS} -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H" # required flag to use proj6
4070
export CPPFLAGS="${CPPFLAGS} -I${PROJ6}/include"
4171
export LDFLAGS="-L${PROJ6}/lib"
4272

43-
# location of libxml2
44-
LIBXML2='/usr/local/Cellar/libxml2/2.9.9_2'
73+
# link libxml2
4574
export CPPFLAGS="${CPPFLAGS} -I${LIBXML2}/include/libxml2"
4675
export LDFLAGS="${LDFLAGS} -L${LIBXML2}/lib"
4776

48-
# # location of rttopo
77+
# # link rttopo
4978
# RTTOPO="$(pwd)/librttopo"
5079
# export CPPFLAGS="${CPPFLAGS} -DGEOS_USE_ONLY_R_API" # required flag to use rttopo?
5180
# export CPPFLAGS="${CPPFLAGS} -I${RTTOPO}/headers"
@@ -62,6 +91,17 @@ export LDFLAGS="${LDFLAGS} -L${LIBXML2}/lib"
6291
make -j8
6392
make install
6493

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+
65105
"${SQLITE3}/bin/sqlite3" :memory: <<SQL
66106
SELECT 'sqlite_version', sqlite_version();
67107

0 commit comments

Comments
 (0)