xref: /aoo42x/main/odk/examples/java/ToDo/Makefile (revision 122c3632)
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 Calc Addin example 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
32COMP_NAME=ToDo
33COMP_CLASS_OUT=$(OUT_CLASS)/$(COMP_NAME)
34COMP_GEN_OUT=$(OUT_MISC)/$(COMP_NAME)
35COMP_RDB_NAME=$(COMP_NAME).uno.rdb
36COMP_RDB=$(COMP_GEN_OUT)/$(COMP_RDB_NAME)
37COMP_PACKAGE=$(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
38COMP_PACKAGE_URL=$(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
39COMP_JAR_NAME=$(COMP_NAME).uno.jar
40COMP_JAR=$(COMP_CLASS_OUT)/$(COMP_JAR_NAME)
41COMP_JAR_MANIFEST=$(COMP_CLASS_OUT)/$(COMP_NAME).uno.Manifest
42COMP_UNOPKG_MANIFEST = $(COMP_GEN_OUT)/META-INF/manifest.xml
43COMP_REGISTERFLAG=$(COMP_GEN_OUT)$(PS)java_$(COMP_NAME)_register_component.flag
44COMP_COMPONENTS=$(COMP_NAME).components
45
46IDLFILES = XToDo.idl \
47	ToDo.idl
48
49# normally the idl file should be stored in a directory tree fitting the module
50# structure, for the example we know the module structure
51PACKAGE = org/openoffice
52
53COMP_JAVAFILES  = ToDo.java
54COMP_CLASSFILES = $(patsubst %.java,$(COMP_CLASS_OUT)/%.class,$(COMP_JAVAFILES))
55
56GEN_CLASSFILES = $(patsubst %.idl,$(COMP_CLASS_OUT)/$(PACKAGE)/%.class,$(IDLFILES))
57GEN_TYPELIST = $(subst /,.,$(patsubst %.idl,-T$(PACKAGE)/% ,$(IDLFILES)))
58GEN_URDFILES = $(patsubst %.idl,$(COMP_GEN_OUT)/%.urd,$(IDLFILES))
59
60
61$(COMP_NAME)_CLASSFILES = $(COMP_NAME).class \
62		$(COMP_NAME)$(QUOTE)$$$(COMP_NAME)Impl.class
63
64$(COMP_NAME)_CLASSFILES += $(subst $(COMP_CLASS_OUT)/,,$(GEN_CLASSFILES))
65
66SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
67		$(PATH_SEPARATOR)$(COMP_CLASS_OUT))
68
69
70# Targets
71.PHONY: ALL
72ALL : JavaToDoExample
73
74include $(SETTINGS)/stdtarget.mk
75
76$(COMP_CLASS_OUT)/%.Manifest :
77	-$(MKDIR) $(subst /,$(PS),$(@D))
78	@echo UNO-Type-Path: $(basename $*).uno.jar> $@
79	@echo RegistrationClassName: $(basename $(basename $(@F)))>> $@
80
81$(COMP_GEN_OUT)/%.urd : %.idl
82	-$(MKDIR) $(subst /,$(PS),$(@D))
83	$(IDLC) -C -I. -I$(IDL_DIR) -O$(COMP_GEN_OUT) $<
84
85$(COMP_GEN_OUT)/%.rdb : $(GEN_URDFILES)
86	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
87	-$(MKDIR) $(subst /,$(PS),$(@D))
88	$(REGMERGE) $@ /UCR $(GEN_URDFILES)
89
90$(GEN_CLASSFILES) : $(COMP_RDB)
91	-$(MKDIR) $(subst /,$(PS),$(@D))
92	$(JAVAMAKER) -BUCR -nD $(GEN_TYPELIST) -O$(COMP_CLASS_OUT) $(COMP_RDB) -X$(URE_TYPES) -X$(OFFICE_TYPES)
93
94$(COMP_CLASSFILES) : $(COMP_JAVAFILES) $(GEN_CLASSFILES)
95	-$(MKDIR) $(subst /,$(PS),$(@D))
96	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(COMP_CLASS_OUT) $(COMP_JAVAFILES)
97
98# rule for component jar file
99$(COMP_JAR) : $(COMP_JAR_MANIFEST) $(COMP_CLASSFILES)
100	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
101	-$(MKDIR) $(subst /,$(PS),$(@D))
102	cd $(subst /,$(PS),$(COMP_CLASS_OUT)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
103
104# rule for component package manifest
105$(COMP_GEN_OUT)/%/manifest.xml :
106	-$(MKDIR) $(subst /,$(PS),$(@D))
107	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
108	@echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
109	@echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
110	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@
111	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_MISC)/,,$(@D))).uno.rdb$(QM)"/$(CSEP) >> $@
112	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
113	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@
114	@echo $(OSEP)/manifest:manifest$(CSEP) >> $@
115
116# rule for component package file
117$(COMP_PACKAGE) : $(COMP_RDB) $(COMP_JAR) $(COMP_UNOPKG_MANIFEST) $(COMP_NAME).components
118	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
119	-$(MKDIR) $(subst /,$(PS),$(@D))
120	$(SDK_ZIP) $@ $(COMP_NAME).components
121	cd $(subst /,$(PS),$(COMP_GEN_OUT)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_RDB_NAME)
122	cd $(subst /,$(PS),$(COMP_CLASS_OUT)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_JAR_NAME)
123	cd $(subst /,$(PS),$(COMP_GEN_OUT)) && $(SDK_ZIP) -u ../../bin/$(@F) META-INF/manifest.xml
124
125$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
126ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
127	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
128	-$(MKDIR) $(subst /,$(PS),$(@D))
129	$(DEPLOYTOOL) $(COMP_PACKAGE_URL)
130	@echo flagged > $(subst /,$(PS),$@)
131else
132	@echo --------------------------------------------------------------------------------
133	@echo  If you want to install your component automatically, please set the environment
134	@echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
135	@echo  possible if no office instance is running.
136	@echo --------------------------------------------------------------------------------
137endif
138
139JavaToDoExample : $(COMP_REGISTERFLAG)
140	@echo --------------------------------------------------------------------------------
141	@echo The $(COMP_NAME) Java component was installed if SDK_AUTO_DEPLOYMENT = YES.
142	@echo Please load the "$(QM)ToDo.ods$(QM)" document to see how this component works, see
143	@echo the example description.
144	@echo -
145	@echo $(MAKE) ToDo.ods.load
146	@echo --------------------------------------------------------------------------------
147
148ToDo.ods.load : $(COMP_REGISTERFLAG)
149	"$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
150
151.PHONY: clean
152clean :
153	-$(DELRECURSIVE) $(subst /,$(PS),$(COMP_CLASS_OUT))
154	-$(DELRECURSIVE) $(subst /,$(PS),$(COMP_GEN_OUT))
155	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
156