Get the style color and number just once
[LibreOffice.git] / odk / examples / DevelopersGuide / Components / JavaComponent / Makefile
bloba20c5f44406d3a83595e1c62883b1ef3d1c542d7
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
45 COMP_NAME=JavaComponent
46 OUT_COMP_CLASS = $(OUT_CLASS)/$(COMP_NAME)
47 OUT_COMP_GEN = $(OUT_MISC)/$(COMP_NAME)
48 COMP_RDB_NAME = $(COMP_NAME).uno.rdb
49 COMP_RDB = $(OUT_COMP_GEN)/$(COMP_RDB_NAME)
50 COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
51 COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
52 COMP_JAR_NAME = $(COMP_NAME).uno.jar
53 COMP_JAR = $(OUT_COMP_CLASS)/$(COMP_JAR_NAME)
54 COMP_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMP_NAME).uno.Manifest
55 COMP_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP_NAME)/META-INF/manifest.xml
56 COMP_COMPONENTS=$(COMP_NAME).components
58 APP1_NAME=TestJavaComponent
59 APP1_JAR=$(OUT_COMP_CLASS)/$(APP1_NAME).jar
61 REGISTERFLAG = $(OUT_MISC)$(PS)devguide_$(COMP_NAME)_register_component.flag
63 IDLFILES = XSomethingA.idl \
64 XSomethingB.idl \
65 SomethingA.idl \
66 SomethingB.idl
68 PACKAGE = com/sun/star/test
70 COMPJAVAFILES = \
71 TestComponentA.java \
72 TestComponentB.java \
73 TestServiceProvider.java
75 GENCLASSFILES = $(patsubst %.idl,$(OUT_COMP_CLASS)/$(PACKAGE)/%.class,$(IDLFILES))
76 GENCLASSNAMES = $(patsubst %.idl,$(PACKAGE)/%.class,$(IDLFILES))
77 GENTYPELIST = $(subst /,.,$(patsubst %.idl,-T$(PACKAGE)/% ,$(IDLFILES)))
79 COMPCLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(COMPJAVAFILES))
81 $(COMP_NAME)_CLASSFILES = $(patsubst %.java,%.class,$(COMPJAVAFILES))
83 $(COMP_NAME)_CLASSFILES += $(subst $(OUT_COMP_CLASS)/,,$(GENCLASSFILES))
85 SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
86 $(PATH_SEPARATOR)$(OUT_COMP_CLASS))
89 # Targets
90 .PHONY: ALL
91 ALL : \
92 JavaComponentExample
94 include $(SETTINGS)/stdtarget.mk
96 $(OUT_COMP_CLASS)/%.Manifest :
97 -$(MKDIR) $(subst /,$(PS),$(@D))
98 @echo UNO-Type-Path: $(basename $(notdir $*)).uno.jar> $@
99 @echo RegistrationClassName: TestServiceProvider>> $@
101 $(OUT_COMP_GEN)/%.rdb : $(patsubst %,$(PACKAGE)/%,$(IDLFILES))
102 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
103 -$(MKDIR) $(subst /,$(PS),$(@D))
104 $(UNOIDLWRITE) $(URE_TYPES) $(OFFICE_TYPES) . $@
106 $(OUT_COMP_CLASS)/$(PACKAGE)/%.class : $(COMP_RDB)
107 -$(MKDIR) $(subst /,$(PS),$(@D))
108 $(JAVAMAKER) -nD $(GENTYPELIST) -O$(OUT_COMP_CLASS) $(COMP_RDB) -X$(URE_TYPES) -X$(OFFICE_TYPES)
110 $(OUT_COMP_CLASS)/%.class : %.java $(GENCLASSFILES)
111 -$(MKDIR) $(subst /,$(PS),$(@D))
112 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $<
114 $(COMPCLASSFILES) : $(COMPJAVAFILES) $(GENCLASSFILES)
115 -$(MKDIR) $(subst /,$(PS),$(@D))
116 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(COMPJAVAFILES)
118 # rule for client/example application manifest file
119 $(OUT_COMP_CLASS)/%.mf :
120 -$(MKDIR) $(subst /,$(PS),$(@D))
121 @echo Main-Class: com.sun.star.lib.loader.Loader> $@
122 $(ECHOLINE)>> $@
123 @echo Name: com/sun/star/lib/loader/Loader.class>> $@
124 @echo Application-Class: $*>> $@
126 # rule for client/example application jar file
127 # Note that the example needs the component files as well for local usage
128 $(APP1_JAR) : $(OUT_COMP_CLASS)/$(APP1_NAME).mf $(OUT_COMP_CLASS)/$(APP1_NAME).class $(COMPCLASSFILES) $(GENCLASSFILES)
129 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
130 -$(MKDIR) $(subst /,$(PS),$(@D))
131 +cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(basename $(@F)).class $($(COMP_NAME)_CLASSFILES)
132 +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
134 # rule for component jar file
135 $(COMP_JAR) : $(COMP_MANIFESTFILE) $(COMPCLASSFILES)
136 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
137 -$(MKDIR) $(subst /,$(PS),$(@D))
138 cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
140 # rule for component package manifest
141 $(OUT_COMP_CLASS)/%/manifest.xml :
142 -$(MKDIR) $(subst /,$(PS),$(@D))
143 @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
144 @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
145 @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
146 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@
147 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_CLASS)/,,$(@D))).uno.rdb$(QM)"/$(CSEP) >> $@
148 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
149 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_COMPONENTS)$(QM)"/$(CSEP)>> $@
150 @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
152 # rule for component package file
153 $(COMP_PACKAGE) : $(COMP_RDB) $(COMP_JAR) $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS) description.xml
154 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
155 -$(MKDIR) $(subst /,$(PS),$(@D))
156 $(COPY) $(subst /,$(PS),$(COMP_RDB)) $(subst /,$(PS),$(OUT_COMP_CLASS))
157 $(SDK_ZIP) $@ $(COMP_COMPONENTS) description.xml
158 cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_RDB_NAME) $(COMP_JAR_NAME)
159 cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
160 $(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_COMP_CLASS)/$(COMP_RDB_NAME)))
162 $(REGISTERFLAG) : $(COMP_PACKAGE)
163 ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
164 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
165 -$(MKDIR) $(subst /,$(PS),$(@D))
166 $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
167 @echo flagged > $(subst /,$(PS),$@)
168 else
169 @echo --------------------------------------------------------------------------------
170 @echo If you want to install your component automatically, please set the environment
171 @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
172 @echo possible if no office instance is running.
173 @echo --------------------------------------------------------------------------------
174 endif
176 JavaComponentExample : $(REGISTERFLAG) $(APP1_JAR)
177 @echo --------------------------------------------------------------------------------
178 @echo Please use one of the following commands to execute the examples!
179 @echo -
180 @echo $(MAKE) $(APP1_NAME).run
181 @echo $(MAKE) $(APP1_NAME).local
182 @echo --------
183 @echo The Java components were installed if SDK_AUTO_DEPLOYMENT = YES.
184 @echo You can use this component inside your office installation, see the
185 @echo example description.
186 @echo --------------------------------------------------------------------------------
188 %.run: $(OUT_COMP_CLASS)/%.jar
189 $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
191 %.local: $(OUT_COMP_CLASS)/%.jar
192 $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< local
194 .PHONY: clean
195 clean :
196 -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
197 -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
198 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
199 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG)))