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 UCB 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=UCBExamples
33OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
34OUT_APP_MISC = $(OUT_MISC)/$(EXAMPLE_NAME)
35
36APP1_NAME=ChildrenRetriever
37APP1_JAR=$(OUT_APP_CLASS)/$(APP1_NAME).jar
38APP2_NAME=DataStreamComposer
39APP2_JAR=$(OUT_APP_CLASS)/$(APP2_NAME).jar
40APP3_NAME=DataStreamRetriever
41APP3_JAR=$(OUT_APP_CLASS)/$(APP3_NAME).jar
42APP4_NAME=PropertiesComposer
43APP4_JAR=$(OUT_APP_CLASS)/$(APP4_NAME).jar
44APP5_NAME=PropertiesRetriever
45APP5_JAR=$(OUT_APP_CLASS)/$(APP5_NAME).jar
46APP6_NAME=ResourceCreator
47APP6_JAR=$(OUT_APP_CLASS)/$(APP6_NAME).jar
48APP7_NAME=ResourceManager
49APP7_JAR=$(OUT_APP_CLASS)/$(APP7_NAME).jar
50APP8_NAME=ResourceRemover
51APP8_JAR=$(OUT_APP_CLASS)/$(APP8_NAME).jar
52
53APP_JAVAFILES  = \
54	Helper.java \
55	MyActiveDataSink.java \
56	MyInputStream.java
57
58APP_CLASSFILES = $(patsubst %.java,$(OUT_APP_CLASS)/%.class,$(APP_JAVAFILES))
59APP_CLASSNAMES = $(patsubst %.java,%.class,$(APP_JAVAFILES))
60
61SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
62		$(PATH_SEPARATOR)$(OUT_APP_CLASS))
63
64OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
65
66# Targets
67.PHONY: ALL
68ALL : \
69	UCBExamples
70
71include $(SETTINGS)/stdtarget.mk
72
73$(APP_CLASSFILES) : $(APP_JAVAFILES)
74	-$(MKDIR) $(subst /,$(PS),$(@D))
75	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $(APP_JAVAFILES)
76
77$(OUT_APP_CLASS)/%.class : %.java $(APP_CLASSFILES)
78	-$(MKDIR) $(subst /,$(PS),$(@D))
79	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $<
80
81$(OUT_APP_CLASS)/$(APP2_NAME).class : $(APP2_NAME).java $(OUT_APP_CLASS)/DataStreamRetriever.class $(APP_CLASSFILES)
82	-$(MKDIR) $(subst /,$(PS),$(@D))
83	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $<
84
85$(OUT_APP_CLASS)/$(APP6_NAME).class : $(APP6_NAME).java $(OUT_APP_CLASS)/DataStreamRetriever.class $(APP_CLASSFILES)
86	-$(MKDIR) $(subst /,$(PS),$(@D))
87	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $<
88
89$(OUT_APP_CLASS)/%.mf :
90	-$(MKDIR) $(subst /,$(PS),$(@D))
91	@echo Main-Class: com.sun.star.lib.loader.Loader> $@
92	$(ECHOLINE)>> $@
93	@echo Name: com/sun/star/lib/loader/Loader.class>> $@
94	@echo Application-Class: $*>> $@
95
96$(OUT_APP_CLASS)/%.jar : $(OUT_APP_CLASS)/%.mf $(OUT_APP_CLASS)/%.class $(APP_CLASSFILES)
97	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
98	-$(MKDIR) $(subst /,$(PS),$(@D))
99	+cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $*.mf $*.class $(APP_CLASSNAMES)
100	+$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
101
102$(APP2_JAR) : $(OUT_APP_CLASS)/$(APP2_NAME).mf $(OUT_APP_CLASS)/$(APP2_NAME).class $(OUT_APP_CLASS)/DataStreamRetriever.class $(APP_CLASSFILES)
103	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
104	-$(MKDIR) $(subst /,$(PS),$(@D))
105	+cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(basename $(@F)).class DataStreamRetriever.class $(APP_CLASSNAMES)
106	+$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
107
108$(APP6_JAR) : $(OUT_APP_CLASS)/$(APP6_NAME).mf $(OUT_APP_CLASS)/$(APP6_NAME).class $(OUT_APP_CLASS)/DataStreamRetriever.class $(APP_CLASSFILES)
109	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
110	-$(MKDIR) $(subst /,$(PS),$(@D))
111	+cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(basename $(@F)).class DataStreamRetriever.class $(APP_CLASSNAMES)
112	+$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
113
114
115$(APP1_JAR) : $(OUT_APP_CLASS)/$(APP1_NAME).mf $(OUT_APP_CLASS)/$(APP1_NAME).class
116$(APP2_JAR) : $(OUT_APP_CLASS)/$(APP2_NAME).mf $(OUT_APP_CLASS)/$(APP2_NAME).class
117$(APP3_JAR) : $(OUT_APP_CLASS)/$(APP3_NAME).mf $(OUT_APP_CLASS)/$(APP3_NAME).class
118$(APP4_JAR) : $(OUT_APP_CLASS)/$(APP4_NAME).mf $(OUT_APP_CLASS)/$(APP4_NAME).class
119$(APP5_JAR) : $(OUT_APP_CLASS)/$(APP5_NAME).mf $(OUT_APP_CLASS)/$(APP5_NAME).class
120$(APP6_JAR) : $(OUT_APP_CLASS)/$(APP6_NAME).mf $(OUT_APP_CLASS)/$(APP6_NAME).class
121$(APP7_JAR) : $(OUT_APP_CLASS)/$(APP7_NAME).mf $(OUT_APP_CLASS)/$(APP7_NAME).class
122$(APP8_JAR) : $(OUT_APP_CLASS)/$(APP8_NAME).mf $(OUT_APP_CLASS)/$(APP8_NAME).class
123
124UCBExamples : $(APP1_JAR) $(APP2_JAR) $(APP3_JAR) $(APP4_JAR) $(APP5_JAR) $(APP6_JAR) $(APP7_JAR) $(APP8_JAR)
125	@echo --------------------------------------------------------------------------------
126	@echo Please use one of the following commands to execute the examples!
127	@echo -
128	@echo $(MAKE) $(APP1_NAME).run
129	@echo $(MAKE) $(APP2_NAME).run
130	@echo $(MAKE) $(APP3_NAME).run
131	@echo $(MAKE) $(APP4_NAME).run
132	@echo $(MAKE) $(APP5_NAME).run
133	@echo $(MAKE) $(APP6_NAME).run
134	@echo $(MAKE) $(APP7_NAME).run
135	@echo $(MAKE) $(APP8_NAME).run
136	@echo --------------------------------------------------------------------------------
137
138%.run: $(OUT_APP_CLASS)/%.jar
139	-$(MKDIR) $(subst /,$(PS),$(OUT_APP_MISC))
140	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< -workdir=$(OUT_APP_MISC)
141
142.PHONY: clean
143clean :
144	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_CLASS))
145