From c742be9c738c91703a7be787639cad167de3a6b1 Mon Sep 17 00:00:00 2001 From: Miguel Date: Fri, 17 Aug 2018 02:28:02 +0200 Subject: started reviving my fool os --- Makefile | 123 ++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 58 insertions(+), 65 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 7450e58..a3980d5 100644 --- a/Makefile +++ b/Makefile @@ -5,26 +5,18 @@ # # ##################### - -# main phony targets - .PHONY: all new run newrun stick clean tags mount umount -############ some constants ############ - -FOOLOS=FoolOS.img -FOOLOS_VDI=FoolOS.vdi - -#submodules -SUBDIRS=userspace - -#take care to set this properly! -USB_STICK=/dev/sdf +############ compiler ############ #use our cross compiler CC=i686-foolos-gcc AS=i686-foolos-as +#sorry just this +CC=i686-elf-gcc +AS=i686-elf-as + ############ compiler flags ############ CFLAGS= ## CFLAGS+=-fstack-protector-all @@ -38,7 +30,8 @@ CFLAGS+=-O0 #CFLAGS+=-nostdlib CFLAGS+=-std=gnu11 CFLAGS+=-I. -CFLAGS+=-I/home/miguel/temp/fool-os-stuff/newlib-2.1.0/newlib/libc/include +#CFLAGS+=-I/home/miguel/temp/fool-os-stuff/newlib-2.1.0/newlib/libc/include +CFLAGS+=-I/home/miguel/foolos/usr/i686-foolos//include/ CFLAGS+=-gstabs #CFLAGS+=-lgcc #CFLAGS+=-fno-zero-initialized-in-bss @@ -47,15 +40,16 @@ CFLAGS+=-gstabs #CFLAGS+= -Werror CFLAGS+= -w +######## linker flags #################### LDFLAGS= LDFLAGS+=-nostdlib LDFLAGS+=-lgcc +########## assembler flags ################# ASFLAGS= ASFLAGS+=-gstabs - -#verbosity +########## verbosity ##################3 #V = 0 #CC = @echo "Compiling $<..."; i686-foolos-gcc #CC_1 = $(CCC) @@ -77,8 +71,6 @@ OBJECTS=$(patsubst %.c, %.o, $(SOURCES)) #derive deps DEPS=$(patsubst %.c, %.d, $(SOURCES)) - - ####### ASM STUFF ##### ASM_SOURCES=$(wildcard ./asm/*.asm) @@ -86,15 +78,27 @@ ASM_OBJECTS=$(patsubst %.asm, %.o, $(ASM_SOURCES)) ASM_MULTIBOOT=$(wildcard ./asm/*.s) ASM_MULTIBOOT_OBJ=$(patsubst %.s, %.o, $(ASM_MULTIBOOT)) +#### BINARIES AND SUBMODULES ######## + +FOOLOS_ISO=FoolOS.iso +KERNEL_IMG=foolos.img +BIN_KERNEL=kernel.bin +BIN_MBR=./boot1/mbr.bin +BIN_STAGE2=./boot2/stage2.bin +BIN_MP=./boot2/mp.bin +BIN_FOOLFONT=./font/binfont.bin +SUBDIRS=userspace +IMG_FILLUP=fill.img +IMG_USERSPACE=./userspace/ext2.img ############ Final Targets ############ -all: $(FOOLOS) tags # $(FOOLOS_VDI) +all: tags $(FOOLOS_ISO) #$(FOOLOS) # tags # $(FOOLOS_VDI) new: clean all -run: run-qemu -debug: run-qemu-debug newrun: clean run +run: run-qemu +debug: run-qemu-debug ########## INCLUDES ################### @@ -102,22 +106,8 @@ include Makefile.common -include $(DEPS) -#### BINARIES AND SUBMODULES ######## - -KERNEL_IMG=foolos.img -BIN_KERNEL=kernel.bin -BIN_MBR=./boot1/mbr.bin -BIN_STAGE2=./boot2/stage2.bin -BIN_MP=./boot2/mp.bin -BIN_FOOLFONT=./font/binfont.bin - -IMG_FILLUP=fill.img -IMG_USERSPACE=./userspace/ext2.img - - ######### RECURSIVE MAKES ######################## - CLEANDIRS=$(SUBDIRS:%=clean-%) .PHONY: $(SUBDIRS) $(CLEANDIRS) @@ -128,74 +118,77 @@ $(SUBDIRS): $(CLEANDIRS): $(MAKE) -C $(@:clean-%=%) clean - - ############ linking kernel binary ############ $(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): $(KERNEL_IMG) $(SUBDIRS) - sudo cp $(KERNEL_IMG) /mnt/vdi/boot - sudo cp $(IMG_USERSPACE) /mnt/vdi/boot - sync - - +# +#$(FOOLOS): $(KERNEL_IMG) $(SUBDIRS) +# sudo cp $(KERNEL_IMG) /mnt/vdi/boot +# sudo cp $(IMG_USERSPACE) /mnt/vdi/boot +# sync ############ virtual machines stuff ############ # vdi image for VirtualBox -$(FOOLOS_VDI): disk.img - -rm FoolOS.vdi - #VBoxManage convertfromraw $< $@ --uuid 2f11ca11-c35d-4240-b77e-79e37d32616c - VBoxManage convertfromraw disk.img $@ --uuid 2f11ca11-c35d-4240-b77e-79e37d32616c +#$(FOOLOS_VDI): disk.img +# -rm FoolOS.vdi +# #VBoxManage convertfromraw $< $@ --uuid 2f11ca11-c35d-4240-b77e-79e37d32616c +# VBoxManage convertfromraw disk.img $@ --uuid 2f11ca11-c35d-4240-b77e-79e37d32616c # run in our local bochs (we need cirrus support for our vesa mode) -run-bochs: all - ~/opt/bochs-2.6.8/bin/bochs -q -f bochs/bochsrc -rc bochs/bochsdebug +#run-bochs: all +# ~/opt/bochs-2.6.8/bin/bochs -q -f bochs/bochsrc -rc bochs/bochsdebug # run in qemu run-qemu: all - qemu-system-i386 -enable-kvm disk.img -smp 4 -s + #qemu-system-i386 -enable-kvm disk.img -smp 4 -s #qemu-system-i386 -enable-kvm -s -kernel foolos.img -smp 4 -initrd userspace/ext2.img + qemu-system-i386 -enable-kvm $(FOOLOS_ISO) -smp 4 run-qemu-debug: all # qemu -enable-kvm -s -S ~/temp/FoolOs/disk.img # qemu -enable-kvm -s -singlestep disk.img - qemu-system-i386 -enable-kvm -s -S -kernel foolos.img -smp 4 -initrd userspace/ext2.img +# qemu-system-i386 -enable-kvm -s -S -kernel foolos.img -smp 4 -initrd userspace/ext2.img + qemu-system-i386 -s -S $(FOOLOS_ISO) -smp 4 #-enable-kvm -smp 1 -stop: +stop-qemu: killall qemu-system-i386 ############ create bootable usb image ############ -stick: $(FOOLOS) - cat $< > $(USB_STICK) && sync - xxd $(USB_STICK) | head -n 50 +#stick: $(FOOLOS) +# cat $< > $(USB_STICK) && sync +# xxd $(USB_STICK) | head -n 50 ############ cleanup ############ clean: $(CLEANDIRS) - -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 tags mp/mp.bin + -rm *.bin $(FOOLOS) $(FOOLOS_ISO) $(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 tags mp/mp.bin grubiso/boot/foolos.bin grubiso/boot/ext2.img tags: ctags --recurse=yes . ############ mounting ############# -mount: disk.img - echo "* mounting disk image" - sudo losetup /dev/loop1 $< -o 1048576 - sudo mount /dev/loop1 /mnt/vdi +#mount: disk.img +# echo "* mounting disk image" +# sudo losetup /dev/loop1 $< -o 1048576 +# sudo mount /dev/loop1 /mnt/vdi -umount: - echo "* unmounting disk image" - sudo umount /mnt/vdi - sudo losetup -d /dev/loop1 +#umount: +# echo "* unmounting disk image" +# sudo umount /mnt/vdi +# sudo losetup -d /dev/loop1 +##### ISO ##### +$(FOOLOS_ISO): $(KERNEL_IMG) userspace + cp $(KERNEL_IMG) grubiso/boot/foolos.bin + cp $(IMG_USERSPACE) grubiso/boot + grub-mkrescue -o $(FOOLOS_ISO) grubiso/ -- cgit v1.2.3