-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
43 lines (33 loc) · 1.37 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
SOURCE = src/
NONOPTIMISED = src/NoOptimisation/
BUILD = build/
TARGET = kernel8.img
LINKER = link.ld
FONT = src/font/font.psf
FONTOBJ = build/font.o
AUDIO = src/audio/The_Amazons.bin
AUDIOOBJ = build/the_amazons.o
LIBS = lib/libopenlibm.a
LIBOBJS = build/libopenlibm.o
ASMOBJS = $(patsubst $(SOURCE)%.s,$(BUILD)%.o,$(wildcard $(SOURCE)*.s))
COBJS = $(patsubst $(SOURCE)%.c,$(BUILD)%.o,$(wildcard $(SOURCE)*.c))
COBJSNOOP = $(patsubst $(NONOPTIMISED)%.c,$(BUILD)%.o,$(wildcard $(NONOPTIMISED)*.c))
CFLAGS = -Wall -O2 -ffreestanding -nostdinc -nostdlib -nostartfiles -std=gnu99
CFLAGSNOOP = -Wall -ffreestanding -nostdinc -nostdlib -nostartfiles
all: clean kernel8.img
$(BUILD)%.o: $(SOURCE)%.s
aarch64-linux-gnu-gcc -g $(CFLAGS) -c $< -o $@
$(BUILD)%.o: $(SOURCE)%.c
aarch64-linux-gnu-gcc -g $(CFLAGS) -c $< -o $@
$(FONTOBJ): $(FONT)
aarch64-linux-gnu-ld -r -b binary -o $(FONTOBJ) $(FONT)
$(AUDIOOBJ): $(AUDIO)
aarch64-linux-gnu-ld -r -b binary -o $(AUDIOOBJ) $(AUDIO)
$(BUILD)%.o: $(NONOPTIMISED)%.c
aarch64-linux-gnu-gcc $(CFLAGSNOOP) -c $< -o $@
kernel8.img: $(ASMOBJS) $(COBJS) $(FONTOBJ) $(COBJSNOOP) $(AUDIOOBJ)
aarch64-linux-gnu-ld -nostdlib -nostartfiles $(FONTOBJ) $(AUDIOOBJ) $(ASMOBJS) $(COBJSNOOP) $(COBJS) -L lib -l openlibm -T $(LINKER) -o $(BUILD)kernel.elf
aarch64-linux-gnu-objcopy $(BUILD)kernel.elf -O binary $(TARGET)
clean:
rm -rf build/*
rm -rf $(TARGET)