#
#  
#
# Copyright  1990-2006 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version
# 2 only, as published by the Free Software Foundation. 
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License version 2 for more details (a copy is
# included at /legal/license.txt). 
# 
# You should have received a copy of the GNU General Public License
# version 2 along with this work; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA 
# 
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
# Clara, CA 95054 or visit www.sun.com if you need additional
# information or have any questions. 
#
######################################################################
#
# Module's Component Configuration file
#
#####################################################################

# Add to global SUBSYSTEMS list
#
SUBSYSTEMS += chapi

# Project speficic definitions
ifndef PROJECT_JSR_211_DIR
PROJECT_JSR_211_DIR=$(JSR_211_DIR)
endif

# Javadoc source path
ifeq ($(USE_NATIVE_AMS), true)
AMS_DIR=nams
EXTRA_CFLAGS += -DENABLE_JSR_211=1
else
AMS_DIR=jams
endif

JSR_211_SOURCEPATH = \
$(JSR_211_DIR)/src/classes$(PATHSEP)$(JSR_211_DIR)/src/core/$(AMS_DIR)/classes

JSR_211_PACKAGES = \
   com.sun.midp.content \
   javax.microedition.content

JAVADOC_ALL_SOURCEPATH += $(JSR_211_SOURCEPATH)
JAVADOC_ALL_PACKAGES +=  $(JSR_211_PACKAGES)

GROUP_DOC_ALL += \
        -group "JSR211 Content Handler API" \
	$(shell echo $(JSR_211_PACKAGES) | tr ' ' $(PATHSEP))

# There are no modules for subsystem ( JSR_211 )
#

# If JSR_211_DIR is not specified, default to in the MIDP workspace
#
ifndef JSR_211_DIR
JSR_211_DIR = $(MIDP_DIR)
endif

# Directory containing native files
SUBSYSTEM_JSR_211_NATIVE_SHARE_DIR = $(JSR_211_DIR)/src/core/native/share

ifeq ($(PLATFORM), javacall)
SUBSYSTEM_JSR_211_NATIVE_PLATF_DIR = $(JSR_211_DIR)/src/core/native/javacall
else 
SUBSYSTEM_JSR_211_NATIVE_PLATF_DIR = $(JSR_211_DIR)/src/core/native/reference
endif

SUBSYSTEM_JSR_211_EXTRA_INCLUDES = -I$(SUBSYSTEM_JSR_211_NATIVE_SHARE_DIR)/inc

DOXYGEN_INPUT_LIST += \
    $(SUBSYSTEM_JSR_211_NATIVE_SHARE_DIR)/inc/jsr211_registry.h \
    $(SUBSYSTEM_JSR_211_NATIVE_SHARE_DIR)/inc/jsr211_invoc.h

# vpath for ( chapi ) subsystem
#
vpath % $(SUBSYSTEM_JSR_211_NATIVE_SHARE_DIR)
vpath % $(SUBSYSTEM_JSR_211_NATIVE_PLATF_DIR)


# Java files for the ( JSR_211 ) module
#
INTERNAL_JSR_211_DIR    = $(JSR_211_DIR)/src/classes
INTERNAL_JSR_211_LF_DIR = $(JSR_211_DIR)/src/core/$(AMS_DIR)/classes
INTERNAL_JSR_211_I3TEST_DIR= $(JSR_211_DIR)/src/i3test
INTERNAL_JSR_211_CONFIG_DIR= $(JSR_211_DIR)/src/config

ifndef JSR_211_BUILD_DIR
JSR_211_BUILD_DIR          = $(MIDP_MAKE_DIR)/chapi_output
endif


# Obsolete: Include JSR_211 system properties in Configuration
SUBSYSTEM_CONFIGURATION_PROPERTRATOR_ARGS += \
    -f $(INTERNAL_JSR_211_CONFIG_DIR)/properties_chapi.xml

# Include JSR_211 system properties in Configuration
SUBSYSTEM_CONFIGURATION_INPUT_FILES += \
	$(INTERNAL_JSR_211_CONFIG_DIR)/properties_chapi.xml

# Include JSR_211 constants in Configuration
#SUBSYSTEM_CONFIGURATION_CONSTANTRATOR_ARGS += \
#    -content $(INTERNAL_JSR_211_CONFIG_DIR)/constants_chapi.xml


# Implementation of JSR_211
INTERNAL_JSR_211_JAVA_FILES := \
    $(INTERNAL_JSR_211_DIR)/com/sun/midp/content/InvocationImpl.java \
    $(INTERNAL_JSR_211_DIR)/com/sun/midp/content/AppProxy.java \
    $(INTERNAL_JSR_211_DIR)/com/sun/midp/content/RegistryStore.java \
    $(INTERNAL_JSR_211_DIR)/com/sun/midp/content/ContentHandlerImpl.java \
    $(INTERNAL_JSR_211_DIR)/com/sun/midp/content/InvocationStore.java \
    $(INTERNAL_JSR_211_DIR)/com/sun/midp/content/RegistryImpl.java \
    $(INTERNAL_JSR_211_DIR)/com/sun/midp/content/RequestListenerImpl.java \
    $(INTERNAL_JSR_211_DIR)/com/sun/midp/content/ResponseListenerImpl.java \
    $(INTERNAL_JSR_211_DIR)/com/sun/midp/content/Invoker.java \
    $(INTERNAL_JSR_211_DIR)/javax/microedition/content/ContentHandlerServer.java \
    $(INTERNAL_JSR_211_DIR)/javax/microedition/content/ContentHandlerException.java \
    $(INTERNAL_JSR_211_DIR)/javax/microedition/content/ActionNameMap.java \
    $(INTERNAL_JSR_211_DIR)/javax/microedition/content/ContentHandlerServerImpl.java \
    $(INTERNAL_JSR_211_DIR)/javax/microedition/content/ContentHandler.java \
    $(INTERNAL_JSR_211_DIR)/javax/microedition/content/Invocation.java \
    $(INTERNAL_JSR_211_DIR)/javax/microedition/content/RequestListener.java \
    $(INTERNAL_JSR_211_DIR)/javax/microedition/content/ResponseListener.java \
    $(INTERNAL_JSR_211_DIR)/javax/microedition/content/Registry.java

INTERNAL_JSR_211_CLASS_FILES := \
$(subst $(INTERNAL_JSR_211_DIR),$(MIDP_MAKE_DIR)/classes,\
$(INTERNAL_JSR_211_JAVA_FILES:java=class))

$(INTERNAL_JSR_211_CLASS_FILES): $(MIDP_MAKE_DIR)/classes/%.class : \
                                 $(INTERNAL_JSR_211_DIR)/%.java
	@echo $< >> $(GENERATED_FILE_LIST)


# Implementation of JSR_211 on MIDP stack
ifeq ($(USE_NATIVE_AMS), true)
INTERNAL_JSR_211_LF_JAVA_FILES := \
    $(INTERNAL_JSR_211_LF_DIR)/com/sun/midp/content/CHManagerImpl.java \
    $(INTERNAL_JSR_211_LF_DIR)/com/sun/midp/jsr211/Initializer.java
else
INTERNAL_JSR_211_LF_JAVA_FILES := \
    $(INTERNAL_JSR_211_LF_DIR)/com/sun/midp/content/RegistryInstaller.java \
    $(INTERNAL_JSR_211_LF_DIR)/com/sun/midp/content/AppBundleProxy.java \
    $(INTERNAL_JSR_211_LF_DIR)/com/sun/midp/content/CHManagerImpl.java \
    $(INTERNAL_JSR_211_LF_DIR)/com/sun/midp/installer/CHAutoTester.java
endif

INTERNAL_JSR_211_LF_CLASS_FILES := \
$(subst $(INTERNAL_JSR_211_LF_DIR),$(MIDP_MAKE_DIR)/classes,\
$(INTERNAL_JSR_211_LF_JAVA_FILES:java=class))

$(INTERNAL_JSR_211_LF_CLASS_FILES): $(MIDP_MAKE_DIR)/classes/%.class : \
                                    $(INTERNAL_JSR_211_LF_DIR)/%.java
	@echo $< >> $(GENERATED_FILE_LIST)

# Tests for JSR_211
INTERNAL_JSR_211_I3TEST_JAVA_FILES := \
    $(INTERNAL_JSR_211_I3TEST_DIR)/com/sun/midp/content/TestActionNameMap.java \
    $(INTERNAL_JSR_211_I3TEST_DIR)/com/sun/midp/content/ExtendedTestCase.java \
    $(INTERNAL_JSR_211_I3TEST_DIR)/com/sun/midp/content/InvocStoreCancel.java \
    $(INTERNAL_JSR_211_I3TEST_DIR)/com/sun/midp/content/InvocStoreStress.java \
    $(INTERNAL_JSR_211_I3TEST_DIR)/com/sun/midp/content/TestRegReadWrite.java \
    $(INTERNAL_JSR_211_I3TEST_DIR)/com/sun/midp/content/TestInvocStore.java \
    $(INTERNAL_JSR_211_I3TEST_DIR)/com/sun/midp/content/TestRegistryImpl.java \
    $(INTERNAL_JSR_211_I3TEST_DIR)/com/sun/midp/content/TestListener.java

INTERNAL_JSR_211_I3TEST_CLASS_FILES := \
$(subst $(INTERNAL_JSR_211_I3TEST_DIR),$(MIDP_MAKE_DIR)/classes,\
$(INTERNAL_JSR_211_I3TEST_JAVA_FILES:java=class))

$(INTERNAL_JSR_211_I3TEST_CLASS_FILES): $(MIDP_MAKE_DIR)/classes/%.class : \
                                        $(INTERNAL_JSR_211_I3TEST_DIR)/%.java
	@echo $< >> $(GENERATED_FILE_LIST)


# All of them together to provide to main makefile
#
SUBSYSTEM_JSR_211_CLASS_FILES = $(INTERNAL_JSR_211_CLASS_FILES) \
                                $(INTERNAL_JSR_211_LF_CLASS_FILES) 
SUBSYSTEM_JSR_211_JAVA_FILES  = $(INTERNAL_JSR_211_JAVA_FILES) \
                                $(INTERNAL_JSR_211_LF_JAVA_FILES)


ifeq ($(USE_I3_TEST), true)
# unit test 
#
SUBSYSTEM_JSR_211_I3TEST_JAVA_FILES += $(INTERNAL_JSR_211_I3TEST_JAVA_FILES)
SUBSYSTEM_JSR_211_I3TEST_CLASS_FILES += $(INTERNAL_JSR_211_I3TEST_CLASS_FILES)

endif

# Native files for the ( chapi ) subsystem
#

INTERNAL_JSR_211_NATIVE_FILES += \
	invocStore.c regstore.c jsr211_registry_impl.c jsr211_deploy.c

ifeq ($(USE_NATIVE_AMS), true)
INTERNAL_JSR_211_NATIVE_FILES += \
	jsr211_nams_installer.c \
	jsr211_nams_initializer_kni.c
endif

# Specify romizer configuration file for the jsr
# and path where the file is located
#
ROMGEN_INCLUDE_PATHS += $(JSR_211_DIR)/src/config
ROMGEN_CFG_FILES     += chapi_rom.cfg

############################################################
# Native files under JSR_211 subsystem
############################################################
SUBSYSTEM_JSR_211_NATIVE_FILES += \
    $(INTERNAL_JSR_211_NATIVE_FILES) \

# Append JSR_211 source bundle creation to target
source_bundle:: chapi_source_bundle

# Create JSR_211 source in subdir 'jsr211/'
JSR_211_SOURCE_OUTPUT_DIR=$(SOURCE_OUTPUT_DIR)/jsr211

# For MIDP stack, only include necessary source files
JSR_211_SOURCE_SUBDIRS =	src/classes \
			src/config \
			src/core \
			src/i3test

# Copy and filter JSR_211 source in JSR_211_SOURCE_OUTPUT_DIR
chapi_source_bundle: JSR_211_DIR SOURCE_OUTPUT_DIR
	@echo " ... JSR 211 source bundle" $(LOG)
	@$(call re_src_filter,$(JSR_211_DIR),$(JSR_211_SOURCE_OUTPUT_DIR),\
	$(JSR_211_SOURCE_SUBDIRS))
