1abfe7a5aSAriel Constenla-Haile#**************************************************************
2b591cb74SAriel Constenla-Haile#
3abfe7a5aSAriel Constenla-Haile#  Licensed to the Apache Software Foundation (ASF) under one
4abfe7a5aSAriel Constenla-Haile#  or more contributor license agreements.  See the NOTICE file
5abfe7a5aSAriel Constenla-Haile#  distributed with this work for additional information
6abfe7a5aSAriel Constenla-Haile#  regarding copyright ownership.  The ASF licenses this file
7abfe7a5aSAriel Constenla-Haile#  to you under the Apache License, Version 2.0 (the
8abfe7a5aSAriel Constenla-Haile#  "License"); you may not use this file except in compliance
9abfe7a5aSAriel Constenla-Haile#  with the License.  You may obtain a copy of the License at
10b591cb74SAriel Constenla-Haile#
11abfe7a5aSAriel Constenla-Haile#    http://www.apache.org/licenses/LICENSE-2.0
12b591cb74SAriel Constenla-Haile#
13abfe7a5aSAriel Constenla-Haile#  Unless required by applicable law or agreed to in writing,
14abfe7a5aSAriel Constenla-Haile#  software distributed under the License is distributed on an
15abfe7a5aSAriel Constenla-Haile#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16abfe7a5aSAriel Constenla-Haile#  KIND, either express or implied.  See the License for the
17abfe7a5aSAriel Constenla-Haile#  specific language governing permissions and limitations
18abfe7a5aSAriel Constenla-Haile#  under the License.
19b591cb74SAriel Constenla-Haile#
20abfe7a5aSAriel Constenla-Haile#**************************************************************
21abfe7a5aSAriel Constenla-Haile
22abfe7a5aSAriel Constenla-Haile# Builds the custom-tool-panel C++ component example of the SDK.
23abfe7a5aSAriel Constenla-Haile
24abfe7a5aSAriel Constenla-HailePRJ=../../..
25abfe7a5aSAriel Constenla-HaileSETTINGS=$(PRJ)/settings
26abfe7a5aSAriel Constenla-Haile
27abfe7a5aSAriel Constenla-Haileinclude $(SETTINGS)/settings.mk
28abfe7a5aSAriel Constenla-Haileinclude $(SETTINGS)/std.mk
29abfe7a5aSAriel Constenla-Haileinclude $(SETTINGS)/dk.mk
30abfe7a5aSAriel Constenla-Haile
31abfe7a5aSAriel Constenla-Haile# Define non-platform/compiler specific settings
32abfe7a5aSAriel Constenla-HaileCOMP_NAME=custom-tool-panel
33abfe7a5aSAriel Constenla-HaileCOMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
34abfe7a5aSAriel Constenla-HaileOUT_COMP_INC=$(OUT_INC)/$(COMP_NAME)
35abfe7a5aSAriel Constenla-HaileOUT_COMP_GEN=$(OUT_MISC)/$(COMP_NAME)
36abfe7a5aSAriel Constenla-HaileOUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
37abfe7a5aSAriel Constenla-HaileCOMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
38abfe7a5aSAriel Constenla-HaileCOMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
39abfe7a5aSAriel Constenla-HaileCOMP_UNOPKG_MANIFEST = $(OUT_COMP_GEN)/$(COMP_NAME)/META-INF/manifest.xml
40abfe7a5aSAriel Constenla-HaileCOMP_MAPFILE = $(OUT_COMP_GEN)/$(COMP_NAME).uno.map
41abfe7a5aSAriel Constenla-HaileCOMP_COMPONENTS = $(OUT_COMP_GEN)/$(COMP_NAME).components
42abfe7a5aSAriel Constenla-HaileCOMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
43abfe7a5aSAriel Constenla-Haile
44abfe7a5aSAriel Constenla-Haile# Allow deploying the extension when running it
45abfe7a5aSAriel Constenla-HaileOUT_COMP_DEPLOY=$(OUT_DEPLOY)/$(COMP_NAME)
46abfe7a5aSAriel Constenla-HaileOUT_DEPLOY_DIR=$(subst /,$(PS),$(OUT_COMP_DEPLOY))
47b591cb74SAriel Constenla-HaileOUT_DEPLOY_URL=$(URLPREFIX)$(OUT_COMP_DEPLOY)
48abfe7a5aSAriel Constenla-HaileENV_USER_INSTALL=-env:"UserInstallation=$(OUT_DEPLOY_URL)"
49abfe7a5aSAriel Constenla-HaileOFFICE_START_OPTIONS=-nologo -nofirststartwizard -norestore -writer
50abfe7a5aSAriel Constenla-HaileOXT_DEPLOYEDFLAG=$(OUT_MISC)/cpp_$(COMP_NAME)_deployed_oxt.flag
51abfe7a5aSAriel Constenla-Haile
52abfe7a5aSAriel Constenla-HaileCXXFILES = \
53abfe7a5aSAriel Constenla-Haile           ctp_factory.cxx \
54abfe7a5aSAriel Constenla-Haile           ctp_panel.cxx \
55abfe7a5aSAriel Constenla-Haile           ctp_services.cxx
56abfe7a5aSAriel Constenla-Haile
57abfe7a5aSAriel Constenla-HaileSLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
58abfe7a5aSAriel Constenla-Haile
59abfe7a5aSAriel Constenla-Haile
60abfe7a5aSAriel Constenla-Haile# Targets
61abfe7a5aSAriel Constenla-Haile.PHONY: ALL
62abfe7a5aSAriel Constenla-HaileALL : \
63abfe7a5aSAriel Constenla-Haile	CustomToolPanelExample
64abfe7a5aSAriel Constenla-Haile
65abfe7a5aSAriel Constenla-Haileinclude $(SETTINGS)/stdtarget.mk
66abfe7a5aSAriel Constenla-Haile
67abfe7a5aSAriel Constenla-Haile$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
68abfe7a5aSAriel Constenla-Haile	-$(MKDIR) $(subst /,$(PS),$(@D))
69abfe7a5aSAriel Constenla-Haile	$(CC) $(CC_FLAGS) $(STL_INCLUDES) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
70abfe7a5aSAriel Constenla-Haile
71abfe7a5aSAriel Constenla-Haile
72abfe7a5aSAriel Constenla-Haile#$(COMP_MAPFILE) : $(SLOFILES)
73abfe7a5aSAriel Constenla-Haile#	-$(MKDIR) $(subst /,$(PS),$(@D))
74*bc3a3bfcSmseidel#	cat $(PRJ)/settings/component.uno.map > $(COMP_MAPFILE)
75abfe7a5aSAriel Constenla-Haile#ifeq "$(OS)" "MACOSX"
76abfe7a5aSAriel Constenla-Haile#	nm -gx $(SLOFILES) | $(ADDSYMBOLS) >> $(COMP_MAPFILE)
77abfe7a5aSAriel Constenla-Haile#endif
78abfe7a5aSAriel Constenla-Haile
79abfe7a5aSAriel Constenla-Haileifeq "$(OS)" "WIN"
80abfe7a5aSAriel Constenla-Haile$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
81abfe7a5aSAriel Constenla-Haile	-$(MKDIR) $(subst /,$(PS),$(@D))
82abfe7a5aSAriel Constenla-Haile	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
83abfe7a5aSAriel Constenla-Haile	$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
84abfe7a5aSAriel Constenla-Haile	/MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
85abfe7a5aSAriel Constenla-Haile	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
86abfe7a5aSAriel Constenla-Haile	$(LINK_MANIFEST)
87abfe7a5aSAriel Constenla-Haileelse
88abfe7a5aSAriel Constenla-Haile#$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(COMP_MAPFILE)
89abfe7a5aSAriel Constenla-Haile$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
90abfe7a5aSAriel Constenla-Haile	-$(MKDIR) $(subst /,$(PS),$(@D))
91abfe7a5aSAriel Constenla-Haile	$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
92abfe7a5aSAriel Constenla-Haile	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
93abfe7a5aSAriel Constenla-Haileifeq "$(OS)" "MACOSX"
94*bc3a3bfcSmseidel	$(INSTALL_NAME_URELIBS) $@
95abfe7a5aSAriel Constenla-Haileendif
96abfe7a5aSAriel Constenla-Haileendif
97abfe7a5aSAriel Constenla-Haile
98abfe7a5aSAriel Constenla-Haile# rule for component package manifest
99abfe7a5aSAriel Constenla-Haile$(OUT_COMP_GEN)/%/manifest.xml :
100abfe7a5aSAriel Constenla-Haile	-$(MKDIR) $(subst /,$(PS),$(@D))
101abfe7a5aSAriel Constenla-Haile	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
102abfe7a5aSAriel Constenla-Haile	@echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
103abfe7a5aSAriel Constenla-Haile	@echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
104*bc3a3bfcSmseidel	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
105abfe7a5aSAriel Constenla-Haile	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)CalcWindowState.xcu$(QM)"/$(CSEP) >> $@
106abfe7a5aSAriel Constenla-Haile	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
107abfe7a5aSAriel Constenla-Haile	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)DrawWindowState.xcu$(QM)"/$(CSEP) >> $@
108abfe7a5aSAriel Constenla-Haile	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
109abfe7a5aSAriel Constenla-Haile	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)ImpressWindowState.xcu$(QM)"/$(CSEP) >> $@
110abfe7a5aSAriel Constenla-Haile	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
111abfe7a5aSAriel Constenla-Haile	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)WriterWindowState.xcu$(QM)"/$(CSEP) >> $@
112abfe7a5aSAriel Constenla-Haile	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
113abfe7a5aSAriel Constenla-Haile	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)Factories.xcu$(QM)"/$(CSEP) >> $@
114abfe7a5aSAriel Constenla-Haile	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@
115abfe7a5aSAriel Constenla-Haile	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@
116abfe7a5aSAriel Constenla-Haile	@echo $(OSEP)/manifest:manifest$(CSEP) >> $@
117abfe7a5aSAriel Constenla-Haile
118abfe7a5aSAriel Constenla-Haile$(COMP_COMPONENTS) :
119abfe7a5aSAriel Constenla-Haile	-$(MKDIR) $(subst /,$(PS),$(@D))
120abfe7a5aSAriel Constenla-Haile	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
121abfe7a5aSAriel Constenla-Haile	@echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
122abfe7a5aSAriel Constenla-Haile	@echo $(SQM)  $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
123abfe7a5aSAriel Constenla-Haile	@echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)org.openoffice.comp.example.custompanel.ToolPanelFactory$(QM)"$(CSEP) >> $@
124abfe7a5aSAriel Constenla-Haile	@echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)org.openoffice.example.colorpanel.ToolPanelFactory$(QM)"/$(CSEP) >> $@
125abfe7a5aSAriel Constenla-Haile	@echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
126abfe7a5aSAriel Constenla-Haile	@echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
127abfe7a5aSAriel Constenla-Haile	@echo $(OSEP)/components$(CSEP) >> $@
128abfe7a5aSAriel Constenla-Haile
129abfe7a5aSAriel Constenla-Haile# rule for component package file
130abfe7a5aSAriel Constenla-Haile$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) WriterWindowState.xcu CalcWindowState.xcu DrawWindowState.xcu ImpressWindowState.xcu Factories.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
131abfe7a5aSAriel Constenla-Haile	-$(MKDIR) $(subst /,$(PS),$(@D)) && $(DEL) $(subst \\,\,$(subst /,$(PS),$@))
132abfe7a5aSAriel Constenla-Haile	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
133abfe7a5aSAriel Constenla-Haile	$(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
134abfe7a5aSAriel Constenla-Haile	cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_NAME).components
135abfe7a5aSAriel Constenla-Haile	cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(UNOPKG_PLATFORM)/$(<F)
136*bc3a3bfcSmseidel	$(SDK_ZIP) -u $@ WriterWindowState.xcu CalcWindowState.xcu DrawWindowState.xcu ImpressWindowState.xcu Factories.xcu panel.png
137abfe7a5aSAriel Constenla-Haile	cd $(subst /,$(PS),$(OUT_COMP_GEN)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
138abfe7a5aSAriel Constenla-Haile
139abfe7a5aSAriel Constenla-HaileCustomToolPanelExample : $(COMP_PACKAGE)
140abfe7a5aSAriel Constenla-Haile	@echo --------------------------------------------------------------------------------
141abfe7a5aSAriel Constenla-Haile	@echo Please use the following command to deploy the example!
142abfe7a5aSAriel Constenla-Haile	@echo -
143abfe7a5aSAriel Constenla-Haile	@echo $(MAKE) CustomToolPanelExample.run
144abfe7a5aSAriel Constenla-Haile	@echo -
145abfe7a5aSAriel Constenla-Haile	@echo --------------------------------------------------------------------------------
146abfe7a5aSAriel Constenla-Haile
147abfe7a5aSAriel Constenla-HaileCustomToolPanelExample.run: $(OXT_DEPLOYEDFLAG)
148*bc3a3bfcSmseidel	"$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(OFFICE_START_OPTIONS) $(ENV_USER_INSTALL)
149abfe7a5aSAriel Constenla-Haile
150abfe7a5aSAriel Constenla-Haile$(OXT_DEPLOYEDFLAG) : $(COMP_PACKAGE)
151abfe7a5aSAriel Constenla-Haile	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
152abfe7a5aSAriel Constenla-Haile	-$(MKDIR) $(subst /,$(PS),$(OUT_DEPLOY))
153abfe7a5aSAriel Constenla-Haile	-$(MKDIR) $(subst /,$(PS),$(OUT_DEPLOY_DIR))
154abfe7a5aSAriel Constenla-Haile	$(DEPLOYTOOL) $(COMP_PACKAGE_URL) $(ENV_USER_INSTALL)
155abfe7a5aSAriel Constenla-Haile	@echo flagged > $(subst /,$(PS),$@)
156abfe7a5aSAriel Constenla-Haile
157abfe7a5aSAriel Constenla-Haile.PHONY: clean
158abfe7a5aSAriel Constenla-Haileclean :
159abfe7a5aSAriel Constenla-Haile	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
160abfe7a5aSAriel Constenla-Haile	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
161abfe7a5aSAriel Constenla-Haile	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
162abfe7a5aSAriel Constenla-Haile	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_DEPLOY_DIR))
163abfe7a5aSAriel Constenla-Haile	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
164abfe7a5aSAriel Constenla-Haile	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
165abfe7a5aSAriel Constenla-Haile	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(OXT_DEPLOYEDFLAG)))
166abfe7a5aSAriel Constenla-Haile	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
167