# 
# This Makefile builds JSP sample code to demonstrate
# how to run JavaServer Pages using the Oracle Servlet Engine in 8.1.7.
#
# Please see the README file in this directory for more information
# and the setup steps.
# 
# NOTE: THIS IS FOR DEMONSTRATION ONLY.  THIS IS NOT SUPPORTED
# BY ORACLE AND SHOULD ONLY BE USED FOR DEMONSTRATION PURPOSES.
# 

# env variables you may want to change ...
# env variables begin
USER = scott
PASSWORD = tiger
SERVICE = http://localhost:8080
CONTEXT = /scottRoot/contexts/scottContext
DOC_ROOT = ${ORACLE_HOME}/javavm/demo/examples/web/service/scottDemo
# env variables end

#
# how to make the JSP samples
# make all : (1) copy static files 
#            (2) load classes, jars and jsp files 
#            (3) compile
# separate steps / targets
# (1) make copy_static
# (2) make load
# (3) make compile
# 
# You can use 'make compileJsp2EJB' for the JSP calls EJB demo,
# and 'make compileJsp2CORBA' for the JSP calls corba demo, 
# but first you must install the required EJB and CORBA objects
# in JServer. See the README file for more information.
#
# The whole build could take upto 15 mins to finish in OSE.
#


LJ = $(ORACLE_HOME)/bin/loadjava -verbose -resolve -user $(USER)/$(PASSWORD) -grant PUBLIC 
DJ = $(ORACLE_HOME)/bin/dropjava
SSH = $(ORACLE_HOME)/bin/sess_sh -u $(USER) -p $(PASSWORD) -s $(SERVICE) -command 


DEPENDENCY_JAVA_FILES = \
	WEB-INF/classes/beans/HtmlQueryBean.java \
	WEB-INF/classes/examples/ExampleLoopTag.java \
	WEB-INF/classes/beans/NameBean.java \
	WEB-INF/classes/examples/ExampleLoopTagTEI.java 

DEPENDENCY_JAVA_CLASSES = \
	WEB-INF/classes/beans/HtmlQueryBean.class \
	WEB-INF/classes/examples/ExampleLoopTag.class \
	WEB-INF/classes/beans/NameBean.class \
	WEB-INF/classes/examples/ExampleLoopTagTEI.class \
	WEB-INF/classes/examples/ExampleLoopTagTEI.class 

DEPENDENCY_JARS = \
	WEB-INF/lib/lottery.jar \
	WEB-INF/lib/scope.jar

STATIC_WEB_FILES = \
	demo/index.html \
	demo/basic/index.html \
	demo/basic/hellouser/synopsis.htm \
	demo/basic/hellouser/viewsrc/hellouser.jsp.txt \
	demo/basic/hellouser/viewsrc/hellouser_jml.jsp.txt \
	demo/basic/jspstore/synopsis.htm \
	demo/basic/jspstore/images/*.* \
	demo/basic/jspstore/viewsrc/cart.jsp.txt \
	demo/basic/jspstore/viewsrc/index.jsp.txt \
	demo/basic/lottery/synopsis.htm \
	demo/basic/lottery/images/*.* \
	demo/basic/lottery/viewsrc/lotto.jsp.txt \
	demo/basic/simple/index.html \
	demo/basic/simple/viewsrc/usebean.jsp.txt \
	demo/basic/simple/viewsrc/welcome.jsp.txt \
	demo/basic/simple/viewsrc/welcomeuser.jsp.txt \
	demo/corba/index.html \
	demo/corba/viewsrc/CallCORBA.jsp.txt \
	demo/customtag/index.html \
	demo/customtag/synopsis.htm \
	demo/customtag/viewsrc/ExampleLoopTag.java.txt \
	demo/customtag/viewsrc/ExampleLoopTagTEI.java.txt \
	demo/customtag/viewsrc/exampletag.jsp.txt \
	demo/customtag/viewsrc/exampletag.tld.txt \
	demo/ejb/index.html \
	demo/ejb/viewsrc/CallEJB.jsp.txt \
	demo/ojspext/index.html \
	demo/ojspext/events/synopsis.htm \
	demo/ojspext/events/viewsrc/globals.jsa.txt \
	demo/ojspext/events/viewsrc/index.jsp.txt \
	demo/ojspext/jmltype/synopsis.htm \
	demo/ojspext/jmltype/viewsrc/index.jsp.txt \
	demo/ojspext/jmltype/synopsis.htm \
	demo/ojspext/jmltype/viewsrc/index.jsp.txt \
	demo/ojspext/jspscope/synopsis.htm \
	demo/ojspext/jspscope/viewsrc/PageEventDispatcher.java.txt \
	demo/ojspext/jspscope/viewsrc/scope.jsp.txt \
	demo/sql/bean/index.html \
	demo/sql/bean/viewsrc/ConnBeanDemo.jsp.txt \
	demo/sql/bean/viewsrc/ConnCacheBeanDemo.jsp.txt \
	demo/sql/bean/viewsrc/CursorBeanDemo.jsp.txt \
	demo/sql/bean/viewsrc/DBBeanDemo.jsp.txt \
	demo/sql/jdbc/index.html \
	demo/sql/jdbc/viewsrc/ConnCache1.jsp.txt \
	demo/sql/jdbc/viewsrc/ConnCache2.jsp.txt \
	demo/sql/jdbc/viewsrc/ConnCache3.jsp.txt \
	demo/sql/jdbc/viewsrc/JDBCQuery.jsp.txt \
	demo/sql/jdbc/viewsrc/SimpleQuery.jsp.txt \
	demo/sql/jdbc/viewsrc/UseHtmlQueryBean.jsp.txt \
	demo/sql/jdbc/viewsrc/setupcache.jsp.txt \
	demo/sql/sqlj/index.html \
	demo/sql/sqlj/viewsrc/SQLJIterator.sqljsp.txt \
	demo/sql/sqlj/viewsrc/SQLJSelectInto.sqljsp.txt \
	demo/sql/tag/index.html \
	demo/sql/tag/taglib.html \
	demo/sql/tag/viewsrc/sample1.jsp.txt \
	demo/sql/tag/viewsrc/sample2.jsp.txt \
	demo/sql/tag/viewsrc/sample3.jsp.txt \
	demo/sql/tag/viewsrc/sample4.jsp.txt \
	demo/sql/tag/viewsrc/sample5.jsp.txt \
	demo/xml/index.html \
	demo/xml/helloxml/index.html \
	demo/xml/helloxml/synopsis.htm \
	demo/xml/helloxml/style/hello.xsl \
	demo/xml/helloxml/viewsrc/hello.jsp.txt \
	demo/xml/helloxml/viewsrc/hello.xsl.txt \
	demo/xml/xmlquery/index.html \
	demo/xml/xmlquery/synopsis.htm \
	demo/xml/xmlquery/viewsrc/XMLQuery.jsp.txt 

JSP_FILES_1 = \
	demo/basic/hellouser/hellouser.jsp \
	demo/basic/hellouser/hellouser_jml.jsp \
	demo/basic/jspstore/cart.jsp \
	demo/basic/jspstore/index.jsp \
	demo/basic/lottery/lotto.jsp \
	demo/basic/simple/usebean.jsp \
	demo/basic/simple/welcome.jsp \
	demo/basic/simple/welcomeuser.jsp 

JSP_FILES_2 = \
	demo/customtag/exampletag.jsp \
	demo/ojspext/jmltype/index.jsp \
	demo/ojspext/jspscope/scope.jsp 

JSP_FILES_3 = \
	demo/sql/index.jsp \
	demo/sql/setconn.jsp \
	demo/sql/bean/ConnBeanDemo.jsp \
	demo/sql/bean/ConnCacheBeanDemo.jsp \
	demo/sql/bean/CursorBeanDemo.jsp \
	demo/sql/bean/DBBeanDemo.jsp \
	demo/sql/jdbc/ConnCache1.jsp \
	demo/sql/jdbc/ConnCache2.jsp \
	demo/sql/jdbc/ConnCache3.jsp \
	demo/sql/jdbc/JDBCQuery.jsp \
	demo/sql/jdbc/SimpleQuery.jsp \
	demo/sql/jdbc/UseHtmlQueryBean.jsp \
	demo/sql/jdbc/setupcache.jsp \
	demo/sql/sqlj/SQLJIterator.sqljsp \
	demo/sql/sqlj/SQLJSelectInto.sqljsp \
	demo/sql/tag/sample1.jsp \
	demo/sql/tag/sample2.jsp \
	demo/sql/tag/sample3.jsp \
	demo/sql/tag/sample4.jsp \
	demo/sql/tag/sample5.jsp 

JSP_FILES_4 = \
	demo/xml/helloxml/hello.jsp \
	demo/xml/xmlquery/XMLQuery.jsp

JSP_FILES_5 = \
	demo/ejb/CallEJB.jsp 

JSP_FILES_6 = \
	demo/corba/CallCORBA.jsp


JSP_FILES = $(JSP_FILES_1) $(JSP_FILES_2) $(JSP_FILES_3) $(JSP_FILES_4) \
		$(JSP_FILES_5) $(JSP_FILES_6) 

JSA_JSP_FILES_1 = \
	demo/ojspext/events/globals.jsa \
	demo/ojspext/events/index.jsp

JSP_OTHER_RESOURCES= \
	WEB-INF/exampletag.tld \
	WEB-INF/jml.tld \
	WEB-INF/sqltaglib.tld 

all: copy_static load compile

load:
	$(LJ) $(DEPENDENCY_JAVA_CLASSES)
	$(LJ) $(DEPENDENCY_JARS)
	$(LJ) $(JSP_FILES) 
	$(LJ) $(JSA_JSP_FILES_1) $(JSP_OTHER_RESOURCES)

compile: compile1 

compile1:
	$(SSH) 'publishjsp -hotload -verbose -context $(CONTEXT) $(JSA_JSP_FILES_1)'
	$(SSH) 'publishjsp -hotload -verbose -context $(CONTEXT) $(JSP_FILES_1)'
	$(SSH) 'publishjsp -hotload -verbose -context $(CONTEXT) $(JSP_FILES_2)'
	$(SSH) 'publishjsp -hotload -verbose -context $(CONTEXT) $(JSP_FILES_3)'
	$(SSH) 'publishjsp -hotload -verbose -context $(CONTEXT) $(JSP_FILES_4)'

compileJsp2EJB:
	$(SSH) 'publishjsp -schema SCOTT -verbose -context $(CONTEXT) $(JSP_FILES_5)'
# To hotload the JSP in SCOTT, you need to grant the hotload permission.
# See the README for the steps.

compileJsp2CORBA:
	$(SSH) 'publishjsp -schema SCOTT -verbose -context $(CONTEXT) $(JSP_FILES_6)'
# To hotload the JSP in SCOTT, you need to grant the hotload permission.
# See the README for the steps.

copy_static:
	cp -r demo $(DOC_ROOT) 
	cd $(DOC_ROOT) ; rm -f $(JSP_FILES) $(JSA_JSP_FILES_1) $(JSP_OTHER_RESOURCES) 

clean:
	cd $(DOC_ROOT) ; rm -rf demo
	$(DJ) $(DEPENDENCY_JAVA_CLASSES)
	$(DJ) $(DEPENDENCY_JARS)
	$(DJ) $(JSP_FILES) 
	$(DJ) $(JSA_JSP_FILES_1) $(JSP_OTHER_RESOURCES)
	$(SSH) 'unpublishjsp -context $(CONTEXT) demo/ojspext/events/index.jsp'
	$(SSH) 'unpublishjsp -context $(CONTEXT) $(JSP_FILES_1)'
	$(SSH) 'unpublishjsp -context $(CONTEXT) $(JSP_FILES_2)'
	$(SSH) 'unpublishjsp -context $(CONTEXT) $(JSP_FILES_3)'
	$(SSH) 'unpublishjsp -context $(CONTEXT) $(JSP_FILES_4)'
	$(SSH) 'unpublishjsp -context $(CONTEXT) $(JSP_FILES_5)'
	$(SSH) 'unpublishjsp -context $(CONTEXT) $(JSP_FILES_6)'




