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 OfficeDevClipboard 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
32EXAMPLE_NAME=OfficeDevClipboardExample
33OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
34
35APP1_NAME=Clipboard
36APP1_JAR=$(OUT_APP_CLASS)/$(APP1_NAME).jar
37
38APP1_JAVAFILES  = \
39	   Clipboard.java \
40	   ClipboardListener.java \
41	   ClipboardOwner.java \
42	   TextTransferable.java
43
44APP1_CLASSFILES = $(patsubst %.java,$(OUT_APP_CLASS)/%.class,$(APP1_JAVAFILES))
45APP1_CLASSNAMES = $(patsubst %.java,%.class,$(APP1_JAVAFILES))
46
47SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
48		$(PATH_SEPARATOR)$(OUT_APP_CLASS))
49
50
51# Targets
52.PHONY: ALL
53ALL : $(EXAMPLE_NAME)
54
55include $(SETTINGS)/stdtarget.mk
56
57$(APP1_CLASSFILES) : $(APP1_JAVAFILES)
58	-$(MKDIR) $(subst /,$(PS),$(@D))
59	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $^
60
61$(OUT_APP_CLASS)/%.mf :
62	-$(MKDIR) $(subst /,$(PS),$(@D))
63	@echo Main-Class: com.sun.star.lib.loader.Loader> $@
64	$(ECHOLINE)>> $@
65	@echo Name: com/sun/star/lib/loader/Loader.class>> $@
66	@echo Application-Class: $*>> $@
67
68$(APP1_JAR) : $(OUT_APP_CLASS)/$(APP1_NAME).mf $(APP1_CLASSFILES)
69	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
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$(EXAMPLE_NAME) : $(APP1_JAR)
75	@echo --------------------------------------------------------------------------------
76	@echo Please use the following command to execute the example!
77	@echo -
78	@echo $(MAKE) $(APP1_NAME).run
79	@echo --------------------------------------------------------------------------------
80
81%.run: $(OUT_APP_CLASS)/%.jar
82	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
83
84.PHONY: clean
85clean :
86	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_CLASS))
87