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