@@ -40,8 +40,10 @@ extens = $(wildcard ext/*.lua) extens-names ?= $(basename $(notdir $(extens))) rendrs = $(wildcard render/*.lua) rendrs-names ?= $(basename $(notdir $(rendrs))) +binds = $(wildcard bind/*.c) +binds-names ?= $(basename $(notdir $(binds))) build = build executable = cortav default-format-flags = -m html:width 40em @@ -50,8 +52,12 @@ bin-prefix = $(prefix)/bin lua-standalone = $(if $(lua-lib-prefix),$(lua-lib-prefix)/liblua.a,-llua) lua-bindeps = -lm -ldl + +ifneq ($(filter net,$(binds-names)),) + lua-bindeps += -lcurl +endif dbg-flags-luac = $(if $(debug),,-s) dbg-flags-cc = $(if $(debug),-g,-s) @@ -87,11 +93,15 @@ @echo ' ยป building with renderers $(rendrs-names)' $(luac) $(dbg-flags-luac) -o $@ $^ # true standalone binary, wraps bytecode file and (optionally) lua -$(build)/$(executable).bin: $(build)/$(executable).lc tool/makeshim.lua - $(lua) tool/makeshim.lua $< |\ - $(CC) -s -o$@ -xc - -xnone $(lua-standalone) $(lua-bindeps) +$(build)/$(executable).bin: $(build)/$(executable).lc tool/makeshim.lua $(binds) + $(lua) tool/makeshim.lua $< "" $(binds-names) |\ + $(CC) -s -o$@ -xc - -xnone $(binds) $(lua-standalone) $(lua-bindeps) + +# loadable lua modules for binds, mainly useful for testing +$(build)/bind/%.so: bind/%.c bind/bind.h | $(build)/bind/ + $(CC) -fPIC -shared -g -o$@ $< $(build)/cortav.html: cortav.ct $(build)/$(executable) | $(build)/ $(build)/$(executable) $< -o $@ -m render:format html -y html:fossil-uv @@ -107,9 +117,9 @@ rm -f $(build)/*.{html,lc,sh,txt,desktop} \ $(build)/$(executable){,.bin} rmdir $(build) -$(build)/%.sh: desk/%.sh +$(build)/%.sh: desk/%.sh | $(build)/ echo >$@ "#!$(sh)" echo >>$@ 'cortav_exec="$(bin-prefix)/$(executable)"' echo >>$@ 'cortav_flags="$${ct_format_flags-$(default-format-flags)}"' cat $< >> $@