-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·96 lines (79 loc) · 3.4 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
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
.PHONY: all clean diff checkversion main-all-prev main-all dist
ifeq ($(OS),Windows_NT)
RM = del /Q
CP = xcopy /-Y /D
MKDIR = mkdir
PYTHON = c:\python27\python
else
RM = rm -Rf
CP = cp -i -u
MKDIR = mkdir -p
PYTHON = python2
endif
ifneq ("$(wildcard main-diff.tex)","")
MAIN_DIFF = 1
endif
# LaTeX representation of Doxygen API documentation
DOXYLATEX:= $(wildcard api/altlatex/*.tex)
# Used to pass information to listings package (e.g., which function names
# should be emphasized)
LISTINGS:=api/altlatex/listings.tex
# Commands that allow LaTeX to include a C function by providing its name
EXAMPLES:=examples/altlatex/lstinputfunlisting.tex
# Temporary directory where to copy intermediate files before distribution
DISTNAME:=hsa_runtime_$(HSA_VERSION)
TMPDIST:=public/$(DISTNAME)
all : main.pdf
diff : main-diff.pdf
checkversion :
$(if $(HSA_VERSION),,$(error Error: variable HSA_VERSION is not set))
# Generate the public files
# syntax: make HSA_VERSION=<current version, any string will do> COMMIT=<hash corresponding to previous version>
# Ex: make dist HSA_VERSION=1_1_20151231 COMMIT=26862995d24908be0e7a870e71807b8a7d6c1996
dist : checkversion diff main.pdf
$(MKDIR) $(TMPDIST)/include/hsa
$(CP) main.pdf $(TMPDIST)/$(DISTNAME).pdf
$(CP) main-diff.pdf $(TMPDIST)/$(DISTNAME)_diff.pdf
$(CP) main-all.tex $(TMPDIST)/$(DISTNAME).tex
$(CP) ChangeLog $(TMPDIST)
$(CP) api/hsa.h $(TMPDIST)/include/hsa
$(CP) api/hsa_ext.h $(TMPDIST)/include/hsa
$(CP) api/hsa_brig.h $(TMPDIST)/include/hsa
cd public && zip -r -9 $(DISTNAME) $(DISTNAME)
$(RM) $(TMPDIST)
%.pdf: $(EXAMPLES) $(LISTINGS) %.tex
latexmk -halt-on-error -g -xelatex -use-make $*.tex
$(EXAMPLES): example/examples.cc example/lstinputfunlisting.py
cd example && doxygen Doxyfile
cd example && $(PYTHON) lstinputfunlisting.py
# Use listings.tex as proxy for all the automatically generated LaTeX files
$(LISTINGS): api/hsa.h api/hsa_ext.h api/xml2tex.py
cd api && doxygen Doxyfile
cd api && $(PYTHON) xml2tex.py
# Diff previous and current version of the document. The result is another Latex
# file. The current version is expected to be named main-all.tex
main-diff.tex: main-all-prev main-all.tex
./latexdiff-1.1.0-so.pl -t UNDERLINE --append-safecmd="hypertarget,hyperlink,reffun,refarg,reffld,reftyp,refenu,refhsl" --exclude-textcmd="chapter,section,subsection,subsubsection" --config="PICTUREENV=(?:picture|DIFnomarkup|tikzpicture|lstlisting|figure)[\w\d*@]*" main-all-prev.tex main-all.tex > main-diff.tex
main-all-prev:
$(MKDIR) $(COMMIT)
git --work-tree=$(COMMIT) checkout $(COMMIT) -- .
cd $(COMMIT) && make main-all.tex
$(CP) $(COMMIT)/main-all.tex main-all-prev.tex
$(RM) $(COMMIT)
# Generate one Latex file out of resolving all \include tags in a given main
# file. This is is needed because `latexdiff --flatten` requires all included
# files to be in the same directory as the main doc.
main-all.tex: $(EXAMPLES) $(LISTINGS) main.tex listingexpand.py
latexpand main.tex > main-all.tex
$(PYTHON) listingexpand.py main-all.tex
clean:
@latexmk -silent -C main
@$(RM) main-all.tex
@$(RM) main-all-prev.tex
@$(RM) main-all-new.tex
# latexdiff fails if the specified tex input does not exist, but the
# diff file only exists if 'make diff' was previously invoked.
$(if $(MAIN_DIFF),@latexmk -silent -C main-diff,)
@$(RM) main-diff.tex
# Manually clean Doxygen and xml2tex output
@cd api && $(RM) xml && $(RM) altlatex