summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSafwatHalaby <SafwatHalaby@users.noreply.github.com>2015-05-24 11:30:22 +0200
committerSafwatHalaby <SafwatHalaby@users.noreply.github.com>2015-05-24 12:48:15 +0200
commit9a6fb60c8501da201cc5d2b45c1d1fad8de8af6c (patch)
tree2128a003038d61151f438cb4e0bc24e7d6ff4d42
parentMerge pull request #2086 from Seadragon91/master (diff)
downloadcuberite-9a6fb60c8501da201cc5d2b45c1d1fad8de8af6c.tar
cuberite-9a6fb60c8501da201cc5d2b45c1d1fad8de8af6c.tar.gz
cuberite-9a6fb60c8501da201cc5d2b45c1d1fad8de8af6c.tar.bz2
cuberite-9a6fb60c8501da201cc5d2b45c1d1fad8de8af6c.tar.lz
cuberite-9a6fb60c8501da201cc5d2b45c1d1fad8de8af6c.tar.xz
cuberite-9a6fb60c8501da201cc5d2b45c1d1fad8de8af6c.tar.zst
cuberite-9a6fb60c8501da201cc5d2b45c1d1fad8de8af6c.zip
-rw-r--r--README.md6
-rwxr-xr-xcompile.sh199
2 files changed, 204 insertions, 1 deletions
diff --git a/README.md b/README.md
index 43ec942d5..8731b0896 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,11 @@ For Windows, you just need to download a file and extract it:
- [Windows 32 bit](http://builds.cuberite.org/job/MCServer%20Windows%20x86/lastSuccessfulBuild/artifact/Install/MCServer.zip)
- [Windows 64 bit](http://builds.cuberite.org/job/MCServer%20Windows%20x64/lastSuccessfulBuild/artifact/Install/MCServer.zip)
-For other operating systems you need to download and compile yourself. There is also an archive of binary builds on the buildserver: http://builds.cuberite.org
+For other operating systems you need to download and compile yourself. This can be done either manually, or with this automatic script:
+
+ bash -c "$(wget -O - https://raw.githubusercontent.com/mc-server/MCServer/master/compile.sh)"
+
+There is also an archive of binary builds on the buildserver: http://builds.cuberite.org
Compiling the server yourself has other benefits: you may get better performance performance (1.5-3x as fast) and it supports more operating systems. See the [COMPILING.md](https://github.com/mc-server/MCServer/blob/master/COMPILING.md) file for more details.
diff --git a/compile.sh b/compile.sh
new file mode 100755
index 000000000..329d79d81
--- /dev/null
+++ b/compile.sh
@@ -0,0 +1,199 @@
+#|| goto :windows_detected
+
+# Do we already have a repo?
+if [[ -d .git && -f easyinstall.sh && -f MakeLuaAPI.cmd ]]; then # A good enough indicator that we're in the MCServer git repo.
+cd ../
+echo "MCServer repository detected. This should make the process faster, especially if you compiled before."
+fi
+
+# Error functions.
+function error
+{
+ echo
+ echo "-----------------"
+ echo "Script aborted, reason:"
+ echo $1
+ exit -1
+}
+
+function missingDepsExit
+{
+ echo
+ echo "Please install the dependencies, then come back."
+ echo
+ exit -2
+}
+
+
+# Echo: Greetings.
+echo
+echo "Hello, this script will download and compile Cuberite/MCServer."
+echo "On subsequent runs, it will update your MCServer."
+echo "The compilation and download will occur in the current directory."
+echo "If you're updating, you should run <Path to MCServer>/MCServer/compile.sh"
+echo "Compiling from source takes time, but it usually generates better executables."
+echo "If you prefer ready-to-use binaries or if you want more info, please visit:"
+echo "http://cuberite.org/"
+echo "http://mc-server.org/"
+
+MISSING_PROGRAMS=""
+
+# Compiler check.
+GCC_EXISTS=0
+CLANG_EXISTS=0
+g++ --help > /dev/null 2> /dev/null && GCC_EXISTS=1
+clang --help > /dev/null 2> /dev/null && CLANG_EXISTS=1
+if [[ $GCC_EXISTS == 0 && $CLANG_EXISTS == 0 ]]; then
+MISSING_PROGRAMS="gcc g++"
+fi
+
+# Depdendency check.
+while read program; do
+$program --help > /dev/null 2> /dev/null || MISSING_PROGRAMS="$MISSING_PROGRAMS $program"
+done <<"EOF"
+git
+make
+cmake
+EOF
+if [[ $MISSING_PROGRAMS != "" ]]; then
+ echo
+ echo "-----------------"
+ echo "You have missing compilation dependencies:"
+ echo $MISSING_PROGRAMS
+ echo
+
+ # apt-get guide.
+ apt-get --help > /dev/null 2> /dev/null && \
+ echo "You can install the missing depndencies via:" && \
+ echo -n "sudo apt-get install " && echo $MISSING_PROGRAMS && missingDepsExit
+
+ # yum guide.
+ yum --help > /dev/null 2> /dev/null && \
+ echo "You can install the missing depndencies via:" && \
+ echo -n "sudo yum install " && echo $MISSING_PROGRAMS && missingDepsExit
+
+ # rpm guide.
+ rpm --help > /dev/null 2> /dev/null && \
+ echo "You can install the missing depndencies via:" && \
+ echo -n "sudo rpm -i " && echo $MISSING_PROGRAMS && missingDepsExit
+
+ # pacman guide.
+ pacman --help > /dev/null 2> /dev/null && \
+ echo "You can install the missing depndencies via:" && \
+ echo -n "sudo pacman -S " && echo $MISSING_PROGRAMS && missingDepsExit
+
+ missingDepsExit
+fi
+
+exit
+# Echo: Branch choice.
+echo
+echo "You can choose between 2 branches:"
+echo "* (S)Stable: (Coming soon) Choose the stable branch if you want the most reliable server."
+echo " As of now, Stable is not yet available, please use testing instead."
+echo
+echo "* (T)Testing: The testing branch is less stable,"
+echo " but using it and finding and reporting bugs helps us a lot!"
+echo
+echo "* (D)Dev: The least stable of the three. (Master branch)"
+echo " Choose the development branch if you are feeling adventurous and"
+echo " want to try new, bleeding edge features."
+echo
+
+
+# Input: Branch choice.
+echo -n "Choose the branch (s/t/d): "
+read BRANCH
+if [[ ($BRANCH == "s") || ($BRANCH == "S" ) ]]; then
+ #BRANCH="stable"
+ error "We don't have a stable branch yet, please use testing, sorry."
+elif [[ ($BRANCH == "t") || ($BRANCH == "T" ) ]]; then
+ BRANCH="testing"
+elif [[ ($BRANCH == "d") || ($BRANCH == "D" ) ]]; then
+ BRANCH="master"
+else
+ error "Unrecognized user input."
+fi
+
+# Echo: Compile mode choice.
+echo
+echo "Choose compile mode:"
+echo "* (N)Normal: Compiles normally."
+echo
+echo "* (D)Debug: Compiles in debug mode. Makes your console and crashes much more verbose."
+echo " But it costs performance."
+echo
+echo "Note that the script will connect to the internet in order to fetch code after this step."
+echo "It will then compile your program."
+echo
+
+# Input: Compile mode choice.
+echo -n "Choose compile mode: (n/d): "
+read BUILDTYPE
+if [[ ($BUILDTYPE == "d") || ($BUILDTYPE == "D") ]]; then
+ BUILDTYPE="Debug"
+elif [[ ($BUILDTYPE == "n") || ($BUILDTYPE == "N") ]]; then
+ BUILDTYPE="Release"
+else
+ error "Unrecognized user input."
+fi
+
+
+# Echo: Downloading began.
+echo
+echo " --- Downloading MCServer's source code from the $BRANCH branch..."
+
+
+# Git: Clone.
+if [ ! -d MCServer ]; then
+ echo " --- Looks like your first run, cloning the whole code..."
+ git clone https://github.com/mc-server/MCServer.git
+fi
+
+
+# Git: Fetch.
+pushd MCServer
+echo " --- Updating the $BRANCH branch..."
+git fetch origin $BRANCH || error "git fetch failed"
+git checkout $BRANCH || error "git checkout failed"
+git merge origin/$BRANCH || error "git merge failed"
+
+
+# Git: Submodules.
+echo " --- Updating submodules..."
+git submodule init
+git submodule update
+
+
+# Cmake.
+echo " --- Running cmake..."
+popd
+if [ ! -d build-mcserver ]; then mkdir build-mcserver; fi
+pushd build-mcserver
+cmake ../MCServer/ -DCMAKE_BUILD_TYPE=$BUILDTYPE || error "cmake failed"
+
+
+# Make.
+echo " --- Compiling..."
+make -j`nproc` || error "Compiling failed"
+echo
+
+
+# Echo: Compilation complete.
+popd
+pushd MCServer/MCServer
+echo
+echo "-----------------"
+echo "Compilation done!"
+echo
+echo "Cuberite awaits you at:"
+echo "`pwd`/MCServer"
+echo
+echo "Enjoy :)"
+popd
+exit 0
+
+:windows_detected
+echo "This script is not available for Windows yet, sorry."
+echo "You can still download the Windows binaries from: http://mc-server.org"
+