#-------------------------------------------------------------------------
#
# 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.25 1998/04/06 17:02:13 momjian Exp $
#
#-------------------------------------------------------------------------

SRCDIR= .
include Makefile.global

FIND = @find@

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

ETAGS = @etags@
XARGS = @xargs@

all:
	$(MAKE) -C lextest all
	@if test ! -f lextest/lextest; then \
	  echo "";\
	  echo "You have a buggy version of flex.  Read INSTALL and search for flex for a fix.";\
	  echo "";\
	  false;\
	else \
	  true;\
	fi
	$(MAKE) -C utils all
	$(MAKE) -C backend all
	$(MAKE) -C interfaces all
	$(MAKE) -C bin all
ifneq ($(wildcard man), )
	$(MAKE) -C man all
endif
	@if test $@. = all. -o $@. = .; then \
	echo All of PostgreSQL is successfully made.  Ready to install. ;\
        fi

install:
	$(MAKE) -C lextest install
	$(MAKE) -C utils install
	$(MAKE) -C backend install
	$(MAKE) -C interfaces install
	$(MAKE) -C bin install
ifneq ($(wildcard man), )
	$(MAKE) -C man install
endif
	cat ../register.txt

clean:
	$(MAKE) -C lextest clean
	$(MAKE) -C utils clean
	$(MAKE) -C backend clean
	$(MAKE) -C interfaces clean
	$(MAKE) -C bin clean
	$(MAKE) -C test clean
	$(MAKE) -C ../contrib/spi clean
ifneq ($(wildcard man), )
	$(MAKE) -C man clean
endif

distclean: clean
	rm -f Makefile.global \
		config.cache \
		config.status \
		config.log \
		GNUmakefile \
		Makefile.global \
		backend/port/Makefile \
		bin/psql/Makefile \
		bin/pg_dump/Makefile \
		bin/pg_version/Makefile \
		include/config.h \
		include/dynloader.h \
		backend/port/tas.s \
		backend/port/dynloader.c \
		backend/utils/Gen_fmgrtab.sh \
		interfaces/ecpg/lib/Makefile \
		interfaces/libpq/Makefile \
		interfaces/libpgtcl/Makefile \
		include/os.h \
		Makefile.port


.DEFAULT:
	$(MAKE) -C lextest $@
	$(MAKE) -C utils $@
	$(MAKE) -C backend $@
	$(MAKE) -C interfaces $@
	$(MAKE) -C bin $@
ifneq ($(wildcard man), )
	$(MAKE) -C man $@
endif
	@if test $@. = all. -o $@. = .; then \
	echo All of PostgreSQL is successfully made.  Ready to install. ;\
        fi

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

