fix for saved view problem on restart
[couchdbimport.git] / build.sh
blobcf851755776aba403c01e27081c59bafc1ba7e85
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 ./src/version`
21 export COUCHDB_VERSION
23 COUCH_DIR=build/couch-$COUCHDB_VERSION/ebin
24 COUCHDB_INSTALL_DIR=/usr/local/
27 #MAKEFILE=" -f build/Makefile"
30 ERLANG_BIN_DIR=false
31 INSTALL_COUCHDB=false
32 # taken from autoconf
33 while test $# != 0; do
34 case $1 in
35 --*=*)
36 ac_option=`expr "x$1" : 'x\([^=]*\)='`
37 ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
38 ac_shift=:
40 -*)
41 ac_option=$1
42 ac_optarg=$2
43 ac_shift=shift
45 *) # This is not an option, so the user has probably given explicit
46 # arguments.
47 ac_option=$1
48 ac_need_defaults=false;;
49 esac
51 case $ac_option in
52 --install)
53 INSTALL_COUCHDB=true
54 COUCHDB_INSTALL_DIR=$ac_optarg
55 if [ -z "$COUCHDB_INSTALL_DIR" ]; then
56 COUCHDB_INSTALL_DIR=/usr/local
57 export COUCHDB_INSTALL_DIR
61 --with-erlang)
62 ERLANG_BIN_DIR=$ac_optarg
63 export ERLANG_BIN_DIR
64 ;;
66 --help)
67 echo "Available options: --install which installs CouchDb and --with-erlang"
68 exit 0;
71 -*)
72 echo "Unknown option $ac_option. Try --help"
73 exit 1;
74 esac
75 shift
76 done
79 if [ "$ERLANG_BIN_DIR" != "false" ]; then
80 ERLC=$ERLANG_BIN_DIR/erlc
81 export ERLC
82 ERL=$ERLANG_BIN_DIR/erl
83 export ERL
86 if [ ! -x "$ERLC" ]; then
87 export ERLC=`which erlc`
90 if [ ! -x "$ERLC" ]; then
91 echo "Cannot find erlc. Please set ERLANG_BIN_DIR manually. (e.g. export ERLANG_BIN_DIR=/usr/local/erlang/bin)"
92 exit 1
95 if [ ! -x "$ERL" ]; then
96 export ERL=`which erl`
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 [ "$INSTALL_COUCHDB" = "true" ]; then
132 echo "Installing CouchDb into $COUCHDB_INSTALL_DIR"
134 if [ -d "$COUCHDB_INSTALL_DIR/couchdb" ]; then
135 rm -rf "$COUCHDB_INSTALL_DIR/old.couchdb"
136 mv "$COUCHDB_INSTALL_DIR/couchdb" "$COUCHDB_INSTALL_DIR/old.couchdb"
139 mkdir -p $COUCHDB_INSTALL_DIR/couchdb
142 COUCHDB_INSTALL_DIR=$COUCHDB_INSTALL_DIR/couchdb
143 export COUCHDB_INSTALL_DIR
145 $MAKE $MAKEFILE install
146 exit 0
149 $MAKE $J $MAKEFILE couchdb