]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - Makefile
Makefile: pretty colours with printf
[xonotic/xonotic.git] / Makefile
index 6f5d56d4c4a82b1c0ae81fc699f1aaf757df666f..50d829efd50bd2dd0e0a78c4936fc197771c5b8f 100644 (file)
--- a/Makefile
+++ b/Makefile
-PREFIX ?= /usr/local
-BINDIR ?= $(PREFIX)/bin
-LIBDIR ?= $(PREFIX)/lib/xonotic
-DOCDIR ?= $(PREFIX)/share/doc/xonotic
-ZIP ?= zip -9
-INSTALL ?= install
-ARCH ?= $(shell if [ x"`uname -m`" = x"x86_64" ]; then echo linux64; else echo linux32; fi)
-LN ?= ln
-CP ?= cp
-BINARY ?= yes
-SUFFIX ?= $(shell if [ -d .git ]; then echo git; elif [ x"$(BINARY)" = x"yes" ]; then echo zip-binary; else echo zip-source; fi)
-
-
-.PHONY: all
-all: all-$(SUFFIX)
-
-.PHONY: all-git
-all-git:
-       ./all compile -r
-
-.PHONY: all-zip-binary
-all-zip-binary:
-       @echo Nothing to do
-
-.PHONY: all-zip-source
-all-zip-source:
-       $(MAKE) -C source/fteqcc
-       $(MAKE) -C source/qcsrc FTEQCC=$(CURDIR)/source/fteqcc/fteqcc.bin
-       $(MAKE) -C source/darkplaces sv-release
-       $(MAKE) -C source/darkplaces cl-release
-       $(MAKE) -C source/darkplaces sdl-release
-
+DPSRC = source/darkplaces
+D0SRC = source/d0_blind_id
+CLIENT = xonotic-local-sdl
+SERVER = xonotic-local-dedicated
+
+# CC and MAKEFLAGS are always set so ?= has no effect, therefore
+# use CFLAGS to set default optimisations and support user override
+CFLAGS ?= -pipe -march=native -mtune=native -flto=auto
+# user can override this with make -j
+MAKEFLAGS := -j$(shell nproc)
+# DP makefile overrides CFLAGS (exporting CFLAGS does work for d0_blind_id but so does this)
+export CC += $(CFLAGS)
+
+# d0_blind_id header location
+export CC += -I$(PWD)/source/
+# d0_blind_id static libs location
+export CC += -L$(PWD)/$(D0SRC)/.libs/
+# Player IDs: DP_LINK_CRYPTO needs to be set (else it defaults to "dlopen"),
+# it should be set to "shared" but then LIB_CRYPTO gets overridden in DP makefile,
+# and we need to set LIB_CRYPTO such that libgmp gets linked
+export DP_LINK_CRYPTO=foo
+export CFLAGS_CRYPTO=-DLINK_TO_CRYPTO
+export LIB_CRYPTO=-ld0_blind_id -lgmp
+# AES
+export DP_LINK_CRYPTO_RIJNDAEL=shared
+
+
+.PHONY: help
+help:
+       @echo
+       @printf "     \e[1;33m===== Xonotic Makefile for stable and beta releases =====\e[m\n"
+       @echo
+       @printf "The DarkPlaces Engine builds will be named \e[1m$(CLIENT) \e[mand \e[1m$(SERVER)\e[m\n"
+       @printf "and will be preferred by \e[1mxonotic-linux-sdl.sh \e[mand \e[1mxonotic-linux-dedicated.sh \e[mscripts.\n"
+       @echo
+       @printf "More info is available at \e[1;36mhttps://gitlab.com/xonotic/xonotic/-/wikis/Compiling\e[m\n"
+       @echo
+       @echo   "-O3 is already enabled for DarkPlaces Engine. Do not add any math flags!"
+       @echo
+       @echo   "MAKEFLAGS=$(MAKEFLAGS)"
+       @echo   "CFLAGS= $(CFLAGS)"
+       @echo
+       @echo   "  make clean-sources         Delete build objects"
+       @echo   "  make clean                 Delete engine builds and build objects"
+       @echo
+       @echo   "  make update-stable         Update to the latest stable release via rsync"
+       @echo   "  make update-beta           Update to the latest daily autobuild via rsync"
+       @echo
+       @printf "  make server                Compile \e[1m$(SERVER)\e[m\n"
+       @printf "  make client                Compile \e[1m$(CLIENT)\e[m\n"
+       @echo   "  make both"
+       @echo
+
+GIT := $(shell [ -d .git ] && printf "\e[1;31mTo compile from git, please read https://gitlab.com/xonotic/xonotic/-/wikis/Repository_Access\e[m")
+ifdef GIT
+  $(error $(GIT))
+endif
+
+.EXTRA_PREREQS := $(findstring update-stable,$(MAKECMDGOALS)) $(findstring update-beta,$(MAKECMDGOALS))
+
+.PHONY: clean-sources
+clean-sources:
+       $(MAKE) -C $(DPSRC) clean
+       $(MAKE) -C $(D0SRC) clean
 
 .PHONY: clean
