You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by be...@apache.org on 2014/01/09 01:08:50 UTC

[95/96] [abbrv] git commit: updated refs/heads/1994-merge-rcouch to 9605700

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/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/79f67b6a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/79f67b6a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/79f67b6a

Branch: refs/heads/1994-merge-rcouch
Commit: 79f67b6a6993c880c05c6a8a28ba4527c01b4020
Parents: 941a823
Author: Benoit Chesneau <be...@apache.org>
Authored: Wed Jan 8 23:15:49 2014 +0100
Committer: Benoit Chesneau <bc...@gmail.com>
Committed: Thu Jan 9 00:59:38 2014 +0100

----------------------------------------------------------------------
 .gitignore                                      |    7 +
 Makefile                                        |   27 +-
 bootstrap                                       |    2 +-
 rebar.config                                    |    1 -
 src/apps/couch/build_spidermonkey.sh            |  251 ++
 src/apps/couch/patches/js/patch-configure       | 3508 +++++++++++++++
 src/apps/couch/patches/js/patch-configure_in    |   56 +
 src/apps/couch/patches/js/patch-jscntxt_h       |   10 +
 src/apps/couch/patches/js/patch-jsprf_cpp       |   11 +
 src/apps/couch/rebar.config.script              |   95 +-
 src/apps/couch_collate/build_icu.sh             |  191 +
 .../patches/icu/common-uloc_c.patch             |   26 +
 .../icu/layout_LookupProcessor_cpp.patch        |   13 +
 .../icu/source_config_Makefile_inc_in.patch     |   12 +
 .../patches/icu/source_icudefs_mk_in.patch      |   19 +
 .../platform/osx/icu/unicode/basictz.h          |  210 +
 .../platform/osx/icu/unicode/brkiter.h          |  557 +++
 .../platform/osx/icu/unicode/calendar.h         | 2170 +++++++++
 .../platform/osx/icu/unicode/caniter.h          |  201 +
 .../platform/osx/icu/unicode/chariter.h         |  716 +++
 .../platform/osx/icu/unicode/choicfmt.h         |  746 +++
 .../platform/osx/icu/unicode/coleitr.h          |  400 ++
 .../platform/osx/icu/unicode/coll.h             | 1035 +++++
 .../platform/osx/icu/unicode/curramt.h          |  130 +
 .../platform/osx/icu/unicode/currunit.h         |  117 +
 .../platform/osx/icu/unicode/datefmt.h          |  700 +++
 .../platform/osx/icu/unicode/dbbi.h             |   41 +
 .../platform/osx/icu/unicode/dcfmtsym.h         |  370 ++
 .../platform/osx/icu/unicode/decimfmt.h         | 1901 ++++++++
 .../platform/osx/icu/unicode/docmain.h          |  202 +
 .../platform/osx/icu/unicode/dtfmtsym.h         |  721 +++
 .../platform/osx/icu/unicode/dtintrv.h          |  159 +
 .../platform/osx/icu/unicode/dtitvfmt.h         |  949 ++++
 .../platform/osx/icu/unicode/dtitvinf.h         |  528 +++
 .../platform/osx/icu/unicode/dtptngen.h         |  423 ++
 .../platform/osx/icu/unicode/dtrule.h           |  250 ++
 .../platform/osx/icu/unicode/fieldpos.h         |  291 ++
 .../platform/osx/icu/unicode/fmtable.h          |  591 +++
 .../platform/osx/icu/unicode/format.h           |  296 ++
 .../platform/osx/icu/unicode/gregocal.h         |  823 ++++
 .../platform/osx/icu/unicode/locid.h            |  765 ++++
 .../platform/osx/icu/unicode/measfmt.h          |   77 +
 .../platform/osx/icu/unicode/measunit.h         |   71 +
 .../platform/osx/icu/unicode/measure.h          |  137 +
 .../platform/osx/icu/unicode/msgfmt.h           |  940 ++++
 .../platform/osx/icu/unicode/normlzr.h          |  823 ++++
 .../platform/osx/icu/unicode/numfmt.h           |  886 ++++
 .../platform/osx/icu/unicode/parseerr.h         |   92 +
 .../platform/osx/icu/unicode/parsepos.h         |  230 +
 .../platform/osx/icu/unicode/platform.h         |  316 ++
 .../platform/osx/icu/unicode/plurfmt.h          |  541 +++
 .../platform/osx/icu/unicode/plurrule.h         |  291 ++
 .../platform/osx/icu/unicode/ppalmos.h          |  273 ++
 .../platform/osx/icu/unicode/putil.h            |  184 +
 .../platform/osx/icu/unicode/pwin32.h           |  311 ++
 .../platform/osx/icu/unicode/rbbi.h             |  722 +++
 .../platform/osx/icu/unicode/rbnf.h             | 1049 +++++
 .../platform/osx/icu/unicode/rbtz.h             |  361 ++
 .../platform/osx/icu/unicode/regex.h            | 1232 +++++
 .../platform/osx/icu/unicode/rep.h              |  259 ++
 .../platform/osx/icu/unicode/resbund.h          |  485 ++
 .../platform/osx/icu/unicode/schriter.h         |  187 +
 .../platform/osx/icu/unicode/search.h           |  569 +++
 .../platform/osx/icu/unicode/simpletz.h         |  927 ++++
 .../platform/osx/icu/unicode/smpdtfmt.h         |  975 ++++
 .../platform/osx/icu/unicode/sortkey.h          |  324 ++
 .../platform/osx/icu/unicode/strenum.h          |  271 ++
 .../platform/osx/icu/unicode/stsearch.h         |  518 +++
 .../platform/osx/icu/unicode/symtable.h         |  112 +
 .../platform/osx/icu/unicode/tblcoll.h          |  926 ++++
 .../platform/osx/icu/unicode/timezone.h         |  803 ++++
 .../platform/osx/icu/unicode/translit.h         | 1323 ++++++
 .../platform/osx/icu/unicode/tzrule.h           |  828 ++++
 .../platform/osx/icu/unicode/tztrans.h          |  195 +
 .../platform/osx/icu/unicode/ubidi.h            | 2013 +++++++++
 .../platform/osx/icu/unicode/ubrk.h             |  482 ++
 .../platform/osx/icu/unicode/ucal.h             | 1161 +++++
 .../platform/osx/icu/unicode/ucasemap.h         |  391 ++
 .../platform/osx/icu/unicode/ucat.h             |  158 +
 .../platform/osx/icu/unicode/uchar.h            | 3062 +++++++++++++
 .../platform/osx/icu/unicode/uchriter.h         |  381 ++
 .../platform/osx/icu/unicode/uclean.h           |  267 ++
 .../platform/osx/icu/unicode/ucnv.h             | 1967 ++++++++
 .../platform/osx/icu/unicode/ucnv_cb.h          |  162 +
 .../platform/osx/icu/unicode/ucnv_err.h         |  463 ++
 .../platform/osx/icu/unicode/ucol.h             | 1132 +++++
 .../platform/osx/icu/unicode/ucoleitr.h         |  315 ++
 .../platform/osx/icu/unicode/uconfig.h          |  228 +
 .../platform/osx/icu/unicode/ucsdet.h           |  349 ++
 .../platform/osx/icu/unicode/ucurr.h            |  270 ++
 .../platform/osx/icu/unicode/udat.h             |  962 ++++
 .../platform/osx/icu/unicode/udata.h            |  389 ++
 .../platform/osx/icu/unicode/udatpg.h           |  471 ++
 .../platform/osx/icu/unicode/udeprctd.h         |   50 +
 .../platform/osx/icu/unicode/udraft.h           |  166 +
 .../platform/osx/icu/unicode/uenum.h            |  134 +
 .../platform/osx/icu/unicode/uidna.h            |  312 ++
 .../platform/osx/icu/unicode/uintrnal.h         |  180 +
 .../platform/osx/icu/unicode/uiter.h            |  707 +++
 .../platform/osx/icu/unicode/uloc.h             | 1046 +++++
 .../platform/osx/icu/unicode/ulocdata.h         |  192 +
 .../platform/osx/icu/unicode/umachine.h         |  338 ++
 .../platform/osx/icu/unicode/umisc.h            |   60 +
 .../platform/osx/icu/unicode/umsg.h             |  647 +++
 .../platform/osx/icu/unicode/unifilt.h          |  127 +
 .../platform/osx/icu/unicode/unifunct.h         |  125 +
 .../platform/osx/icu/unicode/unimatch.h         |  163 +
 .../platform/osx/icu/unicode/unirepl.h          |   97 +
 .../platform/osx/icu/unicode/uniset.h           | 1566 +++++++
 .../platform/osx/icu/unicode/unistr.h           | 4230 ++++++++++++++++++
 .../platform/osx/icu/unicode/unorm.h            |  576 +++
 .../platform/osx/icu/unicode/unum.h             |  869 ++++
 .../platform/osx/icu/unicode/uobject.h          |  308 ++
 .../platform/osx/icu/unicode/uobslete.h         |   32 +
 .../platform/osx/icu/unicode/urbtok.h           |  126 +
 .../platform/osx/icu/unicode/uregex.h           |  989 ++++
 .../platform/osx/icu/unicode/urename.h          | 1775 ++++++++
 .../platform/osx/icu/unicode/urep.h             |  155 +
 .../platform/osx/icu/unicode/ures.h             |  871 ++++
 .../platform/osx/icu/unicode/uscript.h          |  254 ++
 .../platform/osx/icu/unicode/usearch.h          |  766 ++++
 .../platform/osx/icu/unicode/uset.h             | 1052 +++++
 .../platform/osx/icu/unicode/usetiter.h         |  318 ++
 .../platform/osx/icu/unicode/ushape.h           |  263 ++
 .../platform/osx/icu/unicode/usprep.h           |  156 +
 .../platform/osx/icu/unicode/ustring.h          | 1479 ++++++
 .../platform/osx/icu/unicode/usystem.h          |   46 +
 .../platform/osx/icu/unicode/utext.h            | 1562 +++++++
 .../platform/osx/icu/unicode/utf.h              |  227 +
 .../platform/osx/icu/unicode/utf16.h            |  605 +++
 .../platform/osx/icu/unicode/utf32.h            |   23 +
 .../platform/osx/icu/unicode/utf8.h             |  652 +++
 .../platform/osx/icu/unicode/utf_old.h          | 1171 +++++
 .../platform/osx/icu/unicode/utmscale.h         |  481 ++
 .../platform/osx/icu/unicode/utrace.h           |  358 ++
 .../platform/osx/icu/unicode/utrans.h           |  583 +++
 .../platform/osx/icu/unicode/utypes.h           |  801 ++++
 .../platform/osx/icu/unicode/uversion.h         |  275 ++
 .../platform/osx/icu/unicode/vtzone.h           |  443 ++
 src/apps/couch_collate/rebar.config.script      |   66 +-
 src/support/build_js.escript                    |    0
 141 files changed, 78760 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/79f67b6a/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index bf1f2e9..fc9b019 100644
