#
# 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.
#
XPMZIP	= icons.zip

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

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

#
# List of PNG targets required.
#
PNGS	= n.png s.png e.png w.png nw.png ne.png sw.png se.png		\
	  sv.png sh.png si.png up.png down.png in.png out.png		\
	  look.png inventory.png wait.png again.png tn.png tp.png	\
	  examine.png take.png drop.png open.png close.png read.png	\
	  save.png restore.png restart.png quit.png

#
# Lists of source XPM files.
#
XPMS	= again.xpm close.xpm compass.xpm down.xpm drop.xpm examine.xpm	\
	  inventory.xpm in.xpm look.xpm missing.xpm open.xpm out.xpm	\
	  quit.xpm read.xpm restart.xpm restore.xpm save.xpm sh.xpm	\
	  si.xpm sv.xpm take.xpm up.xpm wait.xpm tn.xpm tp.xpm
LXPMS	= l_again.xpm l_close.xpm l_drop.xpm l_examine.xpm		\
	  l_inventory.xpm l_in.xpm l_look.xpm l_open.xpm l_out.xpm	\
	  l_quit.xpm l_read.xpm l_restart.xpm l_restore.xpm l_save.xpm	\
	  l_take.xpm l_wait.xpm

# 
# Default target is all PNGs.
#
all: $(PNGS)

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

#
# Compass PNG files.
#
n.png:	compass.pnm
	pnmcut -left 10 -width 12 <$? | pnmcut -top 0 -height 16 | pnmtopng >$@
s.png:	compass.pnm
	pnmcut -left 10 -width 12 <$? | pnmcut -top 16 -height 16 | pnmtopng >$@
w.png:	compass.pnm
	pnmcut -left 0 -width 10 <$? | pnmcut -top 10 -height 12 | pnmtopng >$@
e.png:	compass.pnm
	pnmcut -left 22 -width 10 <$? | pnmcut -top 10 -height 12 | pnmtopng >$@
nw.png:	compass.pnm
	pnmcut -left 0 -width 10 <$? | pnmcut -top 0 -height 10 | pnmtopng >$@
sw.png:	compass.pnm
	pnmcut -left 0 -width 10 <$? | pnmcut -top 22 -height 10 | pnmtopng >$@
ne.png:	compass.pnm
	pnmcut -left 22 -width 10 <$? | pnmcut -top 0 -height 10 | pnmtopng >$@
se.png:	compass.pnm
	pnmcut -left 22 -width 10 <$? | pnmcut -top 22 -height 10 | pnmtopng >$@

#
# Vertical, horizontal, and inactive separators.
#
sv.png:	sv.pnm
	pnmtopng <$? >$@
sh.png:	sh.pnm
	pnmtopng <$? >$@
si.png:	si.pnm
	pnmtopng <$? >$@

#
# Tier control arrows.
#
tn.png:	tn.pnm
	pnmtopng <$? >$@
tp.png:	tp.pnm
	pnmtopng <$? >$@

#
# Up/down arrows.
#
up.png:		up.pnm
	pnmtopng <$? >$@
down.png:	down.pnm
	pnmtopng <$? >$@

#
# In and out icons.
#
in.png:		in.pnm l_in.pnm
	pnmcat -tb in.pnm l_in.pnm | pnmtopng >$@
out.png:	out.pnm l_out.pnm
	pnmcat -tb out.pnm l_out.pnm | pnmtopng >$@

#
# Look, inventory, wait, and again icons.
#
look.png:	look.pnm l_look.pnm
	pnmcat -tb look.pnm l_look.pnm | pnmtopng >$@
inventory.png:	inventory.pnm l_inventory.pnm
	pnmcat -tb inventory.pnm l_inventory.pnm | pnmtopng >$@
wait.png:	wait.pnm l_wait.pnm
	pnmcat -tb wait.pnm l_wait.pnm | pnmtopng >$@
again.png:	again.pnm l_again.pnm
	pnmcat -tb again.pnm l_again.pnm | pnmtopng >$@

#
# Examine, take, drop, open, close, and read icons.
#
examine.png:	examine.pnm l_examine.pnm
	pnmcat -tb examine.pnm l_examine.pnm | pnmtopng >$@
take.png:	take.pnm l_take.pnm
	pnmcat -tb take.pnm l_take.pnm | pnmtopng >$@
drop.png:	drop.pnm l_drop.pnm
	pnmcat -tb drop.pnm l_drop.pnm | pnmtopng >$@
open.png:	open.pnm l_open.pnm
	pnmcat -tb open.pnm l_open.pnm | pnmtopng >$@
close.png:	close.pnm l_close.pnm
	pnmcat -tb close.pnm l_close.pnm | pnmtopng >$@
read.png:	read.pnm l_read.pnm
	pnmcat -tb read.pnm l_read.pnm | pnmtopng >$@

#
# Save, restore, restart, and quit icons.
#
save.png:	save.pnm l_save.pnm
	pnmcat -tb save.pnm l_save.pnm | pnmtopng >$@
restore.png:	restore.pnm l_restore.pnm
	pnmcat -tb restore.pnm l_restore.pnm | pnmtopng >$@
restart.png:	restart.pnm l_restart.pnm
	pnmcat -tb restart.pnm l_restart.pnm | pnmtopng >$@
quit.png:	quit.pnm l_quit.pnm
	pnmcat -tb quit.pnm l_quit.pnm | pnmtopng >$@

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

distclean maintainer-clean: clean
