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 filterdetection component for the FlatXmlFilter of the Developers Guide.
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=FlatXmlTypeDetection
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_RDB_NAME = $(COMP_NAME).uno.rdb
72COMP_RDB = $(OUT_COMP_GEN)/$(COMP_RDB_NAME)
73COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
74COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
75COMP_UNOPKG_MANIFEST = $(OUT_COMP_GEN)/$(COMP_NAME)/META-INF/manifest.xml
76COMP_COMPONENTS = $(OUT_COMP_GEN)/$(COMP_NAME).components
77#COMP_MAPFILE = $(OUT_COMP_GEN)/$(COMP_NAME).uno.map
78
79REGISTERFLAG = $(OUT_MISC)/devguide_$(COMP_NAME)_register_component.flag
80
81CXXFILES = filterdetect.cxx \
82	fdcomp.cxx
83
84SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
85
86# Targets
87.PHONY: ALL
88ALL : \
89	XMLFilterDetect
90
91include $(SETTINGS)/stdtarget.mk
92
93$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
94	-$(MKDIR) $(subst /,$(PS),$(@D))
95	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
96
97#$(COMP_MAPFILE) : $(SLOFILES)
98#	-$(MKDIR) $(subst /,$(PS),$(@D))
99#	cat $(PRJ)/settings/component.uno.map > $(COMP_MAPFILE)
100#ifeq "$(OS)" "MACOSX"
101#	nm -gx $(SLOFILES) | $(ADDSYMBOLS) >> $(COMP_MAPFILE)
102#endif
103
104ifeq "$(OS)" "WIN"
105$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
106	-$(MKDIR) $(subst /,$(PS),$(@D))
107	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
108	$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
109	/MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
110	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
111	$(LINK_MANIFEST)
112else
113$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
114	-$(MKDIR) $(subst /,$(PS),$(@D))
115	$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
116	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
117ifeq "$(OS)" "MACOSX"
118	$(INSTALL_NAME_URELIBS)  $@
119endif
120endif
121
122# rule for component package manifest
123$(OUT_COMP_GEN)/%/manifest.xml :
124	-$(MKDIR) $(subst /,$(PS),$(@D))
125	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
126	@echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
127	@echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
128	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
129	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)FlatXmlTypeDetection.xcu$(QM)"/$(CSEP) >> $@
130	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@
131	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@
132	@echo $(OSEP)/manifest:manifest$(CSEP) >> $@
133
134$(COMP_COMPONENTS) :
135	-$(MKDIR) $(subst /,$(PS),$(@D))
136	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
137	@echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
138	@echo $(SQM)  $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
139	@echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)devguide.officedev.samples.filter.FlatXmlDetect$(QM)"$(CSEP) >> $@
140	@echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)com.sun.star.document.ExtendedTypeDetection$(QM)"/$(CSEP) >> $@
141	@echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
142	@echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
143	@echo $(OSEP)/components$(CSEP) >> $@
144
145# rule for component package file
146$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) FlatXmlTypeDetection.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
147	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
148	-$(MKDIR) $(subst /,$(PS),$(@D))
149	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
150	$(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
151	$(SDK_ZIP) $@ FlatXmlTypeDetection.xcu
152	cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_NAME).components
153	cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(UNOPKG_PLATFORM)/$(<F)
154	cd $(subst /,$(PS),$(OUT_COMP_GEN)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
155
156$(REGISTERFLAG) : $(COMP_PACKAGE)
157ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
158	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
159	-$(MKDIR) $(subst /,$(PS),$(@D))
160	$(DEPLOYTOOL) $(COMP_PACKAGE_URL)
161	@echo flagged > $(subst /,$(PS),$@)
162else
163	@echo --------------------------------------------------------------------------------
164	@echo  If you want to install your component automatically, please set the environment
165	@echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
166	@echo  possible if no office instance is running.
167	@echo --------------------------------------------------------------------------------
168endif
169
170XMLFilterDetect : $(REGISTERFLAG)
171	@echo --------------------------------------------------------------------------------
172	@echo The FlatXMLFilterDetection component is installed if SDK_AUTO_DEPLOYMENT = YES.
173	@echo You will use this component implicitly in your office installation when you have
174	@echo installed a FlatXMLFilter component C++ or Java.
175	@echo --------------------------------------------------------------------------------
176
177.PHONY: clean
178clean :
179	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
180	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
181	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
182	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
183	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_COMPONENTS))
184	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG)))
185	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
186