1#*************************************************************************
2#
3#  The Contents of this file are made available subject to the terms of
4#  the BSD license.
5#
6#  Copyright 2000, 2010 Oracle and/or its affiliates.
7#  All rights reserved.
8#
9#  Redistribution and use in source and binary forms, with or without
10#  modification, are permitted provided that the following conditions
11#  are met:
12#  1. Redistributions of source code must retain the above copyright
13#     notice, this list of conditions and the following disclaimer.
14#  2. Redistributions in binary form must reproduce the above copyright
15#     notice, this list of conditions and the following disclaimer in the
16#     documentation and/or other materials provided with the distribution.
17#  3. Neither the name of Sun Microsystems, Inc. nor the names of its
18#     contributors may be used to endorse or promote products derived
19#     from this software without specific prior written permission.
20#
21#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24#  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25#  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26#  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27#  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28#  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29#  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30#  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
31#  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32#
33#**************************************************************************
34
35# Builds the OOoBean of the Developers Guide
36
37PRJ=../../../..
38SETTINGS=$(PRJ)/settings
39
40include $(SETTINGS)/settings.mk
41include $(SETTINGS)/std.mk
42include $(SETTINGS)/dk.mk
43
44# Define non-platform/compiler specific settings
45SAMPLE_NAME=SayHello
46SAMPLE_CLASS_OUT = $(OUT_CLASS)/ScriptingFramework/$(SAMPLE_NAME)
47SAMPLE_GEN_OUT = $(OUT_MISC)/ScriptingFramework
48
49SCRIPT_NAME=SayHello
50SCRIPT_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(SCRIPT_NAME)
51SCRIPT_GEN_OUT=$(SAMPLE_GEN_OUT)/$(SCRIPT_NAME)
52SCRIPT_JAR_NAME=$(SCRIPT_NAME).jar
53SCRIPT_JAR=$(SAMPLE_CLASS_OUT)/$(SCRIPT_JAR_NAME)
54SCRIPT_PACKAGE = $(OUT_BIN)/$(SCRIPT_NAME).$(UNOOXT_EXT)
55SCRIPT_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(SCRIPT_NAME).$(UNOOXT_EXT)")
56SCRIPT_REGISTERFLAG=$(SCRIPT_GEN_OUT)$(PS)devguide_scriptingframework_$(SCRIPT_NAME)_register_scriptpkg.flag
57
58JAVAFILES  = \
59	SayHello/SayHello.java
60
61CLASSFILES = $(patsubst %.java,$(SCRIPT_CLASS_OUT)/%.class,$(subst $(SAMPLE_NAME)/,,$(JAVAFILES)))
62
63SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
64		$(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT))
65
66# Targets
67.PHONY: ALL
68ALL : \
69	SayHelloExample
70
71include $(SETTINGS)/stdtarget.mk
72
73$(CLASSFILES) : $(JAVAFILES)
74	-$(MKDIR) $(subst /,$(PS),$(@D))
75	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SCRIPT_CLASS_OUT) $(JAVAFILES)
76
77$(SCRIPT_JAR) : $(CLASSFILES)
78	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
79	-$(MKDIR) $(subst /,$(PS),$(@D))
80	$(SDK_JAR) cvf $@ $(CLASSNAMES) -C $(SCRIPT_CLASS_OUT) .
81
82# rule for component package file
83$(SCRIPT_PACKAGE) : $(SCRIPT_JAR) META-INF/manifest.xml $(SCRIPT_NAME)/parcel-descriptor.xml
84	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
85	-$(MKDIR) $(subst /,$(PS),$(@D))
86	$(SDK_ZIP) $@ META-INF/manifest.xml $(SCRIPT_NAME)/parcel-descriptor.xml
87	cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)/..) && $(SDK_ZIP) -u ../../bin/$(@F) $(SAMPLE_NAME)/$(SCRIPT_JAR_NAME)
88
89$(SCRIPT_REGISTERFLAG) : $(SCRIPT_PACKAGE)
90ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
91	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
92	-$(MKDIR) $(subst /,$(PS),$(@D))
93	$(DEPLOYTOOL) $(SCRIPT_PACKAGE_URL)
94	@echo flagged > $(subst /,$(PS),$@)
95else
96	@echo --------------------------------------------------------------------------------
97	@echo  If you want to install your component automatically, please set the environment
98	@echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
99	@echo  possible if no office instance is running.
100	@echo --------------------------------------------------------------------------------
101endif
102
103
104SayHelloExample : $(SCRIPT_REGISTERFLAG)
105	@echo --------------------------------------------------------------------------------
106	@echo The "$(QM)$(SCRIPT_NAME)$(QM)" scripting package was installed in your office installation
107	@echo if SDK_AUTO_DEPLOYMENT = YES. If you want to run the script, start the Office
108	@echo and use the Tools/Macros/Run Macro menu item.
109	@echo You can also load the document "$(QM)$(SCRIPT_NAME).odt$(QM)" and press the button to run the
110	@echo script.
111	@echo -
112	@echo $(MAKE) $(SCRIPT_NAME).odt.load
113	@echo --------------------------------------------------------------------------------
114
115$(SCRIPT_NAME).odt.load : $(SCRIPT_REGISTERFLAG)
116	"$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
117
118%.run: $(CLASSFILES)
119	$(SDK_JAVA) -classpath "$(SDK_CLASSPATH)" $(subst /,.,$(PACKAGE)).$(basename $@)
120
121%.dbg: $(JAR1_JAR)
122	jdb -classpath "$(SDK_CLASSPATH)" $(subst /,.,$(PACKAGE)).$(basename $@)
123
124.PHONY: clean
125clean :
126	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
127	-$(DELRECURSIVE) $(subst /,$(PS),$(SCRIPT_GEN_OUT))
128	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(SCRIPT_PACKAGE_URL)))
129
130