-
Notifications
You must be signed in to change notification settings - Fork 51
/
Make.defaults
110 lines (97 loc) · 3.61 KB
/
Make.defaults
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
NAME = pesign
COMMIT_ID ?= $(shell git log -1 --pretty=%H 2>/dev/null || echo master)
prefix ?= /usr/
prefix := $(abspath $(prefix))/
libdir ?= $(prefix)lib64/
libdatadir ?= $(prefix)lib/
libexecdir ?= $(prefix)libexec/
datadir ?= $(prefix)share/
mandir ?= $(datadir)man/
includedir ?= $(prefix)include/
bindir ?= $(prefix)bin/
rundir ?= /run/
rundir := $(abspath $(rundir))/
pcdir ?= $(libdir)pkgconfig/
docdir ?= $(prefix)share/doc/
DESTDIR ?=
INSTALLROOT = $(DESTDIR)
INSTALL ?= install
CROSS_COMPILE ?=
EFI_ARCHES ?= aa64 ia32 x64
enabled = $(if $(filter undefined,$(origin $(1))),$(3),$(2))
HOSTARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
ARCH := $(shell uname -m | sed 's,i[3456789]86,ia32,;s,arm.*,arm,')
PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
CC := $(if $(filter default,$(origin CC)),$(CROSS_COMPILE)gcc,$(CC))
CCLD := $(if $(filter undefined,$(origin CCLD)),$(CC),$(CCLD))
CFLAGS ?= -O2 -g3 -pipe -fPIE -fstack-protector-all \
-fstack-clash-protection \
$(if $(filter x86_64 ia32,$(ARCH)),-fcf-protection=full,)
DIAGFLAGS ?= $(call enabled,ENABLE_GCC_ANALYZER,-fmessage-length=0 \
-fdiagnostics-color=always \
-fdiagnostics-format=text \
-fdiagnostics-show-cwe \
-fanalyzer) \
$(call enabled,ENABLE_LEAK_CHECKER,-Wno-analyzer-malloc-leak,)
AS ?= $(CROSS_COMPILE)as
AR ?= $(CROSS_COMPILE)$(if $(filter $(CC),clang),llvm-ar,$(notdir $(CC))-ar)
RANLIB ?= $(CROSS_COMPILE)$(if $(filter $(CC),clang),llvm-ranlib,$(notdir $(CC))-ranlib)
OBJCOPY ?= $(CROSS_COMPILE)objcopy
LD ?= $(CROSS_COMPILE)ld
INSTALL ?= $(CROSS_COMPILE)install
PKGS = efivar nspr nss nss-util uuid
SOFLAGS ?= -shared
clang_cflags =
gcc_cflags = -Wmaybe-uninitialized -grecord-gcc-switches \
$(call enabled,ENABLE_LEAK_CHECKER,$(call enabled,ENABLE_LEAK_CHECKER_LTO,-flto,),) \
$(DIAGFLAGS)
ifneq (,$(wildcard /usr/lib/gcc/x86_64-redhat-linux/*/plugin/annobin.so))
gcc_cflags += -fplugin=annobin
endif
cflags = $(CFLAGS) $(ARCH3264) \
-Wall -Wextra -Wsign-compare -Wno-unused-result \
-Wno-unused-function -Wno-missing-field-initializers \
$(call enabled,ENABLE_LEAK_CHECKER,-Wno-analyzer-malloc-leak,) \
-Werror -Wno-error=cpp -Wno-free-nonheap-object \
-std=gnu11 -fshort-wchar -fPIC -fno-strict-aliasing \
-D_GNU_SOURCE -DCONFIG_$(ARCH) -I${TOPDIR}/include \
'-DRUNDIR="$(rundir)"' \
$(if $(filter $(CC),clang),$(clang_cflags), ) \
$(if $(filter $(CC),gcc),$(gcc_cflags), ) \
$(call pkg-config-cflags)
clang_ccldflags =
gcc_ccldflags = -fno-merge-constants \
-fvar-tracking -fvar-tracking-assignments -fkeep-inline-functions \
-Wl,--fatal-warnings,--no-allow-shlib-undefined,--default-symver \
-Wl,-O2 -Wl,--no-undefined-version -Wl,-z,relro,-z,now \
-Wl,--no-add-needed,--no-copy-dt-needed-entries,--as-needed -pie
ifeq ($(ARCH),arm)
gcc_ccldflags += -Wl,--no-wchar-size-warning
endif
ccldflags = $(cflags) $(CCLDFLAGS) $(LDFLAGS) \
$(if $(filter $(CCLD),clang),$(clang_ccldflags),) \
$(if $(filter $(CCLD),gcc),$(gcc_ccldflags),) \
$(call pkg-config-ccldflags)
efi_cflags = $(cflags)
ASFLAGS ?= $(ARCH3264)
CPPFLAGS ?= -D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS
RANLIBFLAGS ?= $(if $(filter $(CC),gcc),-D)
ARFLAGS ?= $(if $(filter $(CC),gcc),-Dcvqs)$(if $(filter $(CC),clang),-cqvs)
LDLIBS = $(foreach lib,$(LIBS),-l$(lib)) $(call pkg-config-ldlibs)
ifeq ($(ARCH),ia64)
efi_cflags += -mfixed-range=f32-f127
endif
ifeq ($(ARCH), ia32)
ifeq ($(HOSTARCH), x86_64)
ARCH3264 := -m32
endif
endif
ifeq ($(ARCH), x86_64)
efi_cflags += -mno-red-zone
ifeq ($(HOSTARCH), ia32)
ARCH3264 := -m64
endif
endif
# Docs are enabled by default. Set ENABLE_DOCS=0 to disable
# building/installing docs.
ENABLE_DOCS ?= 1