]> git.xonotic.org Git - xonotic/xonotic.git/blob - Makefile
Fix macOS SDL2 framework permissions
[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
19 export DP_LINK_CRYPTO=static
20 # AES
21 export DP_LINK_CRYPTO_RIJNDAEL=static
22
23
24 .PHONY: help
25 help:
26         @echo
27         @printf "     \e[1;33m===== Xonotic Makefile for stable and beta releases =====\e[m\n"
28         @echo
29         @printf "The DarkPlaces Engine builds will be named \e[1m$(CLIENT) \e[mand \e[1m$(SERVER)\e[m\n"
30         @printf "and will be preferred by \e[1mxonotic-linux-sdl.sh \e[mand \e[1mxonotic-linux-dedicated.sh \e[mscripts.\n"
31         @echo
32         @printf "More info is available at \e[1;36mhttps://gitlab.com/xonotic/xonotic/-/wikis/Compiling\e[m\n"
33         @echo
34         @echo   "-O3 is already enabled for DarkPlaces Engine. Do not add any math flags!"
35         @echo
36         @echo   "MAKEFLAGS=$(MAKEFLAGS)"
37         @echo   "CFLAGS= $(CFLAGS)"
38         @echo
39         @echo   "  make clean-sources         Delete build objects"
40         @echo   "  make clean                 Delete engine builds and build objects"
41         @echo
42         @echo   "  make update-stable         Update to the latest stable release via rsync"
43         @echo   "  make update-beta           Update to the latest beta autobuild via rsync"
44         @echo
45         @printf "  make server                Compile \e[1m$(SERVER)\e[m\n"
46         @printf "  make client                Compile \e[1m$(CLIENT)\e[m\n"
47         @echo   "  make both"
48         @echo
49
50 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")
51 ifdef GIT
52   $(error $(GIT))
53 endif
54
55
56 # If requested, these targets must always run first:
57 .EXTRA_PREREQS := $(filter clean update-stable update-beta, $(MAKECMDGOALS))
58
59 .PHONY: clean-sources
60 clean-sources:
61         $(MAKE) -C $(DPSRC) clean
62         ( $(MAKE) -C $(D0SRC) clean || true ) # autotools may not have created the Makefile yet
63 clean-sources: .EXTRA_PREREQS =  # prevents circular dependency
64
65 .PHONY: clean
66 clean: clean-sources
67         $(RM) $(CLIENT) $(SERVER)
68
69 .PHONY: update-stable
70 update-stable:
71         misc/tools/rsync-updater/update-to-release.sh
72
73 .PHONY: update-beta
74 update-beta:
75         misc/tools/rsync-updater/update-to-autobuild.sh
76
77
78 $(D0SRC)/.libs/libd0_blind_id.a $(D0SRC)/.libs/libd0_rijndael.a:
79         ( cd $(D0SRC) && ./autogen.sh && ./configure --enable-static --disable-shared )
80         $(MAKE) -C $(D0SRC) clean  # ensures missing .a files are created FIXME WORKAROUND
81         $(MAKE) -C $(D0SRC)
82
83 $(DPSRC)/darkplaces-dedicated: $(D0SRC)/.libs/libd0_blind_id.a
84         $(MAKE) -C $(DPSRC) sv-release
85 $(SERVER): $(DPSRC)/darkplaces-dedicated
86         cp $(DPSRC)/darkplaces-dedicated $(SERVER)
87
88 $(DPSRC)/darkplaces-sdl: $(D0SRC)/.libs/libd0_blind_id.a
89         $(MAKE) -C $(DPSRC) sdl-release
90 $(CLIENT): $(DPSRC)/darkplaces-sdl
91         cp $(DPSRC)/darkplaces-sdl $(CLIENT)
92
93
94 .PHONY: server
95 server: $(SERVER)
96
97 .PHONY: client
98 client: $(CLIENT)
99
100 .PHONY: both
101 both: client server
102