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 C++ remoteclient 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=remoteclientsample
33COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
34COMP_IMPL=$(SHAREDLIB_OUT)/$(COMP_IMPL_NAME)
35COMP_RDB_NAME = $(COMP_NAME).uno.rdb
36COMP_RDB = $(OUT_BIN)/$(COMP_RDB_NAME)
37COMP_SERVICES=$(SHAREDLIB_OUT)/remoteclientsample.rdb
38
39ENV_COMP_SERVICES=-env:URE_MORE_SERVICES=$(URLPREFIX)$(COMP_SERVICES)
40
41OUT_COMP_INC=$(OUT_INC)/$(COMP_NAME)
42OUT_COMP_GEN=$(OUT_MISC)/$(COMP_NAME)
43OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
44
45COMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
46
47CXXFILES = remoteclient.cxx
48
49SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
50
51# Targets
52.PHONY: ALL
53ALL : \
54	CppClientExample
55
56include $(SETTINGS)/stdtarget.mk
57
58# This example type library will be extended by the URE types
59$(OUT_BIN)/%.rdb :
60	-$(MKDIR) $(subst /,$(PS),$(@D))
61	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
62	$(REGMERGE) $@ / $(URE_TYPES)
63
64$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
65	-$(MKDIR) $(subst /,$(PS),$(@D))
66	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
67
68ifeq "$(OS)" "WIN"
69$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
70	-$(MKDIR) $(subst /,$(PS),$(@D))
71	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
72	$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
73	/MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
74	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
75	$(LINK_MANIFEST)
76else
77$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
78	-$(MKDIR) $(subst /,$(PS),$(@D))
79	$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
80	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
81ifeq "$(OS)" "MACOSX"
82	$(INSTALL_NAME_URELIBS)  $@
83endif
84endif
85
86$(COMP_SERVICES) :
87	-$(MKDIR) $(subst /,$(PS),$(@D))
88	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
89	@echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
90	@echo $(SQM)  $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
91	@echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)com.sun.star.comp.product.example.RemoteClientSample$(QM)"$(CSEP) >> $@
92	@echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)com.sun.star.bridge.example.RemoteClientSample$(QM)"/$(CSEP) >> $@
93	@echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
94	@echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
95	@echo $(OSEP)/components$(CSEP) >> $@
96
97
98#CppClientExample : $(COMP_IMPL) $(COMP_ENV_FLAG)
99CppClientExample : $(COMP_IMPL) $(COMP_SERVICES)
100	@echo --------------------------------------------------------------------------------
101	@echo The remoteclient C++ component can be used by using the uno binary. Use the
102	@echo the follwong command to start the example. The run target starts a remote
103	@echo server and connect with the client to this server.
104	@echo -
105	@echo $(MAKE) remoteclient.run
106	@echo -
107	@echo NOTE: The example uses the $(QM)uno$(QM) tool to prepare a working UNO environment.
108	@echo $(SQM)      $(SQM)The example component is made available via -env:URE_MORE_SERVICES=...
109	@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	@echo $(SQM)      $(SQM)and how to use the passive UNO registration.
111	@echo --------------------------------------------------------------------------------
112
113%.run: $(COMP_IMPL)
114	@echo Start the remote server process ...
115	@echo -
116ifeq "$(OS)" "WIN"
117	start uno $(ENV_COMP_SERVICES) --singleaccept -s com.sun.star.io.Pipe \
118	-u "uno:socket,host=localhost,port=2083;urp;MyPipe"
119else
120	uno $(ENV_COMP_SERVICES) --singleaccept -s com.sun.star.io.Pipe \
121	-u "uno:socket,host=localhost,port=2083;urp;MyPipe" &
122	@echo waiting on the server process ...
123	sleep 5
124endif
125	@echo -
126	@echo ... remote server process runs ...
127	@echo -
128	@echo Start remote client process ...
129	@echo -
130	uno $(ENV_COMP_SERVICES) -s com.sun.star.bridge.example.RemoteClientSample \
131		-- "uno:socket,host=localhost,port=2083;urp;MyPipe"
132	@echo -
133
134.PHONY: clean
135clean :
136	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
137	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
138	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
139	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
140	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_SERVICES)))
141	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
142#	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/remoteserver.rdb))
143