-$(PKG_BUILD_DIR)/.built:
- $(MAKE) -C $(PKG_BUILD_DIR) \
- $(TARGET_CONFIGURE_OPTS) \
- CPPFLAGS="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include -I$(STAGING_DIR)/usr/include/madwifi" \
- LDFLAGS="-L$(STAGING_DIR)/usr/lib" \
- OPT_FLAGS="$(TARGET_CFLAGS)" \
+define Package/wpa-supplicant/config
+ source "$(SOURCE)/Config.in"
+endef
+
+define Package/wpa-cli
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=wpa-supplicant
+ TITLE:=WPA Supplicant command line interface
+endef
+
+define Package/wpa-cli/Description
+ WPA Supplicant control utility
+endef
+
+CONFIG=$(firstword $(wildcard ./files/config.$(BOARD) ./files/config.$(ARCH) ./config))
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/madwifi $(if $(CONFIG_WPA_SUPPLICANT_NO_TIMESTAMP_CHECK),-DNO_TIMESTAMP_CHECK)
+
+define Build/Configure
+ cp $(CONFIG) $(PKG_BUILD_DIR)/wpa_supplicant/.config
+ $(if $(CONFIG_PACKAGE_kmod-madwifi),,$(SED) 's,^CONFIG_DRIVER_MADWIFI,#CONFIG_DRIVER_MADWIFI,g' $(PKG_BUILD_DIR)/wpa_supplicant/.config)
+ $(if $(CONFIG_WPA_SUPPLICANT_OPENSSL),$(SED) 's|^CONFIG_TLS.*|CONFIG_TLS=openssl|g' $(PKG_BUILD_DIR)/wpa_supplicant/.config)
+endef
+
+define Build/Compile
+ rm -rf $(PKG_INSTALL_DIR)
+ mkdir -p $(PKG_INSTALL_DIR)
+ CFLAGS="$(TARGET_CFLAGS)" \
+ $(MAKE) -C $(PKG_BUILD_DIR)/wpa_supplicant \
+ CC="$(TARGET_CC)" \