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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514
|
#### MAKEFILE CONFIG ####
SHELL = /bin/sh
.SILENT:
.SUFFIXES:
#### BEGIN ####
help:
echo 'UNICODE-MATH makefile targets:'
echo ' '
echo ' help - (this message)'
echo ' ctan - generate archive for CTAN'
echo ' doc - compile documentation inside build/'
echo ' clean - remove build directory and compiled files'
echo ' all - clean & doc & ctan'
echo ' '
echo ' install - install the package into your home texmf tree'
echo ' install-sys - install the package into the system-wide texmf tree'
echo ' (may require administration privileges)'
echo ' install TEXMF=<texmf> - install the package into the path <texmf>'
echo ' '
echo ' check - run the test suite'
echo ' initest - initialise any new tests'
echo ' '
echo ' xfile F=<abc> - compile file <abc> with XeLaTeX'
echo ' lfile F=<abc> - compile file <abc> with LuaLaTeX'
echo ' '
echo ' '
echo 'Append `hometree=none` to any of the above to disable searching
echo 'the home texmf directory.'
echo ' '
echo 'To add a new test, add a file called X****.ltx to'
echo 'directory testfiles/, run `make initest` and ensure'
echo 'that the output X****.safe.pdf is correct.'
echo ' '
echo '`make test` will then compare future compilations of the'
echo 'test file against this original and warn against any changes.'
echo '`make build/X****.diff.pdf` will check a single test.'
echo ' '
echo 'I recommend `make -j4 check` or thereabouts to parallelise'
echo 'the testing.'
#### SETUP ####
# file and folder names:
PKG = unicode-math
TBL = $(PKG)-table.tex
SUITE = $(PKG)-testsuite
XMPL = unimath-example.ltx
SYM = unimath-symbols
COPY = cp -a
MKTEXLSR = mktexlsr
testdir=testfiles
builddir=build
tds=$(builddir)/$(PKG).tds
UPDATE = `which dtx-update` || true # TODO: generalise
SPEAKFAIL := say 'Test failed!' || true # Mac OS X only?
hometree = `kpsewhich -var-value=TEXMFHOME`
# these files end up in the CTAN directory:
PKGSOURCE = $(PKG).dtx $(TBL) Makefile
DOC = $(PKG).pdf $(SUITE).pdf README $(XMPL) $(SYM).pdf
CTANFILES = $(PKGSOURCE) $(XMPL) $(SYM).ltx $(DOC) $(testdir)
BUILDCTAN = $(addprefix $(builddir)/,$(CTANFILES))
BUILDDOC = $(addprefix $(builddir)/,$(DOC))
#
LTXSOURCE = $(PKG).sty $(PKG)-xetex.sty $(PKG)-luatex.sty $(PKG).lua $(TBL)
# and this is how the TDS zip file is produced:
INSFILES = \
$(tds)/tex/latex/$(PKG)/unicode-math.sty \
$(tds)/tex/latex/$(PKG)/unicode-math-xetex.sty \
$(tds)/tex/latex/$(PKG)/unicode-math-luatex.sty \
$(tds)/tex/latex/$(PKG)/unicode-math.lua \
$(tds)/tex/latex/$(PKG)/unicode-math-table.tex
OTHERFILES = \
$(tds)/source/latex/$(PKG)/$(PKG).dtx \
$(tds)/source/latex/$(PKG)/$(SUITE).ltx \
$(tds)/source/latex/$(PKG)/$(SYM).ltx \
$(tds)/source/latex/$(PKG)/Makefile \
$(tds)/source/latex/$(PKG)/$(testdir) \
$(tds)/doc/latex/$(PKG)/unicode-math.pdf \
$(tds)/doc/latex/$(PKG)/unicode-math-testsuite.pdf \
$(tds)/doc/latex/$(PKG)/README \
$(tds)/doc/latex/$(PKG)/$(XMPL) \
$(tds)/doc/latex/$(PKG)/$(SYM).pdf \
TDSFILES = $(INSFILES) $(OTHERFILES)
#### BASICS ####
doc: $(BUILDDOC)
README:
$(XMPL):
clean:
rm -rf $(builddir)/*
rm -f $(PKG).zip $(PKG).pdf $(SUITE).pdf
all: clean doc ctan
#### BUILD FILES
$(builddir)/$(PKG).dtx: $(PKG).dtx
mkdir -p $(builddir)
$(UPDATE)
$(COPY) $< $@
$(builddir)/$(PKG).sty: $(builddir)/$(PKG).dtx
echo "Updating $@"
cd $(builddir) && \
tex $(PKG).dtx > /dev/null ;
$(builddir)/$(PKG).lua: $(builddir)/$(PKG).dtx
echo "Updating $@"
cd $(builddir) && \
tex $(PKG).dtx > /dev/null ;
$(builddir)/$(PKG).pdf: $(builddir)/$(PKG).dtx $(BUILDSOURCE)
cd $(builddir) && \
$(run_xelatex) $(PKG).dtx && \
makeindex -s gind.ist $(PKG) && \
$(run_xelatex) $(PKG).dtx;
$(builddir)/$(SYM).pdf: $(builddir)/$(SYM).ltx
cd $(builddir) && \
$(run_xelatex) $(SYM).ltx && \
$(run_xelatex) $(SYM).ltx;
$(builddir)/%.ltx: $(testdir)/%.ltx
$(COPY) $< $@
$(builddir)/%.tex: $(testdir)/%.tex
$(COPY) $< $@
$(builddir)/$(testdir): $(testdir)
$(COPY) $< $@
$(builddir)/%: %
$(COPY) $< $@
$(builddir)/README: $(builddir)/README.markdown
mv -f $< $@
##### CTAN INSTALLATION #####
TDS = $(builddir)/$(PKG).tds.zip
tds: $(TDS)
$(TDS): $(tds)/$(PKG).tds.zip
$(COPY) $< $@
$(tds)/$(PKG).tds.zip: $(TDSFILES)
cd $(tds); \
zip -r $(PKG).tds.zip ./* -x *.DS_Store -x *.safe.pdf *.ignore.pdf
ctan: $(BUILDCTAN) tds
cd $(builddir); \
zip -r \
../$(PKG).zip $(CTANFILES) $(PKG).tds.zip \
-x *.DS_Store -x *.safe.pdf *.ignore.pdf
$(tds)/doc/latex/$(PKG)/% \
$(tds)/tex/latex/$(PKG)/% \
$(tds)/source/latex/$(PKG)/% : $(builddir)/%
mkdir -p $(shell dirname $@)
$(COPY) $< $@
$(tds)/source/latex/$(PKG)/$(testdir):
$(COPY) $(testdir) $(tds)/source/latex/$(PKG)/
##### LOCAL TEXMF INSTALLATION #####
TEXMFHOME=$(shell kpsewhich --var-value TEXMFHOME)
TEXMFLOCAL=$(shell kpsewhich --var-value TEXMFLOCAL)
install: $(INSFILES)
if test -n "$(TEXMFHOME)" ; then \
echo "Installing in '$(TEXMFHOME)'."; \
$(COPY) $(tds)/* $(TEXMFHOME) && $(MKTEXLSR); \
else \
echo "Cannot locate your home texmf tree. Specify manually with\n\n make install TEXMFHOME=/path/to/texmf\n" ; \
false ; \
fi ;
install-sys: $(INSFILES)
if test -n "$(TEXMFLOCAL)" ; then \
echo "Installing in '$(TEXMFLOCAL)'."; \
$(COPY) $(tds)/* $(TEXMFLOCAL) && $(MKTEXLSR); \
else \
echo "Cannot locate your system-wide local texmf tree. Specify manually with\n\n make install TEXMFLOCAL=/path/to/texmf\n" ; \
false ; \
fi ;
run_xelatex = export TEXMFHOME=$(hometree) && xelatex
run_lualatex = export TEXMFHOME=$(hometree) && lualatex
##### USEFUL FOR TEST FILES #####
xfile: $(F) $(BUILDSOURCE)
if test -z "$(F)" ; then \
echo "Typesetting test.tex:"; \
$(COPY) test.tex $(builddir)/test.tex; \
cd $(builddir); $(run_xelatex) test.tex; \
else \
echo Typesetting $(F):; \
$(COPY) $(F) $(builddir)/$(F); \
cd $(builddir); $(run_xelatex) $(F); \
fi
lfile: $(F) $(BUILDSOURCE)
if test -z "$(F)" ; then \
echo "Typesetting test.tex:"; \
$(COPY) test.tex $(builddir)/test.tex; \
cd $(builddir); $(run_lualatex) test.tex; \
else \
echo Typesetting $(F):; \
$(COPY) $(F) $(builddir)/$(F); \
cd $(builddir); $(run_lualatex) $(F); \
fi
#############
# TESTSUITE #
#############
#### Needed to compile and make stuff ####
builddir=build
testdir=testfiles
lprefix=L
xprefix=X
both=F
NAME=unicode-math
COPY = cp -a
MOVE = mv -f
COMPARE_OPTS = -density 300x300 -metric ae -fuzz 35%
# Redefine this to print output if you need:
REDIRECT = > /dev/null
LTXSOURCE = $(NAME).sty $(NAME)-xetex.sty $(NAME)-luatex.sty $(NAME).lua
TESTLIST = umtest-suite-X.tex umtest-suite-L.tex umtest-suite-F.tex
SUITESOURCE = $(addprefix $(testdir)/,umtest-preamble.tex $(TESTLIST))
TESTOUT = $(wildcard $(testdir)/*.safe.pdf)
BUILDTESTSRC = $(subst $(testdir)/,$(builddir)/,$(subst .safe.pdf,.ltx,$(TESTOUT)))
BUILDTESTTARGET1 = $(TESTOUT)
BUILDTESTTARGET2 = $(subst $(testdir)/,$(builddir)/,$(BUILDTESTTARGET1))
BUILDTESTTARGET3 = $(subst .Xsafe.pdf,-X.diff.pdf,$(BUILDTESTTARGET2))
BUILDTESTTARGET4 = $(subst .Lsafe.pdf,-L.diff.pdf,$(BUILDTESTTARGET3))
BUILDTESTTARGET5 = $(subst .safe.pdf,.diff.pdf,$(BUILDTESTTARGET4))
BUILDTESTTARGET = $(BUILDTESTTARGET5)
BUILDSOURCE = $(addprefix $(builddir)/,$(LTXSOURCE))
BUILDSUITE = $(subst $(testdir)/,$(builddir)/,$(SUITESOURCE))
BUILDFILES = $(BUILDSOURCE) $(BUILDSUITE) $(BUILDTESTSRC) $(BUILDTESTTARGET)
# Test suite PDF
$(builddir)/$(SUITE).pdf: $(builddir)/$(SUITE).ltx $(BUILDSUITE)
cd $(builddir) && \
$(run_xelatex) $(SUITE).ltx
#### All tests ####
check: $(TESTLIST)
$(TESTLIST): $(BUILDFILES)
cd $(testdir) && \
ls X*.safe.pdf | sed -e 's/\(.*\).safe.pdf/\\inserttest{\1}/g' > umtest-suite-X.tex && \
ls L*.safe.pdf | sed -e 's/\(.*\).safe.pdf/\\inserttest{\1}/g' > umtest-suite-L.tex && \
ls F*-L.safe.pdf | sed -e 's/\(.*\).safe.pdf/\\inserttest{\1}/g' > umtest-suite-F.tex;
$(builddir)/%: $(testdir)/%
@mkdir -p $(builddir); \
$(COPY) $< $@
$(builddir)/%: %
@mkdir -p $(builddir); \
$(COPY) -f $< $@
#### Generating new tests ####
lonelystub = $(shell cd $(testdir); ls | egrep '[XL].(.*\.ltx)$$|[XL].(.*\.safe\.pdf)$$' | cut -d . -f 1 | uniq -u )
lonelyfile = $(addsuffix .safe.pdf,$(lonelystub))
lonelypath = $(addprefix $(testdir)/,$(lonelyfile))
lonelytest = $(addprefix $(builddir)/,$(addsuffix .pdf,$(lonelystub)))
Xlonelystub = $(shell cd $(testdir); ls | egrep -o '(F.*\.ltx)$$|(F.*-X\.safe\.pdf)$$' | sed -e s/-X.safe.pdf// -e s/.ltx// | uniq -u | uniq )
Xlonelyfile = $(addsuffix -X.safe.pdf,$(Xlonelystub))
Xlonelypath = $(addprefix $(testdir)/,$(Xlonelyfile))
Xlonelytest = $(addprefix $(builddir)/,$(addsuffix -X.pdf,$(Xlonelystub)))
Llonelystub = $(shell cd $(testdir); ls | egrep -o '(F.*\.ltx)$$|(F.*-L\.safe\.pdf)$$' | sed -e s/-L.safe.pdf// -e s/.ltx// | uniq -u | uniq )
Llonelyfile = $(addsuffix -L.safe.pdf,$(Llonelystub))
Llonelypath = $(addprefix $(testdir)/,$(Llonelyfile))
Llonelytest = $(addprefix $(builddir)/,$(addsuffix -L.pdf,$(Llonelystub)))
initest: $(lonelypath) $(Xlonelypath) $(Llonelypath)
$(lonelypath): $(lonelytest)
$(COPY) `echo $@ | sed -e s/$(testdir)/$(builddir)/ -e s/.safe.pdf/.pdf/` $@
$(Xlonelypath): $(Xlonelytest)
$(COPY) `echo $@ | sed -e s/$(testdir)/$(builddir)/ -e s/-X.safe.pdf/-X.pdf/` $@
$(Llonelypath): $(Llonelytest)
$(COPY) `echo $@ | sed -e s/$(testdir)/$(builddir)/ -e s/-L.safe.pdf/-L.pdf/` $@
#### TESTS FOR BOTH ENGINES ####
$(builddir)/F%-L.diff.pdf: $(builddir)/F%-L.pdf
@echo 'F$*: Comparing PDF from LuaLaTeX against reference output.'
compare_result="$$(compare "$(builddir)/F$*-L.pdf" "$(testdir)/F$*-L.safe.pdf" $(COMPARE_OPTS) "$(builddir)/F$*-L.diff.pdf" 2>&1)" ; \
if [ 0 -eq "$$?" -a 1 -ge "$$compare_result" ] ; \
then \
echo 'F$*: Test passed.' ; \
else \
echo 'F$*: Test failed.' ; \
$(SPEAKFAIL) ; \
false ; \
fi
$(builddir)/F%-X.diff.pdf: $(builddir)/F%-X.pdf
@echo 'F$*: Comparing PDF from XeLaTeX against reference output.'
compare_result="$$(compare "$(builddir)/F$*-X.pdf" "$(testdir)/F$*-X.safe.pdf" $(COMPARE_OPTS) "$(builddir)/F$*-X.diff.pdf" 2>&1)" ; \
if [ 0 -eq "$$?" -a 1 -ge "$$compare_result" ] ; \
then \
echo 'F$*: Test passed.' ; \
else \
echo 'F$*: Test failed.' ; \
$(SPEAKFAIL) ; \
false ; \
fi
$(builddir)/F%-L.pdf: $(BUILDSOURCE) $(builddir)/F%-L.ltx
@echo 'F$*: Generating PDF output with LuaLaTeX.'
@cd $(builddir); $(run_lualatex) -interaction=nonstopmode F$*-L.ltx $(REDIRECT)
$(builddir)/F%-X.pdf: $(BUILDSOURCE) $(builddir)/F%-X.ltx
@echo 'F$*: Generating PDF output with XeLaTeX.'
@cd $(builddir); $(run_xelatex) -interaction=nonstopmode F$*-X.ltx $(REDIRECT)
$(builddir)/F%-L.ltx: $(builddir)/F%.ltx
$(COPY) $< $@
$(builddir)/F%-X.ltx: $(builddir)/F%.ltx
$(COPY) $< $@
#### TEST FOR EACH ENGINE INDIVIDUALLY ####
$(builddir)/L%.diff.pdf: $(builddir)/L%.pdf
@echo 'L$*: Comparing PDF against reference output.'
compare_result="$$(compare "$(builddir)/L$*.pdf" "$(testdir)/L$*.safe.pdf" $(COMPARE_OPTS) "$(builddir)/L$*.diff.pdf" 2>&1)" ; \
if [ 0 -eq "$$?" -a 1 -ge "$$compare_result" ] ; \
then \
echo 'L$*: Test passed.' ; \
else \
echo 'L$*: Test failed.' ; \
$(SPEAKFAIL) ; \
false ; \
fi
$(builddir)/X%.diff.pdf: $(builddir)/X%.pdf
@echo 'X$*: Comparing PDF against reference output.'
compare_result="$$(compare "$(builddir)/X$*.pdf" "$(testdir)/X$*.safe.pdf" $(COMPARE_OPTS) "$(builddir)/X$*.diff.pdf" 2>&1)" ; \
if [ 0 -eq "$$?" -a 1 -ge "$$compare_result" ] ; \
then \
echo 'X$*: Test passed.' ; \
else \
echo 'X$*: Test failed.' ; \
$(SPEAKFAIL) ; \
false ; \
fi
$(builddir)/X%.pdf: $(BUILDSOURCE) $(BUILDSUITE) $(builddir)/X%.ltx
@echo 'X$*: Generating PDF output with XeLaTeX.'
@cd $(builddir) && $(run_xelatex) -interaction=nonstopmode X$*.ltx $(REDIRECT)
$(builddir)/L%.pdf: $(BUILDSOURCE) $(BUILDSUITE) $(builddir)/L%.ltx
@echo 'L$*: Generating PDF output with LuaLaTeX.'
@cd $(builddir) && $(run_lualatex) -interaction=nonstopmode L$*.ltx $(REDIRECT)
#### HACK: allow `make <foobar>` run that test.
L%: build/L%.ltx
make build/L$*.diff.pdf
X%: build/X%.ltx
make build/X$*.diff.pdf
F%: build/F%.ltx
make build/F$*-L.diff.pdf
make build/F$*-X.diff.pdf
############################
###### NIGHTLY BUILDS ######
############################
UNAME_S := $(shell uname -s)
# Mac OS X:
ifeq ($(UNAME_S),Darwin)
MD5 = md5
endif
# Linux:
ifeq ($(UNAME_S),Linux)
MD5 = md5sum
endif
BRANCH = tdsbuild
TMP = /tmp
LOG = $(TMP)/gitlog.tmp
checkbranch:
@if git branch | grep $(BRANCH) > /dev/null ; \
then echo "TDS branch exists"; \
else \
echo "TDS branch does not exist; doing so will remove all untracked files from your working directory. Create the TDS branch with\n make createbranch"; \
false; \
fi;
createbranch: $(TDS)
cp -f $(TDS) $(TMP)/
git symbolic-ref HEAD refs/heads/$(BRANCH)
rm .git/index
git clean -fdx
unzip -o $(TMP)/$(TDS) -d .
rm $(TMP)/$(TDS)
git add --all
git commit -m "Initial TDS commit"
git checkout master
git push origin $(BRANCH) master
@echo "\nTDS branch creation was successful.\n"
@echo "Now create a new package at TLContrib: http://tlcontrib.metatex.org/"
@echo "Use the following metadata:"
@echo " Package ID: $(PKG)"
@echo " BRANCH: $(BRANCH)"
@echo "\nAfter this process, use \`make tdsbuild\` to"
@echo " (a) push your recent work on the master branch,"
@echo " (b) automatically create a TDS snapshot,"
@echo " (c) send the TDS snapshot to TLContrib."
ifeq ($(UNAME_S),Darwin)
tlclogin: USERNAME = $(shell security find-internet-password -s tlcontrib.metatex.org | grep "acct" | cut -f 4 -d \")
tlclogin: PASSWORD = $(shell security 2>&1 >/dev/null find-internet-password -gs tlcontrib.metatex.org | cut -f 2 -d ' ')
endif
ifeq ($(UNAME_S),Linux)
tlclogin: USERNAME = ""
tlclogin: PASSWORD = ""
endif
tlclogin: VERSION = $(shell date "+%Y-%m-%d@%H:%M")
tlclogin: ;
tdsbuild: checkbranch tlclogin $(TDS)
cp -f $(TDS) $(TMP)/
@echo "Constructing commit history for snapshot build"
date "+TDS snapshot %Y-%m-%d %H:%M" > $(LOG)
echo '\n\nApproximate commit history since last snapshot:\n' >> $(LOG)
git log --after="`git log -b $(BRANCH) -n 1 --pretty=format:"%aD"`" --pretty=format:"%+H%+s%+b" >> $(LOG)
@echo "Committing TDS snapshot to separate branch"
git checkout $(BRANCH)
unzip -o $(TMP)/$(TDS) -d .
rm $(TMP)/$(TDS)
git commit --all --file=$(LOG)
git clean -df
@echo "Pushing TDS and master branch"
git checkout master
git push origin $(BRANCH) master
@echo "Pinging TLContrib for automatic update"
curl http://tlcontrib.metatex.org/cgi-bin/package.cgi/action=notify/key=$(PKG)/check=$(shell echo $(USERNAME)/$(PASSWORD)/$(VERSION) | $(MD5) )?version=$(VERSION) > /dev/null 2>&1
|