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 | 6d02af4 | 2021-08-05 19:49:01 -0700 | [diff] [blame^] | 16 | NO_READLINE ?= 0 |
17 | |||||
swissChili | 53e7cd1 | 2021-08-02 21:55:53 -0700 | [diff] [blame] | 18 | CFLAGS += -Ivendor/luajit/dynasm -Werror -lreadline # -fsanitize=address |
swissChili | 7e1393c | 2021-07-07 12:59:12 -0700 | [diff] [blame] | 19 | LDFLAGS += -lreadline |
swissChili | 2999dd1 | 2021-07-02 14:19:53 -0700 | [diff] [blame] | 20 | ASMFLAGS += -felf -Fdwarf |
swissChili | ca107a0 | 2021-04-14 12:07:30 -0700 | [diff] [blame] | 21 | |
swissChili | 6d02af4 | 2021-08-05 19:49:01 -0700 | [diff] [blame^] | 22 | ifeq ($(NO_READLINE),1) |
23 | CFLAGS += -DNO_READLINE | ||||
24 | endif | ||||
25 | |||||
swissChili | ca107a0 | 2021-04-14 12:07:30 -0700 | [diff] [blame] | 26 | OBJECTS = main.o \ |
27 | lisp.o \ | ||||
swissChili | b3ca4fb | 2021-04-20 10:33:00 -0700 | [diff] [blame] | 28 | compiler.o \ |
swissChili | 53472e8 | 2021-05-08 16:06:32 -0700 | [diff] [blame] | 29 | lib/std.o \ |
swissChili | 923b536 | 2021-05-09 20:31:43 -0700 | [diff] [blame] | 30 | plat/linux.o \ |
swissChili | 6d6525e | 2021-06-15 21:20:53 -0700 | [diff] [blame] | 31 | istream.o \ |
swissChili | 2999dd1 | 2021-07-02 14:19:53 -0700 | [diff] [blame] | 32 | gc.o \ |
swissChili | 6d02af4 | 2021-08-05 19:49:01 -0700 | [diff] [blame^] | 33 | call_list.o \ |
34 | error.o | ||||
swissChili | 8cfb7c4 | 2021-04-18 21:17:58 -0700 | [diff] [blame] | 35 | |
swissChili | ca107a0 | 2021-04-14 12:07:30 -0700 | [diff] [blame] | 36 | LUA = vendor/luajit/src/host/minilua |
37 | |||||
swissChili | 9e57da4 | 2021-06-15 22:22:46 -0700 | [diff] [blame] | 38 | $(LUA): vendor/luajit/src/host/minilua.c |
swissChili | ca107a0 | 2021-04-14 12:07:30 -0700 | [diff] [blame] | 39 | status_log(CC, $<) |
40 | @$(CC) $< -o $@ -lm | ||||
41 | |||||
swissChili | 9e57da4 | 2021-06-15 22:22:46 -0700 | [diff] [blame] | 42 | compiler.c: compiler.dasc | $(LUA) |
swissChili | ca107a0 | 2021-04-14 12:07:30 -0700 | [diff] [blame] | 43 | status_log(DYNASM, $<) |
44 | @$(LUA) vendor/luajit/dynasm/dynasm.lua -o $@ $< | ||||
swissChili | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 45 | |
46 | type(executable) | ||||
47 | |||||
swissChili | 2999dd1 | 2021-07-02 14:19:53 -0700 | [diff] [blame] | 48 | F ?= test.lisp |
swissChili | f68671f | 2021-07-05 14:14:44 -0700 | [diff] [blame] | 49 | lisp_libpath = $(ROOT)/lib/lisp |
swissChili | 2999dd1 | 2021-07-02 14:19:53 -0700 | [diff] [blame] | 50 | |
swissChili | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 51 | run: lisp |
swissChili | 2999dd1 | 2021-07-02 14:19:53 -0700 | [diff] [blame] | 52 | status_log(LISP, $(F)) |
swissChili | f68671f | 2021-07-05 14:14:44 -0700 | [diff] [blame] | 53 | @LISP_LIBRARY_PATH="$(lisp_libpath)" ./lisp $(F) |
swissChili | bed8092 | 2021-04-13 21:58:05 -0700 | [diff] [blame] | 54 | |
swissChili | 708d4c4 | 2021-07-04 17:40:07 -0700 | [diff] [blame] | 55 | leak-check: lisp |
56 | status_log(VALGRIND, lisp $(F)) | ||||
swissChili | f68671f | 2021-07-05 14:14:44 -0700 | [diff] [blame] | 57 | @LISP_LIBRARY_PATH="$(lisp_libpath)" valgrind --leak-check=full ./lisp $(F) |
swissChili | 708d4c4 | 2021-07-04 17:40:07 -0700 | [diff] [blame] | 58 | |
swissChili | bed8092 | 2021-04-13 21:58:05 -0700 | [diff] [blame] | 59 | format: |
60 | status_log(FORMAT, *) | ||||
swissChili | 53472e8 | 2021-05-08 16:06:32 -0700 | [diff] [blame] | 61 | @clang-format -i *.c *.h *.dasc plat/* lib/* |
swissChili | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 62 | |
63 | finish |