aboutsummaryrefslogtreecommitdiff
path: root/scripts/makefile
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-02-08 21:19:38 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2024-02-08 21:19:38 +0200
commitc035571d85e3d756804519d82de8b354f3910b29 (patch)
tree89714e13753d200d6e9a04f0d19d6dd1f7a55b2e /scripts/makefile
downloadposthaste-c035571d85e3d756804519d82de8b354f3910b29.tar.gz
posthaste-c035571d85e3d756804519d82de8b354f3910b29.zip
project work phase 1
Diffstat (limited to 'scripts/makefile')
-rw-r--r--scripts/makefile57
1 files changed, 57 insertions, 0 deletions
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)