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 SpreadSheet examples of the Developers Guide. 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 32SAMPLE_NAME=DevGuideSpreadsheetExamples 33SAMPLE_CLASS_OUT=$(OUT_CLASS)/$(SAMPLE_NAME) 34SAMPLE_GEN_OUT=$(OUT_MISC)/$(SAMPLE_NAME) 35 36# Example add-in component 37COMP1_NAME=ExampleAddIn 38COMP1_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(COMP1_NAME) 39COMP1_GEN_OUT=$(SAMPLE_GEN_OUT)/$(COMP1_NAME) 40COMP1_RDB_NAME=$(COMP1_NAME).uno.rdb 41COMP1_RDB=$(COMP1_GEN_OUT)/$(COMP1_RDB_NAME) 42COMP1_PACKAGE=$(OUT_BIN)/$(COMP1_NAME).$(UNOOXT_EXT) 43COMP1_PACKAGE_URL=$(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP1_NAME).$(UNOOXT_EXT)") 44COMP1_JAR_NAME=$(COMP1_NAME).uno.jar 45COMP1_JAR=$(SAMPLE_CLASS_OUT)/$(COMP1_JAR_NAME) 46COMP1_MANIFESTFILE=$(COMP1_GEN_OUT)/$(COMP1_NAME).uno.Manifest 47COMP1_UNOPKG_MANIFEST=$(COMP1_GEN_OUT)/$(COMP1_NAME)/META-INF/manifest.xml 48COMP1_REGISTERFLAG=$(SAMPLE_GEN_OUT)/devguide_$(COMP1_NAME)_register_component.flag 49COMP1_COMPONENTS=$(COMP1_NAME).components 50 51# Example DataPilot component 52COMP2_NAME=ExampleDataPilotSource 53COMP2_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(COMP2_NAME) 54COMP2_GEN_OUT=$(SAMPLE_GEN_OUT)/$(COMP2_NAME) 55COMP2_PACKAGE=$(OUT_BIN)/$(COMP2_NAME).$(UNOOXT_EXT) 56COMP2_PACKAGE_URL=$(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP2_NAME).$(UNOOXT_EXT)") 57COMP2_JAR_NAME=$(COMP2_NAME).uno.jar 58COMP2_JAR=$(SAMPLE_CLASS_OUT)/$(COMP2_JAR_NAME) 59COMP2_MANIFESTFILE=$(COMP2_GEN_OUT)/$(COMP2_NAME).uno.Manifest 60COMP2_UNOPKG_MANIFEST=$(COMP2_GEN_OUT)/$(COMP2_NAME)/META-INF/manifest.xml 61COMP2_REGISTERFLAG=$(SAMPLE_GEN_OUT)/devguide_$(COMP2_NAME)_register_component.flag 62COMP2_COMPONENTS=$(COMP2_NAME).components 63 64#REGISTERFLAG = $(OUT_MISC)$(PS)devguide_$(SAMPLE_NAME)_register_component.flag 65 66APP1_NAME=GeneralTableSample 67APP1_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP1_NAME) 68APP1_GEN_OUT=$(SAMPLE_GEN_OUT)/$(APP1_NAME) 69APP1_JAR=$(SAMPLE_CLASS_OUT)/$(APP1_NAME).jar 70 71APP2_NAME=SpreadsheetSample 72APP2_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP2_NAME) 73APP2_GEN_OUT=$(SAMPLE_GEN_OUT)/$(APP2_NAME) 74APP2_JAR=$(SAMPLE_CLASS_OUT)/$(APP2_NAME).jar 75 76APP3_NAME=ViewSample 77APP3_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP3_NAME) 78APP3_GEN_OUT=$(SAMPLE_GEN_OUT)/$(APP3_NAME) 79APP3_JAR=$(SAMPLE_CLASS_OUT)/$(APP3_NAME).jar 80 81 82COMP1_IDLFILES = XExampleAddIn.idl 83 84# normally the idl file should be stored in a directory tree fitting the 85# module structure, for the example we know the module structure 86PACKAGE = org/openoffice/sheet/addin 87 88COMP1_JAVAFILES = \ 89 ExampleAddIn.java 90 91COMP2_JAVAFILES = \ 92 ExampleDataPilotSource.java 93 94APP_JAVAFILES = \ 95 SpreadsheetDocHelper.java 96 97APP_CLASSFILES = $(patsubst %.java,$(SAMPLE_CLASS_OUT)/%.class,$(APP_JAVAFILES)) 98APP_CLASSNAMES = $(patsubst %.java,%.class,$(APP_JAVAFILES)) 99 100COMP1_GENCLASSFILES = $(patsubst %.idl,$(COMP1_CLASS_OUT)/$(PACKAGE)/%.class,$(COMP1_IDLFILES)) 101COMP1_GENTYPELIST = $(subst /,.,$(patsubst %.idl,-T$(PACKAGE)/% ,$(COMP1_IDLFILES))) 102COMP1_GENURDFILES = $(patsubst %.idl,$(COMP1_GEN_OUT)/%.urd,$(COMP1_IDLFILES)) 103 104COMP1_CLASSFILES = $(patsubst %.java,$(COMP1_CLASS_OUT)/%.class,$(COMP1_JAVAFILES)) 105 106COMP2_CLASSFILES = $(patsubst %.java,$(COMP2_CLASS_OUT)/%.class,$(COMP2_JAVAFILES)) 107 108 109SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\ 110 $(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT)\ 111 $(PATH_SEPARATOR)$(COMP1_CLASS_OUT)\ 112 $(PATH_SEPARATOR)$(COMP2_CLASS_OUT)\ 113 $(PATH_SEPARATOR)$(APP1_CLASS_OUT)\ 114 $(PATH_SEPARATOR)$(APP2_CLASS_OUT)\ 115 $(PATH_SEPARATOR)$(APP3_CLASS_OUT)) 116 117 118# Targets 119.PHONY: ALL 120ALL : $(SAMPLE_NAME) 121 122include $(SETTINGS)/stdtarget.mk 123 124$(SAMPLE_GEN_OUT)/%.Manifest : 125 -$(MKDIR) $(subst /,$(PS),$(@D)) 126 @echo UNO-Type-Path: $(basename $(notdir $*)).uno.jar> $@ 127 @echo RegistrationClassName: $(basename $(basename $(@F)))>> $@ 128 129# IDLs only for component 1 relevant 130$(COMP1_GEN_OUT)/%.urd : %.idl 131 -$(MKDIR) $(subst /,$(PS),$(@D)) 132 $(IDLC) -I. -I$(IDL_DIR) -O$(COMP1_GEN_OUT) $^ 133 134$(COMP1_RDB) : $(COMP1_GENURDFILES) 135 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 136 -$(MKDIR) $(subst /,$(PS),$(@D)) 137 $(REGMERGE) $@ /UCR $< 138 139$(COMP1_CLASS_OUT)/$(PACKAGE)/%.class : $(COMP1_RDB) 140 -$(MKDIR) $(subst /,$(PS),$(@D)) 141 $(JAVAMAKER) -BUCR -nD $(COMP1_GENTYPELIST) -O$(COMP1_CLASS_OUT) $(COMP1_RDB) -X$(URE_TYPES) -X$(OFFICE_TYPES) 142 143$(COMP1_CLASSFILES) : $(COMP1_JAVAFILES) $(COMP1_GENCLASSFILES) 144 -$(MKDIR) $(subst /,$(PS),$(@D)) 145 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(COMP1_CLASS_OUT) $(COMP1_JAVAFILES) 146 147$(COMP2_CLASSFILES) : $(COMP2_JAVAFILES) 148 -$(MKDIR) $(subst /,$(PS),$(@D)) 149 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(COMP2_CLASS_OUT) $^ 150 151$(COMP1_JAR) : $(COMP1_MANIFESTFILE) $(COMP1_CLASSFILES) 152 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 153 -$(MKDIR) $(subst /,$(PS),$(@D)) 154 $(SDK_JAR) cvfm $@ $< -C $(COMP1_CLASS_OUT) . 155 156$(COMP2_JAR) : $(COMP2_MANIFESTFILE) $(COMP2_CLASSFILES) 157 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 158 -$(MKDIR) $(subst /,$(PS),$(@D)) 159 $(SDK_JAR) cvfm $@ $< -C $(COMP2_CLASS_OUT) . 160 161$(COMP1_UNOPKG_MANIFEST) : 162 -$(MKDIR) $(subst /,$(PS),$(@D)) 163 @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@ 164 @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@ 165 @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@ 166 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@ 167 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(COMP1_GEN_OUT)/,,$(@D))).uno.rdb$(QM)"/$(CSEP) >> $@ 168 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@ 169 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP1_COMPONENTS)$(QM)"/$(CSEP)>> $@ 170 @echo $(OSEP)/manifest:manifest$(CSEP) >> $@ 171 172$(COMP2_UNOPKG_MANIFEST) : 173 -$(MKDIR) $(subst /,$(PS),$(@D)) 174 @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@ 175 @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@ 176 @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@ 177 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@ 178 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP2_COMPONENTS)$(QM)"/$(CSEP)>> $@ 179 @echo $(OSEP)/manifest:manifest$(CSEP) >> $@ 180 181$(COMP1_PACKAGE) : $(COMP1_RDB) $(COMP1_JAR) $(COMP1_UNOPKG_MANIFEST) $(COMP1_COMPONENTS) 182 echo "####" $(@) 183 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 184 -$(MKDIR) $(subst /,$(PS),$(@D)) 185 $(SDK_ZIP) $@ $(COMP1_COMPONENTS) 186 cd $(subst /,$(PS),$(COMP1_GEN_OUT)) && $(SDK_ZIP) -u ../../../bin/$(@F) $(<F) 187 cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP1_JAR_NAME) 188 cd $(subst /,$(PS),$(COMP1_GEN_OUT)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../../bin/$(@F) META-INF/manifest.xml 189 190$(COMP2_PACKAGE) : $(COMP2_JAR) $(COMP2_UNOPKG_MANIFEST) $(COMP2_COMPONENTS) 191 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 192 -$(MKDIR) $(subst /,$(PS),$(@D)) 193 $(SDK_ZIP) $@ $(COMP2_COMPONENTS) 194 cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_ZIP) -u ../../bin/$(@F) $(<F) 195 cd $(subst /,$(PS),$(COMP2_GEN_OUT)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../../bin/$(@F) META-INF/manifest.xml 196 197$(SAMPLE_GEN_OUT)/devguide_$(COMP1_NAME)_register_component.flag : $(OUT_BIN)/$(COMP1_NAME).$(UNOOXT_EXT) 198ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES" 199 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 200 -$(MKDIR) $(subst /,$(PS),$(@D)) 201 $(DEPLOYTOOL) $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP1_NAME).$(UNOOXT_EXT)") 202 @echo flagged > $(subst /,$(PS),$@) 203else 204 @echo -------------------------------------------------------------------------------- 205 @echo If you want to install your component automatically, please set the environment 206 @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only 207 @echo possible if no office instance is running. 208 @echo -------------------------------------------------------------------------------- 209endif 210 211$(SAMPLE_GEN_OUT)/devguide_$(COMP2_NAME)_register_component.flag : $(OUT_BIN)/$(COMP2_NAME).$(UNOOXT_EXT) 212ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES" 213 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 214 -$(MKDIR) $(subst /,$(PS),$(@D)) 215 $(DEPLOYTOOL) $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP2_NAME).$(UNOOXT_EXT)") 216 @echo flagged > $(subst /,$(PS),$@) 217else 218 @echo -------------------------------------------------------------------------------- 219 @echo If you want to install your component automatically, please set the environment 220 @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only 221 @echo possible if no office instance is running. 222 @echo -------------------------------------------------------------------------------- 223endif 224 225$(APP_CLASSFILES) : $(APP_JAVAFILES) 226 -$(MKDIR) $(subst /,$(PS),$(@D)) 227 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $(APP_JAVAFILES) 228 229$(APP1_CLASS_OUT)/%.class : %.java $(APP_CLASSFILES) 230 -$(MKDIR) $(subst /,$(PS),$(@D)) 231 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP1_CLASS_OUT) $< 232 233$(APP2_CLASS_OUT)/%.class : %.java $(APP_CLASSFILES) 234 -$(MKDIR) $(subst /,$(PS),$(@D)) 235 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP2_CLASS_OUT) $< 236 237$(APP3_CLASS_OUT)/%.class : %.java $(APP_CLASSFILES) 238 -$(MKDIR) $(subst /,$(PS),$(@D)) 239 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP3_CLASS_OUT) $< 240 241$(SAMPLE_GEN_OUT)/%.mf : 242 -$(MKDIR) $(subst /,$(PS),$(@D)) 243 @echo Main-Class: com.sun.star.lib.loader.Loader> $@ 244 $(ECHOLINE)>> $@ 245 @echo Name: com/sun/star/lib/loader/Loader.class>> $@ 246 @echo Application-Class: $(basename $(@F))>> $@ 247 248$(APP1_JAR) : $(APP1_GEN_OUT)/$(APP1_NAME).mf $(APP1_CLASS_OUT)/$(APP1_NAME).class $(APP_CLASSFILES) 249 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 250 -$(MKDIR) $(subst /,$(PS),$(@D)) 251 +$(SDK_JAR) cvfm $@ $< -C $(APP1_CLASS_OUT) . 252 +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES) 253 +cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) uvf $(@F) $(APP_CLASSNAMES) 254 255$(APP2_JAR) : $(APP2_GEN_OUT)/$(APP2_NAME).mf $(APP2_CLASS_OUT)/$(APP2_NAME).class $(APP_CLASSFILES) 256 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 257 -$(MKDIR) $(subst /,$(PS),$(@D)) 258 +$(SDK_JAR) cvfm $@ $< -C $(APP2_CLASS_OUT) . 259 +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES) 260 +cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) uvf $(@F) $(APP_CLASSNAMES) 261 262$(APP3_JAR) : $(APP3_GEN_OUT)/$(APP3_NAME).mf $(APP3_CLASS_OUT)/$(APP3_NAME).class $(APP_CLASSFILES) 263 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 264 -$(MKDIR) $(subst /,$(PS),$(@D)) 265 +$(SDK_JAR) cvfm $@ $< -C $(APP3_CLASS_OUT) . 266 +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES) 267 +cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) uvf $(@F) $(APP_CLASSNAMES) 268 269$(SAMPLE_NAME) : $(COMP1_REGISTERFLAG) $(COMP2_REGISTERFLAG) $(APP1_JAR) $(APP2_JAR) $(APP3_JAR) 270 @echo -------------------------------------------------------------------------------- 271 @echo Please use one of the following commands to execute the examples! 272 @echo - 273 @echo $(MAKE) $(APP1_NAME).run 274 @echo $(MAKE) $(APP2_NAME).run 275 @echo $(MAKE) $(APP3_NAME).run 276 @echo -------- 277 @echo The "$(QM)$(COMP1_NAME)$(QM)" and "$(QM)$(COMP2_NAME)$(QM)" component are installed if 278 @echo SDK_AUTO_DEPLOYMENT = YES. You can use this components inside your office 279 @echo installation, see the example descriptions. You can also load the "$(QM)ExampleAddIn.ods$(QM)" 280 @echo document to see how the add-in functions can be used. For more details about the 281 @echo "$(QM)$(COMP2_NAME)$(QM)" component see the "$(QM)DataPilotReadme.txt"$(QM). 282 @echo - 283 @echo $(MAKE) ExampleAddIn.ods.load 284 @echo -------------------------------------------------------------------------------- 285 286%.run: $(SAMPLE_CLASS_OUT)/%.jar 287 $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< 288 289ExampleAddIn.ods.load : $(COMP1_REGISTERFLAG) 290 "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@) 291 292.PHONY: clean 293clean : 294 -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) 295 -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT)) 296 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP1_PACKAGE_URL))) 297 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP2_PACKAGE_URL))) 298