#
# Copyright 2002 Sun Microsystems, Inc. All rights reserved.
# SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
#

#
# @(#)Makefile	1.8 02/01/12
#

# Makefile for building a set of passed in Service tests in a Servlet

all:	all2

include $(CTS_HOME)/build/Defs.mk


PKG_DIR=com$(SLASH)sun$(SLASH)cts$(SLASH)harness$(SLASH)vehicle$(SLASH)jsp

SRC_DIR=$(CTS_HOME)$(SLASH)common$(SLASH)harness$(SLASH)vehicle$(SLASH)jsp

#The sevice test can provide a props file in the test dir else you get the 
#default in the servlet_vehicle dir.
XML:=$(shell if [ -f $(SRC_DIR)$(SLASH)jsp_vehicle.webprops ];then echo "jsp_vehicle.xml"; else echo "vehicle.xml"; fi )

WEB_FILES=jsp_vehicle.jsp:client.html
WEB_CLASSES=$(TEST_CLASSES)

CLASS_DIR=$(COMPILE_DIR)$(SLASH)$(PKG_DIR)

APP_NAME=$(TESTNAME)_jsp_vehicle
APP_EAR=$(APP_NAME).ear

#Adds test components (if there are any) that need to be packaged with 
#the vehicle
ifneq ($(APP_COMP_TYPE), )
	COMP_TYPE=WEB $(APP_COMP_TYPE)
endif

CONTENTROOT=contentRoot
include $(CTS_HOME)/build/BuildRules.mk

all2: all_classes all_xml $(APP_EAR)

# generate all of the class files
all_classes: all_classescommon $(SERVLET)

#### XML Conversion
all_xml: all_xmlcommon $(XML)

VEHICLE="-vehicle jsp"

runclient:
	cd $(SRC_DIR); $(MAKE) runclient2 APP_NAME=$(APP_NAME) VEHICLE=$(VEHICLE); cd $(CWD);
	
#### CREATE APPLICATION JAR
$(APP_EAR): create_unique_names app_webcommon 
	$(PACKAGE_APP)

create_unique_names:
	sed -e 's/context-root>jsp_vehicle/context-root>$(APP_NAME)/' $(CLASS_DIR)$(SLASH)$(APP_NAME)web.xml.runtime.xml >  \
		$(CLASS_DIR)$(SLASH)$(APP_NAME)web.xml.runtime.xml.tmp; \
	mv -f $(CLASS_DIR)$(SLASH)$(APP_NAME)web.xml.runtime.xml.tmp \
		$(CLASS_DIR)$(SLASH)$(APP_NAME)web.xml.runtime.xml; \
	sed -e 's/display-name>jsp_vehicle/display-name>$(APP_NAME)/' $(CLASS_DIR)$(SLASH)$(APP_NAME)web.xml.runtime.xml >  \
		$(CLASS_DIR)$(SLASH)$(APP_NAME)web.xml.runtime.xml.tmp; \
	mv -f $(CLASS_DIR)$(SLASH)$(APP_NAME)web.xml.runtime.xml.tmp \
		$(CLASS_DIR)$(SLASH)$(APP_NAME)web.xml.runtime.xml; \
	sed -e 's/display-name>jsp_vehicle/display-name>$(APP_NAME)/' $(CLASS_DIR)$(SLASH)$(APP_NAME)web.xml >  \
		$(CLASS_DIR)$(SLASH)$(APP_NAME)web.xml.tmp; \
	mv -f $(CLASS_DIR)$(SLASH)$(APP_NAME)web.xml.tmp \
		$(CLASS_DIR)$(SLASH)$(APP_NAME)web.xml; \


deploy: service_deploycommon

undeploy: undeploycommon

# Note: for clean to work, ejbd must be stopped and restarted
clean:	cleancommon 
	rm -rf jsp_vehicle.webprops
