1b4a5d9f3a78b82c4f64ecae3f7e9c2340518394
[openwrt/openwrt.git] / package / network / services / hostapd / Makefile
1 # Copyright (C) 2006-2014 OpenWrt.org
2 #
3 # This is free software, licensed under the GNU General Public License v2.
4 # See /LICENSE for more information.
5 #
6
7 include $(TOPDIR)/rules.mk
8
9 PKG_NAME:=hostapd
10 PKG_VERSION:=2016-06-15
11 PKG_RELEASE:=1
12 PKG_REV:=31d3692fe5d56c05753ed4a70c7943979e1d29e7
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
15 PKG_SOURCE_URL:=git://w1.fi/srv/git/hostap.git
16 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
17 PKG_SOURCE_VERSION:=$(PKG_REV)
18 PKG_SOURCE_PROTO:=git
19 # PKG_MIRROR_MD5SUM:=4e7c1f97edd7514535056fce54ae053a
20
21 PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
22 PKG_LICENSE:=BSD-3-Clause
23
24 PKG_BUILD_PARALLEL:=1
25
26 PKG_CONFIG_DEPENDS:= \
27 CONFIG_WPA_SUPPLICANT_NO_TIMESTAMP_CHECK \
28 CONFIG_PACKAGE_kmod-ath9k \
29 CONFIG_PACKAGE_kmod-cfg80211 \
30 CONFIG_PACKAGE_hostapd \
31 CONFIG_PACKAGE_hostapd-mini \
32 CONFIG_PACKAGE_kmod-hostap \
33 CONFIG_WPA_RFKILL_SUPPORT \
34 CONFIG_DRIVER_WEXT_SUPPORT \
35 CONFIG_DRIVER_11N_SUPPORT
36
37 LOCAL_TYPE=$(strip \
38 $(if $(findstring wpad,$(BUILD_VARIANT)),wpad, \
39 $(if $(findstring supplicant,$(BUILD_VARIANT)),supplicant, \
40 hostapd \
41 )))
42 LOCAL_VARIANT=$(patsubst wpad-%,%,$(patsubst supplicant-%,%,$(BUILD_VARIANT)))
43 CONFIG_VARIANT:=$(LOCAL_VARIANT)
44 ifeq ($(LOCAL_VARIANT),mesh)
45 CONFIG_VARIANT:=full
46 endif
47
48 ifeq ($(LOCAL_TYPE),supplicant)
49 ifeq ($(LOCAL_VARIANT),full)
50 PKG_CONFIG_DEPENDS += \
51 CONFIG_WPA_SUPPLICANT_INTERNAL \
52 CONFIG_WPA_SUPPLICANT_OPENSSL
53 endif
54 endif
55
56 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
57
58 include $(INCLUDE_DIR)/package.mk
59
60 STAMP_CONFIGURED:=$(STAMP_CONFIGURED)_$(CONFIG_WPA_MSG_MIN_PRIORITY)
61
62 ifneq ($(CONFIG_DRIVER_11N_SUPPORT),)
63 HOSTAPD_IEEE80211N:=y
64 endif
65
66 DRIVER_MAKEOPTS= \
67 CONFIG_ACS=$(CONFIG_PACKAGE_kmod-cfg80211) \
68 CONFIG_DRIVER_NL80211=$(CONFIG_PACKAGE_kmod-cfg80211) \
69 CONFIG_DRIVER_HOSTAP=$(CONFIG_PACKAGE_kmod-hostap) \
70 CONFIG_IEEE80211N=$(HOSTAPD_IEEE80211N) \
71 CONFIG_DRIVER_WEXT=$(CONFIG_DRIVER_WEXT_SUPPORT) \
72
73 ifeq ($(LOCAL_VARIANT),full)
74 DRIVER_MAKEOPTS += CONFIG_IEEE80211W=$(CONFIG_DRIVER_11W_SUPPORT)
75 endif
76
77 ifneq ($(LOCAL_TYPE),hostapd)
78 ifdef CONFIG_WPA_SUPPLICANT_OPENSSL
79 ifeq ($(LOCAL_VARIANT),full)
80 DRIVER_MAKEOPTS += CONFIG_TLS=openssl
81 TARGET_LDFLAGS += -lcrypto -lssl
82 endif
83 endif
84 ifeq ($(LOCAL_VARIANT),mesh)
85 DRIVER_MAKEOPTS += CONFIG_TLS=openssl CONFIG_AP=y CONFIG_SAE=y CONFIG_MESH=y
86 TARGET_LDFLAGS += -lcrypto -lssl
87 endif
88 ifdef CONFIG_WPA_SUPPLICANT_NO_TIMESTAMP_CHECK
89 TARGET_CFLAGS += -DNO_TIMESTAMP_CHECK
90 endif
91 ifdef CONFIG_WPA_RFKILL_SUPPORT
92 DRIVER_MAKEOPTS += NEED_RFKILL=y
93 endif
94 DRIVER_MAKEOPTS += \
95 CONFIG_DRIVER_ROBOSWITCH=$(CONFIG_PACKAGE_kmod-switch)
96 endif
97
98 ifdef CONFIG_USE_GLIBC
99 TARGET_LDFLAGS += -lrt
100 TARGET_LDFLAGS_C += -lrt
101 endif
102
103 DRV_DEPENDS:=+PACKAGE_kmod-cfg80211:libnl-tiny
104
105 define Package/hostapd/Default
106 SECTION:=net
107 CATEGORY:=Network
108 TITLE:=IEEE 802.1x Authenticator
109 URL:=http://hostap.epitest.fi/
110 DEPENDS:=$(DRV_DEPENDS) +hostapd-common +libubus
111 endef
112
113 define Package/hostapd
114 $(call Package/hostapd/Default)
115 TITLE+= (full)
116 VARIANT:=full
117 CONFLICTS:=wpad wpad-mini wpad-mesh
118 endef
119
120 define Package/hostapd/description
121 This package contains a full featured IEEE 802.1x/WPA/EAP/RADIUS
122 Authenticator.
123 endef
124
125 define Package/hostapd-mini
126 $(call Package/hostapd/Default)
127 TITLE+= (WPA-PSK only)
128 VARIANT:=mini
129 CONFLICTS:=wpad wpad-mini wpad-mesh
130 endef
131
132 define Package/hostapd-mini/description
133 This package contains a minimal IEEE 802.1x/WPA Authenticator (WPA-PSK only).
134 endef
135
136 define Package/hostapd-utils
137 $(call Package/hostapd/Default)
138 TITLE+= (utils)
139 DEPENDS:=@PACKAGE_hostapd||PACKAGE_hostapd-mini||PACKAGE_wpad||PACKAGE_wpad-mesh||PACKAGE_wpad-mini
140 endef
141
142 define Package/hostapd-utils/description
143 This package contains a command line utility to control the
144 IEEE 802.1x/WPA/EAP/RADIUS Authenticator.
145 endef
146
147 define Package/wpad/Default
148 SECTION:=net
149 CATEGORY:=Network
150 TITLE:=IEEE 802.1x Authenticator/Supplicant
151 DEPENDS:=$(DRV_DEPENDS) +hostapd-common +libubus
152 URL:=http://hostap.epitest.fi/
153 endef
154
155 define Package/wpad
156 $(call Package/wpad/Default)
157 TITLE+= (full)
158 DEPENDS+=+WPA_SUPPLICANT_OPENSSL:libopenssl
159 VARIANT:=wpad-full
160 endef
161
162 define Package/wpad/description
163 This package contains a full featured IEEE 802.1x/WPA/EAP/RADIUS
164 Authenticator and Supplicant
165 endef
166
167 define Package/wpad-mini
168 $(call Package/wpad/Default)
169 TITLE+= (WPA-PSK only)
170 VARIANT:=wpad-mini
171 endef
172
173 define Package/wpad-mini/description
174 This package contains a minimal IEEE 802.1x/WPA Authenticator and Supplicant (WPA-PSK only).
175 endef
176
177 define Package/wpad-mesh
178 $(call Package/wpad/Default)
179 TITLE+= (with 802.11s mesh and SAE support)
180 DEPENDS:=$(DRV_DEPENDS) +libubus +PACKAGE_wpad-mesh:libopenssl @(!TARGET_uml||BROKEN)
181 VARIANT:=wpad-mesh
182 endef
183
184 define Package/wpad-mesh/description
185 This package contains a minimal IEEE 802.1x/WPA Authenticator and Supplicant (with 802.11s mesh and SAE support).
186 endef
187
188 define Package/wpa-supplicant
189 SECTION:=net
190 CATEGORY:=Network
191 TITLE:=WPA Supplicant
192 URL:=http://hostap.epitest.fi/wpa_supplicant/
193 DEPENDS:=$(DRV_DEPENDS) +WPA_SUPPLICANT_OPENSSL:libopenssl
194 CONFLICTS:=wpad wpad-mini wpad-mesh
195 VARIANT:=supplicant-full
196 endef
197
198 define Package/wpa-supplicant/Description
199 WPA Supplicant
200 endef
201
202 define Package/wpa-supplicant/config
203 source "$(SOURCE)/Config.in"
204 endef
205
206 define Package/wpa-supplicant-p2p
207 $(Package/wpa-supplicant)
208 TITLE:=WPA Supplicant (with Wi-Fi P2P support)
209 DEPENDS:=$(DRV_DEPENDS)
210 CONFLICTS:=wpad wpad-mini wpad-mesh
211 VARIANT:=supplicant-p2p
212 endef
213
214 define Package/wpa-supplicant-p2p/Description
215 WPA Supplicant (with Wi-Fi P2P support)
216 endef
217
218 define Package/wpa-supplicant-mesh
219 $(Package/wpa-supplicant)
220 TITLE:=WPA Supplicant (with 802.11s and SAE)
221 DEPENDS:=$(DRV_DEPENDS) @(!TARGET_uml||BROKEN)
222 CONFLICTS:=wpad wpad-mesh wpad-mesh
223 VARIANT:=supplicant-mesh
224 endef
225
226 define Package/wpa-supplicant-mesh/Description
227 WPA Supplicant (variant with 802.11s and SAE support)
228 endef
229
230 define Package/wpa-supplicant-mini
231 $(Package/wpa-supplicant)
232 TITLE:=WPA Supplicant (minimal version)
233 DEPENDS:=$(DRV_DEPENDS)
234 CONFLICTS:=wpad wpad-mini wpad-mesh
235 VARIANT:=supplicant-mini
236 endef
237
238 define Package/wpa-supplicant-mini/Description
239 WPA Supplicant (minimal version)
240 endef
241
242 define Package/wpa-cli
243 SECTION:=net
244 CATEGORY:=Network
245 DEPENDS:=@PACKAGE_wpa-supplicant||PACKAGE_wpa-supplicant-p2p||PACKAGE_wpad-mini||PACKAGE_wpad||PACKAGE_wpad-mesh
246 TITLE:=WPA Supplicant command line interface
247 endef
248
249 define Package/wpa-cli/Description
250 WPA Supplicant control utility
251 endef
252
253 define Package/hostapd-common
254 TITLE:=hostapd/wpa_supplicant common support files
255 SECTION:=net
256 CATEGORY:=Network
257 endef
258
259 define Package/hostapd-common-old
260 TITLE:=hostapd/wpa_supplicant common support files (legacy drivers)
261 SECTION:=net
262 CATEGORY:=Network
263 endef
264
265 define Package/eapol-test
266 TITLE:=802.1x authentication test utility
267 SECTION:=net
268 CATEGORY:=Network
269 VARIANT:=supplicant-full
270 DEPENDS:=$(DRV_DEPENDS)
271 endef
272
273
274 ifneq ($(wildcard $(PKG_BUILD_DIR)/.config_*),$(subst .configured_,.config_,$(STAMP_CONFIGURED)))
275 define Build/Configure/rebuild
276 $(FIND) $(PKG_BUILD_DIR) -name \*.o -or -name \*.a | $(XARGS) rm -f
277 rm -f $(PKG_BUILD_DIR)/hostapd/hostapd
278 rm -f $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant
279 rm -f $(PKG_BUILD_DIR)/.config_*
280 touch $(subst .configured_,.config_,$(STAMP_CONFIGURED))
281 endef
282 endif
283
284 define Build/Configure
285 $(Build/Configure/rebuild)
286 $(if $(wildcard ./files/hostapd-$(CONFIG_VARIANT).config), \
287 $(CP) ./files/hostapd-$(CONFIG_VARIANT).config $(PKG_BUILD_DIR)/hostapd/.config \
288 )
289 $(CP) ./files/wpa_supplicant-$(CONFIG_VARIANT).config $(PKG_BUILD_DIR)/wpa_supplicant/.config
290 endef
291
292 TARGET_CPPFLAGS := \
293 -I$(STAGING_DIR)/usr/include/libnl-tiny \
294 -I$(PKG_BUILD_DIR)/src/crypto \
295 $(TARGET_CPPFLAGS) \
296 -DCONFIG_LIBNL20 \
297 -D_GNU_SOURCE \
298 $(if $(CONFIG_WPA_MSG_MIN_PRIORITY),-DCONFIG_MSG_MIN_PRIORITY=$(CONFIG_WPA_MSG_MIN_PRIORITY))
299
300 TARGET_CFLAGS += -ffunction-sections -fdata-sections
301 TARGET_LDFLAGS += -Wl,--gc-sections
302 ifeq ($(findstring supplicant,$(BUILD_VARIANT)),)
303 TARGET_LDFLAGS += -lubox -lubus
304 endif
305
306 ifdef CONFIG_PACKAGE_kmod-cfg80211
307 TARGET_LDFLAGS += -lm -lnl-tiny
308 endif
309
310 define Build/RunMake
311 CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
312 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(1) \
313 $(TARGET_CONFIGURE_OPTS) \
314 $(DRIVER_MAKEOPTS) \
315 LIBS="$(TARGET_LDFLAGS)" \
316 LIBS_c="$(TARGET_LDFLAGS_C)" \
317 BCHECK= \
318 $(2)
319 endef
320
321 define Build/Compile/wpad
322 echo ` \
323 $(call Build/RunMake,hostapd,-s MULTICALL=1 dump_cflags); \
324 $(call Build/RunMake,wpa_supplicant,-s MULTICALL=1 dump_cflags) | \
325 sed -e 's,-n ,,g' -e 's^$(TARGET_CFLAGS)^^' \
326 ` > $(PKG_BUILD_DIR)/.cflags
327 +$(call Build/RunMake,hostapd, \
328 CFLAGS="$$$$(cat $(PKG_BUILD_DIR)/.cflags)" \
329 MULTICALL=1 \
330 hostapd_cli hostapd_multi.a \
331 )
332 +$(call Build/RunMake,wpa_supplicant, \
333 CFLAGS="$$$$(cat $(PKG_BUILD_DIR)/.cflags)" \
334 MULTICALL=1 \
335 wpa_cli wpa_supplicant_multi.a \
336 )
337 $(TARGET_CC) -o $(PKG_BUILD_DIR)/wpad \
338 $(TARGET_CFLAGS) \
339 ./files/multicall.c \
340 $(PKG_BUILD_DIR)/hostapd/hostapd_multi.a \
341 $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant_multi.a \
342 $(TARGET_LDFLAGS)
343 endef
344
345 define Build/Compile/hostapd
346 $(call Build/RunMake,hostapd, \
347 hostapd hostapd_cli \
348 )
349 endef
350
351 define Build/Compile/supplicant
352 $(call Build/RunMake,wpa_supplicant, \
353 wpa_cli wpa_supplicant \
354 )
355 endef
356
357 define Build/Compile/supplicant-full
358 $(call Build/RunMake,wpa_supplicant, \
359 eapol_test \
360 )
361 endef
362
363 define Build/Compile
364 $(Build/Compile/$(LOCAL_TYPE))
365 $(Build/Compile/$(BUILD_VARIANT))
366 endef
367
368 define Install/hostapd
369 $(INSTALL_DIR) $(1)/usr/sbin
370 endef
371
372 define Install/supplicant
373 $(INSTALL_DIR) $(1)/usr/sbin
374 endef
375
376 define Package/hostapd-common/install
377 $(INSTALL_DIR) $(1)/lib/netifd
378 $(INSTALL_DATA) ./files/netifd.sh $(1)/lib/netifd/hostapd.sh
379 endef
380
381 define Package/hostapd-common-old/install
382 $(INSTALL_DIR) $(1)/lib/wifi
383 $(INSTALL_DATA) ./files/hostapd.sh $(1)/lib/wifi/hostapd.sh
384 $(INSTALL_DATA) ./files/wpa_supplicant.sh $(1)/lib/wifi/wpa_supplicant.sh
385 endef
386
387 define Package/hostapd/install
388 $(call Install/hostapd,$(1))
389 $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostapd/hostapd $(1)/usr/sbin/
390 endef
391 Package/hostapd-mini/install = $(Package/hostapd/install)
392
393 ifneq ($(LOCAL_TYPE),supplicant)
394 define Package/hostapd-utils/install
395 $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/rc.button
396 $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostapd/hostapd_cli $(1)/usr/sbin/
397 $(INSTALL_BIN) ./files/wps-hotplug.sh $(1)/etc/rc.button/wps
398 endef
399 endif
400
401 define Package/wpad/install
402 $(call Install/hostapd,$(1))
403 $(call Install/supplicant,$(1))
404 $(INSTALL_BIN) $(PKG_BUILD_DIR)/wpad $(1)/usr/sbin/
405 $(LN) wpad $(1)/usr/sbin/hostapd
406 $(LN) wpad $(1)/usr/sbin/wpa_supplicant
407 endef
408 Package/wpad-mini/install = $(Package/wpad/install)
409 Package/wpad-mesh/install = $(Package/wpad/install)
410
411 define Package/wpa-supplicant/install
412 $(call Install/supplicant,$(1))
413 $(INSTALL_BIN) $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant $(1)/usr/sbin/
414 endef
415 Package/wpa-supplicant-mini/install = $(Package/wpa-supplicant/install)
416 Package/wpa-supplicant-p2p/install = $(Package/wpa-supplicant/install)
417
418 ifneq ($(LOCAL_TYPE),hostapd)
419 define Package/wpa-cli/install
420 $(INSTALL_DIR) $(1)/usr/sbin
421 $(CP) $(PKG_BUILD_DIR)/wpa_supplicant/wpa_cli $(1)/usr/sbin/
422 endef
423 endif
424
425 ifeq ($(BUILD_VARIANT),supplicant-full)
426 define Package/eapol-test/install
427 $(INSTALL_DIR) $(1)/usr/sbin
428 $(CP) $(PKG_BUILD_DIR)/wpa_supplicant/eapol_test $(1)/usr/sbin/
429 endef
430 endif
431
432 $(eval $(call BuildPackage,hostapd))
433 $(eval $(call BuildPackage,hostapd-mini))
434 $(eval $(call BuildPackage,wpad))
435 $(eval $(call BuildPackage,wpad-mesh))
436 $(eval $(call BuildPackage,wpad-mini))
437 $(eval $(call BuildPackage,wpa-supplicant))
438 $(eval $(call BuildPackage,wpa-supplicant-mesh))
439 $(eval $(call BuildPackage,wpa-supplicant-mini))
440 $(eval $(call BuildPackage,wpa-supplicant-p2p))
441 $(eval $(call BuildPackage,wpa-cli))
442 $(eval $(call BuildPackage,hostapd-utils))
443 $(eval $(call BuildPackage,hostapd-common))
444 $(eval $(call BuildPackage,hostapd-common-old))
445 $(eval $(call BuildPackage,eapol-test))