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 2>/dev/null)
63 ifeq ($(strip $(BREW_PREFIX)),)
64 MACPORTS_PREFIX ?= /opt/local
69 DEFCXXFLAGS = -g -O0 -pipe
70 DEFCFLAGS = -g -O0 -fstrict-aliasing -pipe
73 DEFCXXFLAGS = -Wall -Werror -O3 -pipe
74 DEFCFLAGS = -Wall -Werror -O3 -fstrict-aliasing -pipe
82 # Next ones are activated only if SANITIZE=1
84 DEFCFLAGS += -g -fsanitize=address -fno-omit-frame-pointer
85 DEFCXXFLAGS += -g -fsanitize=address -fno-omit-frame-pointer
86 DEFLDFLAGS += -g -fsanitize=address
88 # Some more warnings we want as errors:
89 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
90 # Some more warnings we need first to eliminate, so temporarely tolerated:
91 DEFCFLAGS += -Wcast-align -Wno-error=cast-align
92 DEFCFLAGS += -Wswitch-enum -Wno-error=switch-enum
93 # 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)
94 # beware these flags didn't exist for GCC < 7
95 ifeq ($(shell expr $(CC_VERSION) \>= 10), 1)
96 ifneq ($(DETECTED_COMPILER), clang)
97 DEFCFLAGS += -Wno-stringop-overflow -Wno-error=stringop-overflow
100 ifeq ($(platform),Darwin)
101 # their readline has strict-prototype issues
102 DEFCFLAGS += -Wno-strict-prototypes
104 DEFCFLAGS += -Wstrict-prototypes
107 # Next ones are activated only if GCCEXTRA=1 or CLANGEXTRA=1
109 EXTRACFLAGS += -Wunused-parameter -Wno-error=unused-parameter
110 EXTRACFLAGS += -Wsign-compare -Wno-error=sign-compare
111 EXTRACFLAGS += -Wconversion -Wno-error=conversion -Wno-error=sign-conversion -Wno-error=float-conversion
113 # unknown to clang or old gcc:
114 # First we activate Wextra then we explicitly list those we know about
115 # Those without -Wno-error are supposed to be completely solved
116 GCCEXTRACFLAGS = -Wextra
117 GCCEXTRACFLAGS += -Wclobbered -Wno-error=clobbered
118 GCCEXTRACFLAGS += -Wcast-function-type
119 GCCEXTRACFLAGS += -Wimplicit-fallthrough=3 -Wno-error=implicit-fallthrough
120 GCCEXTRACFLAGS += -Wmissing-parameter-type
121 GCCEXTRACFLAGS += -Wold-style-declaration -Wno-error=old-style-declaration
122 GCCEXTRACFLAGS += -Woverride-init
123 GCCEXTRACFLAGS += -Wshift-negative-value
124 GCCEXTRACFLAGS += -Wunused-but-set-parameter -Wno-error=unused-but-set-parameter
126 DEFCFLAGS += $(GCCEXTRACFLAGS) $(EXTRACFLAGS)
128 # unknown to gcc or old clang:
129 # First we activate Wextra then we explicitly list those we know about
130 # Those without -Wno-error are supposed to be completely solved
131 CLANGEXTRACFLAGS = -Wextra
132 CLANGEXTRACFLAGS += -Wtautological-type-limit-compare
133 CLANGEXTRACFLAGS += -Wnull-pointer-arithmetic
134 CLANGEXTRACFLAGS += -Woverride-init
135 CLANGEXTRACFLAGS += -Wshift-negative-value
136 CLANGEXTRACFLAGS += -Wimplicit-fallthrough
137 ifeq ($(CLANGEXTRA),1)
138 DEFCFLAGS += $(CLANGEXTRACFLAGS) $(EXTRACFLAGS)
140 ifeq ($(CLANGEVERYTHING),1)
141 DEFCFLAGS += -Weverything -Wno-error
144 DEFCFLAGS += -Wno-error