Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #******************************************************
- #Title: lau_build-1
- #Description: Lua build script because I suck at Makefiles
- #Author:Russell Haley
- #Date:May23 2016
- #License: Simplified BSD
- #******************************************************
- #Helper Functions to clean the code up.
- get_src()
- {
- echo "Downloading..."
- git clone $1 $2
- }
- run_build()
- {
- echo "Building..."
- cd $1
- $2
- }
- run_install()
- {
- echo "Installing..."
- cd $1
- sudo gmake install
- }
- say_hello()
- {
- echo "Begin DWE build script for Lua ${LUA_VER}"
- echo "Build Target Path: ${BUILD_DIR}/lua"
- }
- #Removes all the source code from the tmp directory
- run_cleanup()
- {
- echo "Removing any previous builds..."
- rm -rf ${BUILD_DIR} #/luarocks
- }
- build_lua()
- {
- get_src "https://github.com/lua/lua.git" ${BUILD_DIR}"/lua"
- operation_system=`uname -s | tr '[:upper:]' '[:lower:]'`
- cd ${BUILD_DIR}"/lua/src"
- echo "patch the lua build to include the -fPIC flag to allow shared files"
- sed -i -e 's/MYCFLAGS=/MYCFLAGS=-fPIC/g' Makefile
- #Undo the previous change...
- #sed -i -e 's/MYCFLAGS=-fPIC/MYCFLAGS=/g' Makefile
- echo ${operating_system}
- run_build ${BUILD_DIR}"/lua/src" "${MAKE} ${operation_system}"
- echo "Installing Lua"
- run_install ${BUILD_DIR}"/lua"
- }
- #copies all the Lua files to the correct locations
- #see https://bitbucket.org/envb/dwe/issues/3 for locations
- #RH May 27 2016 - I don't think this is needed if we just
- #use the standard lua install path
- install_lua()
- {
- cd $1
- sudo ${MAKE} install
- sudo mkdir -p ${LUA_BIN_DIR}
- cd ${BUILD_DIR}"/lua/src"
- sudo cp lua ${LUA_BIN_DIR}
- #THIS IS OBVIOSULY WRONG
- #ln -s ${LUA_BIN_DIR}/lua -t /usr/local/bin/
- sudo cp luac ${LUA_BIN_DIR}
- #THIS IS OBVIOSULY WRONG
- #ln -s ${LUA_BIN_DIR}/luac -t /usr/local/bin/
- sudo mkdir -p ${LUA_INCL_DIR}
- #These are the header files used by c modules
- #to compile against lua
- sudo cp lua.h ${LUA_INCL_DIR}
- sudo cp lauxlib.h ${LUA_INCL_DIR}
- sudo cp lualib.h ${LUA_INCL_DIR}
- sudo cp luaconf.h ${LUA_INCL_DIR}
- #Directory where all the libriaries will go.
- sudo mkdir -p ${LUA_LIB_DIR}
- }
- #Symas Lightning Memory-mapped Database
- #https://symas.com/products/lightning-memory-mapped-database/
- #https://github.com/lmdb/
- build_lmdb()
- {
- get_src "https://github.com/lmdb/lmdb.git" ${BUILD_DIR}"/lmdb"
- run_build ${BUILD_DIR}"/lmdb/libraries/liblmdb/" "make"
- run_install ${BUILD_DIR}"/lmdb/libraries/liblmdb/"
- }
- #https://github.com/keplerproject/luarocks
- build_lua_rocks()
- {
- get_src "https://github.com/keplerproject/luarocks.git" ${BUILD_DIR}"/luarocks"
- cd ${BUILD_DIR}"/luarocks"
- #sh configure --with-lua-include=${LUA_INCL_DIR} --with-lua-lib=${LUA_LIB_DIR} --with-lua-bin=${LUA_BIN_DIR}
- sh configure
- run_build ${BUILD_DIR}"/luarocks" "${MAKE} build"
- run_install ${BUILD_DIR}"/luarocks"
- }
- build_luaxml()
- {
- mkdir ${BUILD_DIR}/viremo
- cd ${BUILD_DIR}/viremo/
- wget -O LuaXML_130610.zip http://viremo.eludi.net/LuaXML/LuaXML_130610.zip
- mkdir -p LuaXML/src
- unzip -d LuaXML/src LuaXML_130610.zip
- cd LuaXML/src
- make
- sudo cp LuaXML_lib.so ${LUA_LIB_DIR}
- sudo cp LuaXml.lua ${LUA_LIB_DIR}
- }
- build_luasys()
- {
- cd ${BUILD_DIR}
- git clone https://github.com/russellhaley/luasys.git
- cd luasys/src
- make && sudo make install
- }
- build_lua_t()
- {}
- rocks_penlight(){}
- rocks_lightning(){}
- #Sets all the important variables
- #for building lua and other stuffs.
- setup()
- {
- #Not ready for this yet!
- #LUA_BIN_DIR=/usr/local/bin/lua/5.3
- #LUA_LIB_DIR=/usr/local/lib/lua/5.3
- #LUA_INCL_DIR=/usr/local/include/5.3
- LUA_BIN_DIR=/usr/local/bin/lua/5.3
- LUA_LIB_DIR=/usr/local/lib/lua/5.3
- LUA_INCL_DIR=/usr/local/include/5.3
- MAKE=gmake
- BUILD_DIR=/tmp/build
- OBJ_DIR=/tmp/obj
- LUA_VER=5.3
- }
- # This is used to delete the installation and start again.
- teardown()
- {
- rm -rf ${LUA_BIN_DIR}
- rm -rf ${LUA_LIB_DIR}
- rm -rf ${LUA_INCL_DIR}
- }
- setup
- say_hello
- run_cleanup
- build_lua
- build_lmdb
- build_lua_rocks
- build_luaxml
- build_luasys
- sudo luarocks install lightningmdb
- #sudo luarocks penlight --> Need to get rid of this for now. find a different configuration Parser?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement