# Makefile for GNU send-pr.
# Copyright (C) 1993, 2001 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@
sysconfdir = @sysconfdir@
VPATH = @srcdir@

# The username for the gnats user.
GNATS_USER = @GNATS_USER@

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

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

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

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

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

# Is the mktemp command available?
MKTEMP = @MKTEMP@

# What to install
SEND_PR_INSTALL = install-norm
SEND_PR_INSTALL_ARCH_DEP = install-norm-arch-dep

CC = cc

AR = ar
AR_FLAGS = rc

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

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

CFLAGS = -g
LDFLAGS = -g

ECHON = @ECHON@

prefix = @prefix@

exec_prefix = @exec_prefix@
bindir = @bindir@
libexecdir = @libexecdir@

program_transform_name =

datadir = @datadir@
lispdir = @lispdir@
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
includedir = @includedir@

# End of system configuration section.

VERSION = 4.0.1

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.1 version.texi
all-gnats: all
all-tools: all

send-pr: send-pr.sh Makefile
	sed -e 's,xVERSIONx,$(VERSION),' \
	    -e 's,xSUBMITTERx,$(SUBMITTER),' \
	    -e 's,xECHONx,$(ECHON),' \
	    -e 's,xMAIL_AGENTx,$(DEFAULT_MAIL_AGENT),' \
	    -e 's,xMKTEMPx,$(MKTEMP),' \
	    -e 's,xPASSWDx,$(PASSWD),' \
	    -e 's%xDEFAULT_ORGANIZATIONx%$(DEFAULT_ORGANIZATION)%' \
	    -e 's,xDEFAULT_RELEASEx,$(DEFAULT_RELEASE),' \
            -e 's,xBINDIRx,$(bindir),g' \
	    -e 's,xLIBEXECDIRx,$(libexecdir),g' \
	    -e 's,xSYSCONFDIRx,$(sysconfdir),g' \
	    -e 's,xDATADIRx,$(datadir),' $(srcdir)/send-pr.sh > $@-t
	mv $@-t $@
	chmod 755 $@

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

install: $(SEND_PR_INSTALL)
install-arch-dep: $(SEND_PR_INSTALL_ARCH_DEP)

install-tools: install-norm
install-tools-arch-dep: install-norm-arch-dep

install-gnats: install-norm
install-gnats-arch-dep: install-norm-arch-dep

install-norm: install-norm-arch-indep install-norm-arch-dep

install-norm-arch-indep:

install-norm-arch-dep:
	$(INSTALL_SCRIPT) send-pr $(bindir)/send-pr
	$(INSTALL_SCRIPT) install-sid $(bindir)/install-sid
	$(INSTALL_DATA) send-pr.1 $(man1dir)/send-pr.1

uninstall:
	-rm -f $(bindir)/send-pr $(bindir)/install-sid
	-rmdir $(datadir)/gnats
	-rm -f $(man1dir)/send-pr.1

TAGS:

info:
dvi:

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

send-pr.1: Makefile
	sed -e 's,xVERSIONx,$(VERSION),g' \
        -e 's,xPREFIXx,$(prefix),g' $(srcdir)/send-pr.man > $@-t
	mv $@-t $@

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

stamp-gnats: Makefile
	sed -e 's,^GNATS_USER =.*,GNATS_USER = $(GNATS_USER),' \
	    -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 stamp-gnats
	-rm -f *.dvi

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

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

maintainer-clean realclean: distclean
	-rm -f send-pr.??s

# 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
