Update ooo320-m1
[ooovba.git] / odk / examples / DevelopersGuide / Components / CppComponent / Makefile
blob7e46f679096fe80e8189589363c001ed8eab7e89
1 #*************************************************************************
3 # $RCSfile: Makefile,v $
5 # $Revision: 1.11 $
7 # last change: $Author: rt $ $Date: 2008-07-11 14:17:49 $
9 # The Contents of this file are made available subject to the terms of
10 # the BSD license.
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
17 # are met:
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 C++ component example of the Developers Guide.
43 PRJ=../../../..
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
51 SAMPLE_NAME=CppComponentSample
52 SAMPLE_INC_OUT=$(OUT_INC)/$(SAMPLE_NAME)
53 SAMPLE_GEN_OUT=$(OUT_MISC)/$(SAMPLE_NAME)
54 SAMPLE_SLO_OUT=$(OUT_SLO)/$(SAMPLE_NAME)
55 SAMPLE_OBJ_OUT=$(OUT_OBJ)/$(SAMPLE_NAME)
57 COMP_NAME=CppComponent
58 COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
60 APP1_NAME= TestCppComponent
61 APP1_BINARY= $(OUT_BIN)/$(APP1_NAME)$(EXE_EXT)
63 COMP_RDB_NAME = $(COMP_NAME).uno.rdb
64 COMP_RDB = $(SAMPLE_GEN_OUT)/$(COMP_RDB_NAME)
65 COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
66 COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
67 COMP_UNOPKG_MANIFEST = $(SAMPLE_GEN_OUT)/$(COMP_NAME)/META-INF/manifest.xml
68 COMP_MAPFILE = $(SAMPLE_GEN_OUT)/$(COMP_NAME).uno.map
70 COMP_REGISTERFLAG = $(SAMPLE_GEN_OUT)/devguide_$(COMP_NAME)_register_component.flag
71 COMP_TYPEFLAG = $(SAMPLE_GEN_OUT)/devguide_$(COMP_NAME)_types.flag
73 IDLFILES = some.idl
75 CXXFILES = service1_impl.cxx \
76 service2_impl.cxx
78 SLOFILES = $(patsubst %.cxx,$(SAMPLE_SLO_OUT)/%.$(OBJ_EXT),$(CXXFILES))
80 GENURDFILES = $(patsubst %.idl,$(SAMPLE_GEN_OUT)/%.urd,$(IDLFILES))
82 TYPELIST=-Tmy_module.XSomething \
83 -Tmy_modules.MyService1 \
84 -Tmy_module.MyService2
86 # Targets
87 .PHONY: ALL
88 ALL : \
89 $(SAMPLE_NAME)
91 include $(SETTINGS)/stdtarget.mk
93 $(SAMPLE_GEN_OUT)/%.urd : %.idl
94 -$(MKDIR) $(subst /,$(PS),$(@D))
95 $(IDLC) -I. -I$(IDL_DIR) -O$(SAMPLE_GEN_OUT) $<
97 $(SAMPLE_GEN_OUT)/%.rdb : $(GENURDFILES)
98 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
99 -$(MKDIR) $(subst /,$(PS),$(@D))
100 $(REGMERGE) $@ /UCR $(GENURDFILES)
102 $(COMP_TYPEFLAG) : $(COMP_RDB) $(SDKTYPEFLAG)
103 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
104 -$(MKDIR) $(subst /,$(PS),$(@D))
105 $(CPPUMAKER) -Gc -BUCR -O$(SAMPLE_INC_OUT) $(TYPESLIST) $(COMP_RDB) -X$(URE_TYPES) -X$(OFFICE_TYPES)
106 echo flagged > $@
108 $(SAMPLE_SLO_OUT)/%.$(OBJ_EXT) : %.cxx $(COMP_TYPEFLAG)
109 -$(MKDIR) $(subst /,$(PS),$(@D))
110 $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(SAMPLE_INC_OUT) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
112 $(COMP_MAPFILE) : $(SLOFILES)
113 -$(MKDIR) $(subst /,$(PS),$(@D))
114 cat $(PRJ)/settings/component.uno.map > $(COMP_MAPFILE)
115 ifeq "$(OS)" "MACOSX"
116 nm -gx $(SLOFILES) | $(ADDSYMBOLS) >> $(COMP_MAPFILE)
117 endif
119 ifeq "$(OS)" "WIN"
120 $(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
121 -$(MKDIR) $(subst /,$(PS),$(@D))
122 -$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
123 $(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
124 /MAP:$(SAMPLE_GEN_OUT)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
125 $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
126 $(LINK_MANIFEST_VC8_ONLY)
127 else
128 $(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(COMP_MAPFILE)
129 -$(MKDIR) $(subst /,$(PS),$(@D)) && $(DEL) $(subst \\,\,$(subst /,$(PS),$@))
130 $(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
131 $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
132 ifeq "$(OS)" "MACOSX"
133 $(INSTALL_NAME_URELIBS) $@
134 endif
135 endif
137 # rule for component package manifest
138 $(SAMPLE_GEN_OUT)/%/manifest.xml :
139 -$(MKDIR) $(subst /,$(PS),$(@D))
140 @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
141 @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
142 @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
143 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@
144 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(SAMPLE_GEN_OUT)/,,$(@D))).uno.rdb$(QM)"/$(CSEP) >> $@
145 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-component;type=native;platform=$(UNOPKG_PLATFORM)$(QM)" >> $@
146 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(SAMPLE_GEN_OUT)/,,$(UNOPKG_PLATFORM)/$(@D))).uno.$(SHAREDLIB_EXT)$(QM)"/$(CSEP) >> $@
147 @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
149 $(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) $(COMP_RDB) $(COMP_UNOPKG_MANIFEST)
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_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),$@)
164 else
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 --------------------------------------------------------------------------------
170 endif
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))
179 ifeq "$(OS)" "WIN"
180 $(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(SAMPLE_GEN_OUT)/$(basename $(@F)).map \
181 $< $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB)
182 else
183 $(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \
184 $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) $(STDC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALHELPERDYLIB) $(SALDYLIB)
185 ifeq "$(OS)" "MACOSX"
186 $(INSTALL_NAME_URELIBS_BIN) $@
187 endif
188 endif
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.
194 ifneq "$(OS)" "WIN"
195 touch $@
196 endif
198 $(SAMPLE_NAME) : $(COMP_REGISTERFLAG) $(APP1_BINARY)
199 @echo --------------------------------------------------------------------------------
200 @echo Please use the following command to execute the example!
201 @echo -
202 @echo $(MAKE) $(APP1_NAME).run
203 @echo --------
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.
208 @echo -
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 $@)
219 .PHONY: clean
220 clean :
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),$(OUT_BIN)/$(COMP_NAME)*))
226 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/*$(APP1_NAME)*))