]> git.xonotic.org Git - xonotic/xonotic.git/commitdiff
End-user focused Makefile 91/head
authorbones_was_here <bones_was_here@xa.org.au>
Tue, 1 Feb 2022 23:11:37 +0000 (09:11 +1000)
committerbones_was_here <bones_was_here@xa.org.au>
Mon, 7 Feb 2022 03:38:32 +0000 (13:38 +1000)
Makefile
xonotic-linux-sdl.sh

index 85fbe91883680894b6d8c2e0e81e51d2287a92e1..0b8b752147bd1fab4e0e4fb2b694a53bd8c6c2ec 100644 (file)
--- a/Makefile
+++ b/Makefile
-DESTDIR ?=
-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)
-RIJNDAELDETECT_CONFIGURE ?= $(shell if ! [ -f source/d0_blind_id/d0_rijndael.c ]; then echo --disable-rijndael; fi)
-RIJNDAELDETECT_MAKE_DP ?= $(shell if [ -f source/d0_blind_id/d0_rijndael.c ]; then echo DP_CRYPTO_RIJNDAEL_STATIC_LIBDIR=$(CURDIR)/source/d0_blind_id/.libs; fi)
-
-
-.PHONY: all
-all: all-$(SUFFIX)
-
-.PHONY: all-git
-all-git:
-       ./all compile
-
-.PHONY: all-zip-binary
-all-zip-binary:
-       @echo Nothing to do
-
-.PHONY: all-zip-source
-all-zip-source:
-       ( cd source/d0_blind_id && ./configure --enable-static --disable-shared $(RIJNDAELDETECT_CONFIGURE) )
-       $(MAKE) -C source/d0_blind_id
-       $(MAKE) -C source/gmqcc
-       $(MAKE) -C source/qcsrc QCC=$(CURDIR)/source/gmqcc/gmqcc
-       $(MAKE) -C source/darkplaces sv-release DP_CRYPTO_STATIC_LIBDIR=$(CURDIR)/source/d0_blind_id/.libs
-       $(MAKE) -C source/darkplaces cl-release DP_CRYPTO_STATIC_LIBDIR=$(CURDIR)/source/d0_blind_id/.libs
-       $(MAKE) -C source/darkplaces sdl-release DP_CRYPTO_STATIC_LIBDIR=$(CURDIR)/source/d0_blind_id/.libs
-
+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
+       @echo "  ===== Xonotic Makefile for stable and beta releases ====="
+       @echo
+       @echo "The DarkPlaces engine builds will be named $(CLIENT) and $(SERVER) and"
+       @echo "will be preferred by the xonotic-linux-sdl.sh and xonotic-linux-dedicated.sh scripts."
+       @echo
+       @echo "For more info, see https://gitlab.com/xonotic/xonotic/-/wikis/Compiling"
+       @echo
+       @echo "-O3 is already enabled for DarkPlaces. 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
+       @echo "  make server                Compile $(SERVER)"
+       @echo "  make client                Compile $(CLIENT)"
+       @echo "  make both"
+       @echo
+
+.PHONY: nogit
+nogit:
+       @if [ -d .git ]; then \
+               echo "To compile from git sources, please use ./all instead!"; \
+               exit 1; \
+       fi
+
+.PHONY: clean-sources
+clean-sources: nogit
+       $(MAKE) -C $(DPSRC) clean
+       $(MAKE) -C $(D0SRC) clean
 
 .PHONY: clean
-clean: clean-$(SUFFIX)
-
-.PHONY: clean-git
-clean-git:
-       ./all clean
-
-.PHONY: clean-zip
-clean-zip-binary:
-       @echo Nothing to do
-
-.PHONY: clean-zip
-clean-zip-source:
-       $(MAKE) -C source/d0_blind_id distclean
-       $(MAKE) -C source/gmqcc clean
-       $(MAKE) -C source/qcsrc clean
-       $(MAKE) -C source/darkplaces clean
-
-
-.PHONY: install-data
-install-data: install-data-$(SUFFIX)
-
-.PHONY: install-data-git
-install-data-git: all-git
-       $(RM) -rf $(DESTDIR)$(LIBDIR)/data
-       $(INSTALL) -d $(DESTDIR)$(LIBDIR)/data
-       for p in data/*.pk3; do $(INSTALL) $$p $(DESTDIR)$(LIBDIR)/$$p || exit 1; done
-       for p in data/*.pk3dir; do ( cd $$p && $(ZIP) -r $(DESTDIR)$(LIBDIR)/$${p%dir} * ) || exit 1; done
-
-.PHONY: install-data-zip-binary
-install-data-zip-binary: all-zip-binary
-       $(RM) -rf $(DESTDIR)$(LIBDIR)/data
-       $(INSTALL) -d $(DESTDIR)$(LIBDIR)/data
-       for p in data/*.pk3; do $(INSTALL) $$p $(DESTDIR)$(LIBDIR)/$$p || exit 1; done
-
-.PHONY: install-data-zip-source
-install-data-zip-source: all-zip-source
-       $(RM) -rf $(DESTDIR)$(LIBDIR)/data
-       $(INSTALL) -d $(DESTDIR)$(LIBDIR)/data
-       for p in data/*.pk3; do $(INSTALL) $$p $(DESTDIR)$(LIBDIR)/$$p || exit 1; done
-       for p in data/xonotic-*-data*.pk3; do cd source && $(ZIP) $(DESTDIR)$(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 $(DESTDIR)$(LIBDIR)
-       $(INSTALL) xonotic-linux-glx.sh $(DESTDIR)$(LIBDIR)/xonotic-linux-glx.sh
-       $(INSTALL) xonotic-linux-sdl.sh $(DESTDIR)$(LIBDIR)/xonotic-linux-sdl.sh
-       $(INSTALL) xonotic-linux-dedicated.sh $(DESTDIR)$(LIBDIR)/xonotic-linux-dedicated.sh
-       $(INSTALL) darkplaces/darkplaces-sdl $(DESTDIR)$(LIBDIR)/xonotic-$(ARCH)-sdl
-       $(INSTALL) darkplaces/darkplaces-glx $(DESTDIR)$(LIBDIR)/xonotic-$(ARCH)-glx
-       $(INSTALL) darkplaces/darkplaces-dedicated $(DESTDIR)$(LIBDIR)/xonotic-$(ARCH)-dedicated
-
-.PHONY: install-engine-zip-binary
-install-engine-zip-binary: all-zip-binary
-       $(INSTALL) -d $(DESTDIR)$(LIBDIR)
-       $(INSTALL) xonotic-linux-glx.sh $(DESTDIR)$(LIBDIR)/xonotic-linux-glx.sh
-       $(INSTALL) xonotic-linux-sdl.sh $(DESTDIR)$(LIBDIR)/xonotic-linux-sdl.sh
-       $(INSTALL) xonotic-linux-dedicated.sh $(DESTDIR)$(LIBDIR)/xonotic-linux-dedicated.sh
-       $(INSTALL) xonotic-$(ARCH)-sdl $(DESTDIR)$(LIBDIR)/xonotic-$(ARCH)-sdl
-       $(INSTALL) xonotic-$(ARCH)-glx $(DESTDIR)$(LIBDIR)/xonotic-$(ARCH)-glx
-       $(INSTALL) xonotic-$(ARCH)-dedicated $(DESTDIR)$(LIBDIR)/xonotic-$(ARCH)-dedicated
+clean: clean-sources
+       $(RM) $(CLIENT) $(SERVER)
 
-.PHONY: install-engine-zip-source
-install-engine-zip-source: all-zip-source
-       $(INSTALL) -d $(DESTDIR)$(LIBDIR)
-       $(INSTALL) xonotic-linux-glx.sh $(DESTDIR)$(LIBDIR)/xonotic-linux-glx.sh
-       $(INSTALL) xonotic-linux-sdl.sh $(DESTDIR)$(LIBDIR)/xonotic-linux-sdl.sh
-       $(INSTALL) xonotic-linux-dedicated.sh $(DESTDIR)$(LIBDIR)/xonotic-linux-dedicated.sh
-       $(INSTALL) source/darkplaces/darkplaces-sdl $(DESTDIR)$(LIBDIR)/xonotic-$(ARCH)-sdl
-       $(INSTALL) source/darkplaces/darkplaces-glx $(DESTDIR)$(LIBDIR)/xonotic-$(ARCH)-glx
-       $(INSTALL) source/darkplaces/darkplaces-dedicated $(DESTDIR)$(LIBDIR)/xonotic-$(ARCH)-dedicated
+.PHONY: update-stable
+update-stable: nogit
+       misc/tools/rsync-updater/update-to-release.sh
 
+.PHONY: update-beta
+update-beta: nogit
+       misc/tools/rsync-updater/update-to-autobuild.sh
 
-.PHONY: install-links
-install-links:
-       $(INSTALL) -d $(BINDIR)
-       $(LN) -snf $(LIBDIR)/xonotic-linux-sdl.sh $(DESTDIR)$(BINDIR)/xonotic-sdl
-       $(LN) -snf $(LIBDIR)/xonotic-linux-glx.sh $(DESTDIR)$(BINDIR)/xonotic-glx
-       $(LN) -snf $(LIBDIR)/xonotic-linux-dedicated.sh $(DESTDIR)$(BINDIR)/xonotic-dedicated
+.PHONY: crypto
+crypto: nogit
+       ( cd $(D0SRC) && ./autogen.sh && ./configure --enable-static --disable-shared )
+       $(MAKE) -C $(D0SRC)
 
+.PHONY: server
+server: crypto
+       $(MAKE) -C $(DPSRC) sv-release
+       cp -v $(DPSRC)/darkplaces-dedicated $(SERVER)
 
-.PHONY: install-doc
-install-doc:
-       $(INSTALL) -d $(DESTDIR)$(DOCDIR)/server
-       $(CP) -R Docs/* $(DESTDIR)$(DOCDIR)/
-       $(CP) -R server/* $(DESTDIR)$(DOCDIR)/server
+.PHONY: client
+client: crypto
+       $(MAKE) -C $(DPSRC) sdl-release
+       cp -v $(DPSRC)/darkplaces-sdl $(CLIENT)
 
+.PHONY: both
+both: client server
 
-.PHONY: install
-install: install-data install-engine install-links install-doc
index e4ae857ee80ea6468f30ebffd29325c80e8af302..becfe8865106b4ab587b54951db34c4168375114 100755 (executable)
@@ -17,7 +17,10 @@ case "$(uname -m)" in
   *)   arch="linux64" ;;
 esac
 
-xonotic="xonotic-${arch}-${mode}"
+# prefer locally built binary if available (see: Makefile)
+xonotic="xonotic-local-${mode}"
+[ -x "$xonotic" ] || xonotic="xonotic-${arch}-${mode}"
+echo "Executing: $xonotic ${@}"
 
 set -- ./${xonotic} "${@}"