.POSIX:
.SUFFIXES:
.SUFFIXES: .txt .html

V=         0
include    Makefile.silent

ASCIIDOC=  asciidoc
WGET=      wget -O
SED=       sed
RM=        rm -f
MV=        mv

ASCIIDOC_FLAGS=

NULL=
all_htmls= slides.html
all_icons= images/icons/note.png
all_shots= \
	images/sponsored-badge-shadow.png			\
	images/Epiphany-Downloading.png				\
	images/Epiphany-Extracting.png 				\
	images/Epiphany-Extraction-Finished.png			\
	images/Epiphany-Upload-Dialog.png			\
	images/Evolution-Attachment-Save-Dialog.png		\
	images/Evolution-Attachment-Load-Creating.png		\
	images/Evolution-Attachment-Load-Creation-Finished.png	\
	images/Empathy-Creating-Progress.png			\
	images/Empathy-Extracting-Archives.png			\
	images/Autoar-FormatFilter-Simple.png			\
	images/Autoar-FormatFilter-Advanced.png			\
	$(NULL)
all_logos= \
	logos/freebsd.png	\
	logos/libtool.jpg	\
	logos/gnome.png		\
	logos/gnome-asia.png	\
	logos/webkit.png	\
	$(NULL)

gsoc_main= https://wiki.gnome.org/Outreach/SummerOfCode/2013/Projects/TingWeiLan_GnomeArchives?action=AttachFile&do=get&target=

.txt.html:
	$(AT_ASCIIDOC)$(ASCIIDOC) $(ASCIIDOC_FLAGS) -o "tmp-$@" "$<"
	$(AT_SED)sed -f fonts.sed "tmp-$@" > "$@"
	@$(RM) "tmp-$@"

all: $(all_icons) $(all_shots) $(all_logos) $(all_htmls)
clean:
	$(RM) $(all_htmls) tmp-* *.html

images/icons/note.png:
	-mkdir -p images logos
	cp -r $$(dirname $$(which asciidoc))/../etc/asciidoc/images/icons images/ || \
	cp -r $$(dirname $$(which asciidoc))/../../etc/asciidoc/images/icons images/ || \
	cp -r $$(dirname $$(which asciidoc))/../../../etc/asciidoc/images/icons images/ || \
	cp -r $$(dirname $$(which asciidoc))/../share/asciidoc/images/icons images/ || \
	cp -r $$(dirname $$(which asciidoc))/../../share/asciidoc/images/icons images/ || \
	cp -r $$(dirname $$(which asciidoc))/../../../share/asciidoc/images/icons images/ || \
	false


images/sponsored-badge-shadow.png:
	$(WGET) $@ "https://wiki.gnome.org/Travel/Policy?action=AttachFile&do=get&target=sponsored-badge-shadow.png"
images/Epiphany-Downloading.png:
	$(WGET) $@ "$(gsoc_main)$$(basename $@)"
images/Epiphany-Extracting.png:
	$(WGET) $@ "$(gsoc_main)$$(basename $@)"
images/Epiphany-Extraction-Finished.png:
	$(WGET) $@ "$(gsoc_main)$$(basename $@)"
images/Epiphany-Upload-Dialog.png:
	$(WGET) $@ "$(gsoc_main)$$(basename $@)"
images/Evolution-Attachment-Save-Dialog.png:
	$(WGET) $@ "$(gsoc_main)$$(basename $@)"
images/Evolution-Attachment-Load-Creating.png:
	$(WGET) $@ "$(gsoc_main)$$(basename $@)"
images/Evolution-Attachment-Load-Creation-Finished.png:
	$(WGET) $@ "$(gsoc_main)$$(basename $@)"
images/Empathy-Creating-Progress.png:
	$(WGET) $@ "$(gsoc_main)$$(basename $@)"
images/Empathy-Extracting-Archives.png:
	$(WGET) $@ "$(gsoc_main)$$(basename $@)"
images/Autoar-FormatFilter-Simple.png:
	$(WGET) $@ "$(gsoc_main)$$(basename $@)"
images/Autoar-FormatFilter-Advanced.png:
	$(WGET) $@ "$(gsoc_main)$$(basename $@)"
logos/freebsd.png:
	$(WGET) $@ http://www.freebsd.org/logo/logo-full.png
logos/libtool.jpg:
	$(WGET) $@ https://www.gnu.org/graphics/libtool.jpg
logos/gnome.png:
	$(WGET) $@ https://people.gnome.org/~engagement/logos/GnomeLogoVertical.png
logos/gnome-asia.png:
	$(WGET) $@ http://2014.gnome.asia/static/img/logo.jpg
logos/webkit.png:
	$(WGET) $@ http://www.webkit.org/images/icon-gold.png
