# In-Tree Makefile for USB combo
EXTRA_CFLAGS += -Idrivers/net/wireless/RT5572_ap/MODULE/include
EXTRA_CFLAGS += -Idrivers/net/wireless/RT5572_ap/UTIL/include
EXTRA_CFLAGS += -Idrivers/net/wireless/RT5572_ap/NETIF/include
EXTRA_CFLAGS += -Idrivers/net/wireless/RT5572_ap/MODULE/ate/include

# UTIL module
obj-$(CONFIG_RTUSB_AP) += RT5572_ap_util.o
RT5572_ap_util-y += UTIL/common/rt_os_util.o
RT5572_ap_util-y += UTIL/os/linux/rt_linux_symb.o
RT5572_ap_util-y += UTIL/os/linux/rt_rbus_pci_util.o
RT5572_ap_util-y += UTIL/os/linux/rt_usb_util.o
RT5572_ap_util-y += UTIL/os/linux/rt_linux.o

# MODULE module
obj-$(CONFIG_RTUSB_AP) += RT5572_ap.o
RT5572_ap-y += MODULE/common/crypt_md5.o
RT5572_ap-y += MODULE/common/crypt_sha2.o
RT5572_ap-y += MODULE/common/crypt_hmac.o
RT5572_ap-y += MODULE/common/crypt_aes.o
RT5572_ap-y += MODULE/common/crypt_arc4.o
RT5572_ap-y += MODULE/common/mlme.o
RT5572_ap-y += MODULE/common/cmm_wep.o
RT5572_ap-y += MODULE/common/action.o
RT5572_ap-y += MODULE/common/cmm_data.o
RT5572_ap-y += MODULE/common/rtmp_init.o
RT5572_ap-y += MODULE/common/rtmp_init_inf.o
RT5572_ap-y += MODULE/common/cmm_tkip.o
RT5572_ap-y += MODULE/common/cmm_aes.o
RT5572_ap-y += MODULE/common/cmm_sync.o
RT5572_ap-y += MODULE/common/eeprom.o
RT5572_ap-y += MODULE/common/cmm_sanity.o
RT5572_ap-y += MODULE/common/cmm_info.o
RT5572_ap-y += MODULE/common/cmm_cfg.o
RT5572_ap-y += MODULE/common/cmm_wpa.o
RT5572_ap-y += MODULE/common/cmm_radar.o
RT5572_ap-y += MODULE/common/spectrum.o
RT5572_ap-y += MODULE/common/rtmp_timer.o
RT5572_ap-y += MODULE/common/rt_channel.o
RT5572_ap-y += MODULE/common/cmm_profile.o
RT5572_ap-y += MODULE/common/cmm_asic.o
RT5572_ap-y += MODULE/common/cmm_cmd.o
RT5572_ap-y += MODULE/rate_ctrl/ra_ctrl.o
RT5572_ap-y += MODULE/rate_ctrl/alg_legacy.o
RT5572_ap-y += MODULE/rate_ctrl/alg_ags.o
RT5572_ap-y += MODULE/os/linux/rt_profile.o
RT5572_ap-y += MODULE/chips/rtmp_chip.o
RT5572_ap-y += MODULE/ap/ap.o
RT5572_ap-y += MODULE/ap/ap_assoc.o
RT5572_ap-y += MODULE/ap/ap_auth.o
RT5572_ap-y += MODULE/ap/ap_connect.o
RT5572_ap-y += MODULE/ap/ap_mlme.o
RT5572_ap-y += MODULE/ap/ap_sanity.o
RT5572_ap-y += MODULE/ap/ap_sync.o
RT5572_ap-y += MODULE/ap/ap_wpa.o
RT5572_ap-y += MODULE/ap/ap_data.o
RT5572_ap-y += MODULE/common/uapsd.o
RT5572_ap-y += MODULE/ap/ap_autoChSel.o
RT5572_ap-y += MODULE/ap/ap_qload.o
RT5572_ap-y += MODULE/ap/ap_cfg.o
RT5572_ap-y += MODULE/common/ba_action.o
RT5572_ap-y += MODULE/common/cmm_mac_usb.o
RT5572_ap-y += MODULE/common/rtusb_io.o
RT5572_ap-y += MODULE/common/rtusb_data.o
RT5572_ap-y += MODULE/common/cmm_data_usb.o
RT5572_ap-y += MODULE/common/rtmp_mcu.o
RT5572_ap-y += MODULE/common/rtusb_bulk.o
RT5572_ap-y += MODULE/os/linux/rt_usb.o
RT5572_ap-y += MODULE/common/ee_prom.o
RT5572_ap-y += MODULE/common/cmm_dfs.o
RT5572_ap-y += MODULE/common/cmm_cs.o
RT5572_ap-y += MODULE/common/ee_prom.o
RT5572_ap-y += MODULE/common/ee_efuse.o
RT5572_ap-y += MODULE/common/rt_rf.o
RT5572_ap-y += MODULE/os/linux/rt_symb.o
RT5572_ap-y += MODULE/common/rt_led.o

