Makefile 12 KB

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