# $Id: Makefile.in,v 1.5 2001/09/05 19:30:58 dan Exp $
#
# Makefile.in for the program "cascade"
#
# Copyright (c) 1998-2001 Dan McMahill <mcmahill@alum.mit.edu>
# All rights reserved.
#
# This code is derived from software written by Dan McMahill
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
#    must display the following acknowledgement:
#        This product includes software developed by Dan McMahill
#  4. The name of the author may not be used to endorse or promote products
#     derived from this software without specific prior written permission.
# 
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
#  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
#  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
#  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
#  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
#  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
#  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
#  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
#  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
#  SUCH DAMAGE.

# This makefile really doesn't do much since there isn't any
# compiling required.  Its purpose is to generate the preformatted
# man page and install the program, man pages, examples, and html
# documentation in the right place.  
#
#
SHELL = @SHELL@

VERSION = 1.4

prefix      = @prefix@
exec_prefix = @exec_prefix@
srcdir      = @srcdir@
bindir      = @bindir@
mandir      = @mandir@
datadir     = @datadir@
lispdir     = @lispdir@

INSTALL         = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT  = @INSTALL_SCRIPT@
INSTALL_DATA    = @INSTALL_DATA@

default: all

clean:
	rm -f cascade cascade.0 *~ */*~

distclean: clean
	rm -f config.status config.cache config.log
	rm -f Makefile
	rm -f cascade-${VERSION}.tar.gz

Makefile: Makefile.in config.status
	$(srcdir)/config.status

# Make the actual cascade program from the script template. This
# simply invloves some string substitution
cascade: $(srcdir)/cascade.sh
	rm -f $@
	sed -e 's;@awk@;@AWK@;' \
	    -e 's;@version@;$(VERSION);'  < $(srcdir)/cascade.sh > $@
	chmod 755 $@

$(bindir)/cascade: $(srcdir)/cascade
	$(INSTALL_SCRIPT) $(srcdir)/cascade $@

$(mandir)/man1/cascade.1: $(srcdir)/cascade.1
	$(INSTALL_DATA) $(srcdir)/cascade.1 $@

install:: installdirs

installdirs: mkinstalldirs
	$(srcdir)/mkinstalldirs $(bindir) $(mandir)/man1 $(mandir)/cat1 \
		$(datadir)/examples/cascade $(datadir)/doc/cascade \
		$(lispdir)

uninstall:
	rm -f $(bindir)/cascade
	rm -f $(mandir)/man1/cascade.1
	rm -f $(mandir)/cat1/cascade.1
	rm -fr $(datadir)/examples/cascade
	rm -fr $(datadir)/doc/cascade
	rm -fr $(lispdir)/cascade-mode.el*


###########################################
# the program
#
all:: cascade

install:: install.bin

install.bin:: $(srcdir)/cascade 
	$(INSTALL_SCRIPT) $(srcdir)/cascade $(bindir)/cascade

###########################################
# the man pages

all:: cascade.0

cascade.0: cascade.1
	rm -f cascade.0
	nroff -man cascade.1 > cascade.0

install:: install.man

install.man:: cascade.0 
	$(INSTALL_DATA)  $(srcdir)/cascade.0 $(mandir)/cat1/cascade.1
	$(INSTALL_DATA)  $(srcdir)/cascade.1 $(mandir)/man1/cascade.1

###########################################
# the examples

install:: install.examples

install.examples::
	$(INSTALL_DATA)  $(srcdir)/examples/ex1.gif \
			$(datadir)/examples/cascade/ex1.gif
	$(INSTALL_DATA)  $(srcdir)/examples/ex1.cas \
			$(datadir)/examples/cascade/ex1.cas
	$(INSTALL_DATA)  $(srcdir)/examples/ex1.out \
			$(datadir)/examples/cascade/ex1.out
	$(INSTALL_DATA)  $(srcdir)/examples/README.examples \
			$(datadir)/examples/cascade/README.examples

###########################################
# the html documentation

install:: install.docs

install.docs::
	$(INSTALL_DATA)  $(srcdir)/doc/index.html \
			$(datadir)/doc/cascade/index.html
	$(INSTALL_DATA)  $(srcdir)/examples/ex1.gif \
			$(datadir)/doc/cascade/ex1.gif

###########################################
# the emacs mode

install:: install.lisp

install.lisp::
	$(INSTALL_DATA)  $(srcdir)/cascade-mode.el \
		$(lispdir)/cascade-mode.el

###########################################
# the source distribution file (for me only)

DISTFILES= \
	cascade.sh \
	cascade.1 \
	cascade-mode.el \
	Makefile.in \
	doc/index.html \
	doc/ex1.gif \
	examples/ex1.gif \
	examples/ex1.cas \
	examples/ex1.out \
	examples/README.examples \
	configure.in \
	configure \
	install-sh \
	mkinstalldirs \
	README \
	INSTALL \
	HISTORY \
	BUGS

distfile:
	mkdir -p cascade-${VERSION}/doc cascade-${VERSION}/examples
	for f in ${DISTFILES} ; do  cp $$f cascade-${VERSION}/$$f ; done
	rm -f cascade-${VERSION}.tar.gz
	tar -cvf - cascade-${VERSION} | gzip > cascade-${VERSION}.tar.gz
	rm -fr cascade-${VERSION}

# Thats all

