xref: /aoo41x/main/odk/examples/cpp/counter/Makefile (revision 34dd1e25)
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#*************************************************************************
23#
24#  The Contents of this file are made available subject to the terms of
25#  the BSD license.
26#
27#  Copyright 2000, 2010 Oracle and/or its affiliates.
28#  All rights reserved.
29#
30#  Redistribution and use in source and binary forms, with or without
31#  modification, are permitted provided that the following conditions
32#  are met:
33#  1. Redistributions of source code must retain the above copyright
34#     notice, this list of conditions and the following disclaimer.
35#  2. Redistributions in binary form must reproduce the above copyright
36#     notice, this list of conditions and the following disclaimer in the
37#     documentation and/or other materials provided with the distribution.
38#  3. Neither the name of Sun Microsystems, Inc. nor the names of its
39#     contributors may be used to endorse or promote products derived
40#     from this software without specific prior written permission.
41#
42#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
45#  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
46#  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
47#  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
48#  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
49#  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
50#  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
51#  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
52#  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53#
54#**************************************************************************
55
56# Builds the C++ counter example of the SDK.
57
58PRJ=../../..
59SETTINGS=$(PRJ)/settings
60
61include $(SETTINGS)/settings.mk
62include $(SETTINGS)/std.mk
63include $(SETTINGS)/dk.mk
64
65# Define non-platform/compiler specific settings
66COMP_NAME=counter
67COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
68COMP_IMPL=$(SHAREDLIB_OUT)/$(COMP_IMPL_NAME)
69COMP_RDB_NAME = $(COMP_NAME).uno.rdb
70COMP_RDB = $(OUT_BIN)/$(COMP_RDB_NAME)
71OUT_COMP_INC = $(OUT_INC)/$(COMP_NAME)
72OUT_COMP_GEN = $(OUT_MISC)/$(COMP_NAME)
73OUT_COMP_OBJ = $(OUT_OBJ)/$(COMP_NAME)
74OUT_COMP_SLO = $(OUT_SLO)/$(COMP_NAME)
75COMP_SERVICES=$(SHAREDLIB_OUT)/counterservices.rdb
76
77ENV_EXAMPLE_TYPES=-env:URE_MORE_TYPES=$(URLPREFIX)$(COMP_RDB)
78ENV_COMP_SERVICES=-env:URE_MORE_SERVICES=$(URLPREFIX)$(COMP_SERVICES)
79
80COMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
81
82IDLFILES = XCountable.idl
83
84COMPCXXFILES = counter.cxx
85
86CXXFILES = countermain.cxx
87
88SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(COMPCXXFILES))
89OBJFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
90
91GENURDFILES = $(patsubst %.idl,$(OUT_COMP_GEN)/%.urd,$(IDLFILES))
92
93TYPESLIST = -Tfoo.XCountable
94
95# Targets
96.PHONY: ALL
97ALL : \
98	CppCounterExample
99
100include $(SETTINGS)/stdtarget.mk
101
102$(OUT_COMP_GEN)/%.urd : %.idl
103	-$(MKDIR) $(subst /,$(PS),$(@D))
104	$(IDLC) -I. -I$(IDL_DIR) -O$(OUT_COMP_GEN) $<
105
106# This example type library will be extended by the URE types
107$(OUT_BIN)/%.rdb : $(GENURDFILES)
108	-$(MKDIR) $(subst /,$(PS),$(@D))
109	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
110	$(REGMERGE) $@ /UCR $(GENURDFILES)
111#	$(REGMERGE) $@ / $(URE_TYPES)
112
113$(COMP_TYPEFLAG) : $(COMP_RDB) $(SDKTYPEFLAG)
114	-$(MKDIR) $(subst /,$(PS),$(@D))
115	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
116	$(CPPUMAKER) -Gc -BUCR -O$(OUT_COMP_INC) $(TYPESLIST) $(COMP_RDB) -X $(URE_TYPES)
117	echo flagged > $@
118
119$(OUT_COMP_OBJ)/%.$(OBJ_EXT) : %.cxx $(COMP_TYPEFLAG)
120	-$(MKDIR) $(subst /,$(PS),$(OUT_OBJ))
121	-$(MKDIR) $(subst /,$(PS),$(@D))
122	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
123
124$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(COMP_TYPEFLAG)
125	-$(MKDIR) $(subst /,$(PS),$(OUT_SLO))
126	-$(MKDIR) $(subst /,$(PS),$(@D))
127	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
128
129ifeq "$(OS)" "WIN"
130$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
131	-$(MKDIR) $(subst /,$(PS),$(@D))
132	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
133	$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
134	/MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
135	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
136	$(LINK_MANIFEST)
137else
138$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
139	-$(MKDIR) $(subst /,$(PS),$(@D))
140	$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
141	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
142ifeq "$(OS)" "MACOSX"
143	$(INSTALL_NAME_URELIBS)  $@
144endif
145endif
146
147$(OUT_BIN)/countermain$(EXE_EXT) : $(OUT_COMP_OBJ)/countermain.$(OBJ_EXT) $(SHAREDLIB_OUT)/counter.uno.$(SHAREDLIB_EXT)
148ifeq "$(OS)" "WIN"
149	-$(MKDIR) $(subst /,$(PS),$(@D))
150	$(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(OUT_COMP_GEN)/$(basename $(@F)).map \
151	  $< $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB)
152else
153	-$(MKDIR) $(subst /,$(PS),$(@D))
154	$(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \
155	  $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) $(STDC++LIB)
156endif
157
158$(COMP_SERVICES) :
159	-$(MKDIR) $(subst /,$(PS),$(@D))
160	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
161	@echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
162	@echo $(SQM)  $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
163	@echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)com.sun.star.comp.example.cpp.Counter$(QM)"$(CSEP) >> $@
164	@echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)foo.Counter$(QM)"/$(CSEP) >> $@
165	@echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
166	@echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
167	@echo $(OSEP)/components$(CSEP) >> $@
168
169
170CppCounterExample : $(OUT_BIN)/countermain$(EXE_EXT) $(COMP_IMPL) $(COMP_SERVICES)
171	@echo --------------------------------------------------------------------------------
172	@echo Please use the following command to execute the example!
173	@echo -
174	@echo $(MAKE) countermain.run
175	@echo -
176	@echo NOTE: The example makes use of the URE and use the defaultBootstrap_InitialComponentContext method.
177	@echo $(SQM)      $(SQM)The additional example IDL types are provided via the UNO environment variable -env:URE_MORE_TYPES=...
178	@echo $(SQM)      $(SQM)and the example component is made available via -env:URE_MORE_SERVICES=...
179	@echo $(SQM)      $(SQM)Please check the generated $(QM)$(COMP_SERVICES)$(QM) to see how you can specify your own components in such an environment
180	@echo $(SQM)      $(SQM)and how to use the passive UNO registration.
181	@echo --------------------------------------------------------------------------------
182
183%.run: $(OUT_BIN)/countermain$(EXE_EXT) $(COMP_IMPL)
184	cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@) $(ENV_EXAMPLE_TYPES) $(ENV_COMP_SERVICES)
185
186.PHONY: clean
187clean :
188	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
189	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
190	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_OBJ))
191	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
192	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
193	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_RDB)))
194	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
195	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/countermain*))
196	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_SERVICES)))
197