cortav  Diff

Differences From Artifact [fbd94cf6db]:

To Artifact [10a67640c2]:


    37     37   luac != which luac
    38     38   sh != which sh
    39     39   
    40     40   extens = $(wildcard ext/*.lua)
    41     41   extens-names ?= $(basename $(notdir $(extens)))
    42     42   rendrs = $(wildcard render/*.lua)
    43     43   rendrs-names ?= $(basename $(notdir $(rendrs)))
           44  +binds = $(wildcard bind/*.c)
           45  +binds-names ?= $(basename $(notdir $(binds)))
    44     46   
    45     47   build = build
    46     48   executable = cortav
    47     49   default-format-flags = -m html:width 40em
    48     50   
    49     51   prefix = $(HOME)/.local
    50     52   bin-prefix = $(prefix)/bin
    51     53   
    52     54   lua-standalone = $(if $(lua-lib-prefix),$(lua-lib-prefix)/liblua.a,-llua)
    53     55   lua-bindeps = -lm -ldl
           56  +
           57  +ifneq ($(filter net,$(binds-names)),)
           58  +    lua-bindeps += -lcurl
           59  +endif
    54     60   
    55     61   dbg-flags-luac = $(if $(debug),,-s)
    56     62   dbg-flags-cc = $(if $(debug),-g,-s)
    57     63   
    58     64   # sterilize the operating theatre
    59     65   export LUA_PATH=./?.lua;./?.lc
    60     66   export LUA_PATH_5_3=./?.lc;./?.lua
................................................................................
    84     90   # raw bytecode without shebang header, must be run as `lua cortav.lc`
    85     91   $(build)/$(executable).lc: sirsem.lua $(encoding-files) cortav.lua $(rendrs) $(extens) cli.lua | $(build)/
    86     92   	@echo ' » building with extensions $(extens-names)'
    87     93   	@echo ' » building with renderers $(rendrs-names)'
    88     94   	$(luac) $(dbg-flags-luac) -o $@ $^
    89     95   
    90     96   # true standalone binary, wraps bytecode file and (optionally) lua
    91         -$(build)/$(executable).bin: $(build)/$(executable).lc tool/makeshim.lua
    92         -	$(lua) tool/makeshim.lua $< |\
    93         -		$(CC) -s -o$@ -xc - -xnone $(lua-standalone) $(lua-bindeps)
           97  +$(build)/$(executable).bin: $(build)/$(executable).lc tool/makeshim.lua $(binds)
           98  +	$(lua) tool/makeshim.lua $< "" $(binds-names) |\
           99  +		$(CC) -s -o$@ -xc - -xnone $(binds) $(lua-standalone) $(lua-bindeps)
          100  +
          101  +# loadable lua modules for binds, mainly useful for testing
          102  +$(build)/bind/%.so: bind/%.c bind/bind.h | $(build)/bind/
          103  +	$(CC) -fPIC -shared -g -o$@ $<
    94    104   
    95    105   $(build)/cortav.html: cortav.ct $(build)/$(executable) | $(build)/
    96    106   	$(build)/$(executable) $< -o $@ -m render:format html -y html:fossil-uv
    97    107   
    98    108   .PHONY: syncdoc
    99    109   syncdoc: $(build)/cortav.html
   100    110   	fossil uv add $< --as cortav.html
................................................................................
   104    114   # just in case it ever gets invoked in a bad way
   105    115   .PHONY: clean
   106    116   clean:
   107    117   	rm -f $(build)/*.{html,lc,sh,txt,desktop} \
   108    118   	      $(build)/$(executable){,.bin}
   109    119   	rmdir $(build)
   110    120   
   111         -$(build)/%.sh: desk/%.sh
          121  +$(build)/%.sh: desk/%.sh | $(build)/
   112    122   	echo >$@ "#!$(sh)"
   113    123   	echo >>$@ 'cortav_exec="$(bin-prefix)/$(executable)"'
   114    124   	echo >>$@ 'cortav_flags="$${ct_format_flags-$(default-format-flags)}"'
   115    125   	cat $< >> $@
   116    126   	chmod +x $@
   117    127   
   118    128   $(build)/velartrill-cortav-view.desktop: desk/cortav-view.desktop