configure

Thu, 10 Jun 2021 11:58:23 +0200

author
Kim Alvefur <zash@zash.se>
date
Thu, 10 Jun 2021 11:58:23 +0200
changeset 445
b119dc4d8bc2
parent 416
92ce569b9b73
permissions
-rwxr-xr-x

plugins.smacks: Don't warn about zero stanzas acked

It's only if the count somehow goes backwards that something is really
wrong. An ack for zero stanzas is fine and we don't need to do anything.

#!/bin/sh

SQUISH=./buildscripts/squish
PROSODY_URL=https://hg.prosody.im/0.10/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."

mercurial