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