forked from zeroc-ice/ice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Make.rules.Linux
131 lines (97 loc) · 4.72 KB
/
Make.rules.Linux
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
# **********************************************************************
#
# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
#
# **********************************************************************
linux_id = $(shell . /etc/os-release && echo $${ID})
is-bin-program = $(and $(filter $(bindir)%,$($4_targetdir)),$(filter $($1_target),program))
ifneq ($(filter centos rhel fedora,$(linux_id)),)
#
# MultiLib Linux (x64 libraries go in the lib64 directory, x86 executable names are suffixed with 32)
#
supported-platforms = x64 x86
multilib-platform = yes
x64_cppflags = -m64
x64_ldflags = $(x64_cppflags)
x64_targetdir = $(if $(filter %/build,$5),/x64,$(if $(filter-out $($1_target),program),64))
x64_installdir = $(if $(and $(filter-out $($1_target),program),$(filter-out %64,$5)),64)
x86_cppflags = -m32
x86_ldflags = $(x86_cppflags)
x86_targetdir = $(if $(filter %/build,$5),/x86)
x86_targetname = $(if $(is-bin-program),32)
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)
# $(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_installdir = $$(if $$(and $(is-bin-program),$(usr_dir_install)),,/$$($1_multiarch))
$1_excludes = $(if $(filter-out $1,$(build-platform)),Slice)
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
#
supported-platforms = $(if $(filter x86_64,$(shell uname -m)),x64,x86)
x64_targetdir = $(if $(filter %/build,$5),/x64,$(if $(filter-out $($1_target),program),64))
x64_installdir = $(if $(and $(filter-out $($1_target),program),$(filter-out %64,$($1_installdir))),64)
x86_targetdir = $(if $(filter %/build,$5),/x86)
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, enable fPIC
shared_cppflags = $(if $(filter-out program,$($1_target)),-fPIC) -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),\
$$(call unique,$$(foreach d,$($4_dependencies),$$(call make-rpath-link-ldflags,$$d,$($4_dependencies)))))
CXXFLAGS += -Wall -Werror -pthread
LDFLAGS += -pthread
ifeq ($(MAXWARN),yes)
CXXFLAGS += -Wextra -Wshadow -Wredundant-decls
endif
ifeq ($(OPTIMIZE),yes)
CXXFLAGS += -O2 -DNDEBUG
else
CXXFLAGS += -g
endif
nodeprecatedwarnings-cppflags := -Wno-deprecated-declarations
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 :=
libbacktrace_fullpath := $(shell $(CXX) --print-file-name=libbacktrace.a)
ifneq ($(libbacktrace_fullpath),libbacktrace.a)
libbacktrace = yes
endif
IceUtil_system_libs = -lrt $(if $(filter yes,$(libbacktrace)),-lbacktrace)
Ice_system_libs = -ldl -lcrypto $(IceUtil_system_libs)
IceSSL_system_libs = -lssl -lcrypto
Glacier2CryptPermissionsVerifier_system_libs = -lcrypt