-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrules.mk
87 lines (55 loc) · 1.28 KB
/
rules.mk
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
85
86
TARGETS = all install clean
.PHONY: $(TARGETS)
$(TARGETS): ;
_INST = $(addprefix $(DESTDIR)$(INCDIR)/, $(INCS)) \
$(addprefix $(DESTDIR)$(ASMDIR)/, $(ASMINCS)) \
$(addprefix $(DESTDIR)$(LIBDIR)/, $(LIB))
# ----------------- Subdirs -----------------------
ifdef SUBDIRS
_SUBDIRS:=$(filter-out .WAIT,$(SUBDIRS))
_CURDIR=$(subst $(TOPDIR),,$(CURDIR))
ifneq ($(_CURDIR),)
_CURDIR:=$(_CURDIR)/
endif
.PHONY: $(_SUBDIRS)
$(_SUBDIRS):
@echo "📁 $(_CURDIR)$@"
@DESTDIR=$(DESTDIR) $(MAKE) -C $@ $(MAKECMDGOALS)
$(TARGETS): $(SUBDIRS)
endif
# --------------- Build rules ------------------
%.o: %.asm
$(AS) $< $@
# --------------- Lib rules --------------------
ifneq ($(LIB),)
all: $(LIB)
_cleanlib:
$(RM) $(LIB)
clean: _cleanlib
endif
# --------------- Progs rules -------------------
ifneq ($(PROG),)
all: $(PROG)
endif
# --------------- Install rules -----------------
ifneq ($(_INST),)
install: $(_INST)
endif
# headers
$(DESTDIR)$(INCDIR)/%.h: %.h
install -D $< $@
$(DESTDIR)$(ASMDIR)/%.inc: %.inc
install -D $< $@
# libs
$(DESTDIR)$(LIBDIR)/%.a: %.a
install -D $< $@
$(DESTDIR)$(LIBDIR)/%.o: %.o
install -D $< $@
# bins
$(DESTDIR)$(BINDIR)/%: %
install -D $< $@
# kernel & mods
$(DESTDIR)/%.sys: %.sys
install -D $< $@
$(DESTDIR)/%.mod: %.mod
install -D $< $@