# Makefile for GNU send-pr.
# 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.

# Start of system configuration section.

srcdir = @srcdir@
VPATH = $(srcdir)

# Where the GNATS database and master configuration stuff lives.
GNATS_ROOT = @GNATS_ROOT@

# Email address to which people should submit bugs.
GNATS_ADDR = @GNATS_ADDR@

# The default release for this send-pr.
DEFAULT_RELEASE = @DEFAULT_RELEASE@

# The default organization for this send-pr.
DEFAULT_ORGANIZATION = @DEFAULT_ORGANIZATION@

# The default GNATS site for send-pr. 
GNATS_SITE = @GNATS_SITE@

# The submitter-id for your site.
SUBMITTER = @SUBMITTER@

# Command line to use for mailer
MAIL_AGENT = @MAIL_AGENT@

# Command line to display the passwd database
PASSWD = @PASSWD@

# What to install
SEND_PR_INSTALL = install-norm install-categories

CC = cc

AR = ar
AR_FLAGS = rc

# Set RANLIB = echo if your system doesn't have or need ranlib.
RANLIB = ranlib

# Where to find texinfo.tex to format docn with TeX
TEXIDIR = $(srcdir)/../texinfo

MAKEINFO = makeinfo
TEXI2DVI = texi2dvi

INSTALL = $(srcdir)/../install.sh -c
INSTALL_PROGRAM = $(INSTALL) 
INSTALL_DATA = $(INSTALL) -m 644

CFLAGS = -g
LDFLAGS = -g

ECHON = @ECHON@

EMACS = `if [ -f ./../emacs19/Makefile ] ; then \
		echo "EMACSLOADPATH=\`cd $(srcdir)/../emacs19/lisp ; pwd\` ; \
		      export EMACSLOADPATH ; \
		      ./../emacs19/src/emacs" ; \
	else  \
		echo emacs ; \
	fi`

prefix = @prefix@

exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
libdir = $(exec_prefix)/lib
tooldir = $(libdir)

program_transform_name =

# Edit this to be the location of your emacs lisp files.
lispdir = @LISPDIR@

datadir = $(prefix)/lib
mandir = $(prefix)/man
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
infodir = $(prefix)/info
includedir = $(prefix)/include
docdir = $(datadir)/doc

# End of system configuration section.

VERSION = 3.95

SHELL = /bin/sh

#### System configurations, if any, are inserted here.

DISTFILES= COPYING ChangeLog Makefile.in README configure.in \
install-sid.sh send-pr-el.in send-pr.man send-pr.texi fields.texi \
states.texi s-usage.texi categ.texi send-pr.sh

all: send-pr install-sid send-pr.elc send-pr.1

send-pr: send-pr.sh Makefile
	${TOOL_SED} -e 's,xVERSIONx,$(VERSION),' \
	    -e 's,xGNATS_ROOTx,$(GNATS_ROOT),' \
	    -e 's,xGNATS_ADDRx,$(GNATS_ADDR),' \
	    -e 's,xGNATS_SITEx,$(GNATS_SITE),' \
	    -e 's,xSUBMITTERx,$(SUBMITTER),' \
	    -e 's,xECHONx,$(ECHON),' \
	    -e 's,xMAIL_AGENTx,$(MAIL_AGENT),' \
	    -e 's,xPASSWDx,$(PASSWD),' \
	    -e 's%xDEFAULT_ORGANIZATIONx%$(DEFAULT_ORGANIZATION)%' \
	    -e 's,xDEFAULT_RELEASEx,$(DEFAULT_RELEASE),' \
	    -e 's,xDATADIRx,$(datadir),' $(srcdir)/send-pr.sh > $@-t
	mv $@-t $@
	chmod 755 $@

install-sid: install-sid.sh Makefile
	${TOOL_SED} -e 's,xBINDIRx,$(bindir),g' \
	    -e 's,xVERSIONx,$(VERSION),g' $(srcdir)/install-sid.sh > $@-t
	mv $@-t $@
	chmod 755 $@

