I am trying to automate building man
pages in my project with make.
I have the following directory structure:
my_project
man/
man1/
man3/
man5/
man7/
Inside each of those directories, there is one or more .md
files.
I would like to generate *.1
, *.3
, ..., pages when the corresponding man/man{1,3,5,7}/*.md
is updated.
The relevant parts of my Makefile
are:
MY_DOC := $(wildcard $(MY_PROJECT)/man/*/*.md)
all: $(MY_DOC:%.md=%.1)
%.1 %.3 %.5 %.7 : %.md
@ronn --roff $?
The above is building .1
pages as intended, but .3
, .5
and .7
always.
I can see $(MY_DOC:%.md=%.1)
is replacing all .md
with .1
which is one of the problems, but I don't know how to change that to mean 1, 3, 5 or 7 depending on the parent directory.
I was able to build man pages as intended and still use the substitution syntax.
MY_DOC := $(MY_PROJECT)/man
MAN1 := $(wildcard $(MY_DOC)/man1/*.md)
MAN3 := $(wildcard $(MY_DOC)/man3/*.md)
MAN5 := $(wildcard $(MY_DOC)/man5/*.md)
MAN7 := $(wildcard $(MY_DOC)/man7/*.md)
all: $(MAN1:%.md=%.1) $(MAN3:%.md=%.3) $(MAN5:%.md=%.5) $(MAN7:%.md=%.7)
%.1 %.3 %.5 %.7 : %.md
@ronn --roff $?
I think there must be a simpler way to achieve this, but this is the best I was able to come up with.