blob: 9879df0713e23e66ec37838f0e91cc90a081dad2 [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 = ./prebuild
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 $(DIR_SRC)/drivers/tz_dapc.c
19
20VPATH = $(DIR_SRC):$(DIR_SRC)/drivers
21SRCS = $(ASRCS) $(CSRCS)
22AOBJS = $(patsubst %.s, $(DIR_OBJ)/%.o, $(notdir $(ASRCS)))
23COBJS = $(patsubst %.c, $(DIR_OBJ)/%.o, $(notdir $(CSRCS)))
24SOBJS = $(wildcard $(DIR_PREBUILT)/*.a)
25OBJS = $(AOBJS) $(COBJS) $(SOBJS)
26
27TARGET = teeloader
28BIN_TARGET = $(DIR_BIN)/$(TARGET)
29
30ifeq ($(strip $(TRUSTEDOS_SIZE)),)
31TRUSTEDOS_SIZE := 0
32endif
33all: $(OBJS)
34 @if [ ! -d `dirname $(BIN_TARGET).elf` ] ; then \
35 mkdir -p `dirname $(BIN_TARGET).elf`; \
36 fi
37 sed "s/%BASE_ADDR%/${BASE_ADDR}/g" $(LDS) > $(DIR_OBJ)/$(LDS)
38 $(LD) --start-group $^ --end-group -T$(DIR_OBJ)/$(LDS) -o $(BIN_TARGET).elf
39 -echo "teeloader binary created"
40 $(OBJCOPY) -O binary $(BIN_TARGET).elf $(BIN_TARGET).bin
41 ./zero_padding.sh $(BIN_TARGET).bin ${TL_ALIGN_SIZE}
42
43$(DIR_OBJ)/%.o: %.c
44 @if [ ! -d `dirname $@` ] ; then \
45 mkdir -p `dirname $@`; \
46 fi
47 $(CC) -I$(DIR_INC) -DBASE_ADDR=${BASE_ADDR} -DTL_ALIGN_SIZE=${TL_ALIGN_SIZE} -DTRUSTEDOS_ENTRYPOINT=${TRUSTEDOS_ENTRYPOINT} -DTRUSTEDOS_SIZE=${TRUSTEDOS_SIZE} -c $(filter %$(patsubst %.o,%.c,$(notdir $@)),$(CSRCS)) -o $@
48
49$(DIR_OBJ)/%.o: %.s
50 @if [ ! -d `dirname $@` ] ; then \
51 mkdir -p `dirname $@`; \
52 fi
53 $(CC) -c $^ -o $@
54
55.PHONY: clean
56clean:
57 -@rm -rf $(DIR_OBJ)/* $(DIR_BIN)/*