#
#       Copyright (C) 1997 Claus Heine.
#
# This program 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, 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 General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#
# $Source: /homes/cvs/ftape-stacked/contrib/scripts/Makefile,v $
# $Revision: 1.2 $
# $Date: 1997/10/28 14:22:56 $
#
#      Makefile for the scripts directory for the QIC-40/80/3010/3020
#      floppy-tape driver "ftape" for Linux.
#
TOPDIR = ../..
#
# all other configuration is in $(TOPDIR)/MCONFIG:
#
include $(TOPDIR)/MCONFIG

SCRIPTS=listtape.pl listtape.sh
TARGETSCRIPT=listtape
PERL=$$(type -path perl)
PERL4=$$(type -path perl4)
PERL5=$$(type -path perl5)
BASH=$$(type -path bash)
SH=$$(type -path sh)

include $(TOPDIR)/Rules.make

sh-install: 
	SH=$$(echo $(SH) | sed -e 's/\//\\\//g') ; \
	echo $$SH ; \
	sed -e "s/@@SH@@/$$SH/g" listtape.sh > listtape
	$(INSTALL) -m 0755 listtape $(BINDIR)/listtape
	rm -f listtape

perl-install:
	PERL=$$(echo $(PERL) | sed -e 's/\//\\\//g') ; \
	echo $$PERL ; \
	sed -e "s/@@PERL@@/$$PERL/g" listtape.pl > listtape
	$(INSTALL) -m 0755 listtape $(BINDIR)/listtape
	rm -f listtape


clean::
	rm -f listtape

install:: 
	@if [ -x $(PERL) ] ; then \
	  make PERL=$(PERL) perl-install ; \
	elif [ -x $(PERL5) ] ; then \
	  make PERL=$(PERL5) perl-install ; \
	elif [ -x $(PERL4) ] ; then \
	  make PERL=$(PERL4) perl-install ; \
	elif [ -x $(BASH) ] ; then \
	  make SH=$(BASH) sh-install ; \
	elif [ -x $(SH) ] ; then \
	  make SH=$(SH) sh-install ; \
	else \
	  echo "Neither sh nor perl have been found, not installing listtape" ; \
	fi

uninstall::
	cd $(BINDIR) ; rm -f listtape

