fix coverity CID 344485, 344482, 344481
[RRG-proxmark3.git] / Makefile.defs
blob23dab5b32f399808d08dc122984b366d9cce563b
1 # Hide full compilation line:
2 ifneq ($(V),1)
3   Q?=@
4 endif
5 # To see full command lines, use make V=1
7 # been here
8 DEFSBEENHERE = true
10 CP = cp -a
11 GZIP = gzip
12 MKDIR = mkdir -p
13 RM = rm -f
14 RMDIR = rm -rf
15 # rmdir only if dir is empty, tolerate failure
16 RMDIR_SOFT = -rmdir
17 MV = mv
18 TOUCH = touch
19 FALSE = false
20 TAR = tar
21 TARFLAGS ?= -v --ignore-failed-read -r
22 TARFLAGS += -C .. -f
23 CROSS  ?= arm-none-eabi-
24 CC = gcc
25 CXX = g++
26 LD = g++
27 SH = sh
28 BASH = bash
29 PERL = perl
30 SWIG = swig
31 CC_VERSION = $(shell $(CC) -dumpversion 2>/dev/null|sed 's/\..*//')
32 CC_VERSION := $(or $(strip $(CC_VERSION)),0)
34 PATHSEP=/
35 PREFIX ?=              /usr/local
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
48 else
49   DETECTED_COMPILER = gcc
50 endif
52 ifeq ($(platform),Darwin)
53   AR= /usr/bin/ar rcs
54   RANLIB= /usr/bin/ranlib
55 else
56   AR= ar rcs
57   RANLIB= ranlib
58 endif
60 # For detection of Apple Silicon
61 ifeq ($(platform),Darwin)
62   BREW_PREFIX = $(shell brew --prefix)
63 endif
65 ifeq ($(DEBUG),1)
66   DEFCXXFLAGS = -g -O0 -pipe
67   DEFCFLAGS = -g -O0 -fstrict-aliasing -pipe
68   DEFLDFLAGS =
69 else
70   DEFCXXFLAGS = -Wall -Werror -O3 -pipe
71   DEFCFLAGS = -Wall -Werror -O3 -fstrict-aliasing -pipe
72   DEFLDFLAGS =
73 endif
75 ifeq ($(DEBUG_ARM),1)
76   APP_CFLAGS += -g
77   SKIP_COMPRESSION=1
78 endif
79 # Next ones are activated only if SANITIZE=1
80 ifeq ($(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
84 endif
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
95   endif
96 endif
97 ifeq ($(platform),Darwin)
98   # their readline has strict-prototype issues
99   DEFCFLAGS += -Wno-strict-prototypes
100 else
101   DEFCFLAGS += -Wstrict-prototypes
102 endif
104 # Next ones are activated only if GCCEXTRA=1 or CLANGEXTRA=1
105 EXTRACFLAGS =
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
122 ifeq ($(GCCEXTRA),1)
123   DEFCFLAGS += $(GCCEXTRACFLAGS) $(EXTRACFLAGS)
124 endif
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)
136 endif
137 ifeq ($(CLANGEVERYTHING),1)
138   DEFCFLAGS += -Weverything -Wno-error
139 endif
140 ifeq ($(NOERROR),1)
141   DEFCFLAGS += -Wno-error
142 endif