1#*************************************************************************
2#
3#  The Contents of this file are made available subject to the terms of
4#  the BSD license.
5#
6#  Copyright 2000, 2010 Oracle and/or its affiliates.
7#  All rights reserved.
8#
9#  Redistribution and use in source and binary forms, with or without
10#  modification, are permitted provided that the following conditions
11#  are met:
12#  1. Redistributions of source code must retain the above copyright
13#     notice, this list of conditions and the following disclaimer.
14#  2. Redistributions in binary form must reproduce the above copyright
15#     notice, this list of conditions and the following disclaimer in the
16#     documentation and/or other materials provided with the distribution.
17#  3. Neither the name of Sun Microsystems, Inc. nor the names of its
18#     contributors may be used to endorse or promote products derived
19#     from this software without specific prior written permission.
20#
21#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24#  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25#  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26#  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27#  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28#  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29#  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30#  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
31#  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32#
33#**************************************************************************
34
35# Builds the C++ FlatXmlFilter component example of the Developers Guide.
36
37PRJ=../../../../..
38SETTINGS=$(PRJ)/settings
39
40include $(SETTINGS)/settings.mk
41include $(SETTINGS)/std.mk
42include $(SETTINGS)/dk.mk
43
44# Define non-platform/compiler specific settings
45COMP_NAME=FlatXmlFilter_cpp
46COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
47OUT_COMP_INC = $(OUT_INC)/$(COMP_NAME)
48OUT_COMP_GEN = $(OUT_MISC)/$(COMP_NAME)
49OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
50COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
51COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
52COMP_UNOPKG_MANIFEST = $(OUT_COMP_GEN)/$(COMP_NAME)/META-INF/manifest.xml
53#COMP_MAPFILE = $(OUT_COMP_GEN)/$(COMP_NAME).uno.map
54COMP_COMPONENTS = $(OUT_COMP_GEN)/$(COMP_NAME).components
55
56COMP_REGISTERFLAG = $(OUT_MISC)/devguide_$(COMP_NAME)_register_component.flag
57
58CXXFILES = FlatXml.cxx
59
60SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
61
62# Targets
63.PHONY: ALL
64ALL : \
65	FlatXmlFilterCppExample
66
67include $(SETTINGS)/stdtarget.mk
68
69$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
70	-$(MKDIR) $(subst /,$(PS),$(@D))
71	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
72
73#$(COMP_MAPFILE) : $(SLOFILES)
74#	-$(MKDIR) $(subst /,$(PS),$(@D))
75#	cat $(PRJ)/settings/component.uno.map > $(COMP_MAPFILE)
76#ifeq "$(OS)" "MACOSX"
77#	nm -gx $(SLOFILES) | $(ADDSYMBOLS) >> $(COMP_MAPFILE)
78#endif
79
80ifeq "$(OS)" "WIN"
81$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
82	-$(MKDIR) $(subst /,$(PS),$(@D))
83	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
84	$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
85	/MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
86	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
87	$(LINK_MANIFEST)
88else
89$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
90	-$(MKDIR) $(subst /,$(PS),$(@D))
91	$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
92	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
93ifeq "$(OS)" "MACOSX"
94	$(INSTALL_NAME_URELIBS)  $@
95endif
96endif
97
98# rule for component package manifest
99$(OUT_COMP_GEN)/%/manifest.xml :
100	-$(MKDIR) $(subst /,$(PS),$(@D))
101	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
102	@echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
103	@echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
104	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
105	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)FlatXmlFilter_cpp.xcu$(QM)"/$(CSEP) >> $@
106	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@
107	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@
108	@echo $(OSEP)/manifest:manifest$(CSEP) >> $@
109
110$(COMP_COMPONENTS) :
111	-$(MKDIR) $(subst /,$(PS),$(@D))
112	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
113	@echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
114	@echo $(SQM)  $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
115	@echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)devguide.officedev.samples.filter.FlatXmlCpp$(QM)"$(CSEP) >> $@
116	@echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)devguide.officedev.samples.filter.FlatXmlCpp$(QM)"/$(CSEP) >> $@
117	@echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
118	@echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
119	@echo $(OSEP)/components$(CSEP) >> $@
120
121# rule for component package file
122$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) FlatXmlFilter_cpp.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
123	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
124	-$(MKDIR) $(subst /,$(PS),$(@D))
125	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
126	$(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
127	$(SDK_ZIP) $@ FlatXmlFilter_cpp.xcu
128	cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_NAME).components
129	cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(UNOPKG_PLATFORM)/$(<F)
130	cd $(subst /,$(PS),$(OUT_COMP_GEN)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
131
132$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
133ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
134	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
135	-$(MKDIR) $(subst /,$(PS),$(@D))
136	$(DEPLOYTOOL) $(COMP_PACKAGE_URL)
137	@echo flagged > $(subst /,$(PS),$@)
138else
139	@echo --------------------------------------------------------------------------------
140	@echo  If you want to install your component automatically, please set the environment
141	@echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
142	@echo  possible if no office instance is running.
143	@echo --------------------------------------------------------------------------------
144endif
145
146FlatXmlFilterCppExample : $(COMP_REGISTERFLAG)
147	@echo --------------------------------------------------------------------------------
148	@echo The C++ FlatXmlFilter component is installed if SDK_AUTO_DEPLOYMENT = YES.
149	@echo You can use the filters "$(QM)DevGuide FlatXML ...$(QM)" inside your office installation
150	@echo after you have installed the "$(QM)FlatXmlTypeDetection.uno.pkg"$(QM) as well.
151	@echo --------------------------------------------------------------------------------
152
153.PHONY: clean
154clean :
155	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
156	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
157	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
158	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
159	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_COMPONENTS)))
160	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_REGISTERFLAG)))
161	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
162	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
163