Files
Toy/test/makefile
2022-11-26 09:43:19 +00:00

58 lines
1.3 KiB
Makefile

CC=gcc
IDIR +=. ../source ../repl
CFLAGS +=$(addprefix -I,$(IDIR)) -g -Wall -W -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable
LIBS +=
ODIR = obj
#TARGETS = $(wildcard ../source/*.c) $(wildcard ../repl/lib_*.c)
#literal primitives
TARGETS+=../source/memory.c ../source/refstring.c ../source/literal.c ../source/literal_array.c ../source/literal_dictionary.c ../source/scope.c
#lexer
TARGETS+=../source/toy_common.c ../source/keyword_types.c ../source/lexer.c
#ast primitives
TARGETS+=../source/ast_node.c
#parser
TARGETS+=../source/parser.c
#compiler
TARGETS+=../source/compiler.c
#interpreter
TARGETS+=../source/interpreter.c ../source/builtin.c
TESTS = $(wildcard test_*.c)
OBJ = $(addprefix $(ODIR)/,$(TARGETS:../source/%.c=%.o)) $(addprefix $(ODIR)/,$(TESTS:.c=.o))
.PRECIOUS: $(TESTS:%.c=../$(TOY_OUTDIR)/%.exe)
all: $(OBJ) $(TESTS:%.c=../$(TOY_OUTDIR)/%.exe)
../$(TOY_OUTDIR)/%.exe: $(ODIR)/%.o
@$(CC) -o $@ $< $(TARGETS:../source/%.c=$(ODIR)/%.o) $(CFLAGS) $(LIBS)
ifeq ($(shell uname),Linux)
valgrind --leak-check=full --track-origins=yes $@
else
$@
endif
$(OBJ): | $(ODIR)
$(ODIR):
mkdir $(ODIR)
$(ODIR)/%.o: %.c
@$(CC) -c -o $@ $< $(CFLAGS)
$(ODIR)/%.o: ../source/%.c
@$(CC) -c -o $@ $< $(CFLAGS)
.PHONY: clean
clean:
$(RM) $(ODIR)