xref: /trunk/main/odk/examples/cpp/counter/Makefile (revision cdf0e10c)
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++ counter 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=counter
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)
50OUT_COMP_INC = $(OUT_INC)/$(COMP_NAME)
51OUT_COMP_GEN = $(OUT_MISC)/$(COMP_NAME)
52OUT_COMP_OBJ = $(OUT_OBJ)/$(COMP_NAME)
53OUT_COMP_SLO = $(OUT_SLO)/$(COMP_NAME)
54COMP_SERVICES=$(SHAREDLIB_OUT)/counterservices.rdb
55
56ENV_EXAMPLE_TYPES=-env:URE_MORE_TYPES=$(URLPREFIX)$(COMP_RDB)
57ENV_COMP_SERVICES=-env:URE_MORE_SERVICES=$(URLPREFIX)$(COMP_SERVICES)
58
59COMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
60
61IDLFILES = XCountable.idl
62
63COMPCXXFILES = counter.cxx
64
65CXXFILES = countermain.cxx
66
67SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(COMPCXXFILES))
68OBJFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
69
70GENURDFILES = $(patsubst %.idl,$(OUT_COMP_GEN)/%.urd,$(IDLFILES))
71
72TYPESLIST = -Tfoo.XCountable
73
74# Targets
75.PHONY: ALL
76ALL : \
77	CppCounterExample
78
79include $(SETTINGS)/stdtarget.mk
80
81$(OUT_COMP_GEN)/%.urd : %.idl
82	-$(MKDIR) $(subst /,$(PS),$(@D))
83	$(IDLC) -I. -I$(IDL_DIR) -O$(OUT_COMP_GEN) $<
84
85# This example type library will be extended by the URE types
86$(OUT_BIN)/%.rdb : $(GENURDFILES)
87	-$(MKDIR) $(subst /,$(PS),$(@D))
88	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
89	$(REGMERGE) $@ /UCR $(GENURDFILES)
90#	$(REGMERGE) $@ / $(URE_TYPES)
91
92$(COMP_TYPEFLAG) : $(COMP_RDB) $(SDKTYPEFLAG)
93	-$(MKDIR) $(subst /,$(PS),$(@D))
94	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
95	$(CPPUMAKER) -Gc -BUCR -O$(OUT_COMP_INC) $(TYPESLIST) $(COMP_RDB) -X $(URE_TYPES)
96	echo flagged > $@
97
98$(OUT_COMP_OBJ)/%.$(OBJ_EXT) : %.cxx $(COMP_TYPEFLAG)
99	-$(MKDIR) $(subst /,$(PS),$(OUT_OBJ))
100	-$(MKDIR) $(subst /,$(PS),$(@D))
101	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
102
103$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(COMP_TYPEFLAG)
104	-$(MKDIR) $(subst /,$(PS),$(OUT_SLO))
105	-$(MKDIR) $(subst /,$(PS),$(@D))
106	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
107
108ifeq "$(OS)" "WIN"
109$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
110	-$(MKDIR) $(subst /,$(PS),$(@D))
111	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
112	$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
113	/MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
114	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
115	$(LINK_MANIFEST)
116else
117$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
118	-$(MKDIR) $(subst /,$(PS),$(@D))
119	$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
120	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
121ifeq "$(OS)" "MACOSX"
122	$(INSTALL_NAME_URELIBS)  $@
123endif
124endif
125
126$(OUT_BIN)/countermain$(EXE_EXT) : $(OUT_COMP_OBJ)/countermain.$(OBJ_EXT) $(SHAREDLIB_OUT)/counter.uno.$(SHAREDLIB_EXT)
127ifeq "$(OS)" "WIN"
128	-$(MKDIR) $(subst /,$(PS),$(@D))
129	$(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(OUT_COMP_GEN)/$(basename $(@F)).map \
130	  $< $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB)
131else
132	-$(MKDIR) $(subst /,$(PS),$(@D))
133	$(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \
134	  $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) $(STDC++LIB)
135endif
136
137$(COMP_SERVICES) :
138	-$(MKDIR) $(subst /,$(PS),$(@D))
139	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
140	@echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
141	@echo $(SQM)  $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
142	@echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)com.sun.star.comp.example.cpp.Counter$(QM)"$(CSEP) >> $@
143	@echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)foo.Counter$(QM)"/$(CSEP) >> $@
144	@echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
145	@echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
146	@echo $(OSEP)/components$(CSEP) >> $@
147
148
149CppCounterExample : $(OUT_BIN)/countermain$(EXE_EXT) $(COMP_IMPL) $(COMP_SERVICES)
150	@echo --------------------------------------------------------------------------------
151	@echo Please use the following command to execute the example!
152	@echo -
153	@echo $(MAKE) countermain.run
154	@echo -
155	@echo NOTE: The example makes use of the URE and use the defaultBootstrap_InitialComponentContext method.
156	@echo $(SQM)      $(SQM)The additional example IDL types are provided via the UNO environment variable -env:URE_MORE_TYPES=...
157	@echo $(SQM)      $(SQM)and the example component is made available via -env:URE_MORE_SERVICES=...
158	@echo $(SQM)      $(SQM)Please check the generated $(QM)$(COMP_SERVICES)$(QM) to see how you can specify your own components in such an environment
159	@echo $(SQM)      $(SQM)and how to use the passive UNO registration.
160	@echo --------------------------------------------------------------------------------
161
162%.run: $(OUT_BIN)/countermain$(EXE_EXT) $(COMP_IMPL)
163	cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@) $(ENV_EXAMPLE_TYPES) $(ENV_COMP_SERVICES)
164
165.PHONY: clean
166clean :
167	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
168	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
169	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_OBJ))
170	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
171	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
172	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_RDB)))
173	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
174	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/countermain*))
175	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_SERVICES)))
176