summaryrefslogtreecommitdiffstats
path: root/nacl-configure
blob: 1dc1c146e6bbd1f50e4a8365ce640035e7aa4091 (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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
#!/bin/bash
# This scripts generates a configure line for Qt on NaCl.

# Require that NACL_SDK_ROOT is set.
if [[ -z "$NACL_SDK_ROOT" ]]
then
    echo ""
    echo Set NACL_SDK_ROOT before running nacl-configure.
    echo Example: export NACL_SDK_ROOT=/Users/USER/code/nacl_sdk/pepper_35
    echo ""
    exit
fi

# Require that $NACL_SDK_ROOT exists on disk.
if [ ! -d "$NACL_SDK_ROOT" ]; then
    echo ""
    echo Directory not found: $NACL_SDK_ROOT. Check NACL_SDK_ROOT.
    echo ""
    exit
fi

# simple mac/linux detection
platform='mac'
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
   platform='linux'
fi

# Require a toolchain as argument
if [ $# -eq 0 ]
  then
    echo ""
    echo "No arguments supplied. Usage:"
    echo "\"nacl-configure <tooolchain> [release|debug] [32|64|PNACL_ARCH]"
    echo "Toolchain is one of:"
    echo "    ${platform}_arm_newlib"
    echo "    ${platform}_pnacl"
    echo "    ${platform}_x86_glibc"
    echo "    ${platform}_x86_newlib"
    echo "    emscripten"
    echo "    host"
    echo ""
    echo "For the pnacl toolchain PNACL_ARCH can be empty for the default"
    echo "PNaCl build, or one of:"
    echo "    x86-32"
    echo "    x86-64"
    echo "    arm"
    echo ""
    exit
fi

# QtBase and configure script location. Look for ../configure first,
# use the qtbase configure if not found.
QTBASE="$(dirname $0)"
CONFIGURE="$QTBASE/../configure"
if [ ! -f $CONFIGURE ]; then
   CONFIGURE="$QTBASE/configure"
fi

# Argument 1: Which toolchain?
TOOLCHAIN=$1
shift

# Argument 2: release/debug build (release default)
OPTIMIZE=$1
if [ -z "$OPTIMIZE" ]; then
    OPTIMIZE="release"
else
    shift
fi

# Argument 3: 32/64 bit build (64-bit default), or PNaCl native arch
BITS=$1
if [[ $BITS == "64" ]]; then
    shift
elif [[ $BITS == "32" ]]; then
    shift
elif [[ $TOOLCHAIN == *pnacl ]]; then
    shift
else
    BITS=64
    shift
fi

# set up for passing the rest of the args to configure
ARG_REST=$@

# Extract parts from the toolchain
# PNACL: pnacl|<blank>
# ARCH : x86|arm
# CLIB : glibc|newlib

if [[ $TOOLCHAIN == *pnacl ]]
  then
    PNACL="pnacl"
fi
if [[ $TOOLCHAIN == *x86* ]]
  then
    ARCH="x86"
fi
if [[ $TOOLCHAIN == *arm* ]]
  then
    ARCH="arm"
fi
if [[ $TOOLCHAIN == *newlib* ]]
  then
    CLIB="newlib"
fi
if [[ $TOOLCHAIN == *glibc* ]]
  then
    CLIB="glibc"
fi
if [[ $TOOLCHAIN == emscripten ]]
  then
    PNACL=""
    CLIB=""
    ARCH=""
fi
if [[ $TOOLCHAIN == host ]]
  then
    PNACL=""
    CLIB=""
    ARCH=""
fi

# Select a mkspec, which can be one of:
# nacl-arm-newlib-g++
# nacl-x86-glibc-g++-32
# nacl-x86-glibc-g++-64
# nacl-x86-newlib-g++-32
# nacl-x86-newlib-g++.-64
# pnacl-newlib-clang
# pnacl-newlib-clang-x86_32
# pnacl-newlib-clang-x86_64
# pnacl-newlib-clang-arm

# Map the selected toolchain to a mkspec.
if [[ $TOOLCHAIN == *arm_newlib ]]
  then
    QT_MKSPEC="nacl-arm-newlib-g++"
fi
if [[ $TOOLCHAIN == *pnacl ]]
  then
    if [[ -z "$BITS" ]]
      then
        QT_MKSPEC="pnacl-newlib-clang"
    else
        QT_MKSPEC="pnacl-newlib-clang-$BITS"
    fi
fi
if [[ $TOOLCHAIN == *x86_glibc ]]
  then
    QT_MKSPEC="nacl-x86-glibc-g++-$BITS"
fi
if [[ $TOOLCHAIN == *x86_newlib ]]
  then
    QT_MKSPEC="nacl-x86-newlib-g++-$BITS"
fi
if [[ $TOOLCHAIN == emscripten ]]
  then
    QT_MKSPEC="nacl-emscripten"
fi
if [[ $TOOLCHAIN == host ]]
  then
    QT_MKSPEC=""
fi
if [[ -z "$QT_MKSPEC" ]]; then
    QT_PLATFPORM=""
else
    QT_PLATFPORM="-xplatform unsupported/$QT_MKSPEC"
fi

# Map the toolchain and bits to a lib directory. One of:
# glibc_x86_32
# glibc_x86_64
# newlib_arm
# newlib_x86_32
# newlib_x86_64
# pnacl
# clang-newlib_arm
# clang-newlib_x86_32
# clang-newlib_x86_64

if [[ $PNACL == pnacl ]]
  then
    if [[ -z "$BITS" ]]
      then
        LIBDIR="pnacl"                  # standard pnacl
    else
        LIBDIR="clang-newlib_${BITS}"   # using one of the native compilers from the
    fi                                  # pnacl toolchain.
else
    LIBDIR="${CLIB}_${ARCH}"
fi

if [[ $ARCH == x86 ]]
  then
      LIBDIR="${LIBDIR}_${BITS}"
fi

if [[ $TOOLCHAIN == emscripten ]]
  then
      LIBDIR="pnacl"
fi

if [[ $TOOLCHAIN == host ]]
  then
    LIBDIR==""
fi

# Assemble command-line options for the configure line
NACL_CONFIGURE_LINE="$CONFIGURE"
# mkspec and nacl toolchain path

# Qt platform and toolchain setup
if [[ $TOOLCHAIN != host ]]; then
    NACL_CONFIGURE_LINE="$NACL_CONFIGURE_LINE $QT_PLATFPORM"
    if [[ $TOOLCHAIN != emscripten ]]; then
        NACL_CONFIGURE_LINE="$NACL_CONFIGURE_LINE -device-option NACL_SDK_BIN=$NACL_SDK_ROOT/toolchain/$TOOLCHAIN/bin/"
    fi
fi

# Include and lib dirs
if [[ $TOOLCHAIN != host ]]; then
    NACL_CONFIGURE_LINE="$NACL_CONFIGURE_LINE -device-option NACL_SDK_INCLUDE=$NACL_SDK_ROOT/include"
    if [[ $TOOLCHAIN != emscripten ]]; then
        NACL_CONFIGURE_LINE="$NACL_CONFIGURE_LINE -device-option NACL_SDK_LIB=$NACL_SDK_ROOT/lib/$LIBDIR/Release"
    fi
fi

# developer build
NACL_CONFIGURE_LINE="$NACL_CONFIGURE_LINE -developer-build -opensource -confirm-license -no-headersclean -nomake examples -nomake tests"

# disable sse
if [[ $TOOLCHAIN != "host" ]]; then
    NACL_CONFIGURE_LINE="$NACL_CONFIGURE_LINE -no-sse2"
fi
# misc
NACL_CONFIGURE_LINE="$NACL_CONFIGURE_LINE -no-qpa-platform-guard -skip xmlpatterns -no-warnings-are-errors -no-qml-debug -no-dbus"

# Newlib is static builds only.
if [[ $QT_MKSPEC == *newlib* ]]
  then
    NACL_CONFIGURE_LINE="$NACL_CONFIGURE_LINE -static"
fi

# C++11 is broken on pnacl, see Chromium bug 314944
if [[ $QT_MKSPEC == *pnacl* ]]
  then
    NACL_CONFIGURE_LINE="$NACL_CONFIGURE_LINE -no-c++11"
fi

# emscripten has several x11 headers but no x11 support
# (that we want to use). this makes several configure tests
# pass and produces a broken build.
if [[ $TOOLCHAIN == emscripten ]]
  then
    NACL_CONFIGURE_LINE="$NACL_CONFIGURE_LINE -no-xlib -no-xcb-xlib -no-eglfs"
    # emscripten needs to enforce OpenGL ES 2
    NACL_CONFIGURE_LINE="$NACL_CONFIGURE_LINE -opengl es2"
    # emscripten needs a static build for plugins to work properly
    NACL_CONFIGURE_LINE="$NACL_CONFIGURE_LINE -static"
fi

# set release/debug build
NACL_CONFIGURE_LINE="$NACL_CONFIGURE_LINE -$OPTIMIZE"

# add extra arguments
NACL_CONFIGURE_LINE="$NACL_CONFIGURE_LINE $ARG_REST"

# ### WORKAROUND: re-configuring breaks if mkspecs/qconfig.pri is present
rm qtbase/mkspecs/qconfig.pri
# Make configure work on compiler upgrades (For example: Xcode.app -> XcodeBeta.app)
rm qtbase/.qmake.cache
touch qtbase/.qmake.cache

echo $NACL_CONFIGURE_LINE

# Run configure
$NACL_CONFIGURE_LINE