optimize := -ffast-math warnbasic := -Wall -pedantic #-ansi # -std=c99 warnclang := -Wextra -Weverything \ -Wno-comma \ -Wno-logical-op-parentheses \ -Wno-parentheses \ -Wno-documentation-unknown-command \ -Wno-documentation \ -Wno-shift-op-parentheses \ -Wno-empty-body \ -Wno-padded \ -Wno-switch-enum \ -Wno-missing-noreturn \ -Wno-implicit-fallthrough # https://stackoverflow.com/a/12099167 UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) warnclang += -Wno-poison-system-directories endif # Some stuff is really new, comment out the warnclang? warn := $(warnbasic) $(warnclang) CC := clang # gcc CF := $(optimize) $(warn) OF := ifeq (release, $(firstword $(MAKECMDGOALS))) CF += -funroll-loops -Ofast -D NDEBUG # -O3 OF += -Ofast else CF += -g endif projects := bin/text bin/kjv #docs := $(patsubst test/test_%.c, doc/%.md, $(wildcard test/test_*.c)) default: $(projects) # success bin/text: build/text.o build/test_text.o bin/kjv: build/text.o build/kjv.o bin/%: # linking test $@ @mkdir -p bin $(CC) $(OF) -o $@ $^ build/%.o: src/%.c # compile src $@ @mkdir -p build $(CC) $(CF) -c -o $@ $< build/%.o: test/%.c # compile test $@ @mkdir -p build $(CC) $(CF) -c -o $@ $< build/%.o: build/%.c # compile generated $@ $(CC) $(CF) -c -o $@ $< build/%.c: src/%.re_c.c # https://re2c.org/ generate $@ @mkdir -p build re2c -W --tags --conditions -o $@ $< #doc/%.md: src/%.h # # https://github.com/neil-edelman/cdoc documentation # -cdoc -o $@ $< .PHONY: clean release test test: $(projects) @for project in $(projects); do \ echo "\033[1;36m\033[1m*** Testing $$project ***\033[0m" ; \ $$project ; \ done clean: -rm -rf bin/ build/ #docs: $(docs)