forked from michal-h21/LuaXML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (46 loc) · 1.74 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
lua_content = $(wildcard luaxml-*.lua)
tex_content = $(wildcard *.tex)
tests = $(wildcard test/*.lua)
name = luaxml
VERSION:= $(shell git --no-pager describe --abbrev=0 --tags --always )
DATE := $(firstword $(shell git --no-pager show --date=short --format="%ad" --name-only))
doc_file = luaxml.pdf
TEXMFHOME = $(shell kpsewhich -var-value=TEXMFHOME)
INSTALL_DIR = $(TEXMFHOME)/scripts/lua/$(name)
MANUAL_DIR = $(TEXMFHOME)/doc/latex/$(name)
SYSTEM_BIN = /usr/local/bin
BUILD_DIR = build
BUILD_LUAXML = $(BUILD_DIR)/$(name)
API_DOC = doc/api.tex
API_SOURCES = luaxml-domobject.lua luaxml-cssquery.lua
LDOC_FILTER = ldoc-latex.lua
ENTITIES_SOURCE = data/entities.json
ENTITIES_MODULE = luaxml-namedentities.lua
all: doc $(ENTITIES_MODULE)
.PHONY: test
doc: api $(doc_file)
$(doc_file): $(name).tex $(API_DOC)
latexmk -pdf -pdflatex='lualatex "\def\version{${VERSION}}\def\gitdate{${DATE}}\input{%S}"' $(name).tex
api: $(API_DOC)
$(API_DOC): $(API_SOURCES) $(LDOC_FILTER)
ldoc --all --filter ldoc-latex.filter . > $(API_DOC)
$(ENTITIES_MODULE): $(ENTITIES_SOURCE) data/jsontolua.lua
lua data/jsontolua.lua < $< > $(ENTITIES_MODULE)
test:
texlua test/dom-test.lua
texlua test/cssquery-test.lua
texlua test/entities-test.lua
build: doc test $(lua_content)
@rm -rf build
@mkdir -p $(BUILD_LUAXML)
@cp $(lua_content) $(tex_content) $(doc_file) $(BUILD_LUAXML)
@cat README | sed -e "s/{{VERSION}}/${VERSION}/" > $(BUILD_LUAXML)/README
@cat luaxml.tex | sed -e "s/{{VERSION}}/${VERSION}/" > $(BUILD_LUAXML)/luaxml.tex
@cd $(BUILD_DIR) && zip -r luaxml.zip luaxml
install: doc $(lua_content) $(filters)
mkdir -p $(INSTALL_DIR)
mkdir -p $(MANUAL_DIR)
cp $(doc_file) $(MANUAL_DIR)
cp $(lua_content) $(INSTALL_DIR)
version:
echo $(VERSION), $(DATE)