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 32 33COMP_NAME=JavaComponent 34OUT_COMP_CLASS = $(OUT_CLASS)/$(COMP_NAME) 35OUT_COMP_GEN = $(OUT_MISC)/$(COMP_NAME) 36COMP_RDB_NAME = $(COMP_NAME).uno.rdb 37COMP_RDB = $(OUT_COMP_GEN)/$(COMP_RDB_NAME) 38COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT) 39COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)") 40COMP_JAR_NAME = $(COMP_NAME).uno.jar 41COMP_JAR = $(OUT_COMP_CLASS)/$(COMP_JAR_NAME) 42COMP_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMP_NAME).uno.Manifest 43COMP_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP_NAME)/META-INF/manifest.xml 44COMP_COMPONENTS=$(COMP_NAME).components 45 46APP1_NAME=TestJavaComponent 47APP1_JAR=$(OUT_COMP_CLASS)/$(APP1_NAME).jar 48 49REGISTERFLAG = $(OUT_MISC)$(PS)devguide_$(COMP_NAME)_register_component.flag 50 51IDLFILES = XSomethingA.idl \ 52 XSomethingB.idl \ 53 SomethingA.idl \ 54 SomethingB.idl 55 56# normally the idl file should be stored in a directory tree fitting the module 57# structure, for the example we know the module structure 58PACKAGE = com/sun/star/test 59 60COMPJAVAFILES = \ 61 TestComponentA.java \ 62 TestComponentB.java \ 63 TestServiceProvider.java 64 65GENCLASSFILES = $(patsubst %.idl,$(OUT_COMP_CLASS)/$(PACKAGE)/%.class,$(IDLFILES)) 66GENCLASSNAMES = $(patsubst %.idl,$(PACKAGE)/%.class,$(IDLFILES)) 67GENTYPELIST = $(subst /,.,$(patsubst %.idl,-T$(PACKAGE)/% ,$(IDLFILES))) 68GENURDFILES = $(patsubst %.idl,$(OUT_COMP_GEN)/%.urd,$(IDLFILES)) 69 70COMPCLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(COMPJAVAFILES)) 71 72$(COMP_NAME)_CLASSFILES = $(patsubst %.java,%.class,$(COMPJAVAFILES)) 73 74$(COMP_NAME)_CLASSFILES += $(subst $(OUT_COMP_CLASS)/,,$(GENCLASSFILES)) 75 76SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\ 77 $(PATH_SEPARATOR)$(OUT_COMP_CLASS)) 78 79 80# Targets 81.PHONY: ALL 82ALL : \ 83 JavaComponentExample 84 85include $(SETTINGS)/stdtarget.mk 86 87$(OUT_COMP_CLASS)/%.Manifest : 88 -$(MKDIR) $(subst /,$(PS),$(@D)) 89 @echo UNO-Type-Path: $(basename $(notdir $*)).uno.jar> $@ 90 @echo RegistrationClassName: TestServiceProvider>> $@ 91 92$(OUT_COMP_GEN)/%.urd : %.idl 93 -$(MKDIR) $(subst /,$(PS),$(@D)) 94 $(IDLC) -I. -I$(IDL_DIR) -O$(OUT_COMP_GEN) $^ 95 96$(OUT_COMP_GEN)/%.rdb : $(GENURDFILES) 97 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 98 -$(MKDIR) $(subst /,$(PS),$(@D)) 99 $(REGMERGE) $@ /UCR $(GENURDFILES) 100 101$(OUT_COMP_CLASS)/$(PACKAGE)/%.class : $(COMP_RDB) 102 -$(MKDIR) $(subst /,$(PS),$(@D)) 103 $(JAVAMAKER) -BUCR -nD $(GENTYPELIST) -O$(OUT_COMP_CLASS) $(COMP_RDB) -X$(URE_TYPES) -X$(OFFICE_TYPES) 104 105$(OUT_COMP_CLASS)/%.class : %.java $(GENCLASSFILES) 106 -$(MKDIR) $(subst /,$(PS),$(@D)) 107 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $< 108 109$(COMPCLASSFILES) : $(COMPJAVAFILES) $(GENCLASSFILES) 110 -$(MKDIR) $(subst /,$(PS),$(@D)) 111 $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(COMPJAVAFILES) 112 113# rule for client/example application manifest file 114$(OUT_COMP_CLASS)/%.mf : 115 -$(MKDIR) $(subst /,$(PS),$(@D)) 116 @echo Main-Class: com.sun.star.lib.loader.Loader> $@ 117 $(ECHOLINE)>> $@ 118 @echo Name: com/sun/star/lib/loader/Loader.class>> $@ 119 @echo Application-Class: $*>> $@ 120 121# rule for client/example application jar file 122# Note that the example needs the component files as well for local usage 123$(APP1_JAR) : $(OUT_COMP_CLASS)/$(APP1_NAME).mf $(OUT_COMP_CLASS)/$(APP1_NAME).class $(COMPCLASSFILES) $(GENCLASSFILES) 124 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 125 -$(MKDIR) $(subst /,$(PS),$(@D)) 126 +cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(basename $(@F)).class $($(COMP_NAME)_CLASSFILES) 127 +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES) 128 129# rule for component jar file 130$(COMP_JAR) : $(COMP_MANIFESTFILE) $(COMPCLASSFILES) 131 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 132 -$(MKDIR) $(subst /,$(PS),$(@D)) 133 cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES) 134 135# rule for component package manifest 136$(OUT_COMP_CLASS)/%/manifest.xml : 137 -$(MKDIR) $(subst /,$(PS),$(@D)) 138 @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@ 139 @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@ 140 @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@ 141 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@ 142 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_CLASS)/,,$(@D))).uno.rdb$(QM)"/$(CSEP) >> $@ 143 @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@ 144 @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_COMPONENTS)$(QM)"/$(CSEP)>> $@ 145 @echo $(OSEP)/manifest:manifest$(CSEP) >> $@ 146 147# rule for component pacakge file 148$(COMP_PACKAGE) : $(COMP_RDB) $(COMP_JAR) $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS) 149 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 150 -$(MKDIR) $(subst /,$(PS),$(@D)) 151 $(COPY) $(subst /,$(PS),$(COMP_RDB)) $(subst /,$(PS),$(OUT_COMP_CLASS)) 152 $(SDK_ZIP) $@ $(COMP_COMPONENTS) 153 cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_RDB_NAME) $(COMP_JAR_NAME) 154 cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml 155 $(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_COMP_CLASS)/$(COMP_RDB_NAME))) 156 157$(REGISTERFLAG) : $(COMP_PACKAGE) 158ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES" 159 -$(DEL) $(subst \\,\,$(subst /,$(PS),$@)) 160 -$(MKDIR) $(subst /,$(PS),$(@D)) 161 $(DEPLOYTOOL) $(COMP_PACKAGE_URL) 162 @echo flagged > $(subst /,$(PS),$@) 163else 164 @echo -------------------------------------------------------------------------------- 165 @echo If you want to install your component automatically, please set the environment 166 @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only 167 @echo possible if no office instance is running. 168 @echo -------------------------------------------------------------------------------- 169endif 170 171JavaComponentExample : $(REGISTERFLAG) $(APP1_JAR) 172 @echo -------------------------------------------------------------------------------- 173 @echo Please use one of the following commands to execute the examples! 174 @echo - 175 @echo $(MAKE) $(APP1_NAME).run 176 @echo $(MAKE) $(APP1_NAME).local 177 @echo -------- 178 @echo The Java components were installed if SDK_AUTO_DEPLOYMENT = YES. 179 @echo You can use this component inside your office installation, see the 180 @echo example description. 181 @echo -------------------------------------------------------------------------------- 182 183%.run: $(OUT_COMP_CLASS)/%.jar 184 $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< 185 186%.local: $(OUT_COMP_CLASS)/%.jar 187 $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< local 188 189.PHONY: clean 190clean : 191 -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS)) 192 -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN)) 193 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL))) 194 -$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG))) 195