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