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 OfficeDevLinguistic examples 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 66EXAMPLE_NAME=OfficeDevLinguisticExample 67OUT_COMP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME) 68 69COMP1_NAME=SampleHyphenator 70COMP1_PACKAGE = $(OUT_BIN)/$(COMP1_NAME).$(UNOOXT_EXT) 71COMP1_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP1_NAME).$(UNOOXT_EXT)") 72COMP1_JAR_NAME = $(COMP1_NAME).uno.jar 73COMP1_JAR = $(OUT_COMP_CLASS)/$(COMP1_JAR_NAME) 74COMP1_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMP1_NAME).uno.Manifest 75COMP1_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP1_NAME)/META-INF/manifest.xml 76COMP1_COMPONENTS=$(COMP1_NAME).components 77 78COMP2_NAME=SampleSpellChecker 79COMP2_PACKAGE = $(OUT_BIN)/$(COMP2_NAME).$(UNOOXT_EXT) 80COMP2_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP2_NAME).$(UNOOXT_EXT)") 81COMP2_JAR_NAME = $(COMP2_NAME).uno.jar 82COMP2_JAR = $(OUT_COMP_CLASS)/$(COMP2_JAR_NAME) 83COMP2_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMP2_NAME).uno.Manifest 84COMP2_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP2_NAME)/META-INF/manifest.xml 85COMP2_COMPONENTS=$(COMP2_NAME).components 86 87COMP3_NAME=SampleThesaurus 88COMP3_PACKAGE = $(OUT_BIN)/$(COMP3_NAME).$(UNOOXT_EXT) 89COMP3_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP3_NAME).$(UNOOXT_EXT)") 90COMP3_JAR_NAME = $(COMP3_NAME).uno.jar 91COMP3_JAR = $(OUT_COMP_CLASS)/$(COMP3_JAR_NAME) 92COMP3_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMP3_NAME).uno.Manifest 93COMP3_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP3_NAME)/META-INF/manifest.xml 94COMP3_COMPONENTS=$(COMP2_NAME).components 95 96APP1_NAME=LinguisticExamples 97APP1_JAR=$(OUT_COMP_CLASS)/$(APP1_NAME).jar 98 99REGISTERFLAG = $(OUT_MISC)/devguide_officedevlinguistic_register_component.flag 100 101JAVAFILES = \ 102 OneInstanceFactory.java \ 103 PropChgHelper.java \ 104 PropChgHelper_Hyph.java \ 105 PropChgHelper_Spell.java \ 106 XHyphenatedWord_impl.java \ 107 XMeaning_impl.java \ 108 XPossibleHyphens_impl.java \ 109 XSpellAlternatives_impl.java \ 110 SampleHyphenator.java \ 111 SampleSpellChecker.java \ 112 SampleThesaurus.java 113 114CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(JAVAFILES)) 115 116$(COMP1_NAME)_CLASSFILES = XHyphenatedWord_impl.class \ 117 XPossibleHyphens_impl.class \ 118 PropChgHelper.class \ 119 PropChgHelper_Hyph.class \ 120 OneInstanceFactory.class \ 121 $(COMP1_NAME).class 122 123$(COMP2_NAME)_CLASSFILES = XSpellAlternatives_impl.class \ 124 PropChgHelper_Spell.class \ 125 PropChgHelper.class \ 126 OneInstanceFactory.class \ 127 $(COMP2_NAME).class 128 129$(COMP3_NAME)_CLASSFILES = XMeaning_impl.class \ 130 OneInstanceFactory.class \ 131 $(COMP3_NAME).class 132 133SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\ 134 $(PATH_SEPARATOR)$(OUT_COMP_CLASS)) 135 136.PHONY: ALL 137ALL : $(EXAMPLE_NAME) 138 139include $(SETTINGS)/stdtarget.mk 140 141$(OUT_COMP_CLASS)/%.Manifest : 142 -$(MKDIR) $(subst /,$(PS),$(@D)) 143 @echo RegistrationClassName: $(basename $(basename $(@F)))> $@ 144 145$(CLASSFILES) : $(JAVAFILES) 146 -$(MKDIR) $(subst /,$(PS),$(@D)) 147 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(JAVAFILES) 148 149# NOTE: because of gnu make problems with full qualified paths, the pattern 150# rules for the component jars and the packages doesn't work proper and we 151# defined explicit rules 152 153# rule for component package manifest 154$(OUT_COMP_CLASS)/%/manifest.xml : 155 -$(MKDIR) $(subst /,$(PS),$(@D)) 156 @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@ 157 @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@ 158 @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@ 159 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)" >> $@ 160 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_CLASS)/,,$(@D))).components$(QM)"/$(CSEP) >> $@ 161 @echo $(OSEP)/manifest:manifest$(CSEP) >> $@ 162 163$(COMP1_JAR) : $(COMP1_MANIFESTFILE) $(CLASSFILES) 164 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 165 -$(MKDIR) $(subst /,$(PS),$(@D)) 166 cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES) 167 168$(COMP1_PACKAGE) : $(COMP1_JAR) $(COMP1_UNOPKG_MANIFEST) $(COMP1_COMPONENTS) 169 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 170 -$(MKDIR) $(subst /,$(PS),$(@D)) 171 $(SDK_ZIP) $@ $(COMP1_COMPONENTS) 172 cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(<F) 173 cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml 174 175$(COMP2_JAR) : $(COMP2_MANIFESTFILE) $(CLASSFILES) 176 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 177 -$(MKDIR) $(subst /,$(PS),$(@D)) 178 cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES) 179 180$(COMP2_PACKAGE) : $(COMP2_JAR) $(COMP2_UNOPKG_MANIFEST) $(COMP2_COMPONENTS) 181 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 182 -$(MKDIR) $(subst /,$(PS),$(@D)) 183 $(SDK_ZIP) $@ $(COMP2_COMPONENTS) 184 cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(<F) 185 cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml 186 187$(COMP3_JAR) : $(COMP3_MANIFESTFILE) $(CLASSFILES) 188 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 189 -$(MKDIR) $(subst /,$(PS),$(@D)) 190 cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES) 191 192$(COMP3_PACKAGE) : $(COMP3_JAR) $(COMP3_UNOPKG_MANIFEST) $(COMP3_COMPONENTS) 193 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 194 -$(MKDIR) $(subst /,$(PS),$(@D)) 195 $(SDK_ZIP) $@ $(COMP3_COMPONENTS) 196 cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(<F) 197 cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml 198 199$(REGISTERFLAG) : $(COMP1_PACKAGE) $(COMP2_PACKAGE) $(COMP3_PACKAGE) 200ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES" 201 -$(MKDIR) $(subst /,$(PS),$(@D)) 202 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 203 $(DEPLOYTOOL) $(COMP1_PACKAGE_URL) 204 $(DEPLOYTOOL) $(COMP2_PACKAGE_URL) 205 $(DEPLOYTOOL) $(COMP3_PACKAGE_URL) 206 @echo flagged > $(subst /,$(PS),$@) 207else 208 @echo -------------------------------------------------------------------------------- 209 @echo If you want to install your component automatically, please set the environment 210 @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only 211 @echo possible if no office instance is running. 212 @echo -------------------------------------------------------------------------------- 213endif 214 215$(OUT_COMP_CLASS)/%.class : %.java 216 -$(MKDIR) $(subst /,$(PS),$(@D)) 217 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $< 218 219$(OUT_COMP_CLASS)/%.mf : 220 -$(MKDIR) $(subst /,$(PS),$(@D)) 221 @echo Main-Class: com.sun.star.lib.loader.Loader> $@ 222 $(ECHOLINE)>> $@ 223 @echo Name: com/sun/star/lib/loader/Loader.class>> $@ 224 @echo Application-Class: $*>> $@ 225 226$(APP1_JAR) : $(OUT_COMP_CLASS)/$(APP1_NAME).mf $(OUT_COMP_CLASS)/$(APP1_NAME).class 227 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 228 -$(MKDIR) $(subst /,$(PS),$(@D)) 229 +cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(basename $(@F)).class $(basename $(@F))$(QUOTE)$$Client.class 230 +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES) 231 232 233$(EXAMPLE_NAME) : $(REGISTERFLAG) $(APP1_JAR) 234 @echo -------------------------------------------------------------------------------- 235 @echo Please use the following command to execute the example! 236 @echo - 237 @echo $(MAKE) $(APP1_NAME).run 238 @echo -------- 239 @echo Before you can run the examples the components "$(QM)$(COMP1_NAME)$(QM)", 240 @echo "$(QM)$(COMP2_NAME)$(QM)" and "$(QM)$(COMP3_NAME)$(QM)" must be deployed. 241 @echo The components will be automatically deployed if SDK_AUTO_DEPLOYMENT = YES. 242 @echo -------------------------------------------------------------------------------- 243 244%.run: $(OUT_COMP_CLASS)/%.jar 245 $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< 246 247.PHONY: clean 248clean : 249 -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS)) 250 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP1_PACKAGE_URL))) 251 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP2_PACKAGE_URL))) 252 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP3_PACKAGE_URL))) 253 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG))) 254