xref: /AOO41X/main/odk/examples/cpp/complextoolbarcontrols/Makefile (revision ff0525f24f03981d56b7579b645949f111420994)
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 complextoolbarcontrols C++ component 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=complextoolbarcontrols
33COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
34OUT_COMP_INC=$(OUT_INC)/$(COMP_NAME)
35OUT_COMP_GEN=$(OUT_MISC)/$(COMP_NAME)
36OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
37COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
38COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
39COMP_UNOPKG_MANIFEST = $(OUT_COMP_GEN)/$(COMP_NAME)/META-INF/manifest.xml
40COMP_MAPFILE = $(OUT_COMP_GEN)/$(COMP_NAME).uno.map
41COMP_COMPONENTS = $(OUT_COMP_GEN)/$(COMP_NAME).components
42COMP_REGISTERFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_register_component.flag
43COMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
44
45CXXFILES = \
46           MyProtocolHandler.cxx \
47           MyJob.cxx \
48           MyListener.cxx \
49           WriterListener.cxx \
50           CalcListener.cxx \
51           ListenerHelper.cxx \
52           exports.cxx
53
54SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
55
56# Add OSL_DEBUG_LEVEL to compiler the flags (for OSL_TRACE et. al.)
57ifeq "$(DEBUG)" "yes"
58CC_FLAGS += -DOSL_DEBUG_LEVEL=2
59endif
60
61# Targets
62.PHONY: ALL
63ALL : \
64    Example
65
66include $(SETTINGS)/stdtarget.mk
67
68$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
69    -$(MKDIR) $(subst /,$(PS),$(@D))
70    $(CC) $(CC_FLAGS) $(STL_INCLUDES) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
71
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) $(COMP_MAPFILE)
90$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
91    -$(MKDIR) $(subst /,$(PS),$(@D))
92    $(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
93    $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
94ifeq "$(OS)" "MACOSX"
95    $(INSTALL_NAME_URELIBS)  $@
96endif
97endif
98
99# rule for component package manifest
100$(OUT_COMP_GEN)/%/manifest.xml :
101    -$(MKDIR) $(subst /,$(PS),$(@D))
102    @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
103    @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
104    @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
105    @echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
106    @echo $(SQM)                       $(SQM)manifest:full-path="$(QM)Addons.xcu$(QM)"/$(CSEP) >> $@
107    @echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
108    @echo $(SQM)                       $(SQM)manifest:full-path="$(QM)WriterWindowState.xcu$(QM)"/$(CSEP) >> $@
109    @echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:meda-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
110    @echo $(SQM)                       $(SQM)manifest:full-path="$(QM)CalcWindowState.xcu$(QM)"/$(CSEP) >> $@
111    @echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
112    @echo $(SQM)                       $(SQM)manifest:full-path="$(QM)ProtocolHandler.xcu$(QM)"/$(CSEP) >> $@
113    @echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@
114    @echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@
115
116#   @echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-component;type=native;platform=$(UNOPKG_PLATFORM)$(QM)" >> $@
117#   @echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_GEN)/,,$(UNOPKG_PLATFORM)/$(@D))).uno.$(SHAREDLIB_EXT)$(QM)"/$(CSEP) >> $@
118    @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
119
120$(COMP_COMPONENTS) :
121    -$(MKDIR) $(subst /,$(PS),$(@D))
122    @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
123    @echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
124    @echo $(SQM)  $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
125    @echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)vnd.My.impl.NewDocListener$(QM)"$(CSEP) >> $@
126    @echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)vnd.My.NewDocListener$(QM)"/$(CSEP) >> $@
127    @echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
128    @echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)vnd.demo.Impl.ProtocolHandler$(QM)"$(CSEP) >> $@
129    @echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)vnd.demo.ProtocolHandler$(QM)"/$(CSEP) >> $@
130    @echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
131    @echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
132    @echo $(OSEP)/components$(CSEP) >> $@
133
134# rule for component package file
135$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) Addons.xcu ProtocolHandler.xcu WriterWindowState.xcu CalcWindowState.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
136    -$(MKDIR) $(subst /,$(PS),$(@D)) && $(DEL) $(subst \\,\,$(subst /,$(PS),$@))
137    -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
138    $(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
139    cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_NAME).components
140    cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(UNOPKG_PLATFORM)/$(<F)
141    $(SDK_ZIP) -u $@ Addons.xcu ProtocolHandler.xcu WriterWindowState.xcu CalcWindowState.xcu logo_small.png logo_big.png
142    cd $(subst /,$(PS),$(OUT_COMP_GEN)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
143
144$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
145ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
146    -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
147    $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
148    @echo flagged > $(subst /,$(PS),$@)
149else
150    @echo --------------------------------------------------------------------------------
151    @echo  If you want to install your component automatically, please set the environment
152    @echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
153    @echo  possible if no office instance is running.
154    @echo --------------------------------------------------------------------------------
155endif
156
157Example : $(COMP_REGISTERFLAG)
158    @echo --------------------------------------------------------------------------------
159    @echo The "$(QM)ProtocolHandler$(QM)" addon component was installed if SDK_AUTO_DEPLOYMENT = YES.
160    @echo You can use this component inside your office installation, see the example
161    @echo description.
162    @echo --------------------------------------------------------------------------------
163
164run: $(COMP1_COMP_REGISTERFLAG)
165    "$(OFFICE_PROGRAM_PATH)$(PS)soffice" -writer
166
167
168.PHONY: clean
169clean :
170    -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
171    -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
172    -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
173    -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
174    -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_REGISTERFLAG)))
175    -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
176    -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
177