1 #*************************************************************************
3 # $RCSfile: Makefile,v $
7 # last change: $Author: rt $ $Date: 2008-07-11 14:30:17 $
9 # The Contents of this file are made available subject to the terms of
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
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 Java Minimal component example of the SDK.
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 # we use the sample directory name dor separating this example
53 # from others in the output directory
54 SAMPLE_NAME
=MinimalComponent
55 SAMPLE_CLASS_OUT
=$(OUT_CLASS
)/$(SAMPLE_NAME
)
56 SAMPLE_GEN_OUT
=$(OUT_MISC
)/$(SAMPLE_NAME
)
58 COMP_NAME
=MinimalComponent
59 COMP_CLASS_OUT
=$(SAMPLE_CLASS_OUT
)/$(COMP_NAME
)
60 COMP_GEN_OUT
=$(SAMPLE_GEN_OUT
)/$(COMP_NAME
)
61 COMP_RDB_NAME
=$(COMP_NAME
).uno.rdb
62 COMP_RDB
=$(COMP_GEN_OUT
)/$(COMP_RDB_NAME
)
63 COMP_PACKAGE
=$(OUT_BIN
)/$(COMP_NAME
).
$(UNOOXT_EXT
)
64 COMP_PACKAGE_URL
=$(subst \\,\
,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
65 COMP_JAR_NAME
=$(COMP_NAME
).uno.jar
66 COMP_JAR
=$(SAMPLE_CLASS_OUT
)/$(COMP_JAR_NAME
)
67 COMP_JAR_MANIFEST
=$(COMP_GEN_OUT
)/$(COMP_NAME
).uno.Manifest
68 COMP_UNOPKG_MANIFEST
= $(COMP_GEN_OUT
)/META-INF
/manifest.xml
69 COMP_REGISTERFLAG
=$(COMP_GEN_OUT
)$(PS
)java_
$(COMP_NAME
)_register_component.flag
71 APP1_NAME
=TestMinimalComponent
72 APP1_CLASS_OUT
=$(SAMPLE_CLASS_OUT
)/$(APP1_NAME
)
73 APP1_GEN_OUT
=$(SAMPLE_GEN_OUT
)/$(APP1_NAME
)
74 APP1_JAR
=$(SAMPLE_CLASS_OUT
)/$(APP1_NAME
).jar
75 APP1_JAR_MANIFEST
=$(APP1_GEN_OUT
)/$(APP1_NAME
).mf
77 IDLFILES
= MinimalComponent.idl
79 # normally the idl file should be stored in a directory tree fitting the module structure,
80 # for the example we know the module structure
81 PACKAGE
= org
/openoffice
83 COMP_JAVAFILES
= MinimalComponent.java
84 COMP_CLASSFILES
= $(patsubst %.java
,$(COMP_CLASS_OUT
)/%.class
,$(COMP_JAVAFILES
))
86 GEN_CLASSFILES
= $(patsubst %.idl
,$(SAMPLE_CLASS_OUT
)/$(PACKAGE
)/%.class
,$(IDLFILES
))
87 GEN_TYPELIST
= $(subst /,.
,$(patsubst %.idl
,-T
$(PACKAGE
)/% ,$(IDLFILES
)))
88 GEN_URDFILES
= $(patsubst %.idl
,$(SAMPLE_GEN_OUT
)/%.urd
,$(IDLFILES
))
90 # the generated types are necessary for the component and the application jar
91 GEN_CLASSFILENAMES
= $(subst $(SAMPLE_CLASS_OUT
)/,,$(GEN_CLASSFILES
))
93 SDK_CLASSPATH
= $(subst $(EMPTYSTRING
) $(PATH_SEPARATOR
),$(PATH_SEPARATOR
),$(CLASSPATH
)\
94 $(PATH_SEPARATOR
)$(SAMPLE_CLASS_OUT
)\
95 $(PATH_SEPARATOR
)$(COMP_CLASS_OUT
)\
96 $(PATH_SEPARATOR
)$(APP1_CLASS_OUT
))
101 ALL
: JavaMinimalComponentExample
103 include $(SETTINGS
)/stdtarget.mk
105 $(COMP_GEN_OUT
)/%.Manifest
:
106 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
107 @echo UNO-Type-Path
: $(basename $*).uno.jar
> $@
108 @echo RegistrationClassName
: $(basename $*)>> $@
110 $(SAMPLE_GEN_OUT
)/%.urd
: %.idl
111 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
112 $(IDLC
) -C
-I.
-I
$(IDL_DIR
) -O
$(SAMPLE_GEN_OUT
) $<
114 $(COMP_GEN_OUT
)/%.rdb
: $(GEN_URDFILES
)
115 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
116 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
117 $(REGMERGE
) $@
/UCR
$(GEN_URDFILES
)
119 $(GEN_CLASSFILES
) : $(COMP_RDB
)
120 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
121 $(JAVAMAKER
) -BUCR
-nD
$(GEN_TYPELIST
) -O
$(SAMPLE_CLASS_OUT
) $(COMP_RDB
) -X
$(URE_TYPES
) -X
$(OFFICE_TYPES
)
123 # component as well as application are dependent from the generated types
124 # rule for component class files
125 $(COMP_CLASS_OUT
)/%.class
: %.java
$(GEN_CLASSFILES
)
126 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
127 $(SDK_JAVAC
) $(JAVAC_FLAGS
) -classpath
"$(SDK_CLASSPATH)" -d
$(COMP_CLASS_OUT
) $<
129 # rule for example application class files
130 $(APP1_CLASS_OUT
)/%.class
: %.java
$(GEN_CLASSFILES
)
131 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
132 $(SDK_JAVAC
) $(JAVAC_FLAGS
) -classpath
"$(SDK_CLASSPATH)" -d
$(APP1_CLASS_OUT
) $<
134 # rule for client/example application manifest file
135 $(APP1_GEN_OUT
)/%.mf
:
136 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
137 @echo Main-Class
: com.sun.star.lib.loader.Loader
> $@
139 @echo Name
: com
/sun
/star
/lib
/loader
/Loader.class
>> $@
140 @echo Application-Class
: $*>> $@
142 # rule for client/example application jar file
143 $(APP1_JAR
) : $(APP1_JAR_MANIFEST
) $(APP1_CLASS_OUT
)/$(APP1_NAME
).class
$(GEN_CLASSFILES
)
144 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
145 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
146 $(SDK_JAR
) cvfm
$@
$< -C
$(APP1_CLASS_OUT
) .
147 +cd
$(subst /,$(PS
),$(SAMPLE_CLASS_OUT
)) && $(SDK_JAR
) uvf
$(@F
) $(GEN_CLASSFILENAMES
)
148 +$(SDK_JAR
) uvf
$@
$(SDK_JAVA_UNO_BOOTSTRAP_FILES
)
150 # rule for component jar file
151 $(COMP_JAR
) : $(COMP_JAR_MANIFEST
) $(COMP_CLASSFILES
)
152 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
153 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
154 $(SDK_JAR
) cvfm
$@
$< -C
$(COMP_CLASS_OUT
) .
155 +cd
$(subst /,$(PS
),$(SAMPLE_CLASS_OUT
)) && $(SDK_JAR
) uvf
$(@F
) $(GEN_CLASSFILENAMES
)
157 # rule for component package manifest
158 $(COMP_GEN_OUT
)/%/manifest.xml
:
159 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
160 @echo
$(OSEP
)?xml version
="$(QM)1.0$(QM)" encoding
="$(QM)UTF-8$(QM)"?
$(CSEP
) > $@
161 @echo
$(OSEP
)!DOCTYPE manifest
:manifest PUBLIC
"$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP
) >> $@
162 @echo
$(OSEP
)manifest
:manifest xmlns
:manifest
="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP
) >> $@
163 @echo
$(SQM
) $(SQM
)$(OSEP
)manifest
:file-entry manifest
:media-type
="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@
164 @echo
$(SQM
) $(SQM
)manifest
:full-path
="$(QM)$(subst /META-INF,,$(subst $(SAMPLE_GEN_OUT)/,,$(@D))).uno.rdb$(QM)"/$(CSEP
) >> $@
165 @echo
$(SQM
) $(SQM
)$(OSEP
)manifest
:file-entry manifest
:media-type
="$(QM)application/vnd.sun.star.uno-component;type=Java$(QM)" >> $@
166 @echo
$(SQM
) $(SQM
)manifest
:full-path
="$(QM)$(subst /META-INF,,$(subst $(SAMPLE_GEN_OUT)/,,$(@D))).uno.jar$(QM)"/$(CSEP
) >> $@
167 @echo
$(OSEP
)/manifest
:manifest
$(CSEP
) >> $@
169 # rule for component package file
170 $(COMP_PACKAGE
) : $(COMP_RDB
) $(COMP_JAR
) $(COMP_UNOPKG_MANIFEST
)
171 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
172 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
173 cd
$(subst /,$(PS
),$(COMP_GEN_OUT
)) && $(SDK_ZIP
) ..
/..
/..
/bin
/$(@F
) $(COMP_RDB_NAME
)
174 cd
$(subst /,$(PS
),$(SAMPLE_CLASS_OUT
)) && $(SDK_ZIP
) -u ..
/..
/bin
/$(@F
) $(COMP_JAR_NAME
)
175 cd
$(subst /,$(PS
),$(COMP_GEN_OUT
)) && $(SDK_ZIP
) -u ..
/..
/..
/bin
/$(@F
) META-INF
/manifest.xml
177 $(COMP_REGISTERFLAG
) : $(COMP_PACKAGE
)
178 ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
179 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
180 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
181 $(DEPLOYTOOL
) $(COMP_PACKAGE_URL
)
182 @echo flagged
> $(subst /,$(PS
),$@
)
184 @echo
--------------------------------------------------------------------------------
185 @echo If you want to
install your component automatically
, please set the environment
186 @echo variable SDK_AUTO_DEPLOYMENT
= YES. But note that auto deployment is only
187 @echo possible if no office instance is running.
188 @echo
--------------------------------------------------------------------------------
191 JavaMinimalComponentExample
: $(COMP_REGISTERFLAG
) $(APP1_JAR
)
192 @echo
--------------------------------------------------------------------------------
193 @echo Please use the following command to execute the example
!
195 @echo
$(MAKE
) $(APP1_NAME
).run
197 @echo The
$(COMP_NAME
) component was installed if SDK_AUTO_DEPLOYMENT
= YES.
198 @echo You can use this component inside your office installation
, see the example
200 @echo
--------------------------------------------------------------------------------
202 %.run
: $(SAMPLE_CLASS_OUT
)/%.jar
203 $(SDK_JAVA
) -Dcom.sun.star.lib.loader.unopath
="$(OFFICE_PROGRAM_PATH)" -jar
$<
207 -$(DELRECURSIVE
) $(subst /,$(PS
),$(SAMPLE_CLASS_OUT
))
208 -$(DELRECURSIVE
) $(subst /,$(PS
),$(SAMPLE_GEN_OUT
))
209 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$(COMP_PACKAGE_URL
)))