NMAKE pattern rules are a lot like GNU make old-school suffix rules. In your case, you had it almost right to begin with, but you were missing the .SUFFIXES declaration. For example:
.SUFFIXES: .bmml .png
.bmml.png:
@echo Building $@ from $<
I think this is only part of your solution though, because you also mentioned wanting to avoid explicitly listing all of the files to be converted. Unfortunately, I don't know of a very clean way to do that in NMAKE, since it only expands wildcards in dependency lists, and what you really want in your dependency list is not the list of files that already exist (the *.bmml files), but the list of files that will be created from those files (the *.png files). Nevertheless, I think you can achieve your goal with a recursive NMAKE invocation like this:
all: *.bmml
$(MAKE) $(**:.bmml=.png)
Here, NMAKE will expand *.bmml
in the prereq list for all
into the list of .bmml files in the directory, and then it will start a new NMAKE instance, specifying the goals to build as that list of files with all instances of .bmml
replaced by .png
. So, putting it all together:
.SUFFIXES: .bmml .png
all: *.bmml
@echo Converting $(**) to .png...
@$(MAKE) $(**:.bmml=.png)
.bmml.png:
@echo Building $@ from $<
If I create files Test1.bmml and Test2.bmml and then run this makefile, I get the following output:
Converting Test1.bmml Test2.bmml to .png...
Building Test1.png from Test1.bmml
Building Test2.png from Test2.bmml
Of course, if you have very many of these .bmml files, you may run afoul of command-line length limitations, so watch out for that. In that case, I recommend either explicitly listing the source files, or using a more capable make tool, like GNU make (which is available for Windows in a variety of forms).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…