-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (44 loc) · 2.43 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
# Copyright (C) 2017 Daniel Page <csdsp@bristol.ac.uk>
#
# Use of this source code is restricted per the CC BY-NC-ND license, a copy of
# which can be found via http://creativecommons.org (and should be included as
# LICENSE.txt within the associated archive or repository).
# part 1: variables
PROJECT_PATH = $(shell find . -mindepth 1 -maxdepth 1 -type d)
PROJECT_SOURCES = $(shell find ${PROJECT_PATH} -name *.c -o -name *.s)
PROJECT_HEADERS = $(shell find ${PROJECT_PATH} -name *.h )
PROJECT_OBJECTS = $(addsuffix .o, $(basename ${PROJECT_SOURCES}))
PROJECT_TARGETS = image.elf image.bin
QEMU_PATH = /usr
QEMU_GDB = 127.0.0.1:1234
QEMU_UART = stdio
#QEMU_UART += telnet:127.0.0.1:1235,server
#QEMU_UART += telnet:127.0.0.1:1236,server
QEMU_DISPLAY = -nographic -display none
#QEMU_DISPLAY = -display sdl
LINARO_PATH = /usr/local/gcc-linaro-5.1-2015.08-x86_64_arm-eabi
LINARO_PREFIX = arm-eabi
# part 2: build commands
%.o : %.s
@${LINARO_PATH}/bin/${LINARO_PREFIX}-as $(addprefix -I , ${PROJECT_PATH} ${LINARO_PATH}/${LINARO_PREFIX}/libc/usr/include) -mcpu=cortex-a8 -g -o ${@} ${<}
%.o : %.c
@${LINARO_PATH}/bin/${LINARO_PREFIX}-gcc $(addprefix -I , ${PROJECT_PATH} ${LINARO_PATH}/${LINARO_PREFIX}/libc/usr/include) -mcpu=cortex-a8 -mabi=aapcs -ffreestanding -std=gnu99 -g -c -fomit-frame-pointer -O -o ${@} ${<}
%.elf : ${PROJECT_OBJECTS}
@${LINARO_PATH}/bin/${LINARO_PREFIX}-ld $(addprefix -L , ${LINARO_PATH}/${LINARO_PREFIX}/libc/usr/lib ) -T ${*}.ld -o ${@} ${^} -lc -lgcc
%.bin : %.elf
@${LINARO_PATH}/bin/${LINARO_PREFIX}-objcopy -O binary ${<} ${@}
# part 3: targets
.PRECIOUS : ${PROJECT_OBJECTS} ${PROJECT_TARGETS}
build : ${PROJECT_TARGETS}
launch-qemu : ${PROJECT_TARGETS}
@${QEMU_PATH}/bin/qemu-system-arm -M realview-pb-a8 -m 512M ${QEMU_DISPLAY} -gdb tcp:${QEMU_GDB} $(addprefix -serial , ${QEMU_UART}) -S -kernel $(filter %.bin, ${PROJECT_TARGETS})
launch-gdb : ${PROJECT_TARGETS}
@${LINARO_PATH}/bin/${LINARO_PREFIX}-gdb -ex "file $(filter %.elf, ${PROJECT_TARGETS})" -ex "target remote ${QEMU_GDB}"
kill-qemu :
@-killall --quiet --user ${USER} qemu-system-arm
kill-gdb :
@-killall --quiet --user ${USER} ${LINARO_PREFIX}-gdb
clean :
@rm -f core ${PROJECT_OBJECTS} ${PROJECT_TARGETS}
include Makefile.console
include Makefile.disk