-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile.rules
95 lines (78 loc) · 1.91 KB
/
Makefile.rules
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
87
88
89
90
91
92
93
94
95
#
# $Id$
#
#
# common Makefile rules, included by main Makefile & the modules
#
#
# Uses: NAME, ALLDEP, CC, CFLAGS, DEFS, INCLUDES, LIBS, MKDEP, auto_gen, auto_gen_others,
# depends, objs, extra_objs, static_modules, static_modules_path
# (all this must be defined previously!, see Makefile.defs & Makefile)
#
#implicit rules
%.o:%.c $(ALLDEP)
$(CC) $(CFLAGS) $(INCLUDES) $(DEFS) -c $< -o $@
%.d: %.c $(ALLDEP)
@set -e; $(MKDEP) $(INCLUDES) $(DEFS) $< \
| sed 's#\(\($*D)\)\?$(*F)\)\.o[ :]*#$*.o $@ : #g' > $@; \
[ -s $@ ] || rm -f $@
# normal rules
$(NAME): $(objs) $(ALLDEP)
$(LD) $(LDFLAGS) $(objs) $(extra_objs) $(LIBS) -o $(NAME)
.PHONY: all
all: $(NAME) modules
.PHONY: dep
dep: $(depends)
.PHONY: static
static: $(objs)
.PHONY: clean
clean:
-@rm -f $(objs) $(NAME) $(objs:.o=.il) 2>/dev/null
-@for r in $(modules) $(static_modules_path) "" ; do \
if [ -d "$$r" ]; then \
echo "module $$r" ; \
$(MAKE) -C $$r clean ; \
fi ; \
done
@if [ -n "$(modules)" ]; then \
for r in $(utils_compile) "" ; do \
if [ -d "$$r" ]; then \
$(MAKE) -C $$r clean ; \
fi ; \
done \
fi
.PHONY: proper
.PHONY: distclean
.PHONY: realclean
proper realclean distclean: clean
-@rm -f $(depends) $(auto_gen) $(auto_gen_others) 2>/dev/null
-@for r in $(modules) "" ; do \
if [ -d "$$r" ]; then \
$(MAKE) -C $$r proper ; \
fi ; \
done
@if [ -n "$(modules)" ]; then \
for r in $(utils_compile) "" ; do \
if [ -d "$$r" ]; then \
$(MAKE) -C $$r proper ; \
fi ; \
done \
fi
.PHONY: mantainer-cleaan
mantainer-clean: distclean
-rm -f TAGS tags *.dbg .*.swp
-@for r in $(modules) "" ; do \
if [ -d "$$r" ]; then \
$(MAKE) -C $$r mantainer-clean; \
fi ; \
done
.PHONY: TAGS
TAGS:
$(MKTAGS)
ifeq (,$(MAKECMDGOALS))
-include $(depends)
endif
ifneq (,$(filter-out clean proper distclean realclean mantainer-clean TAGS \
tar modules, $(MAKECMDGOALS)))
-include $(depends)
endif