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