2015-01-23 23:04:32 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
: '
|
|
|
|
|
|
|
|
todo
|
|
|
|
|
2015-04-24 09:04:00 +02:00
|
|
|
- docs for base setup: sudo apt-get -y install zlib1g-dev make git
|
2015-01-23 23:04:32 +01:00
|
|
|
- shrink icu data
|
|
|
|
'
|
|
|
|
|
2020-10-19 13:27:41 +02:00
|
|
|
MASON_VERSION="cce4ebf4"
|
2016-03-11 01:25:54 +01:00
|
|
|
|
2015-01-24 19:05:58 +01:00
|
|
|
function setup_mason() {
|
2015-01-29 18:09:43 +01:00
|
|
|
if [[ ! -d ./.mason ]]; then
|
2018-08-01 15:24:34 +02:00
|
|
|
git clone https://github.com/mapbox/mason.git .mason || return
|
|
|
|
elif ! git -C .mason rev-parse -q --verify "$MASON_VERSION" >/dev/null; then
|
|
|
|
git -C .mason fetch --all || true # non-fatal
|
2015-01-24 19:05:58 +01:00
|
|
|
fi
|
2018-08-01 15:24:34 +02:00
|
|
|
git -C .mason checkout --detach "$MASON_VERSION" -- || return
|
|
|
|
case ":$PATH:" in
|
|
|
|
*":$PWD/.mason:"*) : already there ;;
|
|
|
|
*) export PATH="$PWD/.mason:$PATH" ;;
|
|
|
|
esac
|
2015-01-29 00:05:59 +01:00
|
|
|
export CXX=${CXX:-clang++}
|
|
|
|
export CC=${CC:-clang}
|
2015-01-24 19:05:58 +01:00
|
|
|
}
|
|
|
|
|
2015-02-03 07:08:52 +01:00
|
|
|
function install() {
|
|
|
|
MASON_PLATFORM_ID=$(mason env MASON_PLATFORM_ID)
|
2015-04-30 00:41:09 +02:00
|
|
|
if [[ ! -d ./mason_packages/${MASON_PLATFORM_ID}/${1}/${2} ]]; then
|
2015-01-27 08:38:22 +01:00
|
|
|
mason install $1 $2
|
2016-03-14 22:02:32 +01:00
|
|
|
if [[ ${3:-false} != false ]]; then
|
2016-06-13 21:21:51 +02:00
|
|
|
LA_FILE=$(mason prefix $1 $2)/lib/$3.la
|
2015-05-23 19:30:49 +02:00
|
|
|
if [[ -f ${LA_FILE} ]]; then
|
2016-08-09 19:41:38 +02:00
|
|
|
perl -i -p -e 's:\Q$ENV{HOME}/build/mapbox/mason\E:$ENV{PWD}:g' ${LA_FILE}
|
2015-05-23 19:30:49 +02:00
|
|
|
else
|
|
|
|
echo "$LA_FILE not found"
|
|
|
|
fi
|
|
|
|
fi
|
2015-01-27 08:38:22 +01:00
|
|
|
fi
|
2016-08-26 22:40:28 +02:00
|
|
|
# the rm here is to workaround https://github.com/mapbox/mason/issues/230
|
|
|
|
rm -f ./mason_packages/.link/mason.ini
|
2016-08-13 01:00:21 +02:00
|
|
|
mason link $1 $2
|
2015-01-27 08:38:22 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 03:39:09 +01:00
|
|
|
ICU_VERSION="57.1"
|
2021-04-19 10:03:51 +02:00
|
|
|
BOOST_VERSION="1.75.0"
|
2015-10-07 00:35:44 +02:00
|
|
|
|
2015-01-24 19:05:58 +01:00
|
|
|
function install_mason_deps() {
|
2017-03-19 03:39:09 +01:00
|
|
|
install ccache 3.3.1
|
2017-03-11 01:50:08 +01:00
|
|
|
install zlib 1.2.8
|
|
|
|
install jpeg_turbo 1.5.1 libjpeg
|
|
|
|
install libpng 1.6.28 libpng
|
|
|
|
install libtiff 4.0.7 libtiff
|
2017-03-19 03:39:09 +01:00
|
|
|
install libpq 9.6.2
|
|
|
|
install sqlite 3.17.0 libsqlite3
|
2017-03-11 01:50:08 +01:00
|
|
|
install expat 2.2.0 libexpat
|
|
|
|
install icu ${ICU_VERSION}
|
|
|
|
install proj 4.9.3 libproj
|
|
|
|
install pixman 0.34.0 libpixman-1
|
|
|
|
install cairo 1.14.8 libcairo
|
|
|
|
install webp 0.6.0 libwebp
|
|
|
|
install libgdal 2.1.3 libgdal
|
2017-11-09 21:12:44 +01:00
|
|
|
install boost ${BOOST_VERSION}
|
|
|
|
install boost_libsystem ${BOOST_VERSION}
|
|
|
|
install boost_libfilesystem ${BOOST_VERSION}
|
|
|
|
install boost_libprogram_options ${BOOST_VERSION}
|
|
|
|
install boost_libregex_icu57 ${BOOST_VERSION}
|
2016-08-10 22:36:46 +02:00
|
|
|
# technically boost thread and python are not a core dep, but installing
|
|
|
|
# here by default helps make python-mapnik builds easier
|
2017-11-09 21:12:44 +01:00
|
|
|
install boost_libthread ${BOOST_VERSION}
|
|
|
|
install boost_libpython ${BOOST_VERSION}
|
2017-03-11 01:50:08 +01:00
|
|
|
install freetype 2.7.1 libfreetype
|
|
|
|
install harfbuzz 1.4.4-ft libharfbuzz
|
2015-01-24 19:05:58 +01:00
|
|
|
}
|
|
|
|
|
2015-02-20 21:56:08 +01:00
|
|
|
MASON_LINKED_ABS=$(pwd)/mason_packages/.link
|
|
|
|
MASON_LINKED_REL=./mason_packages/.link
|
2015-04-27 23:14:10 +02:00
|
|
|
export C_INCLUDE_PATH="${MASON_LINKED_ABS}/include"
|
|
|
|
export CPLUS_INCLUDE_PATH="${MASON_LINKED_ABS}/include"
|
|
|
|
export LIBRARY_PATH="${MASON_LINKED_ABS}/lib"
|
2015-02-20 21:56:08 +01:00
|
|
|
|
2015-01-24 19:05:58 +01:00
|
|
|
function make_config() {
|
|
|
|
echo "
|
2016-01-15 00:26:15 +01:00
|
|
|
CXX = '$CXX'
|
|
|
|
CC = '$CC'
|
2016-12-01 18:50:34 +01:00
|
|
|
CUSTOM_CXXFLAGS = '-D_GLIBCXX_USE_CXX11_ABI=0'
|
2015-01-24 19:05:58 +01:00
|
|
|
RUNTIME_LINK = 'static'
|
2015-01-27 23:06:52 +01:00
|
|
|
INPUT_PLUGINS = 'all'
|
2015-01-24 19:18:32 +01:00
|
|
|
PATH = '${MASON_LINKED_REL}/bin'
|
2015-02-03 07:08:52 +01:00
|
|
|
PKG_CONFIG_PATH = '${MASON_LINKED_REL}/lib/pkgconfig'
|
2015-01-24 19:05:58 +01:00
|
|
|
PATH_REMOVE = '/usr:/usr/local'
|
2016-02-09 15:06:09 +01:00
|
|
|
PATH_REPLACE = '$HOME/build/mapbox/mason/mason_packages:./mason_packages'
|
2015-01-24 19:18:32 +01:00
|
|
|
BOOST_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
|
|
BOOST_LIBS = '${MASON_LINKED_REL}/lib'
|
|
|
|
ICU_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
|
|
ICU_LIBS = '${MASON_LINKED_REL}/lib'
|
|
|
|
HB_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
|
|
HB_LIBS = '${MASON_LINKED_REL}/lib'
|
|
|
|
PNG_INCLUDES = '${MASON_LINKED_REL}/include/libpng16'
|
|
|
|
PNG_LIBS = '${MASON_LINKED_REL}/lib'
|
|
|
|
JPEG_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
|
|
JPEG_LIBS = '${MASON_LINKED_REL}/lib'
|
|
|
|
TIFF_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
|
|
TIFF_LIBS = '${MASON_LINKED_REL}/lib'
|
|
|
|
WEBP_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
|
|
WEBP_LIBS = '${MASON_LINKED_REL}/lib'
|
|
|
|
PROJ_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
|
|
PROJ_LIBS = '${MASON_LINKED_REL}/lib'
|
2015-02-20 22:22:23 +01:00
|
|
|
PG_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
|
|
PG_LIBS = '${MASON_LINKED_REL}/lib'
|
2015-01-24 19:18:32 +01:00
|
|
|
FREETYPE_INCLUDES = '${MASON_LINKED_REL}/include/freetype2'
|
|
|
|
FREETYPE_LIBS = '${MASON_LINKED_REL}/lib'
|
2015-01-24 19:05:58 +01:00
|
|
|
SVG_RENDERER = True
|
2015-01-24 19:18:32 +01:00
|
|
|
CAIRO_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
|
|
CAIRO_LIBS = '${MASON_LINKED_REL}/lib'
|
|
|
|
SQLITE_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
|
|
SQLITE_LIBS = '${MASON_LINKED_REL}/lib'
|
2015-02-02 19:30:24 +01:00
|
|
|
BENCHMARK = True
|
2015-01-29 00:05:59 +01:00
|
|
|
CPP_TESTS = True
|
|
|
|
PGSQL2SQLITE = True
|
2015-01-24 19:05:58 +01:00
|
|
|
XMLPARSER = 'ptree'
|
|
|
|
SVG2PNG = True
|
2016-02-09 15:06:09 +01:00
|
|
|
"
|
2015-01-24 19:05:58 +01:00
|
|
|
}
|
|
|
|
|
2015-04-30 16:42:32 +02:00
|
|
|
# NOTE: the `mapnik-settings.env` is used by test/run (which is run by `make test`)
|
2015-01-24 19:18:32 +01:00
|
|
|
function setup_runtime_settings() {
|
2015-04-26 20:32:20 +02:00
|
|
|
echo "export PROJ_LIB=${MASON_LINKED_ABS}/share/proj" > mapnik-settings.env
|
2015-10-07 00:35:44 +02:00
|
|
|
echo "export ICU_DATA=${MASON_LINKED_ABS}/share/icu/${ICU_VERSION}" >> mapnik-settings.env
|
2015-04-26 20:32:20 +02:00
|
|
|
echo "export GDAL_DATA=${MASON_LINKED_ABS}/share/gdal" >> mapnik-settings.env
|
2015-01-24 19:18:32 +01:00
|
|
|
}
|
|
|
|
|
2018-08-01 15:24:34 +02:00
|
|
|
# turn arguments of the form NAME=VALUE into exported variables;
|
|
|
|
# any other arguments are reported and cause error return status
|
|
|
|
function export_variables() {
|
|
|
|
local arg= ret=0
|
|
|
|
for arg
|
|
|
|
do
|
2018-08-24 17:13:41 +02:00
|
|
|
if [[ "$arg" =~ ^[[:alpha:]][_[:alnum:]]*= ]]
|
2018-08-01 15:24:34 +02:00
|
|
|
then
|
2020-01-03 15:38:48 +01:00
|
|
|
export "$arg"
|
2018-08-01 15:24:34 +02:00
|
|
|
else
|
|
|
|
printf >&2 "bootstrap.sh: invalid argument: %s\n" "$arg"
|
|
|
|
ret=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return $ret
|
2015-01-24 19:05:58 +01:00
|
|
|
}
|
|
|
|
|
2018-08-01 15:24:34 +02:00
|
|
|
function main() {
|
|
|
|
export_variables "$@" || return
|
|
|
|
# setup_mason must not run in subshell, because it sets default
|
|
|
|
# values of CC, CXX and adds mason to PATH, which we want to keep
|
|
|
|
# when sourced
|
|
|
|
setup_mason || return
|
|
|
|
(
|
|
|
|
# this is wrapped in subshell to allow sourcing this script
|
|
|
|
# without having the terminal closed on error
|
|
|
|
set -eu
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
install_mason_deps
|
|
|
|
make_config > ./config.py
|
|
|
|
setup_runtime_settings
|
|
|
|
|
|
|
|
printf "\n\e[1;32m%s\e[m\n" "bootstrap successful, now run:"
|
|
|
|
echo ""
|
|
|
|
echo " ./configure && make"
|
|
|
|
echo ""
|
|
|
|
)
|
|
|
|
}
|
2016-08-09 21:17:39 +02:00
|
|
|
|
2018-08-01 15:24:34 +02:00
|
|
|
main "$@"
|