You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/02/05 05:20:16 UTC

[3/5] couchdb commit: updated refs/heads/1843-feature-bigcouch-multi-repo to e6724ff

Improved configure scripts

This provides a better help output and argument parsing for the
'./configure' script. It implements a method for pulling config values
into rebar.config.script's so that we can control the build a bit more.

As an example there's now a '-c' option to build couchjs with cURL
bindings.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/cd5055d4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/cd5055d4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/cd5055d4

Branch: refs/heads/1843-feature-bigcouch-multi-repo
Commit: cd5055d462816d2071da8bb51a57abae712690c6
Parents: 9de0e8c
Author: Paul J. Davis <pa...@gmail.com>
Authored: Tue Feb 4 21:44:44 2014 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Tue Feb 4 22:07:09 2014 -0600

----------------------------------------------------------------------
 .gitignore          |   1 +
 Makefile            |   8 +++-
 configure           | 117 +++++++++++++++++++++++++++++++----------------
 rebar.config.script |   7 ++-
 4 files changed, 91 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/cd5055d4/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 7b37cea..902035d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+config.erl
 install.mk
 rel/*.config
 rel/dev*

http://git-wip-us.apache.org/repos/asf/couchdb/blob/cd5055d4/Makefile
----------------------------------------------------------------------
diff --git a/Makefile b/Makefile
index 8651369..812849d 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,13 @@
 
 all:  compile
 
-compile:
+config.erl:
+	@echo "Apache CouchDB has not been configured."
+	@echo "Try \"./configure -h\" for help."
+	@echo
+	@false
+
+compile: config.erl
 	@echo "==> couchjs (compile)"
 	@rebar compile
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/cd5055d4/configure
----------------------------------------------------------------------
diff --git a/configure b/configure
index c95a988..7036d7c 100755
--- a/configure
+++ b/configure
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh -e
 # Licensed under the Apache License, Version 2.0 (the "License"); you may not
 # use this file except in compliance with the License. You may obtain a copy of
 # the License at
@@ -13,42 +13,73 @@
 
 PREFIX="/opt/couchdb"
 COUCHDB_USER=`whoami`
-ABSPATH="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")"
-if test ! -n "$DIRPATH"; then DIRPATH=`dirname "$ABSPATH"`; fi
-
-while [ $# -gt 0 ]
-do
-  case $1
-  in
-    -p)
-      PREFIX=$2
-      shift 2
-    ;;
-    -t)
-      TEMPLATE=$2
-      shift 2
-    ;;
-    -d)
-      DATA=$2
-      shift 2
-    ;;
-    -v)
-      VIEW=$2
-      shift 2
-    ;;
-    -u)
-      COUCHDB_USER=$2
-      shift 2
-    ;;
-    *)
-      echo "usage: $0 [-p {prefix} -t {template} -d {data_dir} -v {view_dir} -u {user}]"
-      exit
-    ;;
-  esac
-done
+WITH_CURL="false"
+
+rootdir="$(cd "${0%/*}" 2>/dev/null; echo "$PWD")"
+basename=`basename $0`
+
+
+display_help () {
+    cat << EOF
+Usage: $basename [OPTION]
+
+The $basename command is responsible for generating the build
+system for Apache CouchDB.
+
+Options:
+
+  -h            display a short help message and exit
+  -u USER       set the username to run as (defaults to $COUCHDB_USER)
+  -p DIRECTORY  set the prefix for installation (defaults to $PREFIX)
+  -d DIRECTORY  specify the data directory (defaults to $PREFIX/var/lib)
+  -v DIRECTORY  specify the view directory (defaults to $PREFIX/var/lib)
+  -c            request that couchjs is linked to cURL (default false)
+
+EOF
+}
+
+
+display_error () {
+    if test -n "$1"; then
+        echo $1 >&2
+    fi
+    echo >&2
+    echo "Try \"$basename -h\" for more information." >&2
+    false
+}
+
+
+parse_opts () {
+    set +e
+    options=`getopt hu:p:d:v:c $@`
+    if test ! $? -eq 0; then
+        display_error
+    fi
+    set -e
+    eval set -- $options
+    while [ $# -gt 0 ]; do
+        case "$1" in
+            -h) shift; display_help; exit;;
+            -u) shift; COUCHDB_USER=$1; shift;;
+            -p) shift; PREFIX=$1; shift;;
+            -d) shift; DATA=$1; shift;;
+            -v) shift; VIEW=$1; shift;;
+            -c) shift; WITH_CURL="true";;
+            --) shift; break;;
+            *) display_error "Unknown option: $1" >&2;;
+        esac
+    done
+    if test ! -n "$DATA"; then
+        DATA="$PREFIX/var/lib";
+    fi
+    if test ! -n "$VIEW"; then
+        VIEW="$PREFIX/var/lib";
+    fi
+}
+
+
+parse_opts $@
 
-if test ! -n "$DATA"; then DATA="$PREFIX/var/lib"; fi
-if test ! -n "$VIEW"; then VIEW="$PREFIX/var/lib"; fi
 
 echo "==> configuring couchdb in rel/couchdb.config"
 cat > rel/couchdb.config << EOF
@@ -69,16 +100,22 @@ view_dir = $VIEW
 user = $COUCHDB_USER
 EOF
 
+cat > $rootdir/config.erl << EOF
+{with_curl, $WITH_CURL}.
+EOF
+
 # finally, a few config files for local development nodes
 for i in 1 2 3; do
 cat > rel/dev$i.config << EOF
-{prefix, "$DIRPATH/rel/dev$i"}.
-{data_dir, "$DIRPATH/rel/tmpdata/dev$i"}.
-{view_dir, "$DIRPATH/rel/tmpdata/dev$i"}.
+{prefix, "$rootdir/rel/dev$i"}.
+{data_dir, "$rootdir/rel/tmpdata/dev$i"}.
+{view_dir, "$rootdir/rel/tmpdata/dev$i"}.
 {node_name, "-name dev$i@127.0.0.1"}.
 {cluster_port, `expr 10000 \* $i + 5984`}.
 {backend_port, `expr 10000 \* $i + 5986`}.
 EOF
 done
 
-rebar get-deps && rebar update-deps && cat rel/couchdb.config
+
+echo "==> updating dependencies"
+rebar get-deps update-deps

http://git-wip-us.apache.org/repos/asf/couchdb/blob/cd5055d4/rebar.config.script
----------------------------------------------------------------------
diff --git a/rebar.config.script b/rebar.config.script
index d2ac1b0..cb8e706 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -10,7 +10,11 @@
 % License for the specific language governing permissions and limitations under
 % the License.
 
-{require_otp_vsn, "R14B01|R14B03|R14B04|R15B02|R15B03|R16"}.
+% Set the path to the configuration environment generated
+% by `./configure`.
+ConfigureEnv = filename:join(filename:dirname(SCRIPT), "config.erl"),
+os:putenv("COUCHDB_CONFIG", ConfigureEnv).
+
 
 DepDescs = [
     {chttpd, "couchdb-chttpd", {branch, import}},
@@ -38,6 +42,7 @@ MakeDep = fun({AppName, RepoName, Version}) ->
 end,
 
 AddConfig = [
+    {require_otp_vsn, "R14B01|R14B03|R14B04|R15B02|R15B03|R16"},
     {deps_dir, "src"},
     {deps, lists:map(MakeDep, DepDescs)},
     {sub_dirs, ["rel"]},