-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (32 loc) · 883 Bytes
/
Makefile
File metadata and controls
48 lines (32 loc) · 883 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
42
43
44
45
46
47
48
# Running make in this directory will build everything recursively.
# To build hello only, run "make hello".
.SUFFIXES:
/ := ../
include $/config.mk
subdirs := $(dir $(sort $(wildcard */Makefile)))
build := $(patsubst %,build-%,$(subdirs))
clean := $(patsubst %,clean-%,$(subdirs)) clean-hello
install := $(patsubst %,install-%,$(subdirs))
all: hello $(build)
clean: $(clean)
install: $(if $(DESTDIR),$(install),no-destdir-install)
build-%:
$(MAKE) -C $*
clean-%:
$(MAKE) -C $* clean
install-%:
$(MAKE) -C $* DESTDIR=$(abspath $(DESTDIR)) install
.SILENT: $(build) $(clean) $(install)
hello: hello.o
$(CC) -o $@ $<
hello.o: hello.c
$(CC)$(if $(CFLAGS), $(CLFAGS)) -c $<
clean-hello:
rm -f hello hello.o hello.d
define subtargets
$1%.o:
$$(MAKE) -C $$(dir $$@) $$(notdir $$@)
endef
$(foreach d,$(subdirs),$(eval $(call subtargets,$d)))
test:
@echo $(subdirs)