Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/nacl
diff options
context:
space:
mode:
authorElijah Taylor <elijahtaylor@google.com>2013-02-01 00:13:21 +0400
committerZoltan Varga <vargaz@gmail.com>2013-03-21 08:16:55 +0400
commit99f40ae5bb013e1c2f7b341b9ad9719cf2b72d29 (patch)
treefc092b75b3444678623a92807184375aac4a1cdd /nacl
parent391e857c5b3c397cb00476be2ae3fb1258e863b6 (diff)
Add NaCl build scripts
Diffstat (limited to 'nacl')
-rw-r--r--nacl/README2
-rw-r--r--nacl/common.sh217
-rw-r--r--nacl/config-nacl-runtime.cache19
-rw-r--r--nacl/config-nacl-runtime64.cache19
-rwxr-xr-xnacl/nacl-runtime-mono.sh82
-rwxr-xr-xnacl/nacl_interp_loader_sdk.sh56
6 files changed, 395 insertions, 0 deletions
diff --git a/nacl/README b/nacl/README
new file mode 100644
index 00000000000..03a77babafd
--- /dev/null
+++ b/nacl/README
@@ -0,0 +1,2 @@
+Building NaCl Mono with glibc (newlib support is eliminated but should still be buildable with small effort) is complex. Instructions live here for the adventurous: https://docs.google.com/a/google.com/document/d/1Jd_4M7mlmxF8daVbepAy_8RKYcRbhifXanRYyBKkVa4/pub
+
diff --git a/nacl/common.sh b/nacl/common.sh
new file mode 100644
index 00000000000..65e7dc7a4ad
--- /dev/null
+++ b/nacl/common.sh
@@ -0,0 +1,217 @@
+# Copyright (c) 2011 The Native Client Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that be
+# found in the LICENSE file.
+#
+
+set -o nounset
+set -o errexit
+
+# scripts that source this file must be run from within packages tree
+readonly SAVE_PWD=$(pwd)
+
+# Pick platform directory for compiler.
+readonly OS_NAME=$(uname -s)
+if [ $OS_NAME = "Darwin" ]; then
+ readonly OS_SUBDIR="mac"
+ readonly OS_SUBDIR_SHORT="mac"
+elif [ $OS_NAME = "Linux" ]; then
+ readonly OS_SUBDIR="linux"
+ readonly OS_SUBDIR_SHORT="linux"
+else
+ readonly OS_SUBDIR="windows"
+ readonly OS_SUBDIR_SHORT="win"
+fi
+
+readonly MACHINE=$(uname -m)
+if [ $MACHINE = "x86_64" ]; then
+ readonly TARGET_BITSIZE=${TARGET_BITSIZE:-"64"}
+ readonly HOST_BITSIZE=${HOST_BITSIZE:-"64"}
+else
+ # uname -m reports i686 on Linux and i386 on Mac
+ readonly TARGET_BITSIZE=${TARGET_BITSIZE:-"32"}
+ readonly HOST_BITSIZE=${HOST_BITSIZE:-"32"}
+fi
+
+if [ $TARGET_BITSIZE == "64" ]; then
+ readonly TARGET_BIT_PREFIX="64"
+ readonly CROSS_ID=x86_64
+else
+ readonly TARGET_BIT_PREFIX=""
+ readonly CROSS_ID=i686
+fi
+# we might want to override the detected host platform (e.g. on OSX 10.6)
+if [ $HOST_BITSIZE == "64" ]; then
+ readonly HOST_BIT_PREFIX="64"
+else
+ readonly HOST_BIT_PREFIX=""
+fi
+
+export NACL_CROSS_PREFIX=${CROSS_ID}-nacl
+export NACL_CROSS_PREFIX_DASH=${NACL_CROSS_PREFIX}-
+
+readonly NACL_NEWLIB=${NACL_NEWLIB:-"0"}
+
+if [ $NACL_NEWLIB = "1" ]; then
+ readonly NACL_SDK_BASE=${NACL_SDK_ROOT}/toolchain/${OS_SUBDIR_SHORT}_x86_newlib
+else
+case "${NACL_SDK_ROOT}" in
+*pepper_15* | *pepper_16* | *pepper_17*)
+ readonly NACL_SDK_BASE=${NACL_SDK_ROOT}/toolchain/${OS_SUBDIR_SHORT}_x86
+ ;;
+*)
+ readonly NACL_SDK_BASE=${NACL_SDK_ROOT}/toolchain/${OS_SUBDIR_SHORT}_x86_glibc
+ ;;
+esac
+fi
+
+readonly NACL_BIN_PATH=${NACL_SDK_BASE}/bin
+export NACLCC=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}gcc
+export NACLCXX=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}g++
+export NACLAR=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ar
+export NACLRANLIB=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ranlib
+export NACLLD=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ld
+export NACLAS=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}as
+
+# NACL_SDK_GCC_SPECS_PATH is where nacl-gcc 'specs' file will be installed
+readonly NACL_SDK_GCC_SPECS_PATH=${NACL_SDK_BASE}/lib/gcc/x86_64-nacl/4.4.3
+
+# NACL_SDK_USR is where the headers, libraries, etc. will be installed
+readonly NACL_SDK_USR=${NACL_SDK_BASE}/${NACL_CROSS_PREFIX}/usr
+readonly NACL_SDK_USR_INCLUDE=${NACL_SDK_USR}/include
+readonly NACL_SDK_USR_LIB=${NACL_SDK_USR}/lib
+
+
+######################################################################
+# Helper functions
+######################################################################
+
+Banner() {
+ echo "######################################################################"
+ echo $*
+ echo "######################################################################"
+}
+
+
+VerifyPath() {
+ # make sure path isn't all slashes (possibly from an unset variable)
+ local PATH=$1
+ local TRIM=${PATH##/}
+ if [ ${#TRIM} -ne 0 ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+
+ChangeDir() {
+ local NAME=$1
+ if VerifyPath ${NAME}; then
+ cd ${NAME}
+ else
+ echo "ChangeDir called with bad path."
+ exit -1
+ fi
+}
+
+
+Remove() {
+ local NAME=$1
+ if VerifyPath ${NAME}; then
+ rm -rf ${NAME}
+ else
+ echo "Remove called with bad path."
+ exit -1
+ fi
+}
+
+
+MakeDir() {
+ local NAME=$1
+ if VerifyPath ${NAME}; then
+ mkdir -p ${NAME}
+ else
+ echo "MakeDir called with bad path."
+ exit -1
+ fi
+}
+
+
+PatchSpecFile() {
+ # fix up spaces so gcc sees entire path
+ local SED_SAFE_SPACES_USR_INCLUDE=${NACL_SDK_USR_INCLUDE/ /\ /}
+ local SED_SAFE_SPACES_USR_LIB=${NACL_SDK_USR_LIB/ /\ /}
+ # have nacl-gcc dump specs file & add include & lib search paths
+ ${NACL_SDK_BASE}/bin/x86_64-nacl-gcc -dumpspecs |\
+ sed "/*cpp:/{
+ N
+ s|$| -I${SED_SAFE_SPACES_USR_INCLUDE}|
+ }" |\
+ sed "/*link_libgcc:/{
+ N
+ s|$| -L${SED_SAFE_SPACES_USR_LIB}|
+ }" >${NACL_SDK_GCC_SPECS_PATH}/specs
+}
+
+
+DefaultConfigureStep() {
+ Banner "Configuring ${PACKAGE_NAME}"
+ # export the nacl tools
+ export CC=${NACLCC}
+ export CXX=${NACLCXX}
+ export AR=${NACLAR}
+ export RANLIB=${NACLRANLIB}
+ export PKG_CONFIG_PATH=${NACL_SDK_USR_LIB}/pkgconfig
+ export PKG_CONFIG_LIBDIR=${NACL_SDK_USR_LIB}
+ export PATH=${NACL_BIN_PATH}:${PATH};
+ ChangeDir ${NACL_PACKAGES_REPOSITORY}/${PACKAGE_NAME}
+ Remove ${PACKAGE_NAME}-build
+ MakeDir ${PACKAGE_NAME}-build
+ cd ${PACKAGE_NAME}-build
+ ../configure \
+ --host=nacl \
+ --disable-shared \
+ --prefix=${NACL_SDK_USR} \
+ --exec-prefix=${NACL_SDK_USR} \
+ --libdir=${NACL_SDK_USR_LIB} \
+ --oldincludedir=${NACL_SDK_USR_INCLUDE} \
+ --with-http=off \
+ --with-html=off \
+ --with-ftp=off \
+ --with-x=no
+}
+
+
+DefaultBuildStep() {
+ # assumes pwd has makefile
+ make clean
+if [ $TARGET_BITSIZE == "64" ]; then
+ make -j8
+else
+ make
+fi
+}
+
+
+DefaultInstallStep() {
+ # assumes pwd has makefile
+ make install
+}
+
+
+DefaultCleanUpStep() {
+ PatchSpecFile
+ ChangeDir ${SAVE_PWD}
+}
+
+
+DefaultPackageInstall() {
+ DefaultPreInstallStep
+ DefaultDownloadStep
+ DefaultExtractStep
+ DefaultPatchStep
+ DefaultConfigureStep
+ DefaultBuildStep
+ DefaultInstallStep
+ DefaultCleanUpStep
+}
diff --git a/nacl/config-nacl-runtime.cache b/nacl/config-nacl-runtime.cache
new file mode 100644
index 00000000000..4bd26c474f8
--- /dev/null
+++ b/nacl/config-nacl-runtime.cache
@@ -0,0 +1,19 @@
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+ac_cv_func_mmap=${ac_cv_func_mmap=no}
+ac_cv_var_timezone=${ac_cv_var_timezone=yes}
+ac_cv_host=${ac_cv_host=i686-pc-nacl}
+ac_cv_target=${ac_cv_target=i686-pc-nacl}
+ac_cv_func_backtrace_symbols=${ac_cv_func_backtrace_symbols=no}
+mono_cv_uscore=${mono_cv_uscore=no}
diff --git a/nacl/config-nacl-runtime64.cache b/nacl/config-nacl-runtime64.cache
new file mode 100644
index 00000000000..b952fef84c6
--- /dev/null
+++ b/nacl/config-nacl-runtime64.cache
@@ -0,0 +1,19 @@
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+ac_cv_func_mmap=${ac_cv_func_mmap=no}
+ac_cv_var_timezone=${ac_cv_var_timezone=yes}
+ac_cv_host=${ac_cv_host=x86_64-pc-nacl}
+ac_cv_target=${ac_cv_target=x86_64-pc-nacl}
+ac_cv_func_backtrace_symbols=${ac_cv_func_backtrace_symbols=no}
+mono_cv_uscore=${mono_cv_uscore=no}
diff --git a/nacl/nacl-runtime-mono.sh b/nacl/nacl-runtime-mono.sh
new file mode 100755
index 00000000000..d93bb975463
--- /dev/null
+++ b/nacl/nacl-runtime-mono.sh
@@ -0,0 +1,82 @@
+#!/bin/bash
+# Copyright (c) 2009 The Native Client Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that be
+# found in the LICENSE file.
+#
+
+# nacl-runtime-mono.sh
+#
+# usage: nacl-runtime-mono.sh
+#
+# this script builds mono runtime for Native Client
+#
+
+readonly MONO_TRUNK_NACL=$(pwd)
+
+source common.sh
+
+readonly PACKAGE_NAME=runtime${TARGET_BIT_PREFIX}-build
+readonly INSTALL_PATH=${MONO_TRUNK_NACL}/naclmono-${CROSS_ID}
+
+
+CustomConfigureStep() {
+ Banner "Configuring ${PACKAGE_NAME}"
+ # export the nacl tools
+ set +e
+ if [ -f ${PACKAGE_NAME}/Makefile ]
+ then
+ cd ${PACKAGE_NAME}
+ fi
+ make distclean
+ cd ${MONO_TRUNK_NACL}
+ set -e
+ if [ $TARGET_BITSIZE == "32" ]; then
+ CONFIG_OPTS="--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --target=i686-pc-linux-gnu"
+ else
+ CONFIG_OPTS="--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu"
+ fi
+ # UGLY hack to allow dynamic linking
+ sed -i -e s/elf_i386/elf_nacl/ -e s/elf_x86_64/elf64_nacl/ ../configure
+ sed -i -e s/elf_i386/elf_nacl/ -e s/elf_x86_64/elf64_nacl/ ../libgc/configure
+ sed -i -e s/elf_i386/elf_nacl/ -e s/elf_x86_64/elf64_nacl/ ../eglib/configure
+ Remove ${PACKAGE_NAME}
+ MakeDir ${PACKAGE_NAME}
+ cd ${PACKAGE_NAME}
+ CC=${NACLCC} CXX=${NACLCXX} AR=${NACLAR} RANLIB=${NACLRANLIB} PKG_CONFIG_PATH=${NACL_SDK_USR_LIB}/pkgconfig LD="${NACLLD}" \
+ PKG_CONFIG_LIBDIR=${NACL_SDK_USR_LIB} PATH=${NACL_BIN_PATH}:${PATH} LIBS="-lnacl_dyncode -lc -lg -lnosys -lnacl" \
+ CFLAGS="-g -O2 -D_POSIX_PATH_MAX=256 -DPATH_MAX=256" ../../configure \
+ ${CONFIG_OPTS} \
+ --exec-prefix=${INSTALL_PATH} \
+ --libdir=${INSTALL_PATH}/lib \
+ --prefix=${INSTALL_PATH} \
+ --program-prefix="" \
+ --oldincludedir=${INSTALL_PATH}/include \
+ --with-glib=embedded \
+ --with-tls=pthread \
+ --enable-threads=posix \
+ --without-sigaltstack \
+ --without-mmap \
+ --with-gc=included \
+ --enable-nacl-gc \
+ --with-sgen=no \
+ --enable-nls=no \
+ --enable-nacl-codegen \
+ --disable-system-aot \
+ --enable-shared \
+ --disable-parallel-mark \
+ --with-static-mono=no
+
+}
+
+CustomInstallStep() {
+ make install
+}
+
+CustomPackageInstall() {
+ CustomConfigureStep
+ DefaultBuildStep
+ CustomInstallStep
+}
+
+CustomPackageInstall
+exit 0
diff --git a/nacl/nacl_interp_loader_sdk.sh b/nacl/nacl_interp_loader_sdk.sh
new file mode 100755
index 00000000000..1e4bd31c9b1
--- /dev/null
+++ b/nacl/nacl_interp_loader_sdk.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+# Copyright (c) 2012 The Native Client Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# Usage: nacl_interp_loader.sh PLATFORM NEXE ARGS...
+
+# Assumes this file is sitting in the source tree.
+# This should be changed for some proper SDK installation setup.
+NACL_SDK_ROOT=${NACL_SDK_ROOT:-/path/to/naclsdk/pepper_XX}
+
+case "$1" in
+i?86)
+ arch=x86_32
+ libdir=lib32
+ ;;
+x86_64)
+ arch=x86_64
+ libdir=lib64
+ ;;
+arm|v7l)
+ arch=arm
+ libdir=lib32
+ ;;
+*)
+ echo >&2 "$0: Do not recognize architecture \"$1\""
+ exit 127
+ ;;
+esac
+
+shift
+
+case "${NACL_SDK_ROOT}" in
+*pepper_15* | *pepper_16* | *pepper_17*)
+ SEL_LDR="$NACL_SDK_ROOT/toolchain/linux_x86/bin/sel_ldr_${arch}"
+ IRT="$NACL_SDK_ROOT/toolchain/linux_x86/runtime/irt_core_${arch}.nexe"
+ RTLD="$NACL_SDK_ROOT/toolchain/linux_x86/x86_64-nacl/${libdir}/runnable-ld.so"
+ LIBDIR="$NACL_SDK_ROOT/toolchain/linux_x86/x86_64-nacl/${libdir}"
+ ;;
+*)
+ SEL_LDR="$NACL_SDK_ROOT/tools/sel_ldr_${arch}"
+ IRT="$NACL_SDK_ROOT/tools/irt_core_${arch}.nexe"
+ RTLD="$NACL_SDK_ROOT/toolchain/linux_x86_glibc/x86_64-nacl/${libdir}/runnable-ld.so"
+ LIBDIR="$NACL_SDK_ROOT/toolchain/linux_x86_glibc/x86_64-nacl/${libdir}"
+ ;;
+esac
+
+IGNORE_VALIDATOR_ARG=""
+if [ x"$NACL_IGNORE_VALIDATOR" == x"1" ]; then
+ IGNORE_VALIDATOR_ARG="-c"
+fi
+
+exec "$SEL_LDR" -E "NACL_PWD=`pwd`" -E "MONO_PATH=$MONO_PATH" \
+ -E "MONO_CFG_DIR=$MONO_CFG_DIR" -E "MONO_SHARED_DIR=$MONO_SHARED_DIR" \
+ -a $IGNORE_VALIDATOR_ARG -S -B "$IRT" -l /dev/null -- "$RTLD" \
+ --library-path $LIBDIR "$@"