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