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 Text 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
32SAMPLE_NAME=TextExample
33SAMPLE_CLASS_OUT = $(OUT_CLASS)/$(SAMPLE_NAME)
34SAMPLE_GEN_OUT = $(OUT_MISC)/$(SAMPLE_NAME)
35
36APP1_NAME=TextDocuments
37APP1_JAR=$(SAMPLE_CLASS_OUT)/$(APP1_NAME).jar
38
39SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
40		$(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT))
41
42
43# Targets
44.PHONY: ALL
45ALL : \
46    $(SAMPLE_NAME)
47
48include $(SETTINGS)/stdtarget.mk
49
50$(SAMPLE_CLASS_OUT)/%.class : %.java
51	-$(MKDIR) $(subst /,$(PS),$(@D))
52	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $<
53
54$(SAMPLE_CLASS_OUT)/%.mf :
55	-$(MKDIR) $(subst /,$(PS),$(@D))
56	@echo Main-Class: com.sun.star.lib.loader.Loader> $@
57	$(ECHOLINE)>> $@
58	@echo Name: com/sun/star/lib/loader/Loader.class>> $@
59	@echo Application-Class: $*>> $@
60
61$(SAMPLE_CLASS_OUT)/%.jar : $(SAMPLE_CLASS_OUT)/%.mf $(SAMPLE_CLASS_OUT)/%.class
62	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
63	-$(MKDIR) $(subst /,$(PS),$(@D))
64	+cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) cvfm $(@F) $*.mf $*.class
65	+$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
66
67$(APP1_JAR) : $(SAMPLE_CLASS_OUT)/$(APP1_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP1_NAME).class
68
69$(SAMPLE_NAME) : $(APP1_JAR)
70	@echo --------------------------------------------------------------------------------
71	@echo Please use the following command to execute the example!
72	@echo -
73	@echo $(MAKE) $(APP1_NAME).run
74	@echo --------------------------------------------------------------------------------
75
76%.run: $(SAMPLE_CLASS_OUT)/%.jar
77	-$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT)/savetest)
78	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "$(SAMPLE_GEN_OUT)/savetest"
79
80.PHONY: clean
81clean :
82	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
83	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
84