2017-09-28 04:30:19 +02:00
|
|
|
build/bootloader: bootloader/$(ARCH)/**
|
2017-09-28 10:47:41 +02:00
|
|
|
mkdir -p build
|
2017-09-28 04:24:45 +02:00
|
|
|
nasm -f bin -o $@ -D ARCH_$(ARCH) -ibootloader/$(ARCH)/ bootloader/$(ARCH)/disk.asm
|
|
|
|
|
|
|
|
build/harddrive.bin: build/filesystem.bin bootloader/$(ARCH)/**
|
2020-01-08 08:16:17 +01:00
|
|
|
nasm -f bin -o build/bootsector.bin -D ARCH_$(ARCH) -ibootloader/$(ARCH)/ bootloader/$(ARCH)/disk.asm
|
2020-01-20 17:29:37 +01:00
|
|
|
dd if=/dev/zero of=$@.partial bs=1M count=$$(expr $$(du -m $< | cut -f1) + 2)
|
2021-01-21 23:49:22 +01:00
|
|
|
$(PARTED) -s -a minimal $@.partial mklabel msdos
|
|
|
|
$(PARTED) -s -a minimal $@.partial mkpart primary 2048s $$(expr $$(du -m $< | cut -f1) \* 2048 + 2048)s
|
2020-01-08 08:16:17 +01:00
|
|
|
dd if=build/bootsector.bin of=$@.partial bs=1 count=446 conv=notrunc
|
|
|
|
dd if=build/bootsector.bin of=$@.partial bs=512 skip=1 seek=1 conv=notrunc
|
|
|
|
dd if=$< of=$@.partial bs=1M seek=1 conv=notrunc
|
|
|
|
mv $@.partial $@
|
|
|
|
|
2017-05-11 05:39:05 +02:00
|
|
|
build/livedisk.bin: build/kernel_live bootloader/$(ARCH)/**
|
2017-05-12 05:19:31 +02:00
|
|
|
nasm -f bin -o $@ -D ARCH_$(ARCH) -D KERNEL=$< -ibootloader/$(ARCH)/ bootloader/$(ARCH)/disk.asm
|
2017-01-05 22:07:20 +01:00
|
|
|
|
|
|
|
build/livedisk.iso: build/livedisk.bin.gz
|
|
|
|
rm -rf build/iso/
|
|
|
|
mkdir -p build/iso/
|
|
|
|
cp -RL isolinux build/iso/
|
|
|
|
cp $< build/iso/livedisk.gz
|
|
|
|
genisoimage -o $@ -b isolinux/isolinux.bin -c isolinux/boot.cat \
|
|
|
|
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
|
|
|
build/iso/
|
|
|
|
isohybrid $@
|
2018-04-13 05:24:07 +02:00
|
|
|
|
2019-02-25 20:10:16 +01:00
|
|
|
bootloader-coreboot/build/bootloader: build/kernel_coreboot
|
2019-09-08 04:00:50 +02:00
|
|
|
env --unset=RUST_TARGET_PATH --unset=RUSTUP_TOOLCHAIN --unset=XARGO_RUST_SRC \
|
2019-02-25 20:10:16 +01:00
|
|
|
$(MAKE) -C bootloader-coreboot clean build/bootloader KERNEL="$(ROOT)/$<"
|
|
|
|
|
|
|
|
build/coreboot.elf: bootloader-coreboot/build/bootloader
|
2019-03-17 20:56:10 +01:00
|
|
|
mkdir -p build
|
2019-03-16 21:55:11 +01:00
|
|
|
cp -v $< $@
|
|
|
|
|
|
|
|
bootloader-efi/build/$(EFI_TARGET)/boot.efi: FORCE
|
2019-09-08 04:00:50 +02:00
|
|
|
env --unset=RUST_TARGET_PATH --unset=RUSTUP_TOOLCHAIN --unset=XARGO_RUST_SRC \
|
|
|
|
$(MAKE) -C bootloader-efi build/$(EFI_TARGET)/boot.efi TARGET=$(EFI_TARGET)
|
2019-02-25 20:10:16 +01:00
|
|
|
|
2019-03-16 21:55:11 +01:00
|
|
|
build/bootloader.efi: bootloader-efi/build/$(EFI_TARGET)/boot.efi
|
2019-03-17 20:56:10 +01:00
|
|
|
mkdir -p build
|
2019-03-16 21:55:11 +01:00
|
|
|
cp -v $< $@
|
2018-04-13 05:24:07 +02:00
|
|
|
|
2020-01-06 08:33:22 +01:00
|
|
|
build/harddrive-efi.bin: build/bootloader.efi build/filesystem.bin
|
2020-01-22 03:50:15 +01:00
|
|
|
# TODO: Validate the correctness of this \
|
|
|
|
# Populate an EFI system partition \
|
|
|
|
dd if=/dev/zero of=$@.esp bs=1048576 count=$$(expr $$(du -m $< | cut -f1) + 1) && \
|
|
|
|
mkfs.vfat $@.esp && \
|
|
|
|
mmd -i $@.esp efi && \
|
|
|
|
mmd -i $@.esp efi/boot && \
|
|
|
|
mcopy -i $@.esp $< ::efi/boot/bootx64.efi && \
|
|
|
|
# Create the disk \
|
|
|
|
dd if=/dev/zero of=$@ bs=1048576 count=$$(expr $$(du -m $< | cut -f1) + 2 + $$(du -m build/filesystem.bin | cut -f1)) && \
|
|
|
|
# Create partition table \
|
2021-01-21 23:49:22 +01:00
|
|
|
$(PARTED) -s -a minimal $@ mklabel gpt && \
|
2020-01-22 03:50:15 +01:00
|
|
|
efi_disk_size=$$(du -m $< | cut -f1) && \
|
|
|
|
efi_disk_blkcount=$$(expr $$efi_disk_size \* $$(expr 1048576 / 512)) && \
|
|
|
|
efi_end=$$(expr 2048 + $$efi_disk_blkcount) && \
|
|
|
|
efi_last=$$(expr $$efi_end - 1) && \
|
2021-01-21 23:49:22 +01:00
|
|
|
$(PARTED) -s -a minimal $@ mkpart EFI fat32 2048s "$${efi_last}s" && \
|
2020-01-22 03:52:22 +01:00
|
|
|
fs_disk_size=$$(du -m build/filesystem.bin | cut -f1) && \
|
|
|
|
fs_disk_blkcount=$$(expr $$fs_disk_size \* $$(expr 1048576 / 512)) && \
|
2021-01-21 23:49:22 +01:00
|
|
|
$(PARTED) -s -a minimal $@ mkpart redox ext4 "$${efi_end}s" $$(expr $$efi_end + $$fs_disk_blkcount)s && \
|
|
|
|
$(PARTED) -s -a minimal $@ set 1 boot on && \
|
|
|
|
$(PARTED) -s -a minimal $@ set 1 esp on && \
|
2020-01-22 03:50:15 +01:00
|
|
|
# Write the partitions \
|
|
|
|
dd if=$@.esp bs=512 seek=2048 conv=notrunc count=$$efi_disk_blkcount of=$@ && \
|
2020-01-06 08:33:22 +01:00
|
|
|
dd if=build/filesystem.bin seek=$$efi_end bs=512 conv=notrunc of=$@ count=$$fs_disk_blkcount
|
|
|
|
|
2019-03-16 21:55:11 +01:00
|
|
|
build/livedisk-efi.iso: build/bootloader.efi build/kernel_live
|
2019-10-05 18:04:42 +02:00
|
|
|
dd if=/dev/zero of=$@.partial bs=1048576 count=$$(expr $$(du -mc $^ | grep 'total$$' | cut -f1) + 1)
|
2018-04-13 05:24:07 +02:00
|
|
|
mkfs.vfat $@.partial
|
|
|
|
mmd -i $@.partial efi
|
|
|
|
mmd -i $@.partial efi/boot
|
|
|
|
mcopy -i $@.partial $< ::efi/boot/bootx64.efi
|
|
|
|
mmd -i $@.partial redox_bootloader
|
|
|
|
mcopy -i $@.partial -s build/kernel_live ::redox_bootloader/kernel
|
|
|
|
mv $@.partial $@
|