2013-06-13 00:02:53 +00:00
|
|
|
#
|
|
|
|
# common
|
|
|
|
#
|
|
|
|
CC=arm-elf-eabi-gcc
|
|
|
|
LD=arm-elf-eabi-gcc
|
|
|
|
AS=arm-elf-eabi-gcc
|
|
|
|
OC=arm-elf-eabi-objcopy
|
2012-11-14 11:51:51 +00:00
|
|
|
CFLAGS=-W -Wall -Wundef -O -nostdlib -ffreestanding -Wstrict-prototypes -pipe -std=gnu99 -mcpu=arm926ej-s -fomit-frame-pointer -Wno-pointer-sign -Wno-override-init -ffunction-sections
|
|
|
|
ASFLAGS=$(CFLAGS) -D__ASSEMBLER__
|
|
|
|
OCFLAGS=
|
2013-06-13 00:02:53 +00:00
|
|
|
LINKER_FILE=hwstub.lds
|
|
|
|
TMP_LDS=link.lds
|
|
|
|
TMP_MAP=hwstub.map
|
|
|
|
LDFLAGS=-lgcc -Os -nostdlib -T$(TMP_LDS) -Wl,-Map,$(TMP_MAP)
|
2012-11-14 11:51:51 +00:00
|
|
|
SRC_C=$(wildcard *.c)
|
|
|
|
SRC_S=$(wildcard *.S)
|
|
|
|
OBJ_C=$(SRC_C:.c=.o)
|
|
|
|
OBJ_S=$(SRC_S:.S=.o)
|
|
|
|
OBJ=$(OBJ_C) $(OBJ_S)
|
|
|
|
OBJ_EXCEPT_CRT0=$(filter-out crt0.o,$(OBJ))
|
|
|
|
DEPS=$(OBJ:.o=.d)
|
2013-06-13 00:02:53 +00:00
|
|
|
EXEC_ELF=hwstub.elf
|
2012-11-14 11:51:51 +00:00
|
|
|
|
2013-06-13 00:02:53 +00:00
|
|
|
#
|
|
|
|
# image production
|
|
|
|
#
|
|
|
|
TOOLS=../../../tools
|
|
|
|
SBTOOLS=../../imxtools/sbtools
|
|
|
|
|
|
|
|
# sb (stmp37xx)
|
|
|
|
EXEC_SB=hwstub.sb
|
2012-11-14 11:51:51 +00:00
|
|
|
ELF2SB=$(SBTOOLS)/elftosb -d
|
2013-06-13 00:02:53 +00:00
|
|
|
ELF2SB_CMD=-c hwstub.db
|
|
|
|
ELF2SB_KEY?=-z
|
2012-11-14 11:51:51 +00:00
|
|
|
|
2013-06-13 00:02:53 +00:00
|
|
|
# sb1 (stmp36xx)
|
|
|
|
EXEC_SB1=hwstub.sb1
|
|
|
|
ELF2SB1_CMD=-loadjump $(EXEC_ELF)
|
|
|
|
ELF2SB1_KEY?=
|
|
|
|
ELF2SB1=$(SBTOOLS)/elftosb1 -d
|
2012-11-14 11:51:51 +00:00
|
|
|
|
2013-06-13 00:02:53 +00:00
|
|
|
EXEC=$(EXEC_ELF) $(EXEC_SB) $(EXEC_SB1)
|
2012-11-14 11:51:51 +00:00
|
|
|
|
|
|
|
all: $(EXEC)
|
|
|
|
|
|
|
|
# pull in dependency info for *existing* .o files
|
|
|
|
-include $(DEPS)
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
$(CC) -MM $(CFLAGS) $*.c > $*.d
|
|
|
|
@cp -f $*.d $*.d.tmp
|
|
|
|
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
|
|
|
|
sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
|
|
|
|
@rm -f $*.d.tmp
|
|
|
|
|
|
|
|
%.o: %.S
|
|
|
|
$(AS) $(ASFLAGS) -c -o $@ $<
|
|
|
|
|
2013-06-13 00:02:53 +00:00
|
|
|
$(TMP_LDS): $(LINKER_FILE)
|
2012-11-14 11:51:51 +00:00
|
|
|
$(CC) -E -x c - < $< | sed '/#/d' > $@
|
2013-06-13 00:02:53 +00:00
|
|
|
|
|
|
|
$(EXEC_ELF): $(OBJ) $(TMP_LDS)
|
2012-11-14 11:51:51 +00:00
|
|
|
$(LD) $(LDFLAGS) -o $@ $(OBJ_EXCEPT_CRT0)
|
|
|
|
|
|
|
|
$(EXEC_SB): $(EXEC_ELF)
|
|
|
|
$(ELF2SB) $(ELF2SB_CMD) $(ELF2SB_KEY) -o $@
|
|
|
|
|
2013-06-13 00:02:53 +00:00
|
|
|
$(EXEC_SB1): $(EXEC_ELF)
|
|
|
|
$(ELF2SB1) $(ELF2SB1_CMD) $(ELF2SB1_KEY) -o $@
|
2012-11-14 11:51:51 +00:00
|
|
|
|
|
|
|
clean:
|
2013-06-15 11:57:53 +00:00
|
|
|
rm -rf $(OBJ) $(DEPS) $(EXEC) $(TMP_LDS) $(TMP_MAP)
|
|
|
|
|