# Makefile for GNU GNATS.
# Copyright (C) 2001, 2002 Milan Zamazal
# Copyright (C) 1993, 94, 95, 96, 1997, 1999, 2000 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@

#**** Start of system configuration section.

# Where the default gnats database is located.
# default: $(sharedstatedir)/gnatsdb
GNATS_DEFAULT_DB_DIR = @GNATS_DEFAULT_DB_DIR@

# The gnats-adm dir that is part of the default database install.
GNATS_DEFAULT_ADM_DIR = $(GNATS_DEFAULT_DB_DIR)/gnats-adm

# The default network service to use.
DEFAULT_GNATS_SERVICE = @GNATS_SERVICE@

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

# NOTE: Don't wrap DEFAULT_RELEASE or DEFAULT_ORGANIZATION with
# quotes, or things will break.

# The default release for the `>Release:' field of a PR, for send-pr.
# default: unknown-1.0
DEFAULT_RELEASE = @DEFAULT_RELEASE@

# The default organization for PRs.
# default: unknown
DEFAULT_ORGANIZATION = @DEFAULT_ORGANIZATION@

# Configuration for business hours calculation
# default: 8-5, Mon-Fri
BDAY_START  = @BDAY_START@
BDAY_END    = @BDAY_END@
BWEEK_START = @BWEEK_START@
BWEEK_END   = @BWEEK_END@

# The command line used to run a mailer which gets the address list from
# mail headers
# default: /usr/{lib,sbin}/sendmail -oi -t
DEFAULT_MAIL_AGENT = @DEFAULT_MAIL_AGENT@

# The list of databases.
GLOBAL_DB_LIST_FILE = @GLOBAL_DB_LIST_FILE@

# The global access file with users and passwords.
GNATSD_USER_ACCESS_FILE = @GNATSD_USER_ACCESS_FILE@

# The global access file controlling which hosts have access to gnatsd.
GNATSD_HOST_ACCESS_FILE = @GNATSD_HOST_ACCESS_FILE@

#**** End of GNATS-specific configuration variables.

CC = @CC@
AR = ar
AR_FLAGS = rc

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

YACC = @YACC@
DIFFOPT = @DIFFOPT@
LEX = @LEX@

# These are set by autoconf.
DEFS = @DEFS@ -DGNATSD_USER_ACCESS_FILE=\"${GNATSD_USER_ACCESS_FILE}\" -DGNATSD_HOST_ACCESS_FILE=\"${GNATSD_HOST_ACCESS_FILE}\" -DDEFAULT_GNATS_SERVICE=\"${DEFAULT_GNATS_SERVICE}\" -DGLOBAL_DB_LIST_FILE=\"${GLOBAL_DB_LIST_FILE}\" -DGNATS_USER=\"${GNATS_USER}\"
LIBS = @LIBS@ @LEXLIB@
KRBINCLUDE = @KRBINCLUDE@

M4 = @M4@

INSTALL = $(srcdir)/../install-sh -c
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

SUB_INSTALL = `echo $(INSTALL) | sed 's,^\([^/]\),../\1,'`
SUB_INSTALL_DATA = `echo $(INSTALL_DATA) | sed 's,^\([^/]\),../\1,'`

CFLAGS = @CFLAGS@
GCC_CFLAGS = @GCC_CFLAGS@
LDFLAGS = @LDFLAGS@

prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
libexecdir = @libexecdir@
statedir = @datadir@
sysconfdir = @sysconfdir@

program_transform_name =

datadir = @datadir@
includedir = @includedir@
lispdir = @lispdir@

# End of system configuration section.

VERSION = 4.0.1

SHELL = /bin/sh

#### Host-, target-, and site-specific makefiles are inserted here.

SOURCES = btime.c cmds.c file-pr.c gen-closed-date.c gen-index.c getclose.c gnatsd.c pr-age.c pr-edit.c pr-stat.c query-pr.c queue-pr.c

EXTRA_OBJS = @EXTRA_OBJS@

