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