#! /bin/bash ################################################################################ # Prepare ################################################################################ # Set up shell set -x # Output commands set -e # Abort on errors ################################################################################ # Build ################################################################################ if [ -z "${LUA_DIR}" -o "${LUA_DIR}" = 'BUILD' ]; then echo "BEGIN MESSAGE" echo "Building Lua..." echo "END MESSAGE" # Set locations THORN=lua NAME=lua-5.2.2 SRCDIR=$(dirname $0) BUILD_DIR=${SCRATCH_BUILD}/build/${THORN} INSTALL_DIR=${SCRATCH_BUILD}/external/${THORN} DONE_FILE=${SCRATCH_BUILD}/done/${THORN} LUA_DIR=${INSTALL_DIR} ( exec >&2 # Redirect stdout to stderr set -x # Output commands set -e # Abort on errors cd ${SCRATCH_BUILD} if [ -e ${DONE_FILE} -a ${DONE_FILE} -nt ${SRCDIR}/dist/${NAME}.tar.gz \ -a ${DONE_FILE} -nt ${SRCDIR}/lua.sh ] then echo "LUA: The enclosed lua library has already been built; doing nothing" else echo "LUA: Building enclosed lua library" # Should we use gmake or make? MAKE=$(gmake --help > /dev/null 2>&1 && echo gmake || echo make) # Should we use gtar or tar? TAR=$(gtar --help > /dev/null 2> /dev/null && echo gtar || echo tar) # Set up environment unset LIBS echo "LUA: Preparing directory structure..." mkdir build external done 2> /dev/null || true rm -rf ${BUILD_DIR} ${INSTALL_DIR} mkdir ${BUILD_DIR} ${INSTALL_DIR} echo "LUA: Unpacking archive..." pushd ${BUILD_DIR} ${TAR} xzf ${SRCDIR}/dist/${NAME}.tar.gz echo "LUA: Configuring..." target="generic" # Check whether we are running on Windows if perl -we 'exit (`uname` !~ /^CYGWIN/)'; then target="mingw" fi # Check whether we are running on MacOS if perl -we 'exit (`uname` !~ /^Darwin/)'; then target="macosx" fi # Check whether we are running on Linux if perl -we 'exit (`uname` !~ /^Linux/)'; then target="linux" fi cd ${NAME} perl -p -i -e "s:^CFLAGS=(.*):CFLAGS=\$1 -I${LIBREADLINE_INC_DIRS} -L${LIBREADLINE_LIB_DIRS} -I${LIBNCURSES_INC_DIRS} -L${LIBNCURSES_LIB_DIRS}:g" src/Makefile perl -p -i -e 's:\$\(CC\) -o \$@:\$(CC) -o \$@ \$(CFLAGS):g' src/Makefile perl -p -i -e 's:(-Wl,-E -ldl -lreadline):\1 -lncurses:' src/Makefile echo "LUA: Building (${target}) ..." ${MAKE} $target echo "LUA: Installing..." ${MAKE} install INSTALL_TOP=${INSTALL_DIR} popd echo "LUA: Cleaning up..." rm -rf ${BUILD_DIR} date > ${DONE_FILE} echo "LUA: Done." fi ) if (( $? )); then echo 'BEGIN ERROR' echo 'Error while building LUA. Aborting.' echo 'END ERROR' exit 1 fi fi ################################################################################ # Configure Cactus ################################################################################ # Set options LUA_INC_DIRS="${LUA_DIR}/include" LUA_LIB_DIRS="${LUA_DIR}/lib" LUA_LIBS="lua" # Pass options to Cactus echo "BEGIN MAKE_DEFINITION" echo "HAVE_LUA = 1" echo "LUA_DIR = ${LUA_DIR}" echo "LUA_INC_DIRS = ${LUA_INC_DIRS}" echo "LUA_LIB_DIRS = ${LUA_LIB_DIRS}" echo "LUA_LIBS = ${LUA_LIBS}" cat ${SRCDIR}/src/make.lua.rules echo "END MAKE_DEFINITION" echo 'INCLUDE_DIRECTORY $(LUA_INC_DIRS) $(CURL_INC_DIRS) $(LIBXML2_INC_DIRS)' echo 'LIBRARY_DIRECTORY $(LUA_LIB_DIRS) $(CURL_LIB_DIRS) $(LIBXML2_LIB_DIRS)' echo 'LIBRARY $(LUA_LIBS) $(CURL_LIBS) $(LIBXML2_LIBS)'