#C- This program is free software; you can redistribute it and/or
#C- modify it under the terms of the GNU General Public License,
#C- either version 2 of the license or (at your option) any later
#C- version. The license should have accompanied the program
#C- or you may obtain a copy of the license from the Free Software
#C- Foundation at http://www.fsf.org.
#C-
#C- This program is distributed in the hope that it will be useful,
#C- but WITHOUT ANY WARRANTY; without even the implied warranty of
#C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#C- GNU General Public License for more details.


SHELL = /bin/sh

PACKAGE_NAME = djview
PACKAGE_VERSION = 4.5

srcdir = .
top_srcdir = ..
top_builddir = ..

prefix = /media/card/programs/djview4
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
datarootdir = ${prefix}/share
datadir = ${datarootdir}
libdir = ${exec_prefix}/lib
mandir = ${datarootdir}/man

INSTALL = /scratchbox/tools/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644
CONVERT = false
XDG_MIME = 
XDG_ICON_RESOURCE = 
XDG_DESKTOP_MENU = 
RM = /scratchbox/tools/bin/rm

datadir_djview = ${datadir}/djvu/djview4/desktop


# -------- all

all: icons register-djview-menu

icons: hi-djview4.svgz hi32-djview4.png hi64-djview4.png

hi32-djview4.png hi64-djview4.png: djview.svg
	s=`echo $@ | sed -e 's/[a-z]*\([0-9]*\).*/\1/'`; \
	${CONVERT} -geometry $${s}x$${s} -depth 8 -background none $< $@ \
	  || cp ${srcdir}/prebuilt-$@ $@

hi-djview4.svgz: djview.svg
	gzip <$< >$@

register-djview-menu: register-djview-menu.in
	sed < ${srcdir}/register-djview-menu.in > register-djview-menu \
	  -e 's,XDG_MIME,${XDG_MIME},g' \
	  -e 's,XDG_ICON_RESOURCE,${XDG_ICON_RESOURCE},g' \
	  -e 's,XDG_DESKTOP_MENU,${XDG_DESKTOP_MENU},g' \
	  -e 's,DATADIR,${datadir},g' \
	  -e 's,MYDIR,${datadir_djview},g'
	chmod a+x register-djview-menu

# -------- install

install: install-djview-files 

install-djview-files: FORCE
	${INSTALL} -d ${DESTDIR}${datadir_djview}
	${INSTALL_PROGRAM} register-djview-menu ${DESTDIR}${datadir_djview}
	${INSTALL_DATA} *djview4.png ${DESTDIR}${datadir_djview}
	${INSTALL_DATA} *djview4.svgz ${DESTDIR}${datadir_djview}
	${INSTALL_PROGRAM} ${srcdir}/*djview4.desktop ${DESTDIR}${datadir_djview}
	-@echo "Run ${datadir_djview}/register-djview-menu install"
	-@echo " to register the djview3 menu entries."

# -------- misc

clean: FORCE
	-${RM} 2>/dev/null register-djview-menu

distclean: clean 
	-${RM} -r 2>/dev/null Makefile *.rpo ii_files

depend:

FORCE:

.PHONY: FORCE