send-pr.el: send-pr-el.in Makefile
	${TOOL_SED} -e 's,xVERSIONx,$(VERSION),' \
	    -e 's,xGNATS_ROOTx,$(GNATS_ROOT),' \
	    -e 's,xGNATS_SITEx,$(GNATS_SITE),' \
	    -e 's,xDATADIRx,$(datadir),' \
	    -e 's,xSUBMITTERx,$(SUBMITTER),' \
	    -e 's,xDEFAULT_RELEASEx,$(DEFAULT_RELEASE),' \
		$(srcdir)/send-pr-el.in \
	    > $@-t
	mv $@-t $@

send-pr.elc: send-pr.el
	-PWD=`pwd` eval $(EMACS) -batch -q -f batch-byte-compile send-pr.el

install: $(SEND_PR_INSTALL)
install-tools: install-norm install-categories
install-gnats: install-norm install-gnats-dist install-categories

install-norm all-gnats:
	$(INSTALL_PROGRAM) send-pr $(bindir)/send-pr
	$(INSTALL_PROGRAM) install-sid $(bindir)/install-sid
	$(INSTALL_DATA) send-pr.1 $(man1dir)/send-pr.1
	$(INSTALL_DATA) send-pr.el $(lispdir)/send-pr.el
	if [ -f send-pr.elc ]; then \
	  $(INSTALL_DATA) send-pr.elc $(lispdir)/send-pr.elc; \
	else true; fi

# Install the Cygnus category list for bug reports.
install-categories:
	$(INSTALL_DATA) $(srcdir)/categories $(datadir)/gnats/cygnus

install-gnats-dist:
	$(INSTALL_DATA) $(srcdir)/COPYING $(datadir)/gnats/dist/COPYING
	$(INSTALL_DATA) $(srcdir)/README $(datadir)/gnats/dist/README
	$(INSTALL_DATA) $(srcdir)/INSTALL $(datadir)/gnats/dist/INSTALL
	$(INSTALL_DATA) $(srcdir)/MANIFEST $(datadir)/gnats/dist/MANIFEST
	${TOOL_SED} \
	    -e 's/"DEFAULT_RELEASE") ".*"/"DEFAULT_RELEASE") "@''DEFAULT_RELEASE@"/' \
	    -e 's/"SUBMITTER") ".*"/"SUBMITTER") "@''SUBMITTER@"/' \
	    -e 's/"DATADIR") ".*"/"DATADIR") "@''DATADIR@"/' \
	    send-pr.el > $(datadir)/gnats/dist/send-pr-el.inT
	mv $(datadir)/gnats/dist/send-pr-el.inT \
		$(datadir)/gnats/dist/send-pr-el.in
	${TOOL_SED} -e 's/GNATS_ROOT=.*/GNATS_ROOT=/' \
	    -e 's/SUBMITTER=.*/SUBMITTER=@''SUBMITTER@/' \
	    -e 's/DEFAULT_RELEASE=.*/DEFAULT_RELEASE="@''DEFAULT_RELEASE@"/' \
	    -e 's/DEFAULT_ORGANIZATION=.*/DEFAULT_ORGANIZATION=/' \
	    -e 's/DATADIR=.*/DATADIR=@''DATADIR@/' \
	    send-pr > $(datadir)/gnats/dist/send-pr.sh-t
	mv $(datadir)/gnats/dist/send-pr.sh-t \
		$(datadir)/gnats/dist/send-pr.sh
	${TOOL_SED} -e 's/^BINDIR=.*/BINDIR=@''BINDIR@/' \
	    install-sid > $(datadir)/gnats/dist/install-sid.sT
	mv $(datadir)/gnats/dist/install-sid.sT \
		$(datadir)/gnats/dist/install-sid.sh
	$(INSTALL_DATA) send-pr.1 $(datadir)/gnats/dist/send-pr.1
	for i in `if [ ! -f send-pr.info ];then echo $(srcdir)/;fi`send-pr.info* ; do \
		$(INSTALL_DATA) $$i $(datadir)/gnats/dist/$$i ; \
	done
	$(INSTALL_DATA) $(srcdir)/send-pr.texi \
		$(datadir)/gnats/dist/send-pr.texi
	$(INSTALL_DATA) $(srcdir)/s-usage.texi \
		$(datadir)/gnats/dist/s-usage.texi
	$(INSTALL_DATA) $(srcdir)/categ.texi \
		$(datadir)/gnats/dist/categ.texi
	$(INSTALL_DATA) $(srcdir)/fields.texi \
		$(datadir)/gnats/dist/fields.texi
	$(INSTALL_DATA) $(srcdir)/states.texi \
		$(datadir)/gnats/dist/states.texi
	$(INSTALL_DATA) $(srcdir)/../texinfo/texinfo.tex \
		$(datadir)/gnats/dist/texinfo.tex

