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 Java DocumentHandling examples of the SDK.
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=JavaDocumentHandlingExamples
33SAMPLE_CLASS_OUT = $(OUT_CLASS)/$(SAMPLE_NAME)
34SAMPLE_GEN_OUT = $(OUT_MISC)/$(SAMPLE_NAME)
35
36DIRFLAG=$(OUT_MISC)/$(SAMPLE_NAME)_directory.flag
37
38APP1_NAME=DocumentConverter
39APP1_JAR=$(SAMPLE_CLASS_OUT)/$(APP1_NAME).jar
40APP2_NAME=DocumentLoader
41APP2_JAR=$(SAMPLE_CLASS_OUT)/$(APP2_NAME).jar
42APP3_NAME=DocumentPrinter
43APP3_JAR=$(SAMPLE_CLASS_OUT)/$(APP3_NAME).jar
44APP4_NAME=DocumentSaver
45APP4_JAR=$(SAMPLE_CLASS_OUT)/$(APP4_NAME).jar
46
47SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
48		$(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT))
49
50
51# Targets
52.PHONY: ALL
53ALL : \
54	$(SAMPLE_NAME)
55
56include $(SETTINGS)/stdtarget.mk
57
58$(SAMPLE_CLASS_OUT)/%.class : %.java
59	-$(MKDIR) $(subst /,$(PS),$(@D))
60	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $<
61
62$(SAMPLE_CLASS_OUT)/%.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$(SAMPLE_CLASS_OUT)/%.jar : $(SAMPLE_CLASS_OUT)/%.mf $(SAMPLE_CLASS_OUT)/%.class
70	-$(MKDIR) $(subst /,$(PS),$(@D))
71	+cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) cvfm $(@F) $*.mf $*.class
72	+$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
73
74$(APP1_JAR) : $(SAMPLE_CLASS_OUT)/$(APP1_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP1_NAME).class
75$(APP2_JAR) : $(SAMPLE_CLASS_OUT)/$(APP2_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP2_NAME).class
76$(APP3_JAR) : $(SAMPLE_CLASS_OUT)/$(APP3_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP3_NAME).class
77$(APP4_JAR) : $(SAMPLE_CLASS_OUT)/$(APP4_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP4_NAME).class
78
79$(SAMPLE_NAME) : $(APP1_JAR) $(APP2_JAR) $(APP3_JAR) $(APP4_JAR)
80	@echo --------------------------------------------------------------------------------
81	@echo The $(APP1_NAME) search the "$(QM)./test$(QM)" directory for documents, convert
82	@echo them using using the "$(QM)MS Word 97$(QM)" filter and the extension "$(QM).doc$(QM)".
83	@echo The converted files are store in "$(QM)$(SAMPLE_GEN_OUT)/converted_files$(QM)".
84	@echo The list of possible filter names can change. Normally an updated list can be found
85	@echo on "$(QM)http://www.openoffice.org/files/documents/25/111/filter_description.html$(QM)".
86	@echo -
87	@echo The $(APP2_NAME) loads the document "$(QM)./test/test1.odt$(QM)".
88	@echo -
89	@echo The $(APP3_NAME) prints the document "$(QM)./test/test1.odt$(QM)" using the
90	@echo the specified printer. If the printer is unknown, the default printer is used.
91	@echo -
92	@echo The $(APP5_NAME) loads the document "$(QM)./test/test1.odt$(QM)" and saves it
93	@echo under "$(QM)$(SAMPLE_GEN_OUT)/savetest/testsave.odt$(QM)".
94	@echo -
95	@echo Please use one of the following commands to execute the examples!
96	@echo -
97	@echo $(MAKE) $(APP1_NAME).run
98	@echo $(MAKE) $(APP2_NAME).run
99	@echo $(MAKE) $(APP3_NAME).run
100	@echo $(MAKE) $(APP4_NAME).run
101	@echo --------
102	@echo The examples need parameters. Please use one the following commands to
103	@echo start the demo if you do not want the default parameters specified in the
104	@echo this makefile. Starting without parameters print a command line help:
105	@echo --- $(APP1_NAME) ---
106	@echo java -jar $(APP1_NAME).jar "$(QM)directory$(QM)" "$(QM)filter name$(QM)" "$(QM)extension$(QM)" "$(QM)output_directory$(QM)"
107	@echo --- $(APP2_NAME) ---
108	@echo java -jar $(APP2_NAME).jar "$(QM)Url|path$(QM)"
109	@echo --- $(APP3_NAME) ---
110	@echo java -jar $(APP3_NAME).jar "$(QM)printername$(QM)" "$(QM)filename$(QM)" "$(QM)pages$(QM)"
111	@echo --- $(APP4_NAME) ---
112	@echo java -jar $(APP4_NAME).jar "$(QM)load Url|path$(QM)" "$(QM)save Url|path$(QM)"
113	@echo --------------------------------------------------------------------------------
114
115$(APP1_NAME).run: $(APP1_JAR)
116	-$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT)/converted_files)
117	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "./test" "MS Word 97" "doc" "$(SAMPLE_GEN_OUT)/converted_files"
118
119$(APP2_NAME).run: $(APP2_JAR)
120	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "./test/test1.odt"
121
122$(APP3_NAME).run: $(APP3_JAR)
123	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "my_printer" "./test/test1.odt" 1
124
125$(APP4_NAME).run: $(APP4_JAR)
126	-$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT)/savetest)
127	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "./test/test1.odt" "$(SAMPLE_GEN_OUT)/savetest/testsave.odt"
128
129.PHONY: clean
130clean :
131	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
132	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
133