blob: 5b00b6d47b69da61f22149cf4bbeeefe9ee68dde [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
swissChili53e7cd12021-08-02 21:55:53 -070016CFLAGS += -Ivendor/luajit/dynasm -Werror -lreadline # -fsanitize=address
swissChili7e1393c2021-07-07 12:59:12 -070017LDFLAGS += -lreadline
swissChili2999dd12021-07-02 14:19:53 -070018ASMFLAGS += -felf -Fdwarf
swissChilica107a02021-04-14 12:07:30 -070019
20OBJECTS = main.o \
21 lisp.o \
swissChilib3ca4fb2021-04-20 10:33:00 -070022 compiler.o \
swissChili53472e82021-05-08 16:06:32 -070023 lib/std.o \
swissChili923b5362021-05-09 20:31:43 -070024 plat/linux.o \
swissChili6d6525e2021-06-15 21:20:53 -070025 istream.o \
swissChili2999dd12021-07-02 14:19:53 -070026 gc.o \
27 call_list.o
swissChili8cfb7c42021-04-18 21:17:58 -070028
swissChilica107a02021-04-14 12:07:30 -070029LUA = vendor/luajit/src/host/minilua
30
swissChili9e57da42021-06-15 22:22:46 -070031$(LUA): vendor/luajit/src/host/minilua.c
swissChilica107a02021-04-14 12:07:30 -070032 status_log(CC, $<)
33 @$(CC) $< -o $@ -lm
34
swissChili9e57da42021-06-15 22:22:46 -070035compiler.c: compiler.dasc | $(LUA)
swissChilica107a02021-04-14 12:07:30 -070036 status_log(DYNASM, $<)
37 @$(LUA) vendor/luajit/dynasm/dynasm.lua -o $@ $<
swissChili7a6f5eb2021-04-13 16:46:02 -070038
39type(executable)
40
swissChili2999dd12021-07-02 14:19:53 -070041F ?= test.lisp
swissChilif68671f2021-07-05 14:14:44 -070042lisp_libpath = $(ROOT)/lib/lisp
swissChili2999dd12021-07-02 14:19:53 -070043
swissChili7a6f5eb2021-04-13 16:46:02 -070044run: lisp
swissChili2999dd12021-07-02 14:19:53 -070045 status_log(LISP, $(F))
swissChilif68671f2021-07-05 14:14:44 -070046 @LISP_LIBRARY_PATH="$(lisp_libpath)" ./lisp $(F)
swissChilibed80922021-04-13 21:58:05 -070047
swissChili708d4c42021-07-04 17:40:07 -070048leak-check: lisp
49 status_log(VALGRIND, lisp $(F))
swissChilif68671f2021-07-05 14:14:44 -070050 @LISP_LIBRARY_PATH="$(lisp_libpath)" valgrind --leak-check=full ./lisp $(F)
swissChili708d4c42021-07-04 17:40:07 -070051
swissChilibed80922021-04-13 21:58:05 -070052format:
53 status_log(FORMAT, *)
swissChili53472e82021-05-08 16:06:32 -070054 @clang-format -i *.c *.h *.dasc plat/* lib/*
swissChili7a6f5eb2021-04-13 16:46:02 -070055
56finish