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.
9 if [[ $# -ne 3 ]]; then
10 echo "Usage: $0 [path_to_mono] [build_dir] [install_dir]"
17 readonly MONO_DIR
=$
(readlink
-f $1)
18 readonly BUILD_DIR
=$
(readlink
-f $2)
19 readonly INSTALL_DIR
=$
(readlink
-f $3)
20 readonly ORIGINAL_CWD
=$
(pwd)
23 if [ -f ${BUILD_DIR}/Makefile
-a ${CLEAN} != 0 ]; then
30 case "${TARGET_ARCH}" in
34 readonly TC_FLAVOUR
=linux_x86_glibc
35 readonly NACL_CROSS_PREFIX_DASH
=i686-nacl-
36 CONFIG_OPTS
="--host=i686-pc-linux-gnu \
37 --build=i686-pc-linux-gnu \
38 --target=i686-pc-linux-gnu"
41 readonly CUSTOM_LDFLAGS
=""
46 readonly TC_FLAVOUR
=linux_x86_glibc
47 readonly NACL_CROSS_PREFIX_DASH
=x86_64-nacl-
48 CONFIG_OPTS
="--host=x86_64-pc-linux-gnu \
49 --build=x86_64-pc-linux-gnu \
50 --target=x86_64-pc-linux-gnu"
53 readonly CUSTOM_LDFLAGS
=""
58 readonly TC_FLAVOUR
=linux_arm_newlib
59 readonly NACL_CROSS_PREFIX_DASH
=arm-nacl-
60 CONFIG_OPTS
="--host=armv7l-unknown-linux-gnueabi \
61 --build=x86_64-pc-linux-gnu \
62 --target=armv7l-unknown-linux-gnueabi \
63 --with-jumptables=yes"
64 readonly LIBDIR
=libarm
65 # TODO(olonho): move it to Mono's configure, once nacl target implemented.
69 -Dtimezone=_timezone \
73 readonly CUSTOM_LDFLAGS
=""
78 readonly TC_FLAVOUR
=linux_pnacl
79 readonly NACL_CROSS_PREFIX_DASH
=pnacl-
80 readonly PNACL_LINK_ARGS
="-arch armv7 -O2"
81 CONFIG_OPTS
="--host=armv7l-unknown-linux-gnueabi \
82 --build=x86_64-pc-linux-gnu \
83 --target=armv7l-unknown-linux-gnueabi \
84 --with-jumptables=yes"
85 readonly LIBDIR
=libarm
86 # TODO(olonho): move it to Mono's configure, once nacl target implemented.
90 -D__portable_native_client__ \
92 -Dtimezone=_timezone \
96 readonly CUSTOM_LDFLAGS
=${PNACL_LINK_ARGS}
99 echo "Unsupported target ${TARGET_ARCH}"
103 if [ ${USE_NEWLIB} == 1 ]; then
104 CUSTOM_CFLAGS
="${CUSTOM_CFLAGS} -DUSE_NEWLIB"
105 CONFIG_OPTS
="${CONFIG_OPTS} --enable-shared=no"
107 CONFIG_OPTS
="${CONFIG_OPTS} --enable-shared=yes"
108 # UGLY hack to allow dynamic linking
109 sed -i -e s
/elf_i386
/elf_nacl
/ -e s
/elf_x86_64
/elf64_nacl
/ \
110 ${MONO_DIR}/configure
111 sed -i -e s
/elf_i386
/elf_nacl
/ -e s
/elf_x86_64
/elf64_nacl
/ \
112 ${MONO_DIR}/libgc
/configure
113 sed -i -e s
/elf_i386
/elf_nacl
/ -e s
/elf_x86_64
/elf64_nacl
/ \
114 ${MONO_DIR}/eglib
/configure
117 if [ ${CLEAN} != 0 ]; then
119 mkdir
-p ${BUILD_DIR}
123 mkdir
-p ${INSTALL_DIR}
125 readonly NACL_BIN_PATH
=${NACL_SDK_ROOT}/toolchain
/${TC_FLAVOUR}/bin
127 if [ ${USE_PNACL} == 1 ]; then
128 readonly NACLCC
=${NACL_BIN_PATH}/pnacl-clang
129 readonly NACLCXX
=${NACL_BIN_PATH}/pnacl-clang
++
131 readonly NACLCC
=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}gcc
132 readonly NACLCXX
=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}g
++
134 readonly NACLAR
=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ar
135 readonly NACLRANLIB
=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ranlib
136 readonly NACLLD
=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ld
137 readonly NACLOBJDUMP
=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}objdump
138 readonly NACLSTRIP
=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}strip
140 if [ ${DEBUG} == 1 ]; then
141 CFLAGS
="$CUSTOM_CFLAGS"
142 CONFIG_OPTS
="${CONFIG_OPTS} --enable-debug=yes"
144 CFLAGS
="-g $CUSTOM_CFLAGS"
145 CONFIG_OPTS
="${CONFIG_OPTS} --enable-debug=no"
148 if [ ${PARALLEL} == 1 ]; then
155 LDFLAGS
="$CUSTOM_LDFLAGS"
156 LIBS
="-lnacl_dyncode -lc -lg -lnosys -lpthread"
158 CC
=${NACLCC} CXX=${NACLCXX} LD=${NACLLD} \
159 STRIP
=${NACLSTRIP} AR=${NACLAR} RANLIB=${NACLRANLIB} OBJDUMP=${NACLOBJDUMP} \
161 PATH
=${NACL_BIN_PATH}:${PATH} \
164 LDFLAGS
="${LDFLAGS}" \
165 ${MONO_DIR}/configure
${CONFIG_OPTS} \
166 --exec-prefix=${INSTALL_DIR} \
167 --libdir=${INSTALL_DIR}/${LIBDIR} \
168 --prefix=${INSTALL_DIR} \
169 --program-prefix=${NACL_CROSS_PREFIX_DASH} \
170 --oldincludedir=${INSTALL_DIR}/include \
171 --with-glib=embedded \
173 --enable-threads=posix \
174 --without-sigaltstack \
180 --enable-nacl-codegen \
181 --disable-system-aot \
182 --disable-parallel-mark \
183 --with-static-mono=no
185 if [ ${USE_NEWLIB} == 1 ]; then
186 # Newlib build doesn't support building shared libs, and unfortunately, this
187 # leads to libmonoruntime.la no being built as well, unless we'll do that
189 make ${JOBS} -C mono
/metadata libmonoruntime.la