#-------------------------------------------------------------------------
#
# 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.47 2000/01/09 07:53:52 tgl Exp $
#
#-------------------------------------------------------------------------

SRCDIR= .
include Makefile.global

FIND = @find@

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

ETAGS = @etags@
XARGS = @xargs@

all:
	$(MAKE) lexverify
	$(MAKE) -C utils all
	$(MAKE) -C backend all
	$(MAKE) -C interfaces all
	$(MAKE) -C bin all
	$(MAKE) -C pl all
	@if test $@. = all. -o $@. = .; then \
	echo All of PostgreSQL is successfully made.  Ready to install. ;\
        fi

install:
	$(MAKE) lexverify
	$(MAKE) -C utils install
	$(MAKE) -C backend install
	$(MAKE) -C interfaces install
	$(MAKE) -C bin install
	$(MAKE) -C pl install
	cat ../register.txt

lexverify:
	$(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

clean:
	$(MAKE) -C lextest 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

distclean: clean
	# Remove files and symlinks created by configure script
	rm -f \
		Makefile.port \
		config.cache \
		config.status \
		config.log \
		include/config.h \
		include/dynloader.h \
		include/os.h \
		backend/port/tas.s \
		backend/port/dynloader.c \
		backend/utils/Gen_fmgrtab.sh \
		interfaces/odbc/port \
		interfaces/odbc/makefiles \
		interfaces/odbc/template \
		interfaces/odbc/config.h \
\
\
\
		GNUmakefile \
		Makefile.global \
		backend/port/Makefile \
		backend/catalog/genbki.sh \
		backend/utils/Gen_fmgrtab.sh \
		bin/pg_dump/Makefile \
		bin/pg_version/Makefile \
		bin/psql/Makefile \
		bin/pgtclsh/mkMakefile.tcldefs.sh \
		bin/pgtclsh/mkMakefile.tkdefs.sh \
		include/version.h \
		interfaces/libpq/Makefile \
		interfaces/ecpg/lib/Makefile \
		interfaces/libpq++/Makefile \
		interfaces/libpgeasy/Makefile \
		interfaces/libpgtcl/Makefile \
		interfaces/odbc/GNUmakefile \
		interfaces/odbc/Makefile.global \
		pl/plpgsql/src/Makefile \
		pl/plpgsql/src/mklang.sql \
		pl/tcl/mkMakefile.tcldefs.sh \
		test/regress/GNUmakefile

.DEFAULT:
	$(MAKE) -C lextest $@
	$(MAKE) -C utils $@
	$(MAKE) -C backend $@
	$(MAKE) -C interfaces $@
	$(MAKE) -C bin $@
	$(MAKE) -C pl $@
	@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

