blob: d4e10e6504337ac50161013a60409dd0782e7677 [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 $(DIR_SRC)/drivers/tz_apc.c
32
33ifeq ($(CFG_TRUSTONIC_TEE_SUPPORT),1)
34CSRCS += \
35 $(DIR_SRC)/security/tz_tbase.c
36endif
37ifeq ($(CFG_TRUSTKERNEL_TEE_SUPPORT),1)
38CSRCS += \
39 $(DIR_SRC)/security/tz_tkcore.c
40endif
41
42AOBJS = $(patsubst %.s, $(DIR_OBJ)/%.o, $(notdir $(ASRCS)))
43COBJS = $(patsubst %.c, $(DIR_OBJ)/%.o, $(notdir $(CSRCS)))
44SOBJS = $(wildcard $(DIR_PREBUILT)/*.a)
45OBJS = $(AOBJS) $(COBJS) $(SOBJS)
46
47CFLAGS += -fno-builtin -fno-stack-protector ${C_OPTION}
48
49TARGET = teeloader
50BIN_TARGET = $(DIR_BIN)/$(TARGET)
51
52all: $(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
75clean:
76 -@rm -rf $(DIR_OBJ)/* $(DIR_BIN)/*