Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9B85010A6D for ; Thu, 6 Feb 2014 17:41:17 +0000 (UTC) Received: (qmail 59014 invoked by uid 500); 6 Feb 2014 17:40:20 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 58402 invoked by uid 500); 6 Feb 2014 17:40:00 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 57746 invoked by uid 99); 6 Feb 2014 17:39:45 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Feb 2014 17:39:45 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 354418A361F; Thu, 6 Feb 2014 17:39:44 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: davisp@apache.org To: commits@couchdb.apache.org Date: Thu, 06 Feb 2014 17:40:24 -0000 Message-Id: <71c6e06f48a9465389cb16602538192a@git.apache.org> In-Reply-To: <30dad969d8734713a3ea4c9b315f7fa7@git.apache.org> References: <30dad969d8734713a3ea4c9b315f7fa7@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [42/50] [abbrv] couch commit: updated refs/heads/import-rcouch to e2dbc79 support static build This change backport the static build from rcouch. A static build of spidermonkey is the default. To build with the libraries installed you can pass the parameter `libs=shared` to the make. By default couch_collate is using ICU installed on the system except if you pass the option `icu=static` to the Make. At anytime you can override the compilation environnement with the following variables: JS_CFLAGS JS_LIBS ICU_CFLAGS ICU_LDFLAGS Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/2a800ac6 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/2a800ac6 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/2a800ac6 Branch: refs/heads/import-rcouch Commit: 2a800ac65d81908e18be7331d3b59cc86f83e9b6 Parents: b7f85c3 Author: benoitc Authored: Wed Jan 8 23:15:49 2014 +0100 Committer: Paul J. Davis Committed: Thu Feb 6 11:38:29 2014 -0600 ---------------------------------------------------------------------- build_spidermonkey.sh | 251 +++ patches/js/patch-configure | 3508 ++++++++++++++++++++++++++++++++++++ patches/js/patch-configure_in | 56 + patches/js/patch-jscntxt_h | 10 + patches/js/patch-jsprf_cpp | 11 + rebar.config.script | 95 +- 6 files changed, 3906 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/2a800ac6/build_spidermonkey.sh ---------------------------------------------------------------------- diff --git a/build_spidermonkey.sh b/build_spidermonkey.sh new file mode 100755 index 0000000..95a15dd --- /dev/null +++ b/build_spidermonkey.sh @@ -0,0 +1,251 @@ +#!/bin/sh + +CORE_TOP=`pwd` +export CORE_TOP + +CURLBIN=`which curl` +if ! test -n "CURLBIN"; then + display_error "Error: curl is required. Add it to 'PATH'" + exit 1 +fi + +GUNZIP=`which gunzip` +UNZIP=`which unzip` +TAR=`which tar` +GNUMAKE=`which gmake 2>/dev/null || which make` +PATCHES=$CORE_TOP/patches +STATICLIBS=$CORE_TOP/.libs +DISTDIR=$CORE_TOP/.dists + +# nspr sources +NSPR_VER=4.8.8 +NSPR_DISTNAME=nspr-$NSPR_VER.tar.gz +NSPR_SITE=http://dl.refuge.io + +# spidermonkey js sources +JS_VER=185-1.0.0 +JS_REALVER=1.8.5 +JS_DISTNAME=js$JS_VER.tar.gz +JS_SITE=http://dl.refuge.io +JSDIR=$STATICLIBS/js-$JS_REALVER +JS_LIBDIR=$STATICLIBS/js/lib +JS_INCDIR=$STATICLIBS/js/include + + +[ "$MACHINE" ] || MACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown" +[ "$RELEASE" ] || RELEASE=`(uname -r) 2>/dev/null` || RELEASE="unknown" +[ "$SYSTEM" ] || SYSTEM=`(uname -s) 2>/dev/null` || SYSTEM="unknown" +[ "$BUILD" ] || VERSION=`(uname -v) 2>/dev/null` || VERSION="unknown" + + +CFLAGS="-g -O2 -Wall" +LDFLAGS="-lstdc++" +ARCH= +ISA64= +GNUMAKE=make +CC=gcc +CXX=g++ +PATCH=patch +case "$SYSTEM" in + Linux) + ARCH=`arch 2>/dev/null` + ;; + FreeBSD|OpenBSD|NetBSD) + ARCH=`(uname -p) 2>/dev/null` + GNUMAKE=gmake + ;; + Darwin) + ARCH=`(uname -p) 2>/dev/null` + ISA64=`(sysctl -n hw.optional.x86_64) 2>/dev/null` + ;; + Solaris) + ARCH=`(uname -p) 2>/dev/null` + GNUMAKE=gmake + PATCH=gpatch + ;; + *) + ARCH="unknown" + ;; +esac + + +# TODO: add mirror & signature validation support +fetch() +{ + TARGET=$DISTDIR/$1 + if ! test -f $TARGET; then + echo "==> Fetch $1 to $TARGET" + $CURLBIN --progress-bar -L $2/$1 -o $TARGET + fi +} + +build_nspr() +{ + NSPR_CONFIGURE_ENV="" + case "$SYSTEM" in + Linux) + ARCH=`arch 2>/dev/null` + if [ "$ARCH" = "x86_64" ]; then + NSPR_CONFIGURE_ENV="--enable-64bit" + fi + CFLAGS="$CFLAGS -lpthread" + ;; + FreeBSD|OpenBSD|NetBSD) + ARCH=`(uname -p) 2>/dev/null` + if [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "amd64" ]; then + NSPR_CONFIGURE_ENV+=--enable-64bit + fi + ;; + Darwin) + if [ "$ISA64" = "1" ]; then + NSPR_CONFIGURE_ENV+=--enable-64bit + fi + ;; + esac + + fetch $NSPR_DISTNAME $NSPR_SITE + + # clean the build + rm -rf $STATICLIBS/nspr* + + echo "==> build nspr" + cd $STATICLIBS + $GUNZIP -c $DISTDIR/$NSPR_DISTNAME | $TAR xf - + + cd $STATICLIBS/nspr-$NSPR_VER/mozilla/nsprpub + ./configure --disable-debug --enable-optimize \ + --prefix=$STATICLIBS/nsprpub $NSPR_CONFIGURE_ENV + + $GNUMAKE all + $GNUMAKE install +} + +build_js() +{ + + fetch $JS_DISTNAME $JS_SITE + + # clean the build + rm -rf $STATICLIBS/js* + + mkdir -p $JS_LIBDIR + mkdir -p $JS_INCDIR + + cd $STATICLIBS + $GUNZIP -c $DISTDIR/$JS_DISTNAME | $TAR -xf - + + echo "==> build js" + cd $JSDIR/js/src + $PATCH -p0 -i $PATCHES/js/patch-jsprf_cpp || echo "skipping patch" + $PATCH -p0 -i $PATCHES/js/patch-configure || echo "skipping patch" + + env CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \ + CPPFLAGS="-DXP_UNIX -DJS_C_STRINGS_ARE_UTF8" \ + ./configure --prefix=$STATICLIBS/js \ + --disable-debug \ + --enable-optimize \ + --enable-static \ + --disable-shared-js \ + --disable-tests \ + --with-system-nspr \ + --with-nspr-prefix=$STATICLIBS/nsprpub && \ + $GNUMAKE all || exit 1 + + mkdir -p $JS_INCDIR/js + cp $JSDIR/js/src/*.h $JS_INCDIR + cp $JSDIR/js/src/*.tbl $JS_INCDIR + cp $JSDIR/js/src/libjs_static.a $JS_LIBDIR +} + + +do_setup() +{ + echo "==> spidermonkey (compile)" + mkdir -p $DISTDIR + mkdir -p $STATICLIBS +} + +do_builddeps() +{ + if [ ! -f $STATICLIBS/nsprpub/lib/libnspr4.a ]; then + build_nspr + fi + + if [ ! -f $STATICLIBS/js/lib/libjs_static.a ]; then + build_js + fi +} + + +clean() +{ + rm -rf $STATICLIBS + rm -rf $DISTDIR +} + + + +usage() +{ + cat << EOF +Usage: $basename [command] [OPTIONS] + +The $basename command compile Mozilla Spidermonkey and ICU statically +for couch_core. + +Commands: + + all: build couch_core static libs + clean: clean static libs + -?: display usage + +Report bugs at . +EOF +} + + +if [ ! "x$COUCHDB_STATIC" = "x1" ]; then + exit 0 +fi + +if [ "x$1" = "x" ]; then + do_setup + do_builddeps + exit 0 +fi + +case "$1" in + all) + shift 1 + do_setup + do_builddeps + ;; + clean) + shift 1 + clean + ;; + js) + shift 1 + do_setup + build_js + ;; + nspr) + shift 1 + do_setup + build_nspr + ;; + help|--help|-h|-?) + usage + exit 0 + ;; + *) + echo $basename: ERROR Unknown command $arg 1>&2 + echo 1>&2 + usage 1>&2 + echo "### $basename: Exitting." 1>&2 + exit 1; + ;; +esac + + +exit 0