Moved TKIP countermeasures from hostapd.c to its own file
[wpasupplicant] / hostapd / Makefile
1 ifndef CC
2 CC=gcc
3 endif
4
5 ifndef CFLAGS
6 CFLAGS = -MMD -O2 -Wall -g
7 endif
8
9 # define HOSTAPD_DUMP_STATE to include SIGUSR1 handler for dumping state to
10 # a file (undefine it, if you want to save in binary size)
11 CFLAGS += -DHOSTAPD_DUMP_STATE
12
13 CFLAGS += -I../src
14 CFLAGS += -I../src/crypto
15 CFLAGS += -I../src/utils
16 CFLAGS += -I../src/common
17
18 # Uncomment following line and set the path to your kernel tree include
19 # directory if your C library does not include all header files.
20 # CFLAGS += -DUSE_KERNEL_HEADERS -I/usr/src/linux/include
21
22 -include .config
23
24 ifndef CONFIG_OS
25 ifdef CONFIG_NATIVE_WINDOWS
26 CONFIG_OS=win32
27 else
28 CONFIG_OS=unix
29 endif
30 endif
31
32 ifeq ($(CONFIG_OS), internal)
33 CFLAGS += -DOS_NO_C_LIB_DEFINES
34 endif
35
36 ifdef CONFIG_NATIVE_WINDOWS
37 CFLAGS += -DCONFIG_NATIVE_WINDOWS
38 LIBS += -lws2_32
39 endif
40
41 OBJS =  hostapd.o ieee802_1x.o eapol_sm.o \
42         config.o ieee802_11_auth.o \
43         sta_info.o wpa.o ctrl_iface.o \
44         drivers.o preauth.o pmksa_cache.o \
45         hw_features.o \
46         tkip_countermeasures.o \
47         mlme.o vlan_init.o wpa_auth_ie.o
48
49 OBJS += ../src/utils/eloop.o
50 OBJS += ../src/utils/common.o
51 OBJS += ../src/utils/wpa_debug.o
52 OBJS += ../src/utils/wpabuf.o
53 OBJS += ../src/utils/os_$(CONFIG_OS).o
54 OBJS += ../src/utils/ip_addr.o
55
56 OBJS += ../src/common/ieee802_11_common.o
57 OBJS += ../src/common/wpa_common.o
58
59 ifdef CONFIG_NO_RADIUS
60 CFLAGS += -DCONFIG_NO_RADIUS
61 CONFIG_NO_ACCOUNTING=y
62 else
63 OBJS += ../src/radius/radius.o
64 OBJS += ../src/radius/radius_client.o
65 endif
66
67 ifdef CONFIG_NO_ACCOUNTING
68 CFLAGS += -DCONFIG_NO_ACCOUNTING
69 else
70 OBJS += accounting.o
71 endif
72
73 OBJS += ../src/crypto/md5.o
74 OBJS += ../src/crypto/rc4.o
75 OBJS += ../src/crypto/md4.o
76 OBJS += ../src/crypto/sha1.o
77 OBJS += ../src/crypto/des.o
78 OBJS += ../src/crypto/aes_wrap.o
79 OBJS += ../src/crypto/aes.o
80
81 HOBJS=../src/hlr_auc_gw/hlr_auc_gw.o ../src/utils/common.o ../src/utils/wpa_debug.o ../src/utils/os_$(CONFIG_OS).o ../src/hlr_auc_gw/milenage.o ../src/crypto/aes_wrap.o ../src/crypto/aes.o
82
83 CFLAGS += -DCONFIG_CTRL_IFACE -DCONFIG_CTRL_IFACE_UNIX
84
85 ifdef CONFIG_IAPP
86 CFLAGS += -DCONFIG_IAPP
87 OBJS += iapp.o
88 endif
89
90 ifdef CONFIG_RSN_PREAUTH
91 CFLAGS += -DCONFIG_RSN_PREAUTH
92 CONFIG_L2_PACKET=y
93 endif
94
95 ifdef CONFIG_PEERKEY
96 CFLAGS += -DCONFIG_PEERKEY
97 OBJS += peerkey.o
98 endif
99
100 ifdef CONFIG_IEEE80211W
101 CFLAGS += -DCONFIG_IEEE80211W
102 NEED_SHA256=y
103 endif
104
105 ifdef CONFIG_IEEE80211R
106 CFLAGS += -DCONFIG_IEEE80211R
107 OBJS += wpa_ft.o
108 NEED_SHA256=y
109 endif
110
111 ifdef CONFIG_IEEE80211N
112 CFLAGS += -DCONFIG_IEEE80211N
113 endif
114
115 ifdef CONFIG_DRIVER_HOSTAP
116 NEED_MLME=y
117 CFLAGS += -DCONFIG_DRIVER_HOSTAP
118 OBJS += driver_hostap.o
119 endif
120
121 ifdef CONFIG_DRIVER_WIRED
122 CFLAGS += -DCONFIG_DRIVER_WIRED
123 OBJS += driver_wired.o
124 endif
125
126 ifdef CONFIG_DRIVER_MADWIFI
127 CFLAGS += -DCONFIG_DRIVER_MADWIFI
128 OBJS += driver_madwifi.o
129 CONFIG_L2_PACKET=y
130 endif
131
132 ifdef CONFIG_DRIVER_PRISM54
133 CFLAGS += -DCONFIG_DRIVER_PRISM54
134 OBJS += driver_prism54.o
135 endif
136
137 ifdef CONFIG_DRIVER_NL80211
138 NEED_MLME=y
139 CFLAGS += -DCONFIG_DRIVER_NL80211
140 OBJS += driver_nl80211.o
141 OBJS += ../src/utils/radiotap.o
142 LIBS += -lnl
143 ifdef CONFIG_LIBNL20
144 LIBS += -lnl-genl
145 CFLAGS += -DCONFIG_LIBNL20
146 endif
147 endif
148
149 ifdef CONFIG_DRIVER_BSD
150 CFLAGS += -DCONFIG_DRIVER_BSD
151 OBJS += driver_bsd.o
152 CONFIG_L2_PACKET=y
153 CONFIG_DNET_PCAP=y
154 CONFIG_L2_FREEBSD=y
155 endif
156
157 ifdef CONFIG_DRIVER_TEST
158 NEED_MLME=y
159 CFLAGS += -DCONFIG_DRIVER_TEST
160 OBJS += driver_test.o
161 endif
162
163 ifdef CONFIG_DRIVER_NONE
164 CFLAGS += -DCONFIG_DRIVER_NONE
165 OBJS += driver_none.o
166 endif
167
168 ifdef CONFIG_L2_PACKET
169 ifdef CONFIG_DNET_PCAP
170 ifdef CONFIG_L2_FREEBSD
171 LIBS += -lpcap
172 OBJS += ../src/l2_packet/l2_packet_freebsd.o
173 else
174 LIBS += -ldnet -lpcap
175 OBJS += ../src/l2_packet/l2_packet_pcap.o
176 endif
177 else
178 OBJS += ../src/l2_packet/l2_packet_linux.o
179 endif
180 else
181 OBJS += ../src/l2_packet/l2_packet_none.o
182 endif
183
184
185 ifdef CONFIG_EAP_MD5
186 CFLAGS += -DEAP_MD5
187 OBJS += ../src/eap_server/eap_md5.o
188 CHAP=y
189 endif
190
191 ifdef CONFIG_EAP_TLS
192 CFLAGS += -DEAP_TLS
193 OBJS += ../src/eap_server/eap_tls.o
194 TLS_FUNCS=y
195 endif
196
197 ifdef CONFIG_EAP_PEAP
198 CFLAGS += -DEAP_PEAP
199 OBJS += ../src/eap_server/eap_peap.o
200 OBJS += ../src/eap_common/eap_peap_common.o
201 TLS_FUNCS=y
202 CONFIG_EAP_MSCHAPV2=y
203 endif
204
205 ifdef CONFIG_EAP_TTLS
206 CFLAGS += -DEAP_TTLS
207 OBJS += ../src/eap_server/eap_ttls.o
208 TLS_FUNCS=y
209 CHAP=y
210 endif
211
212 ifdef CONFIG_EAP_MSCHAPV2
213 CFLAGS += -DEAP_MSCHAPv2
214 OBJS += ../src/eap_server/eap_mschapv2.o
215 MS_FUNCS=y
216 endif
217
218 ifdef CONFIG_EAP_GTC
219 CFLAGS += -DEAP_GTC
220 OBJS += ../src/eap_server/eap_gtc.o
221 endif
222
223 ifdef CONFIG_EAP_SIM
224 CFLAGS += -DEAP_SIM
225 OBJS += ../src/eap_server/eap_sim.o
226 CONFIG_EAP_SIM_COMMON=y
227 endif
228
229 ifdef CONFIG_EAP_AKA
230 CFLAGS += -DEAP_AKA
231 OBJS += ../src/eap_server/eap_aka.o
232 CONFIG_EAP_SIM_COMMON=y
233 endif
234
235 ifdef CONFIG_EAP_AKA_PRIME
236 CFLAGS += -DEAP_AKA_PRIME
237 endif
238
239 ifdef CONFIG_EAP_SIM_COMMON
240 OBJS += ../src/eap_common/eap_sim_common.o
241 # Example EAP-SIM/AKA interface for GSM/UMTS authentication. This can be
242 # replaced with another file implementating the interface specified in
243 # eap_sim_db.h.
244 OBJS += ../src/eap_server/eap_sim_db.o
245 NEED_FIPS186_2_PRF=y
246 endif
247
248 ifdef CONFIG_EAP_PAX
249 CFLAGS += -DEAP_PAX
250 OBJS += ../src/eap_server/eap_pax.o ../src/eap_common/eap_pax_common.o
251 endif
252
253 ifdef CONFIG_EAP_PSK
254 CFLAGS += -DEAP_PSK
255 OBJS += ../src/eap_server/eap_psk.o ../src/eap_common/eap_psk_common.o
256 endif
257
258 ifdef CONFIG_EAP_SAKE
259 CFLAGS += -DEAP_SAKE
260 OBJS += ../src/eap_server/eap_sake.o ../src/eap_common/eap_sake_common.o
261 endif
262
263 ifdef CONFIG_EAP_GPSK
264 CFLAGS += -DEAP_GPSK
265 OBJS += ../src/eap_server/eap_gpsk.o ../src/eap_common/eap_gpsk_common.o
266 ifdef CONFIG_EAP_GPSK_SHA256
267 CFLAGS += -DEAP_GPSK_SHA256
268 endif
269 NEED_SHA256=y
270 endif
271
272 ifdef CONFIG_EAP_VENDOR_TEST
273 CFLAGS += -DEAP_VENDOR_TEST
274 OBJS += ../src/eap_server/eap_vendor_test.o
275 endif
276
277 ifdef CONFIG_EAP_FAST
278 CFLAGS += -DEAP_FAST
279 OBJS += ../src/eap_server/eap_fast.o
280 OBJS += ../src/eap_common/eap_fast_common.o
281 TLS_FUNCS=y
282 NEED_T_PRF=y
283 endif
284
285 ifdef CONFIG_WPS
286 CFLAGS += -DCONFIG_WPS -DEAP_WSC
287 OBJS += ../src/utils/uuid.o
288 OBJS += wps_hostapd.o
289 OBJS += ../src/eap_server/eap_wsc.o ../src/eap_common/eap_wsc_common.o
290 OBJS += ../src/wps/wps.o
291 OBJS += ../src/wps/wps_common.o
292 OBJS += ../src/wps/wps_attr_parse.o
293 OBJS += ../src/wps/wps_attr_build.o
294 OBJS += ../src/wps/wps_attr_process.o
295 OBJS += ../src/wps/wps_dev_attr.o
296 OBJS += ../src/wps/wps_enrollee.o
297 OBJS += ../src/wps/wps_registrar.o
298 NEED_DH_GROUPS=y
299 NEED_SHA256=y
300 NEED_CRYPTO=y
301 NEED_BASE64=y
302 endif
303
304 ifdef CONFIG_EAP_IKEV2
305 CFLAGS += -DEAP_IKEV2
306 OBJS += ../src/eap_server/eap_ikev2.o ../src/eap_server/ikev2.o
307 OBJS += ../src/eap_common/eap_ikev2_common.o ../src/eap_common/ikev2_common.o
308 NEED_DH_GROUPS=y
309 endif
310
311 ifdef CONFIG_EAP_TNC
312 CFLAGS += -DEAP_TNC
313 OBJS += ../src/eap_server/eap_tnc.o
314 OBJS += ../src/eap_server/tncs.o
315 NEED_BASE64=y
316 endif
317
318 # Basic EAP functionality is needed for EAPOL
319 OBJS += ../src/eap_server/eap.o
320 OBJS += ../src/eap_common/eap_common.o
321 OBJS += ../src/eap_server/eap_methods.o
322 OBJS += ../src/eap_server/eap_identity.o
323
324 ifdef CONFIG_EAP
325 CFLAGS += -DEAP_SERVER
326 endif
327
328 ifndef CONFIG_TLS
329 CONFIG_TLS=openssl
330 endif
331
332 ifeq ($(CONFIG_TLS), internal)
333 ifndef CONFIG_CRYPTO
334 CONFIG_CRYPTO=internal
335 endif
336 endif
337 ifeq ($(CONFIG_CRYPTO), libtomcrypt)
338 CFLAGS += -DCONFIG_INTERNAL_X509
339 endif
340 ifeq ($(CONFIG_CRYPTO), internal)
341 CFLAGS += -DCONFIG_INTERNAL_X509
342 endif
343
344
345 ifdef TLS_FUNCS
346 # Shared TLS functions (needed for EAP_TLS, EAP_PEAP, and EAP_TTLS)
347 CFLAGS += -DEAP_TLS_FUNCS
348 OBJS += ../src/eap_server/eap_tls_common.o
349 ifeq ($(CONFIG_TLS), openssl)
350 OBJS += ../src/crypto/tls_openssl.o
351 LIBS += -lssl -lcrypto
352 LIBS_p += -lcrypto
353 LIBS_h += -lcrypto
354 endif
355 ifeq ($(CONFIG_TLS), gnutls)
356 OBJS += ../src/crypto/tls_gnutls.o
357 LIBS += -lgnutls -lgcrypt -lgpg-error
358 LIBS_p += -lgcrypt
359 LIBS_h += -lgcrypt
360 endif
361 ifdef CONFIG_GNUTLS_EXTRA
362 CFLAGS += -DCONFIG_GNUTLS_EXTRA
363 LIBS += -lgnutls-extra
364 endif
365 ifeq ($(CONFIG_TLS), internal)
366 OBJS += ../src/crypto/tls_internal.o
367 OBJS += ../src/tls/tlsv1_common.o ../src/tls/tlsv1_record.o
368 OBJS += ../src/tls/tlsv1_cred.o ../src/tls/tlsv1_server.o
369 OBJS += ../src/tls/tlsv1_server_write.o ../src/tls/tlsv1_server_read.o
370 OBJS += ../src/tls/asn1.o ../src/tls/x509v3.o
371 OBJS_p += ../src/tls/asn1.o
372 OBJS_p += ../src/crypto/rc4.o ../src/crypto/aes_wrap.o ../src/crypto/aes.o
373 NEED_BASE64=y
374 CFLAGS += -DCONFIG_TLS_INTERNAL
375 CFLAGS += -DCONFIG_TLS_INTERNAL_SERVER
376 ifeq ($(CONFIG_CRYPTO), internal)
377 ifdef CONFIG_INTERNAL_LIBTOMMATH
378 CFLAGS += -DCONFIG_INTERNAL_LIBTOMMATH
379 else
380 LIBS += -ltommath
381 LIBS_p += -ltommath
382 endif
383 endif
384 ifeq ($(CONFIG_CRYPTO), libtomcrypt)
385 LIBS += -ltomcrypt -ltfm
386 LIBS_p += -ltomcrypt -ltfm
387 endif
388 endif
389 NEED_CRYPTO=y
390 else
391 OBJS += ../src/crypto/tls_none.o
392 endif
393
394 ifdef CONFIG_PKCS12
395 CFLAGS += -DPKCS12_FUNCS
396 endif
397
398 ifdef MS_FUNCS
399 OBJS += ../src/crypto/ms_funcs.o
400 NEED_CRYPTO=y
401 endif
402
403 ifdef CHAP
404 OBJS += ../src/eap_common/chap.o
405 endif
406
407 ifdef NEED_CRYPTO
408 ifndef TLS_FUNCS
409 ifeq ($(CONFIG_TLS), openssl)
410 LIBS += -lcrypto
411 LIBS_p += -lcrypto
412 LIBS_h += -lcrypto
413 endif
414 ifeq ($(CONFIG_TLS), gnutls)
415 LIBS += -lgcrypt
416 LIBS_p += -lgcrypt
417 LIBS_h += -lgcrypt
418 endif
419 ifeq ($(CONFIG_TLS), internal)
420 ifeq ($(CONFIG_CRYPTO), libtomcrypt)
421 LIBS += -ltomcrypt -ltfm
422 LIBS_p += -ltomcrypt -ltfm
423 endif
424 endif
425 endif
426 ifeq ($(CONFIG_TLS), openssl)
427 OBJS += ../src/crypto/crypto_openssl.o
428 OBJS_p += ../src/crypto/crypto_openssl.o
429 HOBJS += ../src/crypto/crypto_openssl.o
430 CONFIG_INTERNAL_SHA256=y
431 endif
432 ifeq ($(CONFIG_TLS), gnutls)
433 OBJS += ../src/crypto/crypto_gnutls.o
434 OBJS_p += ../src/crypto/crypto_gnutls.o
435 HOBJS += ../src/crypto/crypto_gnutls.o
436 CONFIG_INTERNAL_SHA256=y
437 endif
438 ifeq ($(CONFIG_TLS), internal)
439 ifeq ($(CONFIG_CRYPTO), libtomcrypt)
440 OBJS += ../src/crypto/crypto_libtomcrypt.o
441 OBJS_p += ../src/crypto/crypto_libtomcrypt.o
442 CONFIG_INTERNAL_SHA256=y
443 endif
444 ifeq ($(CONFIG_CRYPTO), internal)
445 OBJS += ../src/crypto/crypto_internal.o ../src/tls/rsa.o ../src/tls/bignum.o
446 OBJS_p += ../src/crypto/crypto_internal.o ../src/tls/rsa.o ../src/tls/bignum.o
447 CFLAGS += -DCONFIG_CRYPTO_INTERNAL
448 CONFIG_INTERNAL_AES=y
449 CONFIG_INTERNAL_DES=y
450 CONFIG_INTERNAL_SHA1=y
451 CONFIG_INTERNAL_MD4=y
452 CONFIG_INTERNAL_MD5=y
453 CONFIG_INTERNAL_SHA256=y
454 endif
455 endif
456 else
457 CONFIG_INTERNAL_AES=y
458 CONFIG_INTERNAL_SHA1=y
459 CONFIG_INTERNAL_MD5=y
460 CONFIG_INTERNAL_SHA256=y
461 endif
462
463 ifdef CONFIG_INTERNAL_AES
464 CFLAGS += -DINTERNAL_AES
465 endif
466 ifdef CONFIG_INTERNAL_SHA1
467 CFLAGS += -DINTERNAL_SHA1
468 endif
469 ifdef CONFIG_INTERNAL_SHA256
470 CFLAGS += -DINTERNAL_SHA256
471 endif
472 ifdef CONFIG_INTERNAL_MD5
473 CFLAGS += -DINTERNAL_MD5
474 endif
475 ifdef CONFIG_INTERNAL_MD4
476 CFLAGS += -DINTERNAL_MD4
477 endif
478 ifdef CONFIG_INTERNAL_DES
479 CFLAGS += -DINTERNAL_DES
480 endif
481
482 ifdef NEED_SHA256
483 OBJS += ../src/crypto/sha256.o
484 endif
485
486 ifdef NEED_DH_GROUPS
487 OBJS += ../src/crypto/dh_groups.o
488 endif
489
490 ifndef NEED_FIPS186_2_PRF
491 CFLAGS += -DCONFIG_NO_FIPS186_2_PRF
492 endif
493
494 ifndef NEED_T_PRF
495 CFLAGS += -DCONFIG_NO_T_PRF
496 endif
497
498 ifdef CONFIG_RADIUS_SERVER
499 CFLAGS += -DRADIUS_SERVER
500 OBJS += ../src/radius/radius_server.o
501 endif
502
503 ifdef CONFIG_IPV6
504 CFLAGS += -DCONFIG_IPV6
505 endif
506
507 ifdef CONFIG_DRIVER_RADIUS_ACL
508 CFLAGS += -DCONFIG_DRIVER_RADIUS_ACL
509 endif
510
511 ifdef CONFIG_FULL_DYNAMIC_VLAN
512 # define CONFIG_FULL_DYNAMIC_VLAN to have hostapd manipulate bridges
513 # and vlan interfaces for the vlan feature.
514 CFLAGS += -DCONFIG_FULL_DYNAMIC_VLAN
515 endif
516
517 ifdef NEED_BASE64
518 OBJS += ../src/utils/base64.o
519 endif
520
521 ifdef NEED_MLME
522 OBJS += beacon.o wme.o ap_list.o ieee802_11.o
523 CFLAGS += -DNEED_MLME
524 endif
525
526 ifdef CONFIG_NO_STDOUT_DEBUG
527 CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
528 endif
529
530 ALL=hostapd hostapd_cli
531
532 all: verify_config $(ALL)
533
534 verify_config:
535         @if [ ! -r .config ]; then \
536                 echo 'Building hostapd requires a configuration file'; \
537                 echo '(.config). See README for more instructions. You can'; \
538                 echo 'run "cp defconfig .config" to create an example'; \
539                 echo 'configuration.'; \
540                 exit 1; \
541         fi
542
543 install: all
544         for i in $(ALL); do cp $$i /usr/local/bin/$$i; done
545
546 hostapd: $(OBJS)
547         $(CC) -o hostapd $(OBJS) $(LIBS)
548
549 OBJS_c = hostapd_cli.o ../src/common/wpa_ctrl.o ../src/utils/os_$(CONFIG_OS).o
550 hostapd_cli: $(OBJS_c)
551         $(CC) -o hostapd_cli $(OBJS_c)
552
553 NOBJS = nt_password_hash.o ../src/crypto/ms_funcs.o ../src/crypto/sha1.o ../src/crypto/rc4.o ../src/crypto/md5.o
554 NOBJS += ../src/crypto/crypto_openssl.o ../src/utils/os_$(CONFIG_OS).o
555 ifdef TLS_FUNCS
556 LIBS_n += -lcrypto
557 endif
558
559 nt_password_hash: $(NOBJS)
560         $(CC) -o nt_password_hash $(NOBJS) $(LIBS_n)
561
562 hlr_auc_gw: $(HOBJS)
563         $(CC) -o hlr_auc_gw $(HOBJS) $(LIBS_h)
564
565 clean:
566         $(MAKE) -C ../src clean
567         rm -f core *~ *.o hostapd hostapd_cli nt_password_hash hlr_auc_gw
568         rm -f *.d
569
570 %.eps: %.fig
571         fig2dev -L eps $*.fig $*.eps
572
573 %.png: %.fig
574         fig2dev -L png -m 3 $*.fig | pngtopnm | pnmscale 0.4 | pnmtopng \
575                 > $*.png
576
577 docs-pics: doc/hostapd.png doc/hostapd.eps
578
579 docs: docs-pics
580         (cd ..; doxygen hostapd/doc/doxygen.full; cd hostapd)
581         $(MAKE) -C doc/latex
582         cp doc/latex/refman.pdf hostapd-devel.pdf
583
584 docs-fast: docs-pics
585         (cd ..; doxygen hostapd/doc/doxygen.fast; cd hostapd)
586
587 clean-docs:
588         rm -rf doc/latex doc/html
589         rm -f doc/hostapd.{eps,png} hostapd-devel.pdf
590
591 TEST_SRC_MILENAGE = ../src/hlr_auc_gw/milenage.c ../src/crypto/aes_wrap.c ../src/crypto/aes.c ../src/utils/common.c ../src/utils/wpa_debug.o ../src/utils/os_$(CONFIG_OS).c
592 test-milenage: $(TEST_SRC_MILENAGE)
593         $(CC) -o test-milenage -Wall -Werror $(TEST_SRC_MILENAGE) \
594                 -DTEST_MAIN_MILENAGE -I. -DINTERNAL_AES \
595                 -I../src/crypto -I../src/utils
596         ./test-milenage
597         rm test-milenage
598
599 -include $(OBJS:%.o=%.d)