1 122c3632SJürgen Schmidt#**************************************************************
2 122c3632SJürgen Schmidt#
3 122c3632SJürgen Schmidt#  Licensed to the Apache Software Foundation (ASF) under one
4 122c3632SJürgen Schmidt#  or more contributor license agreements.  See the NOTICE file
5 122c3632SJürgen Schmidt#  distributed with this work for additional information
6 122c3632SJürgen Schmidt#  regarding copyright ownership.  The ASF licenses this file
7 122c3632SJürgen Schmidt#  to you under the Apache License, Version 2.0 (the
8 122c3632SJürgen Schmidt#  "License"); you may not use this file except in compliance
9 122c3632SJürgen Schmidt#  with the License.  You may obtain a copy of the License at
10 122c3632SJürgen Schmidt#
11 122c3632SJürgen Schmidt#    http://www.apache.org/licenses/LICENSE-2.0
12 122c3632SJürgen Schmidt#
13 122c3632SJürgen Schmidt#  Unless required by applicable law or agreed to in writing,
14 122c3632SJürgen Schmidt#  software distributed under the License is distributed on an
15 122c3632SJürgen Schmidt#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 122c3632SJürgen Schmidt#  KIND, either express or implied.  See the License for the
17 122c3632SJürgen Schmidt#  specific language governing permissions and limitations
18 122c3632SJürgen Schmidt#  under the License.
19 cdf0e10cSrcweir#
20 122c3632SJürgen Schmidt#**************************************************************
21 cdf0e10cSrcweir
22 cdf0e10cSrcweir# Builds the C++ component example of the Developers Guide.
23 cdf0e10cSrcweir
24 cdf0e10cSrcweirPRJ=../../../..
25 cdf0e10cSrcweirSETTINGS=$(PRJ)/settings
26 cdf0e10cSrcweir
27 cdf0e10cSrcweirinclude $(SETTINGS)/settings.mk
28 cdf0e10cSrcweirinclude $(SETTINGS)/std.mk
29 cdf0e10cSrcweirinclude $(SETTINGS)/dk.mk
30 cdf0e10cSrcweir
31 cdf0e10cSrcweir# Define non-platform/compiler specific settings
32 cdf0e10cSrcweirSAMPLE_NAME=CppComponentSample
33 cdf0e10cSrcweirSAMPLE_INC_OUT=$(OUT_INC)/$(SAMPLE_NAME)
34 cdf0e10cSrcweirSAMPLE_GEN_OUT=$(OUT_MISC)/$(SAMPLE_NAME)
35 cdf0e10cSrcweirSAMPLE_SLO_OUT=$(OUT_SLO)/$(SAMPLE_NAME)
36 cdf0e10cSrcweirSAMPLE_OBJ_OUT=$(OUT_OBJ)/$(SAMPLE_NAME)
37 cdf0e10cSrcweir
38 cdf0e10cSrcweirCOMP_NAME=CppComponent
39 cdf0e10cSrcweirCOMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
40 cdf0e10cSrcweir
41 cdf0e10cSrcweirAPP1_NAME= TestCppComponent
42 cdf0e10cSrcweirAPP1_BINARY= $(OUT_BIN)/$(APP1_NAME)$(EXE_EXT)
43 cdf0e10cSrcweir
44 cdf0e10cSrcweirCOMP_RDB_NAME = $(COMP_NAME).uno.rdb
45 cdf0e10cSrcweirCOMP_RDB = $(SAMPLE_GEN_OUT)/$(COMP_RDB_NAME)
46 cdf0e10cSrcweirCOMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
47 cdf0e10cSrcweirCOMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
48 cdf0e10cSrcweirCOMP_UNOPKG_MANIFEST = $(SAMPLE_GEN_OUT)/$(COMP_NAME)/META-INF/manifest.xml
49 cdf0e10cSrcweir#COMP_MAPFILE = $(SAMPLE_GEN_OUT)/$(COMP_NAME).uno.map
50 cdf0e10cSrcweirCOMP_COMPONENTS = $(SAMPLE_GEN_OUT)/$(COMP_NAME).components
51 cdf0e10cSrcweir
52 cdf0e10cSrcweirCOMP_REGISTERFLAG = $(SAMPLE_GEN_OUT)/devguide_$(COMP_NAME)_register_component.flag
53 cdf0e10cSrcweirCOMP_TYPEFLAG = $(SAMPLE_GEN_OUT)/devguide_$(COMP_NAME)_types.flag
54 cdf0e10cSrcweir
55 cdf0e10cSrcweirIDLFILES = some.idl
56 cdf0e10cSrcweir
57 cdf0e10cSrcweirCXXFILES = service1_impl.cxx \
58 cdf0e10cSrcweir	service2_impl.cxx
59 cdf0e10cSrcweir
60 cdf0e10cSrcweirSLOFILES = $(patsubst %.cxx,$(SAMPLE_SLO_OUT)/%.$(OBJ_EXT),$(CXXFILES))
61 cdf0e10cSrcweir
62 cdf0e10cSrcweirGENURDFILES = $(patsubst %.idl,$(SAMPLE_GEN_OUT)/%.urd,$(IDLFILES))
63 cdf0e10cSrcweir
64 cdf0e10cSrcweirTYPELIST=-Tmy_module.XSomething  \
65 cdf0e10cSrcweir	-Tmy_modules.MyService1 \
66 cdf0e10cSrcweir	-Tmy_module.MyService2
67 cdf0e10cSrcweir
68 cdf0e10cSrcweir# Targets
69 cdf0e10cSrcweir.PHONY: ALL
70 cdf0e10cSrcweirALL : \
71 cdf0e10cSrcweir	$(SAMPLE_NAME)
72 cdf0e10cSrcweir
73 cdf0e10cSrcweirinclude $(SETTINGS)/stdtarget.mk
74 cdf0e10cSrcweir
75 cdf0e10cSrcweir$(SAMPLE_GEN_OUT)/%.urd : %.idl
76 cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
77 cdf0e10cSrcweir	$(IDLC) -I. -I$(IDL_DIR) -O$(SAMPLE_GEN_OUT) $<
78 cdf0e10cSrcweir
79 cdf0e10cSrcweir$(SAMPLE_GEN_OUT)/%.rdb : $(GENURDFILES)
80 cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
81 cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
82 cdf0e10cSrcweir	$(REGMERGE) $@ /UCR $(GENURDFILES)
83 cdf0e10cSrcweir
84 cdf0e10cSrcweir$(COMP_TYPEFLAG) : $(COMP_RDB) $(SDKTYPEFLAG)
85 cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
86 cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
87 cdf0e10cSrcweir	$(CPPUMAKER) -Gc -BUCR -O$(SAMPLE_INC_OUT) $(TYPESLIST) $(COMP_RDB) -X$(URE_TYPES) -X$(OFFICE_TYPES)
88 cdf0e10cSrcweir	echo flagged > $@
89 cdf0e10cSrcweir
90 cdf0e10cSrcweir$(SAMPLE_SLO_OUT)/%.$(OBJ_EXT) : %.cxx $(COMP_TYPEFLAG)
91 cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
92 cdf0e10cSrcweir	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(SAMPLE_INC_OUT) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
93 cdf0e10cSrcweir
94 cdf0e10cSrcweir#$(COMP_MAPFILE) : $(SLOFILES)
95 cdf0e10cSrcweir#	-$(MKDIR) $(subst /,$(PS),$(@D))
96 cdf0e10cSrcweir#	cat $(PRJ)/settings/component.uno.map > $(COMP_MAPFILE)
97 cdf0e10cSrcweir#ifeq "$(OS)" "MACOSX"
98 cdf0e10cSrcweir#	nm -gx $(SLOFILES) | $(ADDSYMBOLS) >> $(COMP_MAPFILE)
99 cdf0e10cSrcweir#endif
100 cdf0e10cSrcweir
101 cdf0e10cSrcweirifeq "$(OS)" "WIN"
102 cdf0e10cSrcweir$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
103 cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
104 cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
105 cdf0e10cSrcweir	$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
106 cdf0e10cSrcweir	/MAP:$(SAMPLE_GEN_OUT)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
107 *b597708bSHerbert Dürr	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) msvcrt.lib kernel32.lib
108 cdf0e10cSrcweir	$(LINK_MANIFEST)
109 cdf0e10cSrcweirelse
110 cdf0e10cSrcweir#$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(COMP_MAPFILE)
111 cdf0e10cSrcweir$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
112 cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D)) && $(DEL) $(subst \\,\,$(subst /,$(PS),$@))
113 cdf0e10cSrcweir	$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
114 *b597708bSHerbert Dürr	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
115 cdf0e10cSrcweirifeq "$(OS)" "MACOSX"
116 cdf0e10cSrcweir	$(INSTALL_NAME_URELIBS)  $@
117 cdf0e10cSrcweirendif
118 cdf0e10cSrcweirendif
119 cdf0e10cSrcweir
120 cdf0e10cSrcweir# rule for component package manifest
121 cdf0e10cSrcweir$(SAMPLE_GEN_OUT)/%/manifest.xml :
122 cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
123 cdf0e10cSrcweir	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
124 cdf0e10cSrcweir	@echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
125 cdf0e10cSrcweir	@echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
126 cdf0e10cSrcweir	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@
127 cdf0e10cSrcweir	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(SAMPLE_GEN_OUT)/,,$(@D))).uno.rdb$(QM)"/$(CSEP) >> $@
128 cdf0e10cSrcweir	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@
129 cdf0e10cSrcweir	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@
130 cdf0e10cSrcweir	@echo $(OSEP)/manifest:manifest$(CSEP) >> $@
131 cdf0e10cSrcweir
132 cdf0e10cSrcweir$(COMP_COMPONENTS) :
133 cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
134 cdf0e10cSrcweir	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
135 cdf0e10cSrcweir	@echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
136 cdf0e10cSrcweir	@echo $(SQM)  $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
137 cdf0e10cSrcweir	@echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)my_module.my_sc_implementation.MyService1$(QM)"$(CSEP) >> $@
138 cdf0e10cSrcweir	@echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)my_module.MyService1$(QM)"/$(CSEP) >> $@
139 cdf0e10cSrcweir	@echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
140 cdf0e10cSrcweir	@echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)my_module.my_sc_implementation.MyService2$(QM)"$(CSEP) >> $@
141 cdf0e10cSrcweir	@echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)my_module.MyService2$(QM)"/$(CSEP) >> $@
142 cdf0e10cSrcweir	@echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
143 cdf0e10cSrcweir	@echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
144 cdf0e10cSrcweir	@echo $(OSEP)/components$(CSEP) >> $@
145 cdf0e10cSrcweir
146 cdf0e10cSrcweir$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) $(COMP_RDB) $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
147 cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
148 cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
149 cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT)/$(UNOPKG_PLATFORM))
150 cdf0e10cSrcweir	$(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(SAMPLE_GEN_OUT)/$(UNOPKG_PLATFORM))
151 cdf0e10cSrcweir	cd $(subst /,$(PS),$(SAMPLE_GEN_OUT)) && $(SDK_ZIP) ../../bin/$(@F) $(COMP_NAME).components
152 cdf0e10cSrcweir	cd $(subst /,$(PS),$(SAMPLE_GEN_OUT)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_RDB_NAME) $(UNOPKG_PLATFORM)/$(<F)
153 cdf0e10cSrcweir	cd $(subst /,$(PS),$(SAMPLE_GEN_OUT)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
154 cdf0e10cSrcweir
155 cdf0e10cSrcweir
156 cdf0e10cSrcweir$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
157 cdf0e10cSrcweirifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
158 cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
159 cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
160 cdf0e10cSrcweir	$(DEPLOYTOOL) $(COMP_PACKAGE_URL)
161 cdf0e10cSrcweir	@echo flagged > $(subst /,$(PS),$@)
162 cdf0e10cSrcweirelse
163 cdf0e10cSrcweir	@echo --------------------------------------------------------------------------------
164 cdf0e10cSrcweir	@echo  If you want to install your component automatically, please set the environment
165 cdf0e10cSrcweir	@echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
166 cdf0e10cSrcweir	@echo  possible if no office instance is running.
167 cdf0e10cSrcweir	@echo --------------------------------------------------------------------------------
168 cdf0e10cSrcweirendif
169 cdf0e10cSrcweir
170 cdf0e10cSrcweir$(SAMPLE_OBJ_OUT)/$(APP1_NAME).$(OBJ_EXT) : $(APP1_NAME).cxx $(COMP_TYPEFLAG)
171 cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
172 cdf0e10cSrcweir	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(SAMPLE_INC_OUT) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
173 cdf0e10cSrcweir
174 cdf0e10cSrcweir$(OUT_BIN)/_$(APP1_NAME)$(EXE_EXT) : $(SAMPLE_OBJ_OUT)/$(APP1_NAME).$(OBJ_EXT)
175 cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
176 cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
177 cdf0e10cSrcweirifeq "$(OS)" "WIN"
178 cdf0e10cSrcweir	$(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(SAMPLE_GEN_OUT)/$(basename $(@F)).map \
179 *b597708bSHerbert Dürr	  $< $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB)
180 cdf0e10cSrcweirelse
181 cdf0e10cSrcweir	$(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \
182 *b597708bSHerbert Dürr	  $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STDC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALHELPERDYLIB) $(SALDYLIB)
183 cdf0e10cSrcweirifeq "$(OS)" "MACOSX"
184 cdf0e10cSrcweir	$(INSTALL_NAME_URELIBS_BIN)  $@
185 cdf0e10cSrcweirendif
186 cdf0e10cSrcweirendif
187 cdf0e10cSrcweir
188 cdf0e10cSrcweir$(OUT_BIN)/$(APP1_NAME)$(EXE_EXT) : $(OUT_BIN)/_$(APP1_NAME)$(EXE_EXT)
189 cdf0e10cSrcweir	$(COPY) $(subst /,$(PS),$(BIN_DIR)/unoapploader$(EXE_EXT)) $(subst /,$(PS),$@)
190 cdf0e10cSrcweir# touch the target to renew the date for correct dependencies.
191 cdf0e10cSrcweir# Note: no touch under windows! The unoapploader.exe is copied always.
192 cdf0e10cSrcweirifneq "$(OS)" "WIN"
193 cdf0e10cSrcweir	touch $@
194 cdf0e10cSrcweirendif
195 cdf0e10cSrcweir
196 cdf0e10cSrcweir$(SAMPLE_NAME) : $(COMP_REGISTERFLAG) $(APP1_BINARY)
197 cdf0e10cSrcweir	@echo --------------------------------------------------------------------------------
198 cdf0e10cSrcweir	@echo Please use the following command to execute the example!
199 cdf0e10cSrcweir	@echo -
200 cdf0e10cSrcweir	@echo $(MAKE) $(APP1_NAME).run
201 cdf0e10cSrcweir	@echo --------
202 cdf0e10cSrcweir	@echo The simple C++ component was installed if SDK_AUTO_DEPLOYMENT = YES.
203 cdf0e10cSrcweir	@echo You can use this component inside your office installation, see the example
204 cdf0e10cSrcweir	@echo description. You can also load the "$(QM)SimpleComponent.odt$(QM)" document containing
205 cdf0e10cSrcweir	@echo a StarBasic macro which uses this component.
206 cdf0e10cSrcweir	@echo -
207 cdf0e10cSrcweir	@echo $(MAKE) SimpleComponent.odt.load
208 cdf0e10cSrcweir	@echo --------------------------------------------------------------------------------
209 cdf0e10cSrcweir
210 cdf0e10cSrcweir%.run: $(OUT_BIN)/%$(EXE_EXT)
211 cdf0e10cSrcweir	$(subst /,$(PS),$(OUT_BIN))$(PS)$(basename $@)
212 cdf0e10cSrcweir#	cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@)
213 cdf0e10cSrcweir
214 cdf0e10cSrcweirSimpleComponent.odt.load : $(COMP_REGISTERFLAG)
215 cdf0e10cSrcweir	"$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
216 cdf0e10cSrcweir
217 cdf0e10cSrcweir.PHONY: clean
218 cdf0e10cSrcweirclean :
219 cdf0e10cSrcweir	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_INC_OUT))
220 cdf0e10cSrcweir	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
221 cdf0e10cSrcweir	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_SLO_OUT))
222 cdf0e10cSrcweir	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_OBJ_OUT))
223 cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_COMPONENTS)))
224 cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/$(COMP_NAME)*))
225 cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/*$(APP1_NAME)*))
226