-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
96 lines (68 loc) · 2.49 KB
/
Makefile
File metadata and controls
96 lines (68 loc) · 2.49 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
CC = gcc
AS = as
OBJCOPY = objcopy
CFLAGS = -Wall -g
ASFLAGS =
TARGET_INPUT = input.bin
TARGET_TEST = test.bin
TARGET_INPUT_TERRUPT = input_interrupt.bin
TARGETS = kvm
all: $(TARGETS)
CFLAGS = -DCONFIG_X86_64 -DCONFIG_X86
CFLAGS += -I./ -Iinclude -Ix86/include
CFLAGS += -Wall
CFLAGS += -fno-strict-aliasing
CFLAGS += -g
#CFLAGS += -O2
BIOS_CFLAGS += -m32
BIOS_CFLAGS += -march=i386
BIOS_CFLAGS += -mregparm=3
BIOS_CFLAGS += -fno-stack-protector
BIOS_CFLAGS += -fno-pic
x86/bios.o: x86/bios/bios.bin x86/bios/bios-rom.h
x86/bios/bios.bin.elf: x86/bios/entry.S x86/bios/e820.c x86/bios/int10.c x86/bios/int15.c x86/bios/rom.ld.S
$(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c x86/bios/memcpy.c -o x86/bios/memcpy.o
$(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c x86/bios/e820.c -o x86/bios/e820.o
$(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c x86/bios/int10.c -o x86/bios/int10.o
$(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c x86/bios/int15.c -o x86/bios/int15.o
$(CC) $(CFLAGS) $(BIOS_CFLAGS) -c x86/bios/entry.S -o x86/bios/entry.o
$(LD) -T x86/bios/rom.ld.S -o x86/bios/bios.bin.elf x86/bios/memcpy.o x86/bios/entry.o x86/bios/e820.o x86/bios/int10.o x86/bios/int15.o
x86/bios/bios.bin: x86/bios/bios.bin.elf
$(OBJCOPY) -O binary -j .text x86/bios/bios.bin.elf x86/bios/bios.bin
x86/bios/bios-rom.o: x86/bios/bios-rom.S x86/bios/bios.bin x86/bios/bios-rom.h
$(CC) -c $(CFLAGS) x86/bios/bios-rom.S -o x86/bios/bios-rom.o
x86/bios/bios-rom.h: x86/bios/bios.bin.elf
cd x86/bios && sh gen-offsets.sh > bios-rom.h && cd ..
$(TARGET_INPUT): input.S
nasm -f bin input.S -o input.bin
$(TARGET_INPUT_TERRUPT): input_interrupt.S
nasm -f bin input_interrupt.S -o input_interrupt.bin
bios.bin: bios.S
nasm -f bin bios.S -o bios.bin
pit.bin: pit.S
nasm -f bin pit.S -o pit.bin
apic.bin: apic.S
nasm -f bin apic.S -o apic.bin
boot.bin: boot.S
nasm -f bin boot.S -o boot.bin
bios.o:x86/bios.c x86/bios/bios-rom.h
gcc -g -Wall -c -o $@ $<
rbtree.o:rbtree.c
gcc $(CFLAGS) -c -o $@ $<
mptable.o:mptable.c
gcc $(CFLAGS) -c -o $@ $<
term.o:term.c
gcc $(CFLAGS) -c -o $@ $<
serial.o:serial.c
gcc $(CFLAGS) -c -o $@ $<
kvm.o:kvm.c
gcc $(CFLAGS) -c -o $@ $<
kvm: kvm.o rbtree.o x86/bios.o x86/bios/bios-rom.o term.o serial.o mptable.o
gcc -g -Wall -o $@ $^
$(TARGET_TEST): test.o
$(OBJCOPY) -O binary test.o $(TARGET_TEST)
test.o: test.S
$(AS) $(ASFLAGS) test.S -o test.o
clean:
rm -f *.o $(TARGETS) x86/bios/*.o x86/bios/*.bin x86/bios/*.elf x86/bios/bios-rom.h
.PHONY: all clean