Browse code

makefiles: fixes and speed-ups

- make clean, proper, realclean, distclean and maintainer-clean
will work on all the libs in the lib/ directory.
- clean, proper, realclean, distclean and maintainer-clean targets
split into more specific targets: local-clean, clean-modules,
clean-libs, clean-utils (and the same for the others) => make
proper & friends depend now only on the really needed parts =>
much faster.
- doc directories are entered only if a Makefile is present.
- make maintainer-clean properly deletes the config and the
modules list at the end (it doesn't recreate it).

Andrei Pelinescu-Onciul authored on 22/04/2009 13:46:30
Showing 5 changed files
... ...
@@ -763,23 +763,40 @@ install-modules-man: modules-man $(man_prefix)/$(man_dir)/man7
763 763
 	done; true
764 764
 
765 765
 
766
-.PHONY: clean_libs
766
+# libs cleaning targets
767
+.PHONY: clean-libs
768
+clean-libs:
769
+			$(MAKE) -C lib clean
767 770
 
768
-clean_libs:
769
-			$(MAKE) -C lib proper
771
+.PHONY: proper-libs realclean-libs distclean-libs maintainer-clean-libs
772
+proper-libs realclean-libs distclean-libs maintainer-clean-libs:
773
+			$(MAKE) -C lib $(patsubst %-libs,%,$@)
770 774
 
771 775
 
776
+# clean modules on make clean
777
+clean: clean-modules
778
+# clean utils on make clean
779
+clean: clean-utils
772 780
 # cleaning in libs always when cleaning ser
773
-clean:	clean_libs
781
+clean: clean-libs
782
+
783
+# proper/distclean a.s.o modules, utils and libs too
784
+
785
+proper: proper-modules proper-utils proper-libs
786
+distclean: distclean-modules distclean-utils distclean-libs
787
+realclean: realclean-modules realclean-utils realclean-libs
788
+maintainer-clean: maintainer-clean-modules maintainer-clean-utils \
789
+ maintainer-clean-libs
774 790
 
775 791
 #try to clean everything (including all the modules, even ones that are not
776 792
 # configured/compiled normally
777 793
 .PHONY: clean-all
778 794
 clean-all: modules=$(modules_all)
779 795
 clean-all: clean
796
+maintainer-clean: modules=$(modules_all)
780 797
 
781 798
 # on make proper clean also the build config (w/o module list)
782
-proper realclean distclean: clean_cfg 
799
+proper realclean distclean maintainer-clean: clean_cfg
783 800
 
784 801
 # on maintainer clean, remove also the configured module list
785 802
 maintainer-clean: clean_modules_cfg
... ...
@@ -123,16 +123,13 @@ link_clean:
123 123
 	-@rm -f $(LIB_RUNTIME_NAME)
124 124
 	-@rm -f $(LIB_LINK_NAME)
125 125
 
126
-clean: link_clean
126
+local-clean: link_clean
127 127
 
128
-ifneq ($(strip $(LIBINAME_F)),)
129 128
 .PHONY: libiname_clean
130
-
131 129
 libiname_clean:
132
-	-@rm -f "$(LIBINAME_F)"
130
+	-@rm -f libiname.lst
133 131
 
134
-clean: libiname_clean
135
-endif
132
+local-clean: libiname_clean
136 133
 
137 134
 $(lib_prefix)/$(lib_dir):
138 135
 	mkdir -p $(lib_prefix)/$(lib_dir)
... ...
@@ -158,54 +158,78 @@ dep: $(depends)
158 158
 .PHONY: static
159 159
 static: $(objs)
160 160
 
161
-.PHONY: clean
162
-clean: 
161
+# clean only the current directory (no modules or utils)
162
+# (it's usefull to have it separated from clean for speeding up make proper)
163
+.PHONY: local-clean
164
+local-clean:
163 165
 	-@rm -f $(objs) $(NAME) $(objs:.o=.il) librpath.lst 2>/dev/null
166
+
167
+.PHONY: clean
168
+clean: local-clean
169
+
170
+.PHONY: clean-modules
171
+clean-modules:
164 172
 	-@for r in $(modules) $(static_modules_path) "" ; do \
165 173
 		if [ -d "$$r" ]; then \
166 174
 			echo "module $$r" ; \
167
-			$(MAKE) -C $$r clean ; \
168
-			$(MAKE) -C $$r/doc clean ; \
175
+			$(MAKE) -C "$$r" clean ; \
176
+			[ -d "$$r"/doc/Makefile ] && $(MAKE) -C "$$r"/doc clean ; \
169 177
 		fi ; \
170
-	done 
178
+	done
179
+
180
+.PHONY: clean-utils
181
+clean-utils:
171 182
 	@if [ -n "$(modules)" ]; then \
172 183
 		for r in $(utils_compile) "" ; do \
173 184
 			if [ -d "$$r" ]; then \
174
-				 $(MAKE) -C $$r clean ; \
185
+				 $(MAKE) -C "$$r" clean ; \
175 186
 			fi ; \
176 187
 		done \
177 188
 	fi
178 189
 
190
+# make proper for the local directory
179 191
 .PHONY: proper
180 192
 .PHONY: distclean
181 193
 .PHONY: realclean
182
-proper realclean distclean: mrproper
183
-
184
-mrproper: clean 
194
+.PHONY: maintainer-clean
195
+proper distclean realclean maintainer-clean: local-clean
185 196
 	-@rm -f $(depends) $(auto_gen) $(auto_gen_others) \
186 197
 			makecfg.lst 2>/dev/null
198
+
199
+maintainer-clean: clean-tmp
200
+
201
+.PHONY: proper-modules
202
+.PHONY: distclean-modules
203
+.PHONY: realclean-modules
204
+.PHONY: maintainer-clean-modules
205
+proper-modules realclean-modules distclean-modules maintainer-clean-modules: \
206
+ clean_target=$(patsubst %-modules,%,$@)
207
+proper-modules realclean-modules distclean-modules maintainer-clean-modules:
187 208
 	-@for r in $(modules) "" ; do \
188 209
 		if [ -d "$$r" ]; then \
189
-			$(MAKE) -C $$r proper ; \
190
-			$(MAKE) -C $$r/doc proper ; \
210
+			$(MAKE) -C "$$r" $(clean_target); \
211
+			[ -r "$$r"/doc/Makefile ] && $(MAKE) -C "$$r"/doc $(clean_target);\
191 212
 		fi ; \
192
-	done 
213
+	done
214
+
215
+.PHONY: proper-utils
216
+.PHONY: distclean-utils
217
+.PHONY: realclean-utils
218
+.PHONY: maintainer-clean-utils
219
+proper-utils realclean-utils distclean-utils maintainer-clean-utils: \
220
+ clean_target=$(patsubst %-utils,%,$@)
221
+proper-utils realclean-utils distclean-utils maintainer-clean-utils:
193 222
 	@if [ -n "$(modules)" ]; then \
194 223
 		for r in $(utils_compile) "" ; do \
195 224
 			if [ -d "$$r" ]; then \
196
-				 $(MAKE) -C $$r proper ; \
225
+				 $(MAKE) -C "$$r" $(clean_target); \
197 226
 			fi ; \
198 227
 		done \
199 228
 	fi
200 229
 
201
-.PHONY: maintainer-clean
202
-maintainer-clean: distclean
203
-	-rm -f TAGS tags *.dbg .*.swp
204
-	-@for r in $(modules) "" ; do \
205
-		if [ -d "$$r" ]; then \
206
-			$(MAKE) -C $$r maintainer-clean; \
207
-		fi ; \
208
-	 done 
230
+.PHONY: clean-tmp
231
+clean-tmp:
232
+	-@rm -f TAGS tags *.dbg .*.swp
209 233
 
210 234
 
211 235
 .PHONY: doxygen
... ...
@@ -13,9 +13,16 @@
13 13
 #  2008-06-26  initial version (andrei) 
14 14
 #
15 15
 
16
-clean_targets:=	clean proper distclean realclean maintainer-clean clean_libs \
16
+clean_targets:=	clean proper distclean realclean maintainer-clean local-clean \
17 17
 				clean-all proper-all distclean-all realclean-all \
18
-				clean_cfg clean_modules_cfg clean-modules-cfg
18
+				clean_cfg clean_modules_cfg clean-modules-cfg \
19
+				clean-modules proper-modules realclean-modules \
20
+				distclean-modules maintainer-clean-modules \
21
+				clean-utils proper-utils realclean-utils distclean-utils \
22
+				maintaner-clean-utils \
23
+				clean-libs proper-libs realclean-libs distclean-libs \
24
+				maintainer-clean-libs \
25
+				clean-tmp clean_doxygen
19 26
 doc_targets:=	modules-doc modules-readme README modules-man man \
20 27
 		install-doc install-modules-doc install-man install-ser-man \
21 28
 		install-modules-man
... ...
@@ -7,7 +7,10 @@
7 7
 #
8 8
 
9 9
 
10
-SUBDIRS=binrpc cds xcap presence shm_regex
10
+#SUBDIRS=binrpc cds xcap presence shm_regex
11
+
12
+SUBDIRS=$(filter-out CVS doc $(lib_exclude), $(strip \
13
+			$(patsubst %/Makefile,%,$(wildcard */Makefile))))
11 14
 
12 15
 .PHONY: subdirs $(SUBDIRS) 
13 16
 
... ...
@@ -22,11 +25,11 @@ subdirs: $(SUBDIRS)
22 22
 $(SUBDIRS):	
23 23
 			-@echo "Making $(sub_goals) in $@" ; $(MAKE) $(sub_goals) -C $@
24 24
 
25
-all:	subdirs
25
+include ../Makefile.targets
26 26
 
27
-proper:	clean
27
+all:	subdirs
28 28
 
29
-clean:	subdirs
29
+$(clean_targets): subdirs
30 30
 
31 31
 install:	subdirs
32 32