Merge lp:~tangent-org/libmemcached/1.0-build Build: jenkins-Libmemcached-1.0-87
[awesomized/libmemcached] / bootstrap.sh
index 13d10b39f10c86d22daa42fb45ce1e7b72c50686..40b2829989f5d8de55f7f64d1194c0828168a612 100755 (executable)
@@ -637,6 +637,7 @@ make_distcheck ()
 
 make_rpm ()
 {
+  run_configure_if_required
   make_target 'rpm'
 }
 
@@ -687,76 +688,56 @@ run_autoreconf ()
   eval 'bash -n configure' || die "autoreconf generated a malformed configure"
 }
 
-run ()
+function run ()
 {
   if $VERBOSE; then
     echo "\`$@' $ARGS"
   fi
 
-  ($@ $ARGS)
+  eval $@ $ARGS
 } 
 
 parse_command_line_options ()
 {
-  local options=
-
-  local SHORTOPTS='p,c,a,v'
-  local LONGOPTS='target:,debug,clean,print-env,configure,autoreconf' 
-
-  if ! options=$(getopt --shell bash --longoptions $LONGOPTS --options $SHORTOPTS -n 'bootstrap' -- "$@"); then
-    die 'Bad option given'
-  fi
+  local SHORTOPTS=':apcmt:dv'
 
-  eval set -- "$options"
-
-  while [[ $# -gt 0 ]]; do
-    case $1 in
-      -a | --autoreconf )
+  while getopts "$SHORTOPTS" opt; do
+    case $opt in
+      a) #--autoreconf
         AUTORECONF_OPTION=true
         MAKE_TARGET='autoreconf'
-        shift
         ;;
-      -p | --print-env )
+      p) #--print-env
         PRINT_SETUP_OPTION=true
-        shift
         ;;
-      -c | --configure )
+      c) # --configure
         CONFIGURE_OPTION=true
         MAKE_TARGET='configure'
-        shift
         ;;
-      --clean )
+      m) # maintainer-clean
         CLEAN_OPTION=true
         MAKE_TARGET='clean_op'
-        shift
         ;;
-      --target )
+      t) # target
         TARGET_OPTION=true
-        shift
-        TARGET_OPTION_ARG="$1"
-        MAKE_TARGET="$1"
-        shift
+        TARGET_OPTION_ARG="$OPTARG"
+        MAKE_TARGET="$OPTARG"
         ;;
-      --debug )
+      d) # debug
         DEBUG_OPTION=true
         enable_debug
-        shift
         ;;
-      -v | --verbose )
+      v) # verbose
         VERBOSE_OPTION=true
         VERBOSE=true
-        shift
-        ;;
-      -- )
-        shift
-        break
         ;;
-      -* )
-        echo "$0: error - unrecognized option $1" 1>&2
+      :)
+        echo "Option -$OPTARG requires an argument." >&2
         exit 1
         ;;
       *)
-        break
+        echo "$0: error - unrecognized option $1" 1>&2
+        exit 1
         ;;
     esac
   done
@@ -789,10 +770,14 @@ autoreconf_setup ()
   if [[ -z "$MAKE" ]]; then 
     if command_exists gmake; then
       MAKE=`type -p gmake`
+    else
+      if command_exists make; then
+        MAKE=`type -p make`
+      fi
     fi
-
-    if command_exists make; then
-      MAKE=`type -p make`
+    
+    if $DEBUG; then
+      MAKE="$MAKE --warn-undefined-variables"
     fi
   fi
 
@@ -974,6 +959,8 @@ check_make_target()
       ;;
     'configure')
       ;;
+    'rpm')
+      ;;
     'snapshot')
       ;;
     'valgrind')
@@ -1056,6 +1043,9 @@ bootstrap ()
       'snapshot')
         make_for_snapshot
         ;;
+      'rpm')
+        make_rpm
+        ;;
       'valgrind')
         make_valgrind
         ;;