<NME> configure
<BEF> #!/bin/bash

# Re-invoke the configure script
# and keep the output at bay.
if [ "$1" != "quiet" ];
then
  $0 "quiet" $@ > /dev/null
  exit $?
fi
shift

set -o errexit
set -o nounset

# Determine system
uname_linux=0
uname_cygwin=0
uname_osx=0
uname=$(uname)
if [ "$uname" = "Linux" ];
then
  uname_linux=1
elif [ "$uname" = "Darwin" ];
then
  uname_osx=1
elif [ "$(uname -o)" = "Cygwin" ];
then
  uname_cygwin=1
else
  echo "Invalid uname ($uname): unsuppported platform" 1>&2
  exit 1
fi

log() { echo "$@" 1>&2; }
log_start() { printf "$@" 1>&2; }
log_end() { echo "$@" 1>&2; }
log_exit() { echo "$@" 1>&2; exit 1; }

project=jeayeson
log "Configuring ${project}"

prefix=/usr/local
includedir="$prefix/include"
threads=4
cxx_platform_flags=
ld_platform_libs=

# Project-specific flags

if [ "1" -eq "$uname_linux" ];
then
  log "Platform: Linux"
elif [ "1" -eq "$uname_osx" ];
then
  log "Platform: Linux"
elif [ "1" -eq "$UNAME_OSX" ];
then
  log "Platform: OSX"
  CXX_PLATFORM_FLAGS="-stdlib=libc++ -I/opt/local/include"
  LD_PLATFORM_LIBS="-lc++"
elif [ "1" -eq "$UNAME_CYGWIN" ];

function show_help
{
  log "Usage: $0 [OPTION...]"
  log
  log "General:"
  log "  -h, --help                                   Show this help message"
  log "  --prefix=[/usr/local]                        Set installation prefix"
  log "  --includedir=[/usr/local/include]            Set include prefix"
      shift
      PREFIX="$1"
      DATAROOTDIR=$PREFIX/include
      ;;
    --prefix=*)
      PREFIX="${i#*=}"
      DATAROOTDIR=$PREFIX/include
      shift
      ;;
    --datarootdir)
      shift
      DATAROOTDIR="$1"
      ;;
    --datarootdir=*)
      DATAROOTDIR="${i#*=}"
      shift
      ;;
    --threads)
      shift
      THREADS=$1
      ;;
    --threads=*)
      THREADS=${i#*=}
      shift
      ;;
    --help*)
      log "Usage: $0 [OPTION...]"
      log
      shift
      ;;
    --threads=*)
      threads=${i#*=}
      shift
      ;;

    -h)
      show_help
      ;;
    --help*)
      show_help
      ;;

    *)
      # Unknown option
      ;;
  esac
done

# Update after params
log
log "Install prefix: $prefix"
log "Install include prefix: $includedir"
log "Compilation threads: $threads"
log

log_start "Updating submodules..."
log_start " jest" && git submodule update --init --recursive lib/jest 2>&1 > /dev/null || true
log_end " done"

# Describe next steps
log
log "To run tests, use \`make && make test\`"
log "To install, use \`make install\` with the appropriate permissions"
sed "s#%PREFIX%#${prefix}#" |\
sed "s#%INCLUDEDIR%#${includedir}#" |\
sed "s#%PROJECT%#${project}#" |\
sed "s#%THREADS%#${threads}#" > Makefile
log_end " done"

log_start "Generating sources..."
if [ ! -f include/jeayeson/config.hpp ];
then
cat <<EOF > include/jeayeson/config.hpp
#pragma once

namespace jeayeson
{
  /* To customize jeayeson internals, change these types
   * to any other compatible types which suit your needs.
   * Add any required #includes here.
   */
  template <>
  struct config<config_tag>
  {
    using float_t = double;
    using int_t = int64_t;

    template <typename K, typename V>
    using map_t = std::map<K, V>;
  };
}
EOF
fi
log_end " done"

log "Done configuring ${project}"

# Describe next steps
log
log "To run tests, use \`make && make test\`"
log "To install headers, use \`make install\` with the appropriate permissions for your prefix"

<MSG> Expanded configure's argument syntax

<DFF> @@ -55,7 +55,7 @@ then
   log "Platform: Linux"
 elif [ "1" -eq "$UNAME_OSX" ];
 then
-  log "Platform: OSX"
+  log "Platform: OS X"
   CXX_PLATFORM_FLAGS="-stdlib=libc++ -I/opt/local/include"
   LD_PLATFORM_LIBS="-lc++"
 elif [ "1" -eq "$UNAME_CYGWIN" ];
@@ -71,28 +71,34 @@ do
       shift
       PREFIX="$1"
       DATAROOTDIR=$PREFIX/include
+      shift
       ;;
     --prefix=*)
       PREFIX="${i#*=}"
       DATAROOTDIR=$PREFIX/include
       shift
       ;;
