-
Notifications
You must be signed in to change notification settings - Fork 35
/
Makefile
72 lines (65 loc) · 1.26 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
#!/usr/bin/make -f
include tools/config.mk
.PHONY: clean $(PROJECTS)
ifneq ($(cfg),)
.PHONY: $(CONFIG)
endif
ifeq ($(act),)
all: $(PROJECTS)
install: $(PROJECTS)
@$(MAKE) act=$@
clean:
@$(MAKE) act=$@
distclean: clean
@$(RM) -f $(CONFIG)
config:
@$(MAKE) cfg=force $(CONFIG)
$(CONFIG):
@$(CONFTOOL) $@
$(PROJECTS): $(CONFIG)
@$(MAKE) act=build tgt=$@
else
ifeq ($(tgt),)
all: $(PROJECTS)
$(PROJECTS):
@$(MAKE) act=$(act) tgt=$@
else
tbase := $(tgt)/$(BIN_DIR)/$(tgt)
tbin := $(tbase).bin
.PHONY: $(tbin)
ifeq ($(act),clean)
$(tbin):
@$(RM) -f $@
@$(FIND) $(tgt) -name \*.[od] | xargs $(RM) -f
else
include $(CONFIG)
include tools/rulz.mk
ifeq ($(act),install)
$(tbin):
@$(inst)
else
INCLUDE := -I$(tgt)/include -Iinclude
ifeq ($(blob),)
include $(tgt)/Makefile
subdirs := $(addprefix $(tgt)/$(SRC_DIR)/,$(SUBDIRS))
blobs := $(addsuffix /build.o, $(subdirs))
LDSCRIPT := $(tbase).lds
.PHONY: $(blobs)
$(tbin): $(blobs)
@$(link)
$(blobs):
@$(MAKE) act=$(act) tgt=$(tgt) blob=$@
else
blob_path := $(dir $(blob))
include $(blob_path)/Makefile
include $(tgt)/Makefile
blob_obj := $(addprefix $(blob_path), $(obj))
blob_dep := $(blob_obj:.o=.d)
$(blob): $(blob_obj)
@$(aggregate)
-include $(blob_dep)
endif #blob
endif #act=install
endif #act=clean
endif #tgt
endif #act