xref: /trunk/main/odk/examples/cpp/remoteclient/Makefile (revision ef1ef8e674fabf3a541d12c6e6c14cecdfc2f9e7)
1#*************************************************************************
2#
3#  The Contents of this file are made available subject to the terms of
4#  the BSD license.
5#
6#  Copyright 2000, 2010 Oracle and/or its affiliates.
7#  All rights reserved.
8#
9#  Redistribution and use in source and binary forms, with or without
10#  modification, are permitted provided that the following conditions
11#  are met:
12#  1. Redistributions of source code must retain the above copyright
13#     notice, this list of conditions and the following disclaimer.
14#  2. Redistributions in binary form must reproduce the above copyright
15#     notice, this list of conditions and the following disclaimer in the
16#     documentation and/or other materials provided with the distribution.
17#  3. Neither the name of Sun Microsystems, Inc. nor the names of its
18#     contributors may be used to endorse or promote products derived
19#     from this software without specific prior written permission.
20#
21#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24#  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25#  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26#  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27#  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28#  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29#  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30#  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
31#  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32#
33#**************************************************************************
34
35# Builds the C++ remoteclient example of the SDK.
36
37PRJ=../../..
38SETTINGS=$(PRJ)/settings
39
40include $(SETTINGS)/settings.mk
41include $(SETTINGS)/std.mk
42include $(SETTINGS)/dk.mk
43
44# Define non-platform/compiler specific settings
45COMP_NAME=remoteclientsample
46COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
47COMP_IMPL=$(SHAREDLIB_OUT)/$(COMP_IMPL_NAME)
48COMP_RDB_NAME = $(COMP_NAME).uno.rdb
49COMP_RDB = $(OUT_BIN)/$(COMP_RDB_NAME)
50COMP_SERVICES=$(SHAREDLIB_OUT)/remoteclientsample.rdb
51
52ENV_COMP_SERVICES=-env:URE_MORE_SERVICES=$(URLPREFIX)$(COMP_SERVICES)
53
54OUT_COMP_INC=$(OUT_INC)/$(COMP_NAME)
55OUT_COMP_GEN=$(OUT_MISC)/$(COMP_NAME)
56OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
57
58COMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
59
60CXXFILES = remoteclient.cxx
61
62SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
63
64# Targets
65.PHONY: ALL
66ALL : \
67    CppClientExample
68
69include $(SETTINGS)/stdtarget.mk
70
71# This example type library will be extended by the URE types
72$(OUT_BIN)/%.rdb :
73    -$(MKDIR) $(subst /,$(PS),$(@D))
74    -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
75    $(REGMERGE) $@ / $(URE_TYPES)
76
77$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
78    -$(MKDIR) $(subst /,$(PS),$(@D))
79    $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
80
81ifeq "$(OS)" "WIN"
82$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
83    -$(MKDIR) $(subst /,$(PS),$(@D))
84    -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
85    $(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
86    /MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
87    $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
88    $(LINK_MANIFEST)
89else
90$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
91    -$(MKDIR) $(subst /,$(PS),$(@D))
92    $(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
93    $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
94ifeq "$(OS)" "MACOSX"
95    $(INSTALL_NAME_URELIBS)  $@
96endif
97endif
98
99$(COMP_SERVICES) :
100    -$(MKDIR) $(subst /,$(PS),$(@D))
101    @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
102    @echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
103    @echo $(SQM)  $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
104    @echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)com.sun.star.comp.product.example.RemoteClientSample$(QM)"$(CSEP) >> $@
105    @echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)com.sun.star.bridge.example.RemoteClientSample$(QM)"/$(CSEP) >> $@
106    @echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
107    @echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
108    @echo $(OSEP)/components$(CSEP) >> $@
109
110
111#CppClientExample : $(COMP_IMPL) $(COMP_ENV_FLAG)
112CppClientExample : $(COMP_IMPL) $(COMP_SERVICES)
113    @echo --------------------------------------------------------------------------------
114    @echo The remoteclient C++ component can be used by using the uno binary. Use the
115    @echo the follwong command to start the example. The run target starts a remote
116    @echo server and connect with the client to this server.
117    @echo -
118    @echo $(MAKE) remoteclient.run
119    @echo -
120    @echo NOTE: The example uses the $(QM)uno$(QM) tool to prepare a working UNO environment.
121    @echo $(SQM)      $(SQM)The example component is made available via -env:URE_MORE_SERVICES=...
122    @echo $(SQM)      $(SQM)Please check the generated $(QM)$(COMP_SERVICES)$(QM) to see how you can specify your own components in such an environment
123    @echo $(SQM)      $(SQM)and how to use the passive UNO registration.
124    @echo --------------------------------------------------------------------------------
125
126%.run: $(COMP_IMPL)
127    @echo Start the remote server process ...
128    @echo -
129ifeq "$(OS)" "WIN"
130    start uno $(ENV_COMP_SERVICES) --singleaccept -s com.sun.star.io.Pipe \
131    -u "uno:socket,host=localhost,port=2083;urp;MyPipe"
132else
133    uno $(ENV_COMP_SERVICES) --singleaccept -s com.sun.star.io.Pipe \
134    -u "uno:socket,host=localhost,port=2083;urp;MyPipe" &
135    @echo waiting on the server process ...
136    sleep 5
137endif
138    @echo -
139    @echo ... remote server process runs ...
140    @echo -
141    @echo Start remote client process ...
142    @echo -
143    uno $(ENV_COMP_SERVICES) -s com.sun.star.bridge.example.RemoteClientSample \
144        -- "uno:socket,host=localhost,port=2083;urp;MyPipe"
145    @echo -
146
147.PHONY: clean
148clean :
149    -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
150    -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
151    -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
152    -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
153    -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_SERVICES)))
154    -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
155#   -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/remoteserver.rdb))
156