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