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