-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (48 loc) · 1.86 KB
/
Makefile
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
-include ../kconfig/.config
-include ../config.mk
CROSS_COMPILE?=arm-none-eabi-
CC=$(CROSS_COMPILE)gcc
CFLAGS+=-DCONFIG_FRESH=1
CFLAGS += -DCONFIG_IDDLELEDS=1
APPS-y:=apps/init.o
APPS-y+=apps/fresh.o
APPS-y+=apps/binutils.o
APPS-y+=apps/stubs.o
CFLAGS+=-mcpu=cortex-m3 -mthumb -mlittle-endian -mthumb-interwork -fno-common
CFLAGS+=-DCORE_M3 -DARCH_$(ARCH)
CFLAGS+=-DKLOG_LEVEL=6
#Include paths
CFLAGS+=-I. -I$(FROSTED)/include -I$(FROSTED)/include/libc
#Freestanding options
CFLAGS+=-fno-builtin
CFLAGS+=-ffreestanding
#Debugging
CFLAGS+=-ggdb -nostartfiles
ASFLAGS:=-mcpu=cortex-m3 -mthumb -mlittle-endian -mthumb-interwork -ggdb
LDFLAGS+=-L.
all: $(FROSTED)/apps.img
$(FROSTED)/apps.img: apps.elf
$(CROSS_COMPILE)objcopy -O binary --pad-to=$$PADTO $^ $@
apps/apps.ld: apps/apps.ld.in
export KMEM_SIZE_B=`python2 -c "print '0x%X' % ( $(KFLASHMEM_SIZE) * 1024)"`; \
export AMEM_SIZE_B=`python2 -c "print '0x%X' % ( ($(RAM_SIZE) - $(KRAMMEM_SIZE)) * 1024)"`; \
export KFLASHMEM_SIZE_B=`python2 -c "print '0x%X' % ( $(KFLASHMEM_SIZE) * 1024)"`; \
export AFLASHMEM_SIZE_B=`python2 -c "print '0x%X' % ( ($(FLASH_SIZE) - $(KFLASHMEM_SIZE)) * 1024)"`; \
export KRAMMEM_SIZE_B=`python2 -c "print '0x%X' % ( $(KRAMMEM_SIZE) * 1024)"`; \
cat $^ | sed -e "s/__FLASH_ORIGIN/$(FLASH_ORIGIN)/g" | \
sed -e "s/__KFLASHMEM_SIZE/$$KFLASHMEM_SIZE_B/g" | \
sed -e "s/__AFLASHMEM_SIZE/$$AFLASHMEM_SIZE_B/g" | \
sed -e "s/__RAM_BASE/$(RAM_BASE)/g" |\
sed -e "s/__KRAMMEM_SIZE/$$KRAMMEM_SIZE_B/g" |\
sed -e "s/__AMEM_SIZE/$$AMEM_SIZE_B/g" \
>$@
apps.elf: libfrosted.a $(APPS-y) apps/apps.ld
$(CC) -o $@ $(APPS-y) -Tapps/apps.ld -lfrosted -lc -lfrosted -Wl,-Map,apps.map $(LDFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
libfrosted.a: libfrosted
make -C libfrosted FROSTED=$(FROSTED)
clean:
@make -C apps clean
@make -C libfrosted clean
@rm -f apps/apps.ld
@rm -f apps.elf
@rm -f apps.map