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