mirror of
https://github.com/tailix/libkernaux.git
synced 2025-01-27 15:23:57 -05:00
Automate kernel examples
This commit is contained in:
parent
19677e617a
commit
0f3747e5b6
15 changed files with 64 additions and 6 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -34,6 +34,9 @@
|
|||
/tests/test*.log
|
||||
/tests/test*.trs
|
||||
|
||||
/build/*
|
||||
!/build/.keep
|
||||
|
||||
/examples/assert_guards
|
||||
/examples/assert_simple
|
||||
/examples/cmdline
|
||||
|
|
0
build/.keep
Normal file
0
build/.keep
Normal file
|
@ -4,4 +4,6 @@ set -e
|
|||
|
||||
REPO="$(realpath "$(dirname "$(realpath "$0")")/..")"
|
||||
|
||||
if [ -f "$REPO/Makefile" ]; then make -C "$REPO" distclean; fi
|
||||
|
||||
"$REPO/configure" --enable-assert --enable-guard
|
||||
|
|
|
@ -8,6 +8,8 @@ REPO="$(realpath "$(dirname "$(realpath "$0")")/..")"
|
|||
PREFIX="$REPO/vendor/cross"
|
||||
BIN="$PREFIX/bin"
|
||||
|
||||
if [ -f "$REPO/Makefile" ]; then make -C "$REPO" distclean; fi
|
||||
|
||||
export AR="$BIN/$HOST-ar"
|
||||
export CC="$BIN/$HOST-gcc"
|
||||
export RANLIB="$BIN/$HOST-ranlib"
|
||||
|
|
|
@ -8,6 +8,8 @@ REPO="$(realpath "$(dirname "$(realpath "$0")")/..")"
|
|||
PREFIX="$REPO/vendor/cross"
|
||||
BIN="$PREFIX/bin"
|
||||
|
||||
if [ -f "$REPO/Makefile" ]; then make -C "$REPO" distclean; fi
|
||||
|
||||
export AR="$BIN/$HOST-ar"
|
||||
export CC="$BIN/$HOST-gcc"
|
||||
export RANLIB="$BIN/$HOST-ranlib"
|
||||
|
|
19
config/x86_64-stivale2
Executable file
19
config/x86_64-stivale2
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
ARCH='x86_64'
|
||||
HOST="$ARCH-elf"
|
||||
REPO="$(realpath "$(dirname "$(realpath "$0")")/..")"
|
||||
PREFIX="$REPO/vendor/cross"
|
||||
BIN="$PREFIX/bin"
|
||||
|
||||
if [ -f "$REPO/Makefile" ]; then make -C "$REPO" distclean; fi
|
||||
|
||||
export AR="$BIN/$HOST-ar"
|
||||
export CC="$BIN/$HOST-gcc"
|
||||
export RANLIB="$BIN/$HOST-ranlib"
|
||||
|
||||
export CFLAGS='-ffreestanding -nostdlib -fno-builtin -fno-stack-protector'
|
||||
|
||||
"$REPO/configure" --host="$HOST" --enable-assert --enable-guard --with-libc
|
|
@ -1,3 +1,6 @@
|
|||
/build-libkernaux/*
|
||||
!/build-libkernaux/.keep
|
||||
|
||||
/image.iso
|
||||
/output.txt
|
||||
/rootfs/boot/kernel
|
||||
|
|
|
@ -5,11 +5,13 @@ CCPREFIX = ../../vendor/cross/bin/i386-elf-
|
|||
AS = $(CCPREFIX)as
|
||||
CC = $(CCPREFIX)gcc
|
||||
|
||||
CONFIG_LIBKERNAUX = ../../config/i386
|
||||
DIFF = diff
|
||||
GRUB_FILE = grub-file
|
||||
GRUB_MKRESCUE = grub-mkrescue
|
||||
QEMU = qemu-system-i386
|
||||
|
||||
BUILD_LIBKERNAUX = build-libkernaux
|
||||
EXPECTED = expected.txt
|
||||
IMAGE = image.iso
|
||||
LINKERSCR = linker.ld
|
||||
|
@ -39,15 +41,20 @@ run: $(IMAGE)
|
|||
$(QEMU) -cdrom $< -serial stdio -display none | tee $(OUTPUT)
|
||||
|
||||
clean:
|
||||
make -C $(BUILD_LIBKERNAUX) distclean || true
|
||||
rm -f $(OUTPUT) $(IMAGE) $(KERNEL) $(OBJS)
|
||||
|
||||
$(IMAGE): $(GRUBCFG) $(KERNEL)
|
||||
$(GRUB_MKRESCUE) $(ROOTFS) -o $@
|
||||
|
||||
$(KERNEL): $(LINKERSCR) $(OBJS)
|
||||
$(CC) -T $(LINKERSCR) -o $@ $(OBJS) -ffreestanding -nostdlib -lgcc -lkernaux -Wl,-L../..
|
||||
$(KERNEL): $(LINKERSCR) $(OBJS) build-libkernaux.a
|
||||
$(CC) -T $(LINKERSCR) -o $@ $(OBJS) -ffreestanding -nostdlib -lgcc -lkernaux -Wl,-L$(BUILD_LIBKERNAUX)
|
||||
$(GRUB_FILE) --is-x86-multiboot2 $@
|
||||
|
||||
build-libkernaux.a:
|
||||
cd $(BUILD_LIBKERNAUX) && ../$(CONFIG_LIBKERNAUX)
|
||||
cd $(BUILD_LIBKERNAUX) && make libkernaux.a
|
||||
|
||||
%.c.o: %.c
|
||||
$(CC) -c $< -o $@ $(CFLAGS)
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/build-libkernaux/*
|
||||
!/build-libkernaux/.keep
|
||||
|
||||
/image.iso
|
||||
/output.txt
|
||||
/rootfs/boot/kernel
|
||||
|
|
|
@ -5,12 +5,14 @@ CCPREFIX = ../../vendor/cross/bin/i386-elf-
|
|||
AS = $(CCPREFIX)as
|
||||
CC = $(CCPREFIX)gcc
|
||||
|
||||
CONFIG_LIBKERNAUX = ../../config/i386
|
||||
DIFF = diff
|
||||
GRUB_FILE = grub-file
|
||||
LIMINE = ../../vendor/limine/build/bin
|
||||
QEMU = qemu-system-x86_64
|
||||
XORRISO = xorriso
|
||||
|
||||
BUILD_LIBKERNAUX = build-libkernaux
|
||||
EXPECTED = expected.txt
|
||||
IMAGE = image.iso
|
||||
LINKERSCR = linker.ld
|
||||
|
@ -54,14 +56,15 @@ run: $(IMAGE)
|
|||
$(QEMU) -cdrom $< -serial stdio -display none | tee $(OUTPUT)
|
||||
|
||||
clean:
|
||||
make -C $(BUILD_LIBKERNAUX) distclean || true
|
||||
rm -f $(OUTPUT) $(IMAGE) $(FULL_KERNEL) $(FULL_LIMINE_CD) $(FULL_LIMINE_ELTORITO) $(FULL_LIMINE_SYS) $(OBJS)
|
||||
|
||||
$(IMAGE): $(FULL_KERNEL) $(FULL_LIMINE_CD) $(FULL_LIMINE_ELTORITO) $(FULL_LIMINE_SYS)
|
||||
$(XORRISO) -as mkisofs -b $(REL_LIMINE_CD) -no-emul-boot -boot-load-size 4 -boot-info-table --efi-boot $(REL_LIMINE_ELTORITO) -efi-boot-part --efi-boot-image --protective-msdos-label $(ROOTFS) -o $@
|
||||
$(LIMINE_INSTALL) $@
|
||||
|
||||
$(FULL_KERNEL): $(LINKERSCR) $(OBJS)
|
||||
$(CC) -T $(LINKERSCR) -o $@ $(OBJS) -ffreestanding -nostdlib -lgcc -lkernaux -Wl,-L../..
|
||||
$(FULL_KERNEL): $(LINKERSCR) $(OBJS) build-libkernaux.a
|
||||
$(CC) -T $(LINKERSCR) -o $@ $(OBJS) -ffreestanding -nostdlib -lgcc -lkernaux -Wl,-L$(BUILD_LIBKERNAUX)
|
||||
$(GRUB_FILE) --is-x86-multiboot2 $@
|
||||
|
||||
$(FULL_LIMINE_CD):
|
||||
|
@ -73,6 +76,10 @@ $(FULL_LIMINE_ELTORITO):
|
|||
$(FULL_LIMINE_SYS):
|
||||
cp -f $(LIMINE_SYS) $(FULL_LIMINE_SYS)
|
||||
|
||||
build-libkernaux.a:
|
||||
cd $(BUILD_LIBKERNAUX) && ../$(CONFIG_LIBKERNAUX)
|
||||
cd $(BUILD_LIBKERNAUX) && make libkernaux.a
|
||||
|
||||
%.c.o: %.c
|
||||
$(CC) -c $< -o $@ $(CFLAGS)
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/build-libkernaux/*
|
||||
!/build-libkernaux/.keep
|
||||
|
||||
/image.iso
|
||||
/main.c.d
|
||||
/output.txt
|
||||
|
|
|
@ -5,11 +5,13 @@ CCPREFIX = ../../vendor/cross/bin/x86_64-elf-
|
|||
AS = $(CCPREFIX)as
|
||||
CC = $(CCPREFIX)gcc
|
||||
|
||||
CONFIG_LIBKERNAUX = ../../config/x86_64-stivale2
|
||||
DIFF = diff
|
||||
LIMINE = ../../vendor/limine/build/bin
|
||||
QEMU = qemu-system-x86_64
|
||||
XORRISO = xorriso
|
||||
|
||||
BUILD_LIBKERNAUX = build-libkernaux
|
||||
EXPECTED = expected.txt
|
||||
IMAGE = image.iso
|
||||
LINKERSCR = linker.ld
|
||||
|
@ -63,14 +65,15 @@ run: $(IMAGE)
|
|||
$(QEMU) -cdrom $< -serial stdio -display none | tee $(OUTPUT)
|
||||
|
||||
clean:
|
||||
make -C $(BUILD_LIBKERNAUX) distclean || true
|
||||
rm -f $(OUTPUT) $(IMAGE) $(FULL_KERNEL) $(FULL_LIMINE_CD) $(FULL_LIMINE_ELTORITO) $(FULL_LIMINE_SYS) $(OBJS)
|
||||
|
||||
$(IMAGE): $(FULL_KERNEL) $(FULL_LIMINE_CD) $(FULL_LIMINE_ELTORITO) $(FULL_LIMINE_SYS)
|
||||
$(XORRISO) -as mkisofs -b $(REL_LIMINE_CD) -no-emul-boot -boot-load-size 4 -boot-info-table --efi-boot $(REL_LIMINE_ELTORITO) -efi-boot-part --efi-boot-image --protective-msdos-label $(ROOTFS) -o $@
|
||||
$(LIMINE_INSTALL) $@
|
||||
|
||||
$(FULL_KERNEL): $(LINKERSCR) $(OBJS)
|
||||
$(CC) -T $(LINKERSCR) -o $@ $(OBJS) -ffreestanding -nostdlib -zmax-page-size=0x1000 -static -lgcc # -lkernaux -Wl,-L../..
|
||||
$(FULL_KERNEL): $(LINKERSCR) $(OBJS) build-libkernaux.a
|
||||
$(CC) -T $(LINKERSCR) -o $@ $(OBJS) -ffreestanding -nostdlib -zmax-page-size=0x1000 -static -lgcc -lkernaux -Wl,-L$(BUILD_LIBKERNAUX)
|
||||
|
||||
$(FULL_LIMINE_CD):
|
||||
cp -f $(LIMINE_CD) $(FULL_LIMINE_CD)
|
||||
|
@ -81,6 +84,10 @@ $(FULL_LIMINE_ELTORITO):
|
|||
$(FULL_LIMINE_SYS):
|
||||
cp -f $(LIMINE_SYS) $(FULL_LIMINE_SYS)
|
||||
|
||||
build-libkernaux.a:
|
||||
cd $(BUILD_LIBKERNAUX) && ../$(CONFIG_LIBKERNAUX)
|
||||
cd $(BUILD_LIBKERNAUX) && make libkernaux.a
|
||||
|
||||
%.c.o: %.c
|
||||
$(CC) -c $< -o $@ $(CFLAGS)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue