| 1 |
# Shared Logic for GCC and Clang |
| 2 |
|
| 3 |
FLAGS_C_CC += -Wall -Wextra -Wpointer-arith |
| 4 |
CCFLAGS += -Wnon-virtual-dtor |
| 5 |
|
| 6 |
# Suppress "Creating *.a" Message |
| 7 |
ARFLAGS += -c |
| 8 |
|
| 9 |
ifeq ($(shared_libs), 1) |
| 10 |
ifneq ($(static_libs_only), 1) |
| 11 |
# Add all symbols to the dynamic symbol table. Needed to enable |
| 12 |
# dynamic_cast<> for shared libraries. (see |
| 13 |
# http://gcc.gnu.org/faq.html#dso) |
| 14 |
|
| 15 |
ifeq ($(GNU_LD),1) |
| 16 |
# Make sure this version of ld supports the -E option. |
| 17 |
ifneq ($(mingw32),1) |
| 18 |
LD_EXPORT_DEFINED := $(shell sh -c '$(LD_FOR_VERSION_TEST) -E 2>&1 | grep -E -i "(option|flag)" /dev/null; echo $$?') |
| 19 |
else |
| 20 |
LD_EXPORT_DEFINED := $(shell $(LD_FOR_VERSION_TEST) -E 2>&1 | grep -c -i -e '(option|flag)') |
| 21 |
ifeq ($(LD_EXPORT_DEFINED),0) |
| 22 |
LD_EXPORT_DEFINED:=1 |
| 23 |
else |
| 24 |
LD_EXPORT_DEFINED:=0 |
| 25 |
endif |
| 26 |
endif # mingw32 |
| 27 |
ifeq ($(LD_EXPORT_DEFINED),1) |
| 28 |
LDFLAGS += -Wl,-E |
| 29 |
endif # LD_EXPORT_DEFINED = 1 |
| 30 |
endif # GNU ld |
| 31 |
|
| 32 |
# Take advantage of g++ visibility attributes to generate |
| 33 |
# improved shared library binaries. |
| 34 |
ifneq ($(no_hidden_visibility),1) |
| 35 |
CCFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden |
| 36 |
else |
| 37 |
CPPFLAGS += -DACE_HAS_CUSTOM_EXPORT_MACROS=0 |
| 38 |
endif # no_hidden_visibility |
| 39 |
else |
| 40 |
# Explicitly disable g++ visibility attributes since |
| 41 |
# they are only meant for use when building shared libraries. |
| 42 |
no_hidden_visibility = 1 |
| 43 |
CPPFLAGS += -DACE_HAS_CUSTOM_EXPORT_MACROS=0 |
| 44 |
endif # static_libs_only |
| 45 |
else |
| 46 |
# Explicitly disable g++ visibility attributes since |
| 47 |
# they are only meant for use when building shared libraries. |
| 48 |
no_hidden_visibility = 1 |
| 49 |
CPPFLAGS += -DACE_HAS_CUSTOM_EXPORT_MACROS=0 |
| 50 |
endif # shared_libs |
| 51 |
|
| 52 |
ifneq ($(c++std),) |
| 53 |
CCFLAGS += -std=$(c++std) |
| 54 |
else ifeq ($(c++20),1) |
| 55 |
CCFLAGS += -std=c++20 |
| 56 |
else ifeq ($(c++17),1) |
| 57 |
CCFLAGS += -std=c++17 |
| 58 |
endif |
| 59 |
|
| 60 |
# If no option has been specified, set templates to automatic |
| 61 |
# version of the compiler. |
| 62 |
# |
| 63 |
templates ?= automatic |
| 64 |
|
| 65 |
# The correct flags to pass to the linker for ELF dynamic shared library |
| 66 |
# versioning. |
| 67 |
# If the platform file didn't already set versioned_so, default to 1. |
| 68 |
versioned_so ?= 1 |
| 69 |
with_ld ?= |
| 70 |
ifneq ($(versioned_so),0) |
| 71 |
SOFLAGS += -Wl,-h -Wl,$(SONAME) |
| 72 |
endif |
| 73 |
|
| 74 |
ifeq ($(versioned_so),2) |
| 75 |
FLAGS_C_CC += -DACE_VERSIONED_SO=2 |
| 76 |
endif |
| 77 |
|
| 78 |
static_libs_only ?= |
| 79 |
|
| 80 |
ifeq ($(GNU_LD),1) |
| 81 |
STATIC_LINK_FLAG ?= -static |
| 82 |
endif # GNU_LD |
| 83 |
|
| 84 |
ifeq ($(openmp),1) |
| 85 |
FLAGS_C_CC += -fopenmp |
| 86 |
LDFLAGS += -fopenmp |
| 87 |
endif |