diff options
| author | hisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c> | 2009-04-01 17:11:57 +0000 |
|---|---|---|
| committer | hisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c> | 2009-04-01 17:11:57 +0000 |
| commit | a88d6f2eeba2b3355c33fac6d736cf6086342f47 (patch) | |
| tree | 03ebfa0ced0186e091609cf337e290580fab8c11 /configure | |
| download | luarocks-0.2.tar.gz luarocks-0.2.tar.bz2 luarocks-0.2.zip | |
Import latest revision from CVS at luaforge.netv1.0v0.5.2v0.5.1v0.5v0.4.3v0.4.2v0.4.1v0.4v0.3.2v0.3.1v0.3v0.2v0.1
git-svn-id: http://luarocks.org/svn/luarocks/trunk@1 9ca3f7c1-7366-0410-b1a3-b5c78f85698c
Diffstat (limited to 'configure')
| -rwxr-xr-x | configure | 362 |
1 files changed, 362 insertions, 0 deletions
diff --git a/configure b/configure new file mode 100755 index 00000000..268b7241 --- /dev/null +++ b/configure | |||
| @@ -0,0 +1,362 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # A basic configure script for LuaRocks. | ||
| 4 | # Not doing any fancy shell stuff here to keep good compatibility. | ||
| 5 | |||
| 6 | # Defaults | ||
| 7 | |||
| 8 | PREFIX="/usr/local" | ||
| 9 | SYSCONFDIR="$PREFIX/etc/luarocks" | ||
| 10 | ROCKS_TREE="$PREFIX/lib/luarocks" | ||
| 11 | SCRIPTS_DIR="" | ||
| 12 | LUA_SUFFIX="" | ||
| 13 | LUA_DIR="/usr" | ||
| 14 | LUA_BINDIR="/usr/bin" | ||
| 15 | LUA_INCDIR="/usr/include" | ||
| 16 | LUA_LIBDIR="/usr/lib" | ||
| 17 | |||
| 18 | # ---------------------------------------------------------------------------- | ||
| 19 | # FUNCTION DEFINITIONS | ||
| 20 | # ---------------------------------------------------------------------------- | ||
| 21 | |||
| 22 | # Help | ||
| 23 | |||
| 24 | show_help() { | ||
| 25 | cat <<EOF | ||
| 26 | Configure LuaRocks. | ||
| 27 | |||
| 28 | --help This help. | ||
| 29 | --prefix=DIR Prefix where LuaRocks should be installed. | ||
| 30 | Default is $PREFIX | ||
| 31 | --sysconfdir=DIR Location where the config file should be installed. | ||
| 32 | Default is \$PREFIX/etc/luarocks | ||
| 33 | --rocks-tree=FILE Root of the local tree of installed rocks. | ||
| 34 | Default is \$PREFIX/lib/luarocks | ||
| 35 | --scripts-dir=DIR Where to install scripts installed by rocks. | ||
| 36 | Default is \$ROCKS_TREE/bin. Use this if you | ||
| 37 | want to modify it so that rocks install scripts | ||
| 38 | somewhere else (possibly somewhere in your \$PATH), | ||
| 39 | but if you use a system path such as /usr/bin, | ||
| 40 | beware of clashes between files installed by | ||
| 41 | LuaRocks and by your system's package manager. | ||
| 42 | Example: /usr/local/bin | ||
| 43 | --lua-suffix=SUFFIX Versioning suffix to use in Lua filenames. | ||
| 44 | Default is "$LUA_SUFFIX" (lua$LUA_SUFFIX...) | ||
| 45 | --with-lua=PREFIX Use Lua from given prefix. | ||
| 46 | Default is $LUA_DIR | ||
| 47 | --with-lua-include=DIR You can also specify Lua's includes dir. | ||
| 48 | Default is \$LUA_DIR/include | ||
| 49 | --with-lua-lib=DIR You can also specify Lua's libraries dir. | ||
| 50 | Default is \$LUA_DIR/lib | ||
| 51 | --with-downloader=TOOL Which tool to use as a downloader. | ||
| 52 | Valid options are: wget, curl. | ||
| 53 | Default is to auto-detect. | ||
| 54 | --with-md5-checker=TOOL Which tool to use as a downloader. | ||
| 55 | Valid options are: md5sum, openssl | ||
| 56 | Default is to auto-detect. | ||
| 57 | --force-config Use a single config location. Do not use the | ||
| 58 | \$LUAROCKS_CONFIG variable or the user's home | ||
| 59 | directory. Useful to avoid conflicts when LuaRocks | ||
| 60 | is embedded within an application. | ||
| 61 | EOF | ||
| 62 | } | ||
| 63 | |||
| 64 | # Helper functions | ||
| 65 | |||
| 66 | find_program() { | ||
| 67 | path="$PATH" | ||
| 68 | item="`echo "$path" | sed 's/\([^:]*\):.*/\1/'`" | ||
| 69 | path="`echo "$path" | sed -n 's/[^:]*::*\(.*\)/\1/p'`" | ||
| 70 | found="no" | ||
| 71 | while [ -n "$item" ] | ||
| 72 | do | ||
| 73 | if [ -f "$item/$1" ] | ||
| 74 | then | ||
| 75 | found="yes" | ||
| 76 | break | ||
| 77 | fi | ||
| 78 | item="`echo "$path" | sed 's/\([^:]*\):.*/\1/'`" | ||
| 79 | path="`echo "$path" | sed -n 's/[^:]*::*\(.*\)/\1/p'`" | ||
| 80 | done | ||
| 81 | if [ "$found" = "yes" ] | ||
| 82 | then | ||
| 83 | echo "$item" | ||
| 84 | else | ||
| 85 | echo "" | ||
| 86 | fi | ||
| 87 | } | ||
| 88 | |||
| 89 | find_helper() { | ||
| 90 | explanation="$1" | ||
| 91 | shift | ||
| 92 | tried="$*" | ||
| 93 | while [ -n "$1" ] | ||
| 94 | do | ||
| 95 | found=`find_program "$1"` | ||
| 96 | if [ -n "$found" ] | ||
| 97 | then | ||
| 98 | echo "$1 found at $found" | ||
| 99 | HELPER=$1 | ||
| 100 | return | ||
| 101 | fi | ||
| 102 | shift | ||
| 103 | done | ||
| 104 | echo "Could not find a $explanation. Tried: $tried." | ||
| 105 | echo "Make sure one of them is installed and available in your PATH." | ||
| 106 | exit 1 | ||
| 107 | } | ||
| 108 | |||
| 109 | case `echo -n x` in | ||
| 110 | -n*) echo_n_flag='';; | ||
| 111 | *) echo_n_flag='-n';; | ||
| 112 | esac | ||
| 113 | |||
| 114 | echo_n() { | ||
| 115 | echo $echo_n_flag "$*" | ||
| 116 | } | ||
| 117 | |||
| 118 | die() { | ||
| 119 | echo "$*" | ||
| 120 | exit 1 | ||
| 121 | } | ||
| 122 | |||
| 123 | # ---------------------------------------------------------------------------- | ||
| 124 | # MAIN PROGRAM | ||
| 125 | # ---------------------------------------------------------------------------- | ||
| 126 | |||
| 127 | # Parse options | ||
| 128 | |||
| 129 | while [ -n "$1" ] | ||
| 130 | do | ||
| 131 | value="`echo $1 | sed 's/[^=]*.\(.*\)/\1/'`" | ||
| 132 | key="`echo $1 | sed 's/=.*//'`" | ||
| 133 | if `echo "$value" | grep "~" >/dev/null 2>/dev/null` | ||
| 134 | then | ||
| 135 | echo | ||
| 136 | echo '*WARNING*: the "~" sign is not expanded in flags.' | ||
| 137 | echo 'If you mean the home directory, use $HOME instead.' | ||
| 138 | echo | ||
| 139 | fi | ||
| 140 | case "$key" in | ||
| 141 | --help) | ||
| 142 | show_help | ||
| 143 | exit 0 | ||
| 144 | ;; | ||
| 145 | --prefix) | ||
| 146 | [ -n "$value" ] || die "Missing value in flag $key." | ||
| 147 | PREFIX="$value" | ||
| 148 | PREFIX_SET=yes | ||
| 149 | ;; | ||
| 150 | --sysconfdir) | ||
| 151 | [ -n "$value" ] || die "Missing value in flag $key." | ||
| 152 | SYSCONFDIR="$value" | ||
| 153 | SYSCONFDIR_SET=yes | ||
| 154 | ;; | ||
| 155 | --rocks-tree) | ||
| 156 | [ -n "$value" ] || die "Missing value in flag $key." | ||
| 157 | ROCKS_TREE="$value" | ||
| 158 | ROCKS_TREE_SET=yes | ||
| 159 | ;; | ||
| 160 | --scripts-dir) | ||
| 161 | [ -n "$value" ] || die "Missing value in flag $key." | ||
| 162 | SCRIPTS_DIR="$value" | ||
| 163 | SCRIPTS_DIR_SET=yes | ||
| 164 | ;; | ||
| 165 | --force-config) | ||
| 166 | FORCE_CONFIG=yes | ||
| 167 | ;; | ||
| 168 | --lua-suffix) | ||
| 169 | [ -n "$value" ] || die "Missing value in flag $key." | ||
| 170 | LUA_SUFFIX="$value" | ||
| 171 | LUA_SUFFIX_SET=yes | ||
| 172 | ;; | ||
| 173 | --with-lua) | ||
| 174 | [ -n "$value" ] || die "Missing value in flag $key." | ||
| 175 | LUA_DIR="$value" | ||
| 176 | LUA_DIR_SET=yes | ||
| 177 | ;; | ||
| 178 | --with-lua-include) | ||
| 179 | [ -n "$value" ] || die "Missing value in flag $key." | ||
| 180 | LUA_INCDIR="$value" | ||
| 181 | LUA_INCDIR_SET=yes | ||
| 182 | ;; | ||
| 183 | --with-lua-lib) | ||
| 184 | [ -n "$value" ] || die "Missing value in flag $key." | ||
| 185 | LUA_LIBDIR="$value" | ||
| 186 | LUA_LIBDIR_SET=yes | ||
| 187 | ;; | ||
| 188 | --with-downloader) | ||
| 189 | [ -n "$value" ] || die "Missing value in flag $key." | ||
| 190 | case "$value" in | ||
| 191 | wget|curl) LUAROCKS_DOWNLOADER="$value" ;; | ||
| 192 | *) echo "Invalid option: $value. See --help." ; exit 1 ;; | ||
| 193 | esac | ||
| 194 | LUAROCKS_DOWNLOADER_SET=yes | ||
| 195 | ;; | ||
| 196 | --with-md5-checker) | ||
| 197 | [ -n "$value" ] || die "Missing value in flag $key." | ||
| 198 | case "$value" in | ||
| 199 | md5sum|openssl|md5) LUAROCKS_MD5CHECKER="$value" ;; | ||
| 200 | *) echo "Invalid option: $value. See --help." ; exit 1 ;; | ||
| 201 | esac | ||
| 202 | LUAROCKS_MD5CHECKER_SET=yes | ||
| 203 | ;; | ||
| 204 | *) | ||
| 205 | echo "Error: Unknown flag: $1" | ||
| 206 | exit 1 | ||
| 207 | ;; | ||
| 208 | esac | ||
| 209 | shift | ||
| 210 | done | ||
| 211 | |||
| 212 | |||
| 213 | if [ "$PREFIX_SET" = "yes" -a ! "$SYSCONFDIR_SET" = "yes" ] | ||
| 214 | then | ||
| 215 | if [ "$PREFIX" = "/usr" ] | ||
| 216 | then SYSCONFDIR=/etc/luarocks | ||
| 217 | else SYSCONFDIR=$PREFIX/etc/luarocks | ||
| 218 | fi | ||
| 219 | fi | ||
| 220 | |||
| 221 | |||
| 222 | if [ "$PREFIX_SET" = "yes" -a ! "$ROCKS_TREE_SET" = "yes" ] | ||
| 223 | then | ||
| 224 | ROCKS_TREE=$PREFIX/lib/luarocks | ||
| 225 | fi | ||
| 226 | |||
| 227 | if [ "$LUA_SUFFIX_SET" != "yes" ] | ||
| 228 | then | ||
| 229 | for suffix in "" "5.1" "51" "" | ||
| 230 | do | ||
| 231 | LUA_SUFFIX="$suffix" | ||
| 232 | if [ "$LUA_DIR_SET" = "yes" ] | ||
| 233 | then | ||
| 234 | if [ -f "$LUA_DIR/bin/lua$suffix" ] | ||
| 235 | then | ||
| 236 | find_lua="$LUA_DIR" | ||
| 237 | fi | ||
| 238 | else | ||
| 239 | find_lua=`find_program lua$suffix` | ||
| 240 | fi | ||
| 241 | if [ -n "$find_lua" ] | ||
| 242 | then | ||
| 243 | echo "Lua interpreter found: $find_lua/lua$suffix..." | ||
| 244 | break | ||
| 245 | fi | ||
| 246 | done | ||
| 247 | fi | ||
| 248 | |||
| 249 | if [ "$LUA_DIR_SET" != "yes" ] | ||
| 250 | then | ||
| 251 | echo_n "Looking for Lua... " | ||
| 252 | if [ ! -n "$find_lua" ] | ||
| 253 | then | ||
| 254 | find_lua=`find_program lua$LUA_SUFFIX` | ||
| 255 | fi | ||
| 256 | |||
| 257 | if [ -n "$find_lua" ] | ||
| 258 | then | ||
| 259 | LUA_DIR=`dirname $find_lua` | ||
| 260 | LUA_BINDIR="$find_lua" | ||
| 261 | echo "lua$LUA_SUFFIX found in \$PATH: $find_lua" | ||
| 262 | else | ||
| 263 | echo "lua$LUA_SUFFIX not found in \$PATH." | ||
| 264 | echo "You may want to use the flags --with-lua and/or --lua-suffix. See --help." | ||
| 265 | exit 1 | ||
| 266 | fi | ||
| 267 | fi | ||
| 268 | |||
| 269 | if [ "$LUA_INCDIR_SET" != "yes" ] | ||
| 270 | then | ||
| 271 | LUA_INCDIR="$LUA_DIR/include" | ||
| 272 | fi | ||
| 273 | |||
| 274 | if [ "$LUA_LIBDIR_SET" != "yes" ] | ||
| 275 | then | ||
| 276 | LUA_LIBDIR="$LUA_DIR/lib" | ||
| 277 | fi | ||
| 278 | |||
| 279 | if [ "$LUA_DIR_SET" = "yes" ] | ||
| 280 | then | ||
| 281 | LUA_BINDIR="$LUA_DIR/bin" | ||
| 282 | fi | ||
| 283 | |||
| 284 | echo_n "Checking Lua includes... " | ||
| 285 | lua_h="$LUA_INCDIR/lua.h" | ||
| 286 | if [ -f "$lua_h" ] | ||
| 287 | then | ||
| 288 | echo "lua.h found in $lua_h" | ||
| 289 | else | ||
| 290 | echo "lua.h not found (looked in $lua_h)" | ||
| 291 | echo "You may want to use the flag --with-lua-include. See --help." | ||
| 292 | exit 1 | ||
| 293 | fi | ||
| 294 | |||
| 295 | if [ "$LUAROCKS_DOWNLOADER_SET" != "yes" ] | ||
| 296 | then | ||
| 297 | find_helper "downloader helper program" wget curl fetch | ||
| 298 | LUAROCKS_DOWNLOADER=$HELPER | ||
| 299 | fi | ||
| 300 | |||
| 301 | if [ "$LUAROCKS_MD5CHECKER_SET" != "yes" ] | ||
| 302 | then | ||
| 303 | find_helper "MD5 checksum calculator" md5sum openssl md5 | ||
| 304 | LUAROCKS_MD5CHECKER=$HELPER | ||
| 305 | fi | ||
| 306 | |||
| 307 | echo_n "Configuring for system... " | ||
| 308 | if uname -s | ||
| 309 | then | ||
| 310 | LUAROCKS_UNAME_S=`uname -s` | ||
| 311 | else | ||
| 312 | echo "Could not determine operating system. 'uname -s' failed." | ||
| 313 | exit 1 | ||
| 314 | fi | ||
| 315 | echo_n "Configuring for architecture... " | ||
| 316 | if uname -m | ||
| 317 | then | ||
| 318 | LUAROCKS_UNAME_M=`uname -m` | ||
| 319 | else | ||
| 320 | echo "Could not determine processor architecture. 'uname -m' failed." | ||
| 321 | exit 1 | ||
| 322 | fi | ||
| 323 | |||
| 324 | if [ -f config.unix ]; then | ||
| 325 | rm -f config.unix | ||
| 326 | fi | ||
| 327 | |||
| 328 | # Write config | ||
| 329 | |||
| 330 | echo "Writing configuration..." | ||
| 331 | echo | ||
| 332 | |||
| 333 | cat <<EOF > config.unix | ||
| 334 | # This file was automatically generated by the configure script. | ||
| 335 | # Run "./configure --help" for details. | ||
| 336 | |||
| 337 | PREFIX=$PREFIX | ||
| 338 | SYSCONFDIR=$SYSCONFDIR | ||
| 339 | ROCKS_TREE=$ROCKS_TREE | ||
| 340 | SCRIPTS_DIR=$SCRIPTS_DIR | ||
| 341 | LUA_SUFFIX=$LUA_SUFFIX | ||
| 342 | LUA_DIR=$LUA_DIR | ||
| 343 | LUA_INCDIR=$LUA_INCDIR | ||
| 344 | LUA_LIBDIR=$LUA_LIBDIR | ||
| 345 | LUA_BINDIR=$LUA_BINDIR | ||
| 346 | FORCE_CONFIG=$FORCE_CONFIG | ||
| 347 | LUAROCKS_UNAME_M=$LUAROCKS_UNAME_M | ||
| 348 | LUAROCKS_UNAME_S=$LUAROCKS_UNAME_S | ||
| 349 | LUAROCKS_DOWNLOADER=$LUAROCKS_DOWNLOADER | ||
| 350 | LUAROCKS_MD5CHECKER=$LUAROCKS_MD5CHECKER | ||
| 351 | |||
| 352 | EOF | ||
| 353 | |||
| 354 | echo "Installation prefix: $PREFIX" | ||
| 355 | echo "LuaRocks configuration directory: $SYSCONFDIR" | ||
| 356 | echo "Using Lua from: $LUA_DIR" | ||
| 357 | |||
| 358 | make clean > /dev/null 2> /dev/null | ||
| 359 | |||
| 360 | echo | ||
| 361 | echo "Done. You can now run 'make' to build." | ||
| 362 | echo | ||
