From c035571d85e3d756804519d82de8b354f3910b29 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Thu, 8 Feb 2024 21:19:38 +0200 Subject: project work phase 1 --- scripts/makefile | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 scripts/makefile (limited to 'scripts/makefile') diff --git a/scripts/makefile b/scripts/makefile new file mode 100644 index 0000000..fc1eb58 --- /dev/null +++ b/scripts/makefile @@ -0,0 +1,57 @@ +# this could be done better +RELEASE ?= 0 +OPTFLAGS != [ "$(RELEASE)" != "0" ] \ + && echo "-O2 -flto" \ + || echo "-O0" + +DEBUG ?= 1 +DEBUGFLAGS != [ "$(DEBUG)" != "0" ] \ + && echo "-DDEBUG=1" \ + || echo "-DNDEBUG=1" + +ASSERT ?= 1 +ASSERTFLAGS != [ "$(ASSERT)" != "0" ] \ + && echo "-DASSERT=1" \ + || echo + +DEPFLAGS = -MT $@ -MMD -MP -MF $@.d +LINTFLAGS = -fsyntax-only +PREPROCESS = -E + +BUILD = build + +all: posthaste + + +OBFLAGS = -g +WARNFLAGS = -Wall -Wextra -Wvla + +COMPILE_FLAGS = $(CFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(OBFLAGS) $(ASSERTFLAGS) \ + $(DEBUGFLAGS) + +LINK_FLAGS = $(LDFLAGS) + +INCLUDE_FLAGS = -I include + +COMPILE = $(CC) \ + $(COMPILE_FLAGS) $(DEPFLAGS) $(INCLUDE_FLAGS) + +LINT = $(CC) \ + $(COMPILE_FLAGS) $(LINTFLAGS) $(INCLUDE_FLAGS) + +COMPILE_POSTHASTE = $(COMPILE) + +-include deps.mk + +gen/gen_parser.c: src/parser.y gen/gen_lexer.inc + bison -Wcounterexamples -o gen/gen_parser.c src/parser.y + +gen/gen_lexer.inc: src/lexer.l + flex -o gen/gen_lexer.inc src/lexer.l + +posthaste: $(POSTHASTE_OBJS) + $(COMPILE_POSTHASTE) $(POSTHASTE_OBJS) -o $@ + +# might lint some common things twice +.PHONY: +lint: $(POSTHASTE_LINTS) -- cgit v1.2.3