]> git.ipfire.org Git - pakfire.git/blob - macros/cflags.macro
e0f28117d380016353829308a69ebec43d09f21f
[pakfire.git] / macros / cflags.macro
1 build
2 # Export CFLAGS
3 export CFLAGS = # empty
4
5 # Export CXXFLAGS
6 export CXXFLAGS = %{CFLAGS}
7
8 # Export LDFLAGS
9 export LDFLAGS = -Wl,--as-needed -Wl,-z,relro -Wl,-z,now
10
11 # Enable optimisation and compile in debugging information
12 CFLAGS = -O2 -g
13
14 # Enable all compiler warnings
15 CFLAGS += -Wall -Werror=format-security
16
17 # Fortify Source
18 CFLAGS += -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=3
19
20 # Build Position Independent Code
21 CFLAGS += -fPIC
22
23 # Enable Stack Smashing Protection
24 CFLAGS += -fstack-protector-strong
25
26 # Enable unwind tables
27 CFLAGS += -funwind-tables -fasynchronous-unwind-tables
28
29 # Enable Stack Clash Protection
30 CFLAGS += -fstack-clash-protection
31
32 # Tell the compiler where the source will be put
33 CFLAGS += -fdebug-prefix-map=%{DIR_SRC}=%{debugsourcedir}
34
35 # Avoid creating temporary files
36 CFLAGS += -pipe
37
38 # Arch: x86_64
39 CFLAGS_x86_64 = -m64 -march=x86-64-v2 -mtune=generic
40
41 # Arch: aarch64
42 CFLAGS_aarch64 = -mbranch-protection=standard
43
44 # Append architecture optimisations
45 CFLAGS += %{CFLAGS_%{DISTRO_ARCH}}
46
47 # Enable LTO
48 LTO_CFLAGS = -flto=auto -ffat-lto-objects
49 CFLAGS += %{LTO_CFLAGS}
50
51 # Export default compilers
52 export CC = gcc
53 export CXX = g++
54
55 # Show libtool where to find any libraries
56 export LT_SYS_LIBRARY_PATH = %{libdir}:
57 end