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