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