make_rule: Creates a Makefile rule

Description Usage Arguments Details Value References See Also Examples

Description

A rule in a Makefile consists of a (list of) targets which may depend on one or more dependencies each. Optionally, a script is executed to create the target. Generally, multiple targets mean that the rule is identical for each of the individual targets, and multiple dependencies mean that all of them are required to build each of the targets. In the script, the target can be referenced by $@, and the first dependency can be referenced by $<. Note that the dollar sign has a special meaning in a Makefile, use $$ in scripts that need to use the dollar sign themselves.

Usage

1
make_rule(targets, deps = NULL, script = NULL)

Arguments

targets

[character]
Target names

deps

[character]
Dependency names

script

[character]
A script to execute to build the targets.

Details

Use the c function or the + operator to append rules to groups and Makefiles.

Value

An object of class MakefileR_rule

References

https://www.gnu.org/software/make/manual/

See Also

makefile

Other items: make_comment, make_def, make_group, make_text

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
make_rule("all", c("first_target", "second_target"))
make_rule(".FORCE")
make_rule("first_target", ".FORCE", "echo 'Building first target'")
make_rule("second_target", "first_target",
 c("echo 'Building second target'", "echo 'Done'"))

makefile() +
  make_rule("all", c("first_target", "second_target")) +
  make_rule(".FORCE") +
  make_rule("first_target", ".FORCE", "echo 'Building first target'") +
  make_rule("second_target", "first_target",
    c("echo 'Building second target'", "echo 'Done'"))

MakefileR documentation built on May 1, 2019, 10:30 p.m.