-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
87 lines (71 loc) · 1.89 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
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
OBJECTS = \
loader.o\
kmain.o\
kernel.o\
write.o\
descriptor_tables.o\
trap.o\
common.o\
timer.o\
proc.o\
alloc.o\
vm.o\
spinlock.o\
switch.o\
initrd.o\
fs.o\
file.o\
syscall.o\
sys_file.o\
exec.o\
kbd.o\
pic.o\
sysproc.o\
console.o\
CC = gcc
CFLAGS = -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector \
-nostartfiles -nodefaultlibs -Wall -Wextra -c
LDFLAGS = -T link.ld -melf_i386
AS = nasm
ASFLAGS = -f elf
all: kernel.elf
#-nostdinc -I. -c
ULIB = ulib.o usys.o printf.o umalloc2.o
init: init.o $(ULIB)
ld -T ulink.ld -m elf_i386 -Ttext 0 -o init.elf init.o $(ULIB)
./mk_ramdsk init.elf init.elf sh sh ls ls
sh: sh.o $(ULIB)
ld -T ulink.ld -m elf_i386 -Ttext 0 -o sh sh.o $(ULIB)
./mk_ramdsk init.elf init.elf sh sh ls ls
ls: ls.o $(ULIB)
ld -T ulink.ld -m elf_i386 -Ttext 0 -o ls ls.o $(ULIB)
./mk_ramdsk init.elf init.elf sh sh ls ls
initcode:
nasm initcode.s -o initcode.out
ld -e start -r -b binary -m elf_i386 -Ttext 0 -o initcode.o initcode.out
#objcopy -S -O binary initcode.out initcode
kernel.elf: $(OBJECTS) initcode
ld -T link.ld -m elf_i386 -o kernel.elf $(OBJECTS) initcode.o
mk_ramdsk: mk_ramdsk.c
gcc -o mk_ramdsk mk_ramdsk.c
os.iso: kernel.elf
cp kernel.elf iso/boot/kernel.elf
cp initrd.img iso/boot/initrd.img
genisoimage -R \
-b boot/grub/stage2_eltorito \
-no-emul-boot \
-boot-load-size 4 \
-A os \
-input-charset utf8 \
-quiet \
-boot-info-table \
-o os.iso \
iso
run: os.iso
bochs -f bochsrc.txt -q
%.o: %.c
$(CC) $(CFLAGS) $< -o $@
%.o: %.s
$(AS) $(ASFLAGS) $< -o $@
clean:
rm -rf *.o kernel.elf os.iso initcode initcode.out