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
63 COMP_REGISTERFLAG
= $(SAMPLE_GEN_OUT
)/devguide_
$(COMP_NAME
)_register_component.flag
64 COMP_TYPEFLAG
= $(SAMPLE_GEN_OUT
)/devguide_
$(COMP_NAME
)_types.flag
68 CXXFILES
= service1_impl.
cxx \
71 SLOFILES
= $(patsubst %.
cxx,$(SAMPLE_SLO_OUT
)/%.
$(OBJ_EXT
),$(CXXFILES
))
73 GENURDFILES
= $(patsubst %.idl
,$(SAMPLE_GEN_OUT
)/%.urd
,$(IDLFILES
))
75 TYPELIST
=-Tmy_module.XSomething \
76 -Tmy_modules.MyService1 \
77 -Tmy_module.MyService2
84 include $(SETTINGS
)/stdtarget.mk
86 $(SAMPLE_GEN_OUT
)/%.urd
: %.idl
87 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
88 $(IDLC
) -I.
-I
$(IDL_DIR
) -O
$(SAMPLE_GEN_OUT
) $<
90 $(SAMPLE_GEN_OUT
)/%.rdb
: $(GENURDFILES
)
91 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
92 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
93 $(REGMERGE
) $@
/UCR
$(GENURDFILES
)
95 $(COMP_TYPEFLAG
) : $(COMP_RDB
) $(SDKTYPEFLAG
)
96 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
97 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
98 $(CPPUMAKER
) -Gc
-O
$(SAMPLE_INC_OUT
) $(TYPESLIST
) $(COMP_RDB
) -X
$(URE_TYPES
) -X
$(OFFICE_TYPES
)
101 $(SAMPLE_SLO_OUT
)/%.
$(OBJ_EXT
) : %.
cxx $(COMP_TYPEFLAG
)
102 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
103 $(CC
) $(CC_FLAGS
) $(CC_INCLUDES
) -I
$(SAMPLE_INC_OUT
) $(CC_DEFINES
) $(CC_OUTPUT_SWITCH
)$(subst /,$(PS
),$@
) $<
106 $(SHAREDLIB_OUT
)/%.
$(SHAREDLIB_EXT
) : $(SLOFILES
)
107 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
108 -$(MKDIR
) $(subst /,$(PS
),$(SAMPLE_GEN_OUT
))
109 $(LINK
) $(COMP_LINK_FLAGS
) /OUT
:$@ \
110 /MAP
:$(SAMPLE_GEN_OUT
)/$(subst $(SHAREDLIB_EXT
),map
,$(@F
)) $(SLOFILES
) \
111 $(CPPUHELPERLIB
) $(CPPULIB
) $(SALLIB
) msvcprt.lib
$(LIBO_SDK_LDFLAGS_STDLIBS
)
114 $(SHAREDLIB_OUT
)/%.
$(SHAREDLIB_EXT
) : $(SLOFILES
)
115 -$(MKDIR
) $(subst /,$(PS
),$(@D
)) && $(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
116 $(LINK
) $(COMP_LINK_FLAGS
) $(LINK_LIBS
) -o
$@
$(SLOFILES
) \
117 $(CPPUHELPERLIB
) $(CPPULIB
) $(SALLIB
) $(STC
++LIB
)
118 ifeq "$(OS)" "MACOSX"
119 $(INSTALL_NAME_URELIBS
) $@
123 # rule for component package manifest
124 $(SAMPLE_GEN_OUT
)/%/manifest.xml
:
125 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
126 @echo
$(OSEP
)?xml version
="$(QM)1.0$(QM)" encoding
="$(QM)UTF-8$(QM)"?
$(CSEP
) > $@
127 @echo
$(OSEP
)!DOCTYPE manifest
:manifest PUBLIC
"$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP
) >> $@
128 @echo
$(OSEP
)manifest
:manifest xmlns
:manifest
="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP
) >> $@
129 @echo
$(SQM
) $(SQM
)$(OSEP
)manifest
:file-entry manifest
:media-type
="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@
130 @echo
$(SQM
) $(SQM
)manifest
:full-path
="$(QM)$(subst /META-INF,,$(subst $(SAMPLE_GEN_OUT)/,,$(@D))).uno.rdb$(QM)"/$(CSEP
) >> $@
131 @echo
$(SQM
) $(SQM
)$(OSEP
)manifest
:file-entry manifest
:media-type
="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@
132 @echo
$(SQM
) $(SQM
)manifest
:full-path
="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP
)>> $@
133 @echo
$(OSEP
)/manifest
:manifest
$(CSEP
) >> $@
136 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
137 @echo
$(OSEP
)?xml version
="$(QM)1.0$(QM)" encoding
="$(QM)UTF-8$(QM)"?
$(CSEP
) > $@
138 @echo
$(OSEP
)components xmlns
="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP
) >> $@
139 @echo
$(SQM
) $(SQM
)$(OSEP
)component loader
="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri
="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP
) >> $@
140 @echo
$(SQM
) $(SQM
)$(OSEP
)implementation name
="$(QM)my_module.my_sc_implementation.MyService1$(QM)"$(CSEP
) >> $@
141 @echo
$(SQM
) $(SQM
)$(OSEP
)service name
="$(QM)my_module.MyService1$(QM)"/$(CSEP
) >> $@
142 @echo
$(SQM
) $(SQM
)$(OSEP
)/implementation
$(CSEP
) >> $@
143 @echo
$(SQM
) $(SQM
)$(OSEP
)implementation name
="$(QM)my_module.my_sc_implementation.MyService2$(QM)"$(CSEP
) >> $@
144 @echo
$(SQM
) $(SQM
)$(OSEP
)service name
="$(QM)my_module.MyService2$(QM)"/$(CSEP
) >> $@
145 @echo
$(SQM
) $(SQM
)$(OSEP
)/implementation
$(CSEP
) >> $@
146 @echo
$(SQM
) $(SQM
)$(OSEP
)/component
$(CSEP
) >> $@
147 @echo
$(OSEP
)/components
$(CSEP
) >> $@
149 $(COMP_PACKAGE
) : $(SHAREDLIB_OUT
)/$(COMP_IMPL_NAME
) $(COMP_RDB
) $(COMP_UNOPKG_MANIFEST
) $(COMP_COMPONENTS
)
150 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
151 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
152 -$(MKDIR
) $(subst /,$(PS
),$(SAMPLE_GEN_OUT
)/$(UNOPKG_PLATFORM
))
153 $(COPY
) $(subst /,$(PS
),$<) $(subst /,$(PS
),$(SAMPLE_GEN_OUT
)/$(UNOPKG_PLATFORM
))
154 cd
$(subst /,$(PS
),$(SAMPLE_GEN_OUT
)) && $(SDK_ZIP
) ..
/..
/bin
/$(@F
) $(COMP_NAME
).components
155 cd
$(subst /,$(PS
),$(SAMPLE_GEN_OUT
)) && $(SDK_ZIP
) -u ..
/..
/bin
/$(@F
) $(COMP_RDB_NAME
) $(UNOPKG_PLATFORM
)/$(<F
)
156 cd
$(subst /,$(PS
),$(SAMPLE_GEN_OUT
)/$(subst .
$(UNOOXT_EXT
),,$(@F
))) && $(SDK_ZIP
) -u ..
/..
/..
/bin
/$(@F
) META-INF
/manifest.xml
159 $(COMP_REGISTERFLAG
) : $(COMP_PACKAGE
)
160 ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
161 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$@
))
162 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
163 $(DEPLOYTOOL
) $(COMP_PACKAGE_URL
)
164 @echo flagged
> $(subst /,$(PS
),$@
)
166 @echo
--------------------------------------------------------------------------------
167 @echo If you want to
install your component automatically
, please set the environment
168 @echo variable SDK_AUTO_DEPLOYMENT
= YES. But note that auto deployment is only
169 @echo possible if no office instance is running.
170 @echo
--------------------------------------------------------------------------------
173 $(SAMPLE_OBJ_OUT
)/$(APP1_NAME
).
$(OBJ_EXT
) : $(APP1_NAME
).
cxx $(COMP_TYPEFLAG
)
174 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
175 $(CC
) $(CC_FLAGS
) $(CC_INCLUDES
) -I
$(SAMPLE_INC_OUT
) $(CC_DEFINES
) $(CC_OUTPUT_SWITCH
)$(subst /,$(PS
),$@
) $<
177 $(OUT_BIN
)/_
$(APP1_NAME
)$(EXE_EXT
) : $(SAMPLE_OBJ_OUT
)/$(APP1_NAME
).
$(OBJ_EXT
)
178 -$(MKDIR
) $(subst /,$(PS
),$(@D
))
179 -$(MKDIR
) $(subst /,$(PS
),$(SAMPLE_GEN_OUT
))
181 $(LINK
) $(EXE_LINK_FLAGS
) /OUT
:$@
/MAP
:$(SAMPLE_GEN_OUT
)/$(basename $(@F
)).map \
182 $< $(CPPUHELPERLIB
) $(CPPULIB
) $(SALHELPERLIB
) $(SALLIB
)
184 $(LINK
) $(EXE_LINK_FLAGS
) $(LINK_LIBS
) -o
$@
$< \
185 $(CPPUHELPERLIB
) $(CPPULIB
) $(SALHELPERLIB
) $(SALLIB
) $(STDC
++LIB
)
186 ifeq "$(OS)" "MACOSX"
187 $(INSTALL_NAME_URELIBS_BIN
) $@
191 $(OUT_BIN
)/$(APP1_NAME
)$(EXE_EXT
) : $(OUT_BIN
)/_
$(APP1_NAME
)$(EXE_EXT
)
192 $(COPY
) $(subst /,$(PS
),$(BIN_DIR
)/unoapploader
$(EXE_EXT
)) $(subst /,$(PS
),$@
)
193 # touch the target to renew the date for correct dependencies.
194 # Note: no touch under windows! The unoapploader.exe is copied always.
199 $(SAMPLE_NAME
) : $(COMP_REGISTERFLAG
) $(APP1_BINARY
)
200 @echo
--------------------------------------------------------------------------------
201 @echo Please use the following command to execute the example
!
203 @echo
$(MAKE
) $(APP1_NAME
).run
205 @echo The simple C
++ component was installed if SDK_AUTO_DEPLOYMENT
= YES.
206 @echo You can use this component inside your office installation
, see the example
207 @echo description. You can also load the
"$(QM)SimpleComponent.odt$(QM)" document containing
208 @echo a StarBasic macro which uses this component.
210 @echo
$(MAKE
) SimpleComponent.odt.load
211 @echo
--------------------------------------------------------------------------------
213 %.run
: $(OUT_BIN
)/%$(EXE_EXT
)
214 $(subst /,$(PS
),$(OUT_BIN
))$(PS
)$(basename $@
)
215 # cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@)
217 SimpleComponent.odt.load
: $(COMP_REGISTERFLAG
)
218 "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@
)
222 -$(DELRECURSIVE
) $(subst /,$(PS
),$(SAMPLE_INC_OUT
))
223 -$(DELRECURSIVE
) $(subst /,$(PS
),$(SAMPLE_GEN_OUT
))
224 -$(DELRECURSIVE
) $(subst /,$(PS
),$(SAMPLE_SLO_OUT
))
225 -$(DELRECURSIVE
) $(subst /,$(PS
),$(SAMPLE_OBJ_OUT
))
226 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$(COMP_COMPONENTS
)))
227 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$(OUT_BIN
)/$(COMP_NAME
)*))
228 -$(DEL
) $(subst \\,\
,$(subst /,$(PS
),$(OUT_BIN
)/*$(APP1_NAME
)*))