summaryrefslogtreecommitdiff
path: root/Makefile
blob: 00f34f41f01a51c2f2de53fbc6d61d0f3fda7521 (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
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

    #####################
    #			#
    # FoolOS Makefile	#
    #			#
    #####################

#improve implicit rules
#lets use the size of a 1.44 floppy for a start for our boot img
IMAGE_SIZE=1474560

#font data starts at sector 50
FONT_DATA_START=25600

#data starts at 0x8000
#DATA_START=32768 

SOURCES=$(wildcard ./kernel/*.c)
SOURCES+=$(wildcard ./lib/*/*.c)
ASMSOURCES=$(wildcard ./asm/*.asm)


OBJECTS=$(patsubst %.c, %.o, $(SOURCES))
ASMOBJECTS=$(patsubst %.asm, %.o, $(ASMSOURCES))

MBR=./boot/mbr.bin
KERNEL_ENTRY=./boot/kernel_entry.o
FILLUP=./data/fill.bin

CFLAGS=-ffreestanding -std=gnu99 -m32 -fno-asynchronous-unwind-tables -O0

#default target
#final image
all: FoolOS.img 

# some implicit rule patterns for aseembling (elf and binary)
%.o: %.asm
	nasm -f elf $^ -o $@

%.bin: %.asm
	nasm -f bin $^ -o $@

# explicit rule to create fool-font data binary
binfont.bin: data/binfont.src
	python tools/binarize.py $< $@

#assembling of final image
FoolOS.img: Fool.img FoolData.img $(FILLUP)
	cat $^ | head -c $(IMAGE_SIZE) > $@

Fool.img: $(MBR) kernel.bin $(FILLUP)
	cat $^ | head -c $(FONT_DATA_START) > $@

FoolData.img:  binfont.bin
	cat $^ > $@

# kernel_entry.o needs to be FIRST!!
kernel.bin: $(KERNEL_ENTRY) $(ASMOBJECTS) $(OBJECTS) 
	ld -o $@ -Ttext 0x1000 --oformat binary -melf_i386 $^ -O0

##### cleanup #####

clean:
	-rm *.bin *.img bochs.log $(KERNEL_ENTRY) $(ASMOBJECTS) $(OBJECTS) $(FILLUP) $(MBR)

###### virtual machine stuff ######

# dump from vbox
#dump: FoolOS.img
#	vboxmanage debugvm FoolOs dumpguestcore --filename dump.elf
#	xxd dump.elf > dump.xxd

# run in our local bochs 
run: FoolOS.img
	~/opt/bochs-2.6.6/bochs -q

.PHONY: all clean