-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
136 lines (106 loc) · 4.11 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
ISODIR=$(shell pwd)/iso
IMGDIR=$(shell pwd)/img
ISO=astral.iso
IMG=astral-bootable.img
DISKNAME=hdd.img
LIMINEDIR=$(shell pwd)/host-pkgs/limine/usr/local/share/limine/
KERNEL=$(shell pwd)/builds/astral/astral
QEMUFLAGS=-M q35 -m 4g -smp cpus=1 -no-shutdown -no-reboot -monitor stdio -debugcon file:/dev/stdout -serial file:/dev/stdout -netdev user,id=net0 -device virtio-net,netdev=net0 -object filter-dump,id=f1,netdev=net0,file=netdump.dat
QEMUISOFLAGS=-cdrom $(ISO)
QEMUDISKFLAGS=-drive file=$(DISKNAME),if=none,id=nvme -device nvme,serial=deadc0ff,drive=nvme -boot order=dc
QEMUIMGFLAGS=-drive file=$(IMG),if=none,id=usb -device nec-usb-xhci,id=xhci -device usb-storage,bus=xhci.0,drive=usb,removable=on
INITRD=$(shell pwd)/initrds/initrd
DISTROTYPE=full
MINIMALPACKAGES=mlibc bash coreutils init distro-files vim nano mount netd shadow sudo neofetch
.PHONY: all kernel clean clean-kernel iso img initrd full minimal disk
all: jinx
git submodule update --init --recursive
mkdir -p $(ISODIR)
make kernel
make $(ISO)
@echo
@echo "|--------------------------------------------------------------|"
@echo "| To regenerate the initrd, run 'make initrd iso'. |"
@echo "| To generate a bootable USB/HDD image, run 'make initrd img'. |"
@echo "| To generate a disk image, run 'make disk'. |"
@echo "|--------------------------------------------------------------|"
@echo
jinx:
curl https://raw.githubusercontent.com/mintsuki/jinx/f459adb138abff6afc7936f5fd4bc9e24023a495/jinx > jinx
chmod +x jinx
iso: $(ISO)
img: $(IMG)
$(ISO): limine.conf liminebg.bmp $(KERNEL) $(INITRD)-$(DISTROTYPE)
mkdir -p $(ISODIR)
ln -f $(INITRD)-$(DISTROTYPE) $(ISODIR)/initrd
cp $(KERNEL) liminebg.bmp limine.conf $(LIMINEDIR)/limine-bios.sys $(LIMINEDIR)/limine-bios-cd.bin $(LIMINEDIR)/limine-uefi-cd.bin $(ISODIR)
xorriso -as mkisofs -b limine-bios-cd.bin -no-emul-boot -boot-load-size 4 -boot-info-table --efi-boot limine-uefi-cd.bin -efi-boot-part --efi-boot-image --protective-msdos-label $(ISODIR) -o $(ISO)
$(IMG): limine.conf liminebg.bmp $(KERNEL) $(INITRD)-$(DISTROTYPE)
mkdir -p $(IMGDIR)/EFI/BOOT
ln -f $(INITRD)-$(DISTROTYPE) $(IMGDIR)/initrd
cp $(KERNEL) liminebg.bmp limine.conf $(LIMINEDIR)/limine-bios.sys $(IMGDIR)
cp $(LIMINEDIR)/BOOTIA32.EFI $(IMGDIR)/EFI/BOOT
cp $(LIMINEDIR)/BOOTX64.EFI $(IMGDIR)/EFI/BOOT
./genbootimg.sh 1G $(IMG) $(IMGDIR)
# ------ build targets ------
kernel:
rm -f builds/astral.packaged
rm -f builds/astral.built
./jinx build astral
# ------ initrd targets ------
$(INITRD)-full:
./jinx install sysroot \*
mkdir -p initrds
./geninitrd.sh sysroot $(INITRD)-full
$(INITRD)-minimal:
./jinx install minimalsysroot $(MINIMALPACKAGES)
mkdir -p initrds
./geninitrd.sh minimalsysroot $(INITRD)-minimal
initrd:
rm $(INITRD)-$(DISTROTYPE)
make $(INITRD)-$(DISTROTYPE)
# ------ disk targets ------
disk: disk-$(DISTROTYPE)
disk-full:
./jinx sysroot
./gendisk.sh 4g sysroot $(DISKNAME)
disk-minimal:
./jinx install minimalsysroot $(MINIMALPACKAGES)
./gendisk.sh 1g minimalsysroot $(DISKNAME)
# ------ clean targets ------
clean-kernel:
find builds/astral/ -name *.d -delete
find builds/astral/ -name *.o -delete
find builds/astral/ -name *.asmo -delete
clean:
make -i clean-kernel
rm jinx
rm -rf builds
rm -rf host-builds
rm -rf pkgs
rm -rf host-pkgs
rm -rf sources
rm -rf sysroot
rm -rf $(ISODIR)
rm -f $(ISO)
rm -f $(DISKNAME)
rm -rf initrds
# ------ run targets ------
run:
qemu-system-x86_64 $(QEMUFLAGS) $(QEMUISOFLAGS)
run-gdb:
qemu-system-x86_64 $(QEMUFLAGS) $(QEMUISOFLAGS) -S -s
run-kvm:
qemu-system-x86_64 $(QEMUFLAGS) $(QEMUISOFLAGS) -enable-kvm -cpu host,migratable=off
run-disk:
qemu-system-x86_64 $(QEMUFLAGS) $(QEMUISOFLAGS) $(QEMUDISKFLAGS)
run-disk-gdb:
qemu-system-x86_64 $(QEMUFLAGS) $(QEMUISOFLAGS) $(QEMUDISKFLAGS) -S -s
run-disk-kvm:
qemu-system-x86_64 $(QEMUFLAGS) $(QEMUISOFLAGS) $(QEMUDISKFLAGS) -enable-kvm -cpu host,migratable=off
run-img:
qemu-system-x86_64 $(QEMUFLAGS) $(QEMUIMGFLAGS)
run-img-gdb:
qemu-system-x86_64 $(QEMUFLAGS) $(QEMUIMGFLAGS) -S -s
run-img-kvm:
qemu-system-x86_64 $(QEMUFLAGS) $(QEMUIMGFLAGS) -enable-kvm -cpu host,migratable=off