diff options
author | aqua <aqua@iserlohn-fortress.net> | 2022-10-29 14:57:25 +0300 |
---|---|---|
committer | aqua <aqua@iserlohn-fortress.net> | 2022-10-29 15:06:41 +0300 |
commit | 0fc5be1c91be5a2da53bfba58ebe690993448640 (patch) | |
tree | 4f793516fc086e659bfdbc47bfc73610cefc4424 | |
parent | makefile: add devices/devs.a target (diff) | |
download | kernel-0fc5be1c91be5a2da53bfba58ebe690993448640.tar.xz |
makefile: add src/kernel.a target
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | Makefile | 24 | ||||
-rw-r--r-- | i686/toolchain.mk | 6 | ||||
-rw-r--r-- | lib/Makefile | 3 | ||||
-rw-r--r-- | rules.mk | 2 | ||||
-rw-r--r-- | src/Makefile | 19 | ||||
-rw-r--r-- | src/conf.h.in | 4 |
7 files changed, 59 insertions, 5 deletions
@@ -1,2 +1,8 @@ lib/musl* build* +*.o +*.a +*.elf +*.iso +isodir +src/conf.h @@ -13,7 +13,7 @@ info: @echo " LD ${LD} ${LDFLAGS}" @${LD} --version | head -n1 -all: lib/libk.a ${ARCH}/arch.a devices/devs.a +all: lib/libk.a ${ARCH}/arch.a devices/devs.a src/kernel.a lib/libk.a: ${MAKE} ARCH=${ARCH} -C lib libk.a @@ -21,9 +21,31 @@ i686/arch.a: ${MAKE} ARCH=${ARCH} -C i686 arch.a devices/devs.a: ${MAKE} ARCH=${ARCH} -C devices devs.a +src/kernel.a: + ${MAKE} ARCH=${ARCH} -C src kernel.a + +glitch.elf: ${ARCH}/arch.a devices/devs.a lib/libk.a src/kernel.a + ${LD} ${LDFLAGS} -T ${ARCH}/linker.ld -o $@\ + $(wildcard i686/*.o) \ + src/kernel.a \ + -Llib -lk devices/devs.a + +glitch.iso: glitch.elf grub/grub.cfg + mkdir -p isodir/boot/grub + mkdir -p isodir/boot/glitch + cp grub/grub.cfg isodir/boot/grub/grub.cfg + cp glitch.elf isodir/boot/glitch/glitch.elf + grub-mkrescue -o glitch.iso isodir + +run: glitch.iso + qemu-system-i386 -cdrom glitch.iso -accel kvm clean: ${MAKE} ARCH=${ARCH} -C lib clean ${MAKE} ARCH=${ARCH} -C ${ARCH} clean ${MAKE} ARCH=${ARCH} -C devices clean + ${MAKE} ARCH=${ARCH} -C src clean +purge: clean + rm -f lib/libk.a ${ARCH}/arch.a devices/devs.a src/kernel.a + rm -rf isodir diff --git a/i686/toolchain.mk b/i686/toolchain.mk index c41c784..5842584 100644 --- a/i686/toolchain.mk +++ b/i686/toolchain.mk @@ -2,11 +2,11 @@ # AS = i686-elf-as CC = i686-elf-gcc -CCFLAGS = -Wall -Wextra -Wpedantic -fanalyzer -ffreestanding +CCFLAGS = -Wall -Wextra -Wpedantic -fanalyzer -ffreestanding -std=gnu11 -mgeneral-regs-only LD = i686-elf-ld -LDFLAGS = -nostdlib +LDFLAGS = -static -nostdlib AR = i686-elf-ar -ARFLAGS = r +ARFLAGS = -ruv STRIP = i686-elf-strip diff --git a/lib/Makefile b/lib/Makefile index 3a5fff9..22c090c 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -3,11 +3,14 @@ include ../rules.mk CCFLAGS += -I. -I.. +all: libk.a + libk,SRCS = memcpy.c memset.c stdio/printf.c string/itoa.c libk,OBJS = $(libk,SRCS:%.c=%.o) libk.a: ${libk,OBJS} @echo ' AR $@' @${AR} ${ARFLAGS} $@ $^ + i686-elf-ranlib $@ clean: @rm -rf ${libk,OBJS} @@ -1,7 +1,7 @@ .SUFFIXES: .s .S .c .o .s.o: @echo ' CC $^' - @$(AS) $(ASFLAGS) -c -o $@ $^ + @$(CC) $(CCFLAGS) -c -o $@ $^ .S.o: @echo ' CC $^' diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..4c47e20 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,19 @@ +include ../${ARCH}/toolchain.mk +include ../rules.mk + +CCFLAGS += -I. -I../grub/include -I../${ARCH} -I../lib -I.. + +all: kernel.a + +kernel,SRCS = multiboot2.c mmap.c kernel.c isr.c mem/vmm.c +kernel,OBJS = $(kernel,SRCS:%.c=%.o) +kernel.a: conf.h ${kernel,OBJS} + @echo ' AR $@' + @${AR} ${ARFLAGS} $@ ${kernel,OBJS} + +conf.h: conf.h.in + cp conf.h.in conf.h + +clean: + @rm -rf ${kernel,OBJS} + diff --git a/src/conf.h.in b/src/conf.h.in new file mode 100644 index 0000000..9ae9bac --- /dev/null +++ b/src/conf.h.in @@ -0,0 +1,4 @@ +#pragma once + +#define VERSION "0.0.0" +#define CC "gcc xyz" |