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