-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
66 lines (60 loc) · 1.8 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Convenient root makefile. Invokes `cmake` and then `cmake --build` as needed.
# Fallback settings. Keep this in sync with `./run`!
ifndef preset
mode ?= debug
ifndef os
# Detect OS and architecture.
ifeq ($(MSYSTEM),MINGW32)
os := windows
arch := i686
else ifeq ($(MSYSTEM),MINGW64)
os := windows
arch := x86_64
else ifneq ($(MSYSTEM),)
$(error The project cannot be built in '$(MSYSTEM)' mode. Return to the Start Menu and open 'MSYS2 MinGW x86' or 'MSYS2 MinGW x64')
else ifeq ($(shell uname -sm),Linux x86_64)
os := linux
arch := x86_64
else ifeq ($(shell uname -sm),Darwin x86_64)
os := macos
arch := x86_64
else
$(error Unknown system '$(shell uname -sm)'; set preset= manually.)
endif # uname -sm
else ifndef arch
ifneq (,$(filter $(os),windows emscripten))
arch := i686
else ifneq (,$(filter $(os),linux macos))
arch := x86_64
else
$(error Unknown os '$(os)'; set arch= manually.)
endif # filter on os
endif # os, arch
preset := $(os)-$(arch)-$(mode)
endif # preset
# Activate Emscripten SDK if needed.
$(shell tools/build/install-deps.sh >&2)
ifeq ($(os),emscripten)
$(shell tools/emscripten/install-emsdk.sh >&2)
endif
# Variables
CMAKE ?= tools/bootstrap/cmake
BUILD_DIR = build/cmake-$(preset)
BUILD_NINJA = $(BUILD_DIR)/build.ninja
ifeq ($(MAKECMDGOALS),)
# If no targets were specified, synthesize a default target.
.PHONY: _default
_default: $(BUILD_NINJA)
@$(CMAKE) --build $(BUILD_DIR)
else
# If targets were specified, pass them through to `cmake --build`.
.PHONY: $(MAKECMDGOALS)
$(word 1,$(MAKECMDGOALS)):: $(BUILD_NINJA)
@$(CMAKE) --build $(BUILD_DIR) -t $(MAKECMDGOALS)
$(MAKECMDGOALS)::
@#
endif
# If the CMake cache doesn't already exist, configure it for the first time.
# If it does already exist, `cmake --build` will reconfigure if needed.
$(BUILD_NINJA):
@$(CMAKE) --preset $(preset) -B $(BUILD_DIR)