1*b1cdbd2cSJim Jagielski#**************************************************************
2*b1cdbd2cSJim Jagielski#
3*b1cdbd2cSJim Jagielski#  Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski#  or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski#  distributed with this work for additional information
6*b1cdbd2cSJim Jagielski#  regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski#  to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski#  "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski#  with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski#
11*b1cdbd2cSJim Jagielski#    http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski#
13*b1cdbd2cSJim Jagielski#  Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski#  software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski#  KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski#  specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski#  under the License.
19*b1cdbd2cSJim Jagielski#
20*b1cdbd2cSJim Jagielski#**************************************************************
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski# Builds the C++ remoteclient example of the SDK.
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim JagielskiPRJ=../../..
25*b1cdbd2cSJim JagielskiSETTINGS=$(PRJ)/settings
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/settings.mk
28*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/std.mk
29*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/dk.mk
30*b1cdbd2cSJim Jagielski
31*b1cdbd2cSJim Jagielski# Define non-platform/compiler specific settings
32*b1cdbd2cSJim JagielskiCOMP_NAME=remoteclientsample
33*b1cdbd2cSJim JagielskiCOMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
34*b1cdbd2cSJim JagielskiCOMP_IMPL=$(SHAREDLIB_OUT)/$(COMP_IMPL_NAME)
35*b1cdbd2cSJim JagielskiCOMP_RDB_NAME = $(COMP_NAME).uno.rdb
36*b1cdbd2cSJim JagielskiCOMP_RDB = $(OUT_BIN)/$(COMP_RDB_NAME)
37*b1cdbd2cSJim JagielskiCOMP_SERVICES=$(SHAREDLIB_OUT)/remoteclientsample.rdb
38*b1cdbd2cSJim Jagielski
39*b1cdbd2cSJim JagielskiENV_COMP_SERVICES=-env:URE_MORE_SERVICES=$(URLPREFIX)$(COMP_SERVICES)
40*b1cdbd2cSJim Jagielski
41*b1cdbd2cSJim JagielskiOUT_COMP_INC=$(OUT_INC)/$(COMP_NAME)
42*b1cdbd2cSJim JagielskiOUT_COMP_GEN=$(OUT_MISC)/$(COMP_NAME)
43*b1cdbd2cSJim JagielskiOUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
44*b1cdbd2cSJim Jagielski
45*b1cdbd2cSJim JagielskiCOMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
46*b1cdbd2cSJim Jagielski
47*b1cdbd2cSJim JagielskiCXXFILES = remoteclient.cxx
48*b1cdbd2cSJim Jagielski
49*b1cdbd2cSJim JagielskiSLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
50*b1cdbd2cSJim Jagielski
51*b1cdbd2cSJim Jagielski# Targets
52*b1cdbd2cSJim Jagielski.PHONY: ALL
53*b1cdbd2cSJim JagielskiALL : \
54*b1cdbd2cSJim Jagielski	CppClientExample
55*b1cdbd2cSJim Jagielski
56*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/stdtarget.mk
57*b1cdbd2cSJim Jagielski
58*b1cdbd2cSJim Jagielski# This example type library will be extended by the URE types
59*b1cdbd2cSJim Jagielski$(OUT_BIN)/%.rdb :
60*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
61*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
62*b1cdbd2cSJim Jagielski	$(REGMERGE) $@ / $(URE_TYPES)
63*b1cdbd2cSJim Jagielski
64*b1cdbd2cSJim Jagielski$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
65*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
66*b1cdbd2cSJim Jagielski	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
67*b1cdbd2cSJim Jagielski
68*b1cdbd2cSJim Jagielskiifeq "$(OS)" "WIN"
69*b1cdbd2cSJim Jagielski$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
70*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
71*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
72*b1cdbd2cSJim Jagielski	$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
73*b1cdbd2cSJim Jagielski	/MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
74*b1cdbd2cSJim Jagielski	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
75*b1cdbd2cSJim Jagielski	$(LINK_MANIFEST)
76*b1cdbd2cSJim Jagielskielse
77*b1cdbd2cSJim Jagielski$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
78*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
79*b1cdbd2cSJim Jagielski	$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
80*b1cdbd2cSJim Jagielski	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
81*b1cdbd2cSJim Jagielskiifeq "$(OS)" "MACOSX"
82*b1cdbd2cSJim Jagielski	$(INSTALL_NAME_URELIBS)  $@
83*b1cdbd2cSJim Jagielskiendif
84*b1cdbd2cSJim Jagielskiendif
85*b1cdbd2cSJim Jagielski
86*b1cdbd2cSJim Jagielski$(COMP_SERVICES) :
87*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
88*b1cdbd2cSJim Jagielski	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
89*b1cdbd2cSJim Jagielski	@echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
90*b1cdbd2cSJim Jagielski	@echo $(SQM)  $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
91*b1cdbd2cSJim Jagielski	@echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)com.sun.star.comp.product.example.RemoteClientSample$(QM)"$(CSEP) >> $@
92*b1cdbd2cSJim Jagielski	@echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)com.sun.star.bridge.example.RemoteClientSample$(QM)"/$(CSEP) >> $@
93*b1cdbd2cSJim Jagielski	@echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
94*b1cdbd2cSJim Jagielski	@echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
95*b1cdbd2cSJim Jagielski	@echo $(OSEP)/components$(CSEP) >> $@
96*b1cdbd2cSJim Jagielski
97*b1cdbd2cSJim Jagielski
98*b1cdbd2cSJim Jagielski#CppClientExample : $(COMP_IMPL) $(COMP_ENV_FLAG)
99*b1cdbd2cSJim JagielskiCppClientExample : $(COMP_IMPL) $(COMP_SERVICES)
100*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
101*b1cdbd2cSJim Jagielski	@echo The remoteclient C++ component can be used by using the uno binary. Use the
102*b1cdbd2cSJim Jagielski	@echo the follwong command to start the example. The run target starts a remote
103*b1cdbd2cSJim Jagielski	@echo server and connect with the client to this server.
104*b1cdbd2cSJim Jagielski	@echo -
105*b1cdbd2cSJim Jagielski	@echo $(MAKE) remoteclient.run
106*b1cdbd2cSJim Jagielski	@echo -
107*b1cdbd2cSJim Jagielski	@echo NOTE: The example uses the $(QM)uno$(QM) tool to prepare a working UNO environment.
108*b1cdbd2cSJim Jagielski	@echo $(SQM)      $(SQM)The example component is made available via -env:URE_MORE_SERVICES=...
109*b1cdbd2cSJim Jagielski	@echo $(SQM)      $(SQM)Please check the generated $(QM)$(COMP_SERVICES)$(QM) to see how you can specify your own components in such an environment
110*b1cdbd2cSJim Jagielski	@echo $(SQM)      $(SQM)and how to use the passive UNO registration.
111*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
112*b1cdbd2cSJim Jagielski
113*b1cdbd2cSJim Jagielski%.run: $(COMP_IMPL)
114*b1cdbd2cSJim Jagielski	@echo Start the remote server process ...
115*b1cdbd2cSJim Jagielski	@echo -
116*b1cdbd2cSJim Jagielskiifeq "$(OS)" "WIN"
117*b1cdbd2cSJim Jagielski	start uno $(ENV_COMP_SERVICES) --singleaccept -s com.sun.star.io.Pipe \
118*b1cdbd2cSJim Jagielski	-u "uno:socket,host=localhost,port=2083;urp;MyPipe"
119*b1cdbd2cSJim Jagielskielse
120*b1cdbd2cSJim Jagielski	uno $(ENV_COMP_SERVICES) --singleaccept -s com.sun.star.io.Pipe \
121*b1cdbd2cSJim Jagielski	-u "uno:socket,host=localhost,port=2083;urp;MyPipe" &
122*b1cdbd2cSJim Jagielski	@echo waiting on the server process ...
123*b1cdbd2cSJim Jagielski	sleep 5
124*b1cdbd2cSJim Jagielskiendif
125*b1cdbd2cSJim Jagielski	@echo -
126*b1cdbd2cSJim Jagielski	@echo ... remote server process runs ...
127*b1cdbd2cSJim Jagielski	@echo -
128*b1cdbd2cSJim Jagielski	@echo Start remote client process ...
129*b1cdbd2cSJim Jagielski	@echo -
130*b1cdbd2cSJim Jagielski	uno $(ENV_COMP_SERVICES) -s com.sun.star.bridge.example.RemoteClientSample \
131*b1cdbd2cSJim Jagielski		-- "uno:socket,host=localhost,port=2083;urp;MyPipe"
132*b1cdbd2cSJim Jagielski	@echo -
133*b1cdbd2cSJim Jagielski
134*b1cdbd2cSJim Jagielski.PHONY: clean
135*b1cdbd2cSJim Jagielskiclean :
136*b1cdbd2cSJim Jagielski	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
137*b1cdbd2cSJim Jagielski	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
138*b1cdbd2cSJim Jagielski	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
139*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
140*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_SERVICES)))
141*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
142*b1cdbd2cSJim Jagielski#	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/remoteserver.rdb))
143