# Makefile for GNU GNATS manual pages.
# Copyright (C) 1993 Free Software Foundation, Inc.
#
# This file is part of GNU GNATS.
#
# GNU GNATS 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.
# 
# GNU GNATS 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 GNU GNATS; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

srcdir = @srcdir@
VPATH = @srcdir@

GNATS_ROOT = @GNATS_ROOT@
GNATS_SITE = @GNATS_SITE@

prefix = @prefix@

exec_prefix = @exec_prefix@
bindir = @bindir@
datadir = @datadir@

datadir = @datadir@

mandir = @mandir@
man1dir = $(mandir)/man1
man2dir = $(mandir)/man2
man3dir = $(mandir)/man3
man4dir = $(mandir)/man4
man5dir = $(mandir)/man5
man6dir = $(mandir)/man6
man7dir = $(mandir)/man7
man8dir = $(mandir)/man8
man9dir = $(mandir)/man9
man1ext = .1
man5ext = .5
man7ext = .7
man8ext = .8
infodir = @infodir@
includedir = @includedir@

SHELL = /bin/sh

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

#### host, target, and site dependent makefile fragments come in here.
###

SRCS1=	edit-pr$(man1ext) query-pr$(man1ext)
MAN1=	edit-pr.man query-pr.man
SRCS5=  dbconfig$(man5ext) databases$(man5ext)
MAN5=   dbconfig.man databases.man
SRCS7=	gnats$(man7ext)
MAN7=	gnats.man
SRCS8=  mkcat$(man8ext) queue-pr$(man8ext) file-pr$(man8ext) rmcat$(man8ext) gen-index$(man8ext) gnatsd$(man8ext) mkdb$(man8ext) delete-pr$(man8ext) pr-edit$(man8ext)
MAN8 =	mkcat.man queue-pr.man file-pr.man rmcat.man gen-index.man gnatsd.man mkdb.man delete-pr.man pr-edit.man

DISTFILES = Makefile.in $(MAN1) $(MAN7) $(MAN8)

all: @GNATS_ALL@

all-gnats gnats-man-pages: $(SRCS1) $(SRCS5) $(SRCS7) $(SRCS8)
all-tools tools-man-pages: $(SRCS1)

.PHONY: check
check:

$(SRCS1): ../Makefile $(MAN1)
	@echo Creating $@...
	@file=`echo $@ | sed -e 's,\$(man1ext),,'` ; \
	sed -e 's,xGNATS_ROOTx,$(GNATS_ROOT),g' \
	    -e 's,xGNATS_SITEx,$(GNATS_SITE),g' \
	    -e 's,@BINDIR@,$(bindir),g' \
	    -e 's,@PREFIX@,$(prefix),g' \
	    -e 's,@VERSION@,$(VERSION),g' $(srcdir)/$$file.man > tmp-$@
	@mv tmp-$@ $@

$(SRCS5): ../Makefile $(MAN5)
	@echo Creating $@...
	@file=`echo $@ | sed -e 's,\$(man5ext),,'` ; \
	sed -e 's,xGNATS_ROOTx,$(GNATS_ROOT),g' \
	    -e 's,xGNATS_SITEx,$(GNATS_SITE),g' \
	    -e 's,@BINDIR@,$(bindir),g' \
	    -e 's,@PREFIX@,$(prefix),g' \
	    -e 's,@VERSION@,$(VERSION),g' $(srcdir)/$$file.man > tmp-$@
	@mv tmp-$@ $@

$(SRCS7): ../Makefile $(MAN7)
	@echo Creating $@...
	@file=`echo $@ | sed -e 's,\$(man7ext),,'` ; \
	sed -e 's,xGNATS_ROOTx,$(GNATS_ROOT),g' \
	    -e 's,xGNATS_SITEx,$(GNATS_SITE),g' \
	    -e 's,@DATADIR@,$(datadir),g' \
	    -e 's,@VERSION@,$(VERSION),g' $(srcdir)/$$file.man > tmp-$@
	@mv tmp-$@ $@

$(SRCS8): ../Makefile $(MAN8)
	@echo Creating $@...
	@file=`echo $@ | sed -e 's,\$(man8ext),,'` ; \
	sed -e 's,xGNATS_ROOTx,$(GNATS_ROOT),g' \
	    -e 's,xGNATS_SITEx,$(GNATS_SITE),g' \
	    -e 's,@DATADIR@,$(datadir),g' \
	    -e 's,@VERSION@,$(VERSION),g' $(srcdir)/$$file.man > tmp-$@
	@mv tmp-$@ $@

info install-info clean-info:
dvi:
TAGS:

mostlyclean: force
	rm -f $(SRCS1) $(SRCS5) $(SRCS7) $(SRCS8)
clean: mostlyclean
distclean: clean
	rm -f Makefile
realclean: distclean

install: @GNATS_INSTALL@

install-gnats install-gnats-man: all-gnats install-tools
	for i in $(SRCS5); do \
	    $(INSTALL_DATA) $$i $(man5dir)/$$i; \
	done
	for i in $(SRCS7); do \
	    $(INSTALL_DATA) $$i $(man7dir)/$$i; \
	done
	for i in $(SRCS8); do \
	    $(INSTALL_DATA) $$i $(man8dir)/$$i; \
	done

install-tools install-tools-man: all-tools
	for i in $(SRCS1); do \
	    $(INSTALL_DATA) $$i $(man1dir)/$$i; \
	done

uninstall:
	-for i in $(SRCS1); do rm -f $(man1dir)/$$i; done
	-for i in $(SRCS5); do rm -f $(man5dir)/$$i; done
	-for i in $(SRCS7); do rm -f $(man7dir)/$$i; done
	-for i in $(SRCS8); do rm -f $(man8dir)/$$i; done

force:
dist:

# Prevent GNU make v3 from overflowing arg limit on SysV.
.NOEXPORT:
Makefile: $(srcdir)/Makefile.in
	cd .. && $(SHELL) config.status