-clean: clean-$(SUFFIX)
-
-.PHONY: clean-git
-clean-git:
-       ./all clean
-
-.PHONY: clean-zip
-clean-binary:
-       @echo Nothing to do
-
-.PHONY: clean-zip
-clean-source:
-       @echo Sorry, this is not implemented yet
-       @false
-
-
-.PHONY: install-data
-install-data: install-data-$(SUFFIX)
-
-.PHONY: install-data-git
-install-data-git: all-git
-       $(RM) -rf $(LIBDIR)/data
-       $(INSTALL) -d $(LIBDIR)/data
-       for p in data/*.pk3; do $(INSTALL) $$p $(LIBDIR)/$$p || exit 1; done
-       for p in data/*.pk3dir; do ( cd $$p; $(ZIP) -r $(LIBDIR)/$${p%dir} * ) || exit 1; done
-
-.PHONY: install-data-zip-binary
-install-data-zip-binary: all-zip-binary
-       $(RM) -rf $(LIBDIR)/data
-       $(INSTALL) -d $(LIBDIR)/data
-       for p in data/*.pk3; do $(INSTALL) $$p $(LIBDIR)/$$p || exit 1; done
-
-.PHONY: install-data-zip-source
-install-data-zip-source: all-zip-source
-       $(RM) -rf $(LIBDIR)/data
-       $(INSTALL) -d $(LIBDIR)/data
-       for p in data/*.pk3; do $(INSTALL) $$p $(LIBDIR)/$$p || exit 1; done
-       for p in data/xonotic-*-data*.pk3; do cd source; $(ZIP) $(LIBDIR)/$$p progs.dat menu.dat csprogs.dat; done
-
-
-.PHONY: install-engine
-install-engine: install-engine-$(SUFFIX)
-
-.PHONY: install-engine-git
-install-engine-git: all-git
-       $(INSTALL) -d $(LIBDIR)
-       $(INSTALL) xonotic-linux-glx.sh $(LIBDIR)/xonotic-linux-glx.sh
-       $(INSTALL) xonotic-linux-sdl.sh $(LIBDIR)/xonotic-linux-sdl.sh
-       $(INSTALL) xonotic-linux-dedicated.sh $(LIBDIR)/xonotic-linux-dedicated.sh
-       $(INSTALL) darkplaces/darkplaces-sdl $(LIBDIR)/xonotic-$(ARCH)-sdl
-       $(INSTALL) darkplaces/darkplaces-glx $(LIBDIR)/xonotic-$(ARCH)-glx
-       $(INSTALL) darkplaces/darkplaces-dedicated $(LIBDIR)/xonotic-$(ARCH)-dedicated
-
-.PHONY: install-engine-zip-binary
-install-engine-zip: all-zip
-       $(INSTALL) -d $(LIBDIR)
-       $(INSTALL) xonotic-linux-glx.sh $(LIBDIR)/xonotic-linux-glx.sh
-       $(INSTALL) xonotic-linux-sdl.sh $(LIBDIR)/xonotic-linux-sdl.sh
-       $(INSTALL) xonotic-linux-dedicated.sh $(LIBDIR)/xonotic-linux-dedicated.sh
-       $(INSTALL) xonotic-$(ARCH)-sdl $(LIBDIR)/xonotic-$(ARCH)-sdl
-       $(INSTALL) xonotic-$(ARCH)-glx $(LIBDIR)/xonotic-$(ARCH)-glx
-       $(INSTALL) xonotic-$(ARCH)-dedicated $(LIBDIR)/xonotic-$(ARCH)-dedicated
-
-.PHONY: install-engine-zip-source
-install-engine-zip: all-zip
-       $(INSTALL) -d $(LIBDIR)
-       $(INSTALL) xonotic-linux-glx.sh $(LIBDIR)/xonotic-linux-glx.sh
-       $(INSTALL) xonotic-linux-sdl.sh $(LIBDIR)/xonotic-linux-sdl.sh
-       $(INSTALL) xonotic-linux-dedicated.sh $(LIBDIR)/xonotic-linux-dedicated.sh
-       $(INSTALL) source/darkplaces/xonotic-sdl $(LIBDIR)/xonotic-$(ARCH)-sdl
-       $(INSTALL) source/darkplaces/darkplaces-sdl $(LIBDIR)/xonotic-$(ARCH)-glx
-       $(INSTALL) source/darkplaces/darkplaces-dedicated $(LIBDIR)/xonotic-$(ARCH)-dedicated
-
-
-.PHONY: install-links
-install-links:
-       $(INSTALL) -d $(BINDIR)
-       $(LN) -snf $(LIBDIR)/xonotic-linux-sdl.sh $(BINDIR)/xonotic-sdl
-       $(LN) -snf $(LIBDIR)/xonotic-linux-glx.sh $(BINDIR)/xonotic-glx
-       $(LN) -snf $(LIBDIR)/xonotic-linux-dedicated.sh $(BINDIR)/xonotic-dedicated
-
-
-.PHONY: install-doc
-install-doc:
-       $(INSTALL) -d $(DOCDIR)/server
-       $(CP) -R Docs/* $(DOCDIR)/
-       $(CP) -R server/* $(DOCDIR)/server
-
-
-.PHONY: install
-install: install-data install-engine install-links install-doc
+clean: clean-sources
+       $(RM) $(CLIENT) $(SERVER)
+
+.PHONY: update-stable
+update-stable:
+       misc/tools/rsync-updater/update-to-release.sh
+
+.PHONY: update-beta
+update-beta:
+       misc/tools/rsync-updater/update-to-autobuild.sh
+
+$(D0SRC)/Makefile:
+       ( cd $(D0SRC) && ./autogen.sh && ./configure --enable-static --disable-shared )
+
+.PHONY: d0_blind_id
+d0_blind_id: $(D0SRC)/Makefile
+       $(MAKE) -C $(D0SRC)
+
+.PHONY: server
+server: d0_blind_id
+       $(MAKE) -C $(DPSRC) sv-release
+       cp -v $(DPSRC)/darkplaces-dedicated $(SERVER)
+
+.PHONY: client
+client: d0_blind_id
+       $(MAKE) -C $(DPSRC) sdl-release
+       cp -v $(DPSRC)/darkplaces-sdl $(CLIENT)
+
+.PHONY: both
+both: client server
+