interpret/Makefile

84 lines
2.0 KiB
Makefile
Raw Normal View History

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