Release v4.15864 - Radium
[RRG-proxmark3.git] / Makefile.defs
blob57132d8d02ebff5dadee3d7905e9dda15f2bb8b9
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 #-----------------------------------------------------------------------------
16 ifneq ($(V),1)
17   Q?=@
18 endif
19 # To see full command lines, use make V=1
21 # been here
22 DEFSBEENHERE = true
24 # USER not defined on some platforms like Archlinux
25 USER ?= $(shell id -u -n)
27 CP = cp -a
28 GZIP = gzip
29 MKDIR = mkdir -p
30 RM = rm -f
31 RMDIR = rm -rf
32 # rmdir only if dir is empty, tolerate failure
33 RMDIR_SOFT = -rmdir
34 MV = mv
35 TOUCH = touch
36 FALSE = false
37 TAR = tar
38 TARFLAGS ?= -v --ignore-failed-read -r
39 TARFLAGS += -C .. -f
40 CROSS ?= arm-none-eabi-
41 CC ?= gcc
42 CXX ?= g++
43 SH = sh
44 BASH = bash
45 PERL = perl
46 SWIG = swig
47 CC_VERSION = $(shell $(CC) -dumpversion 2>/dev/null|sed 's/\..*//')
48 CC_VERSION := $(or $(strip $(CC_VERSION)),0)
50 ECHO = echo
51 SUDO = sudo
52 USERMOD = usermod -aG
53 ADDUSER = adduser
54 GETENT_BL = getent group bluetooth
58 PATHSEP=/
59 PREFIX ?=              /usr/local
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
66 export INSTALLSUDO
68 platform = $(shell uname)
69 DETECTED_OS=$(platform)
71 ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
72   DETECTED_COMPILER = clang
73 else
74   DETECTED_COMPILER = gcc
75 endif
77 ifeq ($(platform),Darwin)
78   USE_BREW ?= 1
79   USE_MACPORTS ?= 0
80   AR= /usr/bin/ar rcs
81   RANLIB= /usr/bin/ranlib
82 else
83   AR= ar rcs
84   RANLIB= ranlib
85 endif
87 ifeq ($(USE_BREW),1)
88   ifneq ($(strip $(HOMEBREW_PREFIX)),)
89     BREW_PREFIX = $(HOMEBREW_PREFIX)
90   else
91     BREW_PREFIX = $(shell brew --prefix 2>/dev/null)
92     ifeq ($(strip $(BREW_PREFIX)),)
93       USE_BREW = 0
94     endif
95   endif
96 endif
98 ifeq ($(USE_MACPORTS),1)
99   MACPORTS_PREFIX ?= /opt/local
100 endif
102 ifeq ($(DEBUG),1)
103   DEFCXXFLAGS = -g -O0 -pipe
104   DEFCFLAGS = -g -O0 -fstrict-aliasing -pipe
105   DEFLDFLAGS =
106 else
107   DEFCXXFLAGS = -Wall -O3 -pipe
108   DEFCFLAGS = -Wall -O3 -fstrict-aliasing -pipe
109   DEFLDFLAGS =
110 endif
112 ifeq ($(DEBUG_ARM),1)
113   APP_CFLAGS += -g
114   SKIP_COMPRESSION=1
115 endif
116 # Next ones are activated only if SANITIZE=1
117 ifeq ($(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
121 endif
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
132   endif
133 endif
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
139 else
140   DEFCFLAGS += -Wstrict-prototypes
141 endif
143 # Next ones are activated only if GCCEXTRA=1 or CLANGEXTRA=1
144 EXTRACFLAGS =
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
161 ifeq ($(GCCEXTRA),1)
162   DEFCFLAGS += $(GCCEXTRACFLAGS) $(EXTRACFLAGS)
163 endif
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)
175 endif
176 ifeq ($(CLANGEVERYTHING),1)
177   DEFCFLAGS += -Weverything -Wno-error
178 endif
179 ifeq ($(NOERROR),1)
180   DEFCFLAGS += -Wno-error
181 endif