[hostapd] use new button scheme
[openwrt.git] / package / network / services / hostapd / Makefile
1 #
2 # Copyright (C) 2006-2012 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:=20130302
12 PKG_RELEASE:=1
13 PKG_REV:=a311c61dd664db7c1d16dd3395adf07bea6c141d
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:=d81d1b073521df0c608f42e2cedec60c
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 DRV_DEPENDS:=+PACKAGE_kmod-mac80211:libnl-tiny @(!TARGET_avr32||BROKEN)
90
91 define Package/hostapd/Default
92   SECTION:=net
93   CATEGORY:=Network
94   TITLE:=IEEE 802.1x Authenticator
95   URL:=http://hostap.epitest.fi/
96   DEPENDS:=$(DRV_DEPENDS)
97 endef
98
99 define Package/hostapd
100 $(call Package/hostapd/Default)
101   TITLE+= (full)
102   VARIANT:=full
103 endef
104
105 define Package/hostapd/description
106  This package contains a full featured IEEE 802.1x/WPA/EAP/RADIUS
107  Authenticator.
108 endef
109
110 define Package/hostapd-mini
111 $(call Package/hostapd/Default)
112   TITLE+= (WPA-PSK only)
113   VARIANT:=mini
114 endef
115
116 define Package/hostapd-mini/description
117  This package contains a minimal IEEE 802.1x/WPA Authenticator (WPA-PSK only).
118 endef
119
120 define Package/hostapd-utils
121   $(call Package/hostapd/Default)
122   TITLE+= (utils)
123   DEPENDS:=@PACKAGE_hostapd||PACKAGE_hostapd-mini||PACKAGE_wpad||PACKAGE_wpad-mini
124 endef
125
126 define Package/hostapd-utils/description
127  This package contains a command line utility to control the
128  IEEE 802.1x/WPA/EAP/RADIUS Authenticator.
129 endef
130
131 define Package/wpad/Default
132   SECTION:=net
133   CATEGORY:=Network
134   TITLE:=IEEE 802.1x Authenticator/Supplicant
135   URL:=http://hostap.epitest.fi/
136 endef
137
138 define Package/wpad
139 $(call Package/wpad/Default)
140   TITLE+= (full)
141   DEPENDS:=$(DRV_DEPENDS) +WPA_SUPPLICANT_OPENSSL:libopenssl
142   VARIANT:=wpad-full
143 endef
144
145 define Package/wpad/description
146  This package contains a full featured IEEE 802.1x/WPA/EAP/RADIUS
147  Authenticator and Supplicant
148 endef
149
150 define Package/wpad-mini
151 $(call Package/wpad/Default)
152   TITLE+= (WPA-PSK only)
153   DEPENDS:=$(DRV_DEPENDS)
154   VARIANT:=wpad-mini
155 endef
156
157 define Package/wpad-mini/description
158  This package contains a minimal IEEE 802.1x/WPA Authenticator and Supplicant (WPA-PSK only).
159 endef
160
161 define Package/wpa-supplicant
162   SECTION:=net
163   CATEGORY:=Network
164   TITLE:=WPA Supplicant
165   URL:=http://hostap.epitest.fi/wpa_supplicant/
166   DEPENDS:=$(DRV_DEPENDS) +WPA_SUPPLICANT_OPENSSL:libopenssl
167   VARIANT:=supplicant-full
168 endef
169
170 define Package/wpa-supplicant/Description
171   WPA Supplicant
172 endef
173
174 define Package/wpa-supplicant/config
175         source "$(SOURCE)/Config.in"
176 endef
177
178 define Package/wpa-supplicant-mini
179   $(Package/wpa-supplicant)
180   TITLE:=WPA Supplicant (minimal version)
181   DEPENDS:=$(DRV_DEPENDS)
182   VARIANT:=supplicant-mini
183 endef
184
185 define Package/wpa-supplicant-mini/Description
186   WPA Supplicant (minimal version)
187 endef
188
189 define Package/wpa-cli
190   SECTION:=net
191   CATEGORY:=Network
192   DEPENDS:=@PACKAGE_wpa-supplicant||PACKAGE_wpad-mini||PACKAGE_wpad
193   TITLE:=WPA Supplicant command line interface
194 endef
195
196 define Package/wpa-cli/Description
197   WPA Supplicant control utility
198 endef
199
200
201 ifneq ($(wildcard $(PKG_BUILD_DIR)/.config_*),$(subst .configured_,.config_,$(STAMP_CONFIGURED)))
202   define Build/Configure/rebuild
203         $(FIND) $(PKG_BUILD_DIR) -name \*.o -or -name \*.a | $(XARGS) rm -f
204         rm -f $(PKG_BUILD_DIR)/hostapd/hostapd
205         rm -f $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant
206         rm -f $(PKG_BUILD_DIR)/.config_*
207         touch $(subst .configured_,.config_,$(STAMP_CONFIGURED))
208   endef
209 endif
210
211 define Build/Configure
212         $(Build/Configure/rebuild)
213         $(CP) ./files/hostapd-$(LOCAL_VARIANT).config $(PKG_BUILD_DIR)/hostapd/.config
214         $(CP) ./files/wpa_supplicant-$(LOCAL_VARIANT).config $(PKG_BUILD_DIR)/wpa_supplicant/.config
215 endef
216
217 TARGET_CPPFLAGS := \
218         -I$(STAGING_DIR)/usr/include/libnl-tiny \
219         -I$(PKG_BUILD_DIR)/src/crypto \
220         $(TARGET_CPPFLAGS) \
221         -I$(CURDIR)/madwifi \
222         -DCONFIG_LIBNL20 \
223         -D_GNU_SOURCE \
224         $(if $(CONFIG_WPA_MSG_MIN_PRIORITY),-DCONFIG_MSG_MIN_PRIORITY=$(CONFIG_WPA_MSG_MIN_PRIORITY))
225
226 TARGET_CFLAGS += -ffunction-sections -fdata-sections
227 TARGET_LDFLAGS += -Wl,--gc-sections
228
229 ifdef CONFIG_PACKAGE_kmod-mac80211
230   TARGET_LDFLAGS += -lm -lnl-tiny
231 endif
232
233 define Build/RunMake
234         CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
235         $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(1) \
236                 $(TARGET_CONFIGURE_OPTS) \
237                 $(DRIVER_MAKEOPTS) \
238                 LIBS="$(TARGET_LDFLAGS)" \
239                 BCHECK= \
240                 $(2)
241 endef
242
243 define Build/Compile/wpad
244         echo ` \
245                 $(call Build/RunMake,hostapd,-s MULTICALL=1 dump_cflags); \
246                 $(call Build/RunMake,wpa_supplicant,-s MULTICALL=1 dump_cflags) | \
247                 sed -e 's,-n ,,g' -e 's,$(TARGET_CFLAGS),,' \
248         ` > $(PKG_BUILD_DIR)/.cflags
249         +$(call Build/RunMake,hostapd, \
250                 CFLAGS="$$$$(cat $(PKG_BUILD_DIR)/.cflags)" \
251                 MULTICALL=1 \
252                 hostapd_cli hostapd_multi.a \
253         )
254         +$(call Build/RunMake,wpa_supplicant, \
255                 CFLAGS="$$$$(cat $(PKG_BUILD_DIR)/.cflags)" \
256                 MULTICALL=1 \
257                 wpa_cli wpa_supplicant_multi.a \
258         )
259         $(TARGET_CC) -o $(PKG_BUILD_DIR)/wpad \
260                 $(TARGET_CFLAGS) \
261                 ./files/multicall.c \
262                 $(PKG_BUILD_DIR)/hostapd/hostapd_multi.a \
263                 $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant_multi.a \
264                 $(TARGET_LDFLAGS)
265 endef
266
267 define Build/Compile/hostapd
268         $(call Build/RunMake,hostapd, \
269                 hostapd hostapd_cli \
270         )
271 endef
272
273 define Build/Compile/supplicant
274         $(call Build/RunMake,wpa_supplicant, \
275                 wpa_cli wpa_supplicant \
276         )
277 endef
278
279 define Build/Compile
280         $(Build/Compile/$(LOCAL_TYPE))
281 endef
282
283 define Install/hostapd
284         $(INSTALL_DIR) $(1)/lib/wifi
285         $(INSTALL_DATA) ./files/hostapd.sh $(1)/lib/wifi/hostapd.sh
286         $(INSTALL_DIR) $(1)/usr/sbin
287 endef
288
289 define Install/supplicant
290         $(INSTALL_DIR) $(1)/lib/wifi
291         $(INSTALL_DATA) ./files/wpa_supplicant.sh $(1)/lib/wifi/wpa_supplicant.sh
292         $(INSTALL_DIR) $(1)/usr/sbin
293 endef
294
295 define Package/hostapd/install
296         $(call Install/hostapd,$(1))
297         $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostapd/hostapd $(1)/usr/sbin/
298 endef
299 Package/hostapd-mini/install = $(Package/hostapd/install)
300
301 ifneq ($(LOCAL_TYPE),supplicant)
302   define Package/hostapd-utils/install
303         $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/hotplug.d/button
304         $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostapd/hostapd_cli $(1)/usr/sbin/
305         $(INSTALL_DATA) ./files/wps-hotplug.sh $(1)/etc/hotplug.d/button/50-wps
306         $(if $(CONFIG_PROCD_INIT),
307                 $(INSTALL_DIR) $(1)/etc/rc.button/
308                 $(INSTALL_BIN) ./files/wps-hotplug.sh $(1)/etc/rc.button/wps,
309                 $(INSTALL_DATA) ./files/wps-hotplug.sh $(1)/etc/hotplug.d/button/50-wps
310         )
311   endef
312 endif
313
314 define Package/wpad/install
315         $(call Install/hostapd,$(1))
316         $(call Install/supplicant,$(1))
317         $(INSTALL_BIN) $(PKG_BUILD_DIR)/wpad $(1)/usr/sbin/
318         ln -sf wpad $(1)/usr/sbin/hostapd
319         ln -sf wpad $(1)/usr/sbin/wpa_supplicant
320 endef
321 Package/wpad-mini/install = $(Package/wpad/install)
322
323 define Package/wpa-supplicant/install
324         $(call Install/supplicant,$(1))
325         $(INSTALL_BIN) $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant $(1)/usr/sbin/
326 endef
327 Package/wpa-supplicant-mini/install = $(Package/wpa-supplicant/install)
328
329 ifneq ($(LOCAL_TYPE),hostapd)
330   define Package/wpa-cli/install
331         $(INSTALL_DIR) $(1)/usr/sbin
332         $(CP) $(PKG_BUILD_DIR)/wpa_supplicant/wpa_cli $(1)/usr/sbin/
333   endef
334 endif
335
336 $(eval $(call BuildPackage,hostapd))
337 $(eval $(call BuildPackage,hostapd-mini))
338 $(eval $(call BuildPackage,wpad))
339 $(eval $(call BuildPackage,wpad-mini))
340 $(eval $(call BuildPackage,wpa-supplicant))
341 $(eval $(call BuildPackage,wpa-supplicant-mini))
342 $(eval $(call BuildPackage,wpa-cli))
343 $(eval $(call BuildPackage,hostapd-utils))