[SR-Dev] git:ser_core_cvs: makefiles: fixes and speed-ups

Andrei Pelinescu-Onciul andrei at iptel.org
Thu Apr 23 12:51:08 CEST 2009


Module: sip-router
Branch: ser_core_cvs
Commit: 8ca5d8dda4250da35e041833d4427ea8cfd28bfa
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8ca5d8dda4250da35e041833d4427ea8cfd28bfa

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Wed Apr 22 13:46:30 2009 +0000

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).

---

 Makefile         |   27 ++++++++++++++++++----
 Makefile.libs    |    9 ++-----
 Makefile.rules   |   66 ++++++++++++++++++++++++++++++++++++-----------------
 Makefile.targets |   11 +++++++-
 lib/Makefile     |   11 +++++---
 5 files changed, 86 insertions(+), 38 deletions(-)

diff --git a/Makefile b/Makefile
index 003ba26..98ff4d2 100644
--- a/Makefile
+++ b/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
diff --git a/Makefile.libs b/Makefile.libs
index d780dd3..d1f6f3e 100644
--- a/Makefile.libs
+++ b/Makefile.libs
@@ -123,16 +123,13 @@ link_clean:
 	- at rm -f $(LIB_RUNTIME_NAME)
 	- at rm -f $(LIB_LINK_NAME)
 
-clean: link_clean
+local-clean: link_clean
 
-ifneq ($(strip $(LIBINAME_F)),)
 .PHONY: libiname_clean
-
 libiname_clean:
-	- at rm -f "$(LIBINAME_F)"
+	- at rm -f libiname.lst
 
-clean: libiname_clean
-endif
+local-clean: libiname_clean
 
 $(lib_prefix)/$(lib_dir):
 	mkdir -p $(lib_prefix)/$(lib_dir)
diff --git a/Makefile.rules b/Makefile.rules
index f1ea045..ad51d49 100644
--- a/Makefile.rules
+++ b/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:
 	- at rm -f $(objs) $(NAME) $(objs:.o=.il) librpath.lst 2>/dev/null
+
+.PHONY: clean
+clean: local-clean
+
+.PHONY: clean-modules
+clean-modules:
 	- at 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
 	- at 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:
 	- at 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
-	- at for r in $(modules) "" ; do \
-		if [ -d "$$r" ]; then \
-			$(MAKE) -C $$r maintainer-clean; \
-		fi ; \
-	 done 
+.PHONY: clean-tmp
+clean-tmp:
+	- at rm -f TAGS tags *.dbg .*.swp
 
 
 .PHONY: doxygen
diff --git a/Makefile.targets b/Makefile.targets
index 8ccae76..8f287ab 100644
--- a/Makefile.targets
+++ b/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
diff --git a/lib/Makefile b/lib/Makefile
index 01bbc1d..353b76f 100644
--- a/lib/Makefile
+++ b/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):	
 			- at 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
 




More information about the sr-dev mailing list