summaryrefslogtreecommitdiff
path: root/src/Makefile
blob: 041a029f8a643811dc4df586785bf55d9402a8c7 (plain)
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
CC := gcc
CFLAGS := -std=c99 -m32 -ffreestanding
LD := ld

all: image.bin

image.bin: boot.bin kernel.bin
	cat boot.bin kernel.bin > image.bin
	# truncate to correct number of sectors, we have
	# 512 (boot) + N * 1024 (N currenty is 2)
	truncate -s 2560 image.bin
	
boot.bin: boot.asm gdt.asm stage1_functions.asm stage2_functions.asm switch_mode.asm
	nasm boot.asm -f bin -o boot.bin

kernel.bin: kernel.o
	$(LD) -o kernel.bin -Ttext 0x8000 kernel.o --oformat binary

kernel.o: kernel.c
	$(CC) $(CFLAGS) -O0 -c -o kernel.o kernel.c

clean:
	-rm -f boot.bin kernel.bin image.bin *.o

run-qemu: image.bin
	qemu-system-i386 -m 16 -drive "file=image.bin,if=ide,format=raw"

run-bochs:
	bochs -q -f bochs.config 'boot:floppy' 'floppya: 1_44=image.bin, status=inserted'

functions.o: functions.c
	$(CC) $(CFLAGS) -c -o functions.o functions.c