LIBSRC = edit.c getdate.c internal.c misc.c pr.c index.c lists.c query.c version.c regex.c adm.c client.c pr-init.c database.c fconfig.c fconfigl.c mail.c field.c mk_auth.c
LIBOBJS = edit.o getdate.o internal.o misc.o pr.o index.o lists.o query.o version.o regex.o adm.o client.o pr-init.o database.o fconfig.o fconfigl.o mail.o field.o $(EXTRA_OBJS)

INCLUDEDIR = -I. -I$(srcdir) -I$(srcdir)/../include $(KRBINCLUDE)

# Where is the "-liberty" library, containing getopt and obstack?
LIBIBERTY = `if [ -f ../libiberty/libiberty.a ] ; then echo ../libiberty/libiberty.a ; else echo -liberty ; fi`

# Variables that the send-pr Makefile will want to have changed.
GNATS_VARS = \
  "GNATS_DEFAULT_DB_DIR=$(GNATS_DEFAULT_DB_DIR)" \
  "VERSION=$(VERSION)" \
  "DEFAULT_RELEASE=$(DEFAULT_RELEASE)" \
  "DEFAULT_ORGANIZATION=$(DEFAULT_ORGANIZATION)" \
  "SUBMITTER=$(SUBMITTER)" \
  "GNATS_INSTALL=$(GNATS_INSTALL)"

FLAGS_TO_PASS = \
  "SHELL=$(SHELL)" \
  "INSTALL=$(SUB_INSTALL)" \
  "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
  "INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
  "INSTALL_DATA=$(SUB_INSTALL_DATA)"

GNATS_ALL = @GNATS_ALL@

EXTRA_STUFF =
EXTRA_INSTALL =

all: $(GNATS_ALL)

all-gnats: all-tools gnatsd queue-pr mail-query gen-index \
	at-pr mkcat mkdb rmcat gen-closed-date \
	check-db delete-pr dbconfig gnats-databases gnats-pwconv $(EXTRA_STUFF)

all-tools: libgnats.a query-pr pr-age pr-edit edit-pr file-pr getclose \
	config-send-pr mail-agent dbconfig

libgnats.a: $(LIBOBJS)
	-rm -f tmplibgnats.a libgnats.a
	$(AR) $(AR_FLAGS) tmplibgnats.a $(LIBOBJS)
	$(RANLIB) tmplibgnats.a
	mv tmplibgnats.a libgnats.a

.c.o:
	$(CC) -c $(INCLUDEDIR) $(CFLAGS) $(GCC_CFLAGS) $(CPPFLAGS) $(DEFS) $<

version.c: Makefile
	echo 'const char *version_string = "$(VERSION)";' > $@-t
	mv $@-t $@

query-pr: query-pr.o regex.o libgnats.a
	$(CC) $(LDFLAGS) -o $@ query-pr.o regex.o \
		libgnats.a $(LIBIBERTY) $(LIBS)

gnatsd: gnatsd.o cmds.o regex.o file-pr.o btime.o libgnats.a
	$(CC) $(LDFLAGS) -o $@ gnatsd.o cmds.o regex.o file-pr.o btime.o \
	libgnats.a $(LIBRX) $(LIBIBERTY) $(LIBS)

queue-pr: queue-pr.o libgnats.a
	$(CC) $(LDFLAGS) -o $@ queue-pr.o \
		libgnats.a $(LIBIBERTY) $(LIBS)

pr-age: pr-age.o regex.o libgnats.a
	$(CC) $(LDFLAGS) -o $@ pr-age.o regex.o \
		libgnats.a $(LIBIBERTY) $(LIBS)

getclose: getclose.o regex.o libgnats.a
	$(CC) $(LDFLAGS) -o $@ getclose.o regex.o \
		libgnats.a $(LIBIBERTY) $(LIBS)

pr-edit: pr-edit.o file-pr.o btime.o libgnats.a
	$(CC) $(LDFLAGS) -o $@ pr-edit.o file-pr.o btime.o \
		libgnats.a $(LIBIBERTY) $(LIBS)

pr-stat: pr-stat.o regex.o libgnats.a
	$(CC) $(LDFLAGS) -o $@ pr-stat.o regex.o \
		libgnats.a $(LIBIBERTY) $(LIBS)

