interpret/Makefile

84 lines
2.0 KiB
Makefile
Raw Normal View History

2022-02-11 04:30:11 +00:00
optimize := -ffast-math
2022-12-27 07:31:08 +00:00
warnbasic := -Wall -pedantic #-ansi # -std=c99
warnclang := -Wextra -Weverything \
2022-01-20 01:06:41 +00:00
-Wno-comma \
-Wno-logical-op-parentheses \
-Wno-parentheses \
-Wno-documentation-unknown-command \
-Wno-documentation \
-Wno-shift-op-parentheses \
-Wno-empty-body \
-Wno-padded \
2022-02-11 04:30:11 +00:00
-Wno-switch-enum \
2022-12-27 07:31:08 +00:00
-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?
2022-01-20 01:06:41 +00:00
warn := $(warnbasic) $(warnclang)
CC := clang # gcc
2022-12-27 07:31:08 +00:00
CF := $(optimize) $(warn)
OF :=
2022-02-11 04:30:11 +00:00
ifeq (release, $(firstword $(MAKECMDGOALS)))
CF += -funroll-loops -Ofast -D NDEBUG # -O3
OF += -Ofast
else
CF += -g
endif
2022-01-20 01:06:41 +00:00
2022-12-28 22:04:49 +00:00
projects := bin/test-text bin/test-kjv bin/test-journal bin/interpret
2022-12-27 07:31:08 +00:00
#docs := $(patsubst test/test_%.c, doc/%.md, $(wildcard test/test_*.c))
2022-01-20 01:06:41 +00:00
2022-12-27 07:31:08 +00:00
default: $(projects)
# success
2022-01-20 01:06:41 +00:00
2022-12-27 23:19:10 +00:00
bin/test-text: build/test_text.o build/text.o
bin/test-kjv: build/test_kjv.o build/text.o build/kjv.o
2022-12-28 04:45:57 +00:00
bin/test-journal: build/test_journal.o build/text.o build/journal.o
2022-12-28 22:04:49 +00:00
bin/interpret: build/interpret.o build/scan.o build/journal.o build/kjv.o build/text.o
2022-01-20 01:06:41 +00:00
2022-12-27 07:31:08 +00:00
bin/%:
2022-12-28 22:04:49 +00:00
@echo "\033[1;36mlinking $@\033[0m"
2022-12-27 07:31:08 +00:00
@mkdir -p bin
2022-01-20 01:06:41 +00:00
$(CC) $(OF) -o $@ $^
2022-12-28 22:04:49 +00:00
build/%.o: src/%.c src/%.h
@echo "\033[0;36mcompile src $@\033[0m"
2022-12-27 07:31:08 +00:00
@mkdir -p build
2022-01-20 01:06:41 +00:00
$(CC) $(CF) -c -o $@ $<
2022-12-27 07:31:08 +00:00
build/%.o: test/%.c
2022-12-28 22:04:49 +00:00
@echo "\033[0;36mcompile test $@\033[0m"
2022-12-27 07:31:08 +00:00
@mkdir -p build
2022-01-20 01:06:41 +00:00
$(CC) $(CF) -c -o $@ $<
2022-12-28 22:04:49 +00:00
build/%.o: build/%.c src/%.h
@echo "\033[0;36mcompile generated $@\033[0m"
2022-01-20 01:06:41 +00:00
$(CC) $(CF) -c -o $@ $<
2022-12-27 23:19:10 +00:00
build/%.c: src/%.re.c
2022-12-28 22:04:49 +00:00
@echo "\033[0;34mhttps://re2c.org/ generate $@\033[0m"
2022-12-27 07:31:08 +00:00
@mkdir -p build
re2c -W --tags --conditions -o $@ $<
2022-01-20 01:06:41 +00:00
2022-12-27 07:31:08 +00:00
#doc/%.md: src/%.h
# # https://github.com/neil-edelman/cdoc documentation
# -cdoc -o $@ $<
2022-02-11 04:30:11 +00:00
2022-12-28 22:04:49 +00:00
.SECONDARY: build/kjv.c build/journal.c build/scan.c
2022-12-27 07:31:08 +00:00
.PHONY: clean release test
2022-01-20 01:06:41 +00:00
2022-12-27 07:31:08 +00:00
test: $(projects)
@for project in $(projects); do \
echo "\033[1;36m\033[1m*** Testing $$project ***\033[0m" ; \
$$project ; \
done
2022-01-20 01:06:41 +00:00
clean:
2022-12-27 07:31:08 +00:00
-rm -rf bin/ build/
2022-01-20 01:06:41 +00:00
2022-12-27 07:31:08 +00:00
#docs: $(docs)