#!/usr/bin/make -f
%:
	dh $@

P=ttf-ancient-fonts
V=2.57
U=http://users.teilar.gr/~g1951d/
Z=Aegean600.zip \
  Aegyptus313.zip \
  Gardiner313.zip \
  Symbola605.zip \
  Alfios.zip \
  Aroania.zip \
  Alexander.zip \
  Anaktoria.zip \
  Avdira.zip \
  Atavyros.zip \
  Analecta306.zip \
  Musica306.zip \
  Akkadian256.zip \
  Anatolian306.zip \
  Maya106.zip \
  Unidings605.zip

get-orig-source:
	for f in $(Z) ; do \
		wget -O $$f $(U)$$f ; \
		# Some files are duplicated so we need -o \
		unzip -o -d $(P)-$(V).orig $$f ; \
		rm -f $$f ; \
	done
	# We prefer UTF-8 LF text files, convert them using iconv, tr
	find $(P)-$(V).orig -iname '*.txt' -print0 | xargs -0 -I_ sh -c "iconv -f UTF-16 -t UTF-8 _ | tr -d '\r' > _.tmp && mv _.tmp _"
	# PDFs are produced using Microsoft Word and no
	# Word files (source code) are published for them
	# so we have to remove them as per DFSG item 2.
	rm -f $(P)-$(V).orig/*.pdf
	tar zcf $(P)_$(V).orig.tar.gz $(P)-$(V).orig
	rm -rf $(P)-$(V).orig