# NET module
obj-$(CONFIG_RTUSB_AP) += RT5572_ap_net.o
RT5572_ap_net-y += NETIF/common/rtusb_dev_id.o
RT5572_ap_net-y += NETIF/os/linux/ap_ioctl.o
RT5572_ap_net-y += NETIF/os/linux/rt_main_dev.o
RT5572_ap_net-y += NETIF/os/linux/usb_main_dev.o

# By feature
ifeq ($(CONFIG_RTUSB_AP_WSC),y)
RT5572_ap-y += MODULE/common/wsc.o 
RT5572_ap-y += MODULE/common/wsc_tlv.o
RT5572_ap-y += MODULE/common/wsc_ufd.o
RT5572_ap-y += MODULE/common/crypt_biginteger.o
RT5572_ap-y += MODULE/common/crypt_dh.o
RT5572_ap-y += MODULE/common/wsc_v2.o 
endif

ifeq ($(CONFIG_RTUSB_WDS),y)
RT5572_ap-y += MODULE/ap/ap_wds.o
RT5572_ap-y += MODULE/common/client_wds.o
RT5572_ap_net-y += NETIF/ap/ap_wds_inf.o
endif

ifeq ($(CONFIG_RTUSB_AP_MBSS),y)
RT5572_ap-y += MODULE/ap/ap_mbss.o
RT5572_ap_net-y += NETIF/ap/ap_mbss_inf.o
endif

ifeq ($(CONFIG_RTUSB_APCLI),y)
RT5572_ap-y += MODULE/ap/ap_apcli.o
RT5572_ap-y += MODULE/ap/apcli_ctrl.o
RT5572_ap-y += MODULE/ap/apcli_sync.o
RT5572_ap-y += MODULE/ap/apcli_auth.o
RT5572_ap-y += MODULE/ap/apcli_assoc.o
RT5572_ap-y += MODULE/common/cmm_mat.o
RT5572_ap-y += MODULE/common/cmm_mat_iparp.o
RT5572_ap-y += MODULE/common/cmm_mat_pppoe.o
RT5572_ap-y += MODULE/common/cmm_mat_ipv6.o
RT5572_ap_net-y += NETIF/ap/ap_apcli_inf.o
endif

ifeq ($(CONFIG_RTUSB_DFS),y)
RT5572_ap-y += MODULE/common/cmm_dfs.o
endif

ifeq ($(CONFIG_RTUSB_CS),y)
RT5572_ap-y += MODULE/common/cmm_cs.o
endif

ifeq ($(CONFIG_RTUSB_IGMP_SNOOP),y)
RT5572_ap-y += MODULE/common/igmp_snoop.o
endif

ifeq ($(CONFIG_RTUSB_NETIF_BLOCK),y)
RT5572_ap-y += MODULE/common/netif_block.o
endif

ifeq ($(CONFIG_RTUSB_DLS),y)
RT5572_ap-y += MODULE/ap/ap_dls.o
endif

ifeq ($(CONFIG_RTUSB_IDS),y)
RT5572_ap-y += MODULE/ap/ap_ids.o
endif

ifeq ($(CONFIG_RTUSB_AP_FLASH_SUPPORT),y)
RT5572_ap-y += MODULE/common/ee_flash.o
endif

# WAPI
ifeq ($(CONFIG_RTUSB_AP_WAPI),y)
RT5572_ap-y += MODULE/common/wapi.o
RT5572_ap-y += MODULE/common/wapi_sms4.o
RT5572_ap-y += MODULE/common/wapi_crypt.o
endif

