1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
#
# Copyright (c) ZeroC, Inc. All rights reserved.
#
known_distributions := centos rhel fedora debian ubuntu amzn sles
linux_ids := $(if $(wildcard /etc/os-release),$(shell . /etc/os-release && echo $${ID} $${ID_LIKE}),)
linux_id ?= $(word 1,$(or $(filter $(known_distributions),$(linux_ids)),$(linux_ids)))
is-bin-program = $(and $(filter $(bindir)%,$($4_targetdir)),$(filter $($1_target),program))
ifneq ($(OECORE_SDK_VERSION),)
linux_id = yocto
endif
ifneq ($(filter yocto poky,$(linux_id)),)
build-platform = default
supported-platforms = $(build-platform)
$(build-platform)_cc = $(CC)
$(build-platform)_cxx = $(CXX)
$(build-platform)_cppflags = -Wno-psabi
$(build-platform)_libtool = $(AR)
$(build-platform)_targetdir = $(if $(filter %/build,$5),/$(build-platform))
$(build-platform)_installdir =
$(build-platform)_objdir =
# system install directory
system-install-dir := $(OECORE_TARGET_SYSROOT)/usr
else ifneq ($(and $(filter centos rhel fedora,$(linux_id)),$(filter x86_64 i%86,$(shell uname -m))),)
#
# MultiLib Linux (x64 libraries go in the lib64 directory, x86 executable names are suffixed with 32)
#
supported-platforms = x64 x86
multilib-platform = yes
ifeq ($(OPTIMIZE),yes)
# Use default system packaging flags if building with OPTIMIZE and CXXFLAGS/LDFLAGS aren't defined.
# NOTE: We remove the -m32/-m64 flags since we'll add them below.
opt-cppflags = $(if $(CXXFLAGS),,$(filter-out -m32 -m64,$(shell setarch $1 rpm --eval %optflags)))
opt-ldflags = $(if $(LDFLAGS),,$(shell setarch $1 rpm --eval %?__global_ldflags))
endif
x64_cppflags := $(call opt-cppflags,x86_64) -m64
x64_ldflags := $(call opt-ldflags,x86_64) -m64
x64_targetdir = $(if $(filter %/build,$5),/x64,$(if $(filter-out $($1_target),program),64))
x64_installdir = $(if $(and $(filter-out $($1_target),program),$(if $5,$(filter-out %64,$5),true)),64)
x86_cppflags := $(call opt-cppflags,i386) -m32
x86_ldflags := $(call opt-ldflags,i386) -m32
x86_targetdir = $(if $(filter %/build,$5),/x86)
x86_targetname = $(if $(is-bin-program),32)
# No Slice translators for x86
x86_excludes = slice2%
else ifneq ($(filter debian ubuntu,$(linux_id)),)
#
# MultiArch Linux (libraries are installed in lib/<arch>, executables are installed in bin/<arch>
# except for the build architecture where executables are installed in bin/).
#
build-platform ?= $(shell dpkg --print-architecture)
foreign-platforms ?= $(shell dpkg --print-foreign-architectures)
supported-platforms = $(build-platform) $(foreign-platforms)
dpkg-arch = $(shell dpkg-architecture -f -a$1 -q$2 2> /dev/null)
ifeq ($(OPTIMIZE),yes)
# Use default system packaging flags if building with OPTIMIZE and CXXFLAGS/LDFLAGS aren't defined.
opt-cppflags = $(if $(CXXFLAGS),,$(shell dpkg-buildflags --get CXXFLAGS))
opt-ldflags = $(if $(LDFLAGS),,$(shell DEB_BUILD_MAINT_OPTIONS=hardening=+bindnow dpkg-buildflags --get LDFLAGS))
endif
# $(call make-platform-config,$1=platform)
define make-platform-config
$1_gnu_type = $(call dpkg-arch,$1,DEB_HOST_GNU_TYPE)
$1_multiarch = $(call dpkg-arch,$1,DEB_HOST_MULTIARCH)
$1_cc = $$($1_gnu_type)-$(CC)
$1_cxx = $$($1_gnu_type)-$(CXX)
$1_libtool = $$($1_gnu_type)-$(AR)
$1_targetdir = /$$($1_multiarch)
$1_objdir = /$$($1_multiarch)
$1_installdir = $$(if $$(and $(is-bin-program),$(usr_dir_install)),,/$$($1_multiarch))
#
# Disable ABI compatibility warnings for armhf using -Wno-psabi
#
$1_cppflags = $(opt-cppflags) $(if $(filter $1,armhf),-Wno-psabi)
$1_ldflags = $(opt-ldflags)
endef
$(foreach p,$(supported-platforms),$(eval $(call make-platform-config,$p)))
# For the build platform architecture, build and install executables in bin, libraries in lib/<arch>
$(build-platform)_targetdir = $(if $(or $(filter %/build,$5),$(filter-out $($1_target),program)),/$($2_multiarch))
$(build-platform)_installdir = $(if $(is-bin-program),,/$($2_multiarch))
else
#
# Single architecture Linux
#
ifeq ($(OPTIMIZE),yes)
# Use default system packaging flags if building with OPTIMIZE and CXXFLAGS/LDFLAGS aren't defined.
ifneq ($(filter amzn sles,$(linux_id)),)
opt-cppflags = $(if $(CXXFLAGS),,$(shell setarch $1 rpm --eval %optflags))
opt-ldflags = $(if $(LDFLAGS),,$(shell setarch $1 rpm --eval %?__global_ldflags))
else
opt-cppflags = $(if $(CXXFLAGS),,-O2)
endif
endif
build-platform = $(if $(filter arm%,$(shell uname -m)),arm,$(shell uname -m))
supported-platforms = $(build-platform)
lib-suffix = $(if $(filter %64,$(build-platform)),64,)
$(build-platform)_cppflags := $(call opt-cppflags,$(build-platform))
$(build-platform)_ldflags := $(call opt-ldflags,$(build-platform))
$(build-platform)_targetdir = $(if $(filter %/build,$5),/$(build-platform),$(if $(filter-out $($1_target),program),$(lib-suffix)))
$(build-platform)_installdir = $(if $(and $(filter-out $($1_target),program),$(if $5,$(filter-out %$(lib-suffix),$5),true)),$(lib-suffix))
endif
rpath-link-ldflag = -Wl,-rpath-link,$1
make-rpath-link-ldflags = $(foreach d,$(filter-out $2,$(call get-all-deps,$1)),$(call rpath-link-ldflag,$($d_targetdir)))
# If building objects for a shared library build, enable PIC or PIE:
shared_cppflags = $(if $(filter-out program,$($1_target)),-fPIC,-fPIE) -fvisibility=hidden
# If we are linking a program, add -rpath-link to locate secondary libraries that aren't linked with the executable.
shared_ldflags = $(if $(filter-out program,$($1_target)),\
$(if $(filter yes,$(allow-undefined-symbols)),,-Wl$(comma)--no-undefined),\
-pie $(if $(filter yes,$(new_dtags)),-Wl$(comma)--enable-new-dtags,-Wl$(comma)--disable-new-dtags) \
$$(call unique,$$(foreach d,$($4_dependencies),$$(call make-rpath-link-ldflags,$$d,$($4_dependencies)))))
cppflags = -Wall -Wextra -Wredundant-decls -Wshadow -Wdeprecated -pthread $(if $(filter yes,$(OPTIMIZE)),-DNDEBUG,-g)
ldflags = -pthread
# -Wshadow is too strict with gcc 4
ifeq ($(shell $(CXX) -dumpversion | cut -f1 -d\.),4)
cppflags := $(filter-out -Wshadow,$(cppflags))
endif
nodeprecatedwarnings-cppflags := -Wno-deprecated-declarations
nounusedparameter-cppflags := -Wno-unused-parameter
loader_path = \$$ORIGIN
# $(call mklib,$1=target,$2=objects,$3=libname,$4=version,$5=soversion,$6=ldflags,$7=platform)
mklib = $(or $($7_ar),$(AR)) cr $1 $2
# $(call mkshlib,$1=target,$2=objects,$3=libname,$4=version,$5=soversion,$6=ldflags,$7=platform)
mkshlib = $(or $($7_cxx),$(CXX)) -shared $(if $5,-Wl$(comma)-h$(comma)$(call mksoname,$3,$4,$5)) -o $1 $2 $6
#
# $(call mkxxx,$1=libname,$2=version,$3=soversion)
#
mksoname = lib$(1).so$(if $3,.$3)
mkshlibfilename = lib$(1).so$(if $2,.$2)
mkshlibname = lib$(1).so
# Clear the iconv ldflags, iconv is part of libc on Linux
iconv_ldflags :=
#
# With GCC < 6.1, libbacktrace crash with a SEGV for -pie exes linked with debug-stripped libs
# See https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00132.html
# Here we assume only release builds occasionally get -g and later get stripped
# TODO: enable libbacktrace for release builds with GCC >= 6.1
ifneq ($(OPTIMIZE),yes)
libbacktrace_fullpath := $(shell $(CXX) --print-file-name=libbacktrace.a)
ifneq ($(libbacktrace_fullpath),libbacktrace.a)
libbacktrace = yes
endif
endif
IceUtil_system_libs = -lrt $(if $(filter yes,$(libbacktrace)),-lbacktrace)
Ice_system_libs = -ldl -lcrypto $(IceUtil_system_libs)
ifeq ($(shell pkg-config --exists libsystemd 2> /dev/null && echo yes),yes)
Ice_system_libs += $(shell pkg-config --libs libsystemd)
endif
IceSSL_system_libs = -lssl -lcrypto
Glacier2CryptPermissionsVerifier_system_libs = -lcrypt
icegridadmin_system_libs = -ledit
icestormadmin_system_libs = -ledit
#
# On supported platforms and if Bluez and DBus are installed, we set the IceBT
# system libraries. The build system checks for this variable to build or not
# the IceBT plugin, demos, ...
#
ifneq ($(filter debian ubuntu yocto poky,$(linux_id)),)
ifeq ($(shell pkg-config --exists bluez dbus-1 2> /dev/null && echo yes),yes)
IceBT_system_libs = $(IceSSL_system_libs) $(shell pkg-config --libs dbus-1)
endif
endif
|