#-------------------------------------------------------------------------
#
# Makefile.inc--
#    Build and install postgres.
#
# Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
#    $Header: /cvsroot/pgsql/src/Attic/GNUmakefile.in,v 1.52 2000/06/10 18:01:36 petere Exp $
#
#-------------------------------------------------------------------------

SRCDIR= .
include Makefile.global

FIND = @find@

# assuming gnu tar and split here
TAR  = @tar@
SPLIT = @split@

ETAGS = @etags@
XARGS = @xargs@

all:
	$(MAKE) -C utils all
	$(MAKE) -C backend all
	$(MAKE) -C interfaces all
	$(MAKE) -C bin all
	$(MAKE) -C pl all

install: installdirs
	$(MAKE) -C utils install
	$(MAKE) -C backend install
	$(MAKE) -C interfaces install
	$(MAKE) -C bin install
	$(MAKE) -C pl install

installdirs:
	../config/mkinstalldirs $(BINDIR) $(LIBDIR) $(INCLUDEDIR)

clean:
	$(MAKE) -C utils clean
	$(MAKE) -C backend clean
	$(MAKE) -C interfaces clean
	$(MAKE) -C bin clean
	$(MAKE) -C pl clean
	$(MAKE) -C test clean
	$(MAKE) -C ../contrib/spi clean

# Not all subdirectories have a make distclean target yet
distclean:
	-$(MAKE) -C utils clean
	-$(MAKE) -C backend clean
	rm -f backend/port/Makefile backend/catalog/genbki.sh \
		backend/utils/Gen_fmgrtab.sh \
		backend/port/tas.s backend/port/dynloader.c
	-$(MAKE) -C interfaces distclean
	-$(MAKE) -C bin clean
	rm -f bin/pg_dump/Makefile bin/pg_version/Makefile \
		bin/psql/Makefile bin/pgtclsh/mkMakefile.tcldefs.sh \
		bin/pgtclsh/mkMakefile.tkdefs.sh
	-$(MAKE) -C pl distclean
	-$(MAKE) -C test clean
	rm -f test/regress/GNUmakefile
	-$(MAKE) -C ../contrib/spi clean
	rm -f Makefile.port \
		include/config.h include/dynloader.h \
		include/os.h include/version.h \
		Makefile.global \
		GNUmakefile

.DEFAULT:
	$(MAKE) -C utils $@
	$(MAKE) -C backend $@
	$(MAKE) -C interfaces $@
	$(MAKE) -C bin $@
	$(MAKE) -C pl $@

TAGS:
	rm -f TAGS; \
	for i in backend interfaces/libpq bin; do \
	  $(FIND) $$i -name '*.[chyl]' -print | $(XARGS) $(ETAGS) -a ; \
	done

# target to generate a backup tar file and split files that can be 
# saved to 1.44M floppy
BACKUP:
	rm -f BACKUP.filelist BACKUP.tgz; \
	$(FIND) . -not -path '*obj/*' -not -path '*data/*' -type f -print > BACKUP.filelist; \
	$(TAR) --files-from BACKUP.filelist -c -z -v -f BACKUP.tgz
	$(SPLIT) --bytes=1400k BACKUP.tgz pgBACKUP.	

.PHONY: TAGS
.PHONY: BACKUP
