GNU Make is a Command Line Interfacetool to build software programs.

Good tutorial

Sample Makefile

PROGRAM_NAME=myprog
CC=gcc
SRC := naive
BIN := bin

CSRC := $(wildcard $(SRC)/*.c)
BINS := $(patsubst $(SRC)/%.c, $(BIN)/%, $(CSRC))

all: $(BINS)

$(BIN)/%: $(SRC)/%.c
    $(CC) $(CC_FLAGS) -o $@ $< 

run:
    ./$(BIN)/${PROGRAM_NAME}

clean:
    -@ $(RM) $(BINS)

Setting Shell

  • SHELL is probably best set to Bash
  • .SHELLFLAGS can pass flags to make bash be Strict and fail early.
  • .ONESHELL ensures everything is run in one shell session, rather

than new shell per line. Can do loops and variable assignments.

SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c