# Chip related
ifeq ($(CONFIG_RT2870_AP),y)
RT5572_ap-y += MODULE/chips/rt28xx.o
endif

ifeq ($(CONFIG_RT3572_AP),y)
RT5572_ap-y += MODULE/chips/rt28xx.o
RT5572_ap-y += MODULE/chips/rt30xx.o
RT5572_ap-y += MODULE/chips/rt35xx.o
endif

ifeq ($(CONFIG_RT3573_AP),y)
RT5572_ap-y += MODULE/chips/rt28xx.o
RT5572_ap-y += MODULE/chips/rt30xx.o
RT5572_ap-y += MODULE/chips/rt35xx.o
RT5572_ap-y += MODULE/chips/rt3593.o
endif

ifeq ($(CONFIG_RT5572_AP),y)
RT5572_ap-y += MODULE/chips/rt28xx.o
RT5572_ap-y += MODULE/chips/rt30xx.o
RT5572_ap-y += MODULE/chips/rt5592.o
endif

# ATE
ifeq ($(CONFIG_RTUSB_AP_ATE),y)
RT5572_ap-y += MODULE/ate/common/rt_ate.o
RT5572_ap-y += MODULE/ate/common/ate_usb.o
endif

ifeq ($(CONFIG_RT2870_AP_ATE),y)
RT5572_ap-y += MODULE/ate/chips/rt28xx_ate.o
endif

ifeq ($(CONFIG_RT3572_AP_ATE),y)
RT5572_ap-y += MODULE/ate/chips/rt28xx_ate.o
RT5572_ap-y += MODULE/ate/chips/rt35xx_ate.o
endif

ifeq ($(CONFIG_RT5572_AP_ATE),y)
RT5572_ap-y += MODULE/ate/chips/rt28xx_ate.o
RT5572_ap-y += MODULE/ate/chips/rt5592_ate.o
endif

# QA tool
ifeq ($(CONFIG_RTUSB_AP_QA),y)
RT5572_ap-y += MODULE/ate/common/rt_qa.o
endif
###################
#  CFLAGS
###################
EXTRA_CFLAGS += -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT -DLINUX\
		-Wall -Wstrict-prototypes -Wno-trigraphs
EXTRA_CFLAGS += -DSYSTEM_LOG_SUPPORT -DKTHREAD_SUPPORT
EXTRA_CFLAGS += -DCONFIG_AP_SUPPORT  -DUAPSD_SUPPORT -DIAPP_SUPPORT -DDBG\
		-DDOT1X_SUPPORT -DAP_SCAN_SUPPORT
EXTRA_CFLAGS += -DRTMP_MAC_USB -DRTMP_USB_SUPPORT
EXTRA_CFLAGS += -DSTATS_COUNT_SUPPORT -DDOT11_N_SUPPORT -DRTDEV_SUPPORT


ifeq ($(CONFIG_RTUSB_AP),m)
EXTRA_CFLAGS += -DOS_ABL_SUPPORT 
EXTRA_CFLAGS += -DOS_ABL_FUNC_SUPPORT
EXTRA_CFLAGS += -DOS_ABL_OS_PCI_SUPPORT
EXTRA_CFLAGS += -DOS_ABL_OS_USB_SUPPORT
EXTRA_CFLAGS += -DOS_ABL_OS_AP_SUPPORT
endif

ifeq ($(CONFIG_RTUSB_AP_WSC),y)
EXTRA_CFLAGS += -DWSC_AP_SUPPORT -DWSC_INCLUDED -DWSC_V2_SUPPORT
endif

ifeq ($(CONFIG_RTUSB_WDS),y)
EXTRA_CFLAGS += -DWDS_SUPPORT
endif

ifeq ($(CONFIG_RTUSB_MBSS),y)
EXTRA_CFLAGS += -DMBSS_SUPPORT
endif

ifeq ($(CONFIG_RTUSB_APCLI),y)
EXTRA_CFLAGS += -DAPCLI_SUPPORT
EXTRA_CFLAGS += -DMAT_SUPPORT
EXTRA_CFLAGS += -DAP_SCAN_SUPPORT
endif

ifeq ($(CONFIG_RTUSB_AP_DLS),y)
EXTRA_CFLAGS += -DQOS_DLS_SUPPORT
endif

ifeq ($(CONFIG_RTUSB_IDS),y)
EXTRA_CFLAGS += -DIDS_SUPPORT
endif

