cortav  Diff

Differences From Artifact [ac8c1379b3]:

To Artifact [d74d07de6f]:


11
12
13
14
15
16
17
18
19

20














21
22
23
24
25
26
27
..
31
32
33
34
35
36
37














38
39
40
41
42
43
44
45
46
47
48







49
50
51
52
53
54






55
56
57
58
59
60
61
62
63


64
65
66



67
68
69
70
71
72
73
#     * install  * lua
#     * luac     * sh
#
#    if any are not present, the build will fail, although a missing
#    `which` can be worked around by specifying the paths to lua, luac,
#    and `sh` directly
#
#    eventually you will be able to set a "standalone" variable to
#    create a truly standalone binary, by embedding the binary in a

#    C program and statically linking it to lua.















lua != which lua
luac != which luac
sh != which sh

extens = $(wildcard ext/*.lua)
extens-names ?= $(basename $(notdir $(extens)))
................................................................................
build = build
executable = cortav
default-format-flags = -m html:width 40em

prefix = $(HOME)/.local
bin-prefix = $(prefix)/bin
share-prefix = $(prefix)/share/$(executable)















# by default, we fetch and parse information about encodings we
# support so that cortav can do fancy things like format math
# equations by character class (e.g. italicizing variables)
# this is not necessary for parsing the format, and can be
# disabled by blanking the encoding-data list when building
# ($ make encoding-data=)
encoding-data  = ucstbls
encoding-files = $(patsubst %,$(build)/%.lc,$(encoding-data))
encoding-data-ucs = https://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt








$(build)/$(executable): sirsem.lua $(encoding-files) cortav.lua $(rendrs) $(extens) cli.lua | $(build)/
	@echo ' » building with extensions $(extens-names)'
	@echo ' » building with renderers $(rendrs-names)'
	echo '#!$(lua)' > $@
	luac -o - $^ >> $@
	chmod +x $@







$(build)/cortav.html: cortav.ct $(build)/$(executable) | $(build)/
	$(build)/$(executable) $< -o $@ -m render:format html -y html:fossil-uv

.PHONY: syncdoc
syncdoc: $(build)/cortav.html
	fossil uv add $< --as cortav.html
	fossil uv sync



.PHONY: clean
clean:
	rm -f $(build)/cortav $(build)/cortav.html $(build)/velartrill-cortav-view.desktop $(build)/cortav-view.sh




$(build)/%.sh: desk/%.sh
	echo >$@ "#!$(sh)"
	echo >>$@ 'cortav_exec="$(bin-prefix)/$(executable)"'
	echo >>$@ 'cortav_flags="$${ct_format_flags-$(default-format-flags)}"'
	cat $< >> $@
	chmod +x $@







<
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>











>
>
>
>
>
>
>
|


<
<
<
>
>
>
>
>
>









>
>


<
>
>
>







11
12
13
14
15
16
17

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
..
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

106
107
108
109
110
111
112
113
114
115
#     * install  * lua
#     * luac     * sh
#
#    if any are not present, the build will fail, although a missing
#    `which` can be worked around by specifying the paths to lua, luac,
#    and `sh` directly
#

#    to create a truly standalone cortav binary, build the target
#    $(build)/cortav.bin - this will wrap the cortav bytecode in a C
#    shim and produce a binary executable. depending on your needs,
#    you may want to link lua statically or as a shared library.
#    to do this, you'll need to set the variable lua-prefix to the
#    location of your lua build. if you have lua installed systemwide,
#    this will probably be something like `lua-lib-prefix=/usr/lib`,
#    or on Nix `lua-lib-prefix=$(nix path-info lua5_3)/lib`. normally
#    however if you're building a standalone binary, you probably don't
#    have lua installed systemwide, so you'll want to set this to the
#    directory where liblua.a is to be found.
#
#    note that the standalone build script assumes you're using a
#    relatively standard cc, not something like msvc. if your cc
#    doesn't accept options like -l -x -o then you'll have to build
#    the binary by hand, sorry. but if you want to contribute a build
#    script to the repository, i'll happily take merge requests :)

lua != which lua
luac != which luac
sh != which sh

extens = $(wildcard ext/*.lua)
extens-names ?= $(basename $(notdir $(extens)))
................................................................................
build = build
executable = cortav
default-format-flags = -m html:width 40em

prefix = $(HOME)/.local
bin-prefix = $(prefix)/bin
share-prefix = $(prefix)/share/$(executable)

lua-standalone = $(if $(lua-lib-prefix),$(lua-lib-prefix)/liblua.a,-llua)
lua-bindeps = -lm -ldl

dbg-flags-luac = $(if $(debug),,-s)
dbg-flags-cc = $(if $(debug),-g,-s)

# sterilize the operating theatre
export LUA_PATH=./?.lua;./?.lc
export LUA_PATH_5_3=./?.lc;./?.lua
export LUA_PATH_5_4=./?.lc;./?.lua
export LUA_INIT=
export LUA_INIT_5_3=
export LUA_INIT_5_4=

# by default, we fetch and parse information about encodings we
# support so that cortav can do fancy things like format math
# equations by character class (e.g. italicizing variables)
# this is not necessary for parsing the format, and can be
# disabled by blanking the encoding-data list when building
# ($ make encoding-data=)
encoding-data  = ucstbls
encoding-files = $(patsubst %,$(build)/%.lc,$(encoding-data))
encoding-data-ucs = https://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt

# "standalone" bytecode file that can be run directly as a script
$(build)/$(executable): $(build)/$(executable).ct
	echo '#!$(lua)' > $@
	cat $< >>$@
	chmod +x $@

# raw bytecode without shebang header, must be run as `lua cortav.lc`
$(build)/$(executable).lc: sirsem.lua $(encoding-files) cortav.lua $(rendrs) $(extens) cli.lua | $(build)/
	@echo ' » building with extensions $(extens-names)'
	@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
	$(lua) tools/makeshim.lua $< |\
		$(CC) -o$@ -xc - -xnone $(lua-standalone) $(lua-bindeps)

$(build)/cortav.html: cortav.ct $(build)/$(executable) | $(build)/
	$(build)/$(executable) $< -o $@ -m render:format html -y html:fossil-uv

.PHONY: syncdoc
syncdoc: $(build)/cortav.html
	fossil uv add $< --as cortav.html
	fossil uv sync

# clean is written in overly cautious fashion to minimize damage,
# just in case it ever gets invoked in a bad way
.PHONY: clean
clean:

	rm -f $(build)/*.{html,lc,sh,txt,desktop} \
	      $(build)/$(executable){,.bin}
	rmdir $(build)

$(build)/%.sh: desk/%.sh
	echo >$@ "#!$(sh)"
	echo >>$@ 'cortav_exec="$(bin-prefix)/$(executable)"'
	echo >>$@ 'cortav_flags="$${ct_format_flags-$(default-format-flags)}"'
	cat $< >> $@
	chmod +x $@