#########################################################################
#                                                                       #
#                                  GALAX                                #
#                               XQuery Engine                           #
#                                                                       #
#   Copyright 2001-2007.                                                #
#   Distributed only by permission.                                     #
#                                                                       #
#########################################################################

#########################################################################
# Author:	Christopher A. Rath (AT&T Labs Research)
# Descripton:
#		This is a replacement Makefile for the Galax Java API examples
# History:
#	$Log: Makefile-inst,v $
#	Revision 1.3  2007/02/01 22:08:46  simeon
#	February 1, 2007 - Jerome
#	
#	  o Code cleanup:
#	     - Cleaned up all the source file headers. Added module
#	       descriptions when missing, as well as CVS Id.
#	     - Removed obsolete modules: Optimization_rules_treepattern_old,
#	       Factorize_sideeffects.
#	
#	  o AST Walker:
#	     - Added support for a generic fold operation on the AST (useful
#	       to compute a boolean property on the AST for instance).
#	
#	  o Normalization:
#	     - Small fix to the normalization of comparisons to re-enable join
#	       detection, not using let bindings for the comparator
#	       anymore. [hack]
#	
#	  o Rewriting:
#	     - Added a judgment to check for side-effects, removed
#	       corresponding obsolete judgment in Factorization.
#	     - Moved the snap removal rule from optimization to rewriting,
#	       cleaning up the plans as early as possible.
#	
#	Revision 1.2  2006/05/17 15:27:39  mff
#	May 17, 2006 - Mary
#	
#	  o Browser interface/Website
#	    - Updated to align w/ GODI configuration & Galax 0.6.5.
#	    - Fixed CGI printing bug.  All output now printed correctly.
#	
#	  o Documentation
#	    - Updating documentation for GODI release.
#	
#	  o Logical Plan Printing
#	    - Fixed old bug that replicated algebra: namespace.
#	
#	  o Loading
#	    - Made interface names more mneumonic
#	
#	  o Java API & Examples Makefiles
#	    - Added path to CAPI libraries
#	    - Fix to install: target
#	
#	  TODO: Document command-line options :=(
#	
#	Revision 1.1  2006/04/17 18:10:40  car
#	April 17, 2006 - Chris Rath
#	  o Changes necessary to align with GODI
#	
#########################################################################

#########################################################################
# Section:	Default target
# Description:
#		The default target for this Makefile is "all"
#########################################################################

default:	all

#########################################################################
# Section:	Makefile pre-includes
# Description:
#		This is where the file(s) generated during by the Configure script
#		are included.  If config/Makefile.conf does not exist, the
#		make will fail.
#
#		Makefile.galax:	Variables defined for compiling and linking Galax
#								applications in the build environment
#########################################################################

include CONF_GALAX_CONFIG/Makefile.galax

#########################################################################
# Section:	Local variables
# Description:
#		These variables are used for targets of this Makefile
###########################################################################

EXAMPLE=example
TEST=test

JAVACLASSPATH=-classpath $(CONF_GALAX_JAVA_API)/$(GALAX_JAVAAPI_ARCHIVE)
API=java_api

#########################################################################
# Sub-Section:	Targets
# Description:
#		These are the configuration-dependent targets built by "all"
###########################################################################
ALL_PROGRAMS=runexample runtest

#########################################################################
# Section:  Main targets
# Description:
#     This is where all of the named toplevel targets are placed.
#
#  all:        This target builds the GALAX_CAPI_TARGETS
#  clean::     This target cleans files created in the all section
#########################################################################

tests:	$(ALL_PROGRAMS)

all:	$(ALL_PROGRAMS)

clean:
	$(RM) Example.class Test.class example.xml test.xml

#########################################################################
# Sub-Section:  Secondary targets
# Description:
#     These are the supporting targets for "all"
#########################################################################

runexample: Example.class
	(export $(LD_LIBRARY_PATH_VAR)=$(LD_LIBRARY_PATH):$(CONF_GALAX_C_API):$(CONF_GALAX_JAVA_API):$(CONF_C_LIBBDB); \
        $(JAVA) -classpath .:$(CONF_GALAX_JAVA_API)/galapi.jar Example >$(EXAMPLE).out; )
	if [[ -z "`cmp $(EXAMPLE).out $(EXAMPLE).expect`" ]]; then echo "$(EXAMPLE) passed"; else $(MAKE) TEST=$(EXAMPLE) error; fi;

runtest: Test.class 
	(export $(LD_LIBRARY_PATH_VAR)=$(LD_LIBRARY_PATH):$(CONF_GALAX_C_API):$(CONF_GALAX_JAVA_API):$(CONF_C_LIBBDB); \
	$(JAVA) -classpath .:$(CONF_GALAX_JAVA_API)/galapi.jar Test >$(TEST).out)
	if [[ -z "`cmp $(TEST).out $(TEST).expect`" ]]; then echo "$(TEST) passed"; else $(MAKE) TEST=$(TEST) error; fi;

#########################################################################
# Section:  Makefile post-includes
# Description:
#		There are currently no post-includes for this Makefile
#########################################################################

