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 C++ component example 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
44 SAMPLE_NAME
=CppComponentSample
45 SAMPLE_INC_OUT
=$(OUT_INC
)/$(SAMPLE_NAME
)
46 SAMPLE_GEN_OUT
=$(OUT_MISC
)/$(SAMPLE_NAME
)
47 SAMPLE_SLO_OUT
=$(OUT_SLO
)/$(SAMPLE_NAME
)
48 SAMPLE_OBJ_OUT
=$(OUT_OBJ
)/$(SAMPLE_NAME
)
50 COMP_NAME
=CppComponent
51 COMP_IMPL_NAME
=$(COMP_NAME
).uno.
$(SHAREDLIB_EXT
)
53 APP1_NAME
= TestCppComponent
54 APP1_BINARY
= $(OUT_BIN
)/$(APP1_NAME
)$(EXE_EXT
)
56 COMP_RDB_NAME
= $(COMP_NAME
).uno.rdb
57 COMP_RDB
= $(SAMPLE_GEN_OUT
)/$(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_UNOPKG_MANIFEST
= $(SAMPLE_GEN_OUT
)/$(COMP_NAME
)/META-INF
/manifest.xml
61 COMP_COMPONENTS
= $(SAMPLE_GEN_OUT
)/$(COMP_NAME
).components
62 COMP_DESCRIPTION
= $(SAMPLE_GEN_OUT
)/description.xml
64 COMP_REGISTERFLAG
= $(SAMPLE_GEN_OUT
)/devguide_
$(COMP_NAME
)_register_component.flag
65 COMP_TYPEFLAG
= $(SAMPLE_GEN_OUT
)/devguide_
$(COMP_NAME
)_types.flag
69 CXXFILES
= service1_impl.
cxx \
72 SLOFILES
= $(patsubst %.
cxx,$(SAMPLE_SLO_OUT
)/%.
$(OBJ_EXT
),$(CXXFILES
))
74 TYPESLIST
=-Tmymodule.XSomething \
75 -Tmymodule.MyService1 \
83 include $(SETTINGS
)/stdtarget.mk
85 $(SAMPLE_GEN_OUT
)/%.rdb
: $(IDLFILES
)
86 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
87 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
88 $(UNOIDLWRITE
) $(URE_TYPES
) $(OFFICE_TYPES
) $< $@
90 $(COMP_TYPEFLAG
) : $(COMP_RDB
) $(SDKTYPEFLAG
)
91 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
92 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
93 $(CPPUMAKER
) -Gc
-O
$(SAMPLE_INC_OUT
) $(TYPESLIST
) $(COMP_RDB
) -X
$(URE_TYPES
) -X
$(OFFICE_TYPES
)
96 $(SAMPLE_SLO_OUT
)/%.
$(OBJ_EXT
) : %.
cxx $(COMP_TYPEFLAG
)
97 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
98 $(CC
) $(CC_FLAGS
) $(CC_INCLUDES
) -I
$(SAMPLE_INC_OUT
) $(CC_DEFINES
) $(CC_OUTPUT_SWITCH
)$(subst /,$(PS
),$@
) $<
101 $(SHAREDLIB_OUT
)/%.
$(SHAREDLIB_EXT
) : $(SLOFILES
)
102 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
103 -$(MKDIR
) $(subst /,$(PS
),$(SAMPLE_GEN_OUT
))
104 $(LINK
) $(COMP_LINK_FLAGS
) /OUT
:$@ \
105 /MAP
:$(SAMPLE_GEN_OUT
)/$(subst $(SHAREDLIB_EXT
),map
,$(@F
)) $(SLOFILES
) \
106 $(CPPUHELPERLIB
) $(CPPULIB
) $(SALLIB
) msvcprt.lib
$(LIBO_SDK_LDFLAGS_STDLIBS
)
109 $(SHAREDLIB_OUT
)/%.
$(SHAREDLIB_EXT
) : $(SLOFILES
)
110 -$(MKDIR
) $(subst /,$(PS
),$(@D
)) && $(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
111 $(LINK
) $(COMP_LINK_FLAGS
) $(LINK_LIBS
) -o
$@
$(SLOFILES
) \
112 $(CPPUHELPERLIB
) $(CPPULIB
) $(SALLIB
) $(STC
++LIB
)
113 ifeq "$(OS)" "MACOSX"
114 $(INSTALL_NAME_URELIBS
) $@
118 # rule for component package manifest
119 $(SAMPLE_GEN_OUT
)/%/manifest.xml
:
120 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
121 @echo
$(OSEP
)?xml version
="$(QM)1.0$(QM)" encoding
="$(QM)UTF-8$(QM)"?
$(CSEP
) > $@
122 @echo
$(OSEP
)!DOCTYPE manifest
:manifest PUBLIC
"$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP
) >> $@
123 @echo
$(OSEP
)manifest
:manifest xmlns
:manifest
="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP
) >> $@
124 @echo
$(SQM
) $(SQM
)$(OSEP
)manifest
:file-entry manifest
:media-type
="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@
125 @echo
$(SQM
) $(SQM
)manifest
:full-path
="$(QM)$(subst /META-INF,,$(subst $(SAMPLE_GEN_OUT)/,,$(@D))).uno.rdb$(QM)"/$(CSEP
) >> $@
126 @echo
$(SQM
) $(SQM
)$(OSEP
)manifest
:file-entry manifest
:media-type
="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@
127 @echo
$(SQM
) $(SQM
)manifest
:full-path
="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP
)>> $@
128 @echo
$(OSEP
)/manifest
:manifest
$(CSEP
) >> $@
131 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
132 @echo
$(OSEP
)?xml version
="$(QM)1.0$(QM)" encoding
="$(QM)UTF-8$(QM)"?
$(CSEP
) > $@
133 @echo
$(OSEP
)components xmlns
="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP
) >> $@
134 @echo
$(SQM
) $(SQM
)$(OSEP
)component loader
="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri
="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP
) >> $@
135 @echo
$(SQM
) $(SQM
)$(OSEP
)implementation name
="$(QM)mymodule.my_sc_implementation.MyService1$(QM)"$(CSEP
) >> $@
136 @echo
$(SQM
) $(SQM
)$(OSEP
)service name
="$(QM)mymodule.MyService1$(QM)"/$(CSEP
) >> $@
137 @echo
$(SQM
) $(SQM
)$(OSEP
)/implementation
$(CSEP
) >> $@
138 @echo
$(SQM
) $(SQM
)$(OSEP
)implementation name
="$(QM)mymodule.my_sc_implementation.MyService2$(QM)"$(CSEP
) >> $@
139 @echo
$(SQM
) $(SQM
)$(OSEP
)service name
="$(QM)mymodule.MyService2$(QM)"/$(CSEP
) >> $@
140 @echo
$(SQM
) $(SQM
)$(OSEP
)/implementation
$(CSEP
) >> $@
141 @echo
$(SQM
) $(SQM
)$(OSEP
)/component
$(CSEP
) >> $@
142 @echo
$(OSEP
)/components
$(CSEP
) >> $@
144 $(COMP_DESCRIPTION
) : description.xml
145 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
148 $(COMP_PACKAGE
) : $(SHAREDLIB_OUT
)/$(COMP_IMPL_NAME
) $(COMP_RDB
) $(COMP_UNOPKG_MANIFEST
) $(COMP_COMPONENTS
) $(COMP_DESCRIPTION
)
149 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
150 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
151 -$(MKDIR
) $(subst /,$(PS
),$(SAMPLE_GEN_OUT
)/$(UNOPKG_PLATFORM
))
152 $(COPY
) $(subst /,$(PS
),$<) $(subst /,$(PS
),$(SAMPLE_GEN_OUT
)/$(UNOPKG_PLATFORM
))
153 cd
$(subst /,$(PS
),$(SAMPLE_GEN_OUT
)) && $(SDK_ZIP
) ..
/..
/bin
/$(@F
) $(COMP_NAME
).components description.xml
154 cd
$(subst /,$(PS
),$(SAMPLE_GEN_OUT
)) && $(SDK_ZIP
) -u ..
/..
/bin
/$(@F
) $(COMP_RDB_NAME
) $(UNOPKG_PLATFORM
)/$(<F
)
155 cd
$(subst /,$(PS
),$(SAMPLE_GEN_OUT
)/$(subst .
$(UNOOXT_EXT
),,$(@F
))) && $(SDK_ZIP
) -u ..
/..
/..
/bin
/$(@F
) META-INF
/manifest.xml
158 $(COMP_REGISTERFLAG
) : $(COMP_PACKAGE
)
159 ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
160 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
161 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
162 $(DEPLOYTOOL
) $(COMP_PACKAGE_URL
)
163 @echo flagged
> $(subst /,$(PS
),$@
)
165 @echo
--------------------------------------------------------------------------------
166 @echo If you want to
install your component automatically
, please set the environment
167 @echo variable SDK_AUTO_DEPLOYMENT
= YES. But note that auto deployment is only
168 @echo possible if no office instance is running.
169 @echo
--------------------------------------------------------------------------------
172 $(SAMPLE_OBJ_OUT
)/$(APP1_NAME
).
$(OBJ_EXT
) : $(APP1_NAME
).
cxx $(COMP_TYPEFLAG
)
173 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
174 $(CC
) $(CC_FLAGS
) $(CC_INCLUDES
) -I
$(SAMPLE_INC_OUT
) $(CC_DEFINES
) $(CC_OUTPUT_SWITCH
)$(subst /,$(PS
),$@
) $<
176 $(OUT_BIN
)/_
$(APP1_NAME
)$(EXE_EXT
) : $(SAMPLE_OBJ_OUT
)/$(APP1_NAME
).
$(OBJ_EXT
)
177 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
178 -$(MKDIR
) $(subst /,$(PS
),$(SAMPLE_GEN_OUT
))
180 $(LINK
) $(EXE_LINK_FLAGS
) /OUT
:$@
/MAP
:$(SAMPLE_GEN_OUT
)/$(basename $(@F
)).map \
181 $< $(CPPUHELPERLIB
) $(CPPULIB
) $(SALHELPERLIB
) $(SALLIB
)
183 $(LINK
) $(EXE_LINK_FLAGS
) $(LINK_LIBS
) -o
$@
$< \
184 $(CPPUHELPERLIB
) $(CPPULIB
) $(SALHELPERLIB
) $(SALLIB
) $(STDC
++LIB
)
185 ifeq "$(OS)" "MACOSX"
186 $(INSTALL_NAME_URELIBS_BIN
) $@
190 $(OUT_BIN
)/$(APP1_NAME
)$(EXE_EXT
) : $(OUT_BIN
)/_
$(APP1_NAME
)$(EXE_EXT
)
191 $(COPY
) $(subst /,$(PS
),$(BIN_DIR
)/unoapploader
$(EXE_EXT
)) $(subst /,$(PS
),$@
)
192 # touch the target to renew the date for correct dependencies.
193 # Note: no touch under windows! The unoapploader.exe is copied always.
198 $(SAMPLE_NAME
) : $(COMP_REGISTERFLAG
) $(APP1_BINARY
)
199 @echo
--------------------------------------------------------------------------------
200 @echo Please use the following command to execute the example
!
202 @echo
$(MAKE
) $(APP1_NAME
).run
204 @echo The simple C
++ component was installed if SDK_AUTO_DEPLOYMENT
= YES.
205 @echo You can use this component inside your office installation
, see the example
206 @echo description. You can also load the
"$(QM)SimpleComponent.odt$(QM)" document containing
207 @echo a StarBasic macro which uses this component.
209 @echo
$(MAKE
) SimpleComponent.odt.load
210 @echo
--------------------------------------------------------------------------------
212 %.run
: $(OUT_BIN
)/%$(EXE_EXT
)
213 $(subst /,$(PS
),$(OUT_BIN
))$(PS
)$(basename $@
)
214 # cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@)
216 SimpleComponent.odt.load
: $(COMP_REGISTERFLAG
)
217 "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@
)
221 -$(DELRECURSIVE
) $(subst /,$(PS
),$(SAMPLE_INC_OUT
))
222 -$(DELRECURSIVE
) $(subst /,$(PS
),$(SAMPLE_GEN_OUT
))
223 -$(DELRECURSIVE
) $(subst /,$(PS
),$(SAMPLE_SLO_OUT
))
224 -$(DELRECURSIVE
) $(subst /,$(PS
),$(SAMPLE_OBJ_OUT
))
225 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$(COMP_COMPONENTS
)))
226 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$(COMP_DESCRIPTION
)))
227 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$(OUT_BIN
)/$(COMP_NAME
)*))
228 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$(OUT_BIN
)/*$(APP1_NAME
)*))