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