install-info: send-pr.info
	for i in send-pr.info* ; do \
		$(INSTALL_DATA) $$i $(infodir)/$$i ; \
	done

uninstall:
	-rm -f $(bindir)/send-pr $(bindir)/install-sid
	-rm -f $(datadir)/gnats/$(GNATS_SITE)
	-[ x$$GNATS_ROOT = x ] || rm -rf $(datadir)/gnats/dist
	-rmdir $(datadir)/gnats
	-rm -f $(man1dir)/send-pr.1
	-rm -f $(lispdir)/send-pr.el $(lispdir)/send-pr.elc
	-rm -f $(infodir)/send-pr.info*

TAGS:

info: send-pr.info
dvi: send-pr.dvi

version.texi: Makefile
	echo "@set VERSION $(VERSION)" > $@-t
	mv $@-t $@

send-pr.1: Makefile
	${TOOL_SED} -e 's,xGNATS_ROOTx,$(GNATS_ROOT),g' \
	    -e 's,xVERSIONx,$(VERSION),g' $(srcdir)/send-pr.man > $@-t
	mv $@-t $@

send-pr.info: send-pr.texi version.texi fields.texi s-usage.texi categ.texi
	$(MAKEINFO) -I $(srcdir) -o send-pr.info $(srcdir)/send-pr.texi

send-pr.dvi: version.texi
	$(TEXI2DVI) $(srcdir)/send-pr.texi

# When building GNATS, this target is used to communicate information
# known only to the GNATS configuration.
gnats-build: stamp-gnats

stamp-gnats: Makefile
	${TOOL_SED} -e 's,^GNATS_ROOT =.*,GNATS_ROOT = $(GNATS_ROOT),' \
	    -e 's,^GNATS_ADDR =.*,GNATS_ADDR = $(GNATS_ADDR),' \
	    -e 's,^GNATS_SITE =.*,GNATS_SITE = $(GNATS_SITE),' \
	    -e 's,^DEFAULT_RELEASE =.*,DEFAULT_RELEASE = $(DEFAULT_RELEASE),' \
	    -e 's%^DEFAULT_ORGANIZATION =.*%DEFAULT_ORGANIZATION = $(DEFAULT_ORGANIZATION)%' \
	    -e 's,^SUBMITTER =.*,SUBMITTER = $(SUBMITTER),' \
	    -e 's,^VERSION =.*,VERSION = $(VERSION),' \
	    -e 's,^MAIL_AGENT =.*,MAIL_AGENT = $(MAIL_AGENT),' \
 	    -e 's,^SEND_PR_INSTALL =.*,SEND_PR_INSTALL = $(GNATS_INSTALL),' \
		Makefile > Makefile.tmp \
	&& mv Makefile.tmp Makefile \
	&& touch stamp-gnats

# Clean things up.

clean: mostlyclean
	-rm -f send-pr install-sid send-pr.1 send-pr.el send-pr.elc stamp-gnats
	-rm -f *.dvi

mostlyclean:
	-rm -f *.toc *.log *.vr *.fn *.cp *.tp *.ky *.pg

distclean: clean
	-rm -f Makefile config.status
	-rm -rf =* ./"#"* *~*
	-rm -f *.orig *.rej

realclean: distclean
	-rm -f TAGS send-pr.info* send-pr.??s version.texi

# FIXME
dist:
	echo need to do something for dist

check:
installcheck:

# Prevent GNU make v3 from overflowing arg limit on SysV.
.NOEXPORT:

Makefile: $(srcdir)/Makefile.in
	$(SHELL) config.status; \
	if [ -f ../gnats/Makefile ]; then cd ../gnats; $(MAKE) config-send-pr; fi
