diff options
author | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2022-01-20 02:34:32 +0300 |
---|---|---|
committer | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2022-01-20 02:34:32 +0300 |
commit | c0cd4e5f199e8567ec3b5e216fbee27837d21bea (patch) | |
tree | c78eee02932fc6e85413e367d27ec5b5627e1534 /Makefile | |
download | cmonkey-c0cd4e5f199e8567ec3b5e216fbee27837d21bea.tar.gz cmonkey-c0cd4e5f199e8567ec3b5e216fbee27837d21bea.zip |
init
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..60481b3 --- /dev/null +++ b/Makefile @@ -0,0 +1,46 @@ +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 + +CMONKEY_SRCS:=$(shell find src -name '*.c' -not -path '*/tests/*') +CMONKEY_OBJS:=$(CMONKEY_SRCS:%.c=$(OBJDIR)/%.o) +ALL_OBJS:=$(CMONKEY_OBJS) +TEST_OBJS:=$(filter-out $(OBJDIR)/src/cmonkey.o,$(ALL_OBJS)) + +all: cmonkey + +test: tests/lexer tests/slice tests/parser tests/ast tests/eval + +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) + +cmonkey: $(ALL_OBJS) + mkdir -p $(@D) + $(CC) -o $(BUILDIR)/$@ $^ $(LIBS) $(CFLAGS) + +clean: + rm -r build + +.PHONY: clean all test + +.PRECIOUS: $(OBJDIR)/src/tests/%.o |