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