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