Martin,

As we discussed, the patch has to overcome two related issues: the
one-time build of the config.h header when gmake is invoked first time
in TOPDIR and the updating of config.h (without creating a circular
dependency) whenever needed and whenever gmake is invoked in BUILDDIR,
regardless of the target.

This patch is (I believe) an improvement over the previous ones in that
the building process visits the include directory every time  sources
change (and dependencies have to be rebuilt). Doing so it correctly
rebuilds config.h whenever its dependencies have been modified.

Please let me know if you see any more problems with it.

Thanks,
Liviu

Addressing:

http://issues.apache.org/jira/browse/STDCXX-85

ChangeLog entry:

2005-12-23  Liviu Nicoara  <[EMAIL PROTECTED]>

        * GNUMakefile: removed useless rules: all, builddir, added
          rule lib, added variable INCDIR
        * etc/config/makefile.rules: added PHONY dependency "config"
          to .d targets which invokes "$(MAKE) -C$(INCDIR)"
Index: GNUmakefile
===================================================================
--- GNUmakefile (revision 358872)
+++ GNUmakefile (working copy)
@@ -517,7 +517,10 @@
 
 ### TARGETS ##################################################################
 
-all: libstd
+# When invoked without any targets in TOPDIR, it will execute the 
+# first rule in the makefile which will build lib in BUILDDIR
+lib:
+       @$(MAKE) -C$(buildpath) $(MAKEFLAGS) lib BUILDDIR=$(buildpath)
 
 # make-builddir function: creates the build directory tree
 # defined as a single shell command to avoid executing each command
@@ -576,6 +579,7 @@
           && [ "$(MAPFILE)" = "" ]                                          \
           || echo "MAPFILE    = $$""(TOPDIR)/$(MAPFILE)" >> $(MAKEFILE_IN)  \
           && echo "RUNFLAGS   = -t 180"                  >> $(MAKEFILE_IN)  \
+          && echo "INCDIR     = $$""(BUILDDIR)/include"  >> $(MAKEFILE_IN)  \
           && echo "LIBDIR     = $$""(BUILDDIR)/lib"      >> $(MAKEFILE_IN)  \
           && echo "DEPENDDIR  = $(DEPENDDIR)"            >> $(MAKEFILE_IN)  \
           && echo "PHDIR      = $(PHDIR)"                >> $(MAKEFILE_IN)  \
@@ -599,21 +603,16 @@
           && echo "DEFAULT_SHROBJ = $(DEFAULT_SHROBJ)"   >> $(MAKEFILE_IN)  \
           && echo "CXX_REPOSITORY = $(CXX_REPOSITORY)"  >> $(MAKEFILE_IN));
 
-# creates the build directory tree and generates makefile.in
-builddir: $(MAKEFILE_IN)
-       @echo "build directory created: BUILDDIR=$(BUILDDIR)"
-
-
 # prevent trying to make makefile.in when $(BUILDDIR) is
 # not defined and -include $(BUILDDIR)/makefile.in fails
 makefile.in:
 
-
+# When invoked in TOPDIR with any targets which have no rules 
+# it will invoke make in BUILDDIR passing along the targets.
 .DEFAULT:
        @$(MAKE) -C$(buildpath) $(MAKEFLAGS) $(MAKECMDGOALS) \
                  BUILDDIR=$(buildpath)
 
-
 else   # ifneq ($(in_topdir),1) ##############################################
 
   ############################################################################
@@ -650,7 +649,6 @@
 examples:
        [EMAIL PROTECTED](MAKE) -C$(EXMDIR)
 
-
 # run all tests and examples, generate result file and post it in a revison
 # control system (unless the variable DRYRUN is non-empty) ; regressions
 # are computed with respect to last posted report (not just any report that's
Index: etc/config/makefile.rules
===================================================================
--- etc/config/makefile.rules   (revision 358872)
+++ etc/config/makefile.rules   (working copy)
@@ -147,6 +147,9 @@
 endif   # eq ($(findstring clean,$(MAKECMDGOALS)),)
 
 
+config:
+       $(MAKE) -C$(INCDIR)
+
 ifneq ($(DEPENDFLAGS),)
 
 # generate dependencies only if they don't yet exist, removing anything
@@ -189,17 +192,17 @@
 endef
 
 # rule to make dependencies for C++ source files
-$(DEPENDDIR)/%.d: %.cpp
+$(DEPENDDIR)/%.d: %.cpp config
        $(makedep)
 
 # rule to make dependencies for assembly files
-$(DEPENDDIR)/%.d: %$(AS_EXT)
+$(DEPENDDIR)/%.d: %$(AS_EXT) config
        $(makedep)
 
 
 else   # ifeq ($(DEPENDFLAGS),)
 
-$(DEPENDDIR)/%.d:
+$(DEPENDDIR)/%.d: config
 
 endif   # neq ($(DEPENDFLAGS),)
 

Reply via email to