Revert "Merged all Chromoting Host code into remoting_core.dll (Windows)."
[chromium-blink-merge.git] / native_client_sdk / src / build_tools / nacl-mono-runtime.sh
blob7dfffd871addec265616966e6ab147c8338c3816
1 #!/bin/bash
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 set -o nounset
7 set -o errexit
9 if [[ $# -ne 3 ]]; then
10 echo "Usage: $0 [path_to_mono] [build_dir] [install_dir]"
11 exit -1
14 readonly MONO_DIR=$(readlink -f $1)
15 readonly BUILD_DIR=$(readlink -f $2)
16 readonly INSTALL_DIR=$(readlink -f $3)
17 readonly ORIGINAL_CWD=$(pwd)
19 set +e
20 if [ -f ${BUILD_DIR}/Makefile ]; then
21 cd ${BUILD_DIR}
22 make distclean
24 set -e
25 cd $ORIGINAL_CWD
27 case "${TARGET_ARCH}" in
28 x86-32)
29 readonly USE_PNACL=0
30 readonly NACL_CROSS_PREFIX_DASH=i686-nacl-
31 readonly CONFIG_OPTS="--host=i686-pc-linux-gnu \
32 --build=i686-pc-linux-gnu \
33 --target=i686-pc-linux-gnu"
34 readonly LIBDIR=lib32
35 readonly CUSTOM_CFLAGS=""
36 readonly CUSTOM_LDFLAGS=""
38 x86-64)
39 readonly USE_PNACL=0
40 readonly NACL_CROSS_PREFIX_DASH=x86_64-nacl-
41 readonly CONFIG_OPTS="--host=x86_64-pc-linux-gnu \
42 --build=x86_64-pc-linux-gnu \
43 --target=x86_64-pc-linux-gnu"
44 readonly LIBDIR=lib
45 readonly CUSTOM_CFLAGS=""
46 readonly CUSTOM_LDFLAGS=""
48 arm)
49 readonly USE_PNACL=1
50 readonly NACL_CROSS_PREFIX_DASH=pnacl-
51 readonly PNACL_LINK_ARGS="-arch armv7 -O2"
52 readonly CONFIG_OPTS="--host=armv7l-unknown-linux-gnueabi \
53 --build=x86_64-pc-linux-gnu \
54 --target=armv7l-unknown-linux-gnueabi"
55 readonly LIBDIR=libarm
56 # TODO(olonho): move it to Mono's configure, once nacl target implemented.
57 readonly CUSTOM_CFLAGS="\
58 -D__arm__ \
59 -D__ARM_ARCH_7__ \
60 -D__portable_native_client__ \
61 -DARM_FPU_VFP=1 \
62 -Dtimezone=_timezone \
63 -DDISABLE_SOCKETS \
64 -DDISABLE_ATTACH \
65 -DUSE_NEWLIB \
67 readonly CUSTOM_LDFLAGS=${PNACL_LINK_ARGS}
69 esac
71 # UGLY hack to allow dynamic linking
72 sed -i -e s/elf_i386/elf_nacl/ -e s/elf_x86_64/elf64_nacl/ \
73 ${MONO_DIR}/configure
74 sed -i -e s/elf_i386/elf_nacl/ -e s/elf_x86_64/elf64_nacl/ \
75 ${MONO_DIR}/libgc/configure
76 sed -i -e s/elf_i386/elf_nacl/ -e s/elf_x86_64/elf64_nacl/ \
77 ${MONO_DIR}/eglib/configure
79 rm -rf ${BUILD_DIR}
80 mkdir -p ${BUILD_DIR}
81 cd ${BUILD_DIR}
83 mkdir -p ${INSTALL_DIR}
85 if [ ${USE_PNACL} == 1 ]; then
86 readonly NACL_BIN_PATH="\
87 ${NACL_SDK_ROOT}/toolchain/linux_x86_pnacl/newlib/bin"
88 readonly NACLCC=${NACL_BIN_PATH}/pnacl-clang
89 readonly NACLCXX=${NACL_BIN_PATH}/pnacl-clang++
90 else
91 readonly NACL_BIN_PATH=${NACL_SDK_ROOT}/toolchain/linux_x86_glibc/bin
92 readonly NACLCC=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}gcc
93 readonly NACLCXX=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}g++
95 readonly NACLAR=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ar
96 readonly NACLRANLIB=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ranlib
97 readonly NACLLD=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ld
98 readonly NACLOBJDUMP=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}objdump
99 readonly NACLSTRIP=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}strip
101 CFLAGS="-g -O2 -D_POSIX_PATH_MAX=256 -DPATH_MAX=256 $CUSTOM_CFLAGS"
102 LDFLAGS="$CUSTOM_LDFLAGS"
103 LIBS="-lnacl_dyncode -lc -lg -lnosys -lpthread"
105 CC=${NACLCC} CXX=${NACLCXX} LD=${NACLLD} \
106 STRIP=${NACLSTRIP} AR=${NACLAR} RANLIB=${NACLRANLIB} OBJDUMP=${NACLOBJDUMP} \
107 PKG_CONFIG_LIBDIR= \
108 PATH=${NACL_BIN_PATH}:${PATH} \
109 LIBS="${LIBS}" \
110 CFLAGS="${CFLAGS}" \
111 LDFLAGS="${LDFLAGS}" \
112 ${MONO_DIR}/configure ${CONFIG_OPTS} \
113 --exec-prefix=${INSTALL_DIR} \
114 --libdir=${INSTALL_DIR}/${LIBDIR} \
115 --prefix=${INSTALL_DIR} \
116 --program-prefix=${NACL_CROSS_PREFIX_DASH} \
117 --oldincludedir=${INSTALL_DIR}/include \
118 --with-glib=embedded \
119 --with-tls=pthread \
120 --enable-threads=posix \
121 --without-sigaltstack \
122 --without-mmap \
123 --with-gc=included \
124 --enable-nacl-gc \
125 --with-sgen=no \
126 --enable-nls=no \
127 --enable-nacl-codegen \
128 --disable-system-aot \
129 --enable-shared \
130 --disable-parallel-mark \
131 --with-static-mono=no
133 make
134 make install