TARGET = wpa_supplicant

SRCS_DIR += ./src/wpa_supplicant

export CROSS_COMPILE=arm-poky-linux-gnueabi-
export PATH+=$(YOCTOSDK_HOST)/usr/bin:$(YOCTOSDK_HOST)/usr/bin/arm-poky-linux-gnueabi
export ARCH=arm
export KDIR=$(SRC_DIR_KERNEL)

all:
	cp $(SRCS_DIR)/defconfig $(SRCS_DIR)/.config
	sed -i 's/#CONFIG_LIBNL32=y/CONFIG_LIBNL32=y/g' $(SRCS_DIR)/.config
	sed -i 's/#CONFIG_WPS=y/CONFIG_WPS=y/g' $(SRCS_DIR)/.config
	sed -i 's/#CONFIG_WPA_CLI_EDIT=y/CONFIG_WPA_CLI_EDIT=y/g' $(SRCS_DIR)/.config
	sed -i 's/#CONFIG_AP=y/CONFIG_AP=y/g' $(SRCS_DIR)/.config
	sed -i 's/#CONFIG_P2P=y/CONFIG_P2P=y/g' $(SRCS_DIR)/.config
	sed -i 's/#CONFIG_WIFI_DISPLAY=y/CONFIG_WIFI_DISPLAY=y/g' $(SRCS_DIR)/.config
	sed -i 's/#CONFIG_IEEE80211N=y/CONFIG_IEEE80211N=y/g' $(SRCS_DIR)/.config
	sed -i 's/#CONFIG_IEEE80211AC=y/CONFIG_IEEE80211AC=y/g' $(SRCS_DIR)/.config
	make -C $(SRCS_DIR)

install:
	cp $(SRCS_DIR)/wpa_supplicant $(TARGET_FS_PATH)/usr/sbin/.
	cp $(SRCS_DIR)/wpa_cli $(TARGET_FS_PATH)/usr/sbin/.
	cp $(SRCS_DIR)/wpa_supplicant $(SRCS_DIR)/../../bin/.
	cp $(SRCS_DIR)/wpa_cli $(SRCS_DIR)/../../bin/.
	@echo '***************************************'
	@echo 'Succeed to install target: $(TARGET)'
	@echo '***************************************'

clean:
	make -C $(SRCS_DIR) clean
