1*b1cdbd2cSJim Jagielski#**************************************************************
2*b1cdbd2cSJim Jagielski#
3*b1cdbd2cSJim Jagielski#  Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski#  or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski#  distributed with this work for additional information
6*b1cdbd2cSJim Jagielski#  regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski#  to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski#  "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski#  with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski#
11*b1cdbd2cSJim Jagielski#    http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski#
13*b1cdbd2cSJim Jagielski#  Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski#  software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski#  KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski#  specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski#  under the License.
19*b1cdbd2cSJim Jagielski#
20*b1cdbd2cSJim Jagielski#**************************************************************
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski# Builds the CreatingDialogs example of the Developers Guide.
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim JagielskiPRJ=../../../..
25*b1cdbd2cSJim JagielskiSETTINGS=$(PRJ)/settings
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/settings.mk
28*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/std.mk
29*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/dk.mk
30*b1cdbd2cSJim Jagielski
31*b1cdbd2cSJim Jagielski# Define non-platform/compiler specific settings
32*b1cdbd2cSJim JagielskiEXAMPLE_NAME=BaDCreatingDialogsExample
33*b1cdbd2cSJim JagielskiOUT_COMP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
34*b1cdbd2cSJim Jagielski
35*b1cdbd2cSJim JagielskiCOMPONENT_NAME=SampleDialog
36*b1cdbd2cSJim JagielskiCOMPONENT_PACKAGE = $(OUT_BIN)/$(COMPONENT_NAME).$(UNOOXT_EXT)
37*b1cdbd2cSJim JagielskiCOMPONENT_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMPONENT_NAME).$(UNOOXT_EXT)")
38*b1cdbd2cSJim JagielskiCOMPONENT_JAR_NAME = $(COMPONENT_NAME).uno.jar
39*b1cdbd2cSJim JagielskiCOMPONENT_JAR = $(OUT_CLASS)/$(COMPONENT_JAR_NAME)
40*b1cdbd2cSJim JagielskiCOMPONENT_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMPONENT_NAME).uno.Manifest
41*b1cdbd2cSJim JagielskiCOMPONENT_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMPONENT_NAME)/META-INF/manifest.xml
42*b1cdbd2cSJim JagielskiREGISTERFLAG = $(OUT_MISC)/devguide_basicanddialogs_creatingdialogs_register_component.flag
43*b1cdbd2cSJim Jagielski
44*b1cdbd2cSJim Jagielski# often the java files are structured in a hierarchy similar to the package,
45*b1cdbd2cSJim Jagielski# for the example we know the package
46*b1cdbd2cSJim JagielskiPACKAGE = com.sun.star.comp.sdk.examples
47*b1cdbd2cSJim Jagielski
48*b1cdbd2cSJim JagielskiJAVAFILES  = \
49*b1cdbd2cSJim Jagielski	   SampleDialog.java
50*b1cdbd2cSJim Jagielski
51*b1cdbd2cSJim JagielskiCLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(JAVAFILES))
52*b1cdbd2cSJim Jagielski
53*b1cdbd2cSJim Jagielski$(COMPONENT_NAME)_CLASSFILES = SampleDialog.class \
54*b1cdbd2cSJim Jagielski
55*b1cdbd2cSJim JagielskiSDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
56*b1cdbd2cSJim Jagielski		$(PATH_SEPARATOR)$(OUT_COMP_CLASS))
57*b1cdbd2cSJim Jagielski
58*b1cdbd2cSJim Jagielski
59*b1cdbd2cSJim Jagielski# Targets
60*b1cdbd2cSJim Jagielski.PHONY: ALL
61*b1cdbd2cSJim JagielskiALL: $(EXAMPLE_NAME)
62*b1cdbd2cSJim Jagielski
63*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/stdtarget.mk
64*b1cdbd2cSJim Jagielski
65*b1cdbd2cSJim Jagielski$(OUT_COMP_CLASS)/%.Manifest :
66*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
67*b1cdbd2cSJim Jagielski	@echo RegistrationClassName: $(PACKAGE).$(basename $(basename $(@F)))> $@
68*b1cdbd2cSJim Jagielski
69*b1cdbd2cSJim Jagielski$(OUT_COMP_CLASS)/%.class : %.java
70*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
71*b1cdbd2cSJim Jagielski	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $<
72*b1cdbd2cSJim Jagielski
73*b1cdbd2cSJim Jagielski# rule for component jar file
74*b1cdbd2cSJim Jagielski$(COMPONENT_JAR) : $(COMPONENT_MANIFESTFILE) $(CLASSFILES)
75*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
76*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
77*b1cdbd2cSJim Jagielski	$(SDK_JAR) cvfm $@ $< -C $(OUT_COMP_CLASS) .
78*b1cdbd2cSJim Jagielski
79*b1cdbd2cSJim Jagielski# rule for component package manifest
80*b1cdbd2cSJim Jagielski$(OUT_COMP_CLASS)/%/manifest.xml :
81*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
82*b1cdbd2cSJim Jagielski	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
83*b1cdbd2cSJim Jagielski	@echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
84*b1cdbd2cSJim Jagielski	@echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
85*b1cdbd2cSJim Jagielski	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-component;type=Java$(QM)" >> $@
86*b1cdbd2cSJim Jagielski	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_CLASS)/,,$(@D))).uno.jar$(QM)"/$(CSEP) >> $@
87*b1cdbd2cSJim Jagielski	@echo $(OSEP)/manifest:manifest$(CSEP) >> $@
88*b1cdbd2cSJim Jagielski
89*b1cdbd2cSJim Jagielski# rule for component package file
90*b1cdbd2cSJim Jagielski$(COMPONENT_PACKAGE) : $(COMPONENT_JAR) $(COMPONENT_UNOPKG_MANIFEST)
91*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
92*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
93*b1cdbd2cSJim Jagielski	cd $(subst /,$(PS),$(OUT_CLASS)) && $(SDK_ZIP) ../bin/$(@F) $(<F)
94*b1cdbd2cSJim Jagielski	cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
95*b1cdbd2cSJim Jagielski
96*b1cdbd2cSJim Jagielski$(REGISTERFLAG) : $(COMPONENT_PACKAGE)
97*b1cdbd2cSJim Jagielskiifneq "$(SDK_AUTO_DEPLOYMENT)" ""
98*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
99*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
100*b1cdbd2cSJim Jagielski	$(DEPLOYTOOL) $(COMPONENT_PACKAGE_URL)
101*b1cdbd2cSJim Jagielski	@echo flagged > $(subst /,$(PS),$@)
102*b1cdbd2cSJim Jagielskielse
103*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
104*b1cdbd2cSJim Jagielski	@echo  If you want to install your component automatically, please set the environment
105*b1cdbd2cSJim Jagielski	@echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
106*b1cdbd2cSJim Jagielski	@echo  possible if no office instance is running.
107*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
108*b1cdbd2cSJim Jagielskiendif
109*b1cdbd2cSJim Jagielski
110*b1cdbd2cSJim Jagielski$(EXAMPLE_NAME) : $(REGISTERFLAG)
111*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
112*b1cdbd2cSJim Jagielski	@echo The SampleDialog Java component was installed if SDK_AUTO_DEPLOYMENT = YES.
113*b1cdbd2cSJim Jagielski	@echo Please load the "$(QM)CreatingDialogs.odt$(QM)" document to use the component or use it
114*b1cdbd2cSJim Jagielski	@echo by yourself in your office installation, see the example description.
115*b1cdbd2cSJim Jagielski	@echo -
116*b1cdbd2cSJim Jagielski	@echo $(MAKE) CreatingDialogs.odt.load
117*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
118*b1cdbd2cSJim Jagielski
119*b1cdbd2cSJim JagielskiCreatingDialogs.odt.load : $(REGISTERFLAG)
120*b1cdbd2cSJim Jagielski	"$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
121*b1cdbd2cSJim Jagielski
122*b1cdbd2cSJim Jagielski.PHONY: clean
123*b1cdbd2cSJim Jagielskiclean :
124*b1cdbd2cSJim Jagielski	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
125*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMPONENT_PACKAGE_URL)))
126*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG)))
127