forked from apple/HomeKitADK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
84 lines (69 loc) · 1.76 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Use "make TARGET=Linux all" to build for Linux
export
STEPS := all tests apps clean check info tools docs %.debug
.PHONY: $(STEPS) %.debug shell docker lint lint-changed
CWD := $(shell pwd)
HOST := $(shell uname)
NPROC :=
ifeq ($(HOST),Darwin)
NPROC = sysctl -n hw.physicalcpu
else
NPROC = nproc
endif
TARGET ?= $(HOST)
BUILD_TYPE ?= Debug
MAKE := make -f Build/Makefile -j $(shell $(NPROC))
DOCKER_EXE := DOCKER_BUILDKIT=0 docker
DOCKER ?= 1
DOCKERFILE := Build/Docker/Dockerfile
ifeq ($(TARGET),Raspi)
DOCKERFILE := Build/Docker/Dockerfile.Raspi
endif
ENABLE_TTY =
MAKE_DOCKER = $(DOCKER_EXE) build - < $(DOCKERFILE) | tee /dev/stderr | grep "Successfully built" | cut -d ' ' -f 3
RUN = $(DOCKER_EXE) run \
-e APPS \
-e BUILD_TYPE \
-e HOST \
-e LOG_LEVEL \
-e PROTOCOLS \
-e TARGET \
-e USE_HW_AUTH \
-e USE_NFC \
--cap-add=SYS_PTRACE \
--security-opt seccomp=unconfined \
--mount type=bind,source="$(CWD)",target=/build \
--rm \
-i $(ENABLE_TTY) `$(MAKE_DOCKER)`
ifeq ($(HOST)$(TARGET),LinuxDarwin)
$(error Can't build $(TARGET) on $(HOST).)
endif
ifneq ($(TARGET),Darwin)
ifneq (,$(wildcard /.dockerenv))
# If we are already running inside docker
MAKE := $(MAKE)
else ifeq ($(DOCKER),0)
MAKE := $(MAKE)
else
# Else run make inside docker
MAKE := $(RUN) $(MAKE)
endif
endif
define make_target
$(1):
@$(2) $$@
endef
$(eval $(foreach step,$(STEPS),$(call make_target,$(step),$(MAKE) PAL=$(TARGET))))
shell: ENABLE_TTY=-t
shell:
@$(RUN) bash
docker:
@$(MAKE_DOCKER)
# Lint (and correct) all files.
lint:
@Tools/linters/lint.sh -c
# Lint (and correct) all currently-changed files (according to git).
lint-changed:
@git diff-index --name-only HEAD \
| xargs printf -- '-f\0%s\0' \
| xargs -0 -- Tools/linters/lint.sh -Q -c