Search code examples
nmake

Why does nmake ignore my implicit rule?


I need a little nmake makefile for my build process. The file types are TXT and PDF. Therefore I added a inference rule to my makfile. But nmake ignores it completely. What's wrong?

Number=123
Targets=A-$(Number).pdf B-$(Number).pdf
Sources=$(Targets:pdf=txt)

.txt.pdf:
    copy $*.txt $*.pdf

all: test build

#this rule creates sample source files
setup:
    echo hungry > A-$(Number).txt
    echo thursty > B-$(Number).txt

#this rule checks the generated macros
test:
    @echo Sources: $(Sources)
    @echo Targets: $(Targets)
    dir /b $(Sources)

build: $(Targets)

All I get with this nmake Makefile is:

NMAKE : fatal error U1073: don't know how to make 'A-123.pdf'

Solution

  • I think that for ".txt.pdf:" to be recognized as an implicit rule, both extensions have to be in the list of suffixes. Try adding

    .SUFFIXES: .txt .pdf