diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-08-03 17:04:31 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-08-04 14:08:58 +0200 |
commit | e6053aa5475e03568f39e4967dc49ef4aba3c5fe (patch) | |
tree | 0b8fa3e3f5159f28210ff2c0611d8900d9577006 /configure | |
parent | b44fe1c7af889089a640097583add8cd90e9330a (diff) | |
download | qtlocation-mapboxgl-e6053aa5475e03568f39e4967dc49ef4aba3c5fe.tar.gz |
Make build system architecture agnostic to remove Android special case
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 207 |
1 files changed, 56 insertions, 151 deletions
@@ -1,89 +1,63 @@ #!/usr/bin/env bash -set -e -set -o pipefail +set -euo pipefail CONFIG_FILE=$1 -if [ `uname -s` = 'Darwin' ]; then - MASON_PLATFORM=${MASON_PLATFORM:-osx} +if [ -z ${CONFIG_FILE} ]; then + abort 'You need to specify an output path for the configuration file' fi -function finish { - >&2 echo -en "\033[0m"; -} -trap finish EXIT +# Make sure we clear all colors +trap '>&2 echo -en "\033[0m"' TERM INT + +function abort { >&2 echo -e "\033[1m\033[31m$1\033[0m"; exit 1; } +function info { >&2 echo -e "\033[1m\033[33m$1\033[0m"; } +function warn { >&2 echo -e "\033[1m\033[33m$1\033[0m"; } # Install mason -git submodule update --init .mason export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" -case ${MASON_PLATFORM} in - 'ios') - SQLITE_VERSION=system - LIBUV_VERSION=0.10.28 - ZLIB_VERSION=system - BOOST_VERSION=system - ;; - 'android') - SQLITE_VERSION=3.8.8.1 - LIBPNG_VERSION=1.6.16 - LIBJPEG_VERSION=v9a - OPENSSL_VERSION=1.0.1l - LIBCURL_VERSION=7.40.0 - LIBUV_VERSION=1.4.0 - ZLIB_VERSION=system - BOOST_VERSION=1.57.0 - NUNICODE_VERSION=1.5.1 - LIBZIP_VERSION=0.11.2 - ;; - *) - GLFW_VERSION=3.1 - SQLITE_VERSION=3.8.8.1 - LIBPNG_VERSION=1.6.16 - LIBJPEG_VERSION=v9a - LIBCURL_VERSION=system - LIBUV_VERSION=0.10.28 - ZLIB_VERSION=system - BOOST_VERSION=1.57.0 - BOOST_PROGRAM_OPTIONS_VERSION=1.57.0 - NUNICODE_VERSION=1.5.1 - LIBZIP_VERSION=0.11.2 - ;; -esac - -if [ ${MASON_PLATFORM} == 'linux' ] ; then - MESA_VERSION=10.4.3 - mason install mesa ${MESA_VERSION} - export PKG_CONFIG_PATH=`mason prefix mesa ${MESA_VERSION}`/lib/pkgconfig -fi +# You can override the function for a particular set of flags by defining a +# print_XXX_flags function in your dependencies.sh file +function print_flags { + local NAME=$1; shift + if [ "$(type -t print_${NAME}_flags)" = 'function' ]; then + print_${NAME}_flags + else + local VERSION=`echo "${NAME}_VERSION" | tr "[:lower:]" "[:upper:]"` + if [ ! -z ${!VERSION:-} ] ; then + mason install ${NAME} ${!VERSION} + for FLAGS in "$@" ; do + CONFIG+=" '${NAME}_${FLAGS}%': $(quote_flags $(mason ${FLAGS} ${NAME} ${!VERSION})),"$LN + done + else + warn "* Not using ${NAME}" + fi + fi +} -function abort { >&2 echo -e "\033[1m\033[31m$1\033[0m"; exit 1; } +function print_default_flags { + : +} -if [ -z ${CONFIG_FILE} ]; then - abort 'You need to specify an output path for the configuration file' -fi +function print_opengl_flags { + CONFIG+=" 'opengl_cflags%': [],"$LN + CONFIG+=" 'opengl_ldflags%': [],"$LN +} -if [[ ${MASON_PLATFORM} = 'android' && -z ${MASON_ANDROID_ABI} ]]; then - abort 'You need to specify an ABI for android platforms' +# Load dependencies +source scripts/${MASON_PLATFORM}/configure.sh +if [ -e scripts/${MASON_PLATFORM}/${MASON_PLATFORM_VERSION}/configure.sh ]; then + source scripts/${MASON_PLATFORM}/${MASON_PLATFORM_VERSION}/configure.sh fi -echo -n "MASON_PLATFORM=${MASON_PLATFORM} " -if [ ${MASON_PLATFORM} = 'android' ]; then echo -n "MASON_ANDROID_ABI=${MASON_ANDROID_ABI} " ; fi -echo $0 $@ - PYTHON=`which python || abort 'Cannot find python'` >&2 echo -en "\033[1m\033[32m* Using " >&2 ${PYTHON} --version >&2 echo -en "\033[0m"; -PKG_CONFIG=`which pkg-config || abort 'Cannot find pkg-config'` - ->&2 echo -en "\033[1m\033[32m* Using pkg-config " ->&2 ${PKG_CONFIG} --version ->&2 echo -en "\033[0m"; - function quote_flags { ${PYTHON} -c "import sys, re; print filter(None, re.split('(?<!-framework)\s+', ' '.join(sys.argv[1:])))" "$@" } @@ -97,102 +71,33 @@ CONFIG="# Do not edit. Generated by the configure script. 'default_configuration': 'Release', 'defines': [], 'include_dirs': [], - 'libraries': [] - }, - 'variables': { + 'libraries': [], " -if [ ! -z ${BOOST_VERSION} ]; then - mason install boost ${BOOST_VERSION} - CONFIG+=" 'boost_cflags%': $(quote_flags $(mason cflags boost ${BOOST_VERSION})),"$LN -fi +print_default_flags -if [ ! -z ${BOOST_PROGRAM_OPTIONS_VERSION} ]; then - mason install boost_libprogram_options ${BOOST_PROGRAM_OPTIONS_VERSION} - CONFIG+=" 'boost_program_options_static_libs%': $(quote_flags $(mason static_libs boost_libprogram_options ${BOOST_VERSION})),"$LN -fi +CONFIG+=" },"$LN +CONFIG+=" 'variables': {"$LN -if [ ! -z ${OPENSSL_VERSION} ]; then - mason install openssl ${OPENSSL_VERSION} - CONFIG+=" 'openssl_static_libs%': $(quote_flags $(mason static_libs openssl ${OPENSSL_VERSION})),"$LN - CONFIG+=" 'openssl_cflags%': $(quote_flags $(mason cflags openssl ${OPENSSL_VERSION})),"$LN - CONFIG+=" 'openssl_ldflags%': $(quote_flags $(mason ldflags openssl ${OPENSSL_VERSION})),"$LN -fi +print_opengl_flags -if [ ! -z ${LIBCURL_VERSION} ]; then - mason install libcurl ${LIBCURL_VERSION} - CONFIG+=" 'curl_static_libs%': $(quote_flags $(mason static_libs libcurl ${LIBCURL_VERSION})),"$LN - CONFIG+=" 'curl_cflags%': $(quote_flags $(mason cflags libcurl ${LIBCURL_VERSION})),"$LN - CONFIG+=" 'curl_ldflags%': $(quote_flags $(mason ldflags libcurl ${LIBCURL_VERSION})),"$LN -fi - -if [ ! -z ${GLFW_VERSION} ]; then - mason install glfw ${GLFW_VERSION} - CONFIG+=" 'glfw3_static_libs%': $(quote_flags $(mason static_libs glfw ${GLFW_VERSION})),"$LN - CONFIG+=" 'glfw3_cflags%': $(quote_flags $(mason cflags glfw ${GLFW_VERSION})),"$LN - CONFIG+=" 'glfw3_ldflags%': $(quote_flags $(mason ldflags glfw ${GLFW_VERSION})),"$LN -fi - -if [ ${MASON_PLATFORM} == 'linux' ]; then - CONFIG+=" 'opengl_cflags%': $(quote_flags $(pkg-config gl x11 --cflags)),"$LN - CONFIG+=" 'opengl_ldflags%': $(quote_flags $(pkg-config gl x11 --libs)),"$LN -else - CONFIG+=" 'opengl_cflags%': $(quote_flags),"$LN - CONFIG+=" 'opengl_ldflags%': $(quote_flags),"$LN -fi - -if [ ! -z ${LIBPNG_VERSION} ]; then - mason install libpng ${LIBPNG_VERSION} - CONFIG+=" 'png_static_libs%': $(quote_flags $(mason static_libs libpng ${LIBPNG_VERSION})),"$LN - CONFIG+=" 'png_cflags%': $(quote_flags $(mason cflags libpng ${LIBPNG_VERSION})),"$LN - CONFIG+=" 'png_ldflags%': $(quote_flags $(mason ldflags libpng ${LIBPNG_VERSION})),"$LN -fi - -if [ ! -z ${LIBJPEG_VERSION} ]; then - mason install jpeg ${LIBJPEG_VERSION} - CONFIG+=" 'jpeg_static_libs%': $(quote_flags $(mason static_libs jpeg ${LIBJPEG_VERSION})),"$LN - CONFIG+=" 'jpeg_cflags%': $(quote_flags $(mason cflags jpeg ${LIBJPEG_VERSION})),"$LN - CONFIG+=" 'jpeg_ldflags%': $(quote_flags $(mason ldflags jpeg ${LIBJPEG_VERSION})),"$LN -fi - -if [ ! -z ${SQLITE_VERSION} ]; then - mason install sqlite ${SQLITE_VERSION} - CONFIG+=" 'sqlite3_static_libs%': $(quote_flags $(mason static_libs sqlite ${SQLITE_VERSION})),"$LN - CONFIG+=" 'sqlite3_cflags%': $(quote_flags $(mason cflags sqlite ${SQLITE_VERSION})),"$LN - CONFIG+=" 'sqlite3_ldflags%': $(quote_flags $(mason ldflags sqlite ${SQLITE_VERSION})),"$LN -fi - -if [ ! -z ${LIBUV_VERSION} ]; then - mason install libuv ${LIBUV_VERSION} - CONFIG+=" 'uv_static_libs%': $(quote_flags $(mason static_libs libuv ${LIBUV_VERSION})),"$LN - CONFIG+=" 'uv_cflags%': $(quote_flags $(mason cflags libuv ${LIBUV_VERSION})),"$LN - CONFIG+=" 'uv_ldflags%': $(quote_flags $(mason ldflags libuv ${LIBUV_VERSION})),"$LN -fi - -if [ ! -z ${ZLIB_VERSION} ]; then - mason install zlib ${ZLIB_VERSION} - CONFIG+=" 'zlib_static_libs%': $(quote_flags $(mason static_libs zlib ${ZLIB_VERSION})),"$LN - CONFIG+=" 'zlib_cflags%': $(quote_flags $(mason cflags zlib ${ZLIB_VERSION})),"$LN - CONFIG+=" 'zlib_ldflags%': $(quote_flags $(mason ldflags zlib ${ZLIB_VERSION})),"$LN -fi - -if [ ! -z ${NUNICODE_VERSION} ]; then - mason install nunicode ${NUNICODE_VERSION} - CONFIG+=" 'nu_static_libs%': $(quote_flags $(mason static_libs nunicode ${NUNICODE_VERSION})),"$LN - CONFIG+=" 'nu_cflags%': $(quote_flags $(mason cflags nunicode ${NUNICODE_VERSION})),"$LN - CONFIG+=" 'nu_ldflags%': $(quote_flags $(mason ldflags nunicode ${NUNICODE_VERSION})),"$LN -fi - -if [ ! -z ${LIBZIP_VERSION} ]; then - mason install libzip ${LIBZIP_VERSION} - CONFIG+=" 'zip_static_libs%': $(quote_flags $(mason static_libs libzip ${LIBZIP_VERSION})),"$LN - CONFIG+=" 'zip_cflags%': $(quote_flags $(mason cflags libzip ${LIBZIP_VERSION})),"$LN - CONFIG+=" 'zip_ldflags%': $(quote_flags $(mason ldflags libzip ${LIBZIP_VERSION})),"$LN -fi +print_flags boost cflags +print_flags boost_libprogram_options static_libs +print_flags openssl static_libs cflags ldflags +print_flags libcurl static_libs cflags ldflags +print_flags glfw static_libs cflags ldflags +print_flags libpng static_libs cflags ldflags +print_flags jpeg static_libs cflags ldflags +print_flags sqlite static_libs cflags ldflags +print_flags libuv static_libs cflags ldflags +print_flags zlib static_libs cflags ldflags +print_flags nunicode static_libs cflags ldflags +print_flags libzip static_libs cflags ldflags CONFIG+=" } } " +mkdir -p $(dirname "${CONFIG_FILE}") echo "${CONFIG}" > ${CONFIG_FILE} cat ${CONFIG_FILE} |