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 ProtoclHandlerAddon Java component example of the SDK.
23 
24 PRJ=../../../../..
25 SETTINGS=$(PRJ)/settings
26 
27 include $(SETTINGS)/settings.mk
28 include $(SETTINGS)/std.mk
29 include $(SETTINGS)/dk.mk
30 
31 # Define non-platform/compiler specific settings
32 COMP_NAME=ProtocolHandlerAddon_java
33 OUT_COMP_CLASS=$(OUT_CLASS)/$(COMP_NAME)
34 OUT_COMP_MISC=$(OUT_MISC)/$(COMP_NAME)
35 COMP_PACKAGE=$(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
36 COMP_PACKAGE_URL=$(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
37 COMP_JAR_NAME=$(COMP_NAME).uno.jar
38 COMP_JAR=$(OUT_CLASS)/$(COMP_JAR_NAME)
39 COMP_MANIFESTFILE=$(OUT_COMP_CLASS)/$(COMP_NAME).uno.Manifest
40 COMP_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP_NAME)/META-INF/manifest.xml
41 COMP_COMPONENTS=$(COMP_NAME).components
42 
43 REGISTERFLAG=$(OUT_COMP_MISC)$(PS)java_$(COMP_NAME)_register_component.flag
44 
45 JAVAFILES  = ProtocolHandlerAddon.java
46 
47 CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(JAVAFILES))
48 
49 SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
50 		$(PATH_SEPARATOR)$(OUT_COMP_CLASS))
51 
52 
53 # Targets
54 .PHONY: ALL
55 ALL : DevGuideProtocolHandlerAddon
56 
57 include $(SETTINGS)/stdtarget.mk
58 
59 $(OUT_COMP_CLASS)/%.Manifest :
60 	-$(MKDIR) $(subst /,$(PS),$(@D))
61 	@echo RegistrationClassName: ProtocolHandlerAddon> $@
62 
63 $(CLASSFILES) : $(JAVAFILES)
64 	-$(MKDIR) $(subst /,$(PS),$(@D))
65 	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(JAVAFILES)
66 
67 # rule for component jar file
68 $(COMP_JAR) : $(COMP_MANIFESTFILE) $(CLASSFILES)
69 	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
70 	-$(MKDIR) $(subst /,$(PS),$(@D))
71 	$(SDK_JAR) cvfm $@ $< -C $(OUT_COMP_CLASS) .
72 
73 # rule for component package manifest
74 $(OUT_COMP_CLASS)/%/manifest.xml :
75 	-$(MKDIR) $(subst /,$(PS),$(@D))
76 	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
77 	@echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
78 	@echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
79 	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
80 	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)Addons.xcu$(QM)"/$(CSEP) >> $@
81 	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
82 	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)ProtocolHandler.xcu$(QM)"/$(CSEP) >> $@
83 	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
84 	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(COMP_COMPONENTS)$(QM)"/$(CSEP)>> $@
85 	@echo $(OSEP)/manifest:manifest$(CSEP) >> $@
86 
87 # rule for component package file
88 $(COMP_PACKAGE) : $(COMP_JAR) Addons.xcu ProtocolHandler.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
89 	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
90 	-$(MKDIR) $(subst /,$(PS),$(@D))
91 	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_MISC))
92 	$(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_MISC))
93 	cd $(subst /,$(PS),$(OUT_COMP_MISC)) && $(SDK_ZIP) ../../bin/$(@F) $(<F)
94 	$(SDK_ZIP) -u $@ Addons.xcu ProtocolHandler.xcu $(COMP_COMPONENTS)
95 	cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
96 
97 $(REGISTERFLAG) : $(COMP_PACKAGE)
98 ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
99 	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
100 	-$(MKDIR) $(subst /,$(PS),$(@D))
101 	$(DEPLOYTOOL) $(COMP_PACKAGE_URL)
102 	@echo flagged > $(subst /,$(PS),$@)
103 else
104 	@echo --------------------------------------------------------------------------------
105 	@echo  If you want to install your component automatically, please set the environment
106 	@echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
107 	@echo  possible if no office instance is running.
108 	@echo --------------------------------------------------------------------------------
109 endif
110 
111 DevGuideProtocolHandlerAddon : $(REGISTERFLAG)
112 	@echo --------------------------------------------------------------------------------
113 	@echo The "$(QM)ProtocolHandler$(QM)" addon component was installed if SDK_AUTO_DEPLOYMENT = YES.
114 	@echo You can use this component inside your office installation, see the example
115 	@echo description.
116 	@echo --------------------------------------------------------------------------------
117 
118 %.run: $(OUT_COMP_CLASS)/%.class
119 	$SDJ_JAVA) -classpath "$(SDK_CLASSPATH)" $(basename $@)
120 
121 .PHONY: clean
122 clean :
123 	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
124 	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_MISC))
125 	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
126 	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_JAR)))
127