Files
kunlun/ap/Makefile
2024-09-28 14:24:04 +08:00

331 lines
8.8 KiB
Makefile

# OUTPUT type
# 1 - .out
# 2 - .a
# 3 - .so
OUTPUT_TYPE = 1
OUTPUT_NAME = ht
SUB_DIRS = src $(TOPDIR)/app
ifeq ($(APP), 8)
SUB_DIRS += $(TOPDIR)/import/lwip
else
ifeq ($(APP), 12)
SUB_DIRS += $(TOPDIR)/import/lwip
else
ifeq ($(APP), 22)
SUB_DIRS += $(TOPDIR)/import/lwip
endif
ifeq ($(APP), 25)
SUB_DIRS += $(TOPDIR)/import/lwip
endif
endif
endif
ADD_INCLUDE += $(TOPDIR)/export/inc/app $(TOPDIR)/export/inc/sg_lib $(TOPDIR)/export/inc/boot
# predefined macro
PRE_MARCO +=
ifeq ($(cco), 1)
OUTPUT_NAME = ht_cco
else
OUTPUT_NAME = ht_sta
endif
ifeq ($(ftm_build), 1)
OUTPUT_NAME = ht_ftm
endif
ifeq ($(ai), 1)
OUTPUT_NAME = ht_ai
endif
ifeq ($(smart_cco_sta), )
smart_cco_sta = 0
endif
ifeq ($(target), kunlun3)
ifeq ($(flash_build), 1)
# define plc only lds
ifeq ($(build_amp_type), 0)
ifeq ($(cco), 1)
ifeq ($(psram_enable), 1)
LD_SCRIPT = link_psram_8m_cco_plc_only.lds
else
ifeq ($(flash_size), 2)
LD_SCRIPT = link_flash_2m_cco_plc_only.lds
else
LD_SCRIPT = link_flash_4m_cco_plc_only.lds
endif
endif
else
ifeq ($(psram_enable), 1)
LD_SCRIPT = link_psram_8m_sta_plc_only.lds
else
ifeq ($(flash_size), 2)
LD_SCRIPT = link_flash_2m_sta_plc_only.lds
else
LD_SCRIPT = link_flash_4m_sta_plc_only.lds
endif
endif
endif
else
# define customer-core lds of AMP
ifeq ($(build_amp_type), 1)
ifeq ($(cco), 1)
ifeq ($(psram_enable), 1)
# for fastboot-mode specialized
ifeq ($(fastboot_mode), 1)
LD_SCRIPT = link_psram_8m_cus_cco_fb.lds
# for normal mode
else
LD_SCRIPT = link_psram_8m_cus_cco.lds
endif
else
LD_SCRIPT = link_flash_2m_cus_cco.lds
endif
else
ifeq ($(psram_enable), 1)
# for fastboot-mode specialized
ifeq ($(fastboot_mode), 1)
LD_SCRIPT = link_psram_8m_cus_sta_fb.lds
# for normal mode
else
LD_SCRIPT = link_psram_8m_cus_sta.lds
endif
else
LD_SCRIPT = link_flash_2m_cus_sta.lds
endif
endif
else
# define plc-core lds of AMP
ifeq ($(cco), 1)
ifeq ($(psram_enable), 1)
LD_SCRIPT = link_psram_8m_cco.lds
else
LD_SCRIPT = link_flash_2m_cco.lds
endif
else
ifeq ($(psram_enable), 1)
LD_SCRIPT = link_psram_8m_sta.lds
else
LD_SCRIPT = link_flash_2m_sta.lds
endif
endif
endif
endif
else
LD_SCRIPT = link.lds
endif
else
ifneq ($(smart_cco_sta), 0)
#smart build start
ifeq ($(cco), 1)
ifeq ($(psram_enable), 1)
ifeq ($(psram_size), 8)
LD_SCRIPT = link_flash_smart_psram_8m_cco.lds
else
ifeq ($(psram_size), 2)
LD_SCRIPT = link_flash_smart_psram_2m_cco.lds
else
LD_SCRIPT = link_flash_smart_psram_cco.lds
endif
endif
else
LD_SCRIPT = link_flash_smart_cco.lds
endif
else
ifeq ($(psram_enable), 1)
ifeq ($(psram_size), 2)
LD_SCRIPT = link_flash_smart_psram_2m_sta.lds
else
LD_SCRIPT = link_flash_smart_psram_sta.lds
endif
else
LD_SCRIPT = link_flash_smart_sta.lds
endif
endif
#smart build end
else
ifeq ($(flash_build), 1)
ifeq ($(cco), 1)
ifeq ($(psram_size), 8)
LD_SCRIPT = link_psram_8m_cco.lds
else
LD_SCRIPT = link_psram_4m_cco.lds
endif
else
ifeq ($(psram_enable), 1)
ifeq ($(psram_size), 2)
LD_SCRIPT = link_psram_2m_sta.lds
else ifeq ($(psram_size), 4)
LD_SCRIPT = link_psram_4m_sta.lds
else
LD_SCRIPT = link_psram_8m_sta.lds
endif
else
ifeq ($(flash_size), 4)
LD_SCRIPT = link_flash_4m_sta.lds
else
LD_SCRIPT = link_flash_sta.lds
endif
endif
endif
else
LD_SCRIPT = link.lds
endif
endif
ifeq ($(ckb), 1)
ifeq ($(psram_enable), 1)
LD_SCRIPT = link_psram_ckb.lds
else
LD_SCRIPT = link_flash_ckb.lds
endif
endif
endif
# lib dir
ADD_LIBDIR = $(TOPDIR)/startup
ifeq ($(product_line), PLC)
ADD_LIBDIR += $(TOPDIR)/ftm
ifeq ($(target), kunlun3)
ifeq ($(MBEDTLS_NONE_ROM_EN), 1)
ADD_LIBDIR += $(TOPDIR)/import/mbedtls $(TOPDIR)/rom/riscv3/romlib/crypto/iotelic
endif
ifeq ($(ftm_build), 1)
ADD_LIBDIR += $(TOPDIR)/dtest/dtest3/mac_phy/double_cpu/kl3_core0
endif
endif
endif
ADD_LIBDIR += $(TOPDIR)/cli
ADD_LIBDIR += $(TOPDIR)/app
ADD_LIBDIR += $(TOPDIR)/pib
ifeq ($(product_line), PLC)
ADD_LIBDIR += $(TOPDIR)/plc
ADD_LIBDIR += $(TOPDIR)/import/wq_vtb
endif
ADD_LIBDIR += $(TOPDIR)/driver
ADD_LIBDIR += $(TOPDIR)/import/lwip
ADD_LIBDIR += $(TOPDIR)/common
ADD_LIBDIR += $(TOPDIR)/os
ifeq ($(product_line), NB)
ADD_LIBDIR += $(TOPDIR)/nbstack
endif
ifeq ($(product_line), BT)
ADD_LIBDIR += $(TOPDIR)/bt/fw
endif
# lib need to ld together
ADD_LIB = startup app pib
ifeq ($(product_line), PLC)
ifeq ($(target), kunlun3)
ifneq ($(build_amp_type), 1)
ADD_LIB += ftm plc cli
ifeq ($(ftm_build), 1)
ifeq ($(rf_enable), 1)
ADD_LIB += kl3_core0
endif
endif
endif
else
ADD_LIB += ftm plc cli
endif
endif
ifeq ($(product_line), NB)
ADD_LIB += nbstack
endif
ifeq ($(product_line), BT)
#ADD_LIB += bt
endif
ADD_LIB += driver common os
ifeq ($(APP), 8)
ADD_LIB += lwip
else
ifeq ($(APP), 12)
ADD_LIB += lwip
else
ifeq ($(APP), 22)
ADD_LIB += lwip
endif
ifeq ($(APP), 25)
ADD_LIB += lwip
endif
endif
endif
# add import lib
ifeq ($(product_line), PLC)
ADD_LIB += wq_vtb
endif
ifeq ($(target), kunlun3)
ifeq ($(MBEDTLS_NONE_ROM_EN), 1)
ADD_LIB += mbedtls iotelic
endif
endif
ifeq ($(FLASH_SIZE), 2)
SUB_DIRS += $(TOPDIR)/import
ADD_LIBDIR += $(TOPDIR)/import
ADD_LIB += sby
endif
ifeq ($(FLASH_SIZE), 4)
SUB_DIRS += $(TOPDIR)/import
ADD_LIBDIR += $(TOPDIR)/import
ADD_LIB += sby
endif
ifeq ($(build_amp_type), 1)
TMP_LDS=$(TOPDIR)/tools/gen_img/tmp_cus.lds
else
TMP_LDS=$(TOPDIR)/tools/gen_img/tmp_plc.lds
endif
ifeq ($(target), kunlun3)
LDS_DIR=$(TOPDIR)/startup/ldscripts/riscv3
else
ifeq ($(target), kunlun2)
LDS_DIR=$(TOPDIR)/startup/ldscripts/riscv2
else
LDS_DIR=$(TOPDIR)/startup/ldscripts/riscv
endif
endif
# put extra work for the output file
extra_work = echo copy $(OUTPUT_FULL_NAME) to $(TOPDIR)/bin;\
mkdir -p $(TOPDIR)/bin;\
mkdir -p $(TOPDIR)/bin;\
cp $(OUTPUT_FULL_NAME) $(TOPDIR)/bin;\
echo copy $(LDS_DIR)/$(LD_SCRIPT) $(TMP_LDS);\
cp $(LDS_DIR)/$(LD_SCRIPT) $(TMP_LDS)
########################################################
#leave the lines below un-modified
########################################################
ifdef TOPDIR
include $(TOPDIR)/build/makefile.cfg
else
include $(CURDIR)/build/makefile.cfg
TOPDIR = $(CURDIR)
export TOPDIR
endif
# display the obj files and output name
debug:
@echo TOPDIR=$(TOPDIR)
@echo OUTPUT_DIR=$(OUTPUT_DIR)
@echo OUTPUT_MAP=$(OUTPUT_MAP)
@echo OUTPUT_LIB=$(OUTPUT_FULL_NAME)
@echo DEPS=$(DEPS)
@echo OBJECTS=$(OBJECTS)
@echo SRCS=$(SRCS)
@echo OBJECTS folder=$(foreach dirname, $(SUB_DIRS), $(addprefix $(BIN_DIR)/, $(dirname)))
@echo output_name=$(OUTPUT_FULL_NAME)
@echo LINK_LIBS=$(LINK_LIBS)
@echo MAKEDEP=$(MAKEDEP)
@echo CC=$(CC)