-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (44 loc) · 2.14 KB
/
Copy pathMakefile
File metadata and controls
63 lines (44 loc) · 2.14 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
61
LDFILE=testing/linker.ld
LIBPATH=build/libpios.a
TESTSPATH=build/tests.elf
KERNELFILES_C=$(subst .c,.o,$(wildcard kernel/port/gcc/cortex-m3/*.c kernel/*/*.c kernel/*.c))
KERNELFILES_S=$(subst .s,.o,$(wildcard kernel/port/gcc/cortex-m3/*.s))
TESTSFILES_C=$(subst .c,.o,$(wildcard testing/*/*.c testing/*.c))
TESTSFILES_S=$(subst .s,.o,$(wildcard testing/*.s))
BUILDFILES_C=$(subst kernel/,build/,$(KERNELFILES_C))
BUILDFILES_S=$(subst kernel/port/gcc/cortex-m3,build/,$(KERNELFILES_S))
BUILDTESTING_C=$(subst testing/,build/,$(TESTSFILES_C)) $(BUILDFILES_C)
BUILDTESTING_S=$(subst testing/,build/,$(TESTSFILES_S)) $(BUILDFILES_S)
# Rule for building the kernel as a static library
libpios: $(BUILDFILES_C) $(BUILDFILES_S)
@echo building libpios...
@ar rcs $(LIBPATH) $(addprefix build/,$(notdir $^))
# Rule for building tests
testsexec: $(BUILDTESTING_C) $(BUILDTESTING_S)
@echo building tests...
@arm-none-eabi-gcc -Wall -O0 -mcpu=cortex-m3 -mthumb --freestanding -nostartfiles -ggdb -T $(LDFILE) -o $(TESTSPATH) $(addprefix build/,$(notdir $^))
# Rules for C files
build/%.o: kernel/%.c
@[ -d build ] || mkdir build
@arm-none-eabi-gcc -Wall -O0 -mcpu=cortex-m3 -mthumb --freestanding -nostartfiles -ggdb -c $^ -o build/$(notdir $@)
build/%.o: testing/%.c
@[ -d build ] || mkdir build
@arm-none-eabi-gcc -Wall -O0 -mcpu=cortex-m3 -mthumb --freestanding -nostartfiles -ggdb -c $^ -o build/$(notdir $@)
# Rules for S files
build/%.o: kernel/port/gcc/cortex-m3/%.s
@[ -d build ] || mkdir build
@arm-none-eabi-as --warn --fatal-warnings -mcpu=cortex-m3 -ggdb $^ -o $@
build/%.o: testing/%.s
@[ -d build ] || mkdir build
@arm-none-eabi-as --warn --fatal-warnings -mcpu=cortex-m3 -ggdb $^ -o $@
# Rule for cleaning the build directory
clean:
@rm build/*.a build/*.o build/*.elf 2>/dev/null || true
# Rule for running the executable in qemu with gdb
gdb:
@make clean && make testsexec
@qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -gdb tcp::3333 -S -kernel $(TESTSPATH)
# Rule for running the executable in qemu without gdb
test:
@make clean && make testsexec
@qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -kernel $(TESTSPATH)