## ----------------------------------------------------------------------------
##                                                                           --
##  Filename        : $Source: /cvsroot/gnade/gnade/contrib/objects/Makefile,v $
##  Description     : Makefile for the odb package                           --
##  Author          : Michael Erdmann <Michael.Erdmann@snafu.de>             --
##  Created On      : 1-May-2002                                             --
##  Last Modified By: $Author: merdmann $                                    --
##  Last Modified On: $Date: 2007/01/21 08:48:34 $                           --
##  Version         : $Revision: 1.15 $				     --
##  Status          : $State: Exp $					     --
##                                                                           --
##  Copyright (C) 2006 Michael Erdmann                                       --
##                                                                           --
##  ODB is copyrighted by the persons and institutions enumerated in the     --
##  AUTHORS file. This file is located in the root directory of the          --
##  ODB distribution.                                                        --
##                                                                           --
##  ODB is free software; you can redistribute it and/or modify it under     --
##  terms of the  GNU General Public License as published  by the Free Soft- --
##  ware  Foundation;  either version 2,  or (at your option) any later ver- --
##  sion. ABE is distributed in the hope that it will be useful, but WITH-   --
##  OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
##  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
##  for  more details.  You should have  received  a copy of the GNU General --
##  Public License  distributed with GNAT;  see file COPYING.  If not, write --
##  to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
##  MA 02111-1307, USA.                                                      --
##                                                                           --
##  As a special exception,  if other files  instantiate  generics from      --
##  ODB Ada units, or you link ABE Ada units or libraries with other         --
##  files  to produce an executable, these  units or libraries do not by     --
##  itself cause the resulting  executable  to  be covered  by the  GNU      --
##  General  Public  License.  This exception does not however invalidate    --
##  any other reasons why  the executable file  might be covered by the      --
##  GNU Public License.                                                      --
##                                                                           --
##  Contact                                                                  --
##  =======                                                                  --
##  Error reports shall be handled via http://gnade.sourceforge.net          --
##                                                                           --
##  Author contact:                                                          --
##               purl:/net/michael.erdmann                                   --
##                                                                           --
## ----------------------------------------------------------------------------
##
##  Functional Description
##  ======================
##
##  THis is the top level makefile for the ODB package. It makes explicit usage
##  of the GNAT project file facility.
##
include make.conf

prepunits=$(subst .gpq,.adb,$(wildcard *.gpq))

others=apps

# add the  connection information dep. on the configured data base
DBAUTH=  -DDBUSER=\"gnade\" 		\
	 -DDBPASSWD=\"gnade\" 		\
	 -DDBSOURCE=\"gnade\"

# generate debug code
# DEBUG=-debugcode

ESQLFLAGS = -schema $*.sql $(DEBUG) -s $(FLAGS) $(DBAUTH)

## all global targets
all ::  $(prepunits) libobjects.a
	$(MAKE) dbinstall


all distclean clean ::
	$(MAKE)  -C./apps $@

dist:: all

install::

## the demo driver
libobjects.a: $(prepunits) objects.ads \
        persistent.adb persistent.ads person.adb person.ads \
	account.ads account.adb group.ads group.adb \
	account_transaction.ads account_transaction.adb \
	string_table.ads string_table.adb \
	root.ads root.adb \
	md5.ads md5.adb \
	key_type.ads key_type.adb
	gnatmake -x -P./libobjects.gpr

## database ifrastructure
dbinstall: objects.sql
	$(MAKE) dbclean
	bsql -u gnade -p gnade  gnade < objects.sql
	touch dbinstall

dbclean:
	-bsql -u gnade -p gnade -q"DROP TABLE OBJECTS" gnade
	-bsql -u gnade -p gnade -q"DROP TABLE ROOTNAME" gnade
	-bsql -u gnade -p gnade -q"DROP TABLE RELATIONS" gnade
	$(RM) dbinstall


dbreset:
	$(RM) dbinstall
	$(MAKE) dbinstall

## clean out local compilation results
clean ::
	$(RM) *~*

## Cleanup completly
distclean :: clean dbclean
	gnatclean -P./libobjects.gpr
	-$(RM) -f $(prepunits) *.ali *.o *.sql $(LIBDIR)/* $(INCDIR)/*
