blob: ed2e78877f6f42e1dcd49b22ef74c08e168c5ff1 [file] [log] [blame]
swissChili8cfb7c42021-04-18 21:17:58 -07001# -*- mode:makefile -*-
2
swissChili7a6f5eb2021-04-13 16:46:02 -07003init(lisp, lisp)
4
swissChili8cfb7c42021-04-18 21:17:58 -07005option(PLAT, "`platform to build for: either linux or bluejay'", linux)
6
swissChili2999dd12021-07-02 14:19:53 -07007# preset(optimize)
swissChili7a6f5eb2021-04-13 16:46:02 -07008preset(32)
9preset(debug)
10preset(warn)
swissChili2999dd12021-07-02 14:19:53 -070011preset(nasm)
swissChili7a6f5eb2021-04-13 16:46:02 -070012
swissChili2999dd12021-07-02 14:19:53 -070013archetype(c)
14archetype(asm)
swissChili7a6f5eb2021-04-13 16:46:02 -070015
swissChili6d02af42021-08-05 19:49:01 -070016NO_READLINE ?= 0
17
swissChili53e7cd12021-08-02 21:55:53 -070018CFLAGS += -Ivendor/luajit/dynasm -Werror -lreadline # -fsanitize=address
swissChili7e1393c2021-07-07 12:59:12 -070019LDFLAGS += -lreadline
swissChili2999dd12021-07-02 14:19:53 -070020ASMFLAGS += -felf -Fdwarf
swissChilica107a02021-04-14 12:07:30 -070021
swissChili6d02af42021-08-05 19:49:01 -070022ifeq ($(NO_READLINE),1)
23CFLAGS += -DNO_READLINE
24endif
25
swissChilica107a02021-04-14 12:07:30 -070026OBJECTS = main.o \
27 lisp.o \
swissChilib3ca4fb2021-04-20 10:33:00 -070028 compiler.o \
swissChili53472e82021-05-08 16:06:32 -070029 lib/std.o \
swissChili923b5362021-05-09 20:31:43 -070030 plat/linux.o \
swissChili6d6525e2021-06-15 21:20:53 -070031 istream.o \
swissChili2999dd12021-07-02 14:19:53 -070032 gc.o \
swissChili6d02af42021-08-05 19:49:01 -070033 call_list.o \
34 error.o
swissChili8cfb7c42021-04-18 21:17:58 -070035
swissChilica107a02021-04-14 12:07:30 -070036LUA = vendor/luajit/src/host/minilua
37
swissChili9e57da42021-06-15 22:22:46 -070038$(LUA): vendor/luajit/src/host/minilua.c
swissChilica107a02021-04-14 12:07:30 -070039 status_log(CC, $<)
40 @$(CC) $< -o $@ -lm
41
swissChili9e57da42021-06-15 22:22:46 -070042compiler.c: compiler.dasc | $(LUA)
swissChilica107a02021-04-14 12:07:30 -070043 status_log(DYNASM, $<)
44 @$(LUA) vendor/luajit/dynasm/dynasm.lua -o $@ $<
swissChili7a6f5eb2021-04-13 16:46:02 -070045
46type(executable)
47
swissChili2999dd12021-07-02 14:19:53 -070048F ?= test.lisp
swissChilif68671f2021-07-05 14:14:44 -070049lisp_libpath = $(ROOT)/lib/lisp
swissChili2999dd12021-07-02 14:19:53 -070050
swissChili7a6f5eb2021-04-13 16:46:02 -070051run: lisp
swissChili2999dd12021-07-02 14:19:53 -070052 status_log(LISP, $(F))
swissChilif68671f2021-07-05 14:14:44 -070053 @LISP_LIBRARY_PATH="$(lisp_libpath)" ./lisp $(F)
swissChilibed80922021-04-13 21:58:05 -070054
swissChili708d4c42021-07-04 17:40:07 -070055leak-check: lisp
56 status_log(VALGRIND, lisp $(F))
swissChilif68671f2021-07-05 14:14:44 -070057 @LISP_LIBRARY_PATH="$(lisp_libpath)" valgrind --leak-check=full ./lisp $(F)
swissChili708d4c42021-07-04 17:40:07 -070058
swissChilibed80922021-04-13 21:58:05 -070059format:
60 status_log(FORMAT, *)
swissChili53472e82021-05-08 16:06:32 -070061 @clang-format -i *.c *.h *.dasc plat/* lib/*
swissChili7a6f5eb2021-04-13 16:46:02 -070062
63finish