configure

1
#!/bin/sh
2
 
3
SQUISH=./buildscripts/squish
4
PROSODY_URL=https://hg.prosody.im/trunk/raw-file/tip/
5
PREFIX="/usr/local"
6
 
7
LUA_VERSION=5.1
8
LUA_INTERPRETER=lua$LUA_VERSION
9
 
10
if which $LUA_INTERPRETER>/dev/null; then
11
	LUA_DIR=$($LUA_INTERPRETER -e 'print((package.path:match("'"${PREFIX}"'[^;]+%?%.lua"):gsub("/%?%.lua$", "")))')
12
else
13
	LUA_DIR="$PREFIX/share/lua/$LUA_VERSION"
14
fi
15
 
16
# Help
17
 
18
show_help() {
19
cat <<EOF
20
Configure Prosody prior to building.
21
 
22
--help                      This help.
23
--prefix                    Installation path prefix (used when installing)
24
                            Default: $PREFIX
25
--lua-lib-dir=DIR           You can also specify Lua's libraries dir.
26
                            Default: $LUA_DIR
27
--squish                    Path to squish utility (used for building)
28
                            Default: $SQUISH
29
--prosody-rev               Prosody revision to pull files from
30
                            Default: tip
31
--prosody-url               URL to pull Prosody files from (not compatible with --prosody-rev)
32
                            Default: $PROSODY_URL
33
--standalone                Embed Prosody's libraries in verse.lua instead of
34
                            requiring them from an installed Prosody at runtime
35
EOF
36
}
37
 
38
 
39
while [ "$1" ]
40
do
41
   value="`echo $1 | sed 's/[^=]*=\(.*\)/\1/'`"
42
   if echo "$value" | grep -q "~"
43
   then
44
      echo
45
      echo '*WARNING*: the "~" sign is not expanded in flags.'
46
      echo 'If you mean the home directory, use $HOME instead.'
47
      echo
48
   fi
49
   case "$1" in
50
   --help)
51
      show_help
52
      exit 0
53
      ;;
54
   --lua-lib-dir=*)
55
      LUA_LIBDIR="$value"
56
      ;;
57
   --with-squish=*)
58
      SQUISH="$value"
59
      ;;
60
   --prosody-rev=*)
61
      PROSODY_REV="$value"
62
      PROSODY_REV_SET=yes
63
      ;;
64
   --prosody-url=*)
65
      PROSODY_URL="$value"
66
      PROSODY_URL_SET=yes
67
      ;;
68
   --standalone)
69
      SQUISH_FLAGS="--standalone"
70
      ;;
71
   *)
72
      echo "Error: Unknown flag: $1"
73
      exit 1
74
      ;;
75
   esac
76
   shift
77
done
78
 
79
# Sanity-check options
80
 
81
if ! test -x "$SQUISH"; then
82
	echo "FATAL: Unable to find/use squish: $SQUISH";
83
	exit 1;
84
fi
85
 
86
if [ "$PROSODY_URL_SET" = "yes" -a "$PROSODY_REV_SET" = "yes" ]; then
87
	echo "FATAL: You can only specify one of --prosody-rev and --prosody-url, not both"
88
	exit 1;
89
fi
90
 
91
if [ "$PROSODY_REV_SET" = "yes" ]; then
92
	PROSODY_URL="https://hg.prosody.im/trunk/raw-file/${PROSODY_REV}/"
93
fi
94
 
95
cat <<EOF >config.unix
96
 
97
# This file was automatically generated by the configure script.
98
# Run "./configure --help" for details.
99
 
100
SQUISH=./buildscripts/squish
101
SQUISH_FLAGS=$SQUISH_FLAGS
102
PROSODY_URL=$PROSODY_URL
103
LUA_DIR=$LUA_DIR
104
EOF
105
 
106
echo
107
echo "Using squish from:            $SQUISH"
108
echo "Installing verse.lua to:      $LUA_DIR"
109
echo "Fetching Prosody files from:  $PROSODY_URL"
110
echo "Build type:                   ${SQUISH_FLAGS:-uses installed Prosody libraries}"
111
echo
112
echo "Configured successfully. Please run 'make' to proceed."