You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.0 KiB

optimize := -ffast-math
warnbasic := -Wall -pedantic #-ansi # -std=c99
warnclang := -Wextra -Weverything \
1 year ago
-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?
1 year ago
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
1 year ago
projects := bin/test-text bin/test-kjv bin/test-journal bin/kjv
#docs := $(patsubst test/test_%.c, doc/%.md, $(wildcard test/test_*.c))
1 year ago
default: $(projects)
# success
1 year ago
bin/test-text: build/text.o build/test_text.o
bin/test-kjv: build/text.o build/kjv.o build/test_kjv.o
bin/test-journal: build/text.o build/journal.o build/test_journal.o
bin/kjv: build/text.o build/journal.o build/kjv.o build/scan_kjv.o
1 year ago
bin/%:
@echo "\033[1;36mlinking $@\033[0m"
@mkdir -p bin
1 year ago
$(CC) $(OF) -o $@ $^
build/%.o: src/%.c src/%.h
@echo "\033[0;36mcompile src $@\033[0m"
@mkdir -p build
1 year ago
$(CC) $(CF) -c -o $@ $<
build/%.o: test/%.c
@echo "\033[0;36mcompile test $@\033[0m"
@mkdir -p build
1 year ago
$(CC) $(CF) -c -o $@ $<
build/%.o: build/%.c src/%.h
@echo "\033[0;36mcompile generated $@\033[0m"
1 year ago
$(CC) $(CF) -c -o $@ $<
build/%.c: src/%.re.c
@echo "\033[0;34mhttps://re2c.org/ generate $@\033[0m"
@mkdir -p build
re2c -W --tags --conditions -o $@ $<
1 year ago
#doc/%.md: src/%.h
# # https://github.com/neil-edelman/cdoc documentation
# -cdoc -o $@ $<
.SECONDARY: build/kjv.c build/journal.c build/scan_kjv.c
.PHONY: clean release test
1 year ago
test: $(projects)
@for project in $(projects); do \
echo "\033[1;36m\033[1m*** Testing $$project ***\033[0m" ; \
$$project ; \
done
1 year ago
clean:
-rm -rf bin/ build/
1 year ago
#docs: $(docs)