##
## $Id: Makefile,v 1.1.1.15 2002/02/01 01:58:29 nalin Exp $
##
## $Log: Makefile,v $
## Revision 1.1.1.15  2002/02/01 01:58:29  nalin
## adjust target
##
## Revision 1.1.1.14  2002/02/01 01:57:36  nalin
## adjust tar target
##
## Revision 1.1.1.13  2002/02/01 01:54:41  nalin
## fixup archive targets
##
## Revision 1.1.1.12  2002/02/01 01:53:40  nalin
## build as binary compat package;fixup archive target
##
## Revision 1.1.1.11  2002/02/01 01:53:05  nalin
## build as binary compat package;fixup archive target
##
## Revision 1.1.1.10  1999/09/10 01:35:27  gafton
## Fix description
##
## Revision 1.1.1.9  1999/04/09 21:28:57  gafton
## New version release
##
## Revision 1.1.1.8  1998/12/04 01:11:41  gafton
## Don't insist into rebuilding the stuff in the doc dir
##
## Revision 1.1.1.7  1998/10/07 00:00:08  gafton
## Updated
##
## Revision 1.1.1.6  1998/10/06 23:59:14  gafton
## Use release_ instead of r for CVS tags

PROJECT = pwdb
VERSION=$(shell awk '/Version:/ { print $$2 }' $(PROJECT).spec)
CVSTAG = Release_$(subst .,-,$(VERSION))

# Try to propagate this version information
export VERSION
export PROJECT

# Here we include the defines for the preferred operating system
# these include things like CC, CFLAGS and destination directories 
# etc.. By default, this is a symbolic link to one of the .defs files
# the .../defs/ directory. Please take a moment to check that you are
# using the correct one.

include default.defs

# For extra debugging information
# EXTRAS += -DDEBUG
EXTRAS += -D_GNU_SOURCE

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

# the sub-directories to make things in

DIRS = libpwdb examples

#
# Conditional defines..
#

#
# basic defines
#
CRTDIR = $(shell pwd)

WARNINGS += -ansi -D_POSIX_SOURCE -Wall -Wwrite-strings \
	-Wcast-qual -Wcast-align \
	-Wtraditional -Wstrict-prototypes -Wmissing-prototypes \
	-Wnested-externs -Winline -Wshadow 
INCLUDEDIR=-I$(CRTDIR)/include

#
# build composite defines
#

LOADLIBES = -L$(shell pwd)/libpwdb -lpwdb $(ULIBS)
CFLAGS += $(EXTRAS) $(WARNINGS) $(INCLUDEDIR) -fPIC

#
# generic exports
#

export CC			# the C compiler
export INSTALL			# to do instalations with
export MKDIR			# to ensure directories exist
export CFLAGS			# CC flags used to compile everything
export LD_D			# build a shared object file (module)
export LD			# build a generic library
export LDCONFIG			# rebuild the shared libraries
export AR			# build a static library
export RANLIB			# reorder a static library
export LOADLIBES		# libraries needed for application linking

#
# where to install things
#

export PREFIX			# the basic prefix for all other directories
export INCLUDED			# where to store pam---.h files
export SUPLEMENTED		# where to store module helper binaries
export CONFIGED			# where pam.conf file goes
export LIBDIR			# where libpam and libpam_misc go
export SECUREDIR		# where the modules will be placed


#
# Conditional exporting ( ... these go on for a while... )
#

##
## the rules
##

all:
	@for i in $(DIRS) ; do \
		$(MAKE) -C $$i all ; \
		if [ $$? -ne 0 ]; then break ; fi ; \
	done

install:
	for i in $(DIRS) ; do \
		$(MAKE) -C $$i install ; \
		if [ $$? -ne 0 ]; then break ; fi ; \
	done

sterile:
	@$(MAKE) remove
	@$(MAKE) extraclean

remove:
	for i in $(DIRS) ; do \
		$(MAKE) -C $$i remove ; \
	done

clean:
	@rm -f *~ core
	@for i in $(DIRS) ; do \
		$(MAKE)  -C $$i clean ; \
	done
	$(MAKE) -C doc clean
	rm -f $(PROJECT)-*.tar.gz

extraclean: clean
	@rm -f pwdb-*.tar.gz

check:
	$(MAKE) -C conf check

tag:
	cvs tag -cFR $(CVSTAG) .

olddir=$(shell pwd)

tar: clean
	rm -f $(PROJECT)-$(VERSION).tar.gz ;\
	rm -fr /tmp/pwdb-$(VERSION) ;\
	cd /tmp ;\
	cvs export -r $(CVSTAG) $(PROJECT) ;\
	mv pwdb pwdb-$(VERSION) ;\
	tar cf - pwdb-$(VERSION) | gzip > $(olddir)/$(PROJECT)-$(VERSION).tar.gz ;\
	echo "The archive is in $(PROJECT)-$(VERSION).tar.gz"

archive: extraclean tag tar
