Makefile 12 KB

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