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