Debian Codegraph @

build/build-kernel

raw
1 #! /bin/sh
2
3 ## Kernel-mode libcaca compilation script -- Sam Hocevar <[email protected]>
4
5 set -x
6 set -e
7
8 MYCFLAGS="-fno-builtin -O0 -I. -I.. -I../caca/ -Wall -D__KERNEL__ -fno-stack-protector -m32"
9
10 ./configure --enable-kernel --disable-doc --host i386
11
12 # Compile cacademo, leave it as an object
13 cd caca && make && cd ..
14 cd examples && make dithering.o && cd ..
15
16 cd kernel
17
18 # Bootsector
19 nasm -f bin -o bootsect.bin boot/bootsect.asm
20 # Interruption handlers
21 nasm -f elf -o int.o boot/int.asm
22
23 ##### Boot (x86)
24 # Stage2, loads GDT, PIC, IDT, interrupts, then calls kmain()
25 gcc $MYCFLAGS boot/stage2.c -c
26 # GDT installation, called by stage2
27 gcc $MYCFLAGS boot/gdt.c -c
28 # PIC installation, called by stage2
29 gcc $MYCFLAGS boot/pic.c -c
30 # IDT installation, called by stage2
31 gcc $MYCFLAGS boot/idt.c -c
32 # Interruptions installation, called by stage2
33 gcc $MYCFLAGS boot/interruptions.c -c
34
35 ##### Drivers
36 # Floppy driver
37 gcc $MYCFLAGS drivers/floppy.c -c
38 # Processor driver
39 gcc $MYCFLAGS drivers/processor.c -c
40 # Keyboard handler
41 gcc $MYCFLAGS drivers/keyboard.c -c
42 # Memory driver
43 gcc $MYCFLAGS drivers/memory.c -c
44 # Programmable Interval Timer driver
45 gcc $MYCFLAGS drivers/timer.c -c
46
47 # Minimalistic libc
48 gcc $MYCFLAGS klibc.c -c
49
50 # Kernel by itself, contains cmain() which calls main()
51 gcc $MYCFLAGS kernel.c -c
52
53 # Link everything but bootsector, kernel.o MUST be at the very end
54 ld --oformat binary -Ttext 1000 stage2.o gdt.o pic.o int.o idt.o interruptions.o keyboard.o memory.o timer.o floppy.o processor.o klibc.o kernel.o ../caca/.libs/libcaca.a -Map kernel.map -o kern.bin
55
56 ls -ail kern.bin
57 cd ..
58
59 # Copy bootsector at the very beginning of the floppy (first sector/512 bytes of the image), then kernel right after
60 cat kernel/bootsect.bin kernel/kern.bin /dev/zero | dd of=cacademo.img bs=512 count=2500
61