FANTGPU_PRO_PATH := $(src)

#当前机器架构为loongarch时，添加-ffunction-sections -fdata-sections 将.rela_text,.rela_data拆分成一个个具体的函数、变量段
ifeq ($(CONFIG_LOONGARCH),y)
	subdir-ccflags-y := -Wall -Werror -fno-stack-protector -ffunction-sections -fdata-sections
else ifeq ($(CONFIG_ARM64),y)
	subdir-ccflags-y := -Wall -Werror -fno-stack-protector -ffixed-x18
else
	subdir-ccflags-y := -Wall -Werror -fno-stack-protector
endif

generate_dbginfo ?= 0

ifeq ($(GENERATE_DBGINFO),1)
	generate_dbginfo = 1
endif

ifeq ($(BUILD),debug)
	generate_dbginfo = 1
endif

ifeq ($(generate_dbginfo),1)
	subdir-ccflags-y += -g
endif

include $(FANTGPU_PRO_PATH)/fantgpu/Makefile
include $(FANTGPU_PRO_PATH)/fantsmmu/Makefile
include $(FANTGPU_PRO_PATH)/fantdma/Makefile
include $(FANTGPU_PRO_PATH)/fantsrvkm/Makefile
include $(FANTGPU_PRO_PATH)/fantpmbus/Makefile
include $(FANTGPU_PRO_PATH)/fantpower/Makefile
include $(FANTGPU_PRO_PATH)/fantvpu/Makefile
include $(FANTGPU_PRO_PATH)/tools/Makefile


subdir-ccflags-y += \
	$(FANTGPU_INCLUDE) \
	$(FANTSMMU_INCLUDE) \
	$(FANTDMA_INCLUDE) \
	$(FANTDPU_INCLUDE) \
	$(FANTSRVKM_INCLUDE) \
	$(FANTPMBUS_INCLUDE) \
	$(FANTPOWER_INCLUDE) \
	$(FANTVPU_INCLUDE) \
	$(FANTGPU_INFO_INCLUDE) \

ccflags-y += \
	-include config_kernel.h \
	-include kernel_autocfg.h

fantgpu-y := $(FANTGPU)
fantgpu-y += $(FANTSMMU)
fantgpu-y += $(FANTDMA)
fantgpu-y += $(FANTSRVKM)
fantgpu-y += $(FANTPMBUS)
fantgpu-y += $(FANTPOWER)
fantgpu-y += $(FANTVPU)
fantgpu-y += $(FANTGPU_INFO)

obj-m += fantgpu.o

