Debian Codegraph @

testsuite/emscripten/build.sh

raw
1 #!/usr/bin/env bash
2
3 if ! [ -x "$(command -v emcc)" ]; then
4 echo "Error: emcc could not be found." >&2
5 exit 1
6 fi
7
8 set -e
9
10 SOURCE_DIR=$PWD
11
12 # Working directories
13 TARGET=$SOURCE_DIR/target
14 mkdir -p "$TARGET"
15
16 # Define default arguments
17 DEBUG=false
18
19 # Parse arguments
20 while [ $# -gt 0 ]; do
21 case $1 in
22 --debug) DEBUG=true ;;
23 *) echo "ERROR: Unknown parameter: $1" >&2; exit 1 ;;
24 esac
25 shift
26 done
27
28 # Common compiler flags
29 export CFLAGS="-O3 -fPIC"
30 if [ "$DEBUG" = "true" ]; then export CFLAGS+=" -DDEBUG_F"; fi
31 export CXXFLAGS="$CFLAGS"
32
33 # Build paths
34 export CPATH="$TARGET/include"
35 export PKG_CONFIG_PATH="$TARGET/lib/pkgconfig"
36 export EM_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
37
38 # Specific variables for cross-compilation
39 export CHOST="${TARGET_HOST}-unknown-linux" # wasm32-unknown-emscripten
40
41 autoreconf -fiv
42 emconfigure ./configure --host=$CHOST --prefix="$TARGET" --enable-static --disable-shared --disable-dependency-tracking \
43 --disable-builddir --disable-multi-os-directory --disable-raw-api --disable-docs ${EXTRA_CONFIGURE_FLAGS}
44 make install
45 cp fficonfig.h target/include/
46 cp include/ffi_common.h target/include/