xref: /trunk/main/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/Makefile (revision fc9fd3f14a55d77b35643a64034752a178b2a5b0)
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=ScriptSelector
46SAMPLE_CLASS_OUT = $(OUT_CLASS)/ScriptingFramework/$(SAMPLE_NAME)
47SAMPLE_GEN_OUT = $(OUT_MISC)/ScriptingFramework
48
49SCRIPT_NAME=ScriptSelector
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.flag
57
58JAVAFILES  = \
59    ScriptSelector/ScriptSelector.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 : ScriptSelectorExample
69
70include $(SETTINGS)/stdtarget.mk
71
72$(CLASSFILES) : $(JAVAFILES)
73    -$(MKDIR) $(subst /,$(PS),$(@D))
74    $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SCRIPT_CLASS_OUT) $(JAVAFILES)
75
76$(SCRIPT_JAR) : $(CLASSFILES) $(SCRIPT_NAME)/container.gif $(SCRIPT_NAME)/script.gif $(SCRIPT_NAME)/soffice.gif
77    -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
78    -$(MKDIR) $(subst /,$(PS),$(@D))
79    $(COPY) $(subst /,$(PS),$(SCRIPT_NAME)/container.gif) $(subst /,$(PS),$(SCRIPT_CLASS_OUT))
80    $(COPY) $(subst /,$(PS),$(SCRIPT_NAME)/script.gif) $(subst /,$(PS),$(SCRIPT_CLASS_OUT))
81    $(COPY) $(subst /,$(PS),$(SCRIPT_NAME)/soffice.gif) $(subst /,$(PS),$(SCRIPT_CLASS_OUT))
82    $(SDK_JAR) cvf $@ -C $(SCRIPT_CLASS_OUT) .
83
84# rule for component package file
85$(SCRIPT_PACKAGE) : $(SCRIPT_JAR) META-INF/manifest.xml $(SCRIPT_NAME)/parcel-descriptor.xml
86    -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
87    -$(MKDIR) $(subst /,$(PS),$(@D))
88    $(SDK_ZIP) $@ META-INF/manifest.xml $(SCRIPT_NAME)/parcel-descriptor.xml
89    cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)/..) && $(SDK_ZIP) -u ../../bin/$(@F) $(SAMPLE_NAME)/$(SCRIPT_JAR_NAME)
90
91$(SCRIPT_REGISTERFLAG) : $(SCRIPT_PACKAGE)
92ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
93    -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
94    -$(MKDIR) $(subst /,$(PS),$(@D))
95    $(DEPLOYTOOL) $(SCRIPT_PACKAGE_URL)
96    @echo flagged > $(subst /,$(PS),$@)
97else
98    @echo --------------------------------------------------------------------------------
99    @echo  If you want to install your component automatically, please set the environment
100    @echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
101    @echo  possible if no office instance is running.
102    @echo --------------------------------------------------------------------------------
103endif
104
105
106ScriptSelectorExample : $(SCRIPT_REGISTERFLAG)
107    @echo --------------------------------------------------------------------------------
108    @echo The "$(QM)$(SCRIPT_NAME)$(QM)" scripting package was installed in your office installation
109    @echo if SDK_AUTO_DEPLOYMENT = YES. If you want to run the script, start the Office
110    @echo and use the Tools/Macros/Run Macro menu item.
111    @echo You can also load the document "$(QM)$(SCRIPT_NAME).odt$(QM)" and press the button to run
112    @echo the script.
113    @echo -
114    @echo $(MAKE) $(SCRIPT_NAME).odt.load
115    @echo --------------------------------------------------------------------------------
116
117$(SCRIPT_NAME).odt.load : $(SCRIPT_REGISTERFLAG)
118    "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
119
120%.run: $(CLASSFILES)
121    $(SDK_JAVA) -classpath "$(SDK_CLASSPATH)" $(subst /,.,$(PACKAGE)).$(basename $@)
122
123%.dbg: $(JAR1_JAR)
124    jdb -classpath "$(SDK_CLASSPATH)" $(subst /,.,$(PACKAGE)).$(basename $@)
125
126.PHONY: clean
127clean :
128    -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
129    -$(DELRECURSIVE) $(subst /,$(PS),$(SCRIPT_GEN_OUT))
130    -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SCRIPT_PACKAGE_URL)))
131
132