about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2011-03-30 04:45:09 +0000
committerGraydon Hoare <graydon@mozilla.com>2011-03-30 04:45:09 +0000
commit94731fa458a7602d492fcd4cae97d9cfbef84a03 (patch)
tree148a5aa053aa51c9f0d76307fc6b7ae4685ca16c
parent301cfe135485e18666f1859ccf3e39ae4b91f564 (diff)
Add support for --enable-foo and --disable-foo flags to configure, that Makefile.in respects.
-rw-r--r--Makefile.in16
-rwxr-xr-xconfigure85
2 files changed, 87 insertions, 14 deletions
diff --git a/Makefile.in b/Makefile.in
index 6b5d44b4280..e08138badb2 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -162,14 +162,14 @@ else
   $(info cfg: have only ocaml bytecode compiler)
 endif
 
-ifdef BOOT_PROFILE
-  $(info cfg: forcing native bootstrap compiler (BOOT_PROFILE))
+ifdef CFG_BOOT_PROFILE
+  $(info cfg: forcing native bootstrap compiler (CFG_BOOT_PROFILE))
   CFG_BOOT_NATIVE := 1
   CFG_OCAMLOPT_PROFILE_FLAGS := -p
 endif
 
-ifdef BOOT_DEBUG
-  $(info cfg: forcing bytecode bootstrap compiler (DEBUG))
+ifdef CFG_BOOT_DEBUG
+  $(info cfg: forcing bytecode bootstrap compiler (CFG_BOOT_DEBUG))
   CFG_BOOT_NATIVE :=
 endif
 
@@ -179,8 +179,8 @@ else
   $(info cfg: building bytecode bootstrap compiler)
 endif
 
-ifdef NO_VALGRIND
-  $(info cfg: disabling valgrind (NO_VALGRIND))
+ifdef CFG_DISABLE_VALGRIND
+  $(info cfg: disabling valgrind (CFG_DISABLE_VALGRIND))
   CFG_VALGRIND :=
 endif
 
@@ -201,6 +201,10 @@ else
   endif
 endif
 
+ifdef CFG_DISABLE_DOCS
+  $(info cfg: disabling doc build (CFG_DISABLE_DOCS))
+  DOCS :=
+endif
 
 ######################################################################
 # Target-and-rule "utility variables"
diff --git a/configure b/configure
index 573ffe91f60..8c8ed680a1b 100755
--- a/configure
+++ b/configure
@@ -4,6 +4,12 @@ msg() {
     echo "configure: $1"
 }
 
+step_msg() {
+    msg
+    msg "$1"
+    msg
+}
+
 err() {
     echo "configure: error: $1"
     exit 1
@@ -67,6 +73,44 @@ probe_need() {
     fi
 }
 
+opt() {
+    local OP=$1
+    local DEFAULT=$2
+    shift
+    shift
+    local DOC="$*"
+    local FLAG=""
+
+    if [ $DEFAULT -eq 0 ]
+    then
+        FLAG="enable"
+    else
+        FLAG="disable"
+        DOC="don't $DOC"
+    fi
+
+    if [ $HELP -eq 0 ]
+    then
+        for arg in $CFG_CONFIGURE_ARGS
+        do
+            if [ "$arg" = "--${FLAG}-${OP}" ]
+            then
+                OP=$(echo $OP | tr 'a-z' 'A-Z')
+                FLAG=$(echo $FLAG | tr 'a-z' 'A-Z')
+                local V="CFG_${FLAG}_${OP}"
+                eval $V=1
+                putvar $V
+            fi
+        done
+    else
+        if [ ! -z "$META" ]
+        then
+            OP="$OP=<$META>"
+        fi
+        printf "    --%-30s %s\n" "$FLAG-$OP" "$DOC"
+     fi
+}
+
 msg "looking for configure programs"
 need_cmd mkdir
 need_cmd printf
@@ -84,16 +128,40 @@ msg "inspecting environment"
 CFG_OSTYPE=$(uname -s)
 CFG_CPUTYPE=$(uname -m)
 
-CFG_SELF=$(echo $0 | tr '\' '/')
+CFG_SELF=$(echo $0 | tr '\\' '/')
 CFG_SRC_DIR=${CFG_SELF%${CFG_SELF##*/}}
-CFG_BUILD_DIR=$(echo $PWD | tr '\' '/')
+CFG_BUILD_DIR=$(echo $PWD | tr '\\' '/')
 CFG_CONFIGURE_ARGS="$@"
 
+OPTIONS=""
+HELP=0
+if [ "$1" = "--help" ]
+then
+    HELP=1
+    shift
+    echo ""
+    echo "Usage: $CFG_SELF [options]"
+    echo ""
+    echo "Options:"
+    echo ""
+else
+    msg "recreating config.mk"
+    echo '' >config.mk
+
+    step_msg "processing $CFG_SELF args"
+fi
 
-msg "recreating config.mk"
-echo '' >config.mk
+opt valgrind 1 "run tests with valgrind"
+opt docs     1 "build documentation"
+
+
+if [ $HELP -eq 1 ]
+then
+    echo ""
+    exit 0
+fi
 
-msg "making directories"
+step_msg "making directories"
 for i in \
     doc \
     boot/fe boot/me boot/be boot/driver boot/util \
@@ -106,13 +174,14 @@ do
     make_dir $i
 done
 
+step_msg "writing out basic parameters"
 putvar CFG_SRC_DIR
 putvar CFG_BUILD_DIR
 putvar CFG_OSTYPE
 putvar CFG_CPUTYPE
 putvar CFG_CONFIGURE_ARGS
 
-msg "looking for build programs"
+step_msg "looking for build programs"
 probe_need CFG_GCC          gcc
 probe_need CFG_GIT          git
 probe_need CFG_OCAMLC       ocamlc
@@ -160,7 +229,7 @@ fi
 
 case $CFG_LLVM_VERSION in
     (3.0svn | 3.0)
-    msg "found ok version of LLVM: $CFG_LLVM_VERSION"
+    step_msg "found ok version of LLVM: $CFG_LLVM_VERSION"
     ;;
     (*)
     err "bad LLVM version: $CFG_LLVM_VERSION, need >=3.0svn"
@@ -181,4 +250,4 @@ rm -f config.mk.bak
 
 copy ${CFG_SRC_DIR}Makefile.in ./Makefile
 
-echo "configure: complete"
+step_msg "complete"