# from https://tech.davis-hansson.com/p/make/
# use bash as the default shell
SHELL := bash
# ensures each Make recipe is ran as one single shell session, rather than one new shell per line
.ONESHELL:
# use bash strict mode. http://redsymbol.net/articles/unofficial-bash-strict-mode/
.SHELLFLAGS := -eu -o pipefail -c
# remove target files when Make file failed
.DELETE_ON_ERROR:
# warning when referring the undefined variables
MAKEFLAGS += --warn-undefined-variables
# disable the builtin rules. Only do what I tell you!
MAKEFLAGS += --no-builtin-rules
ย
# replace tabs
ifeq ($(origin .RECIPEPREFIX), undefined)
ย ย $(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
endif
.RECIPEPREFIX = >
ย
CC ย ย ย := gcc
CFLAGS ย := -Wall -Werror
ifeq ($(mode), debug)
CFLAGS += -g
endif
OS ย ย ย := $(shell uname -s)
LIBS ย ย :=
ifeq ($(OS), Linux)
LIBS += -pthread
endif
ย
SRCS ย ย := all_src_files.c
OBJS ย ย := ${SRCS:c=o}
PROGS ย ย := ${SRCS:.c=}
ย
.PHONY: all clean
# Default - top level rule is what gets ran when you run just `make`
all: ${PROGS}
ย
${PROGS} : % : %.o Makefile
> ${CC} $< -o $@ ${LIBS}
ย
%.o: %.c Makefile
> ${CC} ${CFLAGS} -c $<
ย
# Clean up
clean:
> rm -f ${OBJS}
> rm -f ${PROGS}
Comments
0 B
|๐
/๐
0 B
|๐
/๐
0 B
|๐
/๐
0 B
|๐
/๐
0 B
|๐
/๐