1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22#************************************************************************* 23# 24# The Contents of this file are made available subject to the terms of 25# the BSD license. 26# 27# Copyright 2000, 2010 Oracle and/or its affiliates. 28# All rights reserved. 29# 30# Redistribution and use in source and binary forms, with or without 31# modification, are permitted provided that the following conditions 32# are met: 33# 1. Redistributions of source code must retain the above copyright 34# notice, this list of conditions and the following disclaimer. 35# 2. Redistributions in binary form must reproduce the above copyright 36# notice, this list of conditions and the following disclaimer in the 37# documentation and/or other materials provided with the distribution. 38# 3. Neither the name of Sun Microsystems, Inc. nor the names of its 39# contributors may be used to endorse or promote products derived 40# from this software without specific prior written permission. 41# 42# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 43# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 44# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 45# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 46# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 47# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 48# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 49# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 50# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 51# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 52# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53# 54#************************************************************************** 55 56# Builds the C++ component example of the Developers Guide. 57 58PRJ=../../../.. 59SETTINGS=$(PRJ)/settings 60 61include $(SETTINGS)/settings.mk 62include $(SETTINGS)/std.mk 63include $(SETTINGS)/dk.mk 64 65# Define non-platform/compiler specific settings 66SAMPLE_NAME=CppComponentSample 67SAMPLE_INC_OUT=$(OUT_INC)/$(SAMPLE_NAME) 68SAMPLE_GEN_OUT=$(OUT_MISC)/$(SAMPLE_NAME) 69SAMPLE_SLO_OUT=$(OUT_SLO)/$(SAMPLE_NAME) 70SAMPLE_OBJ_OUT=$(OUT_OBJ)/$(SAMPLE_NAME) 71 72COMP_NAME=CppComponent 73COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT) 74 75APP1_NAME= TestCppComponent 76APP1_BINARY= $(OUT_BIN)/$(APP1_NAME)$(EXE_EXT) 77 78COMP_RDB_NAME = $(COMP_NAME).uno.rdb 79COMP_RDB = $(SAMPLE_GEN_OUT)/$(COMP_RDB_NAME) 80COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT) 81COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)") 82COMP_UNOPKG_MANIFEST = $(SAMPLE_GEN_OUT)/$(COMP_NAME)/META-INF/manifest.xml 83#COMP_MAPFILE = $(SAMPLE_GEN_OUT)/$(COMP_NAME).uno.map 84COMP_COMPONENTS = $(SAMPLE_GEN_OUT)/$(COMP_NAME).components 85 86COMP_REGISTERFLAG = $(SAMPLE_GEN_OUT)/devguide_$(COMP_NAME)_register_component.flag 87COMP_TYPEFLAG = $(SAMPLE_GEN_OUT)/devguide_$(COMP_NAME)_types.flag 88 89IDLFILES = some.idl 90 91CXXFILES = service1_impl.cxx \ 92 service2_impl.cxx 93 94SLOFILES = $(patsubst %.cxx,$(SAMPLE_SLO_OUT)/%.$(OBJ_EXT),$(CXXFILES)) 95 96GENURDFILES = $(patsubst %.idl,$(SAMPLE_GEN_OUT)/%.urd,$(IDLFILES)) 97 98TYPELIST=-Tmy_module.XSomething \ 99 -Tmy_modules.MyService1 \ 100 -Tmy_module.MyService2 101 102# Targets 103.PHONY: ALL 104ALL : \ 105 $(SAMPLE_NAME) 106 107include $(SETTINGS)/stdtarget.mk 108 109$(SAMPLE_GEN_OUT)/%.urd : %.idl 110 -$(MKDIR) $(subst /,$(PS),$(@D)) 111 $(IDLC) -I. -I$(IDL_DIR) -O$(SAMPLE_GEN_OUT) $< 112 113$(SAMPLE_GEN_OUT)/%.rdb : $(GENURDFILES) 114 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 115 -$(MKDIR) $(subst /,$(PS),$(@D)) 116 $(REGMERGE) $@ /UCR $(GENURDFILES) 117 118$(COMP_TYPEFLAG) : $(COMP_RDB) $(SDKTYPEFLAG) 119 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 120 -$(MKDIR) $(subst /,$(PS),$(@D)) 121 $(CPPUMAKER) -Gc -BUCR -O$(SAMPLE_INC_OUT) $(TYPESLIST) $(COMP_RDB) -X$(URE_TYPES) -X$(OFFICE_TYPES) 122 echo flagged > $@ 123 124$(SAMPLE_SLO_OUT)/%.$(OBJ_EXT) : %.cxx $(COMP_TYPEFLAG) 125 -$(MKDIR) $(subst /,$(PS),$(@D)) 126 $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(SAMPLE_INC_OUT) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $< 127 128#$(COMP_MAPFILE) : $(SLOFILES) 129# -$(MKDIR) $(subst /,$(PS),$(@D)) 130# cat $(PRJ)/settings/component.uno.map > $(COMP_MAPFILE) 131#ifeq "$(OS)" "MACOSX" 132# nm -gx $(SLOFILES) | $(ADDSYMBOLS) >> $(COMP_MAPFILE) 133#endif 134 135ifeq "$(OS)" "WIN" 136$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) 137 -$(MKDIR) $(subst /,$(PS),$(@D)) 138 -$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT)) 139 $(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \ 140 /MAP:$(SAMPLE_GEN_OUT)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \ 141 $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib 142 $(LINK_MANIFEST) 143else 144#$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(COMP_MAPFILE) 145$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) 146 -$(MKDIR) $(subst /,$(PS),$(@D)) && $(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 147 $(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \ 148 $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB) 149ifeq "$(OS)" "MACOSX" 150 $(INSTALL_NAME_URELIBS) $@ 151endif 152endif 153 154# rule for component package manifest 155$(SAMPLE_GEN_OUT)/%/manifest.xml : 156 -$(MKDIR) $(subst /,$(PS),$(@D)) 157 @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@ 158 @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@ 159 @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@ 160 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@ 161 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(SAMPLE_GEN_OUT)/,,$(@D))).uno.rdb$(QM)"/$(CSEP) >> $@ 162 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@ 163 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@ 164 @echo $(OSEP)/manifest:manifest$(CSEP) >> $@ 165 166$(COMP_COMPONENTS) : 167 -$(MKDIR) $(subst /,$(PS),$(@D)) 168 @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@ 169 @echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@ 170 @echo $(SQM) $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@ 171 @echo $(SQM) $(SQM)$(OSEP)implementation name="$(QM)my_module.my_sc_implementation.MyService1$(QM)"$(CSEP) >> $@ 172 @echo $(SQM) $(SQM)$(OSEP)service name="$(QM)my_module.MyService1$(QM)"/$(CSEP) >> $@ 173 @echo $(SQM) $(SQM)$(OSEP)/implementation$(CSEP) >> $@ 174 @echo $(SQM) $(SQM)$(OSEP)implementation name="$(QM)my_module.my_sc_implementation.MyService2$(QM)"$(CSEP) >> $@ 175 @echo $(SQM) $(SQM)$(OSEP)service name="$(QM)my_module.MyService2$(QM)"/$(CSEP) >> $@ 176 @echo $(SQM) $(SQM)$(OSEP)/implementation$(CSEP) >> $@ 177 @echo $(SQM) $(SQM)$(OSEP)/component$(CSEP) >> $@ 178 @echo $(OSEP)/components$(CSEP) >> $@ 179 180$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) $(COMP_RDB) $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS) 181 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 182 -$(MKDIR) $(subst /,$(PS),$(@D)) 183 -$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT)/$(UNOPKG_PLATFORM)) 184 $(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(SAMPLE_GEN_OUT)/$(UNOPKG_PLATFORM)) 185 cd $(subst /,$(PS),$(SAMPLE_GEN_OUT)) && $(SDK_ZIP) ../../bin/$(@F) $(COMP_NAME).components 186 cd $(subst /,$(PS),$(SAMPLE_GEN_OUT)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_RDB_NAME) $(UNOPKG_PLATFORM)/$(<F) 187 cd $(subst /,$(PS),$(SAMPLE_GEN_OUT)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml 188 189 190$(COMP_REGISTERFLAG) : $(COMP_PACKAGE) 191ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES" 192 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 193 -$(MKDIR) $(subst /,$(PS),$(@D)) 194 $(DEPLOYTOOL) $(COMP_PACKAGE_URL) 195 @echo flagged > $(subst /,$(PS),$@) 196else 197 @echo -------------------------------------------------------------------------------- 198 @echo If you want to install your component automatically, please set the environment 199 @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only 200 @echo possible if no office instance is running. 201 @echo -------------------------------------------------------------------------------- 202endif 203 204$(SAMPLE_OBJ_OUT)/$(APP1_NAME).$(OBJ_EXT) : $(APP1_NAME).cxx $(COMP_TYPEFLAG) 205 -$(MKDIR) $(subst /,$(PS),$(@D)) 206 $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(SAMPLE_INC_OUT) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $< 207 208$(OUT_BIN)/_$(APP1_NAME)$(EXE_EXT) : $(SAMPLE_OBJ_OUT)/$(APP1_NAME).$(OBJ_EXT) 209 -$(MKDIR) $(subst /,$(PS),$(@D)) 210 -$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT)) 211ifeq "$(OS)" "WIN" 212 $(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(SAMPLE_GEN_OUT)/$(basename $(@F)).map \ 213 $< $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) 214else 215 $(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \ 216 $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) $(STDC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALHELPERDYLIB) $(SALDYLIB) 217ifeq "$(OS)" "MACOSX" 218 $(INSTALL_NAME_URELIBS_BIN) $@ 219endif 220endif 221 222$(OUT_BIN)/$(APP1_NAME)$(EXE_EXT) : $(OUT_BIN)/_$(APP1_NAME)$(EXE_EXT) 223 $(COPY) $(subst /,$(PS),$(BIN_DIR)/unoapploader$(EXE_EXT)) $(subst /,$(PS),$@) 224# touch the target to renew the date for correct dependencies. 225# Note: no touch under windows! The unoapploader.exe is copied always. 226ifneq "$(OS)" "WIN" 227 touch $@ 228endif 229 230$(SAMPLE_NAME) : $(COMP_REGISTERFLAG) $(APP1_BINARY) 231 @echo -------------------------------------------------------------------------------- 232 @echo Please use the following command to execute the example! 233 @echo - 234 @echo $(MAKE) $(APP1_NAME).run 235 @echo -------- 236 @echo The simple C++ component was installed if SDK_AUTO_DEPLOYMENT = YES. 237 @echo You can use this component inside your office installation, see the example 238 @echo description. You can also load the "$(QM)SimpleComponent.odt$(QM)" document containing 239 @echo a StarBasic macro which uses this component. 240 @echo - 241 @echo $(MAKE) SimpleComponent.odt.load 242 @echo -------------------------------------------------------------------------------- 243 244%.run: $(OUT_BIN)/%$(EXE_EXT) 245 $(subst /,$(PS),$(OUT_BIN))$(PS)$(basename $@) 246# cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@) 247 248SimpleComponent.odt.load : $(COMP_REGISTERFLAG) 249 "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@) 250 251.PHONY: clean 252clean : 253 -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_INC_OUT)) 254 -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT)) 255 -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_SLO_OUT)) 256 -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_OBJ_OUT)) 257 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_COMPONENTS))) 258 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/$(COMP_NAME)*)) 259 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/*$(APP1_NAME)*)) 260