forked from therion/therion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_proj.sh
executable file
·87 lines (78 loc) · 2.5 KB
/
test_proj.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
83
84
85
86
87
#!/bin/bash
# Test linking to multiple versions of the PROJ library.
#
# Usage:
# test_proj.sh [options]
#
# Options:
# -b use batch mode
# -i <path> the installation path of PROJ (default: $HOME/tmp/ThProj_test)
# -m use make instead of cmake
# -p <string> the version(s) of PROJ to test (default: all versions listed in this script)
set -e
BATCHMODE=0
MODE="CMake"
PREFIX=$HOME/tmp/ThProj_test
while getopts "bi:mp:" opt; do
case $opt in
b) BATCHMODE=1 ;;
i) PREFIX="$OPTARG" ;;
m) MODE="Make" ;;
p) PROJVER="$OPTARG";;
\?) exit 1 ;;
esac
done
SRCPATH=$(dirname $BASH_SOURCE)
PROJVER=${PROJVER:-6.3.1 6.3.2 7.0.1 7.2.1 8.0.0 8.2.1 9.0.0 9.5.0}
URL=https://download.osgeo.org/proj/proj
if [ "$MODE" = "Make" ]; then
rm -f thproj.o utest-proj.o
else
rm -f CMakeCache.txt
fi
for ver in $PROJVER
do
# check the environment; install Proj locally if it's missing
if [ ! -d "$PREFIX/proj-$ver" ]; then
if (( ! $BATCHMODE )); then
echo "$PREFIX/proj-$ver missing. Download and install it?"
select yn in "Yes" "No"; do
case $yn in
Yes ) break;;
No ) exit;;
esac
done
fi
WD=$PWD
TMPDIR=`mktemp -d`
curl $URL-$ver.tar.gz | tar -xz --directory=$TMPDIR
cd $TMPDIR/proj-$ver
if (( `echo $ver | sed 's/\..*//'` < 8 )); then # pkgconfig supported with cmake since 8.0.0
CC=gcc-12 CXX=g++-12 ./configure --prefix=$PREFIX/proj-$ver; make -j$(nproc); make install
else
mkdir build; cd build
cmake -DCMAKE_INSTALL_PREFIX=$PREFIX/proj-$ver -DBUILD_APPS=OFF -DBUILD_TESTING=OFF ..; make -j$(nproc); make install
fi
cd $WD
rm -r $TMPDIR
fi
# compile and link
if [ "$MODE" = "CMake" ]; then
export PROJ_LIB="$PREFIX/proj-$ver/share/proj";
cmake -DCMAKE_PREFIX_PATH="$PREFIX/proj-$ver" -DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=ON -DENABLE_CCACHE=ON -GNinja $SRCPATH
ninja utest
./utest
rm -f CMakeCache.txt
else
export PROJ_MVER=`echo $ver | sed 's/\..*//'`
export PROJ_LIBS=`pkg-config --libs --static $PREFIX/proj-$ver/lib/pkgconfig/proj.pc`
export CXXJFLAGS="-DPROJ_VER=$PROJ_MVER -I"`pkg-config --variable=includedir $PREFIX/proj-$ver/lib/pkgconfig/proj.pc`
export PROJ_LIB="$PREFIX/proj-$ver/share/proj"
tclsh thcsdata.tcl $PROJ_LIB
LD_LIBRARY_PATH=$PREFIX/proj-$ver/lib make -j$(nproc) tests
rm thproj.o utest-proj.o thcsdata.o thcsdata.h
fi
done
if [ "$MODE" = "CMake" ]; then
cmake -DENABLE_CCACHE=ON -GNinja $SRCPATH
fi