## src/Makefile
## Copyright (C) 1999, 2000 The MadHouse Project
##
## This file is part of dep.pl.
##
## dep.pl is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## dep.pl 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 General Public License for more details.
##
## You should have received a copy of the GNU 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
##
## $Id: Makefile,v 1.9 2000/12/24 22:00:58 algernon Exp $

top_srcdir	= ..
subdir		= src

perldir		= ${datadir}/perl5
perl_MODS	= DepPl.pm

bin_SCRIPTS	= dep.pl vh-fix.pl dep.pl-config
example_SCRIPTS	= dpkg-dep.sh
EXTRA_DIST	= $(example_SCRIPTS) DepPl.pm.in
DISTFILES	= $(EXTRA_DIST) Makefile $(patsubst %,%.in,$(bin_SCRIPTS))
CLEAN_FILES	= $(bin_SCRIPTS) $(perl_MODS)

include $(top_srcdir)/Rules.mk

all-local:: $(bin_SCRIPTS) $(perl_MODS)

install-hook:
	$(INSTALL_DIR) $(DESTDIR)$(docdir)/examples
	@list='$(example_SCRIPTS)'; for f in $$list; do \
		if test -f $$f; then \
			echo "$(INSTALL_PROG) $$f $(DESTDIR)$(docdir)/examples" ;\
			$(INSTALL_PROG) $$f $(DESTDIR)$(docdir)/examples ;\
		fi \
	done
	$(INSTALL_DIR) $(DESTDIR)$(perldir)
	@list='$(perl_MODS)'; for f in $$list; do \
		echo "$(INSTALL_DATA) $$f $(DESTDIR)$(perldir)/$$f" ;\
		$(INSTALL_DATA) $$f $(DESTDIR)$(perldir)/$$f ;\
	done

uninstall-hook:
	@list='$(example_SCRIPTS)'; for f in $$list; do \
		if test -f $$f; then \
			echo "rm -f $(DESTDIR)$(docdir)/examples/$$f" ;\
			rm -f $(DESTDIR)$(docdir)/examples/$$f ;\
		fi \
	done
	@list='$(perl_MODS)'; for f in $$list; do \
		echo "rm -f $(DESTDIR)$(perldir)/$$f" ;\
		rm -f $(DESTDIR)$(perldir)/$$f ;\
	done

dep.pl-config dep.pl vh-fix.pl DepPl.pm:: %: %.in $(top_srcdir)/Rules.mk
	sed -e "s,%%PKGCONFDIR%%,$(pkgconfdir),g" \
	    -e "s,%%DISTRIB%%,$(PACKAGE) $(VERSION),g" < $@.in >$@.tmp && \
		rm -f $@ && mv $@.tmp $@

dep.pl:: dep.pl.in $(top_srcdir)/Rules.mk $(top_srcdir)/COPYING
	cat dep.pl ../COPYING >$@T && \
		rm -f $@ && mv $@T $@

dep.pl-config dep.pl vh-fix.pl:: %: %.in $(top_srcdir)/Rules.mk
	chmod +x $@
