summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2015-05-12 22:22:06 +0200
committerMichal Idziorek <m.i@gmx.at>2015-05-12 22:22:06 +0200
commit2c1148e7920cf1d4c772d0d81757a7f8d736648e (patch)
treeeed84fead5fae2efb3526094eed05eeae127f915 /Makefile
parent0a9f1b1fb19ea7e0c54c884b7ae8c709ea738d1f (diff)
migrating to grub and elf kernel format
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile55
1 files changed, 28 insertions, 27 deletions
diff --git a/Makefile b/Makefile
index c090265..94d4c7a 100644
--- a/Makefile
+++ b/Makefile
@@ -14,24 +14,23 @@
############ some constants ############
+FOOLOS=FoolOS.img
+FOOLOS_VDI=FoolOS.vdi
#submodules
SUBDIRS=boot1 boot2 font userspace
-FOOLOS=FoolOS.img
-FOOLOS_VDI=FoolOS.vdi
-
#take care to set this properly!
USB_STICK=/dev/sdf
#use our cross compiler
-CC=i686-foolos-gcc
+CC=i686-elf-gcc
############ compiler flags ############
CFLAGS=
-CFLAGS+=-fstack-protector-all
-CFLAGS+=-Werror-implicit-function-declaration
-CFLAGS+=-w
+## CFLAGS+=-fstack-protector-all
+## CFLAGS+=-Werror-implicit-function-declaration
+## CFLAGS+=-w
CFLAGS+=-ffreestanding
CFLATS+=-Wall
CFLAGS+=-Wextra
@@ -41,6 +40,7 @@ CFLAGS+=-Wextra
CFLAGS+=-std=gnu11
CFLAGS+=-I.
CFLAGS+=-I/home/miguel/temp/fool-os-stuff/newlib-2.1.0/newlib/libc/include
+CFLAGS+=-gstabs
#CFLAGS+=-lgcc
#CFLAGS+=-fno-zero-initialized-in-bss
#CFLAGS+= -O4
@@ -78,18 +78,19 @@ DEPS=$(patsubst %.c, %.d, $(SOURCES))
ASM_SOURCES=$(wildcard ./asm/*.asm)
ASM_OBJECTS=$(patsubst %.asm, %.o, $(ASM_SOURCES))
-KERNEL_ENTRY=./asm/kernel_entry.o
-
+ASM_MULTIBOOT=$(wildcard ./asm/*.s)
+ASM_MULTIBOOT_OBJ=$(patsubst %.s, %.o, $(ASM_MULTIBOOT))
############ Final Targets ############
-all: FoolOS.vdi FoolOS.img
+all: $(FOOLOS) #$(FOOLOS_VDI)
new: clean all
+run: run-qemu
+newrun: clean run
-
-########### INCLUDES ###################3
+########### INCLUDES ###################
include Makefile.common
-include $(DEPS)
@@ -97,6 +98,7 @@ include Makefile.common
#### BINARIES AND SUBMODULES ########
+KERNEL_IMG=foolos.img
BIN_KERNEL=kernel.bin
BIN_MBR=./boot1/mbr.bin
BIN_STAGE2=./boot2/stage2.bin
@@ -124,21 +126,23 @@ $(CLEANDIRS):
############ linking kernel binary ############
-# the kernel_entry.o needs to be FIRST!!
-$(BIN_KERNEL): $(KERNEL_ENTRY) $(ASM_OBJECTS) $(OBJECTS)
+$(KERNEL_IMG): $(ASM_MULTIBOOT_OBJ) $(ASM_OBJECTS) $(OBJECTS)
$(CC) $(CFLAGS) $(LDFLAGS) -T linker.ld -o $@ $^
############ assembling of final image ############
# master boot record, kernel binary and fool-font
-$(FOOLOS): $(BIN_KERNEL) $(SUBDIRS)
- dd if=$(BIN_MBR) of=$@ bs=512 seek=0 conv=notrunc
- dd if=$(BIN_STAGE2) of=$@ bs=512 seek=1 conv=notrunc
- # kernel will start at 0x100000 in ram (this is what the booloader starts loading secotr: 10)
- dd if=$(BIN_KERNEL) of=$@ bs=512 seek=10 conv=notrunc # kernel can be about 128KB (incl bss)
- # the data will starts at 0x120000 in ram
- dd if=$(IMG_USERSPACE) of=$@ bs=512 seek=266 conv=notrunc
+$(FOOLOS): $(KERNEL_IMG) # $(SUBDIRS)
+ sudo cp $(KERNEL_IMG) /mnt/vdi/boot
+ sync
+
+# dd if=$(BIN_MBR) of=$@ bs=512 seek=0 conv=notrunc
+# dd if=$(BIN_STAGE2) of=$@ bs=512 seek=1 conv=notrunc
+# # kernel will start at 0x100000 in ram (this is what the booloader starts loading secotr: 10)
+# dd if=$(BIN_KERNEL) of=$@ bs=512 seek=10 conv=notrunc # kernel can be about 128KB (incl bss)
+# # the data will starts at 0x120000 in ram
+# dd if=$(IMG_USERSPACE) of=$@ bs=512 seek=266 conv=notrunc
############ virtual machines stuff ############
@@ -152,15 +156,12 @@ $(FOOLOS_VDI): $(FOOLOS)
run-bochs: all
~/opt/bochs-2.6.6/bochs -q -f bochs/bochsrc -rc bochs/bochsdebug
+# run in qemu
run-qemu: all
qemu-system-i386 $(FOOLOS)
run-qemu-debug: all
- qemu-system-i386 -s -S $(FOOLOS)
-
-run: run-bochs
-
-newrun: clean run
+ qemu-system-i386 -s -S ~/temp/FoolOs/disk.img
############ create bootable usb image ############
@@ -172,4 +173,4 @@ stick: $(FOOLOS)
############ cleanup ############
clean: $(CLEANDIRS)
- -rm *.bin $(FOOLOS) $(FOOLOS_VDI) $(KERNEL_ENTRY) $(ASM_OBJECTS) $(OBJECTS) $(IMG_FILLUP) $(BIN_MBR) $(BIN_MP) $(BIN_STAGE2) $(DEPS) bochs.out bochs.log ne2k-tx.log ne2k-txdump.txt
+ -rm *.bin $(FOOLOS) $(FOOLOS_VDI) $(KERNEL_ENTRY) $(ASM_MULTIBOOT_OBJ) $(KERNEL_IMG) $(ASM_OBJECTS) $(OBJECTS) $(IMG_FILLUP) $(BIN_MBR) $(BIN_MP) $(BIN_STAGE2) $(DEPS) bochs.out bochs.log ne2k-tx.log ne2k-txdump.txt