@@ -6,6 +6,7 @@ LUA_CPATH_MAKE = $(shell $(LUAROCKS) path --lr-cpath);./?.so
66
77LUA_SRC_VERSION ?= 5.1.5
88LPEG_VERSION ?= 1.0.2
9+ LFS_VERSION ?= 1_8_0
910
1011.PHONY : test local build watch lint count show test_binary
1112
@@ -61,6 +62,10 @@ lpeg-$(LPEG_VERSION)/lptree.c:
6162 curl -L -o lpeg.tar.gz https://www.inf.puc-rio.br/~roberto/lpeg/lpeg-$(LPEG_VERSION ) .tar.gz
6263 tar -xzf lpeg.tar.gz
6364
65+ luafilesystem-$(LFS_VERSION ) /src/lfs.c :
66+ curl -L -o luafilesystem.tar.gz https://github.com/keplerproject/luafilesystem/archive/v$(LFS_VERSION ) .tar.gz
67+ tar -xzf luafilesystem.tar.gz
68+
6469bin/binaries/moonscript.h : moonscript/* .lua moon/* .lua
6570 bin/splat.moon -l moonscript moonscript moon > moonscript.lua
6671 xxd -i moonscript.lua > $@
@@ -75,7 +80,12 @@ bin/binaries/argparse.h: lua_modules
7580 bin/splat.moon --strip-prefix -l argparse $$(find lua_modules/share/lua -name "argparse.lua" -exec dirname {} \; | head -1 ) > bin/binaries/argparse.lua
7681 xxd -i -n argparse_lua bin/binaries/argparse.lua > $@
7782
78- dist/moon : lua-$(LUA_SRC_VERSION ) /src/liblua.a lpeg-$(LPEG_VERSION ) /lptree.c bin/binaries/moonscript.h bin/binaries/moon.h bin/binaries/argparse.h
83+ bin/binaries/moonc.h : bin/moonc
84+ awk ' FNR>1' bin/moonc > moonc.lua
85+ xxd -i moonc.lua > $@
86+ rm moonc.lua
87+
88+ dist/moon : lua-$(LUA_SRC_VERSION ) /src/liblua.a lpeg-$(LPEG_VERSION ) /lptree.c bin/binaries/moonscript.h bin/binaries/moon.h bin/binaries/argparse.h bin/binaries/moon.c bin/binaries/moonscript.c
7989 mkdir -p dist
8090 gcc -static -o dist/moon \
8191 -Ilua-$(LUA_SRC_VERSION ) /src/ \
@@ -91,5 +101,22 @@ dist/moon: lua-$(LUA_SRC_VERSION)/src/liblua.a lpeg-$(LPEG_VERSION)/lptree.c bin
91101 lua-$(LUA_SRC_VERSION ) /src/liblua.a \
92102 -lm -ldl
93103
104+ dist/moonc : lua-$(LUA_SRC_VERSION ) /src/liblua.a lpeg-$(LPEG_VERSION ) /lptree.c luafilesystem-$(LFS_VERSION ) /src/lfs.c bin/binaries/moonscript.h bin/binaries/moonc.h bin/binaries/argparse.h bin/binaries/moonc.c bin/binaries/moonscript.c
105+ mkdir -p dist
106+ gcc -static -o dist/moonc \
107+ -Ilua-$(LUA_SRC_VERSION ) /src/ \
108+ -Ilpeg-$(LPEG_VERSION ) / \
109+ -Ibin/binaries/ \
110+ bin/binaries/moonc.c \
111+ bin/binaries/moonscript.c \
112+ lpeg-$(LPEG_VERSION ) /lpvm.c \
113+ lpeg-$(LPEG_VERSION ) /lpcap.c \
114+ lpeg-$(LPEG_VERSION ) /lptree.c \
115+ lpeg-$(LPEG_VERSION ) /lpcode.c \
116+ lpeg-$(LPEG_VERSION ) /lpprint.c \
117+ luafilesystem-$(LFS_VERSION ) /src/lfs.c \
118+ lua-$(LUA_SRC_VERSION ) /src/liblua.a \
119+ -lm -ldl
120+
94121test_binary : dist/moon
95122 dist/moon
0 commit comments