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# Builds the ProtocolHandlerAddon C++ component example of the SDK. 23 24PRJ=../../../../.. 25SETTINGS=$(PRJ)/settings 26 27include $(SETTINGS)/settings.mk 28include $(SETTINGS)/std.mk 29include $(SETTINGS)/dk.mk 30 31# Define non-platform/compiler specific settings 32COMP_NAME=ProtocolHandlerAddon_cpp 33COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT) 34OUT_COMP_INC=$(OUT_INC)/$(COMP_NAME) 35OUT_COMP_GEN=$(OUT_MISC)/$(COMP_NAME) 36OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME) 37COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT) 38COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)") 39COMP_UNOPKG_MANIFEST = $(OUT_COMP_GEN)/$(COMP_NAME)/META-INF/manifest.xml 40#COMP_MAPFILE = $(OUT_COMP_GEN)/$(COMP_NAME).uno.map 41COMP_COMPONENTS = $(OUT_COMP_GEN)/$(COMP_NAME).components 42 43REGISTERFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_register_component.flag 44 45CXXFILES = component.cxx \ 46 addon.cxx 47 48SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES)) 49 50# Targets 51.PHONY: ALL 52ALL : \ 53 Example 54 55include $(SETTINGS)/stdtarget.mk 56 57$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG) 58 -$(MKDIR) $(subst /,$(PS),$(@D)) 59 $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $< 60 61#$(COMP_MAPFILE) : $(SLOFILES) 62# -$(MKDIR) $(subst /,$(PS),$(@D)) 63# cat $(PRJ)/settings/component.uno.map > $(COMP_MAPFILE) 64#ifeq "$(OS)" "MACOSX" 65# nm -gx $(SLOFILES) | $(ADDSYMBOLS) >> $(COMP_MAPFILE) 66#endif 67 68ifeq "$(OS)" "WIN" 69$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) 70 -$(MKDIR) $(subst /,$(PS),$(@D)) 71 -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN)) 72 $(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \ 73 /MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \ 74 $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) msvcrt.lib kernel32.lib 75 $(LINK_MANIFEST) 76else 77#$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(COMP_MAPFILE) 78$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) 79 -$(MKDIR) $(subst /,$(PS),$(@D)) 80 $(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \ 81 $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB) 82ifeq "$(OS)" "MACOSX" 83 $(INSTALL_NAME_URELIBS) $@ 84endif 85endif 86 87# rule for component package manifest 88$(OUT_COMP_GEN)/%/manifest.xml : 89 -$(MKDIR) $(subst /,$(PS),$(@D)) 90 @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@ 91 @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@ 92 @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@ 93 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@ 94 @echo $(SQM) $(SQM)manifest:full-path="$(QM)Addons.xcu$(QM)"/$(CSEP) >> $@ 95 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@ 96 @echo $(SQM) $(SQM)manifest:full-path="$(QM)ProtocolHandler.xcu$(QM)"/$(CSEP) >> $@ 97 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@ 98 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@ 99 @echo $(OSEP)/manifest:manifest$(CSEP) >> $@ 100 101$(COMP_COMPONENTS) : 102 -$(MKDIR) $(subst /,$(PS),$(@D)) 103 @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@ 104 @echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@ 105 @echo $(SQM) $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@ 106 @echo $(SQM) $(SQM)$(OSEP)implementation name="$(QM)org.openoffice.Office.addon.example$(QM)"$(CSEP) >> $@ 107 @echo $(SQM) $(SQM)$(OSEP)service name="$(QM)com.sun.star.frame.ProtocolHandler$(QM)"/$(CSEP) >> $@ 108 @echo $(SQM) $(SQM)$(OSEP)/implementation$(CSEP) >> $@ 109 @echo $(SQM) $(SQM)$(OSEP)/component$(CSEP) >> $@ 110 @echo $(OSEP)/components$(CSEP) >> $@ 111 112# rule for component package file 113$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) Addons.xcu ProtocolHandler.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS) 114 -$(MKDIR) $(subst /,$(PS),$(@D)) && $(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 115 -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM)) 116 $(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM)) 117 cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) ../../bin/$(@F) $(COMP_NAME).components 118 cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(UNOPKG_PLATFORM)/$(<F) 119 $(SDK_ZIP) -u $@ Addons.xcu ProtocolHandler.xcu 120 cd $(subst /,$(PS),$(OUT_COMP_GEN)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml 121 122$(REGISTERFLAG) : $(COMP_PACKAGE) 123ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES" 124 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 125 $(DEPLOYTOOL) $(COMP_PACKAGE_URL) 126 @echo flagged > $(subst /,$(PS),$@) 127else 128 @echo -------------------------------------------------------------------------------- 129 @echo If you want to install your component automatically, please set the environment 130 @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only 131 @echo possible if no office instance is running. 132 @echo -------------------------------------------------------------------------------- 133endif 134 135Example : $(REGISTERFLAG) 136 @echo -------------------------------------------------------------------------------- 137 @echo The "$(QM)ProtocolHandler$(QM)" addon component was installed if SDK_AUTO_DEPLOYMENT = YES. 138 @echo You can use this component inside your office installation, see the example 139 @echo description. 140 @echo -------------------------------------------------------------------------------- 141 142.PHONY: clean 143clean : 144 -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC)) 145 -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN)) 146 -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO)) 147 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL))) 148 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_COMPONENTS))) 149 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG))) 150 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*)) 151