-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
48 lines (37 loc) · 1.06 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
44
45
46
47
#!Makefile
C_SOURCES = $(shell find . -name "*.c")
C_OBJECTS = $(patsubst %.c, %.o, $(C_SOURCES))
S_SOURCES = $(shell find . -name "*.s")
S_OBJECTS = $(patsubst %.s, %.o, $(S_SOURCES))
CC = gcc
LD = ld
ASM = nasm
TARGET = xiaos
C_FLAGS = -c -Wall -m32 -ggdb -gstabs+ -nostdinc -fno-builtin -fno-stack-protector -I include
LD_FLAGS = -T link.ld -m elf_i386 -nostdlib
ASM_FLAGS = -f elf -g -F stabs
all: $(S_OBJECTS) $(C_OBJECTS) xiao burn_image
# compile
.c.o:
$(CC) $(C_FLAGS) $< -o $@
.s.o:
$(ASM) $(ASM_FLAGS) $<
.PHONY:xiao
xiao:
$(LD) $(LD_FLAGS) $(S_OBJECTS) $(C_OBJECTS) -o $(TARGET)
.PHONY:clean
clean:
$(RM) $(S_OBJECTS) $(C_OBJECTS) $(TARGET)
.PHONY:burn_image
burn_image:
mkdir -p /mnt/kernel
mount floppy.img /mnt/kernel
cp $(TARGET) /mnt/kernel/$(TARGET)
sleep 1
umount /mnt/kernel
run:
#qemu -fda floppy.img -boot a -nographic
qemu -fda floppy.img -boot a -curses
#add '-nographic' option if using server of linux distro, such as fedora-server,or "gtk initialization failed" error will occur.
debug:
qemu -S -s -fda floppy.img -boot a -curses