From 47f1d3f8ab6b1afa0820c4e140d6f7268fa611c3 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Thu, 4 Nov 2021 20:26:31 +0100 Subject: [PATCH] Makefile: some simplification --- Makefile | 11 +++++------ userspace/Makefile | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 userspace/Makefile diff --git a/Makefile b/Makefile index e547e82..1c1b873 100644 --- a/Makefile +++ b/Makefile @@ -2,11 +2,11 @@ CPPFLAGS = -MMD AS=nasm ASFLAGS += -f elf32 -#LDFLAGS += -m32 -nostdlib -mkernel -fno-stack-protector -LDFLAGS += -m32 -nostdlib -static -fno-common -fno-use-cxa-atexit -fno-exceptions -fno-non-call-exceptions -fno-weak -fno-rtti -fno-stack-protector +LDFLAGS += -m elf_i386 CFLAGS += -m32 -Wall -Wextra -Werror -ffreestanding -fno-exceptions -fno-pie -fno-stack-protector -fno-tree-vectorize CXXFLAGS += -m32 -Wall -Wextra -Werror -ffreestanding -fno-exceptions -fno-rtti -fno-pie DEBUG_FLAGS += -g -Og -DDEBUG -fno-omit-frame-pointer -fno-inline +LIBGCC = $(shell $(CC) -print-libgcc-file-name $(CFLAGS)) QEMU_OPT += -hda disk.img ARCH?=x86 @@ -24,7 +24,7 @@ cobj=$(csrc:%.c=%.o) deps=$(csrc:%.c=%.d) $(gasmsrc:%.S=%.d) kernel kernel.sym &: $(asmobj) $(gasmobj) $(cobj) linker.ld - $(CC) -m32 -ffreestanding -nostdlib $(cobj) $(gasmobj) $(asmobj) -o kernel -T linker.ld -lgcc + $(LD) $(LDFLAGS) $(asmobj) $(gasmobj) $(cobj) -o kernel -T linker.ld $(LIBGCC) objcopy --only-keep-debug kernel kernel.sym objcopy --strip-debug kernel @@ -38,9 +38,11 @@ disk.img: disk.sfdisk qemu-img create -f raw $@ 32M sfdisk $@ < disk.sfdisk +# NASM without preprocessing %.o:%.asm $(AS) $(ASFLAGS) -o $@ $< +#GNU GAS ASM with C Preprocessing %.o: %.S $(CC) $(CFLAGS) $(CPPFLAGS) -c "$<" -o "$@" @@ -55,9 +57,6 @@ run:kernel disk.img debug: CFLAGS += $(DEBUG_FLAGS) -DRUN_TEST debug: CXXFLAGS += $(DEBUG_FLAGS) debug:kernel kernel.sym - #qemu-system-x86_64 -s -S -kernel kernel& - #qemu-system-i386 -s -S -kernel kernel& - #gdb -s kernel.sym -ex "target remote localhost:1234" -ex "dir core:driver:arch/$(ARCH))'" gdb -q -x debug.gdb debug_test: CFLAGS += $(DEBUG_FLAGS) -DRUN_TEST diff --git a/userspace/Makefile b/userspace/Makefile new file mode 100644 index 0000000..6bfff79 --- /dev/null +++ b/userspace/Makefile @@ -0,0 +1,2 @@ +# Used to generated .d file that deal with header dependencies +CPPFLAGS = -MMD