summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 48560bb98a6b4d0706c0a75b1449d07a051e4dc6 (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
# $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 -channel RGBA -density 196 $(2) -resample 72 -geometry 800x600 -trim +repage -flatten $(1)
endef
	#convert $(2) -geometry 800x600 -quality 100 -depth 24 -weight 10 -render -flatten $(1)

# 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
	

.DEFAULT_GOAL := book.html