SHARE
TWEET

build_minetest.sh

fritigern Sep 19th, 2014 (edited) 468 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. ## ###################
  3. ## This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
  4. ## Read the license terms at http://creativecommons.org/licenses/by-nc-sa/4.0/
  5. ## ###################
  6. ## You can find the latest version of this script at https://gist.github.com/Fritigern/4e21484ec27d6416cc4
  7. ## ###################
  8.  
  9.     ## ******* TROUBLESHOOTING: *******
  10.     ## Run this if you get errors during the first time you try to build. (Works in Debian/Ubuntu, may work in other distros).
  11.    
  12.     ## *** For Debian-based distros (Ubuntu, Debian, etc) ***
  13.     # sudo apt-get install git build-essential libirrlicht-dev cmake libbz2-dev libpng12-dev libjpeg8-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev libhiredis-dev libleveldb-dev libluajit-5.1-dev libspatialindex-dev doxygen gcc-7 g++7
  14.  
  15.     ## *** For Arch-based distros (tested on Manjaro only) ***
  16.     # sudo pacman -S git cmake openal irrlicht libpng12 hiredis leveldb
  17.  
  18.  
  19. #### DOWNLOADING AND BUILDING MINETEST ####
  20. ## The following checks to see if the git repositories have been set up yet, and if needed,
  21. ## it will set up your local git repository and downloads the source code for minetest.
  22. if [ ! -d  Minetest ] ; then
  23.     git clone https://github.com/minetest/minetest Minetest
  24. fi
  25. if [ ! -d  Minetest/games/minetest_game ] ; then
  26.     git clone https://github.com/minetest/minetest_game Minetest/games/minetest_game
  27. fi
  28.  
  29. basedir=$PWD
  30.  
  31. #Timer, so that we know how long the compilation takes.
  32. function timer()
  33. {
  34.     if [[ $# -eq 0 ]]; then
  35.         echo $(date '+%s')
  36.     else
  37.         local  stime=$1
  38.         etime=$(date '+%s')
  39.         if [[ -z "$stime" ]]; then stime=$etime; fi
  40.         dt=$((etime - stime))
  41.         ds=$((dt % 60))
  42.         dm=$(((dt / 60) % 60))
  43.         dh=$((dt / 3600))
  44.         printf '%d:%02d:%02d' $dh $dm $ds
  45.     fi
  46. }
  47.  
  48. numcores=$(nproc) # Get the number of cores that your PC has
  49. let cores=$numcores-1 # Take away one, so that you will have one core free to do whatever else.
  50.  
  51. if [[ $cores == 0 ]]; then # If your PC has only one core, we will use that one core to compile Minetest
  52.   let cores=1
  53. fi
  54.  
  55. echo "************************************************************************"
  56. echo "**  Detected $numcores cores, so we be will using $cores cores for compilation.  **"
  57. echo "************************************************************************"
  58. echo
  59.  
  60. cd $basedir/Minetest/games/minetest_game # First we will try to update minetest_game
  61. echo ">>>> Updating minetest_game..."
  62. git pull # pull in the new updates, if there are any.
  63. echo
  64.  
  65. cd $basedir/Minetest # Now we go the Minetest dir, and try to update minetest itself.
  66. echo ">>>> Updating the minetest engine..."
  67. git pull # And pull again, this time for Minetest itself
  68. echo
  69.  
  70. # Please read the README.txt file for info on what the "-D" options do
  71.  
  72. #Start measuring compilation time....
  73. t=$(timer)
  74.  
  75. # Let's make a game!
  76. echo "-- *** Starting compilation ***"
  77.  
  78. cmake . -DRUN_IN_PLACE=TRUE -DENABLE_FREETYPE=TRUE -DENABLE_LEVELDB=0 -DENABLE_CURL=TRUE -DENABLE_SOUND=TRUE -DENABLE_LUAJIT=TRUE -DENABLE_SPATIAL=TRUE -DBUILD_SERVER=TRUE -DBUILD_CLIENT=TRUE -DENABLE_SYSTEM_JSONCPP=1 -DCMAKE_CXX_COMPILER=/usr/bin/g++-7
  79. make -j$cores
  80.  
  81. ENDTIME=$(timer $t) # We can stop measuring time now. Even if compilation failed.
  82.  
  83. # Check if the compilation is successful, If not, report the error and notify of stoppage.
  84. if [[ $? -ne 0 ]]; then
  85.  echo
  86.  echo "Error $? after $ENDTIME of compilation time. Script halted."
  87.  exit #Make sure to stop completely if there is an error. We do not want Minetest to be unplayable.
  88. fi
  89.  
  90. # Let's start minetest. You can enable/disable this bit if you want to.
  91. #cd $basedir/bin
  92. #exec ./minetest
  93.  
  94. echo "*********************"
  95. echo "****    Done!    ****"
  96. echo "*********************"
  97. echo
  98. echo "Compilation of minetest completed in "$ENDTIME
  99. echo
  100.  
  101. exit # Not really needed, but feels a nice wrap-up of the script.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top