summaryrefslogtreecommitdiff
path: root/configure
blob: b818faa07af46f46e6363b25f8050c55b3202245 (plain)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/usr/bin/env bash

set -e
set -o pipefail

CONFIG_FILE=$1

if [ `uname -s` = 'Darwin' ]; then
    MASON_PLATFORM=${MASON_PLATFORM:-osx}
fi

function finish {
    >&2 echo -en "\033[0m";
}
trap finish EXIT

# Install mason
. ./scripts/local_mason.sh

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=0.11.29
        ZLIB_VERSION=system
        BOOST_VERSION=1.57.0
        NUNICODE_VERSION=1.5.1
        LIBZIP_VERSION=0.11.2
        ;;
    *)
        GLFW_VERSION=e1ae9af5
        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=system
        NUNICODE_VERSION=1.5.1
        LIBZIP_VERSION=0.11.2
        ;;
esac

function abort { >&2 echo -e "\033[1m\033[31m$1\033[0m"; exit 1; }

if [ -z ${CONFIG_FILE} ]; then
    abort 'You need to specify an output path for the configuration file'
fi

if [[ ${MASON_PLATFORM} = 'android' && -z ${MASON_ANDROID_ABI} ]]; then
    abort 'You need to specify an ABI for android platforms'
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:])))" "$@"
}

LN=$'\n'

CONFIG="# Do not edit. Generated by the configure script.
{
  'target_defaults': {
    'cflags%': [],
    'default_configuration': 'Release',
    'defines': [],
    'include_dirs': [],
    'libraries': []
  },
  'variables': {
"

if [ ! -z ${BOOST_VERSION} ]; then
    mason install boost ${BOOST_VERSION}
    CONFIG+="    'boost_cflags%': $(quote_flags $(mason cflags boost ${BOOST_VERSION})),"$LN
    CONFIG+="    'boost_ldflags%': $(quote_flags $(mason ldflags boost ${BOOST_VERSION})),"$LN
fi

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

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 [ ! -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

CONFIG+="  }
}
"

echo "${CONFIG}" > ${CONFIG_FILE}
cat ${CONFIG_FILE}