Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ## ###################
- ## This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
- ## Read the license terms at http://creativecommons.org/licenses/by-nc-sa/4.0/
- ## ###################
- ## You can find the latest version of this script at https://gist.github.com/Fritigern/4e21484ec27d6416cc4
- ## ###################
- ## ******* TROUBLESHOOTING: *******
- ## Run this if you get errors during the first time you try to build. (Works in Debian/Ubuntu, may work in other distros).
- ## *** For Debian-based distros (Ubuntu, Debian, etc) ***
- # 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
- ## *** For Arch-based distros (tested on Manjaro only) ***
- # sudo pacman -S git cmake openal irrlicht libpng12 hiredis leveldb
- #### DOWNLOADING AND BUILDING MINETEST ####
- ## The following checks to see if the git repositories have been set up yet, and if needed,
- ## it will set up your local git repository and downloads the source code for minetest.
- if [ ! -d Minetest ] ; then
- git clone https://github.com/minetest/minetest Minetest
- fi
- if [ ! -d Minetest/games/minetest_game ] ; then
- git clone https://github.com/minetest/minetest_game Minetest/games/minetest_game
- fi
- basedir=$PWD
- #Timer, so that we know how long the compilation takes.
- function timer()
- {
- if [[ $# -eq 0 ]]; then
- echo $(date '+%s')
- else
- local stime=$1
- etime=$(date '+%s')
- if [[ -z "$stime" ]]; then stime=$etime; fi
- dt=$((etime - stime))
- ds=$((dt % 60))
- dm=$(((dt / 60) % 60))
- dh=$((dt / 3600))
- printf '%d:%02d:%02d' $dh $dm $ds
- fi
- }
- numcores=$(nproc) # Get the number of cores that your PC has
- let cores=$numcores-1 # Take away one, so that you will have one core free to do whatever else.
- if [[ $cores == 0 ]]; then # If your PC has only one core, we will use that one core to compile Minetest
- let cores=1
- fi
- echo "************************************************************************"
- echo "** Detected $numcores cores, so we be will using $cores cores for compilation. **"
- echo "************************************************************************"
- echo
- cd $basedir/Minetest/games/minetest_game # First we will try to update minetest_game
- echo ">>>> Updating minetest_game..."
- git pull # pull in the new updates, if there are any.
- echo
- cd $basedir/Minetest # Now we go the Minetest dir, and try to update minetest itself.
- echo ">>>> Updating the minetest engine..."
- git pull # And pull again, this time for Minetest itself
- echo
- # Please read the README.txt file for info on what the "-D" options do
- #Start measuring compilation time....
- t=$(timer)
- # Let's make a game!
- echo "-- *** Starting compilation ***"
- 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
- make -j$cores
- ENDTIME=$(timer $t) # We can stop measuring time now. Even if compilation failed.
- # Check if the compilation is successful, If not, report the error and notify of stoppage.
- if [[ $? -ne 0 ]]; then
- echo
- echo "Error $? after $ENDTIME of compilation time. Script halted."
- exit #Make sure to stop completely if there is an error. We do not want Minetest to be unplayable.
- fi
- # Let's start minetest. You can enable/disable this bit if you want to.
- #cd $basedir/bin
- #exec ./minetest
- echo "*********************"
- echo "**** Done! ****"
- echo "*********************"
- echo
- echo "Compilation of minetest completed in "$ENDTIME
- echo
- exit # Not really needed, but feels a nice wrap-up of the script.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement