-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
43 lines (33 loc) · 1.09 KB
/
Copy pathMakefile
File metadata and controls
43 lines (33 loc) · 1.09 KB
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
ROOT := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
HOST_TRIPLE := $(shell uname -m)-linux-gnu
TRIPLE ?= $(HOST_TRIPLE)
BUILD := $(ROOT)/.build
WORK := $(BUILD)/work/$(TRIPLE)
STORE := $(BUILD)/store/$(TRIPLE)
BIN := $(STORE)/bin/spn
.PHONY: all build configure fetch test install uninstall clean nuke
all: build
ifeq ($(TRIPLE),$(HOST_TRIPLE))
@ln -sfn .build/store/$(TRIPLE) $(ROOT)/bootstrap
@ln -sf .build/work/$(TRIPLE)/compile_commands.json $(ROOT)/compile_commands.json
@echo "host binary: bootstrap/bin/spn -> $(BIN)"
else
@echo "cross binary: $(BIN)"
endif
build: configure
@cmake --build $(WORK) --parallel $(shell nproc)
configure: fetch
@cmake -S $(ROOT) -B $(WORK) -DTRIPLE=$(TRIPLE)
fetch:
@cmake -P $(ROOT)/tools/cmake/fetch.cmake
test: build
@ctest --test-dir $(WORK) --output-on-failure
install: build
@mkdir -p $(HOME)/.local/bin
cp $(BIN) $(HOME)/.local/bin/
uninstall:
rm -f $(HOME)/.local/bin/spn
clean:
rm -rf $(BUILD)/work $(BUILD)/store $(ROOT)/bootstrap $(ROOT)/compile_commands.json
nuke: clean
rm -rf $(BUILD) $(ROOT)/.cache/zig