merge the formfield patch from ooo-build
[ooovba.git] / odk / examples / DevelopersGuide / Components / JavaComponent / Makefile
blobbcda73051a484a5eafc0517202b4c981a0ebe232
1 #*************************************************************************
3 # $RCSfile: Makefile,v $
5 # $Revision: 1.9 $
7 # last change: $Author: rt $ $Date: 2008-07-11 14:18:30 $
9 # The Contents of this file are made available subject to the terms of
10 # the BSD license.
12 # Copyright (c) 2003 by Sun Microsystems, Inc.
13 # All rights reserved.
15 # Redistribution and use in source and binary forms, with or without
16 # modification, are permitted provided that the following conditions
17 # are met:
18 # 1. Redistributions of source code must retain the above copyright
19 # notice, this list of conditions and the following disclaimer.
20 # 2. Redistributions in binary form must reproduce the above copyright
21 # notice, this list of conditions and the following disclaimer in the
22 # documentation and/or other materials provided with the distribution.
23 # 3. Neither the name of Sun Microsystems, Inc. nor the names of its
24 # contributors may be used to endorse or promote products derived
25 # from this software without specific prior written permission.
27 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
34 # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
35 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36 # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
37 # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 #**************************************************************************
41 # Builds the SpreadSheet examples of the Developers Guide.
43 PRJ=../../../..
44 SETTINGS=$(PRJ)/settings
46 include $(SETTINGS)/settings.mk
47 include $(SETTINGS)/std.mk
48 include $(SETTINGS)/dk.mk
50 # Define non-platform/compiler specific settings
52 COMPONENT_NAME=JavaComponent
53 OUT_COMP_CLASS = $(OUT_CLASS)/$(COMPONENT_NAME)
54 OUT_COMP_GEN = $(OUT_MISC)/$(COMPONENT_NAME)
55 COMPONENT_RDB_NAME = $(COMPONENT_NAME).uno.rdb
56 COMPONENT_RDB = $(OUT_COMP_GEN)/$(COMPONENT_RDB_NAME)
57 COMPONENT_PACKAGE = $(OUT_BIN)/$(COMPONENT_NAME).$(UNOOXT_EXT)
58 COMPONENT_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMPONENT_NAME).$(UNOOXT_EXT)")
59 COMPONENT_JAR_NAME = $(COMPONENT_NAME).uno.jar
60 COMPONENT_JAR = $(OUT_COMP_CLASS)/$(COMPONENT_JAR_NAME)
61 COMPONENT_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMPONENT_NAME).uno.Manifest
62 COMPONENT_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMPONENT_NAME)/META-INF/manifest.xml
63 APP1_NAME=TestJavaComponent
64 APP1_JAR=$(OUT_COMP_CLASS)/$(APP1_NAME).jar
66 REGISTERFLAG = $(OUT_MISC)$(PS)devguide_$(COMPONENT_NAME)_register_component.flag
68 IDLFILES = XSomethingA.idl \
69 XSomethingB.idl \
70 SomethingA.idl \
71 SomethingB.idl
73 # normally the idl file should be stored in a directory tree fitting the module
74 # structure, for the example we know the module structure
75 PACKAGE = com/sun/star/test
77 COMPJAVAFILES = \
78 TestComponentA.java \
79 TestComponentB.java \
80 TestServiceProvider.java
82 GENCLASSFILES = $(patsubst %.idl,$(OUT_COMP_CLASS)/$(PACKAGE)/%.class,$(IDLFILES))
83 GENCLASSNAMES = $(patsubst %.idl,$(PACKAGE)/%.class,$(IDLFILES))
84 GENTYPELIST = $(subst /,.,$(patsubst %.idl,-T$(PACKAGE)/% ,$(IDLFILES)))
85 GENURDFILES = $(patsubst %.idl,$(OUT_COMP_GEN)/%.urd,$(IDLFILES))
87 COMPCLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(COMPJAVAFILES))
89 $(COMPONENT_NAME)_CLASSFILES = $(patsubst %.java,%.class,$(COMPJAVAFILES))
91 $(COMPONENT_NAME)_CLASSFILES += $(subst $(OUT_COMP_CLASS)/,,$(GENCLASSFILES))
93 SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
94 $(PATH_SEPARATOR)$(OUT_COMP_CLASS))
97 # Targets
98 .PHONY: ALL
99 ALL : \
100 JavaComponentExample
102 include $(SETTINGS)/stdtarget.mk
104 $(OUT_COMP_CLASS)/%.Manifest :
105 -$(MKDIR) $(subst /,$(PS),$(@D))
106 @echo UNO-Type-Path: $(basename $(notdir $*)).uno.jar> $@
107 @echo RegistrationClassName: TestServiceProvider>> $@
109 $(OUT_COMP_GEN)/%.urd : %.idl
110 -$(MKDIR) $(subst /,$(PS),$(@D))
111 $(IDLC) -I. -I$(IDL_DIR) -O$(OUT_COMP_GEN) $^
113 $(OUT_COMP_GEN)/%.rdb : $(GENURDFILES)
114 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
115 -$(MKDIR) $(subst /,$(PS),$(@D))
116 $(REGMERGE) $@ /UCR $(GENURDFILES)
118 $(OUT_COMP_CLASS)/$(PACKAGE)/%.class : $(COMPONENT_RDB)
119 -$(MKDIR) $(subst /,$(PS),$(@D))
120 $(JAVAMAKER) -BUCR -nD $(GENTYPELIST) -O$(OUT_COMP_CLASS) $(COMPONENT_RDB) -X$(URE_TYPES) -X$(OFFICE_TYPES)
122 $(OUT_COMP_CLASS)/%.class : %.java $(GENCLASSFILES)
123 -$(MKDIR) $(subst /,$(PS),$(@D))
124 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $<
126 $(COMPCLASSFILES) : $(COMPJAVAFILES) $(GENCLASSFILES)
127 -$(MKDIR) $(subst /,$(PS),$(@D))
128 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(COMPJAVAFILES)
130 # rule for client/example application manifest file
131 $(OUT_COMP_CLASS)/%.mf :
132 -$(MKDIR) $(subst /,$(PS),$(@D))
133 @echo Main-Class: com.sun.star.lib.loader.Loader> $@
134 $(ECHOLINE)>> $@
135 @echo Name: com/sun/star/lib/loader/Loader.class>> $@
136 @echo Application-Class: $*>> $@
138 # rule for client/example application jar file
139 # Note that the example needs the component files as well for local usage
140 $(APP1_JAR) : $(OUT_COMP_CLASS)/$(APP1_NAME).mf $(OUT_COMP_CLASS)/$(APP1_NAME).class $(COMPCLASSFILES) $(GENCLASSFILES)
141 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
142 -$(MKDIR) $(subst /,$(PS),$(@D))
143 +cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(basename $(@F)).class $($(COMPONENT_NAME)_CLASSFILES)
144 +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
146 # rule for component jar file
147 $(COMPONENT_JAR) : $(COMPONENT_MANIFESTFILE) $(COMPCLASSFILES)
148 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
149 -$(MKDIR) $(subst /,$(PS),$(@D))
150 cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
152 # rule for component package manifest
153 $(OUT_COMP_CLASS)/%/manifest.xml :
154 -$(MKDIR) $(subst /,$(PS),$(@D))
155 @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
156 @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
157 @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
158 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@
159 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_CLASS)/,,$(@D))).uno.rdb$(QM)"/$(CSEP) >> $@
160 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-component;type=Java$(QM)" >> $@
161 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_CLASS)/,,$(@D))).uno.jar$(QM)"/$(CSEP) >> $@
162 @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
164 # rule for component pacakge file
165 $(COMPONENT_PACKAGE) : $(COMPONENT_RDB) $(COMPONENT_JAR) $(COMPONENT_UNOPKG_MANIFEST)
166 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
167 -$(MKDIR) $(subst /,$(PS),$(@D))
168 $(COPY) $(subst /,$(PS),$(COMPONENT_RDB)) $(subst /,$(PS),$(OUT_COMP_CLASS))
169 cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) ../../bin/$(@F) $(COMPONENT_RDB_NAME) $(COMPONENT_JAR_NAME)
170 cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
171 $(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_COMP_CLASS)/$(COMPONENT_RDB_NAME)))
173 $(REGISTERFLAG) : $(COMPONENT_PACKAGE)
174 ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
175 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
176 -$(MKDIR) $(subst /,$(PS),$(@D))
177 $(DEPLOYTOOL) $(COMPONENT_PACKAGE_URL)
178 @echo flagged > $(subst /,$(PS),$@)
179 else
180 @echo --------------------------------------------------------------------------------
181 @echo If you want to install your component automatically, please set the environment
182 @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
183 @echo possible if no office instance is running.
184 @echo --------------------------------------------------------------------------------
185 endif
187 JavaComponentExample : $(REGISTERFLAG) $(APP1_JAR)
188 @echo --------------------------------------------------------------------------------
189 @echo Please use one of the following commands to execute the examples!
190 @echo -
191 @echo $(MAKE) $(APP1_NAME).run
192 @echo $(MAKE) $(APP1_NAME).local
193 @echo --------
194 @echo The Java components were installed if SDK_AUTO_DEPLOYMENT = YES.
195 @echo You can use this component inside your office installation, see the
196 @echo example description.
197 @echo --------------------------------------------------------------------------------
199 %.run: $(OUT_COMP_CLASS)/%.jar
200 $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
202 %.local: $(OUT_COMP_CLASS)/%.jar
203 $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< local
205 .PHONY: clean
206 clean :
207 -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
208 -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
209 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMPONENT_PACKAGE_URL)))
210 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG)))