# The top-level Makefile for GNU GNATS
# Copyright (C) 2001, 2002 Milan Zamazal
#
# 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; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

VERSION = @PACKAGE_VERSION@
DISTDIR = gnats-$(VERSION)

srcdir = @srcdir@
VPATH = @srcdir@

SUBDIRS = gnats send-pr doc

# Standard GNU targets
.PHONY: all install install-strip uninstall clean distclean distclean-here \
	mostlyclean maintainer-clean TAGS info dvi dist check
# GNATS specific targets
.PHONY: all-gnats all-tools

all: all-gnats

all-gnats:
	for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done

all-tools:
	for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done

install: install-gnats

install-gnats:
	for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done

install-strip:
	$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' $@

install-tools:
	$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' $@

uninstall:
	for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done

mostlyclean:
	-rm -f TAGS *.tar *.tar.gz
	-rm -f .\#* *~*
	for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done

clean: mostlyclean
	for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done

distclean: clean distclean-here
	for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
distclean-here:
	-rm -f Makefile config.status config.cache config.log
	-rm -f .\#* \#* *~*
	-rm -f *.orig *.rej

maintainer-clean: distclean-here
	for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done

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

TAGS:
	for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done

info:
	for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done

dvi:
	for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done

dist: maintainer-clean
	./configure
	$(MAKE)
	$(MAKE) distclean
	-rm -rf $(DISTDIR)
	mkdir $(DISTDIR)
	find \( -maxdepth 1 -not -name . -not -name .. -not -name $(DISTDIR) \
		-not -name debian \) -print0 | \
		xargs --null cp -al --target-directory=$(DISTDIR)
	find $(DISTDIR) \( -name CVS -o -name .cvsignore \) -print0 | \
		xargs --null --no-run-if-empty rm -r
	-find $(DISTDIR) -type d -print0 | \
		xargs --null --no-run-if-empty rmdir -p 2>/dev/null
	set -e; for i in gnats/configure gnats/configure.in; do \
		sed 's/-Werror//' $(DISTDIR)/$$i >$(DISTDIR)/$$i.tmp; \
		mv $(DISTDIR)/$$i.tmp $(DISTDIR)/$$i; \
	done
	tar cvf $(DISTDIR).tar $(DISTDIR)
	rm -rf $(DISTDIR)
	gzip -9 $(DISTDIR).tar

check:
	for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
