-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
56 lines (42 loc) · 1.24 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
#
# (c) 2020 iomonad <[email protected]>
#
include rules/environment.mk
include rules/assembly.mk
include rules/compiler.mk
include rules/linker.mk
TARGET = kfs.rom
TARGET_SYM = kfs.sym
TARGET_ISO = kfs.iso
# ==== BEGIN RULES ====
prepare:
mkdir -p $(BUILD_DIR)
bootloader: prepare $(ASM_TARGETS)
boot/%.o: boot/%.asm
printf "ASM\t\t%s\n" $<
$(ASM) $(ASM_FLAGS) $< -o $@
kernel: $(KERNEL_TARGETS)
kernel/sources/%.o: kernel/sources/%.c
printf "CC\t\t%s\n" $<
$(CC) $(CFLAGS) -c $< -o $@
rom: bootloader kernel
printf "\nLD\t\t%s\n" $(TARGET)
$(LINKER) $(LFLAGS) $(ASM_TARGETS) $(KERNEL_TARGETS) -o $(TARGET)
cp $(TARGET) $(TARGET).cpy && objcopy --only-keep-debug $(TARGET).cpy $(TARGET_SYM) && rm $(TARGET).cpy
post:
strip $(TARGET)
iso: rom post
mkdir -p $(ISODIR_BOOT)
cp $(TARGET) $(ISODIR)/boot/$(TARGET)
cp boot/grub.cfg $(ISODIR_BOOT)/grub.cfg
grub-mkrescue -o $(TARGET_ISO) --compress=gz --themes="" --install-modules="multiboot" $(ISODIR)
clean:
rm -fr $(BUILD_DIR) isodir
rm -fr $(KERNEL_TARGETS) $(ASM_TARGETS) $(TARGET_SYM)
fclean: clean
rm -f $(TARGET) *.iso *.dump
re: fclean rom
# ==== END RULES =====
.PHONY: prepare bootloader kernel rom post clean fclean
.DEFAULT_GOAL := rom
MAKEFLAGS += --silent --no-builtin-rules