xref: /AOO41X/main/odk/examples/cpp/remoteclient/Makefile (revision 03c97e340010506c11d4ffaab7f577e5f7050fe6)
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++ remoteclient 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=remoteclientsample
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)
71COMP_SERVICES=$(SHAREDLIB_OUT)/remoteclientsample.rdb
72
73ENV_COMP_SERVICES=-env:URE_MORE_SERVICES=$(URLPREFIX)$(COMP_SERVICES)
74
75OUT_COMP_INC=$(OUT_INC)/$(COMP_NAME)
76OUT_COMP_GEN=$(OUT_MISC)/$(COMP_NAME)
77OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
78
79COMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
80
81CXXFILES = remoteclient.cxx
82
83SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
84
85# Targets
86.PHONY: ALL
87ALL : \
88    CppClientExample
89
90include $(SETTINGS)/stdtarget.mk
91
92# This example type library will be extended by the URE types
93$(OUT_BIN)/%.rdb :
94    -$(MKDIR) $(subst /,$(PS),$(@D))
95    -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
96    $(REGMERGE) $@ / $(URE_TYPES)
97
98$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
99    -$(MKDIR) $(subst /,$(PS),$(@D))
100    $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
101
102ifeq "$(OS)" "WIN"
103$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
104    -$(MKDIR) $(subst /,$(PS),$(@D))
105    -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
106    $(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
107    /MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
108    $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
109    $(LINK_MANIFEST)
110else
111$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
112    -$(MKDIR) $(subst /,$(PS),$(@D))
113    $(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
114    $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
115ifeq "$(OS)" "MACOSX"
116    $(INSTALL_NAME_URELIBS)  $@
117endif
118endif
119
120$(COMP_SERVICES) :
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)$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
125    @echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)com.sun.star.comp.product.example.RemoteClientSample$(QM)"$(CSEP) >> $@
126    @echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)com.sun.star.bridge.example.RemoteClientSample$(QM)"/$(CSEP) >> $@
127    @echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
128    @echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
129    @echo $(OSEP)/components$(CSEP) >> $@
130
131
132#CppClientExample : $(COMP_IMPL) $(COMP_ENV_FLAG)
133CppClientExample : $(COMP_IMPL) $(COMP_SERVICES)
134    @echo --------------------------------------------------------------------------------
135    @echo The remoteclient C++ component can be used by using the uno binary. Use the
136    @echo the follwong command to start the example. The run target starts a remote
137    @echo server and connect with the client to this server.
138    @echo -
139    @echo $(MAKE) remoteclient.run
140    @echo -
141    @echo NOTE: The example uses the $(QM)uno$(QM) tool to prepare a working UNO environment.
142    @echo $(SQM)      $(SQM)The example component is made available via -env:URE_MORE_SERVICES=...
143    @echo $(SQM)      $(SQM)Please check the generated $(QM)$(COMP_SERVICES)$(QM) to see how you can specify your own components in such an environment
144    @echo $(SQM)      $(SQM)and how to use the passive UNO registration.
145    @echo --------------------------------------------------------------------------------
146
147%.run: $(COMP_IMPL)
148    @echo Start the remote server process ...
149    @echo -
150ifeq "$(OS)" "WIN"
151    start uno $(ENV_COMP_SERVICES) --singleaccept -s com.sun.star.io.Pipe \
152    -u "uno:socket,host=localhost,port=2083;urp;MyPipe"
153else
154    uno $(ENV_COMP_SERVICES) --singleaccept -s com.sun.star.io.Pipe \
155    -u "uno:socket,host=localhost,port=2083;urp;MyPipe" &
156    @echo waiting on the server process ...
157    sleep 5
158endif
159    @echo -
160    @echo ... remote server process runs ...
161    @echo -
162    @echo Start remote client process ...
163    @echo -
164    uno $(ENV_COMP_SERVICES) -s com.sun.star.bridge.example.RemoteClientSample \
165        -- "uno:socket,host=localhost,port=2083;urp;MyPipe"
166    @echo -
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_TYPEFLAG)))
174    -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_SERVICES)))
175    -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
176#   -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/remoteserver.rdb))
177