X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fxonotic.git;a=blobdiff_plain;f=Makefile;h=85fbe91883680894b6d8c2e0e81e51d2287a92e1;hp=f4c26fb0f1b18af33f6f6be3f0cb34ea799c9cc0;hb=HEAD;hpb=1565485f10b633dbaa0e3283c0a515a6ddccd69c diff --git a/Makefile b/Makefile index f4c26fb0..d7d329d2 100644 --- a/Makefile +++ b/Makefile @@ -1,70 +1,102 @@ -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 -SUFFIX ?= $(shell if [ -d .git ]; then echo -git; else echo -zip; fi) -CP ?= cp - -.PHONY: all -all: - ./all compile -r +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 +# we use CFLAGS to set default optimisations which users may 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 +export DP_LINK_CRYPTO=static +# AES +export DP_LINK_CRYPTO_RIJNDAEL=static + + +.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 beta 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;31mThis Makefile only supports stable releases and autobuilds, whereas you are using a git repository. To compile from git, please read https://gitlab.com/xonotic/xonotic/-/wikis/Repository_Access\e[m") +ifdef GIT + $(error $(GIT)) +endif + + +# If requested, these targets must always run first: +.EXTRA_PREREQS := $(filter clean update-stable update-beta, $(MAKECMDGOALS)) + +.PHONY: clean-sources +clean-sources: + $(MAKE) -C $(DPSRC) clean + ( $(MAKE) -C $(D0SRC) clean || true ) # autotools may not have created the Makefile yet +clean-sources: .EXTRA_PREREQS = # prevents circular dependency .PHONY: clean -clean: - ./all compile -c - -.PHONY: install-data-git -install-data-git: all - $(INSTALL) -d $(LIBDIR)/data - for p in data/*.pk3dir; do $(ZIP) -r $(LIBDIR)/data/$${p%dir} data/$$p/*; done - -.PHONY: install-data-zip -install-data-git: all - $(INSTALL) -d $(LIBDIR)/data - for p in data/*.pk3; do $(INSTALL) data/$$p $(LIBDIR)/data/$$p; done - -.PHONY: install-data -install-data: install-data-$(SUFFIX) - -.PHONY: install-engine-git -install-engine-git: all - $(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/xonotic-sdl $(LIBDIR)/xonotic-$(ARCH)-sdl - $(INSTALL) darkplaces/xonotic-glx $(LIBDIR)/xonotic-$(ARCH)-glx - $(INSTALL) darkplaces/xonotic-dedicated $(LIBDIR)/xonotic-$(ARCH)-dedicated - -.PHONY: install-engine-zip -install-engine-git: all - $(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 -install-engine: install-engine-$(SUFFIX) - -.PHONY: install-links -install-links: all - $(INSTALL) -d $(BINDIR) - $(LN) -snf $(LIBDIR)/xonotic-$(ARCH)-sdl $(BINDIR)/xonotic-sdl - $(LN) -snf $(LIBDIR)/xonotic-$(ARCH)-glx $(BINDIR)/xonotic-glx - $(LN) -snf $(LIBDIR)/xonotic-$(ARCH)-dedicated $(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)/.libs/libd0_blind_id.a $(D0SRC)/.libs/libd0_rijndael.a: + ( cd $(D0SRC) && ./autogen.sh && ./configure --enable-static --disable-shared ) + $(MAKE) -C $(D0SRC) clean # ensures missing .a files are created FIXME WORKAROUND + $(MAKE) -C $(D0SRC) + +$(DPSRC)/darkplaces-dedicated: $(D0SRC)/.libs/libd0_blind_id.a + $(MAKE) -C $(DPSRC) sv-release +$(SERVER): $(DPSRC)/darkplaces-dedicated + cp $(DPSRC)/darkplaces-dedicated $(SERVER) + +$(DPSRC)/darkplaces-sdl: $(D0SRC)/.libs/libd0_blind_id.a + $(MAKE) -C $(DPSRC) sdl-release +$(CLIENT): $(DPSRC)/darkplaces-sdl + cp $(DPSRC)/darkplaces-sdl $(CLIENT) + + +.PHONY: server +server: $(SERVER) + +.PHONY: client +client: $(CLIENT) + +.PHONY: both +both: client server +