+
     --datarootdir)
       shift
       DATAROOTDIR="$1"
+      shift
       ;;
     --datarootdir=*)
       DATAROOTDIR="${i#*=}"
       shift
       ;;
+
     --threads)
       shift
       THREADS=$1
+      shift
       ;;
     --threads=*)
       THREADS=${i#*=}
       shift
       ;;
+
     --help*)
       log "Usage: $0 [OPTION...]"
       log
@@ -130,4 +136,4 @@ log "Done configuring ${PROJECT}"
 # Describe next steps
 log
 log "To run tests, use \`make && make test\`"
-log "To install, use \`make install\` with the appropriate permissions"
+log "To install headers, use \`make install\` with the appropriate permissions for your prefix"

{'commit': 'diff --git a/configure b/configure\nindex 4bd816f..59d8b5d 100755\n--- a/configure\n+++ b/configure\n@@ -55,7 +55,7 @@ then\n   log "Platform: Linux"\n elif [ "1" -eq "$UNAME_OSX" ];\n then\n-  log "Platform: OSX"\n+  log "Platform: OS X"\n   CXX_PLATFORM_FLAGS="-stdlib=libc++ -I/opt/local/include"\n   LD_PLATFORM_LIBS="-lc++"\n elif [ "1" -eq "$UNAME_CYGWIN" ];\n@@ -71,28 +71,34 @@ do\n       shift\n       PREFIX="$1"\n       DATAROOTDIR=$PREFIX/include\n+      shift\n       ;;\n     --prefix=*)\n       PREFIX="${i#*=}"\n       DATAROOTDIR=$PREFIX/include\n       shift\n       ;;\n+\n     --datarootdir)\n       shift\n       DATAROOTDIR="$1"\n+      shift\n       ;;\n     --datarootdir=*)\n       DATAROOTDIR="${i#*=}"\n       shift\n       ;;\n+\n     --threads)\n       shift\n       THREADS=$1\n+      shift\n       ;;\n     --threads=*)\n       THREADS=${i#*=}\n       shift\n       ;;\n+\n     --help*)\n       log "Usage: $0 [OPTION...]"\n       log\n@@ -130,4 +136,4 @@ log "Done configuring ${PROJECT}"\n # Describe next steps\n log\n log "To run tests, use \\`make && make test\\`"\n-log "To install, use \\`make install\\` with the appropriate permissions"\n+log "To install headers, use \\`make install\\` with the appropriate permissions for your prefix"\n', 'commit_subject': "Expanded configure's argument syntax", 'repo_name': 'jeaye/jeayeson', 'committer': {'name': 'jeaye', 'email': '1a73af9e7ae00182733b2292511b814be66f065f@jeaye.com', 'time_sec': '1403419130', 'tz_offset': '-420', 'date': {'seconds': '1403419130'}}, 'commit_tree': '83647578765ec43c3d3c6178252d12aef70c35d8', 'commit_message': "Expanded configure's argument syntax\n", 'language_name': 'C++', 'license': 'bsd-3-clause', 'hunks': '@@ -55,7 +55,7 @@ then\n   log "Platform: Linux"\n elif [ "1" -eq "$UNAME_OSX" ];\n then\n-  log "Platform: OSX"\n+  log "Platform: OS X"\n   CXX_PLATFORM_FLAGS="-stdlib=libc++ -I/opt/local/include"\n   LD_PLATFORM_LIBS="-lc++"\n elif [ "1" -eq "$UNAME_CYGWIN" ];\n@@ -71,28 +71,34 @@ do\n       shift\n       PREFIX="$1"\n       DATAROOTDIR=$PREFIX/include\n+      shift\n       ;;\n     --prefix=*)\n       PREFIX="${i#*=}"\n       DATAROOTDIR=$PREFIX/include\n       shift\n       ;;\n+\n     --datarootdir)\n       shift\n       DATAROOTDIR="$1"\n+      shift\n       ;;\n     --datarootdir=*)\n       DATAROOTDIR="${i#*=}"\n       shift\n       ;;\n+\n     --threads)\n       shift\n       THREADS=$1\n+      shift\n       ;;\n     --threads=*)\n       THREADS=${i#*=}\n       shift\n       ;;\n+\n     --help*)\n       log "Usage: $0 [OPTION...]"\n       log\n@@ -130,4 +136,4 @@ log "Done configuring ${PROJECT}"\n # Describe next steps\n log\n log "To run tests, use \\`make && make test\\`"\n-log "To install, use \\`make install\\` with the appropriate permissions"\n+log "To install headers, use \\`make install\\` with the appropriate permissions for your prefix"\n', 'addition_count': 8, 'deletion_count': 2, 'src_file': 'a/configure', 'tgt_file': 'b/configure', 'file_extension': '', 'before_file': '#!/bin/bash\n\n# Re-invoke the configure script\n# and keep the output at bay.\nif [ "$1" != "quiet" ];\nthen\n  $0 "quiet" $@ > /dev/null\n  exit $?\nfi\nshift\n\nset -o errexit\nset -o nounset\n\n# Determine system\nuname_linux=0\nuname_cygwin=0\nuname_osx=0\nuname=$(uname)\nif [ "$uname" = "Linux" ];\nthen\n  uname_linux=1\nelif [ "$uname" = "Darwin" ];\nthen\n  uname_osx=1\nelif [ "$(uname -o)" = "Cygwin" ];\nthen\n  uname_cygwin=1\nelse\n  echo "Invalid uname ($uname): unsuppported platform" 1>&2\n  exit 1\nfi\n\nlog() { echo "$@" 1>&2; }\nlog_start() { printf "$@" 1>&2; }\nlog_end() { echo "$@" 1>&2; }\nlog_exit() { echo "$@" 1>&2; exit 1; }\n\nproject=jeayeson\nlog "Configuring ${project}"\n\nprefix=/usr/local\nincludedir="$prefix/include"\nthreads=4\ncxx_platform_flags=\nld_platform_libs=\n\n# Project-specific flags\n\nif [ "1" -eq "$uname_linux" ];\nthen\n  log "Platform: Linux"\nelif [ "1" -eq "$uname_osx" ];\nthen\n  log "Platform: Linux"\nelif [ "1" -eq "$UNAME_OSX" ];\nthen\n  log "Platform: OSX"\n  CXX_PLATFORM_FLAGS="-stdlib=libc++ -I/opt/local/include"\n  LD_PLATFORM_LIBS="-lc++"\nelif [ "1" -eq "$UNAME_CYGWIN" ];\n\nfunction show_help\n{\n  log "Usage: $0 [OPTION...]"\n  log\n  log "General:"\n  log "  -h, --help                                   Show this help message"\n  log "  --prefix=[/usr/local]                        Set installation prefix"\n  log "  --includedir=[/usr/local/include]            Set include prefix"\n      shift\n      PREFIX="$1"\n      DATAROOTDIR=$PREFIX/include\n      ;;\n    --prefix=*)\n      PREFIX="${i#*=}"\n      DATAROOTDIR=$PREFIX/include\n      shift\n      ;;\n    --datarootdir)\n      shift\n      DATAROOTDIR="$1"\n      ;;\n    --datarootdir=*)\n      DATAROOTDIR="${i#*=}"\n      shift\n      ;;\n    --threads)\n      shift\n      THREADS=$1\n      ;;\n    --threads=*)\n      THREADS=${i#*=}\n      shift\n      ;;\n    --help*)\n      log "Usage: $0 [OPTION...]"\n      log\n      shift\n      ;;\n    --threads=*)\n      threads=${i#*=}\n      shift\n      ;;\n\n    -h)\n      show_help\n      ;;\n    --help*)\n      show_help\n      ;;\n\n    *)\n      # Unknown option\n      ;;\n  esac\ndone\n\n# Update after params\nlog\nlog "Install prefix: $prefix"\nlog "Install include prefix: $includedir"\nlog "Compilation threads: $threads"\nlog\n\nlog_start "Updating submodules..."\nlog_start " jest" && git submodule update --init --recursive lib/jest 2>&1 > /dev/null || true\nlog_end " done"\n\n# Describe next steps\nlog\nlog "To run tests, use \\`make && make test\\`"\nlog "To install, use \\`make install\\` with the appropriate permissions"\nsed "s#%PREFIX%#${prefix}#" |\\\nsed "s#%INCLUDEDIR%#${includedir}#" |\\\nsed "s#%PROJECT%#${project}#" |\\\nsed "s#%THREADS%#${threads}#" > Makefile\nlog_end " done"\n\nlog_start "Generating sources..."\nif [ ! -f include/jeayeson/config.hpp ];\nthen\ncat <<EOF > include/jeayeson/config.hpp\n#pragma once\n\nnamespace jeayeson\n{\n  /* To customize jeayeson internals, change these types\n   * to any other compatible types which suit your needs.\n   * Add any required #includes here.\n   */\n  template <>\n  struct config<config_tag>\n  {\n    using float_t = double;\n    using int_t = int64_t;\n\n    template <typename K, typename V>\n    using map_t = std::map<K, V>;\n  };\n}\nEOF\nfi\nlog_end " done"\n\nlog "Done configuring ${project}"\n\n# Describe next steps\nlog\nlog "To run tests, use \\`make && make test\\`"\nlog "To install headers, use \\`make install\\` with the appropriate permissions for your prefix"\n', 'message': "Expanded configure's argument syntax\n", 'author_name': 'jeaye', 'lang': 'configure'}