-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·60 lines (47 loc) · 1.62 KB
/
Makefile
File metadata and controls
executable file
·60 lines (47 loc) · 1.62 KB
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
CC = arm-none-eabi-gcc
CFLAGS = -O0 -g3 -std=c99 -Wall -mcpu=cortex-a8 -mthumb # -pedantic
AS = arm-none-eabi-as
ASFLAGS = -g3 -mcpu=cortex-a8
OBJDIR = obj
SRC = src
KERNEL_MODULES = context kernel main test
KERNEL_OBJS = $(KERNEL_MODULES:%=$(OBJDIR)/%.o)
KERNEL = kernel.elf
TOP = .
all: _clearscreen $(KERNEL)
$(KERNEL): $(KERNEL_OBJS)
$(CC) $(CFLAGS) --specs=nosys.specs -o $(KERNEL) $(KERNEL_OBJS)
$(OBJDIR)/%.o: $(SRC)/%.c
@test -d $(OBJDIR) || mkdir $(OBJDIR)
$(CC) $(CFLAGS) -I $(TOP) -c -o $@ $<
$(OBJDIR)/context.o: $(SRC)/context.S
@test -d $(OBJDIR) || mkdir $(OBJDIR)
$(AS) $(ASFLAGS) -c -o $(OBJDIR)/context.o $(SRC)/context.S
QEMU = qemu-system-arm
# Use `qemu-system-arm -machine help -nographic` to check
MACHINE = realview-pb-a8
# Use 'qemu-system-arm -machine [Machine name] -cpu help` to check
CPU = cortex-a8
# try to generate a unique GDB port
GDBPORT := $(shell expr `id -u` % 5000 + 25000)
# QEMU's gdb stub command line
QEMUGDB = $(shell if $(QEMU) -nographic -help | grep -q '^-gdb'; \
then echo "-gdb tcp::$(GDBPORT)"; \
else echo "-s -p $(GDBPORT)"; fi)
QEMUOPTS = -kernel $(KERNEL) -machine $(MACHINE) -cpu $(CPU) \
-nographic -monitor null -serial null -semihosting $(QEMUEXTRA)
.gdbinit: .gdbinit.tmpl
sed "s/localhost:1234/localhost:$(GDBPORT)/" < $^ > $@
qemu-gdb: $(KERNEL) .gdbinit
@echo "***"
@echo "*** Now run 'arm-none-eabi-gdb' in another terminal." 1>&2
@echo "***"
$(QEMU) $(QEMUOPTS) -S $(QEMUGDB)
VFLAGS = --leak-check=full --log-file=qemu.log
valgrind: $(KERNEL)
valgrind $(VFLAGS) $(QEMU) $(QEMUOPTS) -S $(QEMUGDB)
.PHONY: clean _clearscreen
clean:
rm $(OBJDIR)/*.o
_clearscreen:
clear