summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/stex/lib/make
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/stex/lib/make
Initial commit
Diffstat (limited to 'macros/latex/contrib/stex/lib/make')
-rw-r--r--macros/latex/contrib/stex/lib/make/Makefile3
-rw-r--r--macros/latex/contrib/stex/lib/make/Makefile.base.in49
-rw-r--r--macros/latex/contrib/stex/lib/make/Makefile.base.vars30
-rw-r--r--macros/latex/contrib/stex/lib/make/Makefile.in3
-rw-r--r--macros/latex/contrib/stex/lib/make/Makefile.latex.in33
-rw-r--r--macros/latex/contrib/stex/lib/make/Makefile.latex.vars17
-rw-r--r--macros/latex/contrib/stex/lib/make/Makefile.latexml.in43
-rw-r--r--macros/latex/contrib/stex/lib/make/Makefile.latexml.vars48
-rw-r--r--macros/latex/contrib/stex/lib/make/Makefile.subdirs6
-rw-r--r--macros/latex/contrib/stex/lib/make/Makefile.vars3
-rw-r--r--macros/latex/contrib/stex/lib/make/README23
11 files changed, 258 insertions, 0 deletions
diff --git a/macros/latex/contrib/stex/lib/make/Makefile b/macros/latex/contrib/stex/lib/make/Makefile
new file mode 100644
index 0000000000..0aaad6a8d8
--- /dev/null
+++ b/macros/latex/contrib/stex/lib/make/Makefile
@@ -0,0 +1,3 @@
+all:
+clean:
+distclean:
diff --git a/macros/latex/contrib/stex/lib/make/Makefile.base.in b/macros/latex/contrib/stex/lib/make/Makefile.base.in
new file mode 100644
index 0000000000..e6d3ec01a5
--- /dev/null
+++ b/macros/latex/contrib/stex/lib/make/Makefile.base.in
@@ -0,0 +1,49 @@
+sms: $(MODS.sms)
+
+####################### sTeX utilities ##############################
+
+$(MODS.sms): %.sms: %.tex $(STEXBINDIR)/sms
+ $(SMSPROG) $<
+
+driver: $(DRIVER)
+$(DRIVER): $(MODS) $(MODS.pre) $(MODS.post)
+ cat $(MODS.pre) > $@
+ @echo '\\begin{document}' >> $@
+ @echo '\\tableofcontents\\newpage' >> $@
+# @for d in $(MODS4all); do (echo "\\\begin{omgroup}{File: $$d.tex} \n\\input{$$d}\n\\\end{omgroup}\n\\\newpage\n" >>$@) done
+ @for d in $(MODS4all); do (echo "\\\begin{center}\\LARGE File: \\\url{$$d.tex}\\end{center}" >>$@; echo "\\input{$$d}\\\newpage" >>$@) done
+ cat $(MODS.post) >> $@
+ echo '\\end{document}' >> $@
+
+# these do not work any more
+# graph:
+# $(GRAPHPROG) -o graph -f pdf $(SNIPPATHS) all.tex
+#
+# idtest: $(TARGET)
+# $(STEXBINDIR)/idcheck -q slides.tex
+#
+# struct: $(TARGET)
+# $(STEXBINDIR)/modstr < slides.tex
+#
+# ccheck: $(TARGET)
+# latex slides.tex
+# $(STEXBINDIR)/idcheck slides.tex
+# $(STEXBINDIR)/modstr -s < slides.tex > sstruct
+# cat sstruct
+
+############################# svn #################################
+cleanup:
+ svn $@
+ci:
+ svn $@ -m'draining'
+
+upgrade:
+ svn upgrade
+
+
+############################# cleaning #################################
+clean:
+ rm -Rf $(CLEAN)
+
+distclean: clean
+ rm -Rf $(DISTCLEAN)
diff --git a/macros/latex/contrib/stex/lib/make/Makefile.base.vars b/macros/latex/contrib/stex/lib/make/Makefile.base.vars
new file mode 100644
index 0000000000..ae1d79f348
--- /dev/null
+++ b/macros/latex/contrib/stex/lib/make/Makefile.base.vars
@@ -0,0 +1,30 @@
+#################################### PATHS ###############################
+# the paths can be customized by setting the shell variable STEXDIR appropriately
+STEXSTYDIR = $(STEXDIR)/sty
+STEXBINDIR = $(STEXDIR)/bin
+
+################################# Programs ###############################
+SMSPROG = PERL5LIB=$(STEXDIR)/bin $(STEXDIR)/bin/sms
+GRAPHPROG = PERL5LIB=$(STEXDIR)/bin $(STEXDIR)/bin/sgraph
+
+########################## Conversion and Formatting Targets ###########
+# the TARGET is the set of top-level TeX files that should be formatted or converted.
+# TARGET.parts are separate parts of the target (e.g. included via \input). The TARGET
+# files usually depend on them and they are not Modules (see below).
+# Modules (MODS) are sTeX files without head and tail, so that they can be included
+# into other sTeX files. TARGET can be set by the including Makefile, MODS are
+# computed as as the remaining *.tex files. Some setups have a driver file, which they can
+# specify in the DRIVER variable. If the DRIVER variable is set, then it is re-made
+
+TARGET ?= $(DRIVER)
+MODS ?= $(filter-out tikztemp.tex $(BUTFILES) $(TARGET.parts) $(TARGET) $(LTARGET), $(shell ls *.tex)) $(MODS.extra)
+MODS.sms ?= $(filter-out $(MODS.sms.but), $(MODS:%.tex=%.sms) $(MODS.sms.extra))
+
+# the prefix files or the MODSLIBDIR variable must be specified by the calling Makefile
+MODS.pre ?= $(MODSLIBDIR)/pre.tex
+MODS.post ?= $(MODSLIBDIR)/post.tex
+
+# the modules that should get inputted in all.tex
+MODS4all ?= $(MODS:%.tex=%)
+########################### for cleaning ######################################
+DISTCLEAN += $(MODS.sms)
diff --git a/macros/latex/contrib/stex/lib/make/Makefile.in b/macros/latex/contrib/stex/lib/make/Makefile.in
new file mode 100644
index 0000000000..e3d989874c
--- /dev/null
+++ b/macros/latex/contrib/stex/lib/make/Makefile.in
@@ -0,0 +1,3 @@
+include $(STEXDIR)/lib/make/Makefile.base.in
+include $(STEXDIR)/lib/make/Makefile.latex.in
+include $(STEXDIR)/lib/make/Makefile.latexml.in
diff --git a/macros/latex/contrib/stex/lib/make/Makefile.latex.in b/macros/latex/contrib/stex/lib/make/Makefile.latex.in
new file mode 100644
index 0000000000..282beb40d8
--- /dev/null
+++ b/macros/latex/contrib/stex/lib/make/Makefile.latex.in
@@ -0,0 +1,33 @@
+pdf: sms driver $(TARGET.pdf) $(LTARGET.pdf)
+mpdf: sms $(MODS.pdf)
+# LaTeX build rules:
+#
+# use non-interactive PDFLATEX (see above)
+#
+# _always_ delete pdf on error (otherwise, we end up with a corrupt
+# pdf file and make saying "nothing to do" on the next run )
+#
+# make will delete temporary files (toc,sms,aux) afterwards
+# (FIXME: why? should this be disabled or kept like that?)
+#
+# make pdf depend on its own .toc and .aux and global aux/sms files
+$(TARGET.pdf) $(LTARGET.pdf): %.pdf: %.tex $(MODS) $(TARGET.parts) $(IMG)
+ $(PDFLATEX) $< || $(RM) $@
+ @echo
+ @if (test -e $(patsubst %.tex, %.idx, $<));\
+ then makeindex $(patsubst %.tex, %.idx, $<); fi
+ @echo
+ @if (grep 'Please (re)run Biber' $(patsubst %.dtx, %.log, $(firstword $<)) > /dev/null);\
+ then biber $(patsubst %.tex, %, $(firstword $<));fi
+ @if (grep 'Please (re)run BibTeX' $(patsubst %.dtx, %.log, $(firstword $<)) > /dev/null);\
+ then bibtex $(patsubst %.tex, %, $(firstword $<));fi
+ @echo
+ $(PDFLATEX) $< || $(RM) $@
+ @echo
+ @if (grep Rerun $(patsubst %.tex, %.log, $<) > /dev/null);\
+ then $(PDFLATEX) $< || $(RM) $@; fi
+ @if (grep Rerun $(patsubst %.tex, %.log, $<) > /dev/null);\
+ then $(PDFLATEX) $< || $(RM) $@; fi
+
+$(MODS.pdf): %.pdf: %.tex
+ $(PDFLATEX) -jobname=$(basename $<) "\nonstopmode\input{$(MODS.pre)}\begin{document}\input{$<}\end{document}" || $(RM) $@
diff --git a/macros/latex/contrib/stex/lib/make/Makefile.latex.vars b/macros/latex/contrib/stex/lib/make/Makefile.latex.vars
new file mode 100644
index 0000000000..f41be4d1ee
--- /dev/null
+++ b/macros/latex/contrib/stex/lib/make/Makefile.latex.vars
@@ -0,0 +1,17 @@
+TARGET.pdf = $(TARGET:%.tex=%.pdf)
+LTARGET.pdf = $(LTARGET:%.tex=%.pdf)
+MODS.pdf = $(MODS:%.tex=%.pdf)
+
+####################### Programs #######################
+# pdflatex: use non-interactive switches
+
+PDFLATEX = pdflatex -interaction batchmode -file-line-error
+#PDFLATEX = pdflatex
+
+########################### environment #############################
+TEXINPUTS := .:$(STEXSTYDIR)//:
+
+########################### cleaning #############################
+
+CLEAN += *~ *.log *.blg *.idx *.ilg *.out *.thm *.tmp
+DISTCLEAN += *.dvi *.aux *.toc *.bbl *.ind $(TARGET.pdf)
diff --git a/macros/latex/contrib/stex/lib/make/Makefile.latexml.in b/macros/latex/contrib/stex/lib/make/Makefile.latexml.in
new file mode 100644
index 0000000000..f0e1731df4
--- /dev/null
+++ b/macros/latex/contrib/stex/lib/make/Makefile.latexml.in
@@ -0,0 +1,43 @@
+omdoc: sms $(filter-out all.omdoc,$(TARGET.omdoc))
+mods: sms $(MODS.omdoc)
+
+############################ Running LaTeXML #############################
+$(TARGET.tex.xml): %.tex.xml: %.tex $(TARGET.parts)
+ latexmlc $< $(LTXPATHS) --mode=standard --local --destination=$@ --log=$@.log\
+
+$(TARGET.xml): %.xml: %.tex.xml
+ $(LATEXMLPOST) --destination=$@ $< >& $@.log\
+ || echo "FATAL: latexmlpost crashed with fatal error on $<" > $@.log
+
+$(TARGET.sdomdoc): %.sdomdoc: %.xml $(STEXOXSL)
+ $(STEXXSLT) -o $@ $(STEXOXSL) $<
+
+$(TARGET.omdoc): %.omdoc: %.tex $(TARGET.parts) $(LTSTY) $(STEXOXSL)
+ latexmlc $< $(LTXPATHS) --local --mode=standard\
+ --postdest=$(basename $<).omdoc\
+ --log=$(basename $<).ltxlog --includestyles\
+ --stylesheet=$(STEXOXSL) --nodefaultcss\
+ --stylesheetparam=math-format:$(MATHFORMAT)\
+ --post --openmath --pmml --summary
+
+$(MODS.tex.xml): %.tex.xml: %.tex $(LTSTY)
+ latexmlc --preamble=$(MODS.pre) $< $(LTXPATHS) --local --mode=fragment --destination=$@ --log=$@.log --includestyles
+
+$(MODS.xml): %.xml: %.tex.xml
+ $(LATEXMLPOST) --destination=$@ $< >& $@.log
+
+$(MODS.sdomdoc): %.sdomdoc: %.xml $(STEXOXSL)
+ xsltproc -o $@ $(STEXOXSL) $< >& $@.log
+
+$(MODS.omdoc): %.omdoc: %.tex $(LTSTY) $(STEXOXSL)
+ latexmlc --preamble=$(MODS.pre) $< $(LTXPATHS)\
+ --local --mode=fragment\
+ --postdest=$(basename $<).omdoc\
+ --log=$(basename $<).ltxlog --includestyles\
+ --stylesheet=$(STEXOXSL) --nodefaultcss\
+ --post --openmath --pmml --summary
+
+errlog: latexml.errlog
+
+latexml.errlog: $(MODS.log)
+ grep -i -e error -e Fatal $(MODS.log) > $@ || echo "No errors found" > $@
diff --git a/macros/latex/contrib/stex/lib/make/Makefile.latexml.vars b/macros/latex/contrib/stex/lib/make/Makefile.latexml.vars
new file mode 100644
index 0000000000..4dfb6848ce
--- /dev/null
+++ b/macros/latex/contrib/stex/lib/make/Makefile.latexml.vars
@@ -0,0 +1,48 @@
+#################################### PATHS ###############################
+# the paths can be customized by setting the shell variable STEXDIR appropriately
+STEXXSLDIR = $(STEXDIR)/xsl
+STEXRNCDIR = $(STEXDIR)/rnc
+
+###################### Conversion Programs ###############################
+STEXLTXDIRS = modules statements sproof omtext omdoc sref presentation dcm reqdoc metakeys\
+ mikoslides problem hwexam cmath etc
+
+LTXPATHS = --path=$(STEXSTYDIR) --path=$(STEXDIR)/schema/rng \
+ $(STEXLTXDIRS:%=--path=$(STEXSTYDIR)/%)
+
+LATEXML = latexmlc $(LTXPATHS)
+LATEXMLPOST = latexmlpost --openmath --pmml --nocrossref --noscan --novalidate
+
+MATHFORMAT = om
+STEXXSLT = xsltproc --stringparam math-format $(MATHFORMAT)
+
+STEXOXSL = $(STEXXSLDIR)/omdocpost.xsl
+
+STEXRNG = $(shell ls $(STEXDIR)/rnc/*.rng)
+
+########################## Conversion and Formatting Targets ###########
+# the TARGET is the set of top-level TeX files that should be formatted or converted
+# Modules (MODS) are sTeX files without head and tail, so that they can be included
+# into other sTeX files. TARGET can be set by the including Makefile, MODS are
+# computed as as the remaining *.tex files.
+
+TARGET.tex.xml = $(TARGET:%.tex=%.tex.xml)
+TARGET.xml = $(TARGET:%.tex=%.xml)
+TARGET.omdoc = $(TARGET:%.tex=%.omdoc)
+TARGET.sdomdoc = $(TARGET:%.tex=%.sdomdoc)
+
+MODS.tex.xml = $(MODS:%.tex=%.tex.xml)
+MODS.xml = $(MODS:%.tex=%.xml)
+MODS.omdoc = $(MODS:%.tex=%.omdoc)
+MODS.sdomdoc = $(MODS:%.tex=%.sdomdoc)
+MODS.log = $(shell ls *.ltxlog)
+
+# the prefix files or the MODSLIBDIR variable must be specified by the calling Makefile
+MODS.pre ?= $(MODSLIBDIR)/pre.tex
+MODS.post ?= $(MODSLIBDIR)/post.tex
+
+########################### environment #############################
+TEXINPUTS := $(TEXINPUTS)$(STEXSTYDIR)//:
+
+CLEAN += $(TARGET.xml) $(TARGET.tex.xml) $(MODS.tex.xml) $(MODS.xml)
+DISTCLEAN += $(TARGET.omdoc) $(MODS.omdoc)
diff --git a/macros/latex/contrib/stex/lib/make/Makefile.subdirs b/macros/latex/contrib/stex/lib/make/Makefile.subdirs
new file mode 100644
index 0000000000..6dc774b8d0
--- /dev/null
+++ b/macros/latex/contrib/stex/lib/make/Makefile.subdirs
@@ -0,0 +1,6 @@
+all pdf mpdf driver::
+ @for d in $(MAKEDIRS); do (cd $$d && $(MAKE) -$(MAKEFLAGS) $@) done
+
+clean distclean::
+ @for d in $(CLEANDIRS); do (cd $$d && $(MAKE) -$(MAKEFLAGS) $@) done
+
diff --git a/macros/latex/contrib/stex/lib/make/Makefile.vars b/macros/latex/contrib/stex/lib/make/Makefile.vars
new file mode 100644
index 0000000000..55172aeb3e
--- /dev/null
+++ b/macros/latex/contrib/stex/lib/make/Makefile.vars
@@ -0,0 +1,3 @@
+include $(STEXDIR)/lib/make/Makefile.base.vars
+include $(STEXDIR)/lib/make/Makefile.latex.vars
+include $(STEXDIR)/lib/make/Makefile.latexml.vars
diff --git a/macros/latex/contrib/stex/lib/make/README b/macros/latex/contrib/stex/lib/make/README
new file mode 100644
index 0000000000..78419320a6
--- /dev/null
+++ b/macros/latex/contrib/stex/lib/make/README
@@ -0,0 +1,23 @@
+This directory contains two Makefiles for inclusion into Makefile-based build systems.
+
+file contains
+--------------------------------------------------------------------------------------
+Makefile.base.vars general variable declarations (include before all others)
+Makefile.base.in general rules (include before all others)
+Makefile.latexml.vars variable declarations for the LaTeXML conversion
+Makefile.latexml.in rules for producing OMDoc via LaTeXML
+Makefile.latex.vars variable declarations for LaTeX formatting
+Makefile.latex.in rules for LaTeX formatting
+Makefile.vars combines all *.vars above
+Makefile.in combines all *.in above
+
+The usual setup for this will be to create SVN externals
+- the deployed instance of sTeX (i.e. https://svn.kwarc.info/repos/sTeX/trunk or /latest)
+- to this directory
+and use the lines
+
+STEXDIR = <the sTeX external>
+include $(STEXDIR)/make/Makefile.vars
+include $(STEXDIR)/make/Makefile.in
+
+at appropriate places in the calling Makefile. It is crucial to set STEXDIR variable to make this setup work.