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 OfficeDevLinguistic examples 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=OfficeDevLinguisticExample
33*b1cdbd2cSJim JagielskiOUT_COMP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
34*b1cdbd2cSJim Jagielski
35*b1cdbd2cSJim JagielskiCOMP1_NAME=SampleHyphenator
36*b1cdbd2cSJim JagielskiCOMP1_PACKAGE = $(OUT_BIN)/$(COMP1_NAME).$(UNOOXT_EXT)
37*b1cdbd2cSJim JagielskiCOMP1_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP1_NAME).$(UNOOXT_EXT)")
38*b1cdbd2cSJim JagielskiCOMP1_JAR_NAME = $(COMP1_NAME).uno.jar
39*b1cdbd2cSJim JagielskiCOMP1_JAR = $(OUT_COMP_CLASS)/$(COMP1_JAR_NAME)
40*b1cdbd2cSJim JagielskiCOMP1_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMP1_NAME).uno.Manifest
41*b1cdbd2cSJim JagielskiCOMP1_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP1_NAME)/META-INF/manifest.xml
42*b1cdbd2cSJim JagielskiCOMP1_COMPONENTS=$(COMP1_NAME).components
43*b1cdbd2cSJim Jagielski
44*b1cdbd2cSJim JagielskiCOMP2_NAME=SampleSpellChecker
45*b1cdbd2cSJim JagielskiCOMP2_PACKAGE = $(OUT_BIN)/$(COMP2_NAME).$(UNOOXT_EXT)
46*b1cdbd2cSJim JagielskiCOMP2_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP2_NAME).$(UNOOXT_EXT)")
47*b1cdbd2cSJim JagielskiCOMP2_JAR_NAME = $(COMP2_NAME).uno.jar
48*b1cdbd2cSJim JagielskiCOMP2_JAR = $(OUT_COMP_CLASS)/$(COMP2_JAR_NAME)
49*b1cdbd2cSJim JagielskiCOMP2_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMP2_NAME).uno.Manifest
50*b1cdbd2cSJim JagielskiCOMP2_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP2_NAME)/META-INF/manifest.xml
51*b1cdbd2cSJim JagielskiCOMP2_COMPONENTS=$(COMP2_NAME).components
52*b1cdbd2cSJim Jagielski
53*b1cdbd2cSJim JagielskiCOMP3_NAME=SampleThesaurus
54*b1cdbd2cSJim JagielskiCOMP3_PACKAGE = $(OUT_BIN)/$(COMP3_NAME).$(UNOOXT_EXT)
55*b1cdbd2cSJim JagielskiCOMP3_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP3_NAME).$(UNOOXT_EXT)")
56*b1cdbd2cSJim JagielskiCOMP3_JAR_NAME = $(COMP3_NAME).uno.jar
57*b1cdbd2cSJim JagielskiCOMP3_JAR = $(OUT_COMP_CLASS)/$(COMP3_JAR_NAME)
58*b1cdbd2cSJim JagielskiCOMP3_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMP3_NAME).uno.Manifest
59*b1cdbd2cSJim JagielskiCOMP3_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP3_NAME)/META-INF/manifest.xml
60*b1cdbd2cSJim JagielskiCOMP3_COMPONENTS=$(COMP2_NAME).components
61*b1cdbd2cSJim Jagielski
62*b1cdbd2cSJim JagielskiAPP1_NAME=LinguisticExamples
63*b1cdbd2cSJim JagielskiAPP1_JAR=$(OUT_COMP_CLASS)/$(APP1_NAME).jar
64*b1cdbd2cSJim Jagielski
65*b1cdbd2cSJim JagielskiREGISTERFLAG = $(OUT_MISC)/devguide_officedevlinguistic_register_component.flag
66*b1cdbd2cSJim Jagielski
67*b1cdbd2cSJim JagielskiJAVAFILES  = \
68*b1cdbd2cSJim Jagielski	OneInstanceFactory.java \
69*b1cdbd2cSJim Jagielski	PropChgHelper.java \
70*b1cdbd2cSJim Jagielski	PropChgHelper_Hyph.java \
71*b1cdbd2cSJim Jagielski	PropChgHelper_Spell.java \
72*b1cdbd2cSJim Jagielski	XHyphenatedWord_impl.java \
73*b1cdbd2cSJim Jagielski	XMeaning_impl.java \
74*b1cdbd2cSJim Jagielski	XPossibleHyphens_impl.java \
75*b1cdbd2cSJim Jagielski	XSpellAlternatives_impl.java \
76*b1cdbd2cSJim Jagielski	SampleHyphenator.java \
77*b1cdbd2cSJim Jagielski	SampleSpellChecker.java \
78*b1cdbd2cSJim Jagielski	SampleThesaurus.java
79*b1cdbd2cSJim Jagielski
80*b1cdbd2cSJim JagielskiCLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(JAVAFILES))
81*b1cdbd2cSJim Jagielski
82*b1cdbd2cSJim Jagielski$(COMP1_NAME)_CLASSFILES = XHyphenatedWord_impl.class \
83*b1cdbd2cSJim Jagielski	XPossibleHyphens_impl.class \
84*b1cdbd2cSJim Jagielski	PropChgHelper.class \
85*b1cdbd2cSJim Jagielski	PropChgHelper_Hyph.class \
86*b1cdbd2cSJim Jagielski	OneInstanceFactory.class \
87*b1cdbd2cSJim Jagielski	$(COMP1_NAME).class
88*b1cdbd2cSJim Jagielski
89*b1cdbd2cSJim Jagielski$(COMP2_NAME)_CLASSFILES = XSpellAlternatives_impl.class \
90*b1cdbd2cSJim Jagielski	PropChgHelper_Spell.class \
91*b1cdbd2cSJim Jagielski	PropChgHelper.class \
92*b1cdbd2cSJim Jagielski	OneInstanceFactory.class \
93*b1cdbd2cSJim Jagielski	$(COMP2_NAME).class
94*b1cdbd2cSJim Jagielski
95*b1cdbd2cSJim Jagielski$(COMP3_NAME)_CLASSFILES = XMeaning_impl.class \
96*b1cdbd2cSJim Jagielski	OneInstanceFactory.class \
97*b1cdbd2cSJim Jagielski	$(COMP3_NAME).class
98*b1cdbd2cSJim Jagielski
99*b1cdbd2cSJim JagielskiSDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
100*b1cdbd2cSJim Jagielski		$(PATH_SEPARATOR)$(OUT_COMP_CLASS))
101*b1cdbd2cSJim Jagielski
102*b1cdbd2cSJim Jagielski.PHONY: ALL
103*b1cdbd2cSJim JagielskiALL : $(EXAMPLE_NAME)
104*b1cdbd2cSJim Jagielski
105*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/stdtarget.mk
106*b1cdbd2cSJim Jagielski
107*b1cdbd2cSJim Jagielski$(OUT_COMP_CLASS)/%.Manifest :
108*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
109*b1cdbd2cSJim Jagielski	@echo RegistrationClassName: $(basename $(basename $(@F)))> $@
110*b1cdbd2cSJim Jagielski
111*b1cdbd2cSJim Jagielski$(CLASSFILES) : $(JAVAFILES)
112*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
113*b1cdbd2cSJim Jagielski	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(JAVAFILES)
114*b1cdbd2cSJim Jagielski
115*b1cdbd2cSJim Jagielski# NOTE: because of gnu make problems with full qualified paths, the pattern
116*b1cdbd2cSJim Jagielski# rules for the component jars and the packages doesn't work proper and we
117*b1cdbd2cSJim Jagielski# defined explicit rules
118*b1cdbd2cSJim Jagielski
119*b1cdbd2cSJim Jagielski# rule for component package manifest
120*b1cdbd2cSJim Jagielski$(OUT_COMP_CLASS)/%/manifest.xml :
121*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
122*b1cdbd2cSJim Jagielski	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
123*b1cdbd2cSJim Jagielski	@echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
124*b1cdbd2cSJim Jagielski	@echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
125*b1cdbd2cSJim Jagielski	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)" >> $@
126*b1cdbd2cSJim Jagielski	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_CLASS)/,,$(@D))).components$(QM)"/$(CSEP) >> $@
127*b1cdbd2cSJim Jagielski	@echo $(OSEP)/manifest:manifest$(CSEP) >> $@
128*b1cdbd2cSJim Jagielski
129*b1cdbd2cSJim Jagielski$(COMP1_JAR) : $(COMP1_MANIFESTFILE) $(CLASSFILES)
130*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
131*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
132*b1cdbd2cSJim Jagielski	cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
133*b1cdbd2cSJim Jagielski
134*b1cdbd2cSJim Jagielski$(COMP1_PACKAGE) : $(COMP1_JAR) $(COMP1_UNOPKG_MANIFEST) $(COMP1_COMPONENTS)
135*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
136*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
137*b1cdbd2cSJim Jagielski	$(SDK_ZIP) $@ $(COMP1_COMPONENTS)
138*b1cdbd2cSJim Jagielski	cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(<F)
139*b1cdbd2cSJim Jagielski	cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
140*b1cdbd2cSJim Jagielski
141*b1cdbd2cSJim Jagielski$(COMP2_JAR) : $(COMP2_MANIFESTFILE) $(CLASSFILES)
142*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
143*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
144*b1cdbd2cSJim Jagielski	cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
145*b1cdbd2cSJim Jagielski
146*b1cdbd2cSJim Jagielski$(COMP2_PACKAGE) : $(COMP2_JAR) $(COMP2_UNOPKG_MANIFEST) $(COMP2_COMPONENTS)
147*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
148*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
149*b1cdbd2cSJim Jagielski	$(SDK_ZIP) $@ $(COMP2_COMPONENTS)
150*b1cdbd2cSJim Jagielski	cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(<F)
151*b1cdbd2cSJim Jagielski	cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
152*b1cdbd2cSJim Jagielski
153*b1cdbd2cSJim Jagielski$(COMP3_JAR) : $(COMP3_MANIFESTFILE) $(CLASSFILES)
154*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
155*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
156*b1cdbd2cSJim Jagielski	cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
157*b1cdbd2cSJim Jagielski
158*b1cdbd2cSJim Jagielski$(COMP3_PACKAGE) : $(COMP3_JAR) $(COMP3_UNOPKG_MANIFEST) $(COMP3_COMPONENTS)
159*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
160*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
161*b1cdbd2cSJim Jagielski	$(SDK_ZIP) $@ $(COMP3_COMPONENTS)
162*b1cdbd2cSJim Jagielski	cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(<F)
163*b1cdbd2cSJim Jagielski	cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
164*b1cdbd2cSJim Jagielski
165*b1cdbd2cSJim Jagielski$(REGISTERFLAG) : $(COMP1_PACKAGE) $(COMP2_PACKAGE) $(COMP3_PACKAGE)
166*b1cdbd2cSJim Jagielskiifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
167*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
168*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
169*b1cdbd2cSJim Jagielski	$(DEPLOYTOOL) $(COMP1_PACKAGE_URL)
170*b1cdbd2cSJim Jagielski	$(DEPLOYTOOL) $(COMP2_PACKAGE_URL)
171*b1cdbd2cSJim Jagielski	$(DEPLOYTOOL) $(COMP3_PACKAGE_URL)
172*b1cdbd2cSJim Jagielski	@echo flagged > $(subst /,$(PS),$@)
173*b1cdbd2cSJim Jagielskielse
174*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
175*b1cdbd2cSJim Jagielski	@echo  If you want to install your component automatically, please set the environment
176*b1cdbd2cSJim Jagielski	@echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
177*b1cdbd2cSJim Jagielski	@echo  possible if no office instance is running.
178*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
179*b1cdbd2cSJim Jagielskiendif
180*b1cdbd2cSJim Jagielski
181*b1cdbd2cSJim Jagielski$(OUT_COMP_CLASS)/%.class : %.java
182*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
183*b1cdbd2cSJim Jagielski	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $<
184*b1cdbd2cSJim Jagielski
185*b1cdbd2cSJim Jagielski$(OUT_COMP_CLASS)/%.mf :
186*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
187*b1cdbd2cSJim Jagielski	@echo Main-Class: com.sun.star.lib.loader.Loader> $@
188*b1cdbd2cSJim Jagielski	$(ECHOLINE)>> $@
189*b1cdbd2cSJim Jagielski	@echo Name: com/sun/star/lib/loader/Loader.class>> $@
190*b1cdbd2cSJim Jagielski	@echo Application-Class: $*>> $@
191*b1cdbd2cSJim Jagielski
192*b1cdbd2cSJim Jagielski$(APP1_JAR) : $(OUT_COMP_CLASS)/$(APP1_NAME).mf $(OUT_COMP_CLASS)/$(APP1_NAME).class
193*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
194*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
195*b1cdbd2cSJim Jagielski	+cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(basename $(@F)).class $(basename $(@F))$(QUOTE)$$Client.class
196*b1cdbd2cSJim Jagielski	+$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
197*b1cdbd2cSJim Jagielski
198*b1cdbd2cSJim Jagielski
199*b1cdbd2cSJim Jagielski$(EXAMPLE_NAME) : $(REGISTERFLAG) $(APP1_JAR)
200*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
201*b1cdbd2cSJim Jagielski	@echo Please use the following command to execute the example!
202*b1cdbd2cSJim Jagielski	@echo -
203*b1cdbd2cSJim Jagielski	@echo $(MAKE) $(APP1_NAME).run
204*b1cdbd2cSJim Jagielski	@echo --------
205*b1cdbd2cSJim Jagielski	@echo Before you can run the examples the components "$(QM)$(COMP1_NAME)$(QM)",
206*b1cdbd2cSJim Jagielski	@echo "$(QM)$(COMP2_NAME)$(QM)" and "$(QM)$(COMP3_NAME)$(QM)" must be deployed.
207*b1cdbd2cSJim Jagielski	@echo The components will be automatically deployed if SDK_AUTO_DEPLOYMENT = YES.
208*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
209*b1cdbd2cSJim Jagielski
210*b1cdbd2cSJim Jagielski%.run: $(OUT_COMP_CLASS)/%.jar
211*b1cdbd2cSJim Jagielski	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
212*b1cdbd2cSJim Jagielski
213*b1cdbd2cSJim Jagielski.PHONY: clean
214*b1cdbd2cSJim Jagielskiclean :
215*b1cdbd2cSJim Jagielski	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
216*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP1_PACKAGE_URL)))
217*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP2_PACKAGE_URL)))
218*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP3_PACKAGE_URL)))
219*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG)))
220