12 ifneq ($(CROSS_COMPILE),)
14 # Build using the cross-tools
15 CC = ${CROSS_COMPILE}gcc${CROSS_COMPILE_SUFFIX}
16 CXX = ${CROSS_COMPILE}g++${CROSS_COMPILE_SUFFIX}
17 AR = ${CROSS_COMPILE}ar${CROSS_COMPILE_SUFFIX}
18 # Cross-linker requires this for linked in shared libs that depend
19 # themselves on other shared libs (not directly linked in)
20 LDFLAGS += -Wl,-rpath-link,$(ACE_ROOT)/lib
22 TAO_IDLFLAGS += -g $(HOST_ROOT)/bin/ace_gperf
23 TAO_IDL = $(HOST_ROOT)/bin/tao_idl
24 TAO_IDL_DEP = $(TAO_IDL)
25 TAO_IDL3_TO_IDL2 = $(HOST_ROOT)/bin/tao_idl3_to_idl2
26 TAO_IDL3_TO_IDL2_DEP = $(TAO_IDL3_TO_IDL2)
27 TAO_IDL3_TO_XMI = $(HOST_ROOT)/bin/tao_idl3_to_xmi
28 TAO_IDL3_TO_XMI_DEP = $(TAO_IDL3_TO_XMI)
29 # make sure to use the target compiler, not the cross-compiler
30 # as preprocessor for the cross-compiled idl tools
31 TAO_IDL_PREPROCESSOR = gcc
37 ifeq ($(tunemodelflag),1)
38 FLAGS_C_CC += -mtune=$(TCPU)
41 ifeq ($(cpumodelflag),1)
42 FLAGS_C_CC += -mcpu=$(TCPU)
45 ifeq ($(archmodelflag),1)
46 FLAGS_C_CC += -march=$(TCPU)
57 # This is needed due to the use of the deprecated auto_ptr class
62 # This is needed due to the use of the deprecated auto_ptr class
67 # This is needed due to the use of the deprecated auto_ptr class
72 # This is needed due to the use of the deprecated auto_ptr class
79 ifeq ($(no_deprecated),1)
80 CCFLAGS += -Wno-deprecated
89 # insure does not pass through the -dumpversion option.
90 CXX_FOR_VERSION_TEST ?= g++
92 CXX_FOR_VERSION_TEST ?= $(CXX)
95 CXX_VERSION := $(shell $(CXX_FOR_VERSION_TEST) -dumpversion)
96 CXX_MACHINE := $(shell $(CXX_FOR_VERSION_TEST) -dumpmachine)
97 ifeq (cmd,$(findstring cmd,$(SHELL)))
98 CXX_MAJOR_VERSION := $(firstword $(subst ., ,$(CXX_VERSION)))
100 CXX_MAJOR_VERSION := $(shell $(CXX_FOR_VERSION_TEST) -dumpversion | sed -e 's/[^0-9\.]//g' | sed -e 's/\..*$$//')
102 ifeq (cmd,$(findstring cmd,$(SHELL)))
103 CXX_MINOR_VERSION := $(word 2,$(subst ., ,$(CXX_VERSION)))
105 CXX_MINOR_VERSION := $(shell $(CXX_FOR_VERSION_TEST) -dumpversion | sed -e 's/[^0-9\.]//g' | sed -e 's/^[0-9]*\.//' | sed -e 's/\..*$$//')
107 ifeq ($(findstring $(CXX_MAJOR_VERSION),1 2 3),$(CXX_MAJOR_VERSION))
113 # If no option has been specified, set templates to automatic
114 # version of the compiler.
116 templates ?= automatic
118 # The correct flags to pass to the linker for ELF dynamic shared library
120 # If the platform file didn't already set versioned_so, default to 1.
123 ifneq ($(versioned_so),0)
124 ifeq ($(with_ld),hpux)
125 SOFLAGS += -Wl,+h -Wl,$(SONAME)
127 ifeq ($(with_ld),aix)
130 SOFLAGS += -Wl,-h -Wl,$(SONAME)
135 ifeq ($(versioned_so),2)
136 FLAGS_C_CC += -DACE_VERSIONED_SO=2
141 CXX_FULL_VERSION := $(shell $(CXX_FOR_VERSION_TEST) --version)
142 gcc_template_instantiation_visibility ?= 0
144 # Only modify LDFLAGS if DLD has been set.
146 ifeq ($(DLD),$(CXX_FOR_VERSION_TEST)) # only try this is we are using ld through gcc
147 LD_FOR_VERSION_TEST = $(shell $(CXX_FOR_VERSION_TEST) -print-prog-name=ld)
149 LD_FOR_VERSION_TEST = $(DLD)
150 endif # DLD = CXX_FOR_VERSION_TEST
151 # The -E option is GNU ld specific
153 GNU_LD := $(shell sh -c '$(LD_FOR_VERSION_TEST) -v 2>&1 | grep -c "GNU ld"')
155 GNU_LD := $(if $(findstring GNU ld,$(shell $(LD_FOR_VERSION_TEST) -v)), 1, 0)
160 STATIC_LINK_FLAG ?= -static
163 ifeq ($(no-optimize-sibling-calls), 1)
164 FLAGS_C_CC += -fno-optimize-sibling-calls
167 ifeq ($(no_strict_aliasing), 1)
168 FLAGS_C_CC += -fno-strict-aliasing
170 ifneq ($(no_strict_aliasing), 0)
171 # if not explicitly disabled enable suppression of strict-aliasing checks by default
172 # for GCC >= 4.2; these checks and the resulting warnings are very controversial and
173 # popular opinion on the web seems to be that it brings little practical value and a
174 # lot of pain to attempt to solve code issues and the best way to deal is to suppress
175 ifeq ($(GXX_4_OR_BETTER), 1)
176 ifneq ($(findstring $(CXX_MAJOR_VERSION).$(CXX_MINOR_VERSION),4.1),$(CXX_MAJOR_VERSION).$(CXX_MINOR_VERSION))
177 FLAGS_C_CC += -fno-strict-aliasing
183 ifeq ($(shared_libs), 1)
184 ifneq ($(static_libs_only), 1)
185 # Add all symbols to the dynamic symbol table. Needed to enable
186 # dynamic_cast<> for shared libraries. (see
187 # http://gcc.gnu.org/faq.html#dso)
190 # Make sure this version of ld supports the -E option.
192 LD_EXPORT_DEFINED := $(shell sh -c '$(LD_FOR_VERSION_TEST) -E 2>&1 | egrep -i "(option|flag)" /dev/null; echo $$?')
194 LD_EXPORT_DEFINED := $(shell $(LD_FOR_VERSION_TEST) -E 2>&1 | grep -c -i -e '(option|flag)')
195 ifeq ($(LD_EXPORT_DEFINED),0)
201 ifeq ($(LD_EXPORT_DEFINED),1)
203 endif # LD_EXPORT_DEFINED = 1
206 # Take advantage of G++ (>= 4.x) visibility attributes to generate
207 # improved shared library binaries.
208 ifeq ($(GXX_4_OR_BETTER), 1)
209 ifneq ($(no_hidden_visibility),1)
210 CCFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
211 ifeq ($(gcc_template_instantiation_visibility),1)
212 CCFLAGS += -DACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS=1
213 endif # gcc_template_instantiation_visibility
215 CPPFLAGS += -DACE_HAS_CUSTOM_EXPORT_MACROS=0
216 endif # no_hidden_visibility
217 endif # GXX_4_OR_BETTER == 1
219 # Explicitly disable G++ (>= 4.x) visibility attributes since
220 # they are only meant for use when building shared libraries.
221 ifeq ($(GXX_4_OR_BETTER), 1)
222 no_hidden_visibility = 1
223 CPPFLAGS += -DACE_HAS_CUSTOM_EXPORT_MACROS=0
224 endif # GXX_4_OR_BETTER == 1
225 endif # static_libs_only
227 # Explicitly disable G++ (>= 4.x) visibility attributes since
228 # they are only meant for use when building shared libraries.
229 ifeq ($(GXX_4_OR_BETTER), 1)
230 no_hidden_visibility = 1
231 CPPFLAGS += -DACE_HAS_CUSTOM_EXPORT_MACROS=0
232 endif # GXX_4_OR_BETTER == 1
236 ifeq ($(minimaltoc),1)
237 FLAGS_C_CC += -mminimal-toc
240 address-sanitizer ?= 0
241 ifeq ($(address-sanitizer),1)
242 CPPFLAGS += -fsanitize=address -fno-omit-frame-pointer
243 LDFLAGS += -fsanitize=address
246 thread-sanitizer ?= 0
247 ifeq ($(thread-sanitizer),1)
248 CPPFLAGS += -fsanitize=thread
249 LDFLAGS += -fsanitize=thread
254 FLAGS_C_CC += -Wall -W -Wpointer-arith
255 CCFLAGS += -Wnon-virtual-dtor