2
0
Эх сурвалжийг харах

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 16 жил өмнө
parent
commit
8ca5d8dda4
5 өөрчлөгдсөн 86 нэмэгдсэн , 38 устгасан
  1. 22 5
      Makefile
  2. 3 6
      Makefile.libs
  3. 45 21
      Makefile.rules
  4. 9 2
      Makefile.targets
  5. 7 4
      lib/Makefile

+ 22 - 5
Makefile

@@ -763,23 +763,40 @@ install-modules-man: modules-man $(man_prefix)/$(man_dir)/man7
 	done; true
 
 
-.PHONY: clean_libs
+# libs cleaning targets
+.PHONY: clean-libs
+clean-libs:
+			$(MAKE) -C lib clean
 
-clean_libs:
-			$(MAKE) -C lib proper
+.PHONY: proper-libs realclean-libs distclean-libs maintainer-clean-libs
+proper-libs realclean-libs distclean-libs maintainer-clean-libs:
+			$(MAKE) -C lib $(patsubst %-libs,%,$@)
 
 
+# clean modules on make clean
+clean: clean-modules
+# clean utils on make clean
+clean: clean-utils
 # cleaning in libs always when cleaning ser
-clean:	clean_libs
+clean: clean-libs
+
+# proper/distclean a.s.o modules, utils and libs too
+
+proper: proper-modules proper-utils proper-libs
+distclean: distclean-modules distclean-utils distclean-libs
+realclean: realclean-modules realclean-utils realclean-libs
+maintainer-clean: maintainer-clean-modules maintainer-clean-utils \
+ maintainer-clean-libs
 
 #try to clean everything (including all the modules, even ones that are not
 # configured/compiled normally
 .PHONY: clean-all
 clean-all: modules=$(modules_all)
 clean-all: clean
+maintainer-clean: modules=$(modules_all)
 
 # on make proper clean also the build config (w/o module list)
-proper realclean distclean: clean_cfg 
+proper realclean distclean maintainer-clean: clean_cfg
 
 # on maintainer clean, remove also the configured module list
 maintainer-clean: clean_modules_cfg

+ 3 - 6
Makefile.libs

@@ -123,16 +123,13 @@ link_clean:
 	-@rm -f $(LIB_RUNTIME_NAME)
 	-@rm -f $(LIB_LINK_NAME)
 
-clean: link_clean
+local-clean: link_clean
 
-ifneq ($(strip $(LIBINAME_F)),)
 .PHONY: libiname_clean
-
 libiname_clean:
-	-@rm -f "$(LIBINAME_F)"
+	-@rm -f libiname.lst
 
-clean: libiname_clean
-endif
+local-clean: libiname_clean
 
 $(lib_prefix)/$(lib_dir):
 	mkdir -p $(lib_prefix)/$(lib_dir)

+ 45 - 21
Makefile.rules

@@ -158,54 +158,78 @@ dep: $(depends)
 .PHONY: static
 static: $(objs)
 
-.PHONY: clean
-clean: 
+# clean only the current directory (no modules or utils)
+# (it's usefull to have it separated from clean for speeding up make proper)
+.PHONY: local-clean
+local-clean:
 	-@rm -f $(objs) $(NAME) $(objs:.o=.il) librpath.lst 2>/dev/null
+
+.PHONY: clean
+clean: local-clean
+
+.PHONY: clean-modules
+clean-modules:
 	-@for r in $(modules) $(static_modules_path) "" ; do \
 		if [ -d "$$r" ]; then \
 			echo "module $$r" ; \
-			$(MAKE) -C $$r clean ; \
-			$(MAKE) -C $$r/doc clean ; \
+			$(MAKE) -C "$$r" clean ; \
+			[ -d "$$r"/doc/Makefile ] && $(MAKE) -C "$$r"/doc clean ; \
 		fi ; \
-	done 
+	done
+
+.PHONY: clean-utils
+clean-utils:
 	@if [ -n "$(modules)" ]; then \
 		for r in $(utils_compile) "" ; do \
 			if [ -d "$$r" ]; then \
-				 $(MAKE) -C $$r clean ; \
+				 $(MAKE) -C "$$r" clean ; \
 			fi ; \
 		done \
 	fi
 
