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