OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # Copyright (c) 2013 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2013 The Native Client Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # Echo the environment variables need to to build/configure standard | 6 # Echo the environment variables need to to build/configure standard |
7 # GNU make/automake/configure projects. e.g. CC, CXX, CFLAGS, etc. | 7 # GNU make/automake/configure projects. e.g. CC, CXX, CFLAGS, etc. |
8 # The values for these variables are calculated based on the following | 8 # The values for these variables are calculated based on the following |
9 # environment variables: | 9 # environment variables: |
10 # | 10 # |
11 # $NACL_ARCH - i386, x86_64, arm or pnacl. Default: x86_64 | 11 # $NACL_ARCH - i386, x86_64, arm, pnacl or le32. Default: x86_64 |
12 # $TOOLCHAIN - clang-newlib, glibc or pnacl. Default: pnacl | 12 # $TOOLCHAIN - clang-newlib, glibc or pnacl. Default: pnacl |
13 # | 13 # |
14 # You can run a command within the NaCl environment | 14 # You can run a command within the NaCl environment |
15 # by passing the command line. e.g: | 15 # by passing the command line. e.g: |
16 # ./webports-env.sh ./configure --host=nacl | 16 # ./webports-env.sh ./configure --host=nacl |
17 # ./webports-env.sh make | 17 # ./webports-env.sh make |
18 # | 18 # |
19 # Alternatively you can see just the essential environment | 19 # Alternatively you can see just the essential environment |
20 # variables by passing --print. This can by used within | 20 # variables by passing --print. This can by used within |
21 # a script using: | 21 # a script using: |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 # Default value for NACL_ARCH | 72 # Default value for NACL_ARCH |
73 NACL_ARCH=${NACL_ARCH:-${DEFAULT_ARCH}} | 73 NACL_ARCH=${NACL_ARCH:-${DEFAULT_ARCH}} |
74 | 74 |
75 # Default Value for TOOLCHAIN | 75 # Default Value for TOOLCHAIN |
76 TOOLCHAIN=${TOOLCHAIN:-pnacl} | 76 TOOLCHAIN=${TOOLCHAIN:-pnacl} |
77 | 77 |
78 # Check NACL_ARCH | 78 # Check NACL_ARCH |
79 if [ ${NACL_ARCH} != "i686" -a ${NACL_ARCH} != "x86_64" -a \ | 79 if [ ${NACL_ARCH} != "i686" -a ${NACL_ARCH} != "x86_64" -a \ |
80 ${NACL_ARCH} != "arm" -a ${NACL_ARCH} != "pnacl" -a \ | 80 ${NACL_ARCH} != "arm" -a ${NACL_ARCH} != "pnacl" -a \ |
81 ${NACL_ARCH} != "emscripten" ]; then | 81 ${NACL_ARCH} != "emscripten" -a ${NACL_ARCH} != "le32" ]; then |
82 echo "Unknown value for NACL_ARCH: '${NACL_ARCH}'" 1>&2 | 82 echo "Unknown value for NACL_ARCH: '${NACL_ARCH}'" 1>&2 |
83 exit 1 | 83 exit 1 |
84 fi | 84 fi |
85 | 85 |
86 # Check TOOLCHAIN | 86 # Check TOOLCHAIN |
87 if [ ${TOOLCHAIN} != "pnacl" -a ${TOOLCHAIN} != "glibc" -a \ | 87 if [ ${TOOLCHAIN} != "pnacl" -a ${TOOLCHAIN} != "glibc" -a \ |
88 ${TOOLCHAIN} != "clang-newlib" -a ${TOOLCHAIN} != "emscripten" ]; then | 88 ${TOOLCHAIN} != "clang-newlib" -a ${TOOLCHAIN} != "emscripten" ]; then |
89 echo "Unknown value for TOOLCHAIN: '${TOOLCHAIN}'" 1>&2 | 89 echo "Unknown value for TOOLCHAIN: '${TOOLCHAIN}'" 1>&2 |
90 exit 1 | 90 exit 1 |
91 fi | 91 fi |
92 | 92 |
93 if [ "${NACL_ARCH}" = "emscripten" -a -z "${EMSCRIPTEN:-}" ]; then | 93 if [ "${NACL_ARCH}" = "emscripten" -a -z "${EMSCRIPTEN:-}" ]; then |
94 echo "-------------------------------------------------------------------" | 94 echo "-------------------------------------------------------------------" |
95 echo "EMSCRIPTEN is unset." | 95 echo "EMSCRIPTEN is unset." |
96 echo "This environment variable needs to be pointed at some version of" | 96 echo "This environment variable needs to be pointed at some version of" |
97 echo "the emscripten repository." | 97 echo "the emscripten repository." |
98 echo "NOTE: set this to an absolute path." | 98 echo "NOTE: set this to an absolute path." |
99 echo "-------------------------------------------------------------------" | 99 echo "-------------------------------------------------------------------" |
100 exit 1 | 100 exit 1 |
101 fi | 101 fi |
102 | 102 |
103 if [ "${TOOLCHAIN}" = "pnacl" ]; then | 103 if [ "${TOOLCHAIN}" = "pnacl" ]; then |
104 if [ "${NACL_ARCH}" != "pnacl" ]; then | 104 if [ "${NACL_ARCH}" != "pnacl" -a "${NACL_ARCH}" != "le32" ]; then |
105 echo "PNaCl does not support the selected architecture: ${NACL_ARCH}" 1>&2 | 105 echo "PNaCl does not support the selected architecture: ${NACL_ARCH}" 1>&2 |
106 exit 1 | 106 exit 1 |
107 fi | 107 fi |
108 fi | 108 fi |
109 | 109 |
110 if [ "${TOOLCHAIN}" = "glibc" ]; then | 110 if [ "${TOOLCHAIN}" = "glibc" ]; then |
111 if [ "${NACL_ARCH}" = "pnacl" ]; then | 111 if [ "${NACL_ARCH}" = "pnacl" ]; then |
112 echo "PNaCl is not supported by the glibc toolchain" 1>&2 | 112 echo "PNaCl is not supported by the glibc toolchain" 1>&2 |
113 exit 1 | 113 exit 1 |
114 fi | 114 fi |
(...skipping 24 matching lines...) Expand all Loading... |
139 elif [ ${NACL_ARCH} = "emscripten" ]; then | 139 elif [ ${NACL_ARCH} = "emscripten" ]; then |
140 NACL_CROSS_PREFIX=emscripten | 140 NACL_CROSS_PREFIX=emscripten |
141 else | 141 else |
142 NACL_CROSS_PREFIX=${NACL_ARCH}-nacl | 142 NACL_CROSS_PREFIX=${NACL_ARCH}-nacl |
143 fi | 143 fi |
144 | 144 |
145 export NACL_LIBC | 145 export NACL_LIBC |
146 export NACL_ARCH | 146 export NACL_ARCH |
147 export NACL_CROSS_PREFIX | 147 export NACL_CROSS_PREFIX |
148 | 148 |
| 149 NACL_EXCEPTIONS_FLAG="" |
| 150 |
149 InitializeNaClGccToolchain() { | 151 InitializeNaClGccToolchain() { |
150 if [ ${NACL_ARCH} = "arm" ]; then | 152 if [ ${NACL_ARCH} = "arm" ]; then |
151 local TOOLCHAIN_ARCH="arm" | 153 local TOOLCHAIN_ARCH="arm" |
152 else | 154 else |
153 local TOOLCHAIN_ARCH="x86" | 155 local TOOLCHAIN_ARCH="x86" |
154 fi | 156 fi |
155 | 157 |
156 local TOOLCHAIN_DIR=${OS_SUBDIR}_${TOOLCHAIN_ARCH}_${NACL_LIBC} | 158 local TOOLCHAIN_DIR=${OS_SUBDIR}_${TOOLCHAIN_ARCH}_${NACL_LIBC} |
157 readonly NACL_TOOLCHAIN_ROOT=${NACL_SDK_ROOT}/toolchain/${TOOLCHAIN_DIR} | 159 readonly NACL_TOOLCHAIN_ROOT=${NACL_SDK_ROOT}/toolchain/${TOOLCHAIN_DIR} |
158 readonly NACL_BIN_PATH=${NACL_TOOLCHAIN_ROOT}/bin | 160 readonly NACL_BIN_PATH=${NACL_TOOLCHAIN_ROOT}/bin |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 local NACL_LIBDIR=x86_64-nacl/lib64 | 244 local NACL_LIBDIR=x86_64-nacl/lib64 |
243 else | 245 else |
244 local NACL_LIBDIR=x86_64-nacl/lib32 | 246 local NACL_LIBDIR=x86_64-nacl/lib32 |
245 fi | 247 fi |
246 else | 248 else |
247 # TODO(sbc): figure our why we do not have a pnacl-strings | 249 # TODO(sbc): figure our why we do not have a pnacl-strings |
248 #NACLSTRINGS=${NACL_BIN_PATH}/pnacl-strings | 250 #NACLSTRINGS=${NACL_BIN_PATH}/pnacl-strings |
249 # until then use the host's strings tool | 251 # until then use the host's strings tool |
250 # (used only by the cairo package) | 252 # (used only by the cairo package) |
251 NACLSTRINGS="$(which strings)" | 253 NACLSTRINGS="$(which strings)" |
| 254 if [ ${NACL_ARCH} = "le32" ]; then |
| 255 NACLSTRINGS=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-strings |
| 256 NACL_EXCEPTIONS_FLAG="-fcxx-exceptions" |
| 257 fi |
252 NACLSTRIP=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-strip | 258 NACLSTRIP=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-strip |
253 NACL_EXEEXT=".pexe" | 259 NACL_EXEEXT=".pexe" |
254 | |
255 # pnacl's translator | 260 # pnacl's translator |
256 TRANSLATOR=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-translate | 261 # This should always be pnacl-translate, pnacl-finalize |
257 PNACLFINALIZE=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-finalize | 262 TRANSLATOR=${NACL_BIN_PATH}/${TOOLCHAIN}-translate |
| 263 PNACLFINALIZE=${NACL_BIN_PATH}/${TOOLCHAIN}-finalize |
258 # pnacl's pexe optimizer | 264 # pnacl's pexe optimizer |
259 PNACL_OPT=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-opt | 265 PNACL_OPT=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX}-opt |
260 | 266 |
261 NACL_SDK_LIBDIR="${NACL_SDK_ROOT}/lib/${TOOLCHAIN}" | 267 NACL_SDK_LIBDIR="${NACL_SDK_ROOT}/lib/${TOOLCHAIN}" |
262 local NACL_LIBDIR=le32-nacl/lib | 268 local NACL_LIBDIR=le32-nacl/lib |
263 fi | 269 fi |
264 | 270 |
265 readonly NACL_SDK_LIB=${NACL_TOOLCHAIN_ROOT}/${NACL_LIBDIR} | 271 readonly NACL_SDK_LIB=${NACL_TOOLCHAIN_ROOT}/${NACL_LIBDIR} |
266 } | 272 } |
267 | 273 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 echo "export PATH=${NACL_PREFIX}/bin:\${PATH}:${NACL_BIN_PATH}" | 345 echo "export PATH=${NACL_PREFIX}/bin:\${PATH}:${NACL_BIN_PATH}" |
340 echo "export CPPFLAGS=\"${NACL_CPPFLAGS}\"" | 346 echo "export CPPFLAGS=\"${NACL_CPPFLAGS}\"" |
341 echo "export ARFLAGS=\"${NACL_ARFLAGS}\"" | 347 echo "export ARFLAGS=\"${NACL_ARFLAGS}\"" |
342 echo "export LDFLAGS=\"${NACL_LDFLAGS}\"" | 348 echo "export LDFLAGS=\"${NACL_LDFLAGS}\"" |
343 else | 349 else |
344 NaClEnvExport | 350 NaClEnvExport |
345 exec "$@" | 351 exec "$@" |
346 fi | 352 fi |
347 fi | 353 fi |
348 fi | 354 fi |
OLD | NEW |