summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/biblatex-contrib/biblatex-oxref/Makefile
blob: c51927feb8bc4ef8c18855d0766a7048161dcf8d (plain)
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
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
NAME  = oxref
PFX   = biblatex-
STY1  = oxnotes
STYS  = oxnotes oxyear oxnum oxalph
VARS  = ibid note inote trad1 trad2 trad3
LANGS = american british english spanish
LANGX = spanish
TESTS = $(STYS) $(foreach sty, $(STYS), $(LANGX:%=%-$(sty)))
AUX   = aux,bbl,bcf,blg,doc,fdb_latexmk,fls,glo,gls,hd,idx,ilg,ind,listing,log,nav,out,run.xml,snm,synctex.gz,toc,vrb
SHELL = bash
PWD   = $(shell pwd)
TEMP := $(shell mktemp -d -t tmp.XXXXXXXXXX)
TDIR  = $(TEMP)/$(PFX)$(NAME)
VERS  = $(shell ltxfileinfo -v $(NAME).dtx)
LOCAL = $(shell kpsewhich --var-value TEXMFLOCAL)
UTREE = $(shell kpsewhich --var-value TEXMFHOME)

.PHONY: source clean distclean inst uninst install uninstall zip ctan

all: $(NAME).pdf $(STYS:%=%-doc.pdf) clean
	@exit 0

source $(NAME).bbx $(LANGS:%=%-$(NAME).lbx) $(STYS:%=%-doc.tex) $(STYS:%=%.bbx) $(STYS:%=%.cbx) $(STYS:%=%.dbx) $(VARS:%=$(STY1)-%.bbx) $(VARS:%=$(STY1)-%.cbx) $(VARS:%=$(STY1)-%.dbx): $(NAME).dtx
	luatex -interaction=nonstopmode $(NAME).dtx >/dev/null

$(NAME).pdf: $(NAME).dtx $(NAME).bbx $(STY1).bbx $(STY1).cbx british-$(NAME).lbx english-$(NAME).lbx
	latexmk -silent -lualatex -shell-escape -interaction=nonstopmode $(NAME).dtx >/dev/null
$(STYS:%=%-doc.pdf): %-doc.pdf : %-doc.tex $(NAME).bbx %.bbx %.cbx british-$(NAME).lbx english-$(NAME).lbx
	latexmk -silent -lualatex -shell-escape -interaction=nonstopmode $< >/dev/null

test-oxalph.tex: test-template.tex
	sed 's/style=oxref/style=oxalph/' $< > $@
test-oxnotes.tex: test-template.tex
	sed 's/style=oxref/style=oxnotes,scnames/' $< > $@
test-oxnum.tex: test-template.tex
	sed 's/style=oxref/style=oxnum,scnames,backref=true/' $< > $@
test-oxyear.tex: test-template.tex
	sed 's/style=oxref/style=oxyear/' $< > $@
$(STYS:%=test-%.pdf): test-%.pdf : test-%.tex $(NAME).bbx %.bbx %.cbx british-$(NAME).lbx english-$(NAME).lbx
	latexmk -silent -lualatex -shell-escape -interaction=nonstopmode $< >/dev/null

define LANGTESTTEX =
test-$(1)-$(2).tex: test-template.tex
	sed -e 's/british/$(1)/' -e 's/style=oxref/style=$(2)/' $$< > $$@
endef

$(foreach lang, $(LANGX), $(foreach sty, $(STYS), $(eval $(call LANGTESTTEX,$(lang),$(sty)))))

define LANGTESTPDF =
test-$(1)-$(2).pdf: test-$(1)-$(2).tex $(NAME).bbx $(2).bbx $(2).cbx $(1)-$(NAME).lbx
	latexmk -silent -lualatex -shell-escape -interaction=nonstopmode $$< >/dev/null
endef

$(foreach lang, $(LANGX), $(foreach sty, $(STYS), $(eval $(call LANGTESTPDF,$(lang),$(sty)))))

$(TESTS:%=%.bbi): %.bbi : test-%.pdf
	pdftotext $< $@

clean:
	@for log in *.log; do [ -e "$$log" ] || continue; grep "WARNING: biblatex-oxref" $$log; test $$? -eq 1; done
	rm -f $(NAME).{$(AUX)} $(STYS:%=%-doc.{$(AUX)}) $(TESTS:%=test-%.{tex,pdf}) $(TESTS:%=test-%.{$(AUX)})
	rm -f $(STYS:%=%.doc) $(LANGS:%=%-$(NAME).doc)
	rm -rf _minted-*
	rm -f $(NAME).markdown.in
	rm -rf _markdown_*
distclean: clean
	rm -f $(NAME).{bbx,bib,ins,pdf} $(STYS:%=%.{b,c,d}bx) $(VARS:%=$(STY1)-%.{b,c,d}bx) $(LANGS:%=%-$(NAME).lbx) $(STYS:%=%-doc.{tex,pdf})

inst: all
	mkdir -p $(UTREE)/{tex,source,doc}/latex/$(PFX)$(NAME)
	cp $(NAME).{dtx,ins} $(UTREE)/source/latex/$(PFX)$(NAME)
	cp $(NAME).bbx $(STYS:%=%.{b,c,d}bx) $(VARS:%=$(STY1)-%.{b,c,d}bx) $(LANGS:%=%-$(NAME).lbx) $(UTREE)/tex/latex/$(PFX)$(NAME)
	cp $(NAME).{bib,pdf} $(STYS:%=%-doc.{tex,pdf}) $(UTREE)/doc/latex/$(PFX)$(NAME)
	mktexlsr
uninst:
	rm -r $(UTREE)/{tex,source,doc}/latex/$(PFX)$(NAME)
	mktexlsr

install: all
	sudo mkdir -p $(LOCAL)/{tex,source,doc}/latex/$(PFX)$(NAME)
	sudo cp $(NAME).{dtx,ins} $(LOCAL)/source/latex/$(PFX)$(NAME)
	sudo cp $(NAME).bbx $(STYS:%=%.{b,c,d}bx) $(VARS:%=$(STY1)-%.{b,c,d}bx) $(LANGS:%=%-$(NAME).lbx) $(LOCAL)/tex/latex/$(PFX)$(NAME)
	sudo cp $(NAME).{bib,pdf} $(STYS:%=%-doc.{tex,pdf}) $(LOCAL)/doc/latex/$(PFX)$(NAME)
	sudo mktexlsr
uninstall:
	sudo rm -r $(LOCAL)/{tex,source,doc}/latex/$(PFX)$(NAME)
	sudo mktexlsr

zip: all
	mkdir $(TDIR)
	cp $(NAME).{dtx,pdf} $(STYS:%=%-doc.pdf) README.md Makefile $(NAME).bbx $(STYS:%=%.{b,c,d}bx) $(VARS:%=$(STY1)-%.{b,c,d}bx) $(LANGS:%=%-$(NAME).lbx) $(TDIR)
	cd $(TEMP); zip -Drq $(PWD)/$(PFX)$(NAME)-$(VERS).zip $(PFX)$(NAME)
ctan: all
	mkdir $(TDIR)
	cp $(NAME).{dtx,pdf} $(STYS:%=%-doc.pdf) README.md Makefile $(TDIR)
	cd $(TEMP); zip -Drq $(PWD)/$(PFX)$(NAME)-$(VERS).zip $(PFX)$(NAME)