# ----------
# Makefile for Slony-I
#
#	Copyright (c) 2003-2004, PostgreSQL Global Development Group
#	Author: Jan Wieck, Afilias USA INC.
#
# $Id: GNUmakefile.in,v 1.29 2006/08/02 15:32:01 xfade Exp $
# ----------

top_builddir = .
include $(top_builddir)/Makefile.global
GZIP = gzip --best

DEFAULTBUILDS=src tools

ifeq (, yes)
DEFAULTBUILDS+=" doc"
endif

DISTFILES = aclocal.m4 \
  config.h.in \
  configure \
  COPYRIGHT \
  README \
  UPGRADING \
  HISTORY-1.1 \
  INSTALL \
  SAMPLE \
  Makefile \
  Makefile.global.in \
  GNUmakefile.in \
  postgresql-slony1-engine.spec \
  postgresql-slony1-engine.spec.in \
  $(wildcard config/*) \
  $(wildcard src/*) \
  $(wildcard doc/*) \
  $(wildcard share/*) \
  $(wildcard makefiles/*)


all:
	@for subdir in $(DEFAULTBUILDS) ; do \
	  $(MAKE) -C $$subdir $@ || exit; \
    done && \
	echo "All of Slony-I is successfully made. Ready to install"

install	installdirs:
	@for subdir in $(DEFAULTBUILDS) ; do \
	  $(MAKE) -C $$subdir $@ || exit; \
    done && \
	echo "All of Slony-I is successfully installed"

clean:
	@for subdir in $(DEFAULTBUILDS) ; do \
	  $(MAKE) -C $$subdir $@ || exit; \
    done ;\
      rm -f postgres.imp

distclean: clean
	rm -f Makefile.global Makefile.port
	rm -f GNUmakefile
	rm -f config.log config.status config.h
	rm -f postgresql-slony1-engine.spec
	rm -f postgresql-slony1-engine-1.2.0_RC5.tar.gz
	rm -f postgres.imp
	rm -rf autom4te.cache

maintainer-clean: distclean
	rm -rf configure autom4te.cache

dist:	distdir

distdir := postgresql-slony1-engine-1.2.0_RC5
dummy	:= =install=
garbage := =*  "#"*  ."#"*  *~*  *.orig  *.rej  core  postgresql-slony1-engine-*

dist 	:= $(distdir).tar.gz

distdir:
	-rm -rf $(distdir)* $(dummy)
	for x in `cd $(top_builddir) && find . -name CVS -prune -o -print`; do \
	  file=`expr X$$x : 'X\./\(.*\)'`; \
	  if test -d "$(top_builddir)/$$file" ; then \
	    mkdir "$(distdir)/$$file" && chmod 777 "$(distdir)/$$file"; \
	  else \
	    ln "$(top_builddir)/$$file" "$(distdir)/$$file" >/dev/null 2>&1 \
	      || cp "$(top_builddir)/$$file" "$(distdir)/$$file"; \
	  fi || exit; \
	done

dist:	distdir
	$(TAR) cf postgresql-slony1-engine-1.2.0_RC5.tar $(distdir)
	$(GZIP) postgresql-slony1-engine-1.2.0_RC5.tar
	-rm -rf $(distdir)

rpm: dist

	rpmbuild -ta postgresql-slony1-engine-1.2.0_RC5.tar.gz

.PHONY: install