gen-index: gen-index.o libgnats.a
	$(CC) $(LDFLAGS) -o $@ gen-index.o libgnats.a \
		$(LIBIBERTY) $(LIBS)

gen-closed-date: gen-closed-date.o libgnats.a
	$(CC) $(LDFLAGS) -o $@ gen-closed-date.o libgnats.a \
		$(LIBIBERTY) $(LIBS)

at-pr: at-pr.sh Makefile
	@echo Creating at-pr...
	@sed -e 's,xVERSIONx,$(VERSION),g' \
	    -e 's,xGNATS_DEFAULT_DB_DIRx,$(GNATS_DEFAULT_DB_DIR),g' \
	    -e 's,xGNATS_USERx,$(GNATS_USER),g' \
	    -e 's,xBINDIRx,$(bindir),g' \
	    -e 's,xLIBEXECDIRx,$(libexecdir),g' $(srcdir)/at-pr.sh > $@-t
	@mv $@-t $@
	@chmod a+x $@

check-db: check-db.sh Makefile
	@echo Creating check-db..
	@sed -e 's,xVERSIONx,$(VERSION),g' \
	    -e 's,xGNATS_DEFAULT_DB_DIRx,$(GNATS_DEFAULT_DB_DIR),g' \
	    -e 's,xGNATS_USERx,$(GNATS_USER),g' \
	    -e 's,xLIBEXECDIRx,$(libexecdir),g' \
	    -e 's,xBINDIRx,$(bindir),g' $(srcdir)/check-db.sh > $@-t
	@mv $@-t $@
	@chmod a+x $@

delete-pr: delete-pr.sh Makefile
	@echo Creating delete-pr...
	@sed -e 's,xVERSIONx,$(VERSION),g' \
	    -e 's,xGNATS_DEFAULT_DB_DIRx,$(GNATS_DEFAULT_DB_DIR),g' \
	    -e 's,xGNATS_USERx,$(GNATS_USER),g' \
	    -e 's,xLIBEXECDIRx,$(libexecdir),g' $(srcdir)/delete-pr.sh > $@-t
	@mv $@-t $@
	@chmod a+x $@

mkcat: mkcat.sh Makefile
	@echo Creating mkcat...
	@cat $(srcdir)/mkcat.sh > $@-t
	@mv $@-t $@
	@chmod a+x $@

mkdb: mkdb.sh Makefile
	@echo Creating mkdb...
	@sed  -e 's,xGNATS_USERx,$(GNATS_USER),g' \
	      -e 's,xLIBEXECDIRx,$(libexecdir),g' \
	      -e 's,xGLOBAL_DB_LIST_FILEx,$(GLOBAL_DB_LIST_FILE),g' \
	      -e 's,xSYSCONFDIRx,$(sysconfdir),g' $(srcdir)/mkdb.sh > $@-t
	@mv $@-t $@
	@chmod a+x $@

rmcat: rmcat.sh Makefile
	@echo Creating rmcat...
	@cat $(srcdir)/rmcat.sh > $@-t
	@mv $@-t $@
	@chmod a+x $@

edit-pr: edit-pr.sh Makefile
	@echo Creating edit-pr...
	@sed -e 's,xGNATS_DEFAULT_DB_DIRx,$(GNATS_DEFAULT_DB_DIR),g' \
	     -e 's,xBINDIRx,$(bindir),g' \
	     -e 's,xLIBEXECDIRx,$(libexecdir),g' \
	     -e 's,xVERSIONx,$(VERSION),g' $(srcdir)/edit-pr.sh > $@-t
	@mv $@-t $@
	@chmod a+x $@

file-pr: file-pr.sh Makefile
	@echo Creating file-pr...
	@sed -e 's,xGNATS_DEFAULT_DB_DIRx,$(GNATS_DEFAULT_DB_DIR),g' \
	    -e 's,xLIBEXECDIRx,$(libexecdir),g' \
	    -e 's,xVERSIONx,$(VERSION),g' $(srcdir)/file-pr.sh > $@-t
	@mv $@-t $@
	@chmod a+x $@

