Monday, September 03, 2018

Re: make(1) and multiple outputs

On Fri, Aug 31, 2018 at 09:23:33AM +0200, Kristaps Dzonsons wrote:
> Short: is there a way to manage multiple outputs from a single command
> with OpenBSD's make(1)?
>
> Longer story. I have a site that generates a few hundred articles using
> sblg(1). Each output article is indexNNN.html, which depends upon every
> input indexNNN.xml. So a change to any indexNNN.xml must result in
> rebuilding all indexNNN.html using a single command.
>
> In GNU make, I can use the pattern substring match to effect this:
>
> all: index001.html index002.html
>
> index001%html index002%html: index001.xml index002.xml
> sblg -L index001.xml index002.xml
>

Our make is perfectly happy generating several targets with one rule.

The only thing we're actually missing wrt % is suffixes rules with multiple
results.

See any Makefile that generates .h and .c file from .y, for instance
lib/libkeynote/Makefile

a line like:

k.tab.c k.tab.h: keynote.y keynote.h signature.h
$(YACC.y) $(YACCFLAGS) ${.CURDIR}/keynote.y

looks exactly like what you want.

If you need to generate a fairly long list, .for loops and variables ought
to help you...

No comments:

Post a Comment