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