rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | CC := ${CROSS_COMPILE}gcc |
| 2 | AR := ${CROSS_COMPILE}ar |
| 3 | LD := ${CROSS_COMPILE}ld |
| 4 | OBJCOPY := ${CROSS_COMPILE}objcopy |
| 5 | |
| 6 | LDS = tllink.lds |
| 7 | |
| 8 | DIR_INC = ./include |
| 9 | DIR_SRC = ./src |
| 10 | DIR_PREBUILT = ./prebuild |
| 11 | DIR_OBJ = ${TL_RAW_OUT}/obj |
| 12 | DIR_BIN = ${TL_RAW_OUT}/bin |
| 13 | |
| 14 | ASRCS = $(wildcard $(DIR_SRC)/*.s) |
| 15 | CSRCS = $(wildcard $(DIR_SRC)/*.c) |
| 16 | SRCS = $(ASRCS) $(CSRCS) |
| 17 | AOBJS = $(patsubst %.s, $(DIR_OBJ)/%.o, $(notdir $(ASRCS))) |
| 18 | COBJS = $(patsubst %.c, $(DIR_OBJ)/%.o, $(notdir $(CSRCS))) |
| 19 | SOBJS = $(wildcard $(DIR_PREBUILT)/*.a) |
| 20 | OBJS = $(AOBJS) $(COBJS) $(SOBJS) |
| 21 | |
| 22 | TARGET = teeloader |
| 23 | BIN_TARGET = $(DIR_BIN)/$(TARGET) |
| 24 | |
| 25 | all: $(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 |
| 48 | clean: |
| 49 | -@rm -rf $(DIR_OBJ)/* $(DIR_BIN)/* |