Advertisement
_dinsdale

Untitled

Jul 20th, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.19 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3.  
  4. #******************************************************
  5. #Title: lau_build-1
  6. #Description: Lua build script because I suck at Makefiles
  7. #Author:Russell Haley
  8. #Date:May23 2016
  9. #License: Simplified BSD
  10. #******************************************************
  11.  
  12. #Helper Functions to clean the code up.
  13. get_src()
  14. {
  15.   echo "Downloading..."
  16.   git clone $1 $2
  17. }
  18.  
  19. run_build()
  20. {
  21.   echo "Building..."
  22.   cd $1
  23.   $2
  24. }
  25.  
  26. run_install()
  27. {
  28.   echo "Installing..."
  29.   cd $1
  30.   sudo gmake install
  31. }
  32.  
  33. say_hello()
  34. {
  35.   echo "Begin DWE build script for Lua ${LUA_VER}"
  36.   echo "Build Target Path: ${BUILD_DIR}/lua"
  37. }
  38.  
  39. #Removes all the source code from the tmp directory
  40. run_cleanup()
  41. {
  42.   echo "Removing any previous builds..."
  43.   rm -rf ${BUILD_DIR} #/luarocks
  44. }
  45.  
  46.  
  47. build_lua()
  48. {
  49.   get_src "https://github.com/lua/lua.git" ${BUILD_DIR}"/lua"
  50.   operation_system=`uname -s | tr '[:upper:]' '[:lower:]'`
  51.   cd ${BUILD_DIR}"/lua/src"
  52.   echo "patch the lua build to include the -fPIC flag to allow shared files"
  53.   sed -i -e 's/MYCFLAGS=/MYCFLAGS=-fPIC/g' Makefile
  54.   #Undo the previous change...
  55.   #sed -i -e 's/MYCFLAGS=-fPIC/MYCFLAGS=/g' Makefile
  56.  echo ${operating_system}
  57.   run_build ${BUILD_DIR}"/lua/src" "${MAKE} ${operation_system}"
  58.     echo "Installing Lua"
  59.   run_install ${BUILD_DIR}"/lua"
  60. }
  61.  
  62. #copies all the Lua files to the correct locations
  63. #see https://bitbucket.org/envb/dwe/issues/3 for locations
  64. #RH May 27 2016 - I don't think this is needed if we just
  65. #use the standard lua install path
  66. install_lua()
  67. {
  68.  
  69.    
  70.    
  71.     cd $1
  72.     sudo ${MAKE} install
  73.     sudo mkdir -p ${LUA_BIN_DIR}
  74.    
  75.     cd ${BUILD_DIR}"/lua/src"
  76.     sudo cp lua ${LUA_BIN_DIR}
  77.     #THIS IS OBVIOSULY WRONG
  78.     #ln -s ${LUA_BIN_DIR}/lua -t /usr/local/bin/
  79.  
  80.     sudo cp luac ${LUA_BIN_DIR}
  81.     #THIS IS OBVIOSULY WRONG
  82.     #ln -s ${LUA_BIN_DIR}/luac -t /usr/local/bin/
  83.  
  84.     sudo mkdir -p ${LUA_INCL_DIR}
  85.  
  86.     #These are the header files used by c modules
  87.     #to compile against lua
  88.     sudo cp lua.h ${LUA_INCL_DIR}
  89.     sudo cp lauxlib.h ${LUA_INCL_DIR}
  90.     sudo cp lualib.h ${LUA_INCL_DIR}
  91.     sudo cp luaconf.h ${LUA_INCL_DIR}
  92.    
  93.     #Directory where all the libriaries will go.
  94.     sudo mkdir -p ${LUA_LIB_DIR}       
  95.    
  96.     }
  97.  
  98. #Symas Lightning Memory-mapped Database
  99. #https://symas.com/products/lightning-memory-mapped-database/
  100. #https://github.com/lmdb/
  101. build_lmdb()
  102. {
  103.   get_src "https://github.com/lmdb/lmdb.git" ${BUILD_DIR}"/lmdb"  
  104.   run_build ${BUILD_DIR}"/lmdb/libraries/liblmdb/" "make"
  105.   run_install ${BUILD_DIR}"/lmdb/libraries/liblmdb/"
  106. }
  107.  
  108. #https://github.com/keplerproject/luarocks
  109. build_lua_rocks()
  110. {
  111.   get_src "https://github.com/keplerproject/luarocks.git" ${BUILD_DIR}"/luarocks"  
  112.   cd ${BUILD_DIR}"/luarocks"
  113.   #sh configure --with-lua-include=${LUA_INCL_DIR} --with-lua-lib=${LUA_LIB_DIR} --with-lua-bin=${LUA_BIN_DIR}
  114.   sh configure
  115.   run_build ${BUILD_DIR}"/luarocks" "${MAKE} build"
  116.   run_install ${BUILD_DIR}"/luarocks"
  117. }
  118.  
  119. build_luaxml()
  120. {
  121. mkdir ${BUILD_DIR}/viremo
  122. cd ${BUILD_DIR}/viremo/
  123. wget -O LuaXML_130610.zip http://viremo.eludi.net/LuaXML/LuaXML_130610.zip
  124. mkdir -p LuaXML/src
  125. unzip -d LuaXML/src LuaXML_130610.zip
  126. cd LuaXML/src
  127. make
  128. sudo cp LuaXML_lib.so ${LUA_LIB_DIR}
  129. sudo cp LuaXml.lua ${LUA_LIB_DIR}
  130. }
  131.  
  132. build_luasys()
  133. {
  134. cd ${BUILD_DIR}
  135. git clone https://github.com/russellhaley/luasys.git
  136. cd luasys/src
  137. make && sudo make install
  138. }
  139.  
  140. build_lua_t()
  141. {}
  142.  
  143. rocks_penlight(){}
  144.  
  145. rocks_lightning(){}
  146.  
  147. #Sets all the important variables
  148. #for building lua and other stuffs.
  149. setup()
  150. {
  151.    
  152.     #Not ready for this yet!
  153.     #LUA_BIN_DIR=/usr/local/bin/lua/5.3
  154.     #LUA_LIB_DIR=/usr/local/lib/lua/5.3
  155.     #LUA_INCL_DIR=/usr/local/include/5.3
  156.  
  157.     LUA_BIN_DIR=/usr/local/bin/lua/5.3
  158.     LUA_LIB_DIR=/usr/local/lib/lua/5.3
  159.     LUA_INCL_DIR=/usr/local/include/5.3
  160.  
  161.     MAKE=gmake
  162.  
  163.     BUILD_DIR=/tmp/build
  164.  
  165.     OBJ_DIR=/tmp/obj
  166.     LUA_VER=5.3
  167. }
  168.    
  169. # This is used to delete the installation and start again.
  170. teardown()
  171. {
  172.     rm -rf ${LUA_BIN_DIR}
  173.     rm -rf ${LUA_LIB_DIR}
  174.     rm -rf ${LUA_INCL_DIR}
  175. }  
  176.    
  177.  
  178. setup
  179.  
  180. say_hello
  181. run_cleanup
  182. build_lua
  183. build_lmdb
  184. build_lua_rocks
  185. build_luaxml
  186. build_luasys
  187. sudo luarocks install lightningmdb
  188.  
  189. #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