forked from Vocalocity/opensips
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.rules
131 lines (109 loc) · 3.15 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#
# $Id$
#
#
# common Makefile rules, included by main Makefile & the modules
#
#
# Uses: NAME, ALLDEP, CC, CFLAGS, DEFS, LIBS, MKDEP, auto_gen, depends, objs,
# extra_objs, static_modules, static_modules_path
# (all this must be defined previously!, see Makefile.defs & Makefile)
#
#directory lists for clean rules
all_modules=$(shell [ -d modules -a -d utils ] && ls modules)
all_utils=$(shell [ -d modules -a -d utils ] && ls utils)
all_nostatic_modules=$(filter-out $(addprefix modules/, $(static_modules)), \
$(wildcard modules/*))
all_modules:=$(addprefix modules/, $(all_modules))
all_utils:=$(addprefix utils/, $(all_utils))
#implicit rules
%.o: %.c $(ALLDEP)
@echo "Compiling $<"
$(Q)$(CC) $(CFLAGS) $(DEFS) -c $< -o $@
%.d: %.c $(ALLDEP)
@set -e; $(MKDEP) $(DEFS) $< \
| sed 's#\(\($*D)\)\?$(*F)\)\.o[ :]*#$*.o $@ : #g' > $@; \
[ -s $@ ] || rm -f $@
# normal rules
$(NAME): $(NEWREVISION) $(objs) $(ALLDEP)
@echo "Linking $(NAME)"
$(Q)$(LD) $(LDFLAGS) $(objs) $(extra_objs) $(LIBS) -o $(NAME)
.PHONY: all
all: $(NAME) modules
.PHONY: dep
dep: $(depends)
.PHONY: static
static: $(objs)
.PHONY: dosetrev
dosetrev:
@echo "New $(VERSIONTYPE) revision: $(THISREVISION)"
@if [ -f "main.o" ] ; then \
rm main.o ; \
fi
@echo "$(THISREVISION)" >.$(VERSIONTYPE)revision
.PHONY: docbook-clean
docbook-clean:
-@for r in $(modules) $(static_modules_path) "" ; do \
if [ -d "$$r" ]; then \
if [ -d "$$r"/doc ]; then \
rm -f "$$r"/doc/*.txt ; \
rm -f "$$r"/doc/*.html ; \
rm -f "$$r"/doc/*.pdf ; \
fi ; \
fi ; \
done
.PHONY: dbschema-docbook-clean
dbschema-docbook-clean:
-@if [ -d doc/database ] ; then \
rm -f doc/database/*.txt ; \
rm -f doc/database/*.html ; \
rm -f doc/database/*.pdf ; \
$(MAKE) -C db/schema docbook_clean; \
fi
.PHONY: clean
clean: docbook-clean dbschema-docbook-clean
-@rm -f $(objs) $(NAME) $(objs:.o=.il) 2>/dev/null
-@for r in $(all_modules) "" ; do \
if [ -d "$$r" -a -f "$$r/Makefile" ]; then \
$(MAKE) -C $$r clean ; \
fi ; \
done
-@for r in $(all_utils) "" ; do \
if [ -d "$$r" -a -f "$$r/Makefile" ]; then \
$(MAKE) -C $$r clean ; \
fi ; \
done
.PHONY: proper
.PHONY: distclean
.PHONY: realclean
proper realclean distclean: clean
-@rm -f $(depends) $(auto_gen) 2>/dev/null
-@rm -f cfg.tab.h 2>/dev/null
-@for r in $(all_nostatic_modules) "" ; do \
if [ -d "$$r" -a -f "$$r/Makefile" ]; then \
$(MAKE) -C $$r proper ; \
fi ; \
done
-@if [ -d utils/opensipsunix ]; then $(MAKE) -C utils/opensipsunix proper; fi
-@if [ -d utils/db_berkeley ]; then $(MAKE) -C utils/db_berkeley proper; fi
-@if [ -d utils/db_oracle ]; then $(MAKE) -C utils/db_oracle proper; fi
.PHONY: mantainer-clean
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
-@if [ -d utils/opensipsunix ]; then $(MAKE) -C utils/opensipsunix mantainer-clean; fi
.PHONY: install_module_custom
.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