2021-12-25 14:06:20 +01:00
|
|
|
ifneq ($(OS),Windows_NT)
|
2021-12-25 22:32:16 +01:00
|
|
|
CPPFLAGS = -D_POSIX_C_SOURCE=200112L
|
2021-12-25 14:06:20 +01:00
|
|
|
endif
|
2021-12-25 22:32:16 +01:00
|
|
|
CFLAGS = -ggdb -std=c11 -Wall -Wextra -pedantic -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition
|
|
|
|
#CFLAGS = -pg -std=c11 -Wall -Wextra -pedantic -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition
|
|
|
|
#CFLAGS = -O3 -std=c11 -Wall -Wextra -pedantic -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition
|
2021-12-21 01:18:22 +01:00
|
|
|
LDFLAGS = -lm
|
|
|
|
SOURCE = main.c util.c tok.c lex.c ir.c parse.c runtime.c vm.c map.c
|
|
|
|
HEADERS = util.h tok.h lex.h ir.h parse.h runtime.h vm.h map.h
|
|
|
|
EXE = main
|
|
|
|
|
|
|
|
OBJ = $(SOURCE:.c=.o)
|
|
|
|
|
|
|
|
$(EXE): $(OBJ)
|
|
|
|
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
|
|
|
|
|
|
|
|
%.o: %.c
|
2021-12-25 22:32:16 +01:00
|
|
|
$(CC) -c -o $@ $< $(CPPFLAGS) $(CFLAGS)
|
2021-12-21 01:18:22 +01:00
|
|
|
|
|
|
|
deps.mk: $(SOURCE) $(HEADERS)
|
|
|
|
@echo "# Automatically generated by $(CC) -MM." > $@
|
|
|
|
$(CC) -MM $(SOURCE) >> $@
|
|
|
|
|
|
|
|
map_test: map_test.c util.c map.c
|
|
|
|
$(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
|
|
|
|
|
|
|
|
run_map_test: map_test
|
|
|
|
valgrind ./map_test
|
|
|
|
|
2021-12-21 11:40:49 +01:00
|
|
|
pool_test: pool_test.c util.c
|
|
|
|
$(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
|
|
|
|
|
|
|
|
run_pool_test: pool_test
|
|
|
|
valgrind ./pool_test
|
|
|
|
|
2021-12-21 01:18:22 +01:00
|
|
|
.PHONY: clean
|
|
|
|
|
|
|
|
clean:
|
2021-12-21 11:40:49 +01:00
|
|
|
rm -f $(OBJ) $(EXE) deps.mk gmon.out map_test pool_test
|
2021-12-21 01:18:22 +01:00
|
|
|
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
|
|
include deps.mk
|
|
|
|
endif
|