add C lib package
[couchdbimport.git] / CouchProjects / build.sh
blob9080bc4fc5d3a6ea130f215c0ae2e31d26efb20f
1 #!/bin/sh
2 GCC=`which gcc`
3 export GCC
5 CPP=`which g++`
6 export CPP
8 MAKE=`which make`
9 export MAKE
13 HOST=`/usr/bin/uname`
14 export HOST
16 BUILD_DIR=build
17 export BUILD_DIR
19 COUCHDB_VERSION=`cat ./version`
20 export COUCHDB_VERSION
22 COUCH_DIR=build/couch-$COUCHDB_VERSION/ebin
23 COUCHDB_INSTALL_DIR=/usr/local/
26 ERLANG_LIB_DIR=false
27 INSTALL_COUCHDB=false
28 BUILD_FABRIC_TESTS=false
29 # taken from autoconf
30 while test $# != 0; do
31 case $1 in
32 --*=*)
33 ac_option=`expr "x$1" : 'x\([^=]*\)='`
34 ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
35 ac_shift=:
37 -*)
38 ac_option=$1
39 ac_optarg=$2
40 ac_shift=shift
42 *) # This is not an option, so the user has probably given explicit
43 # arguments.
44 ac_option=$1
45 ac_need_defaults=false;;
46 esac
48 case $ac_option in
49 --with-fabric-tests)
50 echo "Building CouchDb with Fabric Tests"
51 BUILD_FABRIC_TESTS=true
54 --install)
55 INSTALL_COUCHDB=true
56 COUCHDB_INSTALL_DIR=$ac_optarg
57 if [ -z "$COUCHDB_INSTALL_DIR" ]; then
58 COUCHDB_INSTALL_DIR=/usr/local
59 export COUCHDB_INSTALL_DIR
63 --with-erlang)
64 ERLANG_LIB_DIR=$ac_optarg
65 export ERLANG_LIB_DIR
66 ;;
69 --help)
70 echo "Available options: --install which installs CouchDb and --with-fabric-tests that additionally builds the FabricTests. --with-erlang"
71 exit 0;
74 -*)
75 echo "Unkown option $ac_option. Try --help"
76 exit 1;
77 esac
78 shift
79 done
82 if [ "$ERLANG_BIN_DIR" != "false" ]; then
83 ERLC=$ERLANG_BIN_DIR/erlc
84 export ERLC
85 ERL=$ERLANG_BIN_DIR/erl
86 export ERL
89 if [ -z "$ERLC" ]; then
90 ERLC=`which erlc`
91 export ERLC
94 if [ ! -x "$ERLC" ]; then
95 echo "Cannot find erlc. Please set ERLANG_BIN_DIR manually. (e.g. export ERLANG_BIN_DIR=/usr/local/erlang/bin)"
96 exit 1
99 if [ ! -x "$ERL" ]; then
100 echo "Cannot find erl. Please set ERLANG_BIN_DIR manually. (e.g. export ERLANG_BIN_DIR=/usr/local/erlang/bin)"
101 exit 1
104 if [ -z "$ERLANG_INCLUDE_DIR" ]; then
105 ERLANG_INCLUDE_DIR=/usr/include
106 export ERLANG_INCLUDE_DIR
109 if [ ! -e "$ERLANG_INCLUDE_DIR/erl_driver.h" ]; then
110 ERLANG_INCLUDE_DIR=/usr/lib/erlang/usr/include/
111 export ERLANG_INCLUDE_DIR
113 echo "Cannot find erl_driver.h. Please set ERLANG_INCLUDE_DIR manually and make sure it points to the directory that contains erl_driver.h. (e.g. export ERLANG_INCLUDE_DIR=/usr/local/erlang/usr/include/)"
114 exit 1
117 if [ ! -d "$COUCH_DIR" ]; then
118 mkdir -p $COUCH_DIR
121 COUCH_BIG_ENDIAN=`uname -a|grep powerpc`;
123 if [ ! -z "$COUCH_BIG_ENDIAN" ]; then
124 COUCH_BIG_ENDIAN=true
125 export COUCH_BIG_ENDIAN
130 if [ "$BUILD_FABRIC_TESTS" = "true" ]; then
131 $MAKE $BUILD_DIR/FabricTests
132 exit 0
135 if [ "$INSTALL_COUCHDB" = "true" ]; then
137 # if [ $ERLANG_LIB_DIR = "false" ]; then
138 # echo "Please specify the Erlang lib directory with the --with-erlang=/path/to/erlang option"
139 # exit 1;
140 # fi
141 # echo $ERLANG_LIB_DIR
143 echo "Installing CouchDb into $COUCHDB_INSTALL_DIR"
145 if [ -d "$COUCHDB_INSTALL_DIR/couchdb" ]; then
146 rm -rf "$COUCHDB_INSTALL_DIR/old.couchdb"
147 mv "$COUCHDB_INSTALL_DIR/couchdb" "$COUCHDB_INSTALL_DIR/old.couchdb"
150 mkdir -p $COUCHDB_INSTALL_DIR/couchdb
153 COUCHDB_INSTALL_DIR=$COUCHDB_INSTALL_DIR/couchdb
154 export COUCHDB_INSTALL_DIR
156 $MAKE install
157 exit 0
160 $MAKE $J couchdb