##
## Makefile for SimplePAMApps
##
## $Id: Makefile,v 1.15 1999/02/19 12:03:59 saw Rel $
##

# this should be the name of this directory
RELNAME = SimplePAMApps-0.59

# this is the name of the archive file
DISTFILE = $(RELNAME).tar.gz
CVSDISTFILE = CVS+$(RELNAME).tar.gz

# ////////////////////////////////////////////////////
# // You should not modify anything below this line //
# ////////////////////////////////////////////////////

include Rules.make

SHELL = /bin/bash

TOPDIR := $(shell pwd)
PARDIR := $(shell cd .. ; pwd)

DIRS = conf common $(TAGDIR)

#
# Package building
#
all install:
	set -e ; for i in $(DIRS) ; do $(MAKE) -C "$${i}" $(@) ; done

all: Rules.make

Rules.make: Rules.make.in configure
	./configure

configure: configure.in
	autoconf

install: all

#
# Package cleanup
#
remove:
	for i in $(DIRS) ; do $(MAKE) -C "$${i}" $(@) ; done

clean extraclean:
	rm -f config.* *~ core
	for i in $(DIRS) ; do $(MAKE) -C "$${i}" $(@) ; done

check:
	$(MAKE) -C conf check

#
# Packaging
#
.filelist:
	rm -f .freezemake .filelist
	install -m0600 /dev/null .filelist
	( \
	  cd ..; \
	  if [ -e '$(PARDIR)/$(RELNAME)' ]; then \
	    [ '$(PARDIR)/$(RELNAME)' != '$(TOPDIR)' ] && exit 1; \
	  else \
	    mv '$(TOPDIR)' '$(PARDIR)/$(RELNAME)'; \
	  fi; \
	  find '$(RELNAME)' -name CVS -prune -o \! -type d \! -path '$(RELNAME)/conf/.md5sum' -print > '$(RELNAME)/.filelist' \
	)
	chmod 0400 .filelist

release: extraclean .filelist check
	(cat .filelist; echo '$(RELNAME)/conf/.md5sum') | (cd ..; tar -cz -f'$(DISTFILE)' -T-)
	( \
	  repository=`cat CVS/Repository` ; \
	  repdir=`dirname "$${repository}"` ; \
	  repbase=`basename "$${repository}"` ; \
	  cd .. ; \
	  tar -cz -f'$(CVSDISTFILE)' -C"$${repdir}" "$${repbase}" ; \
	)

#
# Making control
#
.PHONY: all install remove clean extraclean check .filelist release
