-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (59 loc) · 2.56 KB
/
Makefile
File metadata and controls
77 lines (59 loc) · 2.56 KB
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
TOPDIR := .
include $(TOPDIR)/Makedefs
ALL_SOURCES := $(shell find boot klibc kernel include -name '*.swift' -o -name '*.asm' -o -name '*.[ch]')
KERNEL_OBJS := kernel/kernel.o klibc/klibc.o
SUBDIRS := boot kernel klibc
EXTRA_LIBS :=
.PHONY: all iso clean kernel macros
all: iso
iso: output/boot-cd.iso
macros:
cd macros/Printf && $(SWIFT) build -c release
output/kernel.elf: macros $(ALL_SOURCES)
mkdir -p $(MODULE_DIR) output
$(RUNNER) make -C klibc
$(RUNNER) make -C kernel
# initial link must be via ELF to produce a GOT
$(LD) --no-demangle -static -Tlinker.script -Map=output/kernel.map -z max-page-size=0x1000 -o output/kernel.elf $(KERNEL_OBJS) $(SWIFTLIBS) $(EXTRA_LIBS)
output/kernel.dmp: output/kernel.elf
(objdump -d output/kernel.elf -Mintel | $(SWIFT)-demangle > output/kernel.dmp)
output/kernel.efi: output/kernel.elf
$(MAKE) -C boot/uefi
$(OBJCOPY) -I binary -O elf64-x86-64 -B i386:x86-64 output/kernel.elf output/kernel.elf.obj
$(LD) --no-demangle -static -gc-sections -Tboot/uefi/efi_linker.script -Map=output/efi_body.map -o output/efi_body.bin boot/uefi/efi_body.o
$(SWIFT) run -c release --package-path utils efi_patch boot/uefi/efi_header.bin output/efi_body.bin output/kernel.map output/kernel.efi
output/kernel.bin: output/kernel.elf
echo Converting output/kernel.elf to output/kernel.bin
$(OBJCOPY) -O binary output/kernel.elf output/kernel.bin
output/boot-hd.img: output/kernel.bin
$(MAKE) -C boot
$(SWIFT) run -c release --package-path utils mkdiskimg boot/bootsector.bin boot/boot16to64.bin output/kernel.bin output/boot-hd.img
ISO=output/boot-cd.iso
ISO_TMP=output/iso_tmp
BOOT_IMG=$(ISO_TMP)/boot.img
EFI_IMG=$(ISO_TMP)/boot/efi.img
output/boot-cd.iso: output/boot-hd.img output/kernel.efi
rm -rf $(ISO_TMP) $(ISO) #output/efi.img
mkdir -p $(ISO_TMP)/efi/boot $(ISO_TMP)/boot
cp output/boot-hd.img $(BOOT_IMG)
cp output/kernel.efi $(ISO_TMP)/efi/boot/bootx64.efi
$(MKFS_MSDOS) -C output/iso_tmp/boot/efi.img 30240
mmd -i $(EFI_IMG) ::efi
mmd -i $(EFI_IMG) ::efi/boot
mcopy -i $(EFI_IMG) output/kernel.efi ::efi/boot
# uncomment line below to make bootable EFI ISO
mcopy -i $(EFI_IMG) output/kernel.efi ::efi/boot/bootx64.efi
xorrisofs -J -joliet-long \
-isohybrid-mbr boot/isohdr.bin \
-b boot.img -c boot.cat \
-boot-load-size 4 \
-boot-info-table -no-emul-boot \
-eltorito-alt-boot -e boot/efi.img \
-no-emul-boot \
-isohybrid-gpt-basdat \
-isohybrid-apm-hfsplus \
-o output/boot-cd.iso output/iso_tmp
rm -r $(ISO_TMP)
clean:
rm -rf output/*
set -e; for dir in $(SUBDIRS); do $(MAKE) -C $$dir clean; done