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  #*************************************************************************
23#
24#  The Contents of this file are made available subject to the terms of
25#  the BSD license.
26#
27#  Copyright 2000, 2010 Oracle and/or its affiliates.
28#  All rights reserved.
29#
30#  Redistribution and use in source and binary forms, with or without
31#  modification, are permitted provided that the following conditions
32#  are met:
33#  1. Redistributions of source code must retain the above copyright
34#     notice, this list of conditions and the following disclaimer.
35#  2. Redistributions in binary form must reproduce the above copyright
36#     notice, this list of conditions and the following disclaimer in the
37#     documentation and/or other materials provided with the distribution.
38#  3. Neither the name of Sun Microsystems, Inc. nor the names of its
39#     contributors may be used to endorse or promote products derived
40#     from this software without specific prior written permission.
41#
42#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
45#  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
46#  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
47#  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
48#  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
49#  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
50#  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
51#  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
52#  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53#
54#**************************************************************************
55
56# Builds the complextoolbarcontrols C++ component example of the SDK.
57
58PRJ=../../..
59SETTINGS=$(PRJ)/settings
60
61include $(SETTINGS)/settings.mk
62include $(SETTINGS)/std.mk
63include $(SETTINGS)/dk.mk
64
65# Define non-platform/compiler specific settings
66COMP_NAME=complextoolbarcontrols
67COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
68OUT_COMP_INC=$(OUT_INC)/$(COMP_NAME)
69OUT_COMP_GEN=$(OUT_MISC)/$(COMP_NAME)
70OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
71COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
72COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
73COMP_UNOPKG_MANIFEST = $(OUT_COMP_GEN)/$(COMP_NAME)/META-INF/manifest.xml
74COMP_MAPFILE = $(OUT_COMP_GEN)/$(COMP_NAME).uno.map
75COMP_COMPONENTS = $(OUT_COMP_GEN)/$(COMP_NAME).components
76COMP_REGISTERFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_register_component.flag
77COMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
78
79CXXFILES = \
80           MyProtocolHandler.cxx \
81           MyJob.cxx \
82           MyListener.cxx \
83           WriterListener.cxx \
84           CalcListener.cxx \
85           ListenerHelper.cxx \
86           exports.cxx
87
88SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
89
90# Add OSL_DEBUG_LEVEL to compiler the flags (for OSL_TRACE et. al.)
91ifeq "$(DEBUG)" "yes"
92CC_FLAGS += -DOSL_DEBUG_LEVEL=2
93endif
94
95# Targets
96.PHONY: ALL
97ALL : \
98	Example
99
100include $(SETTINGS)/stdtarget.mk
101
102$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
103	-$(MKDIR) $(subst /,$(PS),$(@D))
104	$(CC) $(CC_FLAGS) $(STL_INCLUDES) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
105
106
107#$(COMP_MAPFILE) : $(SLOFILES)
108#	-$(MKDIR) $(subst /,$(PS),$(@D))
109#	cat $(PRJ)/settings/component.uno.map > $(COMP_MAPFILE)
110#ifeq "$(OS)" "MACOSX"
111#	nm -gx $(SLOFILES) | $(ADDSYMBOLS) >> $(COMP_MAPFILE)
112#endif
113
114ifeq "$(OS)" "WIN"
115$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
116	-$(MKDIR) $(subst /,$(PS),$(@D))
117	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
118	$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
119	/MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
120	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
121	$(LINK_MANIFEST)
122else
123#$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(COMP_MAPFILE)
124$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
125	-$(MKDIR) $(subst /,$(PS),$(@D))
126	$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
127	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
128ifeq "$(OS)" "MACOSX"
129	$(INSTALL_NAME_URELIBS)  $@
130endif
131endif
132
133# rule for component package manifest
134$(OUT_COMP_GEN)/%/manifest.xml :
135	-$(MKDIR) $(subst /,$(PS),$(@D))
136	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
137	@echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
138	@echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
139	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
140	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)Addons.xcu$(QM)"/$(CSEP) >> $@
141	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
142	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)WriterWindowState.xcu$(QM)"/$(CSEP) >> $@
143	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:meda-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
144	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)CalcWindowState.xcu$(QM)"/$(CSEP) >> $@
145	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
146	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)ProtocolHandler.xcu$(QM)"/$(CSEP) >> $@
147	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@
148	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@
149
150#	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-component;type=native;platform=$(UNOPKG_PLATFORM)$(QM)" >> $@
151#	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_GEN)/,,$(UNOPKG_PLATFORM)/$(@D))).uno.$(SHAREDLIB_EXT)$(QM)"/$(CSEP) >> $@
152	@echo $(OSEP)/manifest:manifest$(CSEP) >> $@
153
154$(COMP_COMPONENTS) :
155	-$(MKDIR) $(subst /,$(PS),$(@D))
156	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
157	@echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
158	@echo $(SQM)  $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
159	@echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)vnd.My.impl.NewDocListener$(QM)"$(CSEP) >> $@
160	@echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)vnd.My.NewDocListener$(QM)"/$(CSEP) >> $@
161	@echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
162	@echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)vnd.demo.Impl.ProtocolHandler$(QM)"$(CSEP) >> $@
163	@echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)vnd.demo.ProtocolHandler$(QM)"/$(CSEP) >> $@
164	@echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
165	@echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
166	@echo $(OSEP)/components$(CSEP) >> $@
167
168# rule for component package file
169$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) Addons.xcu ProtocolHandler.xcu WriterWindowState.xcu CalcWindowState.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
170	-$(MKDIR) $(subst /,$(PS),$(@D)) && $(DEL) $(subst \\,\,$(subst /,$(PS),$@))
171	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
172	$(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
173	cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_NAME).components
174	cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(UNOPKG_PLATFORM)/$(<F)
175	$(SDK_ZIP) -u $@ Addons.xcu ProtocolHandler.xcu WriterWindowState.xcu CalcWindowState.xcu logo_small.png logo_big.png
176	cd $(subst /,$(PS),$(OUT_COMP_GEN)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
177
178$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
179ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
180	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
181	$(DEPLOYTOOL) $(COMP_PACKAGE_URL)
182	@echo flagged > $(subst /,$(PS),$@)
183else
184	@echo --------------------------------------------------------------------------------
185	@echo  If you want to install your component automatically, please set the environment
186	@echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
187	@echo  possible if no office instance is running.
188	@echo --------------------------------------------------------------------------------
189endif
190
191Example : $(COMP_REGISTERFLAG)
192	@echo --------------------------------------------------------------------------------
193	@echo The "$(QM)ProtocolHandler$(QM)" addon component was installed if SDK_AUTO_DEPLOYMENT = YES.
194	@echo You can use this component inside your office installation, see the example
195	@echo description.
196	@echo --------------------------------------------------------------------------------
197
198run: $(COMP1_COMP_REGISTERFLAG)
199	"$(OFFICE_PROGRAM_PATH)$(PS)soffice" -writer
200
201
202.PHONY: clean
203clean :
204	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
205	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
206	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
207	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
208	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_REGISTERFLAG)))
209	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
210	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
211