From ad4f01f31e764072b4522e778a1becfb1b8f8fa0 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 25 Aug 2018 14:25:33 +0200 Subject: fixed linking flags for 64bit host, added QEMU makefile variable --- src/Makefile | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/Makefile') diff --git a/src/Makefile b/src/Makefile index 96acb38..b57a1b5 100644 --- a/src/Makefile +++ b/src/Makefile @@ -4,12 +4,13 @@ OPT := -O0 INCLUDES = -I. -Ilibc -Ihardware -Idrivers -Idrivers/hdi -Idrivers/hdi/ps2 -Idrivers/video -Inet -Idrivers/net -Ikernel -Igui CFLAGS := -std=c99 -m32 -march=i486 -ffreestanding $(OPT) -g -Werror $(INCLUDES) $(DEFINES) LD := ld -LDFLAGS := -lgcc +LDFLAGS := -m elf_i386 NASMFLAGS := -f elf32 NASM := nasm OBJCOPY := objcopy MAGIC := $(shell printf '%x' `date +%s`) TRUNCATE := truncate +QEMU := qemu-system-i386 all: image.bin kernel.sym @@ -26,7 +27,7 @@ image.bin: boot.bin kernel.bin magic.bin cat boot.bin kernel.bin > image.tmp $(TRUNCATE) -s 89088 image.tmp cat image.tmp magic.bin > image.bin - $(TRUNATE) -s 1474560 image.bin + $(TRUNCATE) -s 1474560 image.bin boot.bin: boot/boot.asm boot/boot_gdt.asm boot/stage1_functions.asm boot/stage2_real_functions.asm boot/stage2_pm_functions.asm boot/stage2_switch_mode.asm boot/stage2_a20.asm $(NASM) boot/boot.asm -DMAGIC='"$(MAGIC)"' -f bin -o boot.bin @@ -38,7 +39,7 @@ kernel.sym: kernel.elf $(OBJCOPY) --only-keep-debug kernel.elf kernel.sym kernel.elf: kernel/entry.o kernel/kernel.o kernel/kernel_asm.o kernel/console.o kernel/vgatext.o kernel/serial.o kernel/memorymanagement.o kernel/tasks.o hardware/port.o hardware/port_asm.o hardware/interrupts.o hardware/interrupts_asm.o hardware/pci.o drivers/driver.o drivers/hdi/mouse.o drivers/hdi/keyboard.o drivers/hdi/ps2/ps2keyboard.o drivers/hdi/ps2/ps2mouse.o drivers/video/video.o drivers/video/vga.o drivers/video/vga_font.o net/ethernet.o net/arp.o net/ipv4.o drivers/net/network.o drivers/net/rtl8139.o gui/widget.o gui/composite_widget.o gui/window.o gui/desktop.o gui/text_widget.o libc/string.o libc/stdlib.o libc/stdio.o libc/setjmp.o - $(LD) -o kernel.elf -N -n -Ttext 0x8800 -e kernel_entry --oformat elf32-i386 \ + $(LD) $(LDFLAGS) -o kernel.elf -N -n -Ttext 0x8800 -e kernel_entry --oformat elf32-i386 \ kernel/entry.o \ kernel/kernel.o kernel/kernel_asm.o \ kernel/console.o kernel/vgatext.o kernel/serial.o \ @@ -170,15 +171,15 @@ clean: drivers/*.o drivers/*/*.o drivers/*/*/*.o gui/*.o run-qemu-hd: image.bin - qemu-system-i386 -cpu 486 -usb -netdev user,id=net0,net=10.0.0.0/24,host=10.0.0.2,dhcpstart=10.0.0.16 -device rtl8139,netdev=net0-d guest_errors -m 32 -drive "file=image.bin,if=ide,format=raw" \ + $(QEMU) -cpu 486 -usb -netdev user,id=net0,net=10.0.0.0/24,host=10.0.0.2,dhcpstart=10.0.0.16 -device rtl8139,netdev=net0-d guest_errors -m 32 -drive "file=image.bin,if=ide,format=raw" \ -serial file:serial.log run-qemu-usb: image.bin - qemu-system-i386 -cpu 486 -usb -netdev user,id=net0,net=10.0.0.0/24,host=10.0.0.2,dhcpstart=10.0.0.16 -device rtl8139,netdev=net0-d guest_errors -m 32 -usb -usbdevice disk:/dev/sde \ + $(QEMU) -cpu 486 -usb -netdev user,id=net0,net=10.0.0.0/24,host=10.0.0.2,dhcpstart=10.0.0.16 -device rtl8139,netdev=net0-d guest_errors -m 32 -usb -usbdevice disk:/dev/sde \ -serial file:serial.log run-qemu: image.bin - qemu-system-i386 -cpu 486 -usb \ + $(QEMU) -cpu 486 -usb \ -netdev user,id=net0,net=10.0.0.0/24,host=10.0.0.2,dhcpstart=10.0.0.16,hostfwd=tcp::8080-:80,hostfwd=udp::8081-:81 \ -device rtl8139,netdev=net0 \ -object filter-dump,id=net0,netdev=net0,file=network.log \ @@ -186,7 +187,7 @@ run-qemu: image.bin -serial file:serial.log run-qemu-debug: image.bin - qemu-system-i386 -cpu 486 -usb \ + $(QEMU) -cpu 486 -usb \ -netdev user,id=net0,net=10.0.0.0/24,host=10.0.0.2,dhcpstart=10.0.0.16,hostfwd=tcp::8080-:80,hostfwd=udp::8081-:81 \ -device rtl8139,netdev=net0 \ -object filter-dump,id=net0,netdev=net0,file=network.log \ -- cgit v1.2.3-54-g00ecf