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