]> git.llucax.com Git - software/posixx.git/commitdiff
Avoid rebuilding of doc, (mem)test and install targets
authorLeandro Lucarella <llucarella@integratech.com.ar>
Mon, 22 Sep 2008 18:05:51 +0000 (15:05 -0300)
committerLeandro Lucarella <llucarella@integratech.com.ar>
Mon, 22 Sep 2008 18:05:51 +0000 (15:05 -0300)
This patch improves the Makefiles to avoid unnecessary rebuilding of some
targets, like doc/test/memtest/install, which only need to be "rebuilt"
when the sources has changed.

This is implemented using empty target files to record events, as
described in the GNU make manual[1].

[1] http://www.gnu.org/software/make/manual/make.html#Empty-Targets

doc/.gitignore
doc/Makefile
src/.gitignore [new file with mode: 0644]
src/Makefile
test/.gitignore
test/Makefile

index 217c48d3611f2dbdfcb032be7722cfa6086f549b..7f4148515abf56ad48ee24754fee935b399362b2 100644 (file)
@@ -1,2 +1,3 @@
 reference
 include
+.*-stamp
index 62de89f769e4d9dfd79f61cde7b959a2f48764ca..24f38798f986ee4cfa989cbf1d8453eaf588e365 100644 (file)
@@ -1,17 +1,34 @@
 
+# sources from where to build the sources
+DOC_SOURCES = $(shell find ../src -name '*.hpp')
 
 # prefix for installing the binaries and headers
 prefix=/usr/local
 
 
+# install command
+INSTALL = install -p -m 0644 -D
+
+
+# install utility functions
+install_msg = echo "  INSTALL $(1)"
+
+install_group = @$(call install_msg,$(2)) && \
+       cd reference && \
+       for f in `find $(1) -type f`; do \
+               $(call install,$$f,$(2)/$$f); \
+       done && \
+       cd .. && \
+       touch $@
+
 ifneq ($(V), 1)
 NICE_DOXY = @echo "  DOXYGEN"; (cat Doxyfile; echo "QUIET=YES") | doxygen -
 NICE_CLEAN = @echo "  CLEAN"; $(RM)
-NICE = @
+install = $(INSTALL) $(1) $(2)
 else
 NICE_DOXY = doxygen
 NICE_CLEAN = $(RM) -v
-NICE =
+install = $(call install_msg,$(2)); $(INSTALL) $(1) $(2)
 endif
 
 
@@ -19,30 +36,30 @@ default: all
 
 all: doc
 
-doc: include
+doc: .doc-stamp
+
+.doc-stamp: include $(DOC_SOURCES) Doxyfile
        $(NICE_DOXY)
+       @touch $@
 
 install: install-man install-html
 
-install-man: doc
-       $(NICE) for f in `find reference/man -type f | cut -b11-`; do \
-               echo "  INSTALL $(prefix)/share/$$f"; \
-               install -p -m 0644 -D reference/$$f $(prefix)/share/$$f; \
-       done
+install-man: .install-man-stamp
+
+.install-man-stamp: .doc-stamp
+       $(call install_group,man,$(prefix)/share/man)
 
-install-html: doc
-       $(NICE) for f in `find reference/html -type f | cut -b11-`; do \
-               echo "  INSTALL $(prefix)/share/doc/posixx/$$f"; \
-               install -p -m 0644 -D reference/$$f $(prefix)/share/doc/posixx/$$f; \
-       done
+install-html: .install-html-stamp
+
+.install-html-stamp: .doc-stamp
+       $(call install_group,html,$(prefix)/share/doc/posixx/html)
 
 include:
        @mkdir -p include
        @ln -fs ../../src include/posixx
 
 clean:
-       $(NICE_CLEAN) -r reference include
+       $(NICE_CLEAN) -r reference include .*-stamp
 
 .PHONY: default all doc install install-man install-doc clean
 
-
diff --git a/src/.gitignore b/src/.gitignore
new file mode 100644 (file)
index 0000000..d1943c2
--- /dev/null
@@ -0,0 +1 @@
+.*-stamp
index 23fde579e6615fd1788596816655e70677cd5965..e3563d327ffad3ebae30381babecb51ddd48cda1 100644 (file)
@@ -6,30 +6,41 @@ HEADERS = $(shell find -name '*.hpp' | cut -b3-)
 HDRPATH = posixx
 
 
+# install command
+INSTALL = install -p -m 0644 -D
+
+
+# install utility functions
+install_msg = echo "  INSTALL $(1)"
+
+install_files = @$(call install_msg,$(2)) && \
+       for f in $(1); do \
+               $(call install,$$f,$(2)/$$f); \
+       done && \
+       touch $@
+
 ifneq ($(V), 1)
-NICE_NOP =
-NICE = @
+NICE_CLEAN = @echo "  CLEAN"; $(RM)
+install = $(INSTALL) $(1) $(2)
 else
-NICE_NOP = @echo "Nothing to do, headers only"
-NICE =
+NICE_CLEAN = $(RM) -v
+install = $(call install_msg,$(2)); $(INSTALL) $(1) $(2)
 endif
 
 
 default: all
 
 all:
-       $(NICE_NOP)
-
-install-headers: $(HEADERS)
-       $(NICE) for f in $(HEADERS); do \
-               echo "  INSTALL $(prefix)/include/$(HDRPATH)/$$f"; \
-               install -p -m 0644 -D $$f $(prefix)/include/$(HDRPATH)/$$f; \
-       done
 
 install: install-headers
 
+install-headers: .install-headers-stamp
+
+.install-headers-stamp: $(HEADERS)
+       $(call install_files,$^,$(prefix)/include/$(HDRPATH))
+
 clean:
-       $(NICE_NOP)
+       $(NICE_CLEAN) .*-stamp
 
-.PHONY: default all clean install-headers install
+.PHONY: default all install install-headers clean
 
index 101f14a84a53426980f20034bad327136d2a263e..a80bb3f027555a42d5b75e9abefba3139ecd77c5 100644 (file)
@@ -5,3 +5,4 @@ test_suite
 test_suite.log
 valgrind.log
 valgrind.test_suite.log
+.*-stamp
index b9ae44899ea7efbcbaae1042d9d2b5532d1fe168..bc09ff4ac8805b502833d2f35a2017da099cb7a2 100644 (file)
@@ -36,9 +36,9 @@ endif
 ifneq ($(V), 1)
 NICE_CXX = @echo "  CXX $@"; $(CXX)
 NICE_LINK = @echo "  LINK $@"; $(CXX)
-NICE_TEST = @echo "  TEST"; $(TESTCMD) > test_suite.log 2>&1
+NICE_TEST = @echo "  TEST"; $(TESTCMD) > $(TESTPRG).log 2>&1
 NICE_MEMTEST = @echo "  MEMTEST"; $(VALGRIND) --log-file=valgrind.log \
-               $(TESTCMD) > valgrind.test_suite.log 2>&1
+               $(TESTCMD) > valgrind.$(TESTPRG).log 2>&1
 NICE_CLEAN = @echo "  CLEAN"; $(RM)
 else
 NICE_CXX = $(CXX)
@@ -51,7 +51,7 @@ endif
 
 default: all
 
-all: test_suite
+all: $(TESTPRG)
 
 
 # dependency handling
@@ -93,16 +93,22 @@ include:
        @mkdir -p include
        @ln -fs ../../src include/posixx
 
-test: all
+test: .test-stamp
+
+.test-stamp: $(TESTPRG)
        $(NICE_TEST)
+       @touch $@
+
+memtest: .memtest-stamp
 
-memtest: all
+.memtest-stamp: $(TESTPRG)
        $(NICE_MEMTEST)
+       @touch $@
 
 clean:
        $(NICE_CLEAN) -r $(TESTPRG) include $(OBJS) .deps valgrind.log \
-               *.bb *.bbg *.da *.gcov *.gcda *.gcno gmon.out
+               *.bb *.bbg *.da *.gcov *.gcda *.gcno gmon.out .*-stamp
 
-.PHONY: default all test clean
+.PHONY: default all test memtest clean