makefile

Back

Learnings

Auto Linking programs

main: a.o b.o

RECIPEPREFIX

By default Makefiles are with tabs. The RECIPEPREFIX can be used to change it

ifeq ($(origin .RECIPEPREFIX), undefined)
  $(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
endif
.RECIPEPREFIX = >

build:
> npm install
> npm build

DELETE_ON_ERROR

If the Make rule fails, it’s target file is destroyed

.DELETE_ON_ERROR:
.RECIPEPREFIX = >

build:
> npm install
> npm build

ONESHELL

Makes the recipe is run as one single shell session, rather than one new shell per line

.ONESHELL:
.RECIPEPREFIX = >

build:
> npm install
> npm build

Makeflags

MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules

References