Makefile 12 KB

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