blob: 03b0e55445f2a6d8a627237d9daca582cce1f0c9 [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
swissChili4691cf62021-08-05 21:34:57 -070018CFLAGS += -Ivendor/luajit/dynasm -Werror # -fsanitize=address
swissChili2999dd12021-07-02 14:19:53 -070019ASMFLAGS += -felf -Fdwarf
swissChilica107a02021-04-14 12:07:30 -070020
swissChili6d02af42021-08-05 19:49:01 -070021ifeq ($(NO_READLINE),1)
22CFLAGS += -DNO_READLINE
swissChili4691cf62021-08-05 21:34:57 -070023else
24LDFLAGS += -lreadline
25CFLAGS += -lreadline
swissChili6d02af42021-08-05 19:49:01 -070026endif
27
swissChilica107a02021-04-14 12:07:30 -070028OBJECTS = main.o \
29 lisp.o \
swissChilib3ca4fb2021-04-20 10:33:00 -070030 compiler.o \
swissChili53472e82021-05-08 16:06:32 -070031 lib/std.o \
swissChili923b5362021-05-09 20:31:43 -070032 plat/linux.o \
swissChili6d6525e2021-06-15 21:20:53 -070033 istream.o \
swissChili2999dd12021-07-02 14:19:53 -070034 gc.o \
swissChili6d02af42021-08-05 19:49:01 -070035 call_list.o \
36 error.o
swissChili8cfb7c42021-04-18 21:17:58 -070037
swissChilica107a02021-04-14 12:07:30 -070038LUA = vendor/luajit/src/host/minilua
39
swissChili9e57da42021-06-15 22:22:46 -070040$(LUA): vendor/luajit/src/host/minilua.c
swissChilica107a02021-04-14 12:07:30 -070041 status_log(CC, $<)
42 @$(CC) $< -o $@ -lm
43
swissChili9e57da42021-06-15 22:22:46 -070044compiler.c: compiler.dasc | $(LUA)
swissChilica107a02021-04-14 12:07:30 -070045 status_log(DYNASM, $<)
46 @$(LUA) vendor/luajit/dynasm/dynasm.lua -o $@ $<
swissChili7a6f5eb2021-04-13 16:46:02 -070047
48type(executable)
49
swissChili2999dd12021-07-02 14:19:53 -070050F ?= test.lisp
swissChilif68671f2021-07-05 14:14:44 -070051lisp_libpath = $(ROOT)/lib/lisp
swissChili2999dd12021-07-02 14:19:53 -070052
swissChili7a6f5eb2021-04-13 16:46:02 -070053run: lisp
swissChili2999dd12021-07-02 14:19:53 -070054 status_log(LISP, $(F))
swissChilif68671f2021-07-05 14:14:44 -070055 @LISP_LIBRARY_PATH="$(lisp_libpath)" ./lisp $(F)
swissChilibed80922021-04-13 21:58:05 -070056
swissChili708d4c42021-07-04 17:40:07 -070057leak-check: lisp
58 status_log(VALGRIND, lisp $(F))
swissChilif68671f2021-07-05 14:14:44 -070059 @LISP_LIBRARY_PATH="$(lisp_libpath)" valgrind --leak-check=full ./lisp $(F)
swissChili708d4c42021-07-04 17:40:07 -070060
swissChilibed80922021-04-13 21:58:05 -070061format:
62 status_log(FORMAT, *)
swissChili53472e82021-05-08 16:06:32 -070063 @clang-format -i *.c *.h *.dasc plat/* lib/*
swissChili7a6f5eb2021-04-13 16:46:02 -070064
65finish