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