Tup has both kinds of rules: country, and western! Err, ':' and ','. The ':' rules specify input files, a command to run, and output files. The ',' rules just specify an input and output file, and are automatically sed'd for @-variable substitution. Usually you just use ':' rules, unless you are replacing some silly autoconf thing.
A rule looks like this:
: [options] [input list] [ | order-only list] |> [command] |> [output list]
Field | What it is |
options | Any options to the rule. Currently there is only one option, which is 'foreach'. Basically, if you want to run one command for each input file, you type 'foreach' here. If you want to run one command using all the input files at once, you don't. |
input list | Files that you want to input. These are the files that get replaced into %f/%b style variables. You can read files from other directories (like foo/bar.c, or ../ok.c). You can also wildcard filenames (like foo/*.c). I think if you try to wildcard directory names it will explode (ex: */*.c == explode). |
order-only list | This is a list of files that you want to have as dependencies to the command, but you don't want to list in %f. An example of this might be an auto-generated header. After you list your C files, you would put a bar '|' and then list the auto-generated headers. This way you will not generate a rule to try to compile the header, but it will still link to the command in the DAG. |
command | This is what you would type in at the command-line to do stuff. Except any variables are replaced before the command is stored in the database. And it's not a command-line. It's a Tupfile. |
output list | This is the list of files that are created from the command. A rule can only create files in its own directory at the moment, and probably for the foreseeable future. You'll get yelled at if you try to do otherwise. This is because it would be silly to have a Tupfile in directory A which inputs files from directory B and outputs files in directory C. If I try to have another Tupfile use input from directory C, how would I know I have to parse the Tupfile in directory A first? Surely you see the dilemma. Long story short, if you input files from other directories, or even if you don't, you probably want to use some variant of the %b or %B flag here, unless you just specify the output explicitly. |
A sed rule can be used to replace files with static configuration-type variables. Depending on your use of compile-time configuration options, you may or may not find them useful. If you are setting some @-variables and want to put their values in a file, you would use them. The rule structure looks like:
, [input list] |> [output list]
Actually I don't know that it works probably with multiple files, but I think you could do something like:
, *.h.in |> %F
At least, it should work. I simply cannot be bothered to try it, though.