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