ifeq ($(CONFIG_RTUSB_AP_FLASH_SUPPORT), y)
EXTRA_CFLAGS += -DRTMP_FLASH_SUPPORT
endif

ifeq ($(CONFIG_RTUSB_AP_80211N_DRAFT3),y)
EXTRA_CFLAGS += -DDOT11N_DRAFT3
endif

ifeq ($(CONFIG_RTUSB_LLTD),y)
EXTRA_CFLAGS += -DLLTD_SUPPORT
endif

ifeq ($(CONFIG_RTUSB_IGMP_SNOOP),y)
EXTRA_CFLAGS += -DIGMP_SNOOP_SUPPORT
endif

ifeq ($(CONFIG_RTUSB_NETIF_BLOCK),y)
EXTRA_CFLAGS += -DBLOCK_NET_IF
endif

# Chip related
ifeq ($(CONFIG_RT2870_AP), y)
EXTRA_CFLAGS += -DRT2870 -DRT28xx -DRTMP_TIMER_TASK_SUPPORT -DA_BAND_SUPPORT

ifeq ($(CONFIG_RTUSB_DFS), y)
EXTRA_CFLAGS += -DDFS_SOFTWARE_SUPPORT
endif

endif

ifeq ($(CONFIG_RT3572_AP), y)
EXTRA_CFLAGS += -DRT2870 -DRT28xx -DRT30xx -DRT35xx -DRT3572 -DRTMP_TIMER_TASK_SUPPORT -DRTMP_RF_RW_SUPPORT -DRTMP_EFUSE_SUPPORT -DA_BAND_SUPPORT -DVCORECAL_SUPPORT

ifeq ($(CONFIG_RTUSB_DFS), y)
EXTRA_CFLAGS += -DDFS_DEBUG
endif

ifeq ($(CONFIG_RTUSB_CS_SUPPORT), y)
EXTRA_CFLAGS += -DCARRIER_DETECTION_FIRMWARE_SUPPORT
endif

endif

ifeq ($(CONFIG_RT3573_AP), y)
EXTRA_CFLAGS += -DRT30xx -DRT35xx -DRT3593 -DRT3573 -DA_BAND_SUPPORT -DDOT11N_SS3_SUPPORT -DVCORECAL_SUPPORT 
endif

ifeq ($(CONFIG_RT5572_AP), y)
EXTRA_CFLAGS += -DRT2870 -DRT28xx -DRT30xx -DRT5572 -DRT5592 -DRTMP_RF_RW_SUPPORT -DRTMP_EFUSE_SUPPORT -DRTMP_TIMER_TASK_SUPPORT -DA_BAND_SUPPORT -DIQ_CAL_SUPPORT -DVCORECAL_SUPPORT -DRTMP_TEMPERATURE_COMPENSATION

ifeq ($(CONFIG_RTUSB_DFS), y)
EXTRA_CFLAGS += -DDFS_SOFTWARE_SUPPORT -DDFS_HARDWARE_SUPPORT -DDFS_DEBUG
endif

ifeq ($(CONFIG_RTUSB_CS_SUPPORT), y)
EXTRA_CFLAGS += -DCARRIER_DETECTION_FIRMWARE_SUPPORT
endif

endif

# ATE
ifeq ($(CONFIG_RTUSB_AP_ATE), y)
EXTRA_CFLAGS += -DRALINK_ATE -DCONFIG_RT2880_ATE_CMD_NEW
endif

# QA
ifeq ($(CONFIG_RTUSB_AP_QA), y)
EXTRA_CFLAGS += -DRALINK_QA
endif

# WAPI
ifeq ($(CONFIG_RTUSB_AP_WAPI), y)
EXTRA_CFLAGS += -DWAPI_SUPPORT -DSOFT_ENCRYPT -DEXPORT_SYMTAB
endif

# NEW MBSS
ifeq ($(CONFIG_RTUSB_AP_NEW_MBSS_MODE), y)
EXTRA_CFLAGS += -DNEW_MBSSID_MODE
endif

clean:
	@rm -f common/*.o
	@rm -f ap/*.o
	@rm -f sta/*.o
	@rm -f os/linux/*.o
	@rm -f chips/*.o
	@rm -f `find ./ -name *.o.cmd`
	@rm -f *.ko
	@rm -f *.o