mail-query: mail-query.sh Makefile
	@echo Creating mail-query...
	@sed -e 's,xGNATS_DEFAULT_DB_DIRx,$(GNATS_DEFAULT_DB_DIR),g' \
	    -e 's,xBINDIRx,$(bindir),g' \
	    -e 's,xLIBEXECDIRx,$(libexecdir),g' \
	    $(srcdir)/mail-query.sh > $@-t
	@mv $@-t $@
	@chmod a+x $@

mail-agent: mail-agent.sh Makefile
	@echo Creating mail-agent...
	@sed -e 's,xDEFAULT_MAIL_AGENTx,$(DEFAULT_MAIL_AGENT),g' \
	    $(srcdir)/mail-agent.sh > $@-t
	@mv $@-t $@
	@chmod a+x $@

dbconfig: dbconfig.in Makefile
	@echo Creating dbconfig...
	@sed -e 's,xBDAY_STARTx,$(BDAY_START),g' \
	    -e 's,xBDAY_ENDx,$(BDAY_END),g' \
	    -e 's,xBWEEK_STARTx,$(BWEEK_START),g' \
	    -e 's,xBWEEK_ENDx,$(BWEEK_END),g' \
	    -e 's,xLIBEXECDIRx,$(libexecdir)/gnats,g' \
	    $(srcdir)/dbconfig.in > $@-t
	@mv $@-t $@

gnats-databases: gnats-databases.in Makefile
	@echo Creating gnats-databases...
	@sed -e 's,xGNATS_DEFAULT_DB_DIRx,$(GNATS_DEFAULT_DB_DIR),g' \
	    $(srcdir)/gnats-databases.in > $@-t
	@mv $@-t $@

gnats-pwconv: gnats-pwconv.o libgnats.a
	$(CC) $(LDFLAGS) -o $@ gnats-pwconv.o \
		libgnats.a $(LIBIBERTY) $(LIBS)

getdate.c: getdate.y
	@echo expect 10 shift/reduce conflicts
	$(YACC) -o getdate.c $(srcdir)/getdate.y

# On some systems with ancient yaxxen, badly-generated .c code have we.
fconfig.o: fconfig.c
	$(CC) -c $(INCLUDEDIR) $(CFLAGS) $(CPPFLAGS) $(DEFS) $<

#
# Ayum yum yum and a bottle of rum!
#
fconfig.c: fconfig.y
	@rm -f fconfig.c fconfig.h fconfig.tab.c fconfig.tab.h
	$(YACC) -p fconf -b fconfig -d $(srcdir)/fconfig.y
	@if [ -f y.tab.c -a ! -f fconfig.c ] ; then \
	  mv y.tab.c fconfig.c ; \
	  mv y.tab.h fconfig.h ; \
	fi
	@if [ -f fconfig.tab.c ] ; then \
	  mv fconfig.tab.c fconfig.c ; \
	  mv fconfig.tab.h fconfig.h ; \
	fi

fconfigl.c: fconfigl.l
	$(LEX) -t $(srcdir)/fconfigl.l >fconfigl.c

config-send-pr:
	@if [ ! -d ../send-pr ]; then \
	  echo "The send-pr directory doesn't seem to be there!" ; \
	  exit 1 ; \
	else \
	  ( cd ../send-pr ; $(MAKE) $(GNATS_VARS) gnats-build ) ; \
	  true ; \
	fi

# Misc targets.

GNATS_INSTALL = @GNATS_INSTALL@

install: $(GNATS_INSTALL)
install-arch-dep: $(GNATS_INSTALL)-arch-dep

install-tools: install-tools-arch-indep install-tools-bin
install-tools-arch-dep: install-tools-bin

