CC = gcc CCFLAGS = -Wall BUILDDIR = build SRCS = pureoption-example.c pureoption.c OBJS = $(addprefix $(BUILDDIR)/, $(patsubst %.c,%.o,$(SRCS))) OUT = pureoption-example .PHONY: all format clean .PRECIOUS: $(BUILDDIR)/. $(BUILDDIR)%/. all: $(OUT) debug: CCFLAGS += -g debug: all $(BUILDDIR)/.: mkdir -p $@ $(BUILDDIR)%/.: mkdir -p $@ $(OUT): $(OBJS) $(CC) $^ -o $(OUT) $(LDFLAGS) .SECONDEXPANSION: $(BUILDDIR)/%.o: %.c | $$(@D)/. $(CC) $(CCFLAGS) -c $< -o $@ format: clang-format -i *.c *.h clean: rm -rf $(BUILDDIR) rm -f $(OUT)