GNU Make is a Command Line Interfacetool to build software programs.
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
SHELLis probably best set to Bash.SHELLFLAGScan pass flags to make bash be Strict and fail early..ONESHELLensures 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