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 CreatingDialogs example 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
32EXAMPLE_NAME=BaDCreatingDialogsExample
33OUT_COMP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
34
35COMPONENT_NAME=SampleDialog
36COMPONENT_PACKAGE = $(OUT_BIN)/$(COMPONENT_NAME).$(UNOOXT_EXT)
37COMPONENT_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMPONENT_NAME).$(UNOOXT_EXT)")
38COMPONENT_JAR_NAME = $(COMPONENT_NAME).uno.jar
39COMPONENT_JAR = $(OUT_CLASS)/$(COMPONENT_JAR_NAME)
40COMPONENT_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMPONENT_NAME).uno.Manifest
41COMPONENT_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMPONENT_NAME)/META-INF/manifest.xml
42REGISTERFLAG = $(OUT_MISC)/devguide_basicanddialogs_creatingdialogs_register_component.flag
43
44# often the java files are structured in a hierarchy similar to the package,
45# for the example we know the package
46PACKAGE = com.sun.star.comp.sdk.examples
47
48JAVAFILES  = \
49	   SampleDialog.java
50
51CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(JAVAFILES))
52
53$(COMPONENT_NAME)_CLASSFILES = SampleDialog.class \
54
55SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
56		$(PATH_SEPARATOR)$(OUT_COMP_CLASS))
57
58
59# Targets
60.PHONY: ALL
61ALL: $(EXAMPLE_NAME)
62
63include $(SETTINGS)/stdtarget.mk
64
65$(OUT_COMP_CLASS)/%.Manifest :
66	-$(MKDIR) $(subst /,$(PS),$(@D))
67	@echo RegistrationClassName: $(PACKAGE).$(basename $(basename $(@F)))> $@
68
69$(OUT_COMP_CLASS)/%.class : %.java
70	-$(MKDIR) $(subst /,$(PS),$(@D))
71	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $<
72
73# rule for component jar file
74$(COMPONENT_JAR) : $(COMPONENT_MANIFESTFILE) $(CLASSFILES)
75	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
76	-$(MKDIR) $(subst /,$(PS),$(@D))
77	$(SDK_JAR) cvfm $@ $< -C $(OUT_COMP_CLASS) .
78
79# rule for component package manifest
80$(OUT_COMP_CLASS)/%/manifest.xml :
81	-$(MKDIR) $(subst /,$(PS),$(@D))
82	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
83	@echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
84	@echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
85	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-component;type=Java$(QM)" >> $@
86	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_CLASS)/,,$(@D))).uno.jar$(QM)"/$(CSEP) >> $@
87	@echo $(OSEP)/manifest:manifest$(CSEP) >> $@
88
89# rule for component package file
90$(COMPONENT_PACKAGE) : $(COMPONENT_JAR) $(COMPONENT_UNOPKG_MANIFEST)
91	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
92	-$(MKDIR) $(subst /,$(PS),$(@D))
93	cd $(subst /,$(PS),$(OUT_CLASS)) && $(SDK_ZIP) ../bin/$(@F) $(<F)
94	cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
95
96$(REGISTERFLAG) : $(COMPONENT_PACKAGE)
97ifneq "$(SDK_AUTO_DEPLOYMENT)" ""
98	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
99	-$(MKDIR) $(subst /,$(PS),$(@D))
100	$(DEPLOYTOOL) $(COMPONENT_PACKAGE_URL)
101	@echo flagged > $(subst /,$(PS),$@)
102else
103	@echo --------------------------------------------------------------------------------
104	@echo  If you want to install your component automatically, please set the environment
105	@echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
106	@echo  possible if no office instance is running.
107	@echo --------------------------------------------------------------------------------
108endif
109
110$(EXAMPLE_NAME) : $(REGISTERFLAG)
111	@echo --------------------------------------------------------------------------------
112	@echo The SampleDialog Java component was installed if SDK_AUTO_DEPLOYMENT = YES.
113	@echo Please load the "$(QM)CreatingDialogs.odt$(QM)" document to use the component or use it
114	@echo by yourself in your office installation, see the example description.
115	@echo -
116	@echo $(MAKE) CreatingDialogs.odt.load
117	@echo --------------------------------------------------------------------------------
118
119CreatingDialogs.odt.load : $(REGISTERFLAG)
120	"$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
121
122.PHONY: clean
123clean :
124	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
125	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMPONENT_PACKAGE_URL)))
126	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG)))
127