forked from OpenSIPS/opensips
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.rules
170 lines (138 loc) · 4.08 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#
#
# 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)
builtin_modules=$(shell [ -d net ] && ls net | grep ^proto_ )
all_nostatic_modules=$(filter-out $(addprefix modules/, $(static_modules)), \
$(wildcard modules/*))
all_modules:=$(addprefix modules/, $(all_modules))
all_modules:="$(addprefix net/, $(builtin_modules)) $all_modules"
all_utils:=$(addprefix utils/, $(all_utils))
#implicit rules
%.o: %.c $(ALLDEP)
ifeq (,$(FASTER))
@echo "Compiling $<"
endif
$(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): $(objs) $(extra_objs) $(ALLDEP)
ifeq (,$(FASTER))
@echo "Linking $(NAME)"
endif
$(Q)$(LD) $(LDFLAGS) $(objs) $(extra_objs) $(LIBS) -o $(NAME)
main.o: main.c $(ALLDEP) $(NEWREVISION)
ifeq (,$(FASTER))
@echo "Compiling $<"
endif
$(Q)$(CC) $(CFLAGS) $(DEFS) -c $< -o $@
.PHONY: all
all: $(NAME) modules
.PHONY: dep
dep: $(depends)
.PHONY: static
static: $(objs)
Makefile.conf: Makefile.conf.template
@if ! [ -e "$@" ]; then \
echo Creating new $@; \
cp $< $@; \
fi
$(cfg-prefix)/$(cfg-dir):
mkdir -p $(cfg-prefix)/$(cfg-dir)
$(bin-prefix)/$(bin-dir):
mkdir -p $(bin-prefix)/$(bin-dir)
$(modules-prefix)/$(modules-dir):
mkdir -p $(modules-prefix)/$(modules-dir)
$(doc-prefix)/$(doc-dir):
mkdir -p $(doc-prefix)/$(doc-dir)
$(man-prefix)/$(man-dir)/man8:
mkdir -p $(man-prefix)/$(man-dir)/man8
$(man-prefix)/$(man-dir)/man5:
mkdir -p $(man-prefix)/$(man-dir)/man5
$(data-prefix)/$(data-dir):
mkdir -p $(data-prefix)/$(data-dir)
.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 menuconfig ]; then $(MAKE) -C menuconfig proper; fi
-@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