+# make proper for the local directory
 .PHONY: proper
 .PHONY: distclean
 .PHONY: realclean
-proper realclean distclean: mrproper
-
-mrproper: clean 
+.PHONY: maintainer-clean
+proper distclean realclean maintainer-clean: local-clean
 	-@rm -f $(depends) $(auto_gen) $(auto_gen_others) \
 			makecfg.lst 2>/dev/null
+
+maintainer-clean: clean-tmp
+
+.PHONY: proper-modules
+.PHONY: distclean-modules
+.PHONY: realclean-modules
+.PHONY: maintainer-clean-modules
+proper-modules realclean-modules distclean-modules maintainer-clean-modules: \
+ clean_target=$(patsubst %-modules,%,$@)
+proper-modules realclean-modules distclean-modules maintainer-clean-modules:
 	-@for r in $(modules) "" ; do \
 		if [ -d "$$r" ]; then \
-			$(MAKE) -C $$r proper ; \
-			$(MAKE) -C $$r/doc proper ; \
+			$(MAKE) -C "$$r" $(clean_target); \
+			[ -r "$$r"/doc/Makefile ] && $(MAKE) -C "$$r"/doc $(clean_target);\
 		fi ; \
-	done 
+	done
+
+.PHONY: proper-utils
+.PHONY: distclean-utils
+.PHONY: realclean-utils
+.PHONY: maintainer-clean-utils
+proper-utils realclean-utils distclean-utils maintainer-clean-utils: \
+ clean_target=$(patsubst %-utils,%,$@)
+proper-utils realclean-utils distclean-utils maintainer-clean-utils:
 	@if [ -n "$(modules)" ]; then \
 		for r in $(utils_compile) "" ; do \
 			if [ -d "$$r" ]; then \
-				 $(MAKE) -C $$r proper ; \
+				 $(MAKE) -C "$$r" $(clean_target); \
 			fi ; \
 		done \
 	fi
 
-.PHONY: maintainer-clean
-maintainer-clean: distclean
-	-rm -f TAGS tags *.dbg .*.swp
-	-@for r in $(modules) "" ; do \
-		if [ -d "$$r" ]; then \
-			$(MAKE) -C $$r maintainer-clean; \
-		fi ; \
-	 done 
+.PHONY: clean-tmp
+clean-tmp:
+	-@rm -f TAGS tags *.dbg .*.swp
 
 
 .PHONY: doxygen

+ 9 - 2
Makefile.targets

@@ -13,9 +13,16 @@
 #  2008-06-26  initial version (andrei) 
 #
 
-clean_targets:=	clean proper distclean realclean maintainer-clean clean_libs \
+clean_targets:=	clean proper distclean realclean maintainer-clean local-clean \
 				clean-all proper-all distclean-all realclean-all \
-				clean_cfg clean_modules_cfg clean-modules-cfg
+				clean_cfg clean_modules_cfg clean-modules-cfg \
+				clean-modules proper-modules realclean-modules \
+				distclean-modules maintainer-clean-modules \
+				clean-utils proper-utils realclean-utils distclean-utils \
+				maintaner-clean-utils \
+				clean-libs proper-libs realclean-libs distclean-libs \
+				maintainer-clean-libs \
+				clean-tmp clean_doxygen
 doc_targets:=	modules-doc modules-readme README modules-man man \
 		install-doc install-modules-doc install-man install-ser-man \
 		install-modules-man

+ 7 - 4
lib/Makefile

@@ -7,7 +7,10 @@
 #
 
 
-SUBDIRS=binrpc cds xcap presence shm_regex
+#SUBDIRS=binrpc cds xcap presence shm_regex
+
+SUBDIRS=$(filter-out CVS doc $(lib_exclude), $(strip \
+			$(patsubst %/Makefile,%,$(wildcard */Makefile))))
 
 .PHONY: subdirs $(SUBDIRS) 
 
@@ -22,11 +25,11 @@ subdirs: $(SUBDIRS)
 $(SUBDIRS):	
 			-@echo "Making $(sub_goals) in $@" ; $(MAKE) $(sub_goals) -C $@
 
-all:	subdirs
+include ../Makefile.targets
 
-proper:	clean
+all:	subdirs
 
-clean:	subdirs
+$(clean_targets): subdirs
 
 install:	subdirs