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 ProfUNO cpp binding example of the Developers Guide
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
45SAMPLE_NAME=ProfUnoCppBinding
46SAMPLE_INC_OUT = $(OUT_INC)/$(SAMPLE_NAME)
47SAMPLE_GEN_OUT = $(OUT_MISC)/$(SAMPLE_NAME)
48SAMPLE_OBJ_OUT=$(OUT_OBJ)/$(SAMPLE_NAME)
49
50APP1_NAME=office_connect
51APP1_BINARY=$(OUT_BIN)/$(APP1_NAME)$(EXE_EXT)
52
53APP2_NAME=string_samples
54APP2_BINARY=$(OUT_BIN)/$(APP2_NAME)$(EXE_EXT)
55
56ENV_OFFICE_TYPES=-env:URE_MORE_TYPES=$(URLPREFIX)$(OFFICE_TYPES)
57
58CXXFILES = \
59	 office_connect.cxx \
60	 string_samples.cxx
61
62# Targets
63.PHONY: ALL
64ALL : \
65    ProUNOCppBindingExample
66
67include $(SETTINGS)/stdtarget.mk
68
69$(SAMPLE_OBJ_OUT)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
70	-$(MKDIR) $(subst /,$(PS),$(@D))
71	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(SAMPLE_INC_OUT) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
72
73$(OUT_BIN)/%$(EXE_EXT) : $(SAMPLE_OBJ_OUT)/%.$(OBJ_EXT)
74	-$(MKDIR) $(subst /,$(PS),$(@D))
75	-$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
76ifeq "$(OS)" "WIN"
77	$(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(SAMPLE_GEN_OUT)/$(subst $(EXE_EXT),.map,$(@F)) \
78	  $< $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB)
79else
80	$(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \
81	  $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) $(STDC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALHELPERDYLIB) $(SALDYLIB)
82ifeq "$(OS)" "MACOSX"
83	$(INSTALL_NAME_URELIBS_BIN)  $@
84endif
85endif
86
87$(OUT_BIN)/office_connect$(EXE_EXT) : $(SAMPLE_OBJ_OUT)/office_connect.$(OBJ_EXT)
88
89$(OUT_BIN)/string_samples$(EXE_EXT) : $(SAMPLE_OBJ_OUT)/string_samples.$(OBJ_EXT)
90
91ProUNOCppBindingExample : $(APP1_BINARY) $(APP2_BINARY)
92	@echo --------------------------------------------------------------------------------
93	@echo Note: For the "$(QM)$(APP1_NAME)$(QM)" example you need a running office listening
94	@echo $(SQM)      $(SQM)on port 2083. The example use the defaultBootstrap_InitialComponentContext method and provides
95	@echo $(SQM)      $(SQM)the additional office types via the UNO environment variable -env:URE_MORE_TYPES=...
96	@echo $(SQM)      $(SQM)Before you can run this example you have to start your office in listening mode.
97	@echo -
98	@echo $(SQM)  $(SQM)soffice "$(QM)-accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager$(QM)"
99	@echo -----
100	@echo Please use one of the following commands to execute the examples!
101	@echo -
102	@echo $(MAKE) $(APP1_NAME).run
103	@echo $(MAKE) $(APP2_NAME).run
104	@echo --------------------------------------------------------------------------------
105
106%.run: $(OUT_BIN)/%$(EXE_EXT)
107	cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@)
108
109$(API1_NAME).run: $(API1_BINARY)
110	cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@) $(ENV_OFFICE_TYPES)
111
112.PHONY: clean
113clean :
114	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_INC_OUT))
115	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
116	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_OBJ_OUT))
117	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/$(APP1_NAME)*))
118	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/$(APP2_NAME)*))
119