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 | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 7 | preset(optimize) |
| 8 | preset(32) |
| 9 | preset(debug) |
| 10 | preset(warn) |
| 11 | |
| 12 | archetype(c) |
| 13 | |
swissChili | ca107a0 | 2021-04-14 12:07:30 -0700 | [diff] [blame] | 14 | CFLAGS += -Ivendor/luajit/dynasm |
| 15 | |
| 16 | OBJECTS = main.o \ |
| 17 | lisp.o \ |
swissChili | b3ca4fb | 2021-04-20 10:33:00 -0700 | [diff] [blame^] | 18 | compiler.o \ |
| 19 | lib/std.o |
swissChili | ca107a0 | 2021-04-14 12:07:30 -0700 | [diff] [blame] | 20 | |
swissChili | 8cfb7c4 | 2021-04-18 21:17:58 -0700 | [diff] [blame] | 21 | ifeq ($(PLAT),linux) |
| 22 | OBJECTS += plat/linux.o |
| 23 | else |
| 24 | $(error linux is the only supported option for PLAT) |
| 25 | endif |
| 26 | |
swissChili | ca107a0 | 2021-04-14 12:07:30 -0700 | [diff] [blame] | 27 | LUA = vendor/luajit/src/host/minilua |
| 28 | |
| 29 | vendor/luajit/src/host/minilua: vendor/luajit/src/host/minilua.c |
| 30 | status_log(CC, $<) |
| 31 | @$(CC) $< -o $@ -lm |
| 32 | |
| 33 | compiler.c: compiler.dasc |
| 34 | status_log(DYNASM, $<) |
| 35 | @$(LUA) vendor/luajit/dynasm/dynasm.lua -o $@ $< |
swissChili | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 36 | |
| 37 | type(executable) |
| 38 | |
| 39 | run: lisp |
| 40 | status_log(RUN, ./lisp) |
swissChili | bed8092 | 2021-04-13 21:58:05 -0700 | [diff] [blame] | 41 | @./lisp "$$(cat test.lisp)" |
| 42 | |
| 43 | format: |
| 44 | status_log(FORMAT, *) |
swissChili | ca107a0 | 2021-04-14 12:07:30 -0700 | [diff] [blame] | 45 | @clang-format -i *.c *.h *.dasc |
swissChili | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 46 | |
| 47 | finish |