~technomancy/shevek

06b9a6b499b3b876937ead8e58028ed925a60611 — Phil Hagelberg 4 years ago 4214f7b master
Add makefile which supports compiling to binary.
3 files changed, 63 insertions(+), 2 deletions(-)

A .gitignore
M README.md
A makefile
A .gitignore => .gitignore +7 -0
@@ 0,0 1,7 @@
/shevek
/shevek.lua
/shevek.lua.c
/luasocket/
/mime.a
/socket.a
/usr

M README.md => README.md +12 -2
@@ 21,11 21,21 @@ limitation that multi-line input is not supported.

## Usage

    $ shevek PORT
    $ ./fennel shevek.fnl $PORT

Or you can compile a binary with `make`:

    $ make STATIC_LUA_LIB=/usr/lib/x86_64-linux-gnu/liblua5.4.a LUA_INCLUDE_DIR=/usr/include/lua5.4
    $ cp shevek ~/bin
    $ shevek $PORT

You will need to set `STATIC_LUA_LIB` and `LUA_INCLUDE_DIR`
appropriately for the versions of Lua you want to compile with; the
examples above are for Debian-based systems using Lua 5.4.

## License

Copyright © 2019 Phil Hagelberg and contributors
Copyright © 2019-2020 Phil Hagelberg and contributors

Released under the terms of the GNU Lesser General Public License
version 3 or later; see the file LICENSE.

A makefile => makefile +44 -0
@@ 0,0 1,44 @@
LUA ?= 5.3

STATIC_LUA_LIB ?= /usr/lib/x86_64-linux-gnu/liblua$(LUA).a
LUA_INCLUDE_DIR ?= /usr/include/lua$(LUA)

LUA_PATH="?.lua;usr/local/share/lua/$(LUA)/?.lua"
LUA_CPATH="usr/local/lib/lua/$(LUA)/?.so"

shevek: shevek.fnl socket.a mime.a
	LUA_PATH=$(LUA_PATH) ./fennel --correlate --compile-binary $< $@ \
		$(STATIC_LUA_LIB) $(LUA_INCLUDE_DIR) \
		--native-module socket.a --native-module mime.a
	chmod 755 $@

luasocket: ; git clone https://github.com/diegonehab/luasocket

luasocket/src/luasocket.o: luasocket
	make -C luasocket/src linux install MYCFLAGS=-static \
		LUAV=$(LUA) DESTDIR=$(PWD) LUAINC_linux=$(LUA_INCLUDE_DIR)

SOCKET_OBJS= \
	luasocket/src/luasocket.o \
	luasocket/src/timeout.o \
	luasocket/src/buffer.o \
	luasocket/src/io.o \
	luasocket/src/auxiliar.o \
	luasocket/src/compat.o \
	luasocket/src/options.o \
	luasocket/src/inet.o \
	luasocket/src/except.o \
	luasocket/src/select.o \
	luasocket/src/tcp.o \
	luasocket/src/udp.o \
	luasocket/src/usocket.o # <- this one should be wsocket.o for Windows

socket.a: $(SOCKET_OBJS)
	ar rcs $@ $^

mime.a: luasocket/src/mime.o luasocket/src/compat.o
	ar rcs $@ $^

clean: ; rm -rf usr socket.a mime.a shevek

.PHONY: clean