swissChili | 8cfb7c4 | 2021-04-18 21:17:58 -0700 | [diff] [blame] | 1 | # -*- mode:makefile -*- |
2 | |||||
swissChili | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 3 | init(lisp, lisp) |
4 | |||||
swissChili | 8cfb7c4 | 2021-04-18 21:17:58 -0700 | [diff] [blame] | 5 | option(PLAT, "`platform to build for: either linux or bluejay'", linux) |
6 | |||||
swissChili | 2999dd1 | 2021-07-02 14:19:53 -0700 | [diff] [blame] | 7 | # preset(optimize) |
swissChili | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 8 | preset(32) |
9 | preset(debug) | ||||
10 | preset(warn) | ||||
swissChili | 2999dd1 | 2021-07-02 14:19:53 -0700 | [diff] [blame] | 11 | preset(nasm) |
swissChili | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 12 | |
swissChili | 2999dd1 | 2021-07-02 14:19:53 -0700 | [diff] [blame] | 13 | archetype(c) |
14 | archetype(asm) | ||||
swissChili | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 15 | |
swissChili | 53e7cd1 | 2021-08-02 21:55:53 -0700 | [diff] [blame] | 16 | CFLAGS += -Ivendor/luajit/dynasm -Werror -lreadline # -fsanitize=address |
swissChili | 7e1393c | 2021-07-07 12:59:12 -0700 | [diff] [blame] | 17 | LDFLAGS += -lreadline |
swissChili | 2999dd1 | 2021-07-02 14:19:53 -0700 | [diff] [blame] | 18 | ASMFLAGS += -felf -Fdwarf |
swissChili | ca107a0 | 2021-04-14 12:07:30 -0700 | [diff] [blame] | 19 | |
20 | OBJECTS = main.o \ | ||||
21 | lisp.o \ | ||||
swissChili | b3ca4fb | 2021-04-20 10:33:00 -0700 | [diff] [blame] | 22 | compiler.o \ |
swissChili | 53472e8 | 2021-05-08 16:06:32 -0700 | [diff] [blame] | 23 | lib/std.o \ |
swissChili | 923b536 | 2021-05-09 20:31:43 -0700 | [diff] [blame] | 24 | plat/linux.o \ |
swissChili | 6d6525e | 2021-06-15 21:20:53 -0700 | [diff] [blame] | 25 | istream.o \ |
swissChili | 2999dd1 | 2021-07-02 14:19:53 -0700 | [diff] [blame] | 26 | gc.o \ |
27 | call_list.o | ||||
swissChili | 8cfb7c4 | 2021-04-18 21:17:58 -0700 | [diff] [blame] | 28 | |
swissChili | ca107a0 | 2021-04-14 12:07:30 -0700 | [diff] [blame] | 29 | LUA = vendor/luajit/src/host/minilua |
30 | |||||
swissChili | 9e57da4 | 2021-06-15 22:22:46 -0700 | [diff] [blame] | 31 | $(LUA): vendor/luajit/src/host/minilua.c |
swissChili | ca107a0 | 2021-04-14 12:07:30 -0700 | [diff] [blame] | 32 | status_log(CC, $<) |
33 | @$(CC) $< -o $@ -lm | ||||
34 | |||||
swissChili | 9e57da4 | 2021-06-15 22:22:46 -0700 | [diff] [blame] | 35 | compiler.c: compiler.dasc | $(LUA) |
swissChili | ca107a0 | 2021-04-14 12:07:30 -0700 | [diff] [blame] | 36 | status_log(DYNASM, $<) |
37 | @$(LUA) vendor/luajit/dynasm/dynasm.lua -o $@ $< | ||||
swissChili | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 38 | |
39 | type(executable) | ||||
40 | |||||
swissChili | 2999dd1 | 2021-07-02 14:19:53 -0700 | [diff] [blame] | 41 | F ?= test.lisp |
swissChili | f68671f | 2021-07-05 14:14:44 -0700 | [diff] [blame] | 42 | lisp_libpath = $(ROOT)/lib/lisp |
swissChili | 2999dd1 | 2021-07-02 14:19:53 -0700 | [diff] [blame] | 43 | |
swissChili | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 44 | run: lisp |
swissChili | 2999dd1 | 2021-07-02 14:19:53 -0700 | [diff] [blame] | 45 | status_log(LISP, $(F)) |
swissChili | f68671f | 2021-07-05 14:14:44 -0700 | [diff] [blame] | 46 | @LISP_LIBRARY_PATH="$(lisp_libpath)" ./lisp $(F) |
swissChili | bed8092 | 2021-04-13 21:58:05 -0700 | [diff] [blame] | 47 | |
swissChili | 708d4c4 | 2021-07-04 17:40:07 -0700 | [diff] [blame] | 48 | leak-check: lisp |
49 | status_log(VALGRIND, lisp $(F)) | ||||
swissChili | f68671f | 2021-07-05 14:14:44 -0700 | [diff] [blame] | 50 | @LISP_LIBRARY_PATH="$(lisp_libpath)" valgrind --leak-check=full ./lisp $(F) |
swissChili | 708d4c4 | 2021-07-04 17:40:07 -0700 | [diff] [blame] | 51 | |
swissChili | bed8092 | 2021-04-13 21:58:05 -0700 | [diff] [blame] | 52 | format: |
53 | status_log(FORMAT, *) | ||||
swissChili | 53472e8 | 2021-05-08 16:06:32 -0700 | [diff] [blame] | 54 | @clang-format -i *.c *.h *.dasc plat/* lib/* |
swissChili | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 55 | |
56 | finish |