A compromise between the speed of make and the ease of use of a build script
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
.PHONY: all clean mrproper bin lib
|
|
|
|
|
|
|
|
MOONC = moonc
|
|
|
|
AMALG = amalg.lua
|
|
|
|
RM = rm -f --
|
|
|
|
LUA = lua5.3
|
|
|
|
|
|
|
|
LIB_SRC = $(wildcard moonbuild/*.moon) $(wildcard moonbuild/*/*.moon) $(wildcard moonbuild/*/*/*.moon)
|
|
|
|
BIN_SRC = $(wildcard bin/*.moon)
|
|
|
|
|
|
|
|
LIB_LUA = $(foreach moon, $(LIB_SRC), $(patsubst %.moon, %.lua, $(moon)))
|
|
|
|
BIN_LUA = $(foreach moon, $(BIN_SRC), $(patsubst %.moon, %.lua, $(moon)))
|
|
|
|
BIN = $(foreach lua, $(BIN_LUA), $(patsubst bin/%.lua, out/%, $(lua)))
|
|
|
|
|
|
|
|
MODULES = $(shell echo $(foreach lib, $(LIB_LUA), $(patsubst %.lua, %, $(lib))) | sed 's|/|.|g')
|
|
|
|
|
|
|
|
all: bin lib
|
|
|
|
|
|
|
|
install: all
|
|
|
|
sudo cp out/moonbuild /usr/local/bin/moonbuild
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(RM) $(LIB_LUA)
|
|
|
|
$(RM) $(BIN_LUA)
|
|
|
|
|
|
|
|
mrproper: clean
|
|
|
|
$(RM) $(BIN)
|
|
|
|
|
|
|
|
bin: $(BIN)
|
|
|
|
|
|
|
|
lib: $(LIB_LUA)
|
|
|
|
|
|
|
|
out/%: bin/%.lua $(LIB_LUA)
|
|
|
|
@mkdir -p `dirname $@`
|
|
|
|
$(AMALG) -o $@.body -s $< $(MODULES)
|
|
|
|
@printf '#!/usr/bin/env %s\n' $(LUA) > $@.headline
|
|
|
|
@cat $@.headline $@.body > $@
|
|
|
|
@rm $@.headline $@.body
|
|
|
|
chmod +x $@
|
|
|
|
|
|
|
|
%.lua: %.moon
|
|
|
|
moonc $^
|