blob: bec229df5cf159557c5993aeb03ee6ce63edfcab [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
6LDS = tllink.lds
7
8DIR_INC = ./include
9DIR_SRC = ./src
10DIR_PREBUILT = ./prebuilt
11DIR_OBJ = ${TL_RAW_OUT}/obj
12DIR_BIN = ${TL_RAW_OUT}/bin
13
14ASRCS = $(wildcard $(DIR_SRC)/*.s)
15CSRCS = $(wildcard $(DIR_SRC)/*.c)
16CSRCS += \
17 $(DIR_SRC)/drivers/tz_emi_mpu.c
18
19VPATH = $(DIR_SRC):$(DIR_SRC)/drivers
20SRCS = $(ASRCS) $(CSRCS)
21AOBJS = $(patsubst %.s, $(DIR_OBJ)/%.o, $(notdir $(ASRCS)))
22COBJS = $(patsubst %.c, $(DIR_OBJ)/%.o, $(notdir $(CSRCS)))
23SOBJS = $(wildcard $(DIR_PREBUILT)/*.a)
24OBJS = $(AOBJS) $(COBJS) $(SOBJS)
25
26TARGET = teeloader
27BIN_TARGET = $(DIR_BIN)/$(TARGET)
28
29all: $(OBJS)
30 @if [ ! -d `dirname $(BIN_TARGET).elf` ] ; then \
31 mkdir -p `dirname $(BIN_TARGET).elf`; \
32 fi
33 sed "s/%BASE_ADDR%/${BASE_ADDR}/g" $(LDS) > $(DIR_OBJ)/$(LDS)
34 $(LD) --start-group $^ --end-group -T$(DIR_OBJ)/$(LDS) -o $(BIN_TARGET).elf
35 -echo "teeloader binary created"
36 $(OBJCOPY) -O binary $(BIN_TARGET).elf $(BIN_TARGET).bin
37 ./zero_padding.sh $(BIN_TARGET).bin ${TL_ALIGN_SIZE}
38
39$(DIR_OBJ)/%.o: %.c
40 @if [ ! -d `dirname $@` ] ; then \
41 mkdir -p `dirname $@`; \
42 fi
43 $(CC) -I$(DIR_INC) -DBASE_ADDR=${BASE_ADDR} -DTL_ALIGN_SIZE=${TL_ALIGN_SIZE} -DTRUSTEDOS_ENTRYPOINT=${TRUSTEDOS_ENTRYPOINT} -c $(filter %$(patsubst %.o,%.c,$(notdir $@)),$(CSRCS)) -o $@
44
45$(DIR_OBJ)/%.o: %.s
46 @if [ ! -d `dirname $@` ] ; then \
47 mkdir -p `dirname $@`; \
48 fi
49 $(CC) -c $^ -o $@
50
51.PHONY: clean
52clean:
53 -@rm -rf $(DIR_OBJ)/* $(DIR_BIN)/*