#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

ROOT    = ..
SHELL   = /bin/sh

#
# Packed XPM icons file, and output PNG images.
#
XPMZIP	= icons.zip
IMAGEZIP= images.zip

#
# Common conversion from XPM to PNM image format.
#
.SUFFIXES:
.SUFFIXES:	.xpm .pnm

.xpm.pnm:
	sed -e 's/None/#dcdcdc/' <$< | xpmtoppm >$@

#
# List of PNG and PIC targets required.
#
PNGS	= vert.png horiz.png idle.png					\
	  first.png last.png next.png prior.png nshort.png pshort.png	\
	  setbm.png gotobm.png auto.png undo.png 			\
	  help.png gpl.png notes.png newbk.png quit.png
IMAGES	= PIC1  PIC2  PIC3  PIC4  PIC5  PIC6  PIC7  PIC8  PIC9  PIC10	\
	  PIC11 PIC12 PIC13 PIC14 PIC15 PIC16 PIC17 PIC18

#
# Lists of source XPM files.
#
XPMS	= vert.xpm horiz.xpm idle.xpm					\
	  first.xpm last.xpm next.xpm prior.xpm nshort.xpm pshort.xpm	\
	  setbm.xpm gotobm.xpm auto.xpm undo.xpm 			\
	  help.xpm gpl.xpm notes.xpm newbk.xpm quit.xpm
LXPMS	= l_top.xpm l_bottom.xpm l_pagedn.xpm l_pageup.xpm l_forward.xpm\
	  l_back.xpm l_marker.xpm l_goto.xpm l_auto.xpm l_undo.xpm 	\
	  l_help.xpm l_license.xpm l_notes.xpm l_open.xpm l_quit.xpm

# 
# Default target is the PIC zip.
#
all: $(IMAGEZIP)

#
# Unpack icon XPM files.
#
$(XPMS) $(LXPMS):	$(XPMZIP)
	unzip -qquL $(XPMZIP) $@

#
# Vertical, horizontal, and inactive separators.
#
vert.png:	vert.pnm
	pnmtopng <$? >$@
horiz.png:	horiz.pnm
	pnmtopng <$? >$@
idle.png:	idle.pnm
	pnmtopng <$? >$@

#
# Toolbar icons.
#
first.png:	first.pnm l_top.pnm
	pnmcat -tb first.pnm l_top.pnm | pnmtopng >$@
last.png:	last.pnm l_bottom.pnm
	pnmcat -tb last.pnm l_bottom.pnm | pnmtopng >$@
next.png:	next.pnm l_pagedn.pnm
	pnmcat -tb next.pnm l_pagedn.pnm | pnmtopng >$@
prior.png:	prior.pnm l_pageup.pnm
	pnmcat -tb prior.pnm l_pageup.pnm | pnmtopng >$@
nshort.png:	nshort.pnm l_forward.pnm
	pnmcat -tb nshort.pnm l_forward.pnm | pnmtopng >$@
pshort.png:	pshort.pnm l_back.pnm
	pnmcat -tb pshort.pnm l_back.pnm | pnmtopng >$@
setbm.png:	setbm.pnm l_marker.pnm
	pnmcat -tb setbm.pnm l_marker.pnm | pnmtopng >$@
gotobm.png:	gotobm.pnm l_goto.pnm
	pnmcat -tb gotobm.pnm l_goto.pnm | pnmtopng >$@
auto.png:	auto.pnm l_auto.pnm
	pnmcat -tb auto.pnm l_auto.pnm | pnmtopng >$@
undo.png:	undo.pnm l_undo.pnm
	pnmcat -tb undo.pnm l_undo.pnm | pnmtopng >$@
help.png:	help.pnm l_help.pnm
	pnmcat -tb help.pnm l_help.pnm | pnmtopng >$@
gpl.png:	gpl.pnm l_license.pnm
	pnmcat -tb gpl.pnm l_license.pnm | pnmtopng >$@
notes.png:	notes.pnm l_notes.pnm
	pnmcat -tb notes.pnm l_notes.pnm | pnmtopng >$@
newbk.png:	newbk.pnm l_open.pnm
	pnmcat -tb newbk.pnm l_open.pnm | pnmtopng >$@
quit.png:	quit.pnm l_quit.pnm
	pnmcat -tb quit.pnm l_quit.pnm | pnmtopng >$@

#
# Copy PNGs to PICs.
#
PIC1:	vert.png
	cp $< $@
PIC2:	horiz.png
	cp $< $@
PIC3:	idle.png
	cp $< $@
PIC4:	first.png
	cp $< $@
PIC5:	last.png
	cp $< $@
PIC6:	next.png
	cp $< $@
PIC7:	prior.png
	cp $< $@
PIC8:	nshort.png
	cp $< $@
PIC9:	pshort.png
	cp $< $@
PIC10:	setbm.png
	cp $< $@
PIC11:	gotobm.png
	cp $< $@
PIC12:	auto.png
	cp $< $@
PIC13:	undo.png
	cp $< $@
PIC14:	help.png
	cp $< $@
PIC15:	gpl.png
	cp $< $@
PIC16:	notes.png
	cp $< $@
PIC17:	newbk.png
	cp $< $@
PIC18:	quit.png
	cp $< $@

#
# Images zip file.
#
$(IMAGEZIP):	$(IMAGES)
	zip $@ $(IMAGES)

#
# Clean up.
#
clean:
	rm -f *.xpm *.pnm *.png PIC*

distclean: clean

maintainer-clean: clean
	rm -rf $(IMAGEZIP)
