Changeset

371:88bcf9fbdd07

configure, Makefile: Add configure script to set build-time variables
author Matthew Wild <mwild1@gmail.com>
date Fri, 01 Jan 2016 15:40:51 +0000
parents 370:75e7917761c0
children 372:0ce6d4a1e2fd
files Makefile configure
diffstat 2 files changed, 107 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Thu Dec 31 21:12:00 2015 +0000
+++ b/Makefile	Fri Jan 01 15:40:51 2016 +0000
@@ -1,5 +1,5 @@
-SQUISH=./buildscripts/squish
-PROSODY_URL=https://hg.prosody.im/0.9/raw-file/tip/
+include config.unix
+
 SOURCE_FILES=$(shell $(SQUISH) --list-files)
 MISSING_FILES=$(shell $(SQUISH) --list-missing-files)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configure	Fri Jan 01 15:40:51 2016 +0000
@@ -0,0 +1,105 @@
+#!/bin/sh
+
+SQUISH=./buildscripts/squish
+PROSODY_URL=https://hg.prosody.im/0.9/raw-file/tip/
+PREFIX="/usr/local"
+
+LUA_VERSION=5.1
+LUA_INTERPRETER=lua$LUA_VERSION
+
+if which $LUA_INTERPRETER>/dev/null; then
+	LUA_DIR=$($LUA_INTERPRETER -e 'print((package.path:match("'"${PREFIX}"'[^;]+%?%.lua"):gsub("/%?%.lua$", "")))')
+else
+	LUA_DIR="$PREFIX/share/lua/$LUA_VERSION"
+fi
+
+# Help
+
+show_help() {
+cat <<EOF
+Configure Prosody prior to building.
+
+--help                      This help.
+--prefix                    Installation path prefix (used when installing)
+                            Default: $PREFIX
+--lua-lib-dir=DIR           You can also specify Lua's libraries dir.
+                            Default: $LUA_DIR
+--squish                    Path to squish utility (used for building)
+                            Default: $SQUISH
+--prosody-rev               Prosody revision to pull files from
+                            Default: tip
+--prosody-url               URL to pull Prosody files from (not compatible with --prosody-rev)
+                            Default: $PROSODY_URL
+EOF
+}
+
+
+while [ "$1" ]
+do
+   value="`echo $1 | sed 's/[^=]*=\(.*\)/\1/'`"
+   if echo "$value" | grep -q "~"
+   then
+      echo
+      echo '*WARNING*: the "~" sign is not expanded in flags.'
+      echo 'If you mean the home directory, use $HOME instead.'
+      echo
+   fi
+   case "$1" in
+   --help)
+      show_help
+      exit 0
+      ;;
+   --lua-lib-dir=*)
+      LUA_LIBDIR="$value"
+      ;;
+   --with-squish=*)
+      SQUISH="$value"
+      ;;
+   --prosody-rev=*)
+      PROSODY_REV="$value"
+      PROSODY_REV_SET=yes
+      ;;
+   --prosody-url=*)
+      PROSODY_URL="$value"
+      PROSODY_URL_SET=yes
+      ;;
+   *)
+      echo "Error: Unknown flag: $1"
+      exit 1
+      ;;
+   esac
+   shift
+done
+
+# Sanity-check options
+
+if ! test -x "$SQUISH"; then
+	echo "FATAL: Unable to find/use squish: $SQUISH";
+	exit 1;
+fi
+
+if [ "$PROSODY_URL_SET" = "yes" -a "$PROSODY_REV_SET" = "yes" ]; then
+	echo "FATAL: You can only specify one of --prosody-rev and --prosody-url, not both"
+	exit 1;
+fi
+
+if [ "$PROSODY_REV_SET" = "yes" ]; then
+	PROSODY_URL="https://hg.prosody.im/trunk/raw-file/${PROSODY_REV}/"
+fi
+
+cat <<EOF >config.unix
+
+# This file was automatically generated by the configure script.
+# Run "./configure --help" for details.
+
+SQUISH=./buildscripts/squish
+PROSODY_URL=$PROSODY_URL
+LUA_DIR=$LUA_DIR
+EOF
+
+echo
+echo "Using squish from:            $SQUISH"
+echo "Installing verse.lua to:      $LUA_DIR"
+echo "Fetching Prosody files from:  $PROSODY_URL"
+echo
+echo "Configured successfully. Please run 'make' to proceed."