interpret/Makefile

87 lines
2.4 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 \
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
2023-02-03 14:50:10 -05:00
projects := bin/test-text bin/test-journal bin/test-source bin/test-kjv bin/kjv bin/flight
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-02-03 14:50:10 -05:00
bin/test-source: build/text.o build/pair.o build/journal.o build/source.o build/test_source.o
2023-03-15 01:02:22 -04:00
bin/test-kjv: build/text.o build/pair.o build/kjvcount.o build/test_kjv.o
2023-03-15 23:10:12 -04:00
bin/kjv: build/text.o build/pair.o build/journal.o build/kjvcount.o build/kjv.o build/source.o
2023-03-15 01:02:22 -04:00
bin/flight: build/text.o build/pair.o build/journal.o build/source.o build/flights.o build/flighthours.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
2023-03-15 23:10:12 -04:00
.SECONDARY: build/kjv.c build/journal.c build/source.c build/scan_kjv.c build/flight.c build/kjvcount.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)