-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
executable file
·40 lines (26 loc) · 986 Bytes
/
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
ARMGNU ?= arm-none-eabi
LINKER ?= build/kernel.ld
AOBJS := $(patsubst %.s,build/%.o,$(wildcard *.s))
COBJS := $(patsubst %.c,build/%.o,$(wildcard *.c))
OBJECTS := $(AOBJS) $(COBJS)
DEPS := $(COBJS:.o=.d)
CFLAGS += -std=c99 -mfloat-abi=hard -ffreestanding -fno-builtin -march=armv7-a -MD -MP -g
LDFLAGS += --no-undefined -L/usr/lib/gcc/arm-none-eabi/6.3.1/ -lgcc
TARGET = build/kernel.img
.PHONY: clean run all
all : $(TARGET)
$(TARGET) : build/output.elf
$(ARMGNU)-objcopy $< -O binary $@
build/output.elf : $(LINKER) $(OBJECTS)
$(ARMGNU)-ld $(OBJECTS) $(LDFLAGS) -o $@ -T $(LINKER)
build/%.o : %.s | build
$(ARMGNU)-as -I . $< -o $@
build/%.o : %.c | build
$(ARMGNU)-gcc $(CFLAGS) -c $< -o $@
build :
@mkdir -p $@
clean :
rm -f $(DEPS) $(OBJECTS) build/output.elf $(TARGET)
run : $(TARGET) qemu/qemu-system-arm qemu/libpng12.so.0 qemu/libcurl.so.4
@LD_LIBRARY_PATH=qemu qemu/qemu-system-arm -machine raspi2 -bios $(TARGET) -serial mon:stdio -s -S
-include $(DEPS)