install-tools-arch-indep: all-tools
	$(SHELL) $(srcdir)/../mkinstalldirs $(datadir)/gnats
	$(SHELL) $(srcdir)/../mkinstalldirs $(sysconfdir)/gnats/defaults
	@if [ `whoami` = root -o `whoami` = $(GNATS_USER) ] ; then \
	  echo "chown $(GNATS_USER) $(datadir)/gnats" ; \
	  chown $(GNATS_USER) $(datadir)/gnats ; \
        else \
	  echo "*** Warning: Must chown $(GNATS_USER) $(datadir)/gnats" ; \
	fi
	$(INSTALL_DATA) $(srcdir)/gnats.el $(lispdir)/gnats.el
	for i in categories submitters responsible gnatsd.user_access addresses states classes dbconfig ; do \
	    if [ -f "$$i" ] ; then \
		$(INSTALL_DATA) $$i $(sysconfdir)/gnats/defaults/$$i ; \
	    else \
		$(INSTALL_DATA) $(srcdir)/$$i $(sysconfdir)/gnats/defaults/$$i ; \
	    fi ; \
	done

install-tools-bin: all-tools
	$(INSTALL_PROGRAM) query-pr $(bindir)/query-pr
	$(INSTALL_PROGRAM) getclose $(bindir)/getclose
	$(INSTALL_SCRIPT) edit-pr $(bindir)/edit-pr
	$(INSTALL_SCRIPT) $(srcdir)/diff-prs $(libexecdir)/gnats/diff-prs
	$(INSTALL_SCRIPT) mail-agent $(libexecdir)/gnats/mail-agent
	$(INSTALL_PROGRAM) file-pr $(libexecdir)/gnats/file-pr
	$(INSTALL_PROGRAM) pr-age $(libexecdir)/gnats/pr-age
	$(INSTALL_PROGRAM) pr-edit $(libexecdir)/gnats/pr-edit
	@if [ `whoami` = root -o `whoami` = $(GNATS_USER) ] ; then \
	  echo "chown $(GNATS_USER) $(libexecdir)/gnats/pr-edit" ; \
	  echo "chmod 4555 $(libexecdir)/gnats/pr-edit" ; \
	  chown $(GNATS_USER) $(libexecdir)/gnats/pr-edit ; \
	  chmod 4555 $(libexecdir)/gnats/pr-edit ; \
        else \
	  echo "*** Warning: Must make pr-edit suid $(GNATS_USER)" ; \
	fi

EXTRA_INSTALL =

install-gnats: install-gnats-bin install-gnats-arch-indep $(EXTRA_INSTALL)
install-gnats-arch-dep: install-gnats-bin $(EXTRA_INSTALL)

install-gnats-arch-indep: all-gnats install-tools-arch-indep
	@if [ -f $(GLOBAL_DB_LIST_FILE) ]; then \
	  echo "Not putting gnats-databases file in $(GLOBAL_DB_LIST_FILE), it's already there." ; \
	  true ; \
	else \
	  if [ `whoami` = root -o `whoami` = $(GNATS_USER) ] ; then \
	    $(INSTALL_DATA) -o $(GNATS_USER) gnats-databases \
	                    $(GLOBAL_DB_LIST_FILE) ; \
	  else \
	    $(INSTALL_DATA) gnats-databases $(GLOBAL_DB_LIST_FILE) ; \
	    echo "*** Warning: Must chown $(GNATS_USER) $(GLOBAL_DB_LIST_FILE)" ; \
	  fi \
	fi
	@if [ -f $(GNATSD_HOST_ACCESS_FILE) ]; then \
	   echo "Not putting gnats.host_access file in $(GNATSD_HOST_ACCESS_FILE), it's already there." ; \
	   true ; \
	else \
	  if [ `whoami` = root -o `whoami` = $(GNATS_USER) ] ; then \
	    $(INSTALL_DATA) -o $(GNATS_USER) $(srcdir)/gnatsd.host_access \
	                    $(GNATSD_HOST_ACCESS_FILE) ; \
          else \
	    $(INSTALL_DATA) $(srcdir)/gnatsd.host_access \
	                    $(GNATSD_HOST_ACCESS_FILE) ; \
	    echo "*** Warning: Must chown $(GNATS_USER) $(GNATSD_HOST_ACCESS_FILE)" ; \
	  fi \
	fi
	@echo "*** If you're a first-time user, you'll want to create a new database";
	@echo "*** with $(libexecdir)/gnats/mkdb."

