1*cdf0e10cSrcweir#*************************************************************************
2*cdf0e10cSrcweir#
3*cdf0e10cSrcweir#  The Contents of this file are made available subject to the terms of
4*cdf0e10cSrcweir#  the BSD license.
5*cdf0e10cSrcweir#
6*cdf0e10cSrcweir#  Copyright 2000, 2010 Oracle and/or its affiliates.
7*cdf0e10cSrcweir#  All rights reserved.
8*cdf0e10cSrcweir#
9*cdf0e10cSrcweir#  Redistribution and use in source and binary forms, with or without
10*cdf0e10cSrcweir#  modification, are permitted provided that the following conditions
11*cdf0e10cSrcweir#  are met:
12*cdf0e10cSrcweir#  1. Redistributions of source code must retain the above copyright
13*cdf0e10cSrcweir#     notice, this list of conditions and the following disclaimer.
14*cdf0e10cSrcweir#  2. Redistributions in binary form must reproduce the above copyright
15*cdf0e10cSrcweir#     notice, this list of conditions and the following disclaimer in the
16*cdf0e10cSrcweir#     documentation and/or other materials provided with the distribution.
17*cdf0e10cSrcweir#  3. Neither the name of Sun Microsystems, Inc. nor the names of its
18*cdf0e10cSrcweir#     contributors may be used to endorse or promote products derived
19*cdf0e10cSrcweir#     from this software without specific prior written permission.
20*cdf0e10cSrcweir#
21*cdf0e10cSrcweir#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22*cdf0e10cSrcweir#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23*cdf0e10cSrcweir#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24*cdf0e10cSrcweir#  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25*cdf0e10cSrcweir#  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26*cdf0e10cSrcweir#  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27*cdf0e10cSrcweir#  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28*cdf0e10cSrcweir#  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29*cdf0e10cSrcweir#  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30*cdf0e10cSrcweir#  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
31*cdf0e10cSrcweir#  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32*cdf0e10cSrcweir#
33*cdf0e10cSrcweir#**************************************************************************
34*cdf0e10cSrcweir
35*cdf0e10cSrcweir# Builds the OfficeDevLinguistic examples of the Developers Guide.
36*cdf0e10cSrcweir
37*cdf0e10cSrcweirPRJ=../../../..
38*cdf0e10cSrcweirSETTINGS=$(PRJ)/settings
39*cdf0e10cSrcweir
40*cdf0e10cSrcweirinclude $(SETTINGS)/settings.mk
41*cdf0e10cSrcweirinclude $(SETTINGS)/std.mk
42*cdf0e10cSrcweirinclude $(SETTINGS)/dk.mk
43*cdf0e10cSrcweir
44*cdf0e10cSrcweir# Define non-platform/compiler specific settings
45*cdf0e10cSrcweirEXAMPLE_NAME=OfficeDevLinguisticExample
46*cdf0e10cSrcweirOUT_COMP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
47*cdf0e10cSrcweir
48*cdf0e10cSrcweirCOMP1_NAME=SampleHyphenator
49*cdf0e10cSrcweirCOMP1_PACKAGE = $(OUT_BIN)/$(COMP1_NAME).$(UNOOXT_EXT)
50*cdf0e10cSrcweirCOMP1_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP1_NAME).$(UNOOXT_EXT)")
51*cdf0e10cSrcweirCOMP1_JAR_NAME = $(COMP1_NAME).uno.jar
52*cdf0e10cSrcweirCOMP1_JAR = $(OUT_COMP_CLASS)/$(COMP1_JAR_NAME)
53*cdf0e10cSrcweirCOMP1_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMP1_NAME).uno.Manifest
54*cdf0e10cSrcweirCOMP1_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP1_NAME)/META-INF/manifest.xml
55*cdf0e10cSrcweirCOMP1_COMPONENTS=$(COMP1_NAME).components
56*cdf0e10cSrcweir
57*cdf0e10cSrcweirCOMP2_NAME=SampleSpellChecker
58*cdf0e10cSrcweirCOMP2_PACKAGE = $(OUT_BIN)/$(COMP2_NAME).$(UNOOXT_EXT)
59*cdf0e10cSrcweirCOMP2_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP2_NAME).$(UNOOXT_EXT)")
60*cdf0e10cSrcweirCOMP2_JAR_NAME = $(COMP2_NAME).uno.jar
61*cdf0e10cSrcweirCOMP2_JAR = $(OUT_COMP_CLASS)/$(COMP2_JAR_NAME)
62*cdf0e10cSrcweirCOMP2_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMP2_NAME).uno.Manifest
63*cdf0e10cSrcweirCOMP2_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP2_NAME)/META-INF/manifest.xml
64*cdf0e10cSrcweirCOMP2_COMPONENTS=$(COMP2_NAME).components
65*cdf0e10cSrcweir
66*cdf0e10cSrcweirCOMP3_NAME=SampleThesaurus
67*cdf0e10cSrcweirCOMP3_PACKAGE = $(OUT_BIN)/$(COMP3_NAME).$(UNOOXT_EXT)
68*cdf0e10cSrcweirCOMP3_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP3_NAME).$(UNOOXT_EXT)")
69*cdf0e10cSrcweirCOMP3_JAR_NAME = $(COMP3_NAME).uno.jar
70*cdf0e10cSrcweirCOMP3_JAR = $(OUT_COMP_CLASS)/$(COMP3_JAR_NAME)
71*cdf0e10cSrcweirCOMP3_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMP3_NAME).uno.Manifest
72*cdf0e10cSrcweirCOMP3_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP3_NAME)/META-INF/manifest.xml
73*cdf0e10cSrcweirCOMP3_COMPONENTS=$(COMP2_NAME).components
74*cdf0e10cSrcweir
75*cdf0e10cSrcweirAPP1_NAME=LinguisticExamples
76*cdf0e10cSrcweirAPP1_JAR=$(OUT_COMP_CLASS)/$(APP1_NAME).jar
77*cdf0e10cSrcweir
78*cdf0e10cSrcweirREGISTERFLAG = $(OUT_MISC)/devguide_officedevlinguistic_register_component.flag
79*cdf0e10cSrcweir
80*cdf0e10cSrcweirJAVAFILES  = \
81*cdf0e10cSrcweir	OneInstanceFactory.java \
82*cdf0e10cSrcweir	PropChgHelper.java \
83*cdf0e10cSrcweir	PropChgHelper_Hyph.java \
84*cdf0e10cSrcweir	PropChgHelper_Spell.java \
85*cdf0e10cSrcweir	XHyphenatedWord_impl.java \
86*cdf0e10cSrcweir	XMeaning_impl.java \
87*cdf0e10cSrcweir	XPossibleHyphens_impl.java \
88*cdf0e10cSrcweir	XSpellAlternatives_impl.java \
89*cdf0e10cSrcweir	SampleHyphenator.java \
90*cdf0e10cSrcweir	SampleSpellChecker.java \
91*cdf0e10cSrcweir	SampleThesaurus.java
92*cdf0e10cSrcweir
93*cdf0e10cSrcweirCLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(JAVAFILES))
94*cdf0e10cSrcweir
95*cdf0e10cSrcweir$(COMP1_NAME)_CLASSFILES = XHyphenatedWord_impl.class \
96*cdf0e10cSrcweir	XPossibleHyphens_impl.class \
97*cdf0e10cSrcweir	PropChgHelper.class \
98*cdf0e10cSrcweir	PropChgHelper_Hyph.class \
99*cdf0e10cSrcweir	OneInstanceFactory.class \
100*cdf0e10cSrcweir	$(COMP1_NAME).class
101*cdf0e10cSrcweir
102*cdf0e10cSrcweir$(COMP2_NAME)_CLASSFILES = XSpellAlternatives_impl.class \
103*cdf0e10cSrcweir	PropChgHelper_Spell.class \
104*cdf0e10cSrcweir	PropChgHelper.class \
105*cdf0e10cSrcweir	OneInstanceFactory.class \
106*cdf0e10cSrcweir	$(COMP2_NAME).class
107*cdf0e10cSrcweir
108*cdf0e10cSrcweir$(COMP3_NAME)_CLASSFILES = XMeaning_impl.class \
109*cdf0e10cSrcweir	OneInstanceFactory.class \
110*cdf0e10cSrcweir	$(COMP3_NAME).class
111*cdf0e10cSrcweir
112*cdf0e10cSrcweirSDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
113*cdf0e10cSrcweir		$(PATH_SEPARATOR)$(OUT_COMP_CLASS))
114*cdf0e10cSrcweir
115*cdf0e10cSrcweir.PHONY: ALL
116*cdf0e10cSrcweirALL : $(EXAMPLE_NAME)
117*cdf0e10cSrcweir
118*cdf0e10cSrcweirinclude $(SETTINGS)/stdtarget.mk
119*cdf0e10cSrcweir
120*cdf0e10cSrcweir$(OUT_COMP_CLASS)/%.Manifest :
121*cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
122*cdf0e10cSrcweir	@echo RegistrationClassName: $(basename $(basename $(@F)))> $@
123*cdf0e10cSrcweir
124*cdf0e10cSrcweir$(CLASSFILES) : $(JAVAFILES)
125*cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
126*cdf0e10cSrcweir	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(JAVAFILES)
127*cdf0e10cSrcweir
128*cdf0e10cSrcweir# NOTE: because of gnu make problems with full qualified paths, the pattern
129*cdf0e10cSrcweir# rules for the component jars and the packages doesn't work proper and we
130*cdf0e10cSrcweir# defined explicit rules
131*cdf0e10cSrcweir
132*cdf0e10cSrcweir# rule for component package manifest
133*cdf0e10cSrcweir$(OUT_COMP_CLASS)/%/manifest.xml :
134*cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
135*cdf0e10cSrcweir	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
136*cdf0e10cSrcweir	@echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
137*cdf0e10cSrcweir	@echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
138*cdf0e10cSrcweir	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)" >> $@
139*cdf0e10cSrcweir	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_CLASS)/,,$(@D))).components$(QM)"/$(CSEP) >> $@
140*cdf0e10cSrcweir	@echo $(OSEP)/manifest:manifest$(CSEP) >> $@
141*cdf0e10cSrcweir
142*cdf0e10cSrcweir$(COMP1_JAR) : $(COMP1_MANIFESTFILE) $(CLASSFILES)
143*cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
144*cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
145*cdf0e10cSrcweir	cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
146*cdf0e10cSrcweir
147*cdf0e10cSrcweir$(COMP1_PACKAGE) : $(COMP1_JAR) $(COMP1_UNOPKG_MANIFEST) $(COMP1_COMPONENTS)
148*cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
149*cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
150*cdf0e10cSrcweir	$(SDK_ZIP) $@ $(COMP1_COMPONENTS)
151*cdf0e10cSrcweir	cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(<F)
152*cdf0e10cSrcweir	cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
153*cdf0e10cSrcweir
154*cdf0e10cSrcweir$(COMP2_JAR) : $(COMP2_MANIFESTFILE) $(CLASSFILES)
155*cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
156*cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
157*cdf0e10cSrcweir	cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
158*cdf0e10cSrcweir
159*cdf0e10cSrcweir$(COMP2_PACKAGE) : $(COMP2_JAR) $(COMP2_UNOPKG_MANIFEST) $(COMP2_COMPONENTS)
160*cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
161*cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
162*cdf0e10cSrcweir	$(SDK_ZIP) $@ $(COMP2_COMPONENTS)
163*cdf0e10cSrcweir	cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(<F)
164*cdf0e10cSrcweir	cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
165*cdf0e10cSrcweir
166*cdf0e10cSrcweir$(COMP3_JAR) : $(COMP3_MANIFESTFILE) $(CLASSFILES)
167*cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
168*cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
169*cdf0e10cSrcweir	cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
170*cdf0e10cSrcweir
171*cdf0e10cSrcweir$(COMP3_PACKAGE) : $(COMP3_JAR) $(COMP3_UNOPKG_MANIFEST) $(COMP3_COMPONENTS)
172*cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
173*cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
174*cdf0e10cSrcweir	$(SDK_ZIP) $@ $(COMP3_COMPONENTS)
175*cdf0e10cSrcweir	cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(<F)
176*cdf0e10cSrcweir	cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
177*cdf0e10cSrcweir
178*cdf0e10cSrcweir$(REGISTERFLAG) : $(COMP1_PACKAGE) $(COMP2_PACKAGE) $(COMP3_PACKAGE)
179*cdf0e10cSrcweirifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
180*cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
181*cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
182*cdf0e10cSrcweir	$(DEPLOYTOOL) $(COMP1_PACKAGE_URL)
183*cdf0e10cSrcweir	$(DEPLOYTOOL) $(COMP2_PACKAGE_URL)
184*cdf0e10cSrcweir	$(DEPLOYTOOL) $(COMP3_PACKAGE_URL)
185*cdf0e10cSrcweir	@echo flagged > $(subst /,$(PS),$@)
186*cdf0e10cSrcweirelse
187*cdf0e10cSrcweir	@echo --------------------------------------------------------------------------------
188*cdf0e10cSrcweir	@echo  If you want to install your component automatically, please set the environment
189*cdf0e10cSrcweir	@echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
190*cdf0e10cSrcweir	@echo  possible if no office instance is running.
191*cdf0e10cSrcweir	@echo --------------------------------------------------------------------------------
192*cdf0e10cSrcweirendif
193*cdf0e10cSrcweir
194*cdf0e10cSrcweir$(OUT_COMP_CLASS)/%.class : %.java
195*cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
196*cdf0e10cSrcweir	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $<
197*cdf0e10cSrcweir
198*cdf0e10cSrcweir$(OUT_COMP_CLASS)/%.mf :
199*cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
200*cdf0e10cSrcweir	@echo Main-Class: com.sun.star.lib.loader.Loader> $@
201*cdf0e10cSrcweir	$(ECHOLINE)>> $@
202*cdf0e10cSrcweir	@echo Name: com/sun/star/lib/loader/Loader.class>> $@
203*cdf0e10cSrcweir	@echo Application-Class: $*>> $@
204*cdf0e10cSrcweir
205*cdf0e10cSrcweir$(APP1_JAR) : $(OUT_COMP_CLASS)/$(APP1_NAME).mf $(OUT_COMP_CLASS)/$(APP1_NAME).class
206*cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
207*cdf0e10cSrcweir	-$(MKDIR) $(subst /,$(PS),$(@D))
208*cdf0e10cSrcweir	+cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(basename $(@F)).class $(basename $(@F))$(QUOTE)$$Client.class
209*cdf0e10cSrcweir	+$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
210*cdf0e10cSrcweir
211*cdf0e10cSrcweir
212*cdf0e10cSrcweir$(EXAMPLE_NAME) : $(REGISTERFLAG) $(APP1_JAR)
213*cdf0e10cSrcweir	@echo --------------------------------------------------------------------------------
214*cdf0e10cSrcweir	@echo Please use the following command to execute the example!
215*cdf0e10cSrcweir	@echo -
216*cdf0e10cSrcweir	@echo $(MAKE) $(APP1_NAME).run
217*cdf0e10cSrcweir	@echo --------
218*cdf0e10cSrcweir	@echo Before you can run the examples the components "$(QM)$(COMP1_NAME)$(QM)",
219*cdf0e10cSrcweir	@echo "$(QM)$(COMP2_NAME)$(QM)" and "$(QM)$(COMP3_NAME)$(QM)" must be deployed.
220*cdf0e10cSrcweir	@echo The components will be automatically deployed if SDK_AUTO_DEPLOYMENT = YES.
221*cdf0e10cSrcweir	@echo --------------------------------------------------------------------------------
222*cdf0e10cSrcweir
223*cdf0e10cSrcweir%.run: $(OUT_COMP_CLASS)/%.jar
224*cdf0e10cSrcweir	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
225*cdf0e10cSrcweir
226*cdf0e10cSrcweir.PHONY: clean
227*cdf0e10cSrcweirclean :
228*cdf0e10cSrcweir	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
229*cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP1_PACKAGE_URL)))
230*cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP2_PACKAGE_URL)))
231*cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP3_PACKAGE_URL)))
232*cdf0e10cSrcweir	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG)))
233