help-make
[Top][All Lists]
Advanced

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

GNU Make feature request, pattern matching


From: Noah Slater
Subject: GNU Make feature request, pattern matching
Date: Tue, 30 Sep 2008 19:42:42 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

Hello,

Summary: I would like to request a small feature be added to GNU Make

I am currently doing some software for GNU that uses GNU Make to build websites
based on a distributed set of makefiles, a users configuration makefile and a
source directory of files.

Because I do not want the users of my software to have to learn make where not
strictly necessary, my idea was that they could configure the build process by
exporting variables based on pattern rules like this:

  dir/dir/index.html: author = jim bob

When trying to create a set of rules for the distributed makefiles I initially
had the software changing into the output directory to doing something similar 
to this:

  %.html: $(src)/%.txt
      $(info example making html from txt)

The idea being that this would match the following:

  dir/dir/index.html: $(src)/dir/dir/index.txt

I was confused when this didn't work, and from the GNU Make manual we have this:

  "When the target pattern does not contain a slash (and it usually does not),
  directory names in the file names are removed from the file name before it is
  compared with the target prefix and suffix."

So in actual fact, this rule was trying to match:

  dir/dir/index.html: dir/dir/$(src)/index.txt

Which clearly won't work for this specific situation.

The solution to this problem is to use $(CURDIR) everywhere, that way GNU Make
will not activate it's special case directory stripping in the implicit rule.

Unfortunately this means that the user configuration file now looks like:

  $(CURDIR)/dir/dir/index.html: author = jim bob

It works, but it's certainly not ideal. Confusing even.

I have put up a very condensed proof of concept for this here:

  http://bytesexual.org/ephemera/make.tar.gz

Would you consider putting in a command option that would disable this special
case implicit match behaviour?

I had a poke through implicit.c and found what looks to be the right bit of
code, and the change looks like it should be simple enough, but I'm no C
developer so I won't embarrass my self with a patch.

Thanks,

-- 
Noah Slater, http://bytesexual.org/nslater




reply via email to

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