--- a/.gitignore
+++ b/.gitignore
@@ -148,6 +148,8 @@ support/rebar/.test
 src/apps/couch_collate/ebin
 src/apps/couch_collate/priv
 src/apps/couch_collate/c_src/*.o
+src/apps/couch_collate/.libs
+src/apps/couch_collate/.dists
 
 src/apps/couch/ebin
 src/apps/couch_replicator/ebin
@@ -163,3 +165,8 @@ src/apps/couch/c_src/couch_js/config.h
 src/apps/couch/priv/couchjs
 src/apps/couch/c_src/spawnkillable/*.o
 src/apps/couch/priv/couchspawnkillable
+src/apps/couch/.libs
+src/apps/couch/.dists
+
+src/share/server/main-coffee.js
+src/share/server/main.js

http://git-wip-us.apache.org/repos/asf/couchdb/blob/79f67b6a/Makefile
----------------------------------------------------------------------
diff --git a/Makefile b/Makefile
index 0c36ffc..2b09f43 100644
--- a/Makefile
+++ b/Makefile
@@ -1,30 +1,45 @@
 BASE_DIR = $(shell pwd)
 ERLANG_BIN = $(shell dirname $(shell which erl))
+GIT_BIN = $(shell dirname $(shell which git))
 REBAR ?= $(BASE_DIR)/rebar
 OVERLAY_VARS ?=
 
 $(if $(ERLANG_BIN),,$(warning "Warning: No Erlang found in your path, this will probably not work"))
 
+$(if $(GIT_BIN),,$(warning "Warning: No Git found in your path, this will probably not work"))
+
+
 .PHONY: rel deps
 
+COUCHDB_STATIC=1
+ifeq ($(libs), shared)
+	COUCHDB_STATIC=0
+endif
+export COUCHDB_STATIC
+
+USE_STATIC_ICU=0
+ifeq ($(icu), static)
+	USE_STATIC_ICU=1
+endif
+export USE_STATIC_ICU
+
 all: deps compile
 
 compile:
-	./rebar compile
+	@./rebar compile
 
 deps:
-	./rebar get-deps
+	@./rebar get-deps
 
 clean:
-	./rebar clean
+	@./rebar clean
 
 distclean: clean relclean
 
 generate:
-	./rebar generate $(OVERLAY_VARS)
+	@./rebar generate $(OVERLAY_VARS)
 
 rel: deps compile generate
 
 relclean:
-	rm -rf rel/apache-couchdb
-
+	@rm -rf rel/apache-couchdb

http://git-wip-us.apache.org/repos/asf/couchdb/blob/79f67b6a/bootstrap
----------------------------------------------------------------------
diff --git a/bootstrap b/bootstrap
index 4e2a42f..38db553 100755
--- a/bootstrap
+++ b/bootstrap
@@ -65,7 +65,7 @@ fi
 sed "s/%revision%/$REVISION/" < pkg.vars.config.in > pkg.vars.config
 
 # build rebar
-export SUPPORT_DIR=$CURRENT/support
+export SUPPORT_DIR=$CURRENT/src/support
 ESCRIPT=`find_program escript`
 ERLC=`find_program erlc`
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/79f67b6a/rebar.config
----------------------------------------------------------------------
diff --git a/rebar.config b/rebar.config
index f33cca6..8950111 100644
--- a/rebar.config
+++ b/rebar.config
@@ -33,7 +33,6 @@
     {jiffy, ".*", {git, "git://github.com/refuge/jiffy.git", "master"}}
 ]}.
 
-{lib_dirs, ["src/apps", "src/deps"]}.
 
 {deps_dir, ["src/deps"]}.
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/79f67b6a/src/apps/couch/build_spidermonkey.sh
----------------------------------------------------------------------
diff --git a/src/apps/couch/build_spidermonkey.sh b/src/apps/couch/build_spidermonkey.sh
new file mode 100755
index 0000000..95a15dd
--- /dev/null
+++ b/src/apps/couch/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 <https://github.com/refuge/couch_core>.
+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