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