aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorYaroslav de la Peña Smirnov <yps@yaroslavps.com>2022-03-24 01:04:02 +0300
committerYaroslav de la Peña Smirnov <yps@yaroslavps.com>2022-03-24 01:04:02 +0300
commit5d66c96a190a396a1535c89bed4e33c2a005fe8d (patch)
tree36a681d8cf226cf30f06b2764c008077d9655dc7 /Makefile
downloadroscha-5d66c96a190a396a1535c89bed4e33c2a005fe8d.tar.gz
roscha-5d66c96a190a396a1535c89bed4e33c2a005fe8d.zip
Initial commit
Basically it works, just needs some polishing and maybe a couple of features that I could actually use. Also probably better docs. Not sure if it will be of use to anybody besides me.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile47
1 files changed, 47 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..2e8c567
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,47 @@
+VERSION=0.1.0
+CC?=gcc
+XFLAGS=
+CFLAGS?=-std=c11 -O2 -Wall $(XFLAGS)
+
+LIBS:=
+IDIRS:=$(addprefix -iquote,include ./)
+
+BUILDIR?=build/release
+
+ifdef DEBUG
+BUILDIR:=build/debug
+CFLAGS:=-std=c11 -O0 -DDEBUG $(XFLAGS) -g
+endif
+ifdef ASAN
+CFLAGS+= -fsanitize=address -fno-omit-frame-pointer
+endif
+
+OBJDIR=$(BUILDIR)/obj
+
+ROSCHA_SRCS:=$(shell find . -name '*.c' -not -path '*/tests/*')
+ROSCHA_OBJS:=$(ROSCHA_SRCS:%.c=$(OBJDIR)/%.o)
+ALL_OBJS:=$(ROSCHA_OBJS)
+TEST_OBJS:=$(filter-out $(OBJDIR)/src/roscha.o,$(ALL_OBJS))
+
+all: roscha
+
+test: tests/slice tests/lexer tests/parser tests/roscha
+
+tests/%: $(OBJDIR)/src/tests/%.o $(TEST_OBJS)
+ mkdir -p $(BUILDIR)/$(@D)
+ $(CC) -o $(BUILDIR)/$@ $^ $(IDIRS) $(LIBS) $(CFLAGS)
+
+$(OBJDIR)/%.o: %.c
+ mkdir -p $(@D)
+ $(CC) -c $(IDIRS) -o $@ $< $(LIBS) $(CFLAGS)
+
+roscha: $(ALL_OBJS)
+ mkdir -p $(@D)
+ $(CC) -o $(BUILDIR)/$@ $^ $(LIBS) $(CFLAGS)
+
+clean:
+ rm -r build
+
+.PHONY: clean all test
+
+.PRECIOUS: $(OBJDIR)/src/tests/%.o