-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
65 lines (46 loc) · 1.53 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
59
60
61
62
63
64
65
# Miguel Jimenez Lopez for UGR 2014.
# Original: Makefile from wrpc-sw repository (OHWR), Tomasz Wlostowski for CERN, 2011,2012
CROSS_COMPILE ?= lm32-elf-
export CROSS_COMPILE
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
OBJDUMP = $(CROSS_COMPILE)objdump
OBJCOPY = $(CROSS_COMPILE)objcopy
SIZE = $(CROSS_COMPILE)size
obj-y = arch/lm32/crt0.o arch/lm32/irq.o
obj-y += main.o
LDS-y = arch/lm32/ram.ld
cflags-y = -ffreestanding -I. -Iinclude
cflags-y += -I$(CURDIR)/pp_printf
CFLAGS_PLATFORM = -mmultiply-enabled -mbarrel-shift-enabled
LDFLAGS_PLATFORM = -mmultiply-enabled -mbarrel-shift-enabled \
-nostdlib -T $(LDS-y)
include pp_printf/printf.mk
include dev/dev.mk
CFLAGS = $(CFLAGS_PLATFORM) $(cflags-y) -Wall \
-ffunction-sections -fdata-sections -Os \
-include include/trace.h
# This povokes a problem!
#CFLAGS += -ggdb
LDFLAGS = $(LDFLAGS_PLATFORM) \
-Wl,--gc-sections -Os -lgcc -lc
OBJS = $(obj-y)
OUTPUT-y = main_run
OUTPUT := $(OUTPUT-y)
all: build_tools $(OUTPUT).elf $(OUTPUT).bin $(OUTPUT).ram
$(OUTPUT).elf: $(LDS-y) $(OUTPUT).o
${CC} -o $@ $(OUTPUT).o $(LDFLAGS)
${OBJDUMP} -d $(OUTPUT).elf > $(OUTPUT)_disasm.S
$(SIZE) $@
$(OUTPUT).o: $(OBJS)
$(LD) --gc-sections -e _start -r $(OBJS) -o $@
$(OUTPUT).bin: $(OUTPUT).elf
${OBJCOPY} -O binary $^ $@
$(OUTPUT).ram: $(OUTPUT).bin
./tools/genraminit $(OUTPUT).bin 0 > $@
build_tools:
$(MAKE) -C tools
clean:
rm -f $(OBJS) $(OUTPUT).elf $(OUTPUT).bin $(OUTPUT).ram $(LDS) *.o *.S *~
%.o: %.c
${CC} $(CFLAGS) $(PTPD_CFLAGS) $(INCLUDE_DIR) $(LIB_DIR) -c $*.c -o $@