Updated: 11.10.2022

Here are some references to start using makefile. It makes automation easily by just running make. Nevertheless, some Apps need to be installed if running in Windows. The easiest way to install Apps is to use scoop to install make and additionally with sed.

Here is an example of my Makefile for R package.

PKGNAME = $(shell sed -n "s/Package: *\([^ ]*\)/\1/p" DESCRIPTION)
PKGVERS = $(shell sed -n "s/Version: *\([^ ]*\)/\1/p" DESCRIPTION)


all: check

build: install_deps
    R CMD build .

check: build
    R CMD check --no-manual $(PKGNAME)_$(PKGVERS).tar.gz

install_deps:
    Rscript \
    -e 'if (!requireNamespace("remotes")) install.packages("remotes")' \
    -e 'remotes::install_deps(dependencies = TRUE)'

install: build
    R CMD INSTALL $(PKGNAME)_$(PKGVERS).tar.gz

clean:
    @rm -rf $(PKGNAME)_$(PKGVERS).tar.gz $(PKGNAME).Rcheck
comments powered by Disqus