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++ DocumentLoader 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
32COMPONENT_NAME=DocumentLoader
33
34OUT_COMP_INC = $(OUT_INC)/$(COMPONENT_NAME)
35OUT_COMP_GEN = $(OUT_MISC)/$(COMPONENT_NAME)
36OUT_COMP_OBJ=$(OUT_OBJ)/$(COMPONENT_NAME)
37
38CXXFILES = DocumentLoader.cxx
39
40OBJFILES = $(patsubst %.cxx,$(OUT_SLO_COMP)/%.$(OBJ_EXT),$(CXXFILES))
41
42ENV_OFFICE_TYPES=-env:URE_MORE_TYPES=$(URLPREFIX)$(OFFICE_TYPES)
43
44# Targets
45.PHONY: ALL
46ALL : \
47	CppDocumentLoaderExample
48
49include $(SETTINGS)/stdtarget.mk
50
51$(OUT_COMP_OBJ)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
52	-$(MKDIR) $(subst /,$(PS),$(@D))
53	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
54
55$(OUT_BIN)/DocumentLoader$(EXE_EXT) : $(OUT_COMP_OBJ)/DocumentLoader.$(OBJ_EXT)
56	-$(MKDIR) $(subst /,$(PS),$(@D))
57	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
58ifeq "$(OS)" "WIN"
59	$(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(OUT_COMP_GEN)/$(basename $(@F)).map \
60	  $< $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB)
61else
62	$(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \
63	  $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) $(STDC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALHELPERDYLIB) $(SALDYLIB)
64ifeq "$(OS)" "MACOSX"
65	$(INSTALL_NAME_URELIBS_BIN)  $@
66endif
67endif
68
69CppDocumentLoaderExample : $(OUT_BIN)/DocumentLoader$(EXE_EXT)
70	@echo --------------------------------------------------------------------------------
71	@echo The example loads the "$(QM)test.odt$(QM)" document in the DocumentLoader example directory.
72	@echo If you want to load your own document, please use:
73	@echo $(SQM)  $(SQM)DocumentLoader -env:URE_MORE_TYPES="$(QM)<fileurl_office_types_rdb>$(QM)" "$(QM)filename$(QM)" [connection_url]
74	@echo -
75	@echo Use the following command to execute the example!
76	@echo -
77	@echo $(MAKE) DocumentLoader.run
78	@echo -
79	@echo NOTE: This example does not use the new UNO bootstrap mechanism, it uses still a socket
80	@echo $(SQM)      $(SQM)connection. The example use the defaultBootstrap_InitialComponentContext method and provides
81	@echo $(SQM)      $(SQM)the additional office types via the UNO environment variable -env:URE_MORE_TYPES=...
82	@echo $(SQM)      $(SQM)Before you can run this example you have to start your office in listening mode.
83	@echo -
84	@echo $(SQM)  $(SQM)soffice "$(QM)-accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager$(QM)"
85	@echo --------------------------------------------------------------------------------
86
87%.run: $(OUT_BIN)/DocumentLoader$(EXE_EXT)
88	cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@) $(ENV_OFFICE_TYPES) $(subst \\,/,$(subst /,$(PS),"$(OO_SDK_HOME)/examples/cpp/DocumentLoader/test.odt"))
89
90.PHONY: clean
91clean :
92	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
93	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
94	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_OBJ))
95	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/DocumentLoader*))
96