1 #*************************************************************************
3 # The Contents of this file are made available subject to the terms of
6 # Copyright 2000, 2010 Oracle and/or its affiliates.
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
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.
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 \
68 # normally the idl file should be stored in a directory tree fitting the module
69 # structure, for the example we know the module structure
70 PACKAGE
= com
/sun
/star
/test
75 TestServiceProvider.java
77 GENCLASSFILES
= $(patsubst %.idl
,$(OUT_COMP_CLASS
)/$(PACKAGE
)/%.class
,$(IDLFILES
))
78 GENCLASSNAMES
= $(patsubst %.idl
,$(PACKAGE
)/%.class
,$(IDLFILES
))
79 GENTYPELIST
= $(subst /,.
,$(patsubst %.idl
,-T
$(PACKAGE
)/% ,$(IDLFILES
)))
80 GENURDFILES
= $(patsubst %.idl
,$(OUT_COMP_GEN
)/%.urd
,$(IDLFILES
))
82 COMPCLASSFILES
= $(patsubst %.java
,$(OUT_COMP_CLASS
)/%.class
,$(COMPJAVAFILES
))
84 $(COMP_NAME
)_CLASSFILES
= $(patsubst %.java
,%.class
,$(COMPJAVAFILES
))
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
))
97 include $(SETTINGS
)/stdtarget.mk
99 $(OUT_COMP_CLASS
)/%.Manifest
:
100 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
101 @echo UNO-Type-Path
: $(basename $(notdir $*)).uno.jar
> $@
102 @echo RegistrationClassName
: TestServiceProvider
>> $@
104 $(OUT_COMP_GEN
)/%.urd
: %.idl
105 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
106 $(IDLC
) -I.
-I
$(IDL_DIR
) -O
$(OUT_COMP_GEN
) $^
108 $(OUT_COMP_GEN
)/%.rdb
: $(GENURDFILES
)
109 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
110 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
111 $(REGMERGE
) $@
/UCR
$(GENURDFILES
)
113 $(OUT_COMP_CLASS
)/$(PACKAGE
)/%.class
: $(COMP_RDB
)
114 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
115 $(JAVAMAKER
) -nD
$(GENTYPELIST
) -O
$(OUT_COMP_CLASS
) $(COMP_RDB
) -X
$(URE_TYPES
) -X
$(OFFICE_TYPES
)
117 $(OUT_COMP_CLASS
)/%.class
: %.java
$(GENCLASSFILES
)
118 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
119 $(SDK_JAVAC
) $(JAVAC_FLAGS
) -classpath
"$(SDK_CLASSPATH)" -d
$(OUT_COMP_CLASS
) $<
121 $(COMPCLASSFILES
) : $(COMPJAVAFILES
) $(GENCLASSFILES
)
122 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
123 $(SDK_JAVAC
) $(JAVAC_FLAGS
) -classpath
"$(SDK_CLASSPATH)" -d
$(OUT_COMP_CLASS
) $(COMPJAVAFILES
)
125 # rule for client/example application manifest file
126 $(OUT_COMP_CLASS
)/%.mf
:
127 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
128 @echo Main-Class
: com.sun.star.lib.loader.Loader
> $@
130 @echo Name
: com
/sun
/star
/lib
/loader
/Loader.class
>> $@
131 @echo Application-Class
: $*>> $@
133 # rule for client/example application jar file
134 # Note that the example needs the component files as well for local usage
135 $(APP1_JAR
) : $(OUT_COMP_CLASS
)/$(APP1_NAME
).mf
$(OUT_COMP_CLASS
)/$(APP1_NAME
).class
$(COMPCLASSFILES
) $(GENCLASSFILES
)
136 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
137 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
138 +cd
$(subst /,$(PS
),$(OUT_COMP_CLASS
)) && $(SDK_JAR
) cvfm
$(@F
) $(basename $(@F
)).mf
$(basename $(@F
)).class
$($(COMP_NAME
)_CLASSFILES
)
139 +$(SDK_JAR
) uvf
$@
$(SDK_JAVA_UNO_BOOTSTRAP_FILES
)
141 # rule for component jar file
142 $(COMP_JAR
) : $(COMP_MANIFESTFILE
) $(COMPCLASSFILES
)
143 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
144 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
145 cd
$(subst /,$(PS
),$(OUT_COMP_CLASS
)) && $(SDK_JAR
) cvfm
$(@F
) $(<F
) $($(basename $(basename $(@F
)))_CLASSFILES
)
147 # rule for component package manifest
148 $(OUT_COMP_CLASS
)/%/manifest.xml
:
149 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
150 @echo
$(OSEP
)?xml version
="$(QM)1.0$(QM)" encoding
="$(QM)UTF-8$(QM)"?
$(CSEP
) > $@
151 @echo
$(OSEP
)!DOCTYPE manifest
:manifest PUBLIC
"$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP
) >> $@
152 @echo
$(OSEP
)manifest
:manifest xmlns
:manifest
="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP
) >> $@
153 @echo
$(SQM
) $(SQM
)$(OSEP
)manifest
:file-entry manifest
:media-type
="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@
154 @echo
$(SQM
) $(SQM
)manifest
:full-path
="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_CLASS)/,,$(@D))).uno.rdb$(QM)"/$(CSEP
) >> $@
155 @echo
$(SQM
) $(SQM
)$(OSEP
)manifest
:file-entry manifest
:media-type
="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
156 @echo
$(SQM
) $(SQM
)manifest
:full-path
="$(QM)$(COMP_COMPONENTS)$(QM)"/$(CSEP
)>> $@
157 @echo
$(OSEP
)/manifest
:manifest
$(CSEP
) >> $@
159 # rule for component package file
160 $(COMP_PACKAGE
) : $(COMP_RDB
) $(COMP_JAR
) $(COMP_UNOPKG_MANIFEST
) $(COMP_COMPONENTS
)
161 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
162 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
163 $(COPY
) $(subst /,$(PS
),$(COMP_RDB
)) $(subst /,$(PS
),$(OUT_COMP_CLASS
))
164 $(SDK_ZIP
) $@
$(COMP_COMPONENTS
)
165 cd
$(subst /,$(PS
),$(OUT_COMP_CLASS
)) && $(SDK_ZIP
) -u ..
/..
/bin
/$(@F
) $(COMP_RDB_NAME
) $(COMP_JAR_NAME
)
166 cd
$(subst /,$(PS
),$(OUT_COMP_CLASS
)/$(subst .
$(UNOOXT_EXT
),,$(@F
))) && $(SDK_ZIP
) -u ..
/..
/..
/bin
/$(@F
) META-INF
/manifest.xml
167 $(DEL
) $(subst \\,\
,$(subst /,$(PS
),$(OUT_COMP_CLASS
)/$(COMP_RDB_NAME
)))
169 $(REGISTERFLAG
) : $(COMP_PACKAGE
)
170 ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
171 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
172 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
173 $(DEPLOYTOOL
) $(COMP_PACKAGE_URL
)
174 @echo flagged
> $(subst /,$(PS
),$@
)
176 @echo
--------------------------------------------------------------------------------
177 @echo If you want to
install your component automatically
, please set the environment
178 @echo variable SDK_AUTO_DEPLOYMENT
= YES. But note that auto deployment is only
179 @echo possible if no office instance is running.
180 @echo
--------------------------------------------------------------------------------
183 JavaComponentExample
: $(REGISTERFLAG
) $(APP1_JAR
)
184 @echo
--------------------------------------------------------------------------------
185 @echo Please use one of the following commands to execute the examples
!
187 @echo
$(MAKE
) $(APP1_NAME
).run
188 @echo
$(MAKE
) $(APP1_NAME
).local
190 @echo The Java components were installed if SDK_AUTO_DEPLOYMENT
= YES.
191 @echo You can use this component inside your office installation
, see the
192 @echo example description.
193 @echo
--------------------------------------------------------------------------------
195 %.run
: $(OUT_COMP_CLASS
)/%.jar
196 $(SDK_JAVA
) -Dcom.sun.star.lib.loader.unopath
="$(OFFICE_PROGRAM_PATH)" -jar
$<
198 %.local
: $(OUT_COMP_CLASS
)/%.jar
199 $(SDK_JAVA
) -Dcom.sun.star.lib.loader.unopath
="$(OFFICE_PROGRAM_PATH)" -jar
$< local
203 -$(DELRECURSIVE
) $(subst /,$(PS
),$(OUT_COMP_CLASS
))
204 -$(DELRECURSIVE
) $(subst /,$(PS
),$(OUT_COMP_GEN
))
205 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$(COMP_PACKAGE_URL
)))
206 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$(REGISTERFLAG
)))