#  C->Haskell Compiler: documentation makefile
#
#  Author : Manuel M T Chakravarty
#  Created: 30 October 1999
#
#  Version $Revision: 1.9 $ from $Date: 2002/07/06 09:59:40 $
#
#  Copyright (c) [1999..2002] Manuel M T Chakravarty
#
#  This file 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.
#
#  This file 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.
#
#  = DOCU =====================================================================
#
#  * The man page isn't installed anymore as it is too much out of date.

INSTALL=/bin/sh ../../install-sh
INSTALL_DATA=/bin/sh ../../install-sh -c

# must be first
#
default: all

# install dirs
#
prefix=@prefix@
datarootdir=@datarootdir@
datadir=@datadir@
SGMLDIR=$(datadir)/doc/c2hs-@C2HS_VERSION@/sgml
HTMLDIR=$(datadir)/doc/c2hs-@C2HS_VERSION@/html
TXTDIR =$(datadir)/doc/c2hs-@C2HS_VERSION@/txt

# build targets
#

.PHONY: all
all: c2hs.html c2hs.txt

c2hs.html: c2hs.sgml
	sgml2html c2hs.sgml

c2hs.txt: c2hs.sgml
	sgml2txt c2hs.sgml

# install target (sgml, html & txt)
#

.PHONY: install
install: all
	@for f in $(MANPAGES); do\
	  echo $(INSTALL) -d `dirname $(MANDIR)/$$f`;\
	  $(INSTALL) -d `dirname $(MANDIR)/$$f`;\
	  echo $(INSTALL_DATA) $$f $(MANDIR)/$$f;\
	  $(INSTALL_DATA) $$f $(MANDIR)/$$f;\
	done

	$(INSTALL) -d $(SGMLDIR)
	@for f in *.sgml; do\
	  echo $(INSTALL_DATA) $$f $(SGMLDIR)/$$f;\
	  $(INSTALL_DATA) $$f $(SGMLDIR)/$$f;\
	done

	$(INSTALL) -d $(HTMLDIR)
	@for f in *.html; do\
	  echo $(INSTALL_DATA) $$f $(HTMLDIR)/$$f;\
	  $(INSTALL_DATA) $$f $(HTMLDIR)/$$f;\
	done

	$(INSTALL) -d $(TXTDIR)
	@for f in *.txt; do\
	  echo $(INSTALL_DATA) $$f $(TXTDIR)/$$f;\
	  $(INSTALL_DATA) $$f $(TXTDIR)/$$f;\
	done

# auxiliary targets
#
.PHONY: clean
clean:
	-$(RM) *.html *.txt
