rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | CC := ${CROSS_COMPILE}gcc |
| 2 | AR := ${CROSS_COMPILE}ar |
| 3 | LD := ${CROSS_COMPILE}ld |
| 4 | OBJCOPY := ${CROSS_COMPILE}objcopy |
| 5 | |
| 6 | CUST_TEE := ./custom/$(TZ_PROJECT)/cust_tee.mak |
| 7 | CUST_TEE_EXIST := $(if $(wildcard $(CUST_TEE)),TRUE,FALSE) |
| 8 | |
| 9 | include ./default.mak |
| 10 | ifeq ("$(CUST_TEE_EXIST)","TRUE") |
| 11 | include ./custom/$(TZ_PROJECT)/cust_tee.mak |
| 12 | endif |
| 13 | include ./feature.mak |
| 14 | |
| 15 | LDS = tllink.lds |
| 16 | |
| 17 | DIR_INC = ./include |
| 18 | DIR_SRC = ./src |
| 19 | DIR_PREBUILT = ./prebuilt |
| 20 | DIR_OBJ = ${TL_RAW_OUT}/obj |
| 21 | DIR_BIN = ${TL_RAW_OUT}/bin |
| 22 | |
| 23 | ASRCS = $(wildcard $(DIR_SRC)/*.s) |
| 24 | CSRCS = $(wildcard $(DIR_SRC)/*.c) |
| 25 | CSRCS += \ |
| 26 | $(DIR_SRC)/drivers/device_apc.c \ |
| 27 | $(DIR_SRC)/security/tz_init.c \ |
| 28 | $(DIR_SRC)/security/tz_emi_mpu.c \ |
| 29 | $(DIR_SRC)/security/tz_sec_cfg.c \ |
| 30 | $(DIR_SRC)/security/seclib.c \ |
| 31 | $(DIR_SRC)/drivers/tz_apc.c |
| 32 | |
| 33 | ifeq ($(CFG_TRUSTONIC_TEE_SUPPORT),1) |
| 34 | CSRCS += \ |
| 35 | $(DIR_SRC)/security/tz_tbase.c |
| 36 | endif |
| 37 | ifeq ($(CFG_TRUSTKERNEL_TEE_SUPPORT),1) |
| 38 | CSRCS += \ |
| 39 | $(DIR_SRC)/security/tz_tkcore.c |
| 40 | endif |
| 41 | |
| 42 | AOBJS = $(patsubst %.s, $(DIR_OBJ)/%.o, $(notdir $(ASRCS))) |
| 43 | COBJS = $(patsubst %.c, $(DIR_OBJ)/%.o, $(notdir $(CSRCS))) |
| 44 | SOBJS = $(wildcard $(DIR_PREBUILT)/*.a) |
| 45 | OBJS = $(AOBJS) $(COBJS) $(SOBJS) |
| 46 | |
| 47 | CFLAGS += -fno-builtin -fno-stack-protector ${C_OPTION} |
| 48 | |
| 49 | TARGET = teeloader |
| 50 | BIN_TARGET = $(DIR_BIN)/$(TARGET) |
| 51 | |
| 52 | all: $(OBJS) |
| 53 | @if [ ! -d `dirname $(BIN_TARGET).elf` ] ; then \ |
| 54 | mkdir -p `dirname $(BIN_TARGET).elf`; \ |
| 55 | fi |
| 56 | sed "s/%BASE_ADDR%/${BASE_ADDR}/g" $(LDS) > $(DIR_OBJ)/$(LDS) |
| 57 | $(LD) --start-group $^ --end-group -T$(DIR_OBJ)/$(LDS) -o $(BIN_TARGET).elf |
| 58 | -echo "teeloader binary created" |
| 59 | $(OBJCOPY) -O binary $(BIN_TARGET).elf $(BIN_TARGET).bin |
| 60 | ./zero_padding.sh $(BIN_TARGET).bin ${TL_ALIGN_SIZE} |
| 61 | |
| 62 | $(COBJS): $(CSRCS) |
| 63 | @if [ ! -d `dirname $@` ] ; then \ |
| 64 | mkdir -p `dirname $@`; \ |
| 65 | fi |
| 66 | $(CC) -I$(DIR_INC) $(CFLAGS) -c $(filter %$(patsubst %.o,%.c,$(notdir $@)),$(CSRCS)) -o $@ |
| 67 | |
| 68 | $(AOBJS): $(ASRCS) |
| 69 | @if [ ! -d `dirname $@` ] ; then \ |
| 70 | mkdir -p `dirname $@`; \ |
| 71 | fi |
| 72 | $(CC) -c $(filter %$(patsubst %.o,%.s,$(notdir $@)),$(ASRCS)) -o $@ |
| 73 | |
| 74 | .PHONY: clean |
| 75 | clean: |
| 76 | -@rm -rf $(DIR_OBJ)/* $(DIR_BIN)/* |