hostapd: clean up openssl tls dependencies and build handling (fixes #6572)
[openwrt/openwrt.git] / package / hostapd / Makefile
1 #
2 # Copyright (C) 2006-2009 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:=20100309
12 PKG_RELEASE:=1
13 PKG_REV:=7b90c16aa9ca377b1a6d160c1ba0f2bd304f7e2f
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:=hostapd-$(PKG_VERSION)
18 PKG_SOURCE_VERSION:=$(PKG_REV)
19 PKG_SOURCE_PROTO:=git
20
21 PKG_BUILD_DEPENDS:= \
22 PACKAGE_kmod-madwifi:madwifi \
23 PACKAGE_kmod-mac80211:mac80211 \
24
25 PKG_CONFIG_DEPENDS:= \
26 CONFIG_WPA_SUPPLICANT_NO_TIMESTAMP_CHECK \
27 CONFIG_PACKAGE_kmod-ath9k \
28 CONFIG_PACKAGE_kmod-mac80211 \
29 CONFIG_PACKAGE_kmod-madwifi \
30 CONFIG_PACKAGE_hostapd \
31 CONFIG_PACKAGE_hostapd-mini \
32 CONFIG_PACKAGE_kmod-hostap
33
34 LOCAL_TYPE=$(strip \
35 $(if $(findstring wpad,$(BUILD_VARIANT)),wpad, \
36 $(if $(findstring supplicant,$(BUILD_VARIANT)),supplicant, \
37 hostapd \
38 )))
39 LOCAL_VARIANT=$(patsubst wpad-%,%,$(patsubst supplicant-%,%,$(BUILD_VARIANT)))
40
41 ifeq ($(LOCAL_TYPE),supplicant)
42 ifeq ($(LOCAL_VARIANT),full)
43 PKG_CONFIG_DEPENDS += \
44 CONFIG_WPA_SUPPLICANT_INTERNAL \
45 CONFIG_WPA_SUPPLICANT_OPENSSL
46 endif
47 endif
48
49 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
50
51 include $(INCLUDE_DIR)/package.mk
52
53 DRIVER_MAKEOPTS= \
54 CONFIG_DRIVER_NL80211=$(CONFIG_PACKAGE_kmod-mac80211) \
55 CONFIG_DRIVER_MADWIFI=$(CONFIG_PACKAGE_kmod-madwifi) \
56 CONFIG_DRIVER_HOSTAP=$(CONFIG_PACKAGE_kmod-hostap) \
57 CONFIG_IEEE80211N=$(CONFIG_PACKAGE_kmod-ath9k) \
58 CONFIG_IEEE80211W=$(CONFIG_PACKAGE_kmod-ath9k)
59
60 ifneq ($(LOCAL_TYPE),hostapd)
61 ifdef CONFIG_WPA_SUPPLICANT_OPENSSL
62 ifeq ($(LOCAL_VARIANT),full)
63 DRIVER_MAKEOPTS += CONFIG_TLS=openssl
64 TARGET_LDFLAGS += -lcrypto -lssl
65 endif
66 endif
67 ifdef CONFIG_WPA_SUPPLICANT_NO_TIMESTAMP_CHECK
68 TARGET_CFLAGS += -DNO_TIMESTAMP_CHECK
69 endif
70 DRIVER_MAKEOPTS += \
71 CONFIG_DRIVER_ROBOSWITCH=$(CONFIG_PACKAGE_kmod-switch)
72 endif
73
74 DRV_DEPENDS:=+PACKAGE_kmod-mac80211:libnl-tiny +PACKAGE_kmod-mac80211:crda @(!(TARGET_avr32||TARGET_etrax)||BROKEN)
75
76 define Package/hostapd/Default
77 SECTION:=net
78 CATEGORY:=Network
79 TITLE:=IEEE 802.1x Authenticator
80 URL:=http://hostap.epitest.fi/
81 DEPENDS:=$(DRV_DEPENDS)
82 MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
83 endef
84
85 define Package/hostapd
86 $(call Package/hostapd/Default)
87 TITLE+= (full)
88 VARIANT:=full
89 endef
90
91 define Package/hostapd/description
92 This package contains a full featured IEEE 802.1x/WPA/EAP/RADIUS
93 Authenticator.
94 endef
95
96 define Package/hostapd-mini
97 $(call Package/hostapd/Default)
98 TITLE+= (WPA-PSK only)
99 VARIANT:=mini
100 endef
101
102 define Package/hostapd-mini/description
103 This package contains a minimal IEEE 802.1x/WPA Authenticator (WPA-PSK only).
104 endef
105
106 define Package/hostapd-utils
107 $(call Package/hostapd/Default)
108 TITLE+= (utils)
109 DEPENDS:=@PACKAGE_hostapd||PACKAGE_hostapd-mini
110 endef
111
112 define Package/hostapd-utils/description
113 This package contains a command line utility to control the
114 IEEE 802.1x/WPA/EAP/RADIUS Authenticator.
115 endef
116
117 define Package/wpad/Default
118 SECTION:=net
119 CATEGORY:=Network
120 TITLE:=IEEE 802.1x Authenticator/Supplicant
121 URL:=http://hostap.epitest.fi/
122 MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
123 endef
124
125 define Package/wpad
126 $(call Package/wpad/Default)
127 TITLE+= (full)
128 DEPENDS:=$(DRV_DEPENDS) +WPA_SUPPLICANT_OPENSSL:libopenssl
129 VARIANT:=wpad-full
130 endef
131
132 define Package/wpad/description
133 This package contains a full featured IEEE 802.1x/WPA/EAP/RADIUS
134 Authenticator and Supplicant
135 endef
136
137 define Package/wpad-mini
138 $(call Package/wpad/Default)
139 TITLE+= (WPA-PSK only)
140 DEPENDS:=$(DRV_DEPENDS)
141 VARIANT:=wpad-mini
142 endef
143
144 define Package/wpad-mini/description
145 This package contains a minimal IEEE 802.1x/WPA Authenticator and Supplicant (WPA-PSK only).
146 endef
147
148 define Package/wpa-supplicant
149 SECTION:=net
150 CATEGORY:=Network
151 TITLE:=WPA Supplicant
152 URL:=http://hostap.epitest.fi/wpa_supplicant/
153 DEPENDS:=$(DRV_DEPENDS) +WPA_SUPPLICANT_OPENSSL:libopenssl
154 VARIANT:=supplicant-full
155 MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
156 endef
157
158 define Package/wpa-supplicant/Description
159 WPA Supplicant
160 endef
161
162 define Package/wpa-supplicant/config
163 source "$(SOURCE)/Config.in"
164 endef
165
166 define Package/wpa-supplicant-mini
167 $(Package/wpa-supplicant)
168 TITLE:=WPA Supplicant (minimal version)
169 DEPENDS:=$(DRV_DEPENDS)
170 VARIANT:=supplicant-mini
171 endef
172
173 define Package/wpa-supplicant-mini/Description
174 WPA Supplicant (minimal version)
175 endef
176
177 define Package/wpa-cli
178 SECTION:=net
179 CATEGORY:=Network
180 DEPENDS:=wpa-supplicant
181 TITLE:=WPA Supplicant command line interface
182 MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
183 endef
184
185 define Package/wpa-cli/Description
186 WPA Supplicant control utility
187 endef
188
189
190 ifneq ($(wildcard $(PKG_BUILD_DIR)/.config_*),$(subst .configured_,.config_,$(STAMP_CONFIGURED)))
191 define Build/Configure/rebuild
192 $(FIND) $(PKG_BUILD_DIR) -name \*.o -or -name \*.a | $(XARGS) rm -f
193 rm -f $(PKG_BUILD_DIR)/hostapd/hostapd
194 rm -f $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant
195 rm -f $(PKG_BUILD_DIR)/.config_*
196 touch $(subst .configured_,.config_,$(STAMP_CONFIGURED))
197 endef
198 endif
199
200 define Build/Configure
201 $(Build/Configure/rebuild)
202 $(CP) ./files/hostapd-$(LOCAL_VARIANT).config $(PKG_BUILD_DIR)/hostapd/.config
203 $(CP) ./files/wpa_supplicant-$(LOCAL_VARIANT).config $(PKG_BUILD_DIR)/wpa_supplicant/.config
204 endef
205
206 TARGET_CPPFLAGS := \
207 -I$(STAGING_DIR)/usr/include/libnl-tiny \
208 -I$(PKG_BUILD_DIR)/src/crypto \
209 $(TARGET_CPPFLAGS) \
210 -I$(STAGING_DIR)/usr/include/madwifi \
211 -I$(STAGING_DIR)/usr/include/mac80211 \
212 -DCONFIG_LIBNL20 \
213 -D_GNU_SOURCE
214
215 ifdef CONFIG_PACKAGE_kmod-mac80211
216 TARGET_LDFLAGS += -lm -lnl-tiny
217 endif
218
219 define Build/RunMake
220 CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
221 $(MAKE) -C $(PKG_BUILD_DIR)/$(1) \
222 $(TARGET_CONFIGURE_OPTS) \
223 $(DRIVER_MAKEOPTS) \
224 LIBS="$(TARGET_LDFLAGS)" \
225 $(2)
226 endef
227
228 define Build/Compile/wpad
229 echo ` \
230 $(call Build/RunMake,hostapd,-s MULTICALL=1 dump_cflags); \
231 $(call Build/RunMake,wpa_supplicant,-s dump_cflags) | \
232 sed -e 's,-n ,,g' -e 's,$(TARGET_CFLAGS),,' \
233 ` > $(PKG_BUILD_DIR)/.cflags
234 $(call Build/RunMake,hostapd, \
235 CFLAGS="$$$$(cat $(PKG_BUILD_DIR)/.cflags)" \
236 MULTICALL=1 \
237 hostapd_cli hostapd_multi.a \
238 )
239 $(call Build/RunMake,wpa_supplicant, \
240 CFLAGS="$$$$(cat $(PKG_BUILD_DIR)/.cflags)" \
241 MULTICALL=1 \
242 wpa_cli wpa_supplicant_multi.a \
243 )
244 $(TARGET_CC) -o $(PKG_BUILD_DIR)/wpad \
245 $(TARGET_CFLAGS) \
246 ./files/multicall.c \
247 $(PKG_BUILD_DIR)/hostapd/hostapd_multi.a \
248 $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant_multi.a \
249 $(TARGET_LDFLAGS)
250 endef
251
252 define Build/Compile/hostapd
253 $(call Build/RunMake,hostapd, \
254 hostapd hostapd_cli \
255 )
256 endef
257
258 define Build/Compile/supplicant
259 $(call Build/RunMake,wpa_supplicant, \
260 wpa_cli wpa_supplicant \
261 )
262 endef
263
264 define Build/Compile
265 $(Build/Compile/$(LOCAL_TYPE))
266 endef
267
268 define Install/hostapd
269 $(INSTALL_DIR) $(1)/lib/wifi
270 $(INSTALL_DATA) ./files/hostapd.sh $(1)/lib/wifi/hostapd.sh
271 $(INSTALL_DIR) $(1)/usr/sbin
272 endef
273
274 define Install/supplicant
275 $(INSTALL_DIR) $(1)/lib/wifi
276 $(INSTALL_DATA) ./files/wpa_supplicant.sh $(1)/lib/wifi/wpa_supplicant.sh
277 $(INSTALL_DIR) $(1)/usr/sbin
278 endef
279
280 define Package/hostapd/install
281 $(call Install/hostapd,$(1))
282 $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostapd/hostapd $(1)/usr/sbin/
283 endef
284 Package/hostapd-mini/install = $(Package/hostapd/install)
285
286 ifneq ($(LOCAL_TYPE),supplicant)
287 define Package/hostapd-utils/install
288 $(INSTALL_DIR) $(1)/usr/sbin
289 $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostapd/hostapd_cli $(1)/usr/sbin/
290 endef
291 endif
292
293 define Package/wpad/install
294 $(call Install/hostapd,$(1))
295 $(call Install/supplicant,$(1))
296 $(INSTALL_BIN) $(PKG_BUILD_DIR)/wpad $(1)/usr/sbin/
297 ln -sf wpad $(1)/usr/sbin/hostapd
298 ln -sf wpad $(1)/usr/sbin/wpa_supplicant
299 endef
300 Package/wpad-mini/install = $(Package/wpad/install)
301
302 define Package/wpa-supplicant/install
303 $(call Install/supplicant,$(1))
304 $(INSTALL_BIN) $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant $(1)/usr/sbin/
305 endef
306 Package/wpa-supplicant-mini/install = $(Package/wpa-supplicant/install)
307
308 ifneq ($(LOCAL_TYPE),hostapd)
309 define Package/wpa-cli/install
310 $(INSTALL_DIR) $(1)/usr/sbin
311 $(CP) $(PKG_BUILD_DIR)/wpa_supplicant/wpa_cli $(1)/usr/sbin/
312 endef
313 endif
314
315 $(eval $(call BuildPackage,hostapd))
316 $(eval $(call BuildPackage,hostapd-mini))
317 $(eval $(call BuildPackage,wpad))
318 $(eval $(call BuildPackage,wpad-mini))
319 $(eval $(call BuildPackage,wpa-supplicant))
320 $(eval $(call BuildPackage,wpa-supplicant-mini))
321 $(eval $(call BuildPackage,wpa-cli))
322 $(eval $(call BuildPackage,hostapd-utils))