xref: /aoo4110/main/odk/examples/cpp/counter/Makefile (revision b1cdbd2c)
1*b1cdbd2cSJim Jagielski#**************************************************************
2*b1cdbd2cSJim Jagielski#
3*b1cdbd2cSJim Jagielski#  Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski#  or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski#  distributed with this work for additional information
6*b1cdbd2cSJim Jagielski#  regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski#  to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski#  "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski#  with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski#
11*b1cdbd2cSJim Jagielski#    http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski#
13*b1cdbd2cSJim Jagielski#  Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski#  software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski#  KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski#  specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski#  under the License.
19*b1cdbd2cSJim Jagielski#
20*b1cdbd2cSJim Jagielski#**************************************************************
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski# Builds the C++ counter example of the SDK.
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim JagielskiPRJ=../../..
25*b1cdbd2cSJim JagielskiSETTINGS=$(PRJ)/settings
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/settings.mk
28*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/std.mk
29*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/dk.mk
30*b1cdbd2cSJim Jagielski
31*b1cdbd2cSJim Jagielski# Define non-platform/compiler specific settings
32*b1cdbd2cSJim JagielskiCOMP_NAME=counter
33*b1cdbd2cSJim JagielskiCOMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
34*b1cdbd2cSJim JagielskiCOMP_IMPL=$(SHAREDLIB_OUT)/$(COMP_IMPL_NAME)
35*b1cdbd2cSJim JagielskiCOMP_RDB_NAME = $(COMP_NAME).uno.rdb
36*b1cdbd2cSJim JagielskiCOMP_RDB = $(OUT_BIN)/$(COMP_RDB_NAME)
37*b1cdbd2cSJim JagielskiOUT_COMP_INC = $(OUT_INC)/$(COMP_NAME)
38*b1cdbd2cSJim JagielskiOUT_COMP_GEN = $(OUT_MISC)/$(COMP_NAME)
39*b1cdbd2cSJim JagielskiOUT_COMP_OBJ = $(OUT_OBJ)/$(COMP_NAME)
40*b1cdbd2cSJim JagielskiOUT_COMP_SLO = $(OUT_SLO)/$(COMP_NAME)
41*b1cdbd2cSJim JagielskiCOMP_SERVICES=$(SHAREDLIB_OUT)/counterservices.rdb
42*b1cdbd2cSJim Jagielski
43*b1cdbd2cSJim JagielskiENV_EXAMPLE_TYPES=-env:URE_MORE_TYPES=$(URLPREFIX)$(COMP_RDB)
44*b1cdbd2cSJim JagielskiENV_COMP_SERVICES=-env:URE_MORE_SERVICES=$(URLPREFIX)$(COMP_SERVICES)
45*b1cdbd2cSJim Jagielski
46*b1cdbd2cSJim JagielskiCOMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
47*b1cdbd2cSJim Jagielski
48*b1cdbd2cSJim JagielskiIDLFILES = XCountable.idl
49*b1cdbd2cSJim Jagielski
50*b1cdbd2cSJim JagielskiCOMPCXXFILES = counter.cxx
51*b1cdbd2cSJim Jagielski
52*b1cdbd2cSJim JagielskiCXXFILES = countermain.cxx
53*b1cdbd2cSJim Jagielski
54*b1cdbd2cSJim JagielskiSLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(COMPCXXFILES))
55*b1cdbd2cSJim JagielskiOBJFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
56*b1cdbd2cSJim Jagielski
57*b1cdbd2cSJim JagielskiGENURDFILES = $(patsubst %.idl,$(OUT_COMP_GEN)/%.urd,$(IDLFILES))
58*b1cdbd2cSJim Jagielski
59*b1cdbd2cSJim JagielskiTYPESLIST = -Tfoo.XCountable
60*b1cdbd2cSJim Jagielski
61*b1cdbd2cSJim Jagielski# Targets
62*b1cdbd2cSJim Jagielski.PHONY: ALL
63*b1cdbd2cSJim JagielskiALL : \
64*b1cdbd2cSJim Jagielski	CppCounterExample
65*b1cdbd2cSJim Jagielski
66*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/stdtarget.mk
67*b1cdbd2cSJim Jagielski
68*b1cdbd2cSJim Jagielski$(OUT_COMP_GEN)/%.urd : %.idl
69*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
70*b1cdbd2cSJim Jagielski	$(IDLC) -I. -I$(IDL_DIR) -O$(OUT_COMP_GEN) $<
71*b1cdbd2cSJim Jagielski
72*b1cdbd2cSJim Jagielski# This example type library will be extended by the URE types
73*b1cdbd2cSJim Jagielski$(OUT_BIN)/%.rdb : $(GENURDFILES)
74*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
75*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
76*b1cdbd2cSJim Jagielski	$(REGMERGE) $@ /UCR $(GENURDFILES)
77*b1cdbd2cSJim Jagielski#	$(REGMERGE) $@ / $(URE_TYPES)
78*b1cdbd2cSJim Jagielski
79*b1cdbd2cSJim Jagielski$(COMP_TYPEFLAG) : $(COMP_RDB) $(SDKTYPEFLAG)
80*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
81*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
82*b1cdbd2cSJim Jagielski	$(CPPUMAKER) -Gc -BUCR -O$(OUT_COMP_INC) $(TYPESLIST) $(COMP_RDB) -X $(URE_TYPES)
83*b1cdbd2cSJim Jagielski	echo flagged > $@
84*b1cdbd2cSJim Jagielski
85*b1cdbd2cSJim Jagielski$(OUT_COMP_OBJ)/%.$(OBJ_EXT) : %.cxx $(COMP_TYPEFLAG)
86*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(OUT_OBJ))
87*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
88*b1cdbd2cSJim Jagielski	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
89*b1cdbd2cSJim Jagielski
90*b1cdbd2cSJim Jagielski$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(COMP_TYPEFLAG)
91*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(OUT_SLO))
92*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
93*b1cdbd2cSJim Jagielski	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
94*b1cdbd2cSJim Jagielski
95*b1cdbd2cSJim Jagielskiifeq "$(OS)" "WIN"
96*b1cdbd2cSJim Jagielski$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
97*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
98*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
99*b1cdbd2cSJim Jagielski	$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
100*b1cdbd2cSJim Jagielski	/MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
101*b1cdbd2cSJim Jagielski	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
102*b1cdbd2cSJim Jagielski	$(LINK_MANIFEST)
103*b1cdbd2cSJim Jagielskielse
104*b1cdbd2cSJim Jagielski$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
105*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
106*b1cdbd2cSJim Jagielski	$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
107*b1cdbd2cSJim Jagielski	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
108*b1cdbd2cSJim Jagielskiifeq "$(OS)" "MACOSX"
109*b1cdbd2cSJim Jagielski	$(INSTALL_NAME_URELIBS)  $@
110*b1cdbd2cSJim Jagielskiendif
111*b1cdbd2cSJim Jagielskiendif
112*b1cdbd2cSJim Jagielski
113*b1cdbd2cSJim Jagielski$(OUT_BIN)/countermain$(EXE_EXT) : $(OUT_COMP_OBJ)/countermain.$(OBJ_EXT) $(SHAREDLIB_OUT)/counter.uno.$(SHAREDLIB_EXT)
114*b1cdbd2cSJim Jagielskiifeq "$(OS)" "WIN"
115*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
116*b1cdbd2cSJim Jagielski	$(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(OUT_COMP_GEN)/$(basename $(@F)).map \
117*b1cdbd2cSJim Jagielski	  $< $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB)
118*b1cdbd2cSJim Jagielskielse
119*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
120*b1cdbd2cSJim Jagielski	$(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \
121*b1cdbd2cSJim Jagielski	  $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) $(STDC++LIB)
122*b1cdbd2cSJim Jagielskiendif
123*b1cdbd2cSJim Jagielski
124*b1cdbd2cSJim Jagielski$(COMP_SERVICES) :
125*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
126*b1cdbd2cSJim Jagielski	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
127*b1cdbd2cSJim Jagielski	@echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
128*b1cdbd2cSJim Jagielski	@echo $(SQM)  $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
129*b1cdbd2cSJim Jagielski	@echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)com.sun.star.comp.example.cpp.Counter$(QM)"$(CSEP) >> $@
130*b1cdbd2cSJim Jagielski	@echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)foo.Counter$(QM)"/$(CSEP) >> $@
131*b1cdbd2cSJim Jagielski	@echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
132*b1cdbd2cSJim Jagielski	@echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
133*b1cdbd2cSJim Jagielski	@echo $(OSEP)/components$(CSEP) >> $@
134*b1cdbd2cSJim Jagielski
135*b1cdbd2cSJim Jagielski
136*b1cdbd2cSJim JagielskiCppCounterExample : $(OUT_BIN)/countermain$(EXE_EXT) $(COMP_IMPL) $(COMP_SERVICES)
137*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
138*b1cdbd2cSJim Jagielski	@echo Please use the following command to execute the example!
139*b1cdbd2cSJim Jagielski	@echo -
140*b1cdbd2cSJim Jagielski	@echo $(MAKE) countermain.run
141*b1cdbd2cSJim Jagielski	@echo -
142*b1cdbd2cSJim Jagielski	@echo NOTE: The example makes use of the URE and use the defaultBootstrap_InitialComponentContext method.
143*b1cdbd2cSJim Jagielski	@echo $(SQM)      $(SQM)The additional example IDL types are provided via the UNO environment variable -env:URE_MORE_TYPES=...
144*b1cdbd2cSJim Jagielski	@echo $(SQM)      $(SQM)and the example component is made available via -env:URE_MORE_SERVICES=...
145*b1cdbd2cSJim Jagielski	@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*b1cdbd2cSJim Jagielski	@echo $(SQM)      $(SQM)and how to use the passive UNO registration.
147*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
148*b1cdbd2cSJim Jagielski
149*b1cdbd2cSJim Jagielski%.run: $(OUT_BIN)/countermain$(EXE_EXT) $(COMP_IMPL)
150*b1cdbd2cSJim Jagielski	cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@) $(ENV_EXAMPLE_TYPES) $(ENV_COMP_SERVICES)
151*b1cdbd2cSJim Jagielski
152*b1cdbd2cSJim Jagielski.PHONY: clean
153*b1cdbd2cSJim Jagielskiclean :
154*b1cdbd2cSJim Jagielski	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
155*b1cdbd2cSJim Jagielski	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
156*b1cdbd2cSJim Jagielski	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_OBJ))
157*b1cdbd2cSJim Jagielski	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
158*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
159*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_RDB)))
160*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
161*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/countermain*))
162*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_SERVICES)))
163