#!/bin/bash # A basic installation script for Lua. # Defaults PREFIX="/usr/local" LUA_SUFFIX="" BUILD_LUA="yes" INSTALL_LUA="yes" USE_READLINE="yes" NCURSES_DIR="/usr" READLINE_DIR="/usr" LUA_DIR="/usr" LUA_INCDIR="/usr/include" LUA_LIBDIR="/usr/lib" LUA_BINDIR="/usr/bin" UNAME="`uname`" if ! [ "$UNAME" = "Linux" -o "$UNAME" = "Darwin" -o "$UNAME" = "FreeBSD" ] then USE_READLINE=no fi LUA_VERSION=5.1.2 EASYLUA_VERSION=0.1 # Help show_help() { cat < Makefile # This file was automatically generated by the configure script. # Run "./configure --help" for details. BUILD_LUA=$BUILD_LUA INSTALL_LUA=$INSTALL_LUA USE_READLINE=$USE_READLINE PREFIX=$PREFIX INCLUDEDIR=$INCLUDEDIR LUA_SUFFIX=$LUA_SUFFIX READLINE_DIR=$READLINE_DIR NCURSES_DIR=$NCURSES_DIR LUA_DIR=$LUA_DIR LUA_INCDIR=$LUA_INCDIR LUA_LIBDIR=$LUA_LIBDIR LUA_BINDIR=$LUA_BINDIR LUA_URL=http://www.lua.org/ftp READLINE_LIBDIR=\$(READLINE_DIR)/lib READLINE_INCLUDEDIR=\$(READLINE_DIR)/include NCURSES_LIBDIR=\$(NCURSES_DIR)/lib NCURSES_INCLUDEDIR=\$(NCURSES_DIR)/include LUA_VERSION=$LUA_VERSION PLATFORM_CFLAGS=-Wl,-E PLATFORM_LDFLAGS=-lm -ldl LIB_FLAG=-shared ifeq (\$(shell uname -m | sed 's/i.86/i386/'),i386) FPIC= else FPIC=-fpic endif LUA_LIB=\$(LUA_LIBDIR)/liblua\$(LUA_SUFFIX).a LUA_DEFPATH=-DLUA_ROOT=\\\\\\"\$(LUA_DIR)\\\\\\" ifeq (\$(USE_READLINE), yes) LUA_READLINE_CFLAGS=-DLUA_USE_READLINE -I\$(READLINE_INCLUDEDIR) LUA_READLINE_LIBS=-lreadline -lhistory -lncurses -L\$(READLINE_LIBDIR) -L\$(NCURSES_LIBDIR) else LUA_READLINE_CFLAGS= LUA_READLINE_LIBS= endif LUA_MYCFLAGS=-DLUA_USE_POSIX -DLUA_USE_DLOPEN \$(LUA_READLINE_CFLAGS) LUA_MYLIBS=\$(PLATFORM_CFLAGS) -ldl \$(LUA_READLINE_LIBS) WGET=wget -c -t0 PLATFORM_BUILD=build ifeq (\$(shell bash -c 'echo $${OSTYPE%%[0-9]*}'),darwin) PLATFORM_BUILD=OSX-build ifneq (\$(LUA_READLINE_LIBS),) LUA_READLINE_LIBS=-lreadline -L\$(READLINE_LIBDIR) endif endif ifeq (\$(shell uname -s),FreeBSD) PLATFORM_BUILD=FreeBSD-build endif platform: \$(PLATFORM_BUILD) OSX-build: MACOSX_DEPLOYMENT_TARGET=10.3 \$(MAKE) \\ LUA_MYCFLAGS="-DLUA_USE_MACOSX \$(LUA_READLINE_CFLAGS)" \\ LUA_MYLIBS="\$(LUA_READLINE_LIBS)" \\ PLATFORM_CFLAGS="-dynamic" \\ PLATFORM_LDFLAGS="-lm -ldl" \\ LIB_FLAG="-bundle -undefined dynamic_lookup -all_load" \\ build FreeBSD-build: \$(MAKE) \\ LUA_MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" \\ LUA_MYLIBS="-Wl,-E" \\ PLATFORM_LDFLAGS="-lm" \\ build LUA_TESTFILE=lua-\$(LUA_VERSION)/src/lua\$(LUA_SUFFIX) fetch: lua-\$(LUA_VERSION) lua-\$(LUA_VERSION).tar.gz: \$(WGET) \$(LUA_URL)/\$@ lua-\$(LUA_VERSION): \$(MAKE) lua-\$(LUA_VERSION).tar.gz test -d \$@ || tar zxvpf lua-\$(LUA_VERSION).tar.gz cd lua-\$(LUA_VERSION) && patch -p1 < ../lua-\$(LUA_VERSION)-easylua.diff build: \$(LUA_TESTFILE) \$(LUA_TESTFILE): lua-\$(LUA_VERSION) cd lua-\$(LUA_VERSION) && \$(MAKE) \\ LUA_SUFFIX="\$(LUA_SUFFIX)" \\ INSTALL_INC="\$(LUA_INCDIR)" \\ MYCFLAGS="\$(LUA_DEFPATH) \$(LUA_MYCFLAGS)" \\ MYLIBS="\$(LUA_MYLIBS)" \\ CC="\$(CC)" \\ generic install: build cd lua-\$(LUA_VERSION) && \$(MAKE) \\ LUA_SUFFIX="\$(LUA_SUFFIX)" \\ INSTALL_INC="\$(LUA_INCDIR)" \\ INSTALL_TOP="\$(LUA_DIR)" \\ MYCFLAGS="\$(LUA_MYCFLAGS)" \\ MYLIBS="\$(LUA_MYLIBS)" \\ INSTALL_EXEC="install -p -m 0755" \\ INSTALL_DATA="install -p -m 0644" \\ STRIP="true" \\ install clean: if [ -d lua-\$(LUA_VERSION) ]; then \\ cd lua-\$(LUA_VERSION) && \$(MAKE) \\ LUA_SUFFIX="\$(LUA_SUFFIX)" \\ clean; \\ fi klean: rm -f lua-\$(LUA_VERSION).tar.gz rm -rf lua-\$(LUA_VERSION) rm -f Makefile rm -f lua-\$(LUA_VERSION)-easylua.diff EOF cat < lua-5.1.2-easylua.diff diff -Naur lua-5.1.2-orig/Makefile lua-5.1.2/Makefile --- lua-5.1.2-orig/Makefile 2007-03-25 11:44:39.000000000 -0300 +++ lua-5.1.2/Makefile 2007-05-11 16:08:02.000000000 -0300 @@ -41,10 +41,10 @@ PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris # What to install. -TO_BIN= lua luac +TO_BIN= lua\$(LUA_SUFFIX) luac\$(LUA_SUFFIX) TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp -TO_LIB= liblua.a -TO_MAN= lua.1 luac.1 +TO_LIB= liblua\$(LUA_SUFFIX).a +TO_MAN= lua\$(LUA_SUFFIX).1 luac\$(LUA_SUFFIX).1 # Lua version and release. V= 5.1 @@ -56,13 +56,17 @@ cd src && \$(MAKE) \$@ test: dummy - src/lua test/hello.lua + src/lua\$(LUA_SUFFIX) test/hello.lua install: dummy cd src && \$(MKDIR) -p \$(INSTALL_BIN) \$(INSTALL_INC) \$(INSTALL_LIB) \$(INSTALL_MAN) \$(INSTALL_LMOD) \$(INSTALL_CMOD) cd src && \$(INSTALL_EXEC) \$(TO_BIN) \$(INSTALL_BIN) cd src && \$(INSTALL_DATA) \$(TO_INC) \$(INSTALL_INC) cd src && \$(INSTALL_DATA) \$(TO_LIB) \$(INSTALL_LIB) + cp doc/lua.1 doc/t_lua.1 + cp doc/luac.1 doc/t_luac.1 + mv doc/t_lua.1 doc/lua\$(LUA_SUFFIX).1 + mv doc/t_luac.1 doc/luac\$(LUA_SUFFIX).1 cd doc && \$(INSTALL_DATA) \$(TO_MAN) \$(INSTALL_MAN) # \$(RANLIB) \$(INSTALL_LIB)/\$(TO_LIB) diff -Naur lua-5.1.2-orig/src/luaconf.h lua-5.1.2/src/luaconf.h --- lua-5.1.2-orig/src/luaconf.h 2007-03-24 00:01:55.000000000 -0300 +++ lua-5.1.2/src/luaconf.h 2007-05-11 16:12:55.000000000 -0300 @@ -94,9 +94,11 @@ ".\\\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" #else -#define LUA_ROOT "/usr/local/" -#define LUA_LDIR LUA_ROOT "share/lua/5.1/" -#define LUA_CDIR LUA_ROOT "lib/lua/5.1/" +#ifndef LUA_ROOT +#define LUA_ROOT "/usr/local" +#endif +#define LUA_LDIR LUA_ROOT "/share/lua/5.1/" +#define LUA_CDIR LUA_ROOT "/lib/lua/5.1/" #define LUA_PATH_DEFAULT \\ "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \\ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" diff -Naur lua-5.1.2-orig/src/Makefile lua-5.1.2/src/Makefile --- lua-5.1.2-orig/src/Makefile 2007-03-25 11:49:23.000000000 -0300 +++ lua-5.1.2/src/Makefile 2007-05-11 16:08:02.000000000 -0300 @@ -22,17 +22,17 @@ PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris -LUA_A= liblua.a +LUA_A= liblua\$(LUA_SUFFIX).a CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \\ lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \\ lundump.o lvm.o lzio.o LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \\ lstrlib.o loadlib.o linit.o -LUA_T= lua +LUA_T= lua\$(LUA_SUFFIX) LUA_O= lua.o -LUAC_T= luac +LUAC_T= luac\$(LUA_SUFFIX) LUAC_O= luac.o print.o ALL_O= \$(CORE_O) \$(LIB_O) \$(LUA_O) \$(LUAC_O) @@ -93,7 +93,7 @@ \$(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline" generic: - \$(MAKE) all MYCFLAGS= + \$(MAKE) all linux: \$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" EOF echo "Installing Lua on $PREFIX" if [ "`uname -s`" = "FreeBSD" ] then MAKE=gmake else MAKE=make fi $MAKE clean > /dev/null 2> /dev/null $MAKE $MAKE install echo echo "Done. Lua is installed on $PREFIX." echo echo echo "Cleaning up..." echo popd && rm -rf /tmp/easylua-$EASYLUA_VERSION