85 lines
2.1 KiB
Makefile
85 lines
2.1 KiB
Makefile
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/test-text bin/test-kjv bin/test-journal bin/kjv bin/flight
|
|
#docs := $(patsubst test/test_%.c, doc/%.md, $(wildcard test/test_*.c))
|
|
|
|
default: $(projects)
|
|
# success
|
|
|
|
bin/test-text: build/text.o build/test_text.o
|
|
bin/test-journal: build/text.o build/journal.o build/test_journal.o
|
|
bin/test-kjv: build/text.o build/kjv.o build/test_kjv.o
|
|
bin/kjv: build/text.o build/journal.o build/kjv.o build/scan_kjv.o
|
|
bin/flight: build/text.o build/journal.o build/flight.o build/driver_flighthours.o
|
|
|
|
bin/%:
|
|
@echo "\033[1;36mlinking $@\033[0m"
|
|
@mkdir -p bin
|
|
$(CC) $(OF) -o $@ $^
|
|
|
|
build/%.o: src/%.c #src/%.h
|
|
@echo "\033[0;36mcompile src $@\033[0m"
|
|
@mkdir -p build
|
|
$(CC) $(CF) -c -o $@ $<
|
|
|
|
build/%.o: test/%.c
|
|
@echo "\033[0;36mcompile test $@\033[0m"
|
|
@mkdir -p build
|
|
$(CC) $(CF) -c -o $@ $<
|
|
|
|
build/%.o: build/%.c src/%.h
|
|
@echo "\033[0;36mcompile generated $@\033[0m"
|
|
$(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 $@ $<
|
|
|
|
#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
|
|
|
|
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)
|