allow some tests to run also under --long
[RRG-proxmark3.git] / Makefile.defs
blob493c50ccd51cee19c6b92e2861450a67d2d9249a
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   USE_BREW = 1
54   AR= /usr/bin/ar rcs
55   RANLIB= /usr/bin/ranlib
56 else
57   AR= ar rcs
58   RANLIB= ranlib
59 endif
61 ifeq ($(USE_BREW),1)
62   BREW_PREFIX = $(shell brew --prefix 2>/dev/null)
63   ifeq ($(strip $(BREW_PREFIX)),)
64     MACPORTS_PREFIX ?= /opt/local
65   endif
66 endif
68 ifeq ($(DEBUG),1)
69   DEFCXXFLAGS = -g -O0 -pipe
70   DEFCFLAGS = -g -O0 -fstrict-aliasing -pipe
71   DEFLDFLAGS =
72 else
73   DEFCXXFLAGS = -Wall -Werror -O3 -pipe
74   DEFCFLAGS = -Wall -Werror -O3 -fstrict-aliasing -pipe
75   DEFLDFLAGS =
76 endif
78 ifeq ($(DEBUG_ARM),1)
79   APP_CFLAGS += -g
80   SKIP_COMPRESSION=1
81 endif
82 # Next ones are activated only if SANITIZE=1
83 ifeq ($(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
87 endif
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
98   endif
99 endif
100 ifeq ($(platform),Darwin)
101   # their readline has strict-prototype issues
102   DEFCFLAGS += -Wno-strict-prototypes
103 else
104   DEFCFLAGS += -Wstrict-prototypes
105 endif
107 # Next ones are activated only if GCCEXTRA=1 or CLANGEXTRA=1
108 EXTRACFLAGS =
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
125 ifeq ($(GCCEXTRA),1)
126   DEFCFLAGS += $(GCCEXTRACFLAGS) $(EXTRACFLAGS)
127 endif
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)
139 endif
140 ifeq ($(CLANGEVERYTHING),1)
141   DEFCFLAGS += -Weverything -Wno-error
142 endif
143 ifeq ($(NOERROR),1)
144   DEFCFLAGS += -Wno-error
145 endif