Add Lucene Indexer Control
[couchdbimport.git] / CouchProjects / build.sh
blobf2e4e460c92eb1c9c72602dbf18c0b681dddb19d
1 #!/bin/sh
2 GCC=`which gcc`
3 export GCC
5 CPP=`which g++`
6 export CPP
8 MAKE=`which make`
9 export MAKE
11 UNAME=`which uname`
12 export UNAME
14 HOST=`$UNAME`
15 export HOST
17 BUILD_DIR=build
18 export BUILD_DIR
20 COUCHDB_VERSION=`cat ./version`
21 export COUCHDB_VERSION
23 COUCH_DIR=build/couch-$COUCHDB_VERSION/ebin
24 COUCHDB_INSTALL_DIR=/usr/local/
27 ERLANG_LIB_DIR=false
28 INSTALL_COUCHDB=false
29 BUILD_FABRIC_TESTS=false
30 # taken from autoconf
31 while test $# != 0; do
32 case $1 in
33 --*=*)
34 ac_option=`expr "x$1" : 'x\([^=]*\)='`
35 ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
36 ac_shift=:
38 -*)
39 ac_option=$1
40 ac_optarg=$2
41 ac_shift=shift
43 *) # This is not an option, so the user has probably given explicit
44 # arguments.
45 ac_option=$1
46 ac_need_defaults=false;;
47 esac
49 case $ac_option in
50 --with-fabric-tests)
51 echo "Building CouchDb with Fabric Tests"
52 BUILD_FABRIC_TESTS=true
55 --install)
56 INSTALL_COUCHDB=true
57 COUCHDB_INSTALL_DIR=$ac_optarg
58 if [ -z "$COUCHDB_INSTALL_DIR" ]; then
59 COUCHDB_INSTALL_DIR=/usr/local
60 export COUCHDB_INSTALL_DIR
64 --with-erlang)
65 ERLANG_LIB_DIR=$ac_optarg
66 export ERLANG_LIB_DIR
67 ;;
70 --help)
71 echo "Available options: --install which installs CouchDb and --with-fabric-tests that additionally builds the FabricTests. --with-erlang"
72 exit 0;
75 -*)
76 echo "Unknown option $ac_option. Try --help"
77 exit 1;
78 esac
79 shift
80 done
83 if [ "$ERLANG_BIN_DIR" != "false" ]; then
84 ERLC=$ERLANG_BIN_DIR/erlc
85 export ERLC
86 ERL=$ERLANG_BIN_DIR/erl
87 export ERL
90 if [ -z "$ERLC" ]; then
91 ERLC=`which erlc`
92 export ERLC
95 if [ ! -x "$ERLC" ]; then
96 echo "Cannot find erlc. Please set ERLANG_BIN_DIR manually. (e.g. export ERLANG_BIN_DIR=/usr/local/erlang/bin)"
97 exit 1
100 if [ ! -x "$ERL" ]; then
101 echo "Cannot find erl. Please set ERLANG_BIN_DIR manually. (e.g. export ERLANG_BIN_DIR=/usr/local/erlang/bin)"
102 exit 1
105 if [ -z "$ERLANG_INCLUDE_DIR" ]; then
106 ERLANG_INCLUDE_DIR=/usr/include
107 export ERLANG_INCLUDE_DIR
110 if [ ! -e "$ERLANG_INCLUDE_DIR/erl_driver.h" ]; then
111 ERLANG_INCLUDE_DIR=/usr/lib/erlang/usr/include/
112 export ERLANG_INCLUDE_DIR
114 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/)"
115 exit 1
118 if [ ! -d "$COUCH_DIR" ]; then
119 mkdir -p $COUCH_DIR
122 COUCH_BIG_ENDIAN=`uname -a|grep powerpc`;
124 if [ ! -z "$COUCH_BIG_ENDIAN" ]; then
125 COUCH_BIG_ENDIAN=true
126 export COUCH_BIG_ENDIAN
131 if [ "$BUILD_FABRIC_TESTS" = "true" ]; then
132 $MAKE $BUILD_DIR/FabricTests
133 exit 0
136 if [ "$INSTALL_COUCHDB" = "true" ]; then
138 # if [ $ERLANG_LIB_DIR = "false" ]; then
139 # echo "Please specify the Erlang lib directory with the --with-erlang=/path/to/erlang option"
140 # exit 1;
141 # fi
142 # echo $ERLANG_LIB_DIR
144 echo "Installing CouchDb into $COUCHDB_INSTALL_DIR"
146 if [ -d "$COUCHDB_INSTALL_DIR/couchdb" ]; then
147 rm -rf "$COUCHDB_INSTALL_DIR/old.couchdb"
148 mv "$COUCHDB_INSTALL_DIR/couchdb" "$COUCHDB_INSTALL_DIR/old.couchdb"
151 mkdir -p $COUCHDB_INSTALL_DIR/couchdb
154 COUCHDB_INSTALL_DIR=$COUCHDB_INSTALL_DIR/couchdb
155 export COUCHDB_INSTALL_DIR
157 $MAKE install
158 exit 0
161 $MAKE $J couchdb