autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Expanded rules for scripts


From: Pavel Roskin
Subject: RE: Expanded rules for scripts
Date: Thu, 14 Dec 2000 10:25:26 -0500 (EST)

Hello, Bernard and Akim!

> But anyway the documentation patch should be enhanced as it was not
> clear enough.

Well, it was unclear enough to confuse at least two people :-/

Let me explain in more words (but this can be too verbose for the
documentation).

It's portable to use suffix rules. It doesn't matter whether it's a
double-suffix rule like this:

.c.o:
        cc -c $<

or a single-suffix rule like this:

.sh:
        $(editsh) $< > $@

I'm not aware of any differences in the way how single-suffix and
double-suffix rules are handled.

What I was talking about, and what lead me into expanding the rules is a
limitation of the suffix rules, that, to my best knowledge (please correct
me if you can!!!) cannot be worked around except by writing explicit
rules.

As the GNU make manual puts it:

=====================================
   Suffix rules cannot have any prerequisites of their own.  If they
have any, they are treated as normal files with funny names, not as
suffix rules.  Thus, the rule:

     .c.o: foo.h
             $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<

tells how to make the file `.c.o' from the prerequisite file `foo.h'
=====================================

You cannot make the target of the suffix rule depend on anything else
other then the "corresponding implicit prerequisite".

Along with the above example, there is another _bad_ way of adding
prerequisites to the suffix rules without overriding them, which was until
recently exploited by Autoconf.

I mean an explicit rule without commands, something like this:

.c.o:
        $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<

$(SOURCES): foo.h

This would work as expected with GNU make, but is will break with BSD
make. It will not just break, it will break badly, because it is not the
explicit rule that in ignored by BSD make - it is the suffix rule. Thus
the commands in the suffix rule will not be run by the BSD make.

This certainly doesn't belong to the section "Limitations of Usual Tools"
of the Autoconf manual. That section describes how to write portable
tests.

And this is how to write portable makefiles, so it belongs to
make-stds.texi or maybe also to the Automake manual.

Regards,
Pavel Roskin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]