xref: /trunk/main/odk/examples/cpp/custompanel/Makefile (revision 2752044b)
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 custom-tool-panel 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=custom-tool-panel
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_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
43
44# Allow deploying the extension when running it
45
46#this should be in odk/settings/std.mk
47OUT_DEPLOY=$(OUT)/deploy
48
49OUT_COMP_DEPLOY=$(OUT_DEPLOY)/$(COMP_NAME)
50OUT_DEPLOY_DIR=$(subst /,$(PS),$(OUT_COMP_DEPLOY))
51OUT_DEPLOY_URL=$(URLPREFIX)$(OUT_COMP_DEPLOY)
52ENV_USER_INSTALL=-env:"UserInstallation=$(OUT_DEPLOY_URL)"
53OFFICE_START_OPTIONS=-nologo -nofirststartwizard -norestore -writer
54OXT_DEPLOYEDFLAG=$(OUT_MISC)/cpp_$(COMP_NAME)_deployed_oxt.flag
55
56CXXFILES = \
57           ctp_factory.cxx \
58           ctp_panel.cxx \
59           ctp_services.cxx
60
61SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
62
63
64# Targets
65.PHONY: ALL
66ALL : \
67	CustomToolPanelExample
68
69include $(SETTINGS)/stdtarget.mk
70
71$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
72	-$(MKDIR) $(subst /,$(PS),$(@D))
73	$(CC) $(CC_FLAGS) $(STL_INCLUDES) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
74
75
76#$(COMP_MAPFILE) : $(SLOFILES)
77#	-$(MKDIR) $(subst /,$(PS),$(@D))
78#	cat $(PRJ)/settings/component.uno.map > $(COMP_MAPFILE)
79#ifeq "$(OS)" "MACOSX"
80#	nm -gx $(SLOFILES) | $(ADDSYMBOLS) >> $(COMP_MAPFILE)
81#endif
82
83ifeq "$(OS)" "WIN"
84$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
85	-$(MKDIR) $(subst /,$(PS),$(@D))
86	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
87	$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
88	/MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
89	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
90	$(LINK_MANIFEST)
91else
92#$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(COMP_MAPFILE)
93$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
94	-$(MKDIR) $(subst /,$(PS),$(@D))
95	$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
96	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
97ifeq "$(OS)" "MACOSX"
98	$(INSTALL_NAME_URELIBS)  $@
99endif
100endif
101
102# rule for component package manifest
103$(OUT_COMP_GEN)/%/manifest.xml :
104	-$(MKDIR) $(subst /,$(PS),$(@D))
105	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
106	@echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
107	@echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
108	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:meda-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
109	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)CalcWindowState.xcu$(QM)"/$(CSEP) >> $@
110	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
111	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)DrawWindowState.xcu$(QM)"/$(CSEP) >> $@
112	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
113	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)ImpressWindowState.xcu$(QM)"/$(CSEP) >> $@
114	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
115	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)WriterWindowState.xcu$(QM)"/$(CSEP) >> $@
116	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
117	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)Factories.xcu$(QM)"/$(CSEP) >> $@
118	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@
119	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@
120	@echo $(OSEP)/manifest:manifest$(CSEP) >> $@
121
122$(COMP_COMPONENTS) :
123	-$(MKDIR) $(subst /,$(PS),$(@D))
124	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
125	@echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
126	@echo $(SQM)  $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
127	@echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)org.openoffice.comp.example.custompanel.ToolPanelFactory$(QM)"$(CSEP) >> $@
128	@echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)org.openoffice.example.colorpanel.ToolPanelFactory$(QM)"/$(CSEP) >> $@
129	@echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
130	@echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
131	@echo $(OSEP)/components$(CSEP) >> $@
132
133# rule for component package file
134$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) WriterWindowState.xcu CalcWindowState.xcu DrawWindowState.xcu ImpressWindowState.xcu Factories.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
135	-$(MKDIR) $(subst /,$(PS),$(@D)) && $(DEL) $(subst \\,\,$(subst /,$(PS),$@))
136	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
137	$(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
138	cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_NAME).components
139	cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(UNOPKG_PLATFORM)/$(<F)
140	$(SDK_ZIP) -u $@  WriterWindowState.xcu CalcWindowState.xcu DrawWindowState.xcu ImpressWindowState.xcu Factories.xcu panel.png
141	cd $(subst /,$(PS),$(OUT_COMP_GEN)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
142
143CustomToolPanelExample : $(COMP_PACKAGE)
144	@echo --------------------------------------------------------------------------------
145	@echo Please use the following command to deploy the example!
146	@echo -
147	@echo $(MAKE) CustomToolPanelExample.run
148	@echo -
149	@echo --------------------------------------------------------------------------------
150
151CustomToolPanelExample.run: $(OXT_DEPLOYEDFLAG)
152	"$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(OFFICE_START_OPTIONS)  $(ENV_USER_INSTALL)
153
154$(OXT_DEPLOYEDFLAG) : $(COMP_PACKAGE)
155	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
156	-$(MKDIR) $(subst /,$(PS),$(OUT_DEPLOY))
157	-$(MKDIR) $(subst /,$(PS),$(OUT_DEPLOY_DIR))
158	$(DEPLOYTOOL) $(COMP_PACKAGE_URL) $(ENV_USER_INSTALL)
159	@echo flagged > $(subst /,$(PS),$@)
160
161.PHONY: clean
162clean :
163	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
164	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
165	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
166	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_DEPLOY_DIR))
167	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
168	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
169	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(OXT_DEPLOYEDFLAG)))
170	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
171