help-make
[Top][All Lists]
Advanced

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

Re: how to have an "optional" prerequisite in a static pattern rule


From: Paul D. Smith
Subject: Re: how to have an "optional" prerequisite in a static pattern rule
Date: Fri, 13 Jan 2006 14:41:26 -0500

%% "Ming Kin Lai" <address@hidden> writes:

  >> Your mail to 'Help-make' with the subject
  >> 
  >> how to have an "optional" prerequisite in a static pattern rule
  >> 
  >> Is being held until the list moderator can review it for approval.
  >> 
  >> The reason it is being held:
  >> 
  >> Post by non-member to a members-only list

  mkl> "Post by non-member to a members-only list"???
  mkl> http://www.gnu.org/software/make/ says "All of the above mailing
  mkl> lists are open for posting by non-subscribers".

They are.  However, if you don't subscribe to the list then your message
has to wait to be approved before it goes in.  As long as your post is
not spam it will be approved, but it has to wait to get that approval.

The mailing lists are spammed constantly.  I personally throw out about
25 spams to each of the 3 main make mailing lists every day, and I have
co-moderators who throw out more.

Without this check, all that spam would be sent directly to the mailing
list and every subscriber would see it all... and quickly we would have
no subscribers.

The current method is not perfect but it's the best solution we have.
Most GNU mailing lists are now using this method.

  mkl> Also, after sending out my question, I realized that there is
  mkl> already a similar question in a thread "Optional prerequisite" on
  mkl> August 31, 2005.  The answer is there is no way to do it.  Well,
  mkl> I don't mind you cancelling my post,

It was already approved this morning.  Unfortunately the mailing list
servers seem to be very busy so it's taking a few hours, it seems, after
approval for mail to arrive.

  mkl> or you can link the 8/31/2005 answer as the answer to my
  mkl> question, assuming the current version of make does not have any
  mkl> enhancement after 8/31/2005.  But I think it would be really nice
  mkl> that 'make' one day would be enhanced to accomodate optional
  mkl> prerequisites.  As you can see, my situation is not a rare one in
  mkl> real life.  Thanks.

Without stating an opinion one way or the other on the concept of an
optional prerequisite, the case made in your email is not, to me,
compelling.

Having a rule like this:

    %.o: %.c %.h

is just not appropriate, unless you have some rule in your development
process that forces every .c to have a .h (and I would think that
process would be broken).  That's not what a pattern rule is for... you
should only put files that MUST exist, or the thing won't work at all,
as prerequisite patterns.

Also, it's almost unheard of that a .c file includes nothing other than
a single .h file, so you'll have to define all the other .h files as
prerequisites anyway... what makes that particular .h file so special
that it deserves a pattern?

You should define the pattern rule with just the bare minimum MANDATORY
prerequisites, then use extra prerequisite definitions to add the
optional ones to the appropriate target.

    %.o : %.c
            ...
    foo.o: foo.h
    bar.o: bar.h

But more likely, as above, you'll have to implement some kind of
automatically generated list of header files, in which case that will
all be done for you.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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