mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
52 lines
1.1 KiB
Makefile
52 lines
1.1 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+=
|
|
|
|
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)
|