forked from aircrack-ng/aircrack-ng-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.mak
265 lines (222 loc) · 6.31 KB
/
common.mak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
PKG_CONFIG ?= pkg-config
NEWSSE = true
# Newer version of the core can be enabled via SIMDCORE
# but should be automatically flipped on thru autodetection
SIMDCORE = false
# Multibin will compile a separate binary for each core: original, SSE and SIMD.
MULTIBIN = false
ifndef TOOL_PREFIX
TOOL_PREFIX =
endif
ifndef OSNAME
OSNAME := $(shell uname -s | sed -e 's/.*CYGWIN.*/cygwin/g' -e 's,/,-,g')
endif
ifndef SQLITE
SQLITE = false
endif
ifndef LIBAIRPCAP
LIBAIRPCAP =
endif
ifeq ($(OSNAME), cygwin)
EXE = .exe
PIC =
SQLITE = false
else
EXE =
ifeq ($(OSNAME), SunOS)
PIC =
LDFLAGS += -lsocket -lnsl
else
PIC = -fPIC
endif
ifndef SQLITE
SQLITE = true
endif
endif
COMMON_CFLAGS =
OSX_ALT_FLAGS =
ifeq ($(subst TRUE,true,$(filter TRUE true,$(xcode) $(XCODE))),true)
COMMON_CFLAGS += -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdk/MacOSX.sdk/usr/include/ -D_XCODE -I../..
OSX_ALT_FLAGS = true
endif
ifeq ($(subst TRUE,true,$(filter TRUE true,$(macport) $(MACPORT))),true)
COMMON_CFLAGS += -I/opt/local/include -I../..
LDFLAGS += -L/opt/local/lib
OSX_ALT_FLAGS = true
endif
ifeq ($(subst TRUE,true,$(filter TRUE true,$(sqlite) $(SQLITE))),true)
COMMON_CFLAGS += -DHAVE_SQLITE
endif
ifeq ($(pcre), true)
PCRE = true
endif
ifeq ($(PCRE), true)
COMMON_CFLAGS += $(shell $(PKG_CONFIG) --cflags libpcre) -DHAVE_PCRE
endif
STACK_PROTECTOR = true
ifeq ($(stackprotector), false)
STACK_PROTECTOR = false
endif
ifeq ($(STACKPROTECTOR), false)
STACK_PROTECTOR = false
endif
ifeq ($(OSNAME), cygwin)
COMMON_CFLAGS += -DCYGWIN
endif
ifeq ($(OSNAME), Linux)
ifneq ($(libnl), false)
NL3xFOUND := $(shell $(PKG_CONFIG) --atleast-version=3.2 libnl-3.0 && echo Y)
ifneq ($(NL3xFOUND),Y)
NL31FOUND := $(shell $(PKG_CONFIG) --exact-version=3.1 libnl-3.1 && echo Y)
ifneq ($(NL31FOUND),Y)
NL3FOUND := $(shell $(PKG_CONFIG) --atleast-version=3 libnl-3.0 && echo Y)
endif
ifneq ($(NL3FOUND),Y)
NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y)
endif
ifneq ($(NL1FOUND),Y)
NLTFOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-tiny && echo Y)
endif
endif
ifeq ($(NL1FOUND),Y)
NLLIBNAME = libnl-1
COMMON_CFLAGS += -DCONFIG_LIBNL
endif
ifeq ($(NLTFOUND),Y)
NLLIBNAME = libnl-tiny
COMMON_CFLAGS += -DCONFIG_LIBNL -DCONFIG_LIBNL20
endif
ifeq ($(NL3xFOUND),Y)
COMMON_CFLAGS += -DCONFIG_LIBNL30 -DCONFIG_LIBNL
LIBS += -lnl-genl-3
NLLIBNAME = libnl-3.0
endif
ifeq ($(NL3FOUND),Y)
COMMON_CFLAGS += -DCONFIG_LIBNL30 -DCONFIG_LIBNL
LIBS += -lnl-genl
NLLIBNAME = libnl-3.0
endif
# nl-3.1 has a broken libnl-gnl-3.1.pc file
# as show by pkg-config --debug --libs --cflags --exact-version=3.1 libnl-genl-3.1;echo $?
ifeq ($(NL31FOUND),Y)
COMMON_CFLAGS += -DCONFIG_LIBNL30 -DCONFIG_LIBNL
LIBS += -lnl-genl
NLLIBNAME = libnl-3.1
endif
NLLIBNAME ?= $(error Cannot find development files for any supported version of libnl. install either libnl1 or libnl3.)
LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME))
COMMON_CFLAGS +=$(shell $(PKG_CONFIG) --cflags $(NLLIBNAME))
COMMON_CFLAGS := $(COMMON_CFLAGS)
endif
endif
ifeq ($(subst TRUE,true,$(filter TRUE true,$(airpcap) $(AIRPCAP))),true)
LIBAIRPCAP = -DHAVE_AIRPCAP -I$(AC_ROOT)/../developers/Airpcap_Devpack/include
endif
ifneq ($(origin CC),environment)
ifeq ($(OSNAME), FreeBSD)
CC = $(TOOL_PREFIX)cc
CXX = $(TOOL_PREFIX)c++
else
CC = $(TOOL_PREFIX)gcc
CXX = $(TOOL_PREFIX)g++
endif
endif
# This is for autodetection of processor features in the new crypto cores.
-include $(AC_ROOT)/common.cfg
RANLIB ?= $(TOOL_PREFIX)ranlib
ifneq ($(origin AR),environment)
AR = $(TOOL_PREFIX)ar
endif
REVISION = $(shell $(AC_ROOT)/evalrev $(AC_ROOT))
REVFLAGS ?= -D_REVISION=$(REVISION)
OPTFLAGS = -D_FILE_OFFSET_BITS=64
CFLAGS ?= -g -W -Wall -O3
ifeq ($(subst TRUE,true,$(filter TRUE true,$(icc) $(ICC))),true)
ICCMODE = Y
CC = icc
CXX = icpc
AR = xiar
CFLAGS += -no-prec-div
endif
# If we're building multibin make sure simd is disabled
ifeq ($(subst TRUE,true,$(filter TRUE true,$(multibin) $(MULTIBIN))),true)
SIMDCORE = false
endif
ifeq ($(HAS_NEON), Y)
CFLAGS += -mfpu=neon
endif
ifeq ($(subst FALSE,false,$(filter FALSE false,$(newsse) $(NEWSSE))),false)
CFLAGS += -DOLD_SSE_CORE=1
else
ifeq ($(AVX2FLAG), Y)
ifeq ($(ICCMODE), Y)
CFLAGS += -march=core-avx2 -DJOHN_AVX2
else
CFLAGS += -mavx2 -DJOHN_AVX2
endif
else
ifeq ($(AVX1FLAG), Y)
ifeq ($(ICCMODE), Y)
CFLAGS += -march=corei7-avx -DJOHN_AVX
else
CFLAGS += -mavx -DJOHN_AVX
endif
else
ifeq ($(SSEFLAG), Y)
ifeq ($(ICCMODE), Y)
CFLAGS += -march=corei7
else
CFLAGS += -msse2
endif
endif
endif # AVX1FLAG
endif # AVX2FLAG
endif # NEWSSE
ifeq ($(INTEL_ASM), Y)
ASMFLAG = -masm=intel
endif
# This will enable -D_REENTRANT if compatible so we have thread-safe functions available to us via -pthread.
ifeq ($(PTHREAD), Y)
CFLAGS += -pthread
endif
CXXFLAGS = $(CFLAGS) $(ASMFLAG) -fdata-sections -ffunction-sections
CFLAGS += $(OPTFLAGS) $(REVFLAGS) $(COMMON_CFLAGS)
prefix = /usr/local
bindir = $(prefix)/bin
sbindir = $(prefix)/sbin
mandir = $(prefix)/share/man/man1
smandir = $(prefix)/share/man/man8
datadir = $(prefix)/share
docdir = $(datadir)/doc/aircrack-ng
libdir = $(prefix)/lib
etcdir = $(prefix)/etc/aircrack-ng
ifneq ($(ICCMODE), Y)
GCC_OVER41 = $(shell expr 41 \<= `$(CC) -dumpversion | awk -F. '{ print $1$2 }'`)
GCC_OVER45 = $(shell expr 45 \<= `$(CC) -dumpversion | awk -F. '{ print $1$2 }'`)
GCC_OVER49 = $(shell expr 49 \<= `$(CC) -dumpversion | awk -F. '{ print $1$2 }'`)
ifeq ($(GCC_OVER41), 0)
GCC_OVER41 = $(shell expr 4.1 \<= `$(CC) -dumpversion | awk -F. '{ print $1$2 }'`)
endif
ifeq ($(GCC_OVER45), 0)
GCC_OVER45 = $(shell expr 4.5 \<= `$(CC) -dumpversion | awk -F. '{ print $1$2 }'`)
endif
ifeq ($(GCC_OVER49), 0)
GCC_OVER49 = $(shell expr 4.9 \<= `$(CC) -dumpversion | awk -F. '{ print $1$2 }'`)
endif
ifeq ($(STACK_PROTECTOR), true)
ifeq ($(GCC_OVER49), 0)
ifeq ($(GCC_OVER41), 1)
COMMON_CFLAGS += -fstack-protector
endif
endif
ifeq ($(GCC_OVER49), 1)
COMMON_CFLAGS += -fstack-protector-strong
endif
endif
ifeq ($(GCC_OVER45), 1)
CFLAGS += -Wno-unused-but-set-variable -Wno-array-bounds
endif
endif
ifeq ($(subst TRUE,true,$(filter TRUE true,$(duma) $(DUMA))),true)
LIBS += -lduma
endif