General and specific make questions

Chuck Robey chuckr at telenix.org
Mon Jun 8 17:58:39 UTC 2009


Lars Eighner wrote:
> 
> What I need most is to find (a) make tutorial(s) that do not suppose
> make is
> being used for compling c/c++ programs.  Yes, I know, that is mostly why
> make exists, but many tutorials plunge right into C examples with
> implicit C
> rules, while -- it seems to me -- make could be much more useful for a
> variety of things, and I could sure use more of the general and arbitrary
> examples.
> 
> Second, it appears to me that the pmake document in the books section of
> the
> documentation is not longer in sync with make as actually installed in
> FreeBSD 7.x.  In particular, the pmake doc refers to switches which make no
> longer recognizes and which do not have clear replacements in man make.
> 
> Now for my particular question.
> 
> I have some sources which may or may not exist.  My target should be
> rebuilt
> if a source exists that is younger than the target.  But sources that do
> not exist should be ignored and make should not be perplexed over how to
> create them.  How do I express that kind of relationship?
> 

OK, first, about those docs in /usr/share/doc/{psd|smm|usd|others}, they all
come from the original papers written by the CSRG folks well before FreeBSD was
created.  They are somewhat useful, so for that (and sheer historical interest)
they're kept around, but they aren't updated.  If you wanted to see updated
stuff, try the man page, which is both constantly updated and complete in it's
coverage.

OK, for your "particular question", it's honestly not real clear what you're
asking ... are you asking how to tell make NOT to make something?  I'll make a
guess here, and lay the guess out for you to comment on, maybe asking you to
reconsider your question might have the side effect of making the answer be
obvious?  Anyhow, maybe you have a target that has a dependency listed for it,
but make(1) doesn't have rules on how to remake that dependency, and either
make(1) can't find it, or does find it, but finds that the time stamps of that
dependency shows it has to be remade.  One easy way to fix that would be to do a
"touch" (read the man page on touch for info) that dependency, which should
cause make(1) to lose interest in rebuilding it.  I couldn't get more exact
without having a better idea of what's happening.

Oh, BTW, about applications of make for other than C progs.  Using make(1) to
compile other things, like maybe python progs, or whatever, is fairly obvious
that it can be handled just like the C progs.  Yes, you CAN use make(1) for
non-compilation tasks, but I've never seen any documentation for that beyond the
make(1) man page.  In fact, the only example of doing that which  I've even seen
was helping NIS to maintain itself.  Two things about make(1): first, it's very
widely terrified programmers, but (secondly) it's really not all that complex,
so it's actually frightening everyone based upon it's reputation.  Well, that,
and the one truly poor makefile I've ever seen, that one defaulted to by all of
the autoconf tools (the gcc Makefile is an example of this, it's too bad to be
described without using foul language).  It doesn't have to be that way, but it
does a fine job of scaring everyone away from make(1).


More information about the freebsd-questions mailing list