Created
May 23, 2010 01:31
-
-
Save rickosborne/410544 to your computer and use it in GitHub Desktop.
Patch against lstoll's couchdbx-core to allow fine-grained control of 32/64-bit builds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/couchdbx-core-builder.sh b/couchdbx-core-builder.sh | |
index 9196441..8e3c4d6 100755 | |
--- a/couchdbx-core-builder.sh | |
+++ b/couchdbx-core-builder.sh | |
@@ -7,11 +7,17 @@ | |
# customise here: | |
-# use full svn path for branches like "branches/0.9.x" | |
+# Valid repos: "git", "github", "svn" (default) | |
+if [ -z "$COUCHDB_REPO" ]; then | |
+ COUCHDB_REPO="svn" | |
+fi | |
+ | |
+# use just version number like "0.9.x" or "trunk" | |
if [ -z "$COUCHDB_VERSION" ]; then | |
COUCHDB_VERSION="trunk" | |
fi | |
+# use full svn path for branches like "branches/0.9.x" or "trunk" | |
if [ -z "$COUCHDB_SVNPATH" ]; then | |
COUCHDB_SVNPATH="trunk" | |
fi | |
@@ -21,21 +27,50 @@ if [ -z "$ERLANG_VERSION" ]; then | |
ERLANG_VERSION="R13B04" | |
fi | |
+# or 1.7.0 | |
+if [ -z "$JS_VERSION" ]; then | |
+ JS_VERSION="1.8.0-rc1" | |
+fi | |
+ | |
+# to force a build of 32- or 64-bit, set this to 32 or 64, or leave blank for default | |
+if [ -z "$BUILD_BITS"]; then | |
+ BUILD_BITS="" | |
+fi | |
+ | |
# make options | |
MAKE_OPTS="-j4" | |
- | |
# stop customising | |
# internal vars | |
DIRS="src dist" | |
WORKDIR=`pwd` | |
+MBITS="" | |
+BITSUFFIX="" | |
+ERLANGBUILDARCH="" | |
+if [ "$BUILD_BITS" = "32" ]; then | |
+ echo "\n\n Forcing 32-bit build\n\n" | |
+ CC="gcc -m32" | |
+ CXX="g++ -m32" | |
+ ERLANGBUILDARCH="--enable-m32-build --enable-darwin-universal" | |
+ MBITS='-m32' | |
+ BITSUFFIX="_32" | |
+fi | |
+if [ "$BUILD_BITS" = "64" ]; then | |
+ echo "\n\n Forcing 64-bit build\n\n" | |
+ CC="gcc -m64" | |
+ CXX="g++ -m64" | |
+ ERLANGBUILDARCH="--enable-m64-build --enable-darwin-64bit" | |
+ MBITS='-m64' | |
+ BITSUFFIX="_64" | |
+fi | |
+ | |
ERLANGSRCDIR="erlang_$ERLANG_VERSION" | |
-ERLANGDISTDIR="$ERLANGSRCDIR" | |
+ERLANGDISTDIR="$ERLANGSRCDIR$BITSUFFIX" | |
COUCHDBSRCDIR="couchdb_$COUCHDB_VERSION" | |
-COUCHDBDISTDIR="$COUCHDBSRCDIR" | |
+COUCHDBDISTDIR="$COUCHDBSRCDIR$BITSUFFIX" | |
#functions | |
erlang_download() | |
@@ -63,9 +98,7 @@ erlang_install() | |
--enable-hipe \ | |
--enable-dynamic-ssl-lib \ | |
--with-ssl=/usr \ | |
- --without-java \ | |
- --enable-darwin-64bit \ | |
- --enable-m64-build | |
+ --without-java $ERLANGBUILDARCH | |
# skip wxWidgets | |
touch lib/wx/SKIP | |
make # can't have -jN so no $MAKEOPTS | |
@@ -174,12 +207,33 @@ erlang() | |
couchdb_download() | |
{ | |
cd src | |
- if [ ! -d "$COUCHDBSRCDIR" ]; then | |
- svn checkout http://svn.apache.org/repos/asf/couchdb/$COUCHDB_SVNPATH $COUCHDBSRCDIR | |
+ if [ "$COUCHDB_REPO" = "github" ] || [ "$COUCHDB_REPO" = "git" ]; then | |
+ COUCHDBSRCDIR="couchdb_$COUCHDB_REPO" | |
+ if [ ! -d "$COUCHDBSRCDIR" ]; then | |
+ if [ "$COUCHDB_REPO" = "github" ]; then | |
+ git clone git://github.com/apache/couchdb.git "$COUCHDBSRCDIR" | |
+ else | |
+ git clone git://git.apache.org/couchdb.git "$COUCHDBSRCDIR" | |
+ fi | |
+ fi | |
+ cd "$COUCHDBSRCDIR" | |
+ git pull | |
+ git checkout "$COUCHDB_VERSION" | |
+ if [ "$COUCHDB_VERSION" = "trunk" ] || [ "$COUCHDB_VERSION" = "master" ]; then | |
+ COUCHDB_VERSION=`git log -n1 --date=short --format='%cd_%h'` | |
+ COUCHDBDISTDIR="couchdb_$COUCHDB_VERSION$BITSUFFIX" | |
+ fi | |
+ cd .. | |
else | |
+ if [ ! -d "$COUCHDBSRCDIR" ]; then | |
+ svn checkout http://svn.apache.org/repos/asf/couchdb/$COUCHDB_SVNPATH $COUCHDBSRCDIR | |
+ fi | |
svn up $COUCHDBSRCDIR | |
+ if [ "$COUCHDB_VERSION" = "trunk" ]; then | |
+ COUCHDB_VERSION=${COUCHDB_SVNPATH}_`svnversion $COUCHDBSRCDIR` | |
+ COUCHDBDISTDIR="couchdb_$COUCHDB_VERSION$BITSUFFIX" | |
+ fi | |
fi | |
- COUCHDB_VERSION=${COUCHDB_SVNPATH}_`svnversion $COUCHDBSRCDIR` | |
cd .. | |
} | |
@@ -220,7 +274,7 @@ couchdb_link_erl_driver() | |
gcc -I$WORKDIR/src/icu -I/usr/include -L/usr/lib \ | |
-I$WORKDIR/dist/$ERLANGDISTDIR/lib/erlang/usr/include/ \ | |
-lpthread -lm -licucore \ | |
- -flat_namespace -undefined suppress -bundle \ | |
+ -flat_namespace -undefined suppress -bundle $MBITS \ | |
-o couch_icu_driver.so couch_icu_driver.c -fPIC | |
mv couch_icu_driver.so \ | |
../../../../../../dist/$COUCHDBDISTDIR/lib/couchdb/erlang/lib/couch-*/priv/lib | |
@@ -230,7 +284,7 @@ couchdb_link_erl_driver() | |
gcc -I$WORKDIR/src/icu -I/usr/include -L/usr/lib \ | |
-I$WORKDIR/dist/$ERLANGDISTDIR/lib/erlang/usr/include/ \ | |
-lpthread -lm -licucore \ | |
- -flat_namespace -undefined suppress -bundle \ | |
+ -flat_namespace -undefined suppress -bundle $MBITS \ | |
-o couch_erl_driver.so couch_erl_driver.c -fPIC | |
mv couch_erl_driver.so \ | |
../../../../dist/$COUCHDBDISTDIR/lib/couchdb/erlang/lib/couch-*/priv/lib | |
@@ -265,33 +319,34 @@ create_dirs() | |
download_js() | |
{ | |
- if [ ! -e .js-downloaded ]; then | |
+ if [ ! -e .js-$JS_VERSION-downloaded ]; then | |
cd src | |
- if [ ! -e js-1.7.0.tar.gz ]; then | |
- wget http://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz | |
+ if [ ! -e js-$JS_VERSION.tar.gz ]; then | |
+ wget http://ftp.mozilla.org/pub/mozilla.org/js/js-$JS_VERSION.tar.gz | |
fi | |
- tar xzf js-1.7.0.tar.gz | |
- cd .. | |
- touch .js-downloaded | |
+ rm -Rf ./js | |
+ tar xzf js-$JS_VERSION.tar.gz | |
+ cd js/src | |
+ patch -N -p0 < ../../../patches/js/patch-jsprf.c | |
+ cd ../../.. | |
+ touch .js-$JS_VERSION-downloaded | |
fi | |
} | |
install_js() | |
{ | |
- if [ ! -e .js-installed ]; then | |
+ if [ ! -e .js-$JS_VERSION-installed ]; then | |
uname=`uname` | |
if [ "$uname" = "Darwin" ]; then | |
soext="dylib" | |
else | |
soext="so" | |
fi | |
- cd src/js | |
- cd src | |
- patch -N -p0 < ../../../patches/js/patch-jsprf.c | |
+ cd src/js/src | |
make $MAKEOPTS -f Makefile.ref | |
JS_DIST=$WORKDIR/dist/js make -f Makefile.ref export | |
cd ../../../ | |
- touch .js-installed | |
+ touch .js-$JS_VERSION-installed | |
fi | |
} | |
@@ -308,7 +363,7 @@ package() | |
mkdir $PACKAGEDIR | |
cp -r dist/$ERLANGDISTDIR \ | |
dist/$COUCHDBDISTDIR \ | |
- dist/js \ | |
+ src/js \ | |
$PACKAGEDIR | |
install_name_tool -change Darwin_DBG.OBJ/libjs.dylib js/lib/libjs.dylib \ | |
$PACKAGEDIR/$COUCHDBDISTDIR/lib/couchdb/bin/couchjs | |
@@ -337,10 +392,10 @@ bundle_app() | |
cp -r $PACKAGEDIR CouchDBX.app/Contents/Resources/couchdbx-core | |
cd CouchDBX.app/Contents/Resources/couchdbx-core/ | |
rm -rf couchdb | |
- ln -s couchdb_trunk couchdb | |
+ ln -s $COUCHDBDISTDIR couchdb | |
cd ../../../../ | |
- DEST_APP_PATH="CouchDBX-$ERLANG_VERSION-$COUCHDB_VERSION.app" | |
+ DEST_APP_PATH="CouchDBX-$ERLANG_VERSION-$COUCHDB_VERSION$BITSUFFIX.app" | |
mv CouchDBX.app $DEST_APP_PATH | |
mkdir bundle | |
mv $DEST_APP_PATH bundle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment