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