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 PRJ=../../../..
23 SETTINGS=$(PRJ)/settings
24 
25 include $(SETTINGS)/settings.mk
26 include $(SETTINGS)/std.mk
27 # include $(SETTINGS)/dk.mk
28 
29 # Define non-platform/compiler specific settings
30 
31 # we use the sample directory name for separating this example
32 # from others in the output directory
33 SAMPLE_NAME=EmbeddedObject
34 SAMPLE_CLASS_OUT=$(OUT_CLASS)/$(SAMPLE_NAME)
35 SAMPLE_GEN_OUT=$(OUT_MISC)/$(SAMPLE_NAME)
36 
37 COMP_NAME=OwnEmbeddedObject
38 COMP_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(COMP_NAME)
39 COMP_GEN_OUT=$(SAMPLE_GEN_OUT)/$(COMP_NAME)
40 COMP_PACKAGE=$(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
41 COMP_PACKAGE_URL=$(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
42 COMP_JAR_NAME=$(COMP_NAME).uno.jar
43 COMP_JAR=$(SAMPLE_CLASS_OUT)/$(COMP_JAR_NAME)
44 COMP_JAR_MANIFEST=$(COMP_GEN_OUT)/$(COMP_NAME).Manifest
45 COMP_UNOPKG_MANIFEST = $(COMP_GEN_OUT)/META-INF/manifest.xml
46 COMP_REGISTERFLAG=$(COMP_GEN_OUT)$(PS)java_$(COMP_NAME)_register_component.flag
47 COMP_COMPONENTS=$(COMP_NAME).components
48 
49 PACKAGE = org/openoffice/examples/embedding
50 
51 COMP_JAVAFILES  =\
52 					OwnEmbeddedObject.java\
53 					OwnEmbeddedObjectFactory.java\
54 					EditorFrame.java
55 
56 COMP_CLASSFILES = $(patsubst %.java,$(COMP_CLASS_OUT)/%.class,$(COMP_JAVAFILES))
57 
58 SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
59 		$(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT)\
60 		$(PATH_SEPARATOR)$(COMP_CLASS_OUT))
61 
62 
63 # Targets
64 .PHONY: ALL
65 ALL : $(COMP_NAME)
66 
67 include $(SETTINGS)/stdtarget.mk
68 
69 $(COMP_GEN_OUT)/%.Manifest :
70 	-$(MKDIR) $(subst \\,\,$(subst /,$(PS),$(@D)))
71 	@echo RegistrationClassName: $(subst /,.,$(PACKAGE)).$(COMP_NAME)Factory> $@
72 
73 # component as well as application are dependent from the generated types
74 # rule for component class files
75 $(COMP_CLASS_OUT)/%.class : $(COMP_JAVAFILES)
76 	-$(MKDIR) $(subst /,$(PS),$(@D))
77 	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(COMP_CLASS_OUT) $(COMP_JAVAFILES)
78 
79 # rule for component jar file
80 $(COMP_JAR) : $(COMP_JAR_MANIFEST) $(COMP_CLASSFILES)
81 	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
82 	-$(MKDIR) $(subst /,$(PS),$(@D))
83 	$(SDK_JAR) cvfm $@  $< -C $(COMP_CLASS_OUT) .
84 
85 # rule for component package manifest
86 $(COMP_GEN_OUT)/%/manifest.xml :
87 	-$(MKDIR) $(subst /,$(PS),$(@D))
88 	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
89 	@echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
90 	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
91 	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(SAMPLE_NAME).xcu$(QM)"/$(CSEP) >> $@
92 	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
93 	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@
94 	@echo $(OSEP)/manifest:manifest$(CSEP) >> $@
95 
96 # rule for component package file
97 $(COMP_PACKAGE) : $(COMP_JAR) $(COMP_UNOPKG_MANIFEST) $(COMP_NAME).components
98 	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
99 	-$(MKDIR) $(subst /,$(PS),$(@D))
100 	$(SDK_ZIP) $@ $(SAMPLE_NAME).xcu
101 	$(SDK_ZIP) $@ -u $(COMP_NAME).components
102 	cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_ZIP) -u $@ $(COMP_JAR_NAME)
103 	cd $(subst /,$(PS),$(COMP_GEN_OUT)) && $(SDK_ZIP) -u $@ META-INF/manifest.xml
104 
105 $(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
106 ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
107 	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
108 	-$(MKDIR) $(subst \\,\,$(subst /,$(PS),$(@D)))
109 	$(DEPLOYTOOL) $(COMP_PACKAGE_URL)
110 	@echo flagged > $(subst /,$(PS),$@)
111 else
112 	@echo --------------------------------------------------------------------------------
113 	@echo  If you want to install your component automatically, please set the environment
114 	@echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
115 	@echo  possible if no office instance is running.
116 	@echo --------------------------------------------------------------------------------
117 endif
118 
119 $(COMP_NAME) : $(COMP_REGISTERFLAG)
120 	@echo ------
121 	@echo The $(COMP_NAME) component was installed if SDK_AUTO_DEPLOYMENT = YES.
122 	@echo Load the "$(QM)$(SAMPLE_NAME).odt$(QM)" document to see how this component works.
123 	@echo You can use this component inside your office installation, see the example
124 	@echo description.
125 	@echo -
126 	@echo $(MAKE) $(SAMPLE_NAME).odt.load
127 	@echo --------------------------------------------------------------------------------
128 
129 $(SAMPLE_NAME).odt.load : $(COMP_REGISTERFLAG)
130 	"$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
131 
132 .PHONY: clean
133 clean :
134 	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
135 	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
136 	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
137