cid#1607171 Data race condition
[LibreOffice.git] / odk / examples / java / Spreadsheet / Makefile
blobf4d845be9fda17b0ba927551540da0b6e637795d
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 Java Spreadsheet examples of the SDK.
37 PRJ=../../..
38 SETTINGS=$(PRJ)/settings
40 include $(SETTINGS)/settings.mk
41 include $(SETTINGS)/std.mk
43 # Define non-platform/compiler specific settings
44 EXAMPLE_NAME=JavaSpreadsheetExamples
45 OUT_COMP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
46 OUT_COMP_GEN = $(OUT_MISC)/$(EXAMPLE_NAME)
48 APP1_NAME=EuroAdaption
49 APP1_JAR=$(OUT_COMP_CLASS)/$(APP1_NAME).jar
50 APP2_NAME=SCalc
51 APP2_JAR=$(OUT_COMP_CLASS)/$(APP2_NAME).jar
52 APP3_NAME=ChartTypeChange
53 APP3_JAR=$(OUT_COMP_CLASS)/$(APP3_NAME).jar
55 COMP_NAME=CalcAddins
56 COMP_RDB_NAME=$(COMP_NAME).uno.rdb
57 COMP_RDB=$(OUT_COMP_GEN)/$(COMP_RDB_NAME)
58 COMP_PACKAGE=$(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
59 COMP_PACKAGE_URL=$(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
60 COMP_JAR_NAME=$(COMP_NAME).uno.jar
61 COMP_JAR=$(OUT_COMP_CLASS)/$(COMP_JAR_NAME)
62 COMP_MANIFESTFILE=$(OUT_COMP_CLASS)/$(COMP_NAME).uno.Manifest
63 COMP_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP_NAME)/META-INF/manifest.xml
64 COMP_REGISTERFLAG=$(OUT_MISC)$(PS)java_$(COMP_NAME)_register_component.flag
65 COMP_COMPONENTS=$(COMP_NAME).components
67 IDLFILES = XCalcAddins.idl
69 # normally the idl file should be stored in a directory tree fitting the module structure,
70 # for the example we know the module structure
71 PACKAGE = org/openoffice/sheet/addin
73 COMPJAVAFILES = CalcAddins.java
75 #GENJAVAFILES = $(patsubst %.idl,$(OUT_COMP_GEN)/$(PACKAGE)/%.java,$(IDLFILES))
76 GENCLASSFILES = $(patsubst %.idl,$(OUT_COMP_CLASS)/$(PACKAGE)/%.class,$(IDLFILES))
77 GENTYPELIST = $(subst /,.,$(patsubst %.idl,-T$(PACKAGE)/% ,$(IDLFILES)))
79 COMPCLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(COMPJAVAFILES))
80 #COMPCLASSFILES += $(subst $(OUT_COMP_GEN),$(OUT_COMP_CLASS),$(GENJAVAFILES:.java=.class))
82 $(COMP_NAME)_CLASSFILES = $(COMP_NAME).class \
83 $(COMP_NAME)$(QUOTE)$$_$(COMP_NAME).class
85 #$(COMP_NAME)_CLASSFILES += $(subst $(OUT_COMP_GEN)/,,$(GENJAVAFILES:.java=.class))
86 $(COMP_NAME)_CLASSFILES += $(subst $(OUT_COMP_CLASS)/,,$(GENCLASSFILES))
88 SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
89 $(PATH_SEPARATOR)$(OUT_COMP_CLASS))
91 # Targets
92 .PHONY: ALL
93 ALL : $(EXAMPLE_NAME)
95 include $(SETTINGS)/stdtarget.mk
97 # rule for a component manifest file
98 $(OUT_COMP_CLASS)/%.Manifest :
99 -$(MKDIR) $(subst /,$(PS),$(@D))
100 @echo UNO-Type-Path: $(basename $*).uno.jar> $@
101 @echo RegistrationClassName: $(basename $*)>> $@
103 $(OUT_COMP_GEN)/%.rdb : $(IDLFILES)
104 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
105 -$(MKDIR) $(subst /,$(PS),$(@D))
106 $(UNOIDLWRITE) $(URE_TYPES) $(OFFICE_TYPES) $< $@
108 #$(OUT_COMP_GEN)/%.java : $(COMP_RDB)
109 $(GENCLASSFILES) : $(COMP_RDB)
110 -$(MKDIR) $(subst /,$(PS),$(@D))
111 $(JAVAMAKER) -nD $(GENTYPELIST) -O$(OUT_COMP_CLASS) $(COMP_RDB) -X$(URE_TYPES) -X$(OFFICE_TYPES)
113 $(OUT_COMP_CLASS)/%.class : %.java
114 -$(MKDIR) $(subst /,$(PS),$(@D))
115 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $<
117 # only the component depends on the generated types
118 $(COMPCLASSFILES) : $(JAVAFILES) $(GENCLASSFILES)
119 -$(MKDIR) $(subst /,$(PS),$(@D))
120 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(COMPJAVAFILES)
122 # rule for client/example application manifest file
123 $(OUT_COMP_CLASS)/%.mf :
124 -$(MKDIR) $(subst /,$(PS),$(@D))
125 @echo Main-Class: com.sun.star.lib.loader.Loader> $@
126 $(ECHOLINE)>> $@
127 @echo Name: com/sun/star/lib/loader/Loader.class>> $@
128 @echo Application-Class: $*>> $@
130 # rule for client/example application jar file
131 $(OUT_COMP_CLASS)/%.jar : $(OUT_COMP_CLASS)/%.mf $(OUT_COMP_CLASS)/%.class
132 -$(MKDIR) $(subst /,$(PS),$(@D))
133 +cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $*.mf $*.class
134 +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
136 # rule for component jar file
137 $(COMP_JAR) : $(COMP_MANIFESTFILE) $(COMPCLASSFILES)
138 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
139 -$(MKDIR) $(subst /,$(PS),$(@D))
140 cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
142 # rule for component package manifest
143 $(OUT_COMP_CLASS)/%/manifest.xml :
144 -$(MKDIR) $(subst /,$(PS),$(@D))
145 @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
146 @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
147 @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
148 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@
149 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_CLASS)/,,$(@D))).uno.rdb$(QM)"/$(CSEP) >> $@
150 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
151 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@
152 @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
154 # rule for component package file
155 $(COMP_PACKAGE) : $(COMP_RDB) $(COMP_JAR) $(COMP_UNOPKG_MANIFEST) $(COMP_NAME).components description.xml
156 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
157 -$(MKDIR) $(subst /,$(PS),$(@D))
158 $(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_CLASS))
159 $(SDK_ZIP) $@ -u $(COMP_NAME).components description.xml
160 cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_RDB_NAME) $(COMP_JAR_NAME)
161 cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
162 $(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_COMP_CLASS)/$(<F)))
164 $(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
165 ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
166 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
167 -$(MKDIR) $(subst /,$(PS),$(@D))
168 $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
169 @echo flagged > $(subst /,$(PS),$@)
170 else
171 @echo --------------------------------------------------------------------------------
172 @echo If you want to install your component automatically, please set the environment
173 @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
174 @echo possible if no office instance is running.
175 @echo --------------------------------------------------------------------------------
176 endif
178 $(APP1_JAR) : $(OUT_COMP_CLASS)/$(APP1_NAME).mf $(OUT_COMP_CLASS)/$(APP1_NAME).class
179 $(APP2_JAR) : $(OUT_COMP_CLASS)/$(APP2_NAME).mf $(OUT_COMP_CLASS)/$(APP2_NAME).class
180 $(APP3_JAR) : $(OUT_COMP_CLASS)/$(APP3_NAME).mf $(OUT_COMP_CLASS)/$(APP3_NAME).class
182 $(EXAMPLE_NAME) : $(COMP_REGISTERFLAG) $(APP1_JAR) $(APP2_JAR) $(APP3_JAR)
183 @echo --------------------------------------------------------------------------------
184 @echo Please use the following command to execute the examples!
185 @echo -
186 @echo $(MAKE) EuroAdaption.run
187 @echo $(MAKE) SCalc.run
188 @echo $(MAKE) ChartTypeChange.run
189 @echo --------------------------------------------------------------------------------
190 @echo The Calc add-in component was installed if SDK_AUTO_DEPLOYMENT = YES.
191 @echo You can use this component inside your office installation, see the example
192 @echo description. You can also load the "$(QM)CalcAddins.ods$(QM)" document to see
193 @echo how the add-in functions works.
194 @echo -
195 @echo $(MAKE) CalcAddins.ods.load
196 @echo --------------------------------------------------------------------------------
198 %.run: $(OUT_COMP_CLASS)/%.jar
199 $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
201 CalcAddins.ods.load : $(COMP_REGISTERFLAG)
202 "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
204 .PHONY: clean
205 clean :
206 -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
207 -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
208 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
209 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_REGISTERFLAG)))