blob: 7fd33c3d9e838ca795c74040ea9d0c7e284d8e93 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#
# common
#
CC=arm-elf-eabi-gcc
LD=arm-elf-eabi-gcc
AS=arm-elf-eabi-gcc
OC=arm-elf-eabi-objcopy
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=
LINKER_FILE=hwstub.lds
TMP_LDS=link.lds
TMP_MAP=hwstub.map
LDFLAGS=-lgcc -Os -nostdlib -T$(TMP_LDS) -Wl,-Map,$(TMP_MAP)
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)
EXEC_ELF=hwstub.elf
#
# image production
#
TOOLS=../../../tools
SBTOOLS=../../imxtools/sbtools
# sb (stmp37xx)
EXEC_SB=hwstub.sb
ELF2SB=$(SBTOOLS)/elftosb -d
ELF2SB_CMD=-c hwstub.db
ELF2SB_KEY?=-z
# sb1 (stmp36xx)
EXEC_SB1=hwstub.sb1
ELF2SB1_CMD=-loadjump $(EXEC_ELF)
ELF2SB1_KEY?=
ELF2SB1=$(SBTOOLS)/elftosb1 -d
EXEC=$(EXEC_ELF) $(EXEC_SB) $(EXEC_SB1)
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 $@ $<
$(TMP_LDS): $(LINKER_FILE)
$(CC) -E -x c - < $< | sed '/#/d' > $@
$(EXEC_ELF): $(OBJ) $(TMP_LDS)
$(LD) $(LDFLAGS) -o $@ $(OBJ_EXCEPT_CRT0)
$(EXEC_SB): $(EXEC_ELF)
$(ELF2SB) $(ELF2SB_CMD) $(ELF2SB_KEY) -o $@
$(EXEC_SB1): $(EXEC_ELF)
$(ELF2SB1) $(ELF2SB1_CMD) $(ELF2SB1_KEY) -o $@
clean:
rm -rf $(OBJ) $(DEPS) $(EXEC) $(TMP_LDS) $(TMP_MAP)
|