Makefile 12 KB

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