-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmagic.mk
More file actions
41 lines (31 loc) · 945 Bytes
/
magic.mk
File metadata and controls
41 lines (31 loc) · 945 Bytes
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
# from github.com/cyman-ide/magic.mk
PROFILE := $(filter-out all,$(firstword $(MAKECMDGOALS)))
ifeq (,$(PROFILE))
ifndef MAGIC_DEFAULT_PROFILE
$(error No profile and MAGIC_DEFAULT_PROFILE is not defined.)
endif
PROFILE := $(MAGIC_DEFAULT_PROFILE)
MAKECMDGOALS := $(PROFILE)
endif
ifeq ($(flavor PROFILE.$(PROFILE)), undefined)
$(error Invalid profile: $(PROFILE))
endif
$(eval $(PROFILE.$(PROFILE)))
.PHONY: $(MAKECMDGOALS)
$(MAKECMDGOALS): $(MAGIC_TARGET)
BUILDDIR ?= build
PROFILEDIR ?= $(PROFILE)
OBJDIR := $(BUILDDIR)/$(PROFILEDIR)
DEPGENFLAGS ?= -MMD
getobj = $(addprefix $(OBJDIR)/,$(addsuffix .o,$(basename $(notdir $(1)))))
OBJ := $(call getobj,$(SRC))
DEPS := $(OBJ:%.o=%.d)
$(foreach f,$(SRC),$(eval $(call getobj,$f): $f))
$(OBJDIR):
mkdir -p $(OBJDIR)
$(DEPS): %.d: %.o
$(OBJ): | $(OBJDIR)
$(COMPILE$(suffix $<)) $(DEPGENFLAGS) $< $(OUTPUT_OPTION)
ifndef MAGIC_NODEP
include $(DEPS)
endif