new target for contrib/Makefile

Started by Andrew Dunstanalmost 22 years ago7 messagespatches
Jump to latest
#1Andrew Dunstan
andrew@dunslane.net

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.
To solve that I implemented a new target that does run them all and only
fails at the end if any have failed. The patch is attached for your
delectation.

cheers

andrew

Attachments:

contrib-make.patchtext/x-patch; name=contrib-make.patchDownload+6-0
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#1)
Re: new target for contrib/Makefile

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.

regards, tom lane

#3Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#2)
Re: new target for contrib/Makefile

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.

But I am not a make expert (make has almost as many warts as sendmail ...)

cheers

andrew

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#3)
Re: new target for contrib/Makefile

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

#5Peter Eisentraut
peter_e@gmx.net
In reply to: Tom Lane (#4)
Re: new target for contrib/Makefile

Tom Lane wrote:

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?

I've seen the following idea somewhere:

SUBDIRS = ...

.PHONY: $(addsuffix -foo, $(SUBDIRS)):

$(addsuffix -foo, $(SUBDIRS)):
$(MAKE) -C `echo $@ | sed 's/-.*$//'` `echo $@ | sed 's/^.*-//'`

Repeat for all "foo" targets that you need. The sed expressions may
need refining.

Then again, the original proposal doesn't sound so bad either.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#5)
Re: new target for contrib/Makefile

Peter Eisentraut <peter_e@gmx.net> writes:

I've seen the following idea somewhere:

Looks like you used a variant of this in src/backend/Makefile.

Then again, the original proposal doesn't sound so bad either.

Well, I'd like a more generic fix that we could apply everywhere,
because right now the Makefiles are not good about honoring -k,
and that irritates me at least a couple times a week ;-). As an
example, if you get a compile error in building the backend,
src/Makefile aborts after "$(MAKE) -C backend" returns, instead of
proceeding to build interfaces, bin, etc.

regards, tom lane

#7Andrew Dunstan
andrew@dunslane.net
In reply to: Peter Eisentraut (#5)
Re: new target for contrib/Makefile

Peter Eisentraut wrote:

Tom Lane wrote:

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?

I've seen the following idea somewhere:

SUBDIRS = ...

.PHONY: $(addsuffix -foo, $(SUBDIRS)):

$(addsuffix -foo, $(SUBDIRS)):
$(MAKE) -C `echo $@ | sed 's/-.*$//'` `echo $@ | sed 's/^.*-//'`

Cute. And wonderfully cryptic. I'm sure I've lost brain cells already
just trying to understand it ;-)

cheers

andrew