summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-02-01 08:31:01 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2018-02-12 03:34:18 +0200
commitf54e7e8c2aeb4fafebf0d5bd5570b060462c9ecf (patch)
treeb3bcc7ca21cda7d655bfcc0d9ec26d4a6668f27f /Makefile
Initial commit
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile43
1 files changed, 43 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..0e133f0
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,43 @@
+PREFIX ?= /usr/local
+BINDIR ?= /bin
+
+MAKEFLAGS += --no-builtin-rules
+
+# GCC 7: -Wstringop-overflow=, -Walloc-size-larger-than=, -Wduplicated-{branches,cond}
+WARNINGS := -Wall -Wextra -Wpedantic -Wformat=2 -Wstrict-aliasing=3 -Wstrict-overflow=3 -Wstack-usage=12500 \
+ -Wfloat-equal -Wcast-align -Wpointer-arith -Wchar-subscripts -Warray-bounds=2
+
+override CFLAGS ?= -g
+override CFLAGS += -std=c11 $(WARNINGS)
+override CPPFLAGS += -Isrc
+
+bins = escpos2raster starpbm
+all: $(bins)
+
+%.c: %.rl
+ ragel $^
+
+%.a:
+ $(LINK.c) -c $(filter %.c,$^) $(LDLIBS) -o $@
+
+$(bins): %:
+ $(LINK.c) $(filter %.c %.a,$^) $(LDLIBS) -o $@
+
+escpos-membuf.a: src/escpos/memory.h src/util/membuf.h src/util/membuf.c
+escpos-ragel.a: src/util/ragel/ragel.h src/util/ragel/ragel.c
+escpos-stack.a: src/escpos/stack.h src/escpos/stack.c
+escpos-parser.a: src/escpos/parser.h src/escpos/parser.c
+escpos2raster: src/bin/escpos2raster.c escpos-membuf.a escpos-ragel.a escpos-stack.a escpos-parser.a
+
+starpbm: src/bin/starpbm.c
+
+install-bin: $(bins)
+ install -Dm755 $^ -t "$(DESTDIR)$(PREFIX)$(BINDIR)"
+
+install: install-bin
+
+clean:
+ $(RM) src/util/ragel/ragel.c src/escpos/stack.c src/escpos/parser.c
+ $(RM) $(bins) *.a
+
+.PHONY: all clean install