include $(RT28xx_DIR)/os/linux/config.mk


#ifdef CONFIG_STA_SUPPORT
ifeq ($(RT28xx_MODE), STA)
MOD_NAME = rtnet$(MODULE)sta
endif
#endif // CONFIG_STA_SUPPORT //


OBJ := $(MOD_NAME).o


#ifdef CONFIG_STA_SUPPORT
RT28XX_STA_OBJ := \
	../../os/linux/sta_ioctl.o\
	../../os/linux/rt_main_dev.o

ifeq ($(HAS_MESH_SUPPORT),y)
RT28XX_STA_OBJ += \
	../../common/mesh_inf.o
endif

ifeq ($(HAS_P2P_SUPPORT), y)
RT28XX_STA_OBJ += \
	../../common/p2p_inf.o\
	../../os/linux/ap_ioctl.o
endif



#ifdef RT2870
ifneq ($(findstring 2870,$(CHIPSET)),)
RT28XX_STA_OBJ += \
	../../common/rtusb_dev_id.o\
	../../os/linux/usb_main_dev.o
endif
#endif // RT2870 //


#ifdef RT3070
ifneq ($(findstring 3070,$(CHIPSET)),)
RT28XX_STA_OBJ += \
	../../common/rtusb_dev_id.o\
	../../os/linux/usb_main_dev.o
endif
#endif // RT3070 //


#ifdef RT3572
ifneq ($(findstring 3572,$(CHIPSET)),)
RT28XX_STA_OBJ += \
	../../common/rtusb_dev_id.o\
	../../os/linux/usb_main_dev.o
endif
#endif // RT3572 //



#ifdef RT3573
ifneq ($(findstring 3573,$(CHIPSET)),)
RT28XX_STA_OBJ += \
	../../common/rtusb_dev_id.o\
	../../os/linux/usb_main_dev.o
endif
#endif // RT3573 //

#ifdef RT3593
ifneq ($(findstring 3593,$(CHIPSET)),)
RT28XX_STA_OBJ += \
	../../os/linux/rt_pci_rbus.o\
	../../os/linux/pci_main_dev.o
endif
#endif // RT3593 //


#ifdef RT3370
ifneq ($(findstring 3370,$(CHIPSET)),)
RT28XX_STA_OBJ += \
	../../common/rtusb_dev_id.o\
	../../os/linux/usb_main_dev.o
endif
#endif // RT3370 //

#ifdef RT5370
ifneq ($(findstring 5370,$(CHIPSET)),)
RT28XX_STA_OBJ += \
	../../common/rtusb_dev_id.o\
	../../os/linux/usb_main_dev.o
endif
#endif // RT5370 //

#ifdef RT5572
ifneq ($(findstring 5572,$(CHIPSET)),)
RT28XX_STA_OBJ += \
	../../common/rtusb_dev_id.o\
	../../os/linux/usb_main_dev.o
endif
#endif // RT5572 //

#ifdef RT5592
ifneq ($(findstring 5592,$(CHIPSET)),)
RT28XX_STA_OBJ += \
	../../os/linux/rt_pci_rbus.o\
	../../os/linux/pci_main_dev.o
endif
#endif // RT5592 //

#endif // CONFIG_STA_SUPPORT //


PHONY := all clean

all:$(OBJ)

rtnet$(MODULE)sta.o: $(RT28XX_STA_OBJ)
	$(LD) -r $^ -o $@

rtnet$(MODULE)ap.o: $(RT28XX_AP_OBJ)
	$(LD) -r $^ -o $@

rtnet$(MODULE)apsta.o: $(RT28XX_APSTA_OBJ)
	$(LD) -r $^ -o $@

clean:
	rm -f $(RT28xx_DIR)/common/*.o
	rm -f $(RT28xx_DIR)/common/.*.{cmd,flags,d}
	rm -f $(RT28xx_DIR)/os/linux/*.{o,ko,mod.{o,c}}
	rm -f $(RT28xx_DIR)/os/linux/.*.{cmd,flags,d}
	rm -fr $(RT28xx_DIR)/os/linux/.tmp_versions
	rm -f $(RT28xx_DIR)/chips/*.o
	rm -f $(RT28xx_DIR)/chips/.*.{cmd,flags,d}
ifeq ($(RT28xx_MODE),AP)
	rm -f $(RT28xx_DIR)/ap/*.o
	rm -f $(RT28xx_DIR)/ap/.*.{cmd,flags,d}
else
ifeq ($(RT28xx_MODE),STA)
	rm -f $(RT28xx_DIR)/sta/*.o
	rm -f $(RT28xx_DIR)/sta/.*.{cmd,flags,d}
else
ifeq ($(RT28xx_MODE),APSTA)
	rm -f $(RT28xx_DIR)/ap/*.o
	rm -f $(RT28xx_DIR)/ap/.*.{cmd,flags,d}
	rm -f $(RT28xx_DIR)/sta/*.o
	rm -f $(RT28xx_DIR)/sta/.*.{cmd,flags,d}
endif
endif
endif

install:
	install -d $(LINUX_SRC_MODULE)
	install -m 644 -c $(addsuffix .o,$(MOD_NAME)) $(LINUX_SRC_MODULE)
	/sbin/depmod -a ${shell uname -r}

uninstall:
	rm -rf $(addprefix $(LINUX_SRC_MODULE),$(addsuffix .o,$(MOD_NAME)))
	/sbin/depmod -a ${shell uname -r}

# Declare the contents of the .PHONY variable as phony.  We keep that
# # information in a variable so we can use it in if_changed and friends.
.PHONY: $(PHONY)
