summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 39c5af1511be4bf788d9e56cb7387eef5e40ed38 (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
# $Id$

chapters := $(wildcard chapter_*.xml)

imgs_ps := $(wildcard ps-imgs/*.eps)
imgs_png := $(addsuffix .png,$(addprefix png/,$(basename $(notdir $(imgs_ps)))))


list_imgs:
	@echo $(imgs_ps)
	@echo $(imgs_png)

define png_template
$(1): $(2)
	mkdir -p $(CWD)png && \
	convert $(2) -antialias -flatten $(1)
endef

# this is a little voodoo, to iterate over the *.eps files, 
# and create a make target of the png output name, that will
# build those *.png files
# :) --vbatts
$(foreach ps,$(imgs_ps),$(eval $(call png_template,$(addsuffix .png,$(addprefix png/,$(basename $(notdir $(ps))))),$(ps))))

images: $(imgs_png)

book.html: build.sh main.xml $(chapters) $(imgs_png) .clean.html
	sh build.sh && \
	ls -l $@

book.pdf: main.xml $(chapters) $(imgs_png) .dblatex .clean.pdf
	dblatex \
		--pdf \
		-x'-xinclude' \
		-o $@ \
		$<

view.pdf: book.pdf
	xdg-open $<

view.html: book.html
	xdg-open $<

.dblatex:
	$(shell which dblatex 2>/dev/null >/dev/null || echo "ERROR: 'dblatex' REQUIRED, SEE http://github.com/vbatts/SlackBuilds/ FOR THE SlackBuild")


.PHONY: .clean.html
.clean.html:
	rm -f book.html

.PHONY: .clean.pdf
.clean.pdf:
	rm -f book.pdf

.PHONY: .clean.images
.clean.images:
	rm -fr png/

.PHONY: clean
clean: .clean.pdf .clean.html .clean.images
	

.DEFAULT_GOAL := book.html