Appends a Makefile rule to a Makefile

Usage

append_make_rule(makefile, targets, deps = NULL, script = NULL)

Arguments

makefile
A Makefile created by create_makefile
targets
Target names as a character vector
deps
Dependency names as a character vector
script
A script to execute to build the targets.

Value

The first parameter, with the newly created rule appended

Description

This helper function creates a rule and appends it to an existing Makefile. Most useful in pipes.

Examples

library(magrittr) create_makefile() %>% append_make_rule("all", c("first_target", "second_target")) %>% append_make_rule(".FORCE") %>% append_make_rule("first_target", ".FORCE", "echo 'Building first target'") %>% append_make_rule("second_target", "first_target", c("echo 'Building second target'", "echo 'Done'"))
# Generated by MakefileR, do not edit by hand all: first_target second_target .FORCE: first_target: .FORCE echo 'Building first target' second_target: first_target echo 'Building second target' echo 'Done'