install-gnats-bin: all-gnats install-tools-bin
	$(SHELL) $(srcdir)/../mkinstalldirs $(libexecdir)/gnats
	$(INSTALL_PROGRAM) gnatsd $(libexecdir)/gnats/gnatsd
	$(INSTALL_SCRIPT) at-pr $(libexecdir)/gnats/at-pr
	$(INSTALL_SCRIPT) check-db $(libexecdir)/gnats/check-db
	$(INSTALL_SCRIPT) delete-pr $(libexecdir)/gnats/delete-pr
	$(INSTALL_SCRIPT) mkcat $(libexecdir)/gnats/mkcat
	$(INSTALL_SCRIPT) mkdb $(libexecdir)/gnats/mkdb
	$(INSTALL_SCRIPT) rmcat $(libexecdir)/gnats/rmcat
	$(INSTALL_PROGRAM) queue-pr $(libexecdir)/gnats/queue-pr
	$(INSTALL_PROGRAM) gen-index $(libexecdir)/gnats/gen-index
	$(INSTALL_SCRIPT) mail-query $(libexecdir)/gnats/mail-query
	$(INSTALL_PROGRAM) gnats-pwconv $(libexecdir)/gnats/gnats-pwconv
	@if [ `whoami` = root -o `whoami` = $(GNATS_USER) ] ; then \
	  echo "chown $(GNATS_USER) $(libexecdir)/gnats/queue-pr $(libexecdir)/gnats/file-pr $(libexecdir)/gnats/gen-index" ; \
	  echo "chmod 4555 $(libexecdir)/gnats/queue-pr $(libexecdir)/gnats/file-pr $(libexecdir)/gnats/gen-index" ; \
	  echo "chown $(GNATS_USER) $(libexecdir)/gnats/gnatsd" ; \
	  echo "chmod 555 $(libexecdir)/gnats/gnatsd" ; \
	  chown $(GNATS_USER) $(libexecdir)/gnats/queue-pr $(libexecdir)/gnats/gen-index ; \
	  chmod 4555 $(libexecdir)/gnats/queue-pr $(libexecdir)/gnats/gen-index ; \
	  chown $(GNATS_USER) $(libexecdir)/gnats/gnatsd ; \
	  chmod 555 $(libexecdir)/gnats/gnatsd ; \
	else \
	  echo "*** Warning: must make queue-pr and gen-index suid $(GNATS_USER)." ; \
	fi

# regex.c is pretty badly broken, and I don't feel like fixing it.
regex.o: $(srcdir)/regex.c
	$(CC) -c $(INCLUDEDIR) $(CFLAGS) $(CPPFLAGS) $(DEFS) $<

# Flex 2.5.4's scanner seems to be a bit broken too.
fconfigl.o: fconfigl.c
	$(CC) -c $(INCLUDEDIR) $(CFLAGS) $(CPPFLAGS) $(DEFS) $<

# More misc bugs that aren't under my control exactly.
getdate.o: getdate.c
	$(CC) -c $(INCLUDEDIR) $(CFLAGS) $(CPPFLAGS) $(DEFS) $<

# These is here because Suckass' make is wacky in the head.

client.o: $(srcdir)/client.c
	$(CC) -c $(INCLUDEDIR) $(CFLAGS) $(GCC_CFLAGS) $(CPPFLAGS) $(DEFS) $(srcdir)/client.c

query-pr.o: $(srcdir)/query-pr.c
	$(CC) -c $(INCLUDEDIR) $(CFLAGS) $(GCC_CFLAGS) $(CPPFLAGS) $(DEFS) $(srcdir)/query-pr.c

pr-age.o: $(srcdir)/pr-age.c
	$(CC) -c $(INCLUDEDIR) $(CFLAGS) $(GCC_CFLAGS) $(CPPFLAGS) $(DEFS) $(srcdir)/pr-age.c

pr-edit.o: $(srcdir)/pr-edit.c
	$(CC) -c $(INCLUDEDIR) $(CFLAGS) $(GCC_CFLAGS) $(CPPFLAGS) $(DEFS) $(srcdir)/pr-edit.c

getclose.o: $(srcdir)/getclose.c
	$(CC) -c $(INCLUDEDIR) $(CFLAGS) $(GCC_CFLAGS) $(CPPFLAGS) $(DEFS) $(srcdir)/getclose.c

