Other Custom rules in BSD Makefiles

Holger

New Member

Reaction score: 13
Messages: 14

Hi!

I am looking for a way to create custom build rules in BSD makefiles, but did not find anything besides the common .c.o pattern. Here is my use-case:

I would like to create an .html file out of an .htmlm4 file using the the m4(1) macro processor. I am using a Makefile along the following lines:
Code:
.htmlm4.html:
    @echo "Input: $<"
    @echo "Target: $@"
    #m4 $< > $@

index.html: index.htmlm4
When running make(1), the output is the following:
Code:
Input: 
Target: .htmlm4.html
This is not what I expected. I expected:
Code:
Input: index.htmlm4
Target: index.html
How can I fix this?
 

ljboiler

Well-Known Member

Reaction score: 160
Messages: 440

You need to add a .SUFFIXES line that defines the files suffixes that you use in the suffix-transformation definition, like this:
Code:
.SUFFIXES: .html .htmlm4

.htmlm4.html:
    @echo ...
    ...
 
Top