3
votes

I have a bit of file processing to do in Automake and can't figure out how to do it correctly (using either automake rules of gnu make extensions). For example, I have a file called refName.in and wish to produce the output refName.out. I have two relevant command-lines:

produce-out refName.in refName.out
produce-deps refName.in

The first simply takes the input file and produces the output. The second provides a list of dependencies for the file.

What am I supposed to do in Automake to get this setup working? I wish to have full dependency tracking, such that if any file in the list produced by produce-deps will trigger produce-out to be called.

(NOTE: I have no problem changing how these commands work. One command can produce the output and dependencies if needed. Different command-line switches, etc. can also be modified.)

(PS: If need be a GNU make extension is totally okay. I already use patterned rules in the Makefile.am and other extensions.)

1

1 Answers

3
votes

The only automake specific thing you need for this is to add the built file to BUILT_SOURCES:

BUILT_SOURCES := refName.out

# You might well want refName.in in EXTRA_DIST
EXTRA_DIST := refName.in

# then any standard Make rules will do:
refName.out: refName.in $(shell produce-deps refName.in)
        produce-out refName.in refName.out

If you want a more sophisticated way of doing the dependencies you can use these rules with GNU make's include, which will only cause produce-deps to be run when refName.deps is missing or refName.in changes:

refName.deps: refName.in
        echo 'ref-deps := "' $(shell produce-deps refName.in) '"' > refName.deps

include refName.deps

refName.out: refName.in $(ref-deps)
        produce-out refName.in refName.out

You can make these rules generic with the usual GNU make % rules.