gnatsd.o: $(srcdir)/gnatsd.c
	$(CC) -c $(INCLUDEDIR) $(CFLAGS) $(GCC_CFLAGS) $(CPPFLAGS) $(DEFS) $(srcdir)/gnatsd.c

cmds.o: $(srcdir)/cmds.c
	$(CC) -c $(INCLUDEDIR) $(CFLAGS) $(GCC_CFLAGS) $(CPPFLAGS) $(DEFS) $(srcdir)/cmds.c

queue-pr.o: $(srcdir)/queue-pr.c
	$(CC) -c $(INCLUDEDIR) $(CFLAGS) $(GCC_CFLAGS) $(CPPFLAGS) $(DEFS) $(srcdir)/queue-pr.c

gen-index.o: $(srcdir)/gen-index.c
	$(CC) -c $(INCLUDEDIR) $(CFLAGS) $(GCC_CFLAGS) $(CPPFLAGS) $(DEFS) $(srcdir)/gen-index.c

gen-closed-date.o: $(srcdir)/gen-closed-date.c
	$(CC) -c $(INCLUDEDIR) $(CFLAGS) $(GCC_CFLAGS) $(CPPFLAGS) $(DEFS) $(srcdir)/gen-closed-date.c

# Don't use rm -rf in case there's other stuff in the directories
uninstall:
	-rm -f $(bindir)/edit-pr
	-rm -f $(bindir)/query-pr
	-rm -f $(bindir)/getclose
	-rm -f $(libexecdir)/gnats/gnats-edit-pr
	-rm -f $(libexecdir)/gnats/pr-age
	-rm -f $(libexecdir)/gnats/pr-edit
	-rm -f $(libexecdir)/gnats/at-pr
	-rm -f $(libexecdir)/gnats/check-db
	-rm -f $(libexecdir)/gnats/delete-pr
	-rm -f $(libexecdir)/gnats/file-pr
	-rm -f $(libexecdir)/gnats/nfile-pr
	-rm -f $(libexecdir)/gnats/gnats-file-pr
	-rm -f $(libexecdir)/gnats/queue-pr
	-rm -f $(libexecdir)/gnats/mkcat
	-rm -f $(libexecdir)/gnats/mkdb
	-rm -f $(libexecdir)/gnats/rmcat
	-rm -f $(libexecdir)/gnats/gen-index
	-rm -f $(libexecdir)/gnats/mail-query
	-rm -f $(libexecdir)/gnats/gnats-pwconv
	-rmdir $(libexecdir)/gnats

TAGS: $(SOURCES) $(LIBSRC)
	etags -f TAGS $(SOURCES) $(LIBSRC) *.h gnats.el ;

info:
dvi:

# Don't use $@ or it'll try to overwrite the version in $(srcdir).
version.texi:
	echo "@set VERSION $(VERSION)" > version.texi-t
	mv version.texi-t version.texi

# Clean things up.

clean: doclean
doclean: domostlyclean
	-rm -f *.o core queue-pr gnats at-pr mkcat mkdb gnats-pwconv
	-rm -f rmcat file-pr mail-query check-db delete-pr
	-rm -f libgnats.a
	-rm -f pr-age pr-stat query-pr pr-edit gnats-edit-pr edit-pr gen-index
	-rm -f gnatsd getclose gen-closed-date
	-rm -f gnats-file-pr file-pr nfile-pr *.dvi version.c
	-rm -f gnats-databases dbconfig mail-agent
	-rm -f *.elc
	-rm -f TAGS

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

distclean: dodistclean
dodistclean: doclean
	-rm -f Makefile config.status config.cache autoconf.h config config.log
	-rm -rf =* .\#* \#* *~*
	-rm -f *.orig *.rej
	-rm -f TAGS

maintainer-clean realclean: dodistclean
dorealclean: dodistclean
	-rm -f getdate.c fconfig.c fconfig.h fconfigl.c

# FIXME
dist:
	echo need to do something for dist

diststuff: getdate.c

config.status: configure
	@if [ -r config.status ]; then \
	  sh ./config.status --recheck ; \
	else \
	  echo You must configure GNATS.  Look at the INSTALL file for details. ; \
	  exit 1 ; \
	fi

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

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

# Dependencies

$(srcdir)/gnatsd.h: $(srcdir)/pcodes.h
btime.o: $(srcdir)/gnats.h $(srcdir)/../include/ansidecl.h 
btime.o: $(srcdir)/pr.h
btime.o: $(srcdir)/../include/ansidecl.h
client.o: $(srcdir)/gnats.h $(srcdir)/gnatsd.h
client.o: $(srcdir)/query.h autoconf.h
file-pr.o: $(srcdir)/../include/ansidecl.h $(srcdir)/pr.h
file-pr.o: $(srcdir)/gnats.h
file-pr.o: $(srcdir)/regex.h 
gen-index.o: $(srcdir)/../include/ansidecl.h 
gen-index.o: $(srcdir)/pr.h $(srcdir)/gnats.h
gen-index.o: $(srcdir)/gnats-dirs.h
gen-closed-date.o: $(srcdir)/../include/ansidecl.h 
gen-closed-date.o: $(srcdir)/pr.h $(srcdir)/gnats.h
gen-closed-date.o: $(srcdir)/gnats-dirs.h
getclose.o: $(srcdir)/gnats.h $(srcdir)/../include/ansidecl.h
getclose.o: $(srcdir)/query.h
getdate.o: autoconf.h
index.o: $(srcdir)/pr.h 
index.o: autoconf.h
index.o: $(srcdir)/gnats.h $(srcdir)/../include/ansidecl.h
internal.o: $(srcdir)/pr.h
internal.o: autoconf.h $(srcdir)/../include/getopt.h
misc.o: $(srcdir)/../include/ansidecl.h 
misc.o: $(srcdir)/pr.h
misc.o: $(srcdir)/gnats.h
pr-age.o: $(srcdir)/gnats.h $(srcdir)/../include/ansidecl.h
pr-age.o: $(srcdir)/query.h
pr-edit.o: $(srcdir)/../include/getopt.h
pr-edit.o: $(srcdir)/../include/ansidecl.h $(srcdir)/gnats.h
pr-edit.o: 
pr-edit.o: $(srcdir)/pr.h
pr-edit.o: autoconf.h
pr-stat.o: $(srcdir)/gnats.h $(srcdir)/../include/ansidecl.h
pr-stat.o: $(srcdir)/query.h
pr.o: $(srcdir)/../include/ansidecl.h $(srcdir)/pr.h
pr.o: $(srcdir)/gnats.h
pr.o: $(srcdir)/../include/getopt.h autoconf.h
query.o: $(srcdir)/gnats.h $(srcdir)/../include/ansidecl.h
query.o: $(srcdir)/query.h
query.o: $(srcdir)/regex.h $(srcdir)/pr.h
query-pr.o: $(srcdir)/gnats.h $(srcdir)/../include/ansidecl.h
query-pr.o: $(srcdir)/pr.h
query-pr.o: $(srcdir)/query.h
query-pr.o: $(srcdir)/regex.h
lists.o: $(srcdir)/gnats.h $(srcdir)/query.h
cmds.o: $(srcdir)/gnats.h $(srcdir)/../include/ansidecl.h
cmds.o: $(srcdir)/gnatsd.h $(srcdir)/query.h
gnatsd.o: $(srcdir)/gnats.h $(srcdir)/../include/ansidecl.h
gnatsd.o: $(srcdir)/gnatsd.h
queue-pr.o: autoconf.h $(srcdir)/../include/getopt.h
queue-pr.o: $(srcdir)/gnats-dirs.h
queue-pr.o: $(srcdir)/../include/ansidecl.h
queue-pr.o: $(srcdir)/pr.h 
queue-pr.o: $(srcdir)/gnats.h
regex.o: $(srcdir)/regex.h $(srcdir)/../include/ansidecl.h
edit.o: $(srcdir)/gnats.h $(srcdir)/gnatsd.h
edit.o: $(srcdir)/pr.h
mail.o: $(srcdir)/config.h $(srcdir)/gnats.h $(srcdir)/query.h
mail.o: $(srcdir)/pcodes.h
