interpret/Makefile

86 lines
2.2 KiB
Makefile
Raw Permalink Normal View History

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 \
2023-02-03 02:13:55 -05:00
-Wno-parentheses \
2022-01-19 20:06:41 -05:00
-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
projects := bin/test-text bin/test-journal bin/test-source bin/test-kjv bin/scan
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-journal: build/text.o build/journal.o build/test_journal.o
2023-04-30 00:29:27 -04:00
bin/test-source: build/text.o build/pair.o build/journal.o build/scan.o build/kjv.o build/test_source.o
bin/test-kjv: build/text.o build/pair.o build/kjv.o build/test_kjv.o
bin/scan: build/text.o build/journal.o build/kjv.o build/pair.o build/scan.o build/driver.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 $@ $^
2023-02-01 03:58:51 -05:00
build/%.o: src/%.c #src/%.h
2022-12-28 17:04:49 -05:00
@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 $@ $<
2023-02-03 02:24:14 -05:00
build/%.o: build/%.c #src/%.h
2022-12-28 17:04:49 -05:00
@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
.SECONDARY: build/kjv.c build/journal.c build/scan.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:
2023-02-03 02:13:55 -05:00
-rm -rf build/
2022-01-19 20:06:41 -05:00
2022-12-27 02:31:08 -05:00
#docs: $(docs)