Makefile (1467B)
1 EFI_CC = x86_64-w64-mingw32-gcc 2 EFI_CFLAGS = -nostdlib -fpic -mno-red-zone -fno-stack-protector -static \ 3 -fno-builtin -g -mabi=sysv \ 4 -mno-stack-arg-probe -Wall -e EfiMain 5 KERN_CC = tcc 6 KERN_LD = ld 7 KERN_CFLAGS = -nostdlib -fpic -mno-red-zone -ffreestanding -Wall -g 8 KERN_LDFLAGS = -e kernel_main -static 9 OBJCOPY = objcopy 10 11 all: disk.img 12 13 disk.img: uefi/uefi.efi kernel/setos.elf 14 qemu-img create -f raw disk.img 200M 15 mkfs.fat -n 'SETOS' -s 2 -f 2 -R 32 -F 32 disk.img 16 mkdir -p image 17 doas mount disk.img image 18 doas mkdir -p image/EFI/BOOT 19 doas cp uefi/uefi.efi image/EFI/BOOT/BOOTX64.EFI 20 doas cp kernel/setos.elf image/setos.elf 21 doas umount image 22 23 uefi/uefi.dll: uefi/uefi.c uefi/uefi.h uefi/utils.c uefi/utils.h 24 $(EFI_CC) $(EFI_CFLAGS) -o $@ uefi/uefi.c uefi/utils.c 25 26 uefi/uefi.efi: uefi/uefi.dll 27 $(OBJCOPY) --target=efi-app-x86_64 $< $@ 28 29 %.o: %.c 30 $(KERN_CC) $(KERN_CFLAGS) -c -o $@ $< 31 32 kernel/setos.elf: kernel/main.o kernel/memmap.ld 33 $(KERN_LD) $(KERN_LDFLAGS) -T kernel/memmap.ld -o $@ $< 34 35 run: disk.img OVMF.fd 36 qemu-system-x86_64 \ 37 -bios OVMF.fd \ 38 -drive format=raw,file=disk.img \ 39 40 gdb: disk.img OVMF.fd 41 qemu-system-x86_64 \ 42 -bios OVMF.fd \ 43 -drive format=raw,file=disk.img \ 44 -gdb tcp::1234 -S 45 46 #OVMF.fd: 47 # curl -OL https://downloads.sourceforge.net/project/edk2/OVMF/OVMF-X64-r15214.zip 48 # unzip OVMF-X64-r15214.zip OVMF.fd 49 50 clean: 51 rm -rf *.o *.efi *.elf *.dll disk.img image 52 rm -r uefi/*.efi uefi/*.dll 53 rm -r kernel/*.o kernel/*.elf