]> git.xonotic.org Git - xonotic/xonotic.git/blob - Makefile
1ab3dc2b10f2904dd6810c1f042321e7266ac71a
[xonotic/xonotic.git] / Makefile
1 DPSRC = source/darkplaces
2 D0SRC = source/d0_blind_id
3 CLIENT = xonotic-local-sdl
4 SERVER = xonotic-local-dedicated
5
6 # CC and MAKEFLAGS are always set so ?= has no effect, therefore
7 # we use CFLAGS to set default optimisations which users may override
8 CFLAGS ?= -pipe -march=native -mtune=native -flto=auto
9 # user can override this with make -j
10 MAKEFLAGS := -j$(shell nproc)
11 # DP makefile overrides CFLAGS (exporting CFLAGS does work for d0_blind_id but so does this)
12 export CC += $(CFLAGS)
13
14 # d0_blind_id header location
15 export CC += -I$(PWD)/source/
16 # d0_blind_id static libs location
17 export CC += -L$(PWD)/$(D0SRC)/.libs/
18 # Player IDs: DP_LINK_CRYPTO needs to be set (else it defaults to "dlopen"),
19 # it should be set to "shared" but then LIB_CRYPTO gets overridden in DP makefile,
20 # and we need to set LIB_CRYPTO such that libgmp gets linked
21 export DP_LINK_CRYPTO=foo
22 export CFLAGS_CRYPTO=-DLINK_TO_CRYPTO
23 export LIB_CRYPTO=-ld0_blind_id -lgmp
24 # AES
25 export DP_LINK_CRYPTO_RIJNDAEL=shared
26
27
28 .PHONY: help
29 help:
30         @echo
31         @printf "     \e[1;33m===== Xonotic Makefile for stable and beta releases =====\e[m\n"
32         @echo
33         @printf "The DarkPlaces Engine builds will be named \e[1m$(CLIENT) \e[mand \e[1m$(SERVER)\e[m\n"
34         @printf "and will be preferred by \e[1mxonotic-linux-sdl.sh \e[mand \e[1mxonotic-linux-dedicated.sh \e[mscripts.\n"
35         @echo
36         @printf "More info is available at \e[1;36mhttps://gitlab.com/xonotic/xonotic/-/wikis/Compiling\e[m\n"
37         @echo
38         @echo   "-O3 is already enabled for DarkPlaces Engine. Do not add any math flags!"
39         @echo
40         @echo   "MAKEFLAGS=$(MAKEFLAGS)"
41         @echo   "CFLAGS= $(CFLAGS)"
42         @echo
43         @echo   "  make clean-sources         Delete build objects"
44         @echo   "  make clean                 Delete engine builds and build objects"
45         @echo
46         @echo   "  make update-stable         Update to the latest stable release via rsync"
47         @echo   "  make update-beta           Update to the latest beta autobuild via rsync"
48         @echo
49         @printf "  make server                Compile \e[1m$(SERVER)\e[m\n"
50         @printf "  make client                Compile \e[1m$(CLIENT)\e[m\n"
51         @echo   "  make both"
52         @echo
53
54 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")
55 ifdef GIT
56   $(error $(GIT))
57 endif
58
59
60 # If requested, these targets must always run first:
61 .EXTRA_PREREQS := $(filter clean update-stable update-beta, $(MAKECMDGOALS))
62 # It makes sense to `clean-sources` after building if requested.
63 .NOTPARALLEL: $(.EXTRA_PREREQS) clean-sources
64
65 .PHONY: clean-sources
66 clean-sources:
67         $(MAKE) -C $(DPSRC) clean
68         ( $(MAKE) -C $(D0SRC) clean || true ) # autotools may not have created the Makefile yet
69 clean-sources: .EXTRA_PREREQS =  # prevents circular dependency
70
71 .PHONY: clean
72 clean: clean-sources
73         $(RM) $(CLIENT) $(SERVER)
74
75 .PHONY: update-stable
76 update-stable:
77         misc/tools/rsync-updater/update-to-release.sh
78
79 .PHONY: update-beta
80 update-beta:
81         misc/tools/rsync-updater/update-to-autobuild.sh
82
83
84 $(D0SRC)/.libs/libd0_blind_id.a $(D0SRC)/.libs/libd0_rijndael.a:
85         ( cd $(D0SRC) && ./autogen.sh && ./configure --enable-static --disable-shared )
86         $(MAKE) -C $(D0SRC) clean  # ensures missing .a files are created FIXME WORKAROUND
87         $(MAKE) -C $(D0SRC)
88
89 $(DPSRC)/darkplaces-dedicated: $(D0SRC)/.libs/libd0_blind_id.a $(D0SRC)/.libs/libd0_rijndael.a
90         $(MAKE) -C $(DPSRC) sv-release
91 $(SERVER): $(DPSRC)/darkplaces-dedicated
92         cp $(DPSRC)/darkplaces-dedicated $(SERVER)
93
94 $(DPSRC)/darkplaces-sdl: $(D0SRC)/.libs/libd0_blind_id.a $(D0SRC)/.libs/libd0_rijndael.a
95         $(MAKE) -C $(DPSRC) sdl-release
96 $(CLIENT): $(DPSRC)/darkplaces-sdl
97         cp $(DPSRC)/darkplaces-sdl $(CLIENT)
98
99
100 .PHONY: server
101 server: $(SERVER)
102
103 .PHONY: client
104 client: $(CLIENT)
105
106 .PHONY: both
107 both: client server
108