Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / odk / examples / DevelopersGuide / Spreadsheet / Makefile
blob39633e1769191419e4e6578bcec06171d7f53773
1 #*************************************************************************
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.
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.
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.
33 #**************************************************************************
35 # Builds the SpreadSheet examples of the Developers Guide.
37 PRJ=../../..
38 SETTINGS=$(PRJ)/settings
40 include $(SETTINGS)/settings.mk
41 include $(SETTINGS)/std.mk
43 # Define non-platform/compiler specific settings
44 SAMPLE_NAME=DevGuideSpreadsheetExamples
45 SAMPLE_CLASS_OUT=$(OUT_CLASS)/$(SAMPLE_NAME)
46 SAMPLE_GEN_OUT=$(OUT_MISC)/$(SAMPLE_NAME)
48 # Example add-in component
49 COMP1_NAME=ExampleAddIn
50 COMP1_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(COMP1_NAME)
51 COMP1_GEN_OUT=$(SAMPLE_GEN_OUT)/$(COMP1_NAME)
52 COMP1_RDB_NAME=$(COMP1_NAME).uno.rdb
53 COMP1_RDB=$(COMP1_GEN_OUT)/$(COMP1_RDB_NAME)
54 COMP1_PACKAGE=$(OUT_BIN)/$(COMP1_NAME).$(UNOOXT_EXT)
55 COMP1_PACKAGE_URL=$(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP1_NAME).$(UNOOXT_EXT)")
56 COMP1_JAR_NAME=$(COMP1_NAME).uno.jar
57 COMP1_JAR=$(SAMPLE_CLASS_OUT)/$(COMP1_JAR_NAME)
58 COMP1_MANIFESTFILE=$(COMP1_GEN_OUT)/$(COMP1_NAME).uno.Manifest
59 COMP1_UNOPKG_MANIFEST=$(COMP1_GEN_OUT)/$(COMP1_NAME)/META-INF/manifest.xml
60 COMP1_REGISTERFLAG=$(SAMPLE_GEN_OUT)/devguide_$(COMP1_NAME)_register_component.flag
61 COMP1_COMPONENTS=$(COMP1_NAME).components
63 # Example DataPilot component
64 COMP2_NAME=ExampleDataPilotSource
65 COMP2_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(COMP2_NAME)
66 COMP2_GEN_OUT=$(SAMPLE_GEN_OUT)/$(COMP2_NAME)
67 COMP2_PACKAGE=$(OUT_BIN)/$(COMP2_NAME).$(UNOOXT_EXT)
68 COMP2_PACKAGE_URL=$(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP2_NAME).$(UNOOXT_EXT)")
69 COMP2_JAR_NAME=$(COMP2_NAME).uno.jar
70 COMP2_JAR=$(SAMPLE_CLASS_OUT)/$(COMP2_JAR_NAME)
71 COMP2_MANIFESTFILE=$(COMP2_GEN_OUT)/$(COMP2_NAME).uno.Manifest
72 COMP2_UNOPKG_MANIFEST=$(COMP2_GEN_OUT)/$(COMP2_NAME)/META-INF/manifest.xml
73 COMP2_REGISTERFLAG=$(SAMPLE_GEN_OUT)/devguide_$(COMP2_NAME)_register_component.flag
74 COMP2_COMPONENTS=$(COMP2_NAME).components
76 #REGISTERFLAG = $(OUT_MISC)$(PS)devguide_$(SAMPLE_NAME)_register_component.flag
78 APP1_NAME=GeneralTableSample
79 APP1_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP1_NAME)
80 APP1_GEN_OUT=$(SAMPLE_GEN_OUT)/$(APP1_NAME)
81 APP1_JAR=$(SAMPLE_CLASS_OUT)/$(APP1_NAME).jar
83 APP2_NAME=SpreadsheetSample
84 APP2_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP2_NAME)
85 APP2_GEN_OUT=$(SAMPLE_GEN_OUT)/$(APP2_NAME)
86 APP2_JAR=$(SAMPLE_CLASS_OUT)/$(APP2_NAME).jar
88 APP3_NAME=ViewSample
89 APP3_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP3_NAME)
90 APP3_GEN_OUT=$(SAMPLE_GEN_OUT)/$(APP3_NAME)
91 APP3_JAR=$(SAMPLE_CLASS_OUT)/$(APP3_NAME).jar
94 COMP1_IDLFILES = XExampleAddIn.idl
96 # normally the idl file should be stored in a directory tree fitting the
97 # module structure, for the example we know the module structure
98 PACKAGE = org/openoffice/sheet/addin
100 COMP1_JAVAFILES = \
101 ExampleAddIn.java
103 COMP2_JAVAFILES = \
104 ExampleDataPilotSource.java
106 APP_JAVAFILES = \
107 SpreadsheetDocHelper.java
109 APP_CLASSFILES = $(patsubst %.java,$(SAMPLE_CLASS_OUT)/%.class,$(APP_JAVAFILES))
110 APP_CLASSNAMES = $(patsubst %.java,%.class,$(APP_JAVAFILES))
112 COMP1_GENCLASSFILES = $(patsubst %.idl,$(COMP1_CLASS_OUT)/$(PACKAGE)/%.class,$(COMP1_IDLFILES))
113 COMP1_GENTYPELIST = $(subst /,.,$(patsubst %.idl,-T$(PACKAGE)/% ,$(COMP1_IDLFILES)))
114 COMP1_GENURDFILES = $(patsubst %.idl,$(COMP1_GEN_OUT)/%.urd,$(COMP1_IDLFILES))
116 COMP1_CLASSFILES = $(patsubst %.java,$(COMP1_CLASS_OUT)/%.class,$(COMP1_JAVAFILES))
118 COMP2_CLASSFILES = $(patsubst %.java,$(COMP2_CLASS_OUT)/%.class,$(COMP2_JAVAFILES))
121 SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
122 $(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT)\
123 $(PATH_SEPARATOR)$(COMP1_CLASS_OUT)\
124 $(PATH_SEPARATOR)$(COMP2_CLASS_OUT)\
125 $(PATH_SEPARATOR)$(APP1_CLASS_OUT)\
126 $(PATH_SEPARATOR)$(APP2_CLASS_OUT)\
127 $(PATH_SEPARATOR)$(APP3_CLASS_OUT))
130 # Targets
131 .PHONY: ALL
132 ALL : $(SAMPLE_NAME)
134 include $(SETTINGS)/stdtarget.mk
136 $(SAMPLE_GEN_OUT)/%.Manifest :
137 -$(MKDIR) $(subst /,$(PS),$(@D))
138 @echo UNO-Type-Path: $(basename $(notdir $*)).uno.jar> $@
139 @echo RegistrationClassName: $(basename $(basename $(@F)))>> $@
141 # IDLs only for component 1 relevant
142 $(COMP1_GEN_OUT)/%.urd : %.idl
143 -$(MKDIR) $(subst /,$(PS),$(@D))
144 $(IDLC) -I. -I$(IDL_DIR) -O$(COMP1_GEN_OUT) $^
146 $(COMP1_RDB) : $(COMP1_GENURDFILES)
147 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
148 -$(MKDIR) $(subst /,$(PS),$(@D))
149 $(REGMERGE) $@ /UCR $<
151 $(COMP1_CLASS_OUT)/$(PACKAGE)/%.class : $(COMP1_RDB)
152 -$(MKDIR) $(subst /,$(PS),$(@D))
153 $(JAVAMAKER) -nD $(COMP1_GENTYPELIST) -O$(COMP1_CLASS_OUT) $(COMP1_RDB) -X$(URE_TYPES) -X$(OFFICE_TYPES)
155 $(COMP1_CLASSFILES) : $(COMP1_JAVAFILES) $(COMP1_GENCLASSFILES)
156 -$(MKDIR) $(subst /,$(PS),$(@D))
157 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(COMP1_CLASS_OUT) $(COMP1_JAVAFILES)
159 $(COMP2_CLASSFILES) : $(COMP2_JAVAFILES)
160 -$(MKDIR) $(subst /,$(PS),$(@D))
161 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(COMP2_CLASS_OUT) $^
163 $(COMP1_JAR) : $(COMP1_MANIFESTFILE) $(COMP1_CLASSFILES)
164 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
165 -$(MKDIR) $(subst /,$(PS),$(@D))
166 $(SDK_JAR) cvfm $@ $< -C $(COMP1_CLASS_OUT) .
168 $(COMP2_JAR) : $(COMP2_MANIFESTFILE) $(COMP2_CLASSFILES)
169 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
170 -$(MKDIR) $(subst /,$(PS),$(@D))
171 $(SDK_JAR) cvfm $@ $< -C $(COMP2_CLASS_OUT) .
173 $(COMP1_UNOPKG_MANIFEST) :
174 -$(MKDIR) $(subst /,$(PS),$(@D))
175 @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
176 @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
177 @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
178 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@
179 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(COMP1_GEN_OUT)/,,$(@D))).uno.rdb$(QM)"/$(CSEP) >> $@
180 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
181 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP1_COMPONENTS)$(QM)"/$(CSEP)>> $@
182 @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
184 $(COMP2_UNOPKG_MANIFEST) :
185 -$(MKDIR) $(subst /,$(PS),$(@D))
186 @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
187 @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
188 @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
189 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
190 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP2_COMPONENTS)$(QM)"/$(CSEP)>> $@
191 @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
193 $(COMP1_PACKAGE) : $(COMP1_RDB) $(COMP1_JAR) $(COMP1_UNOPKG_MANIFEST) $(COMP1_COMPONENTS)
194 echo "####" $(@)
195 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
196 -$(MKDIR) $(subst /,$(PS),$(@D))
197 $(SDK_ZIP) $@ $(COMP1_COMPONENTS)
198 cd $(subst /,$(PS),$(COMP1_GEN_OUT)) && $(SDK_ZIP) -u ../../../bin/$(@F) $(<F)
199 cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP1_JAR_NAME)
200 cd $(subst /,$(PS),$(COMP1_GEN_OUT)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../../bin/$(@F) META-INF/manifest.xml
202 $(COMP2_PACKAGE) : $(COMP2_JAR) $(COMP2_UNOPKG_MANIFEST) $(COMP2_COMPONENTS)
203 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
204 -$(MKDIR) $(subst /,$(PS),$(@D))
205 $(SDK_ZIP) $@ $(COMP2_COMPONENTS)
206 cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_ZIP) -u ../../bin/$(@F) $(<F)
207 cd $(subst /,$(PS),$(COMP2_GEN_OUT)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../../bin/$(@F) META-INF/manifest.xml
209 $(SAMPLE_GEN_OUT)/devguide_$(COMP1_NAME)_register_component.flag : $(OUT_BIN)/$(COMP1_NAME).$(UNOOXT_EXT)
210 ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
211 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
212 -$(MKDIR) $(subst /,$(PS),$(@D))
213 $(DEPLOYTOOL) $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP1_NAME).$(UNOOXT_EXT)")
214 @echo flagged > $(subst /,$(PS),$@)
215 else
216 @echo --------------------------------------------------------------------------------
217 @echo If you want to install your component automatically, please set the environment
218 @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
219 @echo possible if no office instance is running.
220 @echo --------------------------------------------------------------------------------
221 endif
223 $(SAMPLE_GEN_OUT)/devguide_$(COMP2_NAME)_register_component.flag : $(OUT_BIN)/$(COMP2_NAME).$(UNOOXT_EXT)
224 ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
225 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
226 -$(MKDIR) $(subst /,$(PS),$(@D))
227 $(DEPLOYTOOL) $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP2_NAME).$(UNOOXT_EXT)")
228 @echo flagged > $(subst /,$(PS),$@)
229 else
230 @echo --------------------------------------------------------------------------------
231 @echo If you want to install your component automatically, please set the environment
232 @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
233 @echo possible if no office instance is running.
234 @echo --------------------------------------------------------------------------------
235 endif
237 $(APP_CLASSFILES) : $(APP_JAVAFILES)
238 -$(MKDIR) $(subst /,$(PS),$(@D))
239 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $(APP_JAVAFILES)
241 $(APP1_CLASS_OUT)/%.class : %.java $(APP_CLASSFILES)
242 -$(MKDIR) $(subst /,$(PS),$(@D))
243 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP1_CLASS_OUT) $<
245 $(APP2_CLASS_OUT)/%.class : %.java $(APP_CLASSFILES)
246 -$(MKDIR) $(subst /,$(PS),$(@D))
247 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP2_CLASS_OUT) $<
249 $(APP3_CLASS_OUT)/%.class : %.java $(APP_CLASSFILES)
250 -$(MKDIR) $(subst /,$(PS),$(@D))
251 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP3_CLASS_OUT) $<
253 $(SAMPLE_GEN_OUT)/%.mf :
254 -$(MKDIR) $(subst /,$(PS),$(@D))
255 @echo Main-Class: com.sun.star.lib.loader.Loader> $@
256 $(ECHOLINE)>> $@
257 @echo Name: com/sun/star/lib/loader/Loader.class>> $@
258 @echo Application-Class: $(basename $(@F))>> $@
260 $(APP1_JAR) : $(APP1_GEN_OUT)/$(APP1_NAME).mf $(APP1_CLASS_OUT)/$(APP1_NAME).class $(APP_CLASSFILES)
261 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
262 -$(MKDIR) $(subst /,$(PS),$(@D))
263 +$(SDK_JAR) cvfm $@ $< -C $(APP1_CLASS_OUT) .
264 +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
265 +cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) uvf $(@F) $(APP_CLASSNAMES)
267 $(APP2_JAR) : $(APP2_GEN_OUT)/$(APP2_NAME).mf $(APP2_CLASS_OUT)/$(APP2_NAME).class $(APP_CLASSFILES)
268 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
269 -$(MKDIR) $(subst /,$(PS),$(@D))
270 +$(SDK_JAR) cvfm $@ $< -C $(APP2_CLASS_OUT) .
271 +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
272 +cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) uvf $(@F) $(APP_CLASSNAMES)
274 $(APP3_JAR) : $(APP3_GEN_OUT)/$(APP3_NAME).mf $(APP3_CLASS_OUT)/$(APP3_NAME).class $(APP_CLASSFILES)
275 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
276 -$(MKDIR) $(subst /,$(PS),$(@D))
277 +$(SDK_JAR) cvfm $@ $< -C $(APP3_CLASS_OUT) .
278 +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
279 +cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) uvf $(@F) $(APP_CLASSNAMES)
281 $(SAMPLE_NAME) : $(COMP1_REGISTERFLAG) $(COMP2_REGISTERFLAG) $(APP1_JAR) $(APP2_JAR) $(APP3_JAR)
282 @echo --------------------------------------------------------------------------------
283 @echo Please use one of the following commands to execute the examples!
284 @echo -
285 @echo $(MAKE) $(APP1_NAME).run
286 @echo $(MAKE) $(APP2_NAME).run
287 @echo $(MAKE) $(APP3_NAME).run
288 @echo --------
289 @echo The "$(QM)$(COMP1_NAME)$(QM)" and "$(QM)$(COMP2_NAME)$(QM)" component are installed if
290 @echo SDK_AUTO_DEPLOYMENT = YES. You can use this components inside your office
291 @echo installation, see the example descriptions. You can also load the "$(QM)ExampleAddIn.ods$(QM)"
292 @echo document to see how the add-in functions can be used. For more details about the
293 @echo "$(QM)$(COMP2_NAME)$(QM)" component see the "$(QM)DataPilotReadme.txt"$(QM).
294 @echo -
295 @echo $(MAKE) ExampleAddIn.ods.load
296 @echo --------------------------------------------------------------------------------
298 %.run: $(SAMPLE_CLASS_OUT)/%.jar
299 $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
301 ExampleAddIn.ods.load : $(COMP1_REGISTERFLAG)
302 "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
304 .PHONY: clean
305 clean :
306 -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
307 -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
308 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP1_PACKAGE_URL)))
309 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP2_PACKAGE_URL)))