1 # Hide full compilation line:
5 # To see full command lines, use make V=1
15 # rmdir only if dir is empty, tolerate failure
21 TARFLAGS ?= -v --ignore-failed-read -r
23 CROSS ?= arm-none-eabi-
31 CC_VERSION = $(shell $(CC) -dumpversion 2>/dev/null|sed 's/\..*//')
32 CC_VERSION := $(or $(strip $(CC_VERSION)),0)
36 UDEV_PREFIX ?= /etc/udev/rules.d
37 INSTALLBINRELPATH ?= bin
38 INSTALLSHARERELPATH ?= share/proxmark3
39 INSTALLFWRELPATH ?= share/proxmark3/firmware
40 INSTALLTOOLSRELPATH ?= share/proxmark3/tools
41 INSTALLDOCSRELPATH ?= share/doc/proxmark3
43 platform = $(shell uname)
44 DETECTED_OS=$(platform)
46 ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
47 DETECTED_COMPILER = clang
49 DETECTED_COMPILER = gcc
52 ifeq ($(platform),Darwin)
55 RANLIB= /usr/bin/ranlib
62 BREW_PREFIX = $(shell brew --prefix)
66 DEFCXXFLAGS = -g -O0 -pipe
67 DEFCFLAGS = -g -O0 -fstrict-aliasing -pipe
70 DEFCXXFLAGS = -Wall -Werror -O3 -pipe
71 DEFCFLAGS = -Wall -Werror -O3 -fstrict-aliasing -pipe
79 # Next ones are activated only if SANITIZE=1
81 DEFCFLAGS += -g -fsanitize=address -fno-omit-frame-pointer
82 DEFCXXFLAGS += -g -fsanitize=address -fno-omit-frame-pointer
83 DEFLDFLAGS += -g -fsanitize=address
85 # Some more warnings we want as errors:
86 DEFCFLAGS += -Wbad-function-cast -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wshadow -Wundef -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wmissing-declarations -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits -Wold-style-definition
87 # Some more warnings we need first to eliminate, so temporarely tolerated:
88 DEFCFLAGS += -Wcast-align -Wno-error=cast-align
89 DEFCFLAGS += -Wswitch-enum -Wno-error=switch-enum
90 # GCC 10 has issues with false positives on stringop-overflow, let's disable them for now (cf https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92955, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94335)
91 # beware these flags didn't exist for GCC < 7
92 ifeq ($(shell expr $(CC_VERSION) \>= 10), 1)
93 ifneq ($(DETECTED_COMPILER), clang)
94 DEFCFLAGS += -Wno-stringop-overflow -Wno-error=stringop-overflow
97 ifeq ($(platform),Darwin)
98 # their readline has strict-prototype issues
99 DEFCFLAGS += -Wno-strict-prototypes
101 DEFCFLAGS += -Wstrict-prototypes
104 # Next ones are activated only if GCCEXTRA=1 or CLANGEXTRA=1
106 EXTRACFLAGS += -Wunused-parameter -Wno-error=unused-parameter
107 EXTRACFLAGS += -Wsign-compare -Wno-error=sign-compare
108 EXTRACFLAGS += -Wconversion -Wno-error=conversion -Wno-error=sign-conversion -Wno-error=float-conversion
110 # unknown to clang or old gcc:
111 # First we activate Wextra then we explicitly list those we know about
112 # Those without -Wno-error are supposed to be completely solved
113 GCCEXTRACFLAGS = -Wextra
114 GCCEXTRACFLAGS += -Wclobbered -Wno-error=clobbered
115 GCCEXTRACFLAGS += -Wcast-function-type
116 GCCEXTRACFLAGS += -Wimplicit-fallthrough=3 -Wno-error=implicit-fallthrough
117 GCCEXTRACFLAGS += -Wmissing-parameter-type
118 GCCEXTRACFLAGS += -Wold-style-declaration -Wno-error=old-style-declaration
119 GCCEXTRACFLAGS += -Woverride-init
120 GCCEXTRACFLAGS += -Wshift-negative-value
121 GCCEXTRACFLAGS += -Wunused-but-set-parameter -Wno-error=unused-but-set-parameter
123 DEFCFLAGS += $(GCCEXTRACFLAGS) $(EXTRACFLAGS)
125 # unknown to gcc or old clang:
126 # First we activate Wextra then we explicitly list those we know about
127 # Those without -Wno-error are supposed to be completely solved
128 CLANGEXTRACFLAGS = -Wextra
129 CLANGEXTRACFLAGS += -Wtautological-type-limit-compare
130 CLANGEXTRACFLAGS += -Wnull-pointer-arithmetic
131 CLANGEXTRACFLAGS += -Woverride-init
132 CLANGEXTRACFLAGS += -Wshift-negative-value
133 CLANGEXTRACFLAGS += -Wimplicit-fallthrough
134 ifeq ($(CLANGEXTRA),1)
135 DEFCFLAGS += $(CLANGEXTRACFLAGS) $(EXTRACFLAGS)
137 ifeq ($(CLANGEVERYTHING),1)
138 DEFCFLAGS += -Weverything -Wno-error
141 DEFCFLAGS += -Wno-error