Re: new target for contrib/Makefile - Mailing list pgsql-patches

From Tom Lane
Subject Re: new target for contrib/Makefile
Date
Msg-id 2963.1096489732@sss.pgh.pa.us
Whole thread Raw
In response to Re: new target for contrib/Makefile  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: new target for contrib/Makefile  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-patches
Andrew Dunstan <andrew@dunslane.net> writes:
> Tom Lane wrote:
>> Andrew Dunstan <andrew@dunslane.net> writes:
>>> If you run make installcheck in contrib it stops on the first module
>>> that fails. This is mildly annoying from the point of view of the
>>> buildfarm script, which wants to run all the available regression tests.
>>
>> Yeah.  ISTM that "make -k installcheck" should be the correct way to do
>> this, but I've never gotten around to figuring out how to make it work.

> I can't see an obvious way, because of the need to loop through
> WANTED_DIRS.

I found the following closely-related suggestion in the Make manual.
It's not quite there because it doesn't seem to provide a way to pass
down the current action (all/clean/install/etc) to the sub-Make.
Any ideas how we could do that?


      Another example of the usefulness of phony targets is in conjunction
   with recursive invocations of `make'.  In this case the makefile will
   often contain a variable which lists a number of subdirectories to be
   built.  One way to handle this is with one rule whose command is a
   shell loop over the subdirectories, like this:

        SUBDIRS = foo bar baz

        subdirs:
                for dir in $(SUBDIRS); do \
                  $(MAKE) -C $$dir; \
                done

      There are a few of problems with this method, however.  First, any
   error detected in a submake is not noted by this rule, so it will
   continue to build the rest of the directories even when one fails.
   This can be overcome by adding shell commands to note the error and
   exit, but then it will do so even if `make' is invoked with the `-k'
   option, which is unfortunate.  Second, and perhaps more importantly,
   you cannot take advantage of the parallel build capabilities of make
   using this method, since there is only one rule.

      By declaring the subdirectories as phony targets (you must do this as
   the subdirectory obviously always exists; otherwise it won't be built)
   you can remove these problems:

        SUBDIRS = foo bar baz

        .PHONY: subdirs $(SUBDIRS)

        subdirs: $(SUBDIRS)

        $(SUBDIRS):
                $(MAKE) -C $@
        foo: baz

      Here we've also declared that the `foo' subdirectory cannot be built
   until after the `baz' subdirectory is complete; this kind of
   relationship declaration is particularly important when attempting
   parallel builds.


            regards, tom lane

pgsql-patches by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: new target for contrib/Makefile
Next
From: Peter Eisentraut
Date:
Subject: Re: new target for contrib/Makefile