1*b1cdbd2cSJim Jagielski#**************************************************************
2*b1cdbd2cSJim Jagielski#
3*b1cdbd2cSJim Jagielski#  Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski#  or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski#  distributed with this work for additional information
6*b1cdbd2cSJim Jagielski#  regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski#  to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski#  "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski#  with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski#
11*b1cdbd2cSJim Jagielski#    http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski#
13*b1cdbd2cSJim Jagielski#  Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski#  software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski#  KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski#  specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski#  under the License.
19*b1cdbd2cSJim Jagielski#
20*b1cdbd2cSJim Jagielski#**************************************************************
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski# Builds the OOoBean of the Developers Guide
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim JagielskiPRJ=../../../..
25*b1cdbd2cSJim JagielskiSETTINGS=$(PRJ)/settings
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/settings.mk
28*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/std.mk
29*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/dk.mk
30*b1cdbd2cSJim Jagielski
31*b1cdbd2cSJim Jagielski# Define non-platform/compiler specific settings
32*b1cdbd2cSJim JagielskiSAMPLE_NAME=SayHello
33*b1cdbd2cSJim JagielskiSAMPLE_CLASS_OUT = $(OUT_CLASS)/ScriptingFramework/$(SAMPLE_NAME)
34*b1cdbd2cSJim JagielskiSAMPLE_GEN_OUT = $(OUT_MISC)/ScriptingFramework
35*b1cdbd2cSJim Jagielski
36*b1cdbd2cSJim JagielskiSCRIPT_NAME=SayHello
37*b1cdbd2cSJim JagielskiSCRIPT_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(SCRIPT_NAME)
38*b1cdbd2cSJim JagielskiSCRIPT_GEN_OUT=$(SAMPLE_GEN_OUT)/$(SCRIPT_NAME)
39*b1cdbd2cSJim JagielskiSCRIPT_JAR_NAME=$(SCRIPT_NAME).jar
40*b1cdbd2cSJim JagielskiSCRIPT_JAR=$(SAMPLE_CLASS_OUT)/$(SCRIPT_JAR_NAME)
41*b1cdbd2cSJim JagielskiSCRIPT_PACKAGE = $(OUT_BIN)/$(SCRIPT_NAME).$(UNOOXT_EXT)
42*b1cdbd2cSJim JagielskiSCRIPT_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(SCRIPT_NAME).$(UNOOXT_EXT)")
43*b1cdbd2cSJim JagielskiSCRIPT_REGISTERFLAG=$(SCRIPT_GEN_OUT)$(PS)devguide_scriptingframework_$(SCRIPT_NAME)_register_scriptpkg.flag
44*b1cdbd2cSJim Jagielski
45*b1cdbd2cSJim JagielskiJAVAFILES  = \
46*b1cdbd2cSJim Jagielski	SayHello/SayHello.java
47*b1cdbd2cSJim Jagielski
48*b1cdbd2cSJim JagielskiCLASSFILES = $(patsubst %.java,$(SCRIPT_CLASS_OUT)/%.class,$(subst $(SAMPLE_NAME)/,,$(JAVAFILES)))
49*b1cdbd2cSJim Jagielski
50*b1cdbd2cSJim JagielskiSDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
51*b1cdbd2cSJim Jagielski		$(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT))
52*b1cdbd2cSJim Jagielski
53*b1cdbd2cSJim Jagielski# Targets
54*b1cdbd2cSJim Jagielski.PHONY: ALL
55*b1cdbd2cSJim JagielskiALL : \
56*b1cdbd2cSJim Jagielski	SayHelloExample
57*b1cdbd2cSJim Jagielski
58*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/stdtarget.mk
59*b1cdbd2cSJim Jagielski
60*b1cdbd2cSJim Jagielski$(CLASSFILES) : $(JAVAFILES)
61*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
62*b1cdbd2cSJim Jagielski	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SCRIPT_CLASS_OUT) $(JAVAFILES)
63*b1cdbd2cSJim Jagielski
64*b1cdbd2cSJim Jagielski$(SCRIPT_JAR) : $(CLASSFILES)
65*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
66*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
67*b1cdbd2cSJim Jagielski	$(SDK_JAR) cvf $@ $(CLASSNAMES) -C $(SCRIPT_CLASS_OUT) .
68*b1cdbd2cSJim Jagielski
69*b1cdbd2cSJim Jagielski# rule for component package file
70*b1cdbd2cSJim Jagielski$(SCRIPT_PACKAGE) : $(SCRIPT_JAR) META-INF/manifest.xml $(SCRIPT_NAME)/parcel-descriptor.xml
71*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
72*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
73*b1cdbd2cSJim Jagielski	$(SDK_ZIP) $@ META-INF/manifest.xml $(SCRIPT_NAME)/parcel-descriptor.xml
74*b1cdbd2cSJim Jagielski	cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)/..) && $(SDK_ZIP) -u ../../bin/$(@F) $(SAMPLE_NAME)/$(SCRIPT_JAR_NAME)
75*b1cdbd2cSJim Jagielski
76*b1cdbd2cSJim Jagielski$(SCRIPT_REGISTERFLAG) : $(SCRIPT_PACKAGE)
77*b1cdbd2cSJim Jagielskiifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
78*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
79*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
80*b1cdbd2cSJim Jagielski	$(DEPLOYTOOL) $(SCRIPT_PACKAGE_URL)
81*b1cdbd2cSJim Jagielski	@echo flagged > $(subst /,$(PS),$@)
82*b1cdbd2cSJim Jagielskielse
83*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
84*b1cdbd2cSJim Jagielski	@echo  If you want to install your component automatically, please set the environment
85*b1cdbd2cSJim Jagielski	@echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
86*b1cdbd2cSJim Jagielski	@echo  possible if no office instance is running.
87*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
88*b1cdbd2cSJim Jagielskiendif
89*b1cdbd2cSJim Jagielski
90*b1cdbd2cSJim Jagielski
91*b1cdbd2cSJim JagielskiSayHelloExample : $(SCRIPT_REGISTERFLAG)
92*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
93*b1cdbd2cSJim Jagielski	@echo The "$(QM)$(SCRIPT_NAME)$(QM)" scripting package was installed in your office installation
94*b1cdbd2cSJim Jagielski	@echo if SDK_AUTO_DEPLOYMENT = YES. If you want to run the script, start the Office
95*b1cdbd2cSJim Jagielski	@echo and use the Tools/Macros/Run Macro menu item.
96*b1cdbd2cSJim Jagielski	@echo You can also load the document "$(QM)$(SCRIPT_NAME).odt$(QM)" and press the button to run the
97*b1cdbd2cSJim Jagielski	@echo script.
98*b1cdbd2cSJim Jagielski	@echo -
99*b1cdbd2cSJim Jagielski	@echo $(MAKE) $(SCRIPT_NAME).odt.load
100*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
101*b1cdbd2cSJim Jagielski
102*b1cdbd2cSJim Jagielski$(SCRIPT_NAME).odt.load : $(SCRIPT_REGISTERFLAG)
103*b1cdbd2cSJim Jagielski	"$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
104*b1cdbd2cSJim Jagielski
105*b1cdbd2cSJim Jagielski%.run: $(CLASSFILES)
106*b1cdbd2cSJim Jagielski	$(SDK_JAVA) -classpath "$(SDK_CLASSPATH)" $(subst /,.,$(PACKAGE)).$(basename $@)
107*b1cdbd2cSJim Jagielski
108*b1cdbd2cSJim Jagielski%.dbg: $(JAR1_JAR)
109*b1cdbd2cSJim Jagielski	jdb -classpath "$(SDK_CLASSPATH)" $(subst /,.,$(PACKAGE)).$(basename $@)
110*b1cdbd2cSJim Jagielski
111*b1cdbd2cSJim Jagielski.PHONY: clean
112*b1cdbd2cSJim Jagielskiclean :
113*b1cdbd2cSJim Jagielski	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
114*b1cdbd2cSJim Jagielski	-$(DELRECURSIVE) $(subst /,$(PS),$(SCRIPT_GEN_OUT))
115*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(SCRIPT_PACKAGE_URL)))
116*b1cdbd2cSJim Jagielski
117