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