## Process this file with automake to produce Makefile.in

## Making a release: see README.developer

ACLOCAL_AMFLAGS = -I m4

## Build this directory before its children (required, since test programs
## link against ../libdvi2bitmap.la).  This results in the test programs
## always being built, rather than at 'make check' time, but it appears
## to be necessary in order for 'make check' and 'make dist' to include
## the test directory.
SUBDIRS = . doc test

lib_LTLIBRARIES = libdvi2bitmap.la
D2BHEADERS = \
	Bitmap.h \
	BitmapImage.h \
	DviError.h \
	DviFile.h \
	DviFilePosition.h \
	InputByteStream.h \
	FileByteStream.h \
	PipeStream.h \
	PageRange.h \
	PkFont.h \
	Util.h \
	XBMBitmap.h \
	XPMBitmap.h \
	Byte.h \
	getopt_long.h \
	stringstream.h \
	version.h \
	verbosity.h
libdvi2bitmap_la_SOURCES = \
	Bitmap.cc \
	BitmapImage.cc \
	DviError.cc \
	DviFile.cc \
	DviFilePosition.cc \
	InputByteStream.cc \
	FileByteStream.cc \
	PipeStream.cc \
	PageRange.cc \
	PkFont.cc \
	Util.cc \
	XBMBitmap.cc \
	XPMBitmap.cc \
	$(D2BHEADERS)
EXTRA_libdvi2bitmap_la_SOURCES = \
	GIFBitmap.cc \
	GIFBitmap.h \
	PNGBitmap.cc \
	PNGBitmap.h \
	KarlPathSearcher.cc \
	KarlPathSearcher.h
EXTRALO=@EXTRALO@
libdvi2bitmap_la_LIBADD = $(EXTRALO) $(LTLIBOBJS) -lm
libdvi2bitmap_la_DEPENDENCIES = $(EXTRALO) $(LTLIBOBJS)
libdvi2bitmap_la_LDFLAGS = -version-info @libdvi2bitmap_la_version_info@

bin_PROGRAMS = dvi2bitmap dvireport
dvi2bitmap_SOURCES = dvi2bitmap.cc
dvi2bitmap_LDADD = libdvi2bitmap.la
dvireport_SOURCES = dvireport.cc
dvireport_LDADD = libdvi2bitmap.la

man1_MANS = dvi2bitmap.1 dvireport.1

# OS X tar inserts HFS+ rubbish unless we stop it.
# However there seems no way to stop it doing so, short of
# setting COPYFILE_DISABLE=1 in the environment when we 'make dist'
#AMTAR=COPYFILE_DISABLE=1 tar ### <-- doesn't work

# Special handling for distribution
EXTRA_DIST = $(libdocdir) $(man1_MANS) README LICENCE doc/doc.html doc/doc.img doc/style.css

# Generate library documentation using Doxygen.
# If it's not available, just touch a stamp file in the right directory.
# The configure.ac sets DOXYGEN to NO_DOXYGEN if it's not found.
libdocdir = @DOXYGEN_OUTPUT_DIRECTORY@
DOXYGEN=@DOXYGEN@
$(libdocdir): Doxyfile
	if test -d $(libdocdir); then \
	  rm -Rf $(libdocdir); \
	fi
	if test "$(DOXYGEN)" != NO_DOXYGEN; then \
	  $(DOXYGEN); \
	else \
	  mkdir $(libdocdir); \
	  echo "No doxygen available -- library documentation not generated" >$(libdocdir)/stamp; \
	fi

doc/doc.html: version.sed
	cd doc; $(MAKE) doc.html 
test/sampler.tar:
	cd test; make sampler.tar

# Sync the generated docs to the sourceforge project pages at
# http://dvi2bitmap.sourceforge.net/
sourceforge-sync: dvi2bitmap-webpage/index.html
	rsync -avzP --delete -e ssh dvi2bitmap-webpage/ normang,dvi2bitmap@web.sourceforge.net:htdocs

# An alternative way of bundling the distribution
# (use sourceforge-sync for preference)
webpage-tarball.tar: dvi2bitmap-webpage/index.html
	cd dvi2bitmap-webpage; tar cf ../$@ .

dvi2bitmap-webpage/index.html: \
		html/index.html \
		doc/doc.html \
		test/sampler.tar \
		$(libdocdir) \
		version.sed
	rm -Rf dvi2bitmap-webpage
	mkdir dvi2bitmap-webpage
	cp html/style.css doc/doc.html dvi2bitmap-webpage
	sed -e '/include:AUTHORS/r AUTHORS' -f version.sed html/index.html >dvi2bitmap-webpage/index.html
#	cd dvi2bitmap-webpage; tar xzf ../doc/dvi2bitmap-docs.tar.gz
	cd dvi2bitmap-webpage; tar xf ../test/sampler.tar
	pax -r -w $(libdocdir) dvi2bitmap-webpage

README: README.md version.sed
	rm -f $@
	sed -f version.sed README.md >$@.tmp && mv $@.tmp $@

version.sed: .hg Makefile
	rm -f version.sed
	{ hg parent --template 'if test {latesttagdistance} -eq 0 -a "x{latesttag}" = "x$(VERSION)"; then echo s,@VERSION''@,$(VERSION),; else echo s,@VERSION''@,{node|short},; fi' | sh; \
	  hg parent --template 's/@VCSINFO''@/Mercurial revision {node|short}, {date|isodate}, tag {latesttag} + {latesttagdistance}/\ns,@RELEASEDATE''@,{date(date,"%Y %B %d")},\n'; \
	} >version.sed.tmp && mv version.sed.tmp version.sed

# Version: The reported version is obtained from the most recent
# Mercurial tag IFF that was attached to the last tagged
# version.
version.h: version.sed
	rm -f version.h
	echo 'const char version_string[] = "dvi2bitmap version @VERSION''@, @RELEASEDATE''@";' | sed -f version.sed >version.h
