1 #-----------------------------------------------------------------------------
2 # Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # See LICENSE.txt for the text of the license.
15 #-----------------------------------------------------------------------------
19 # To see full command lines, use make V=1
24 # USER not defined on some platforms like Archlinux
25 USER ?= $(shell id -u -n)
32 # rmdir only if dir is empty, tolerate failure
38 TARFLAGS ?= -v --ignore-failed-read -r
40 CROSS ?= arm-none-eabi-
47 CC_VERSION = $(shell $(CC) -dumpversion 2>/dev/null|sed 's/\..*//')
48 CC_VERSION := $(or $(strip $(CC_VERSION)),0)
54 GETENT_BL = getent group bluetooth
60 UDEV_PREFIX ?= /etc/udev/rules.d
61 INSTALLBINRELPATH ?= bin
62 INSTALLSHARERELPATH ?= share/proxmark3
63 INSTALLFWRELPATH ?= share/proxmark3/firmware
64 INSTALLTOOLSRELPATH ?= share/proxmark3/tools
65 INSTALLDOCSRELPATH ?= share/doc/proxmark3
68 platform = $(shell uname)
69 DETECTED_OS=$(platform)
71 ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
72 DETECTED_COMPILER = clang
74 DETECTED_COMPILER = gcc
77 ifeq ($(platform),Darwin)
81 RANLIB= /usr/bin/ranlib
88 ifneq ($(strip $(HOMEBREW_PREFIX)),)
89 BREW_PREFIX = $(HOMEBREW_PREFIX)
91 BREW_PREFIX = $(shell brew --prefix 2>/dev/null)
92 ifeq ($(strip $(BREW_PREFIX)),)
98 ifeq ($(USE_MACPORTS),1)
99 MACPORTS_PREFIX ?= /opt/local
103 DEFCXXFLAGS = -g -O0 -pipe
104 DEFCFLAGS = -g -O0 -fstrict-aliasing -pipe
107 DEFCXXFLAGS = -Wall -O3 -pipe
108 DEFCFLAGS = -Wall -O3 -fstrict-aliasing -pipe
112 ifeq ($(DEBUG_ARM),1)
116 # Next ones are activated only if SANITIZE=1
118 DEFCFLAGS += -g -fsanitize=address -fno-omit-frame-pointer
119 DEFCXXFLAGS += -g -fsanitize=address -fno-omit-frame-pointer
120 DEFLDFLAGS += -g -fsanitize=address
122 # Some more warnings we want as errors:
123 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
124 # Some more warnings we need first to eliminate, so temporarely tolerated:
125 DEFCFLAGS += -Wcast-align -Wno-error=cast-align
126 DEFCFLAGS += -Wswitch-enum -Wno-error=switch-enum
127 # 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)
128 # beware these flags didn't exist for GCC < 7
129 ifeq ($(shell expr $(CC_VERSION) \>= 10), 1)
130 ifneq ($(DETECTED_COMPILER), clang)
131 DEFCFLAGS += -Wno-stringop-overflow -Wno-error=stringop-overflow
134 ifeq ($(platform),Darwin)
135 # their readline has strict-prototype issues
136 DEFCFLAGS += -Wno-strict-prototypes
137 # some warnings about braced initializers on structs we want to ignore
138 DEFCFLAGS += -Wno-missing-braces
140 DEFCFLAGS += -Wstrict-prototypes
143 # Next ones are activated only if GCCEXTRA=1 or CLANGEXTRA=1
145 EXTRACFLAGS += -Wunused-parameter -Wno-error=unused-parameter
146 EXTRACFLAGS += -Wsign-compare -Wno-error=sign-compare
147 EXTRACFLAGS += -Wconversion -Wno-error=conversion -Wno-error=sign-conversion -Wno-error=float-conversion
149 # unknown to clang or old gcc:
150 # First we activate Wextra then we explicitly list those we know about
151 # Those without -Wno-error are supposed to be completely solved
152 GCCEXTRACFLAGS = -Wextra
153 GCCEXTRACFLAGS += -Wclobbered -Wno-error=clobbered
154 GCCEXTRACFLAGS += -Wcast-function-type
155 GCCEXTRACFLAGS += -Wimplicit-fallthrough=3 -Wno-error=implicit-fallthrough
156 GCCEXTRACFLAGS += -Wmissing-parameter-type
157 GCCEXTRACFLAGS += -Wold-style-declaration -Wno-error=old-style-declaration
158 GCCEXTRACFLAGS += -Woverride-init
159 GCCEXTRACFLAGS += -Wshift-negative-value
160 GCCEXTRACFLAGS += -Wunused-but-set-parameter -Wno-error=unused-but-set-parameter
162 DEFCFLAGS += $(GCCEXTRACFLAGS) $(EXTRACFLAGS)
164 # unknown to gcc or old clang:
165 # First we activate Wextra then we explicitly list those we know about
166 # Those without -Wno-error are supposed to be completely solved
167 CLANGEXTRACFLAGS = -Wextra
168 CLANGEXTRACFLAGS += -Wtautological-type-limit-compare
169 CLANGEXTRACFLAGS += -Wnull-pointer-arithmetic
170 CLANGEXTRACFLAGS += -Woverride-init
171 CLANGEXTRACFLAGS += -Wshift-negative-value
172 CLANGEXTRACFLAGS += -Wimplicit-fallthrough
173 ifeq ($(CLANGEXTRA),1)
174 DEFCFLAGS += $(CLANGEXTRACFLAGS) $(EXTRACFLAGS)
176 ifeq ($(CLANGEVERYTHING),1)
177 DEFCFLAGS += -Weverything -Wno-error
180 DEFCFLAGS += -Wno-error