-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (68 loc) · 2.1 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
DD = dd
LD = /home/rdwn/opt/cross/bin/i686-elf-ld
CC = /home/rdwn/opt/cross/bin/i686-elf-gcc
AS = nasm
CT = cat
QM = qemu-system-i386
KernelB = build/kernel/bin/main.bin
BootB = build/boot/bin/boot.bin
KernelBin = build/bin/os.bin
KernelImg = build/img/os.img
KernelIso = build/iso/os.iso
COLOR_INFO := \e[1;32m
COLOR_ERR := \e[1;31m
COLOR_WARN := \e[1;33m
COLOR_RESET := $<\e[0m
all: clear bin img iso run
iso:
@echo "${COLOR_INFO}[ BLD ]${COLOR_RESET} Building OS (iso) ..."
@mkdir -p build/iso
@if genisoimage -quiet -V 'MYOS' -input-charset iso8859-1 -o ${KernelIso} -b os.img -hide os.img build/img; \
then echo "${COLOR_INFO}[ MSG ]${COLOR_RESET} Done!"; \
else \
echo "${COLOR_ERR}[ ERR ]${COLOR_RESET} Failed!"; \
fi
img:
@echo "${COLOR_INFO}[ BLD ]${COLOR_RESET} Building OS (img) ..."
@mkdir -p build/img
@if dd if=/dev/zero of=${KernelImg} bs=1024 count=1440 && \
dd if=${KernelBin} of=${KernelImg} seek=0 count=30 conv=notrunc; \
then echo "${COLOR_INFO}[ MSG ]${COLOR_RESET} Done!"; \
else \
echo "${COLOR_ERR}[ ERR ]${COLOR_RESET} Failed!"; \
fi
bin: booto kernelo
@echo "${COLOR_INFO}[ LNK ]${COLOR_RESET} Proparing OS (bin) ..."
@mkdir -p build/bin
@if ${CT} ${BootB} ${KernelB} > ${KernelBin}; \
then echo "${COLOR_INFO}[ MSG ]${COLOR_RESET} Done!"; \
else \
echo "${COLOR_ERR}[ ERR ]${COLOR_RESET} Failed!"; \
fi
kernelo:
@ cd kernel && make
booto:
@ cd boot && make
run:
@echo "${COLOR_INFO}[ RUN ]${COLOR_RESET} Booting OS ..."
@if ${QM} -fda ${KernelBin}; \
then echo "${COLOR_INFO}[ MSG ]${COLOR_RESET} Done!"; \
else \
echo "${COLOR_ERR}[ ERR ]${COLOR_RESET} Failed!"; \
fi
clean: cleank cleanb
@echo "${COLOR_INFO}[ CLN ]${COLOR_RESET} Cleaning kerenl ..."
@if rm -f ${KernelBin} && \
rm -f ${KernelImg} && \
rm -f ${KernelIso} && \
rm -rf build; \
then echo "${COLOR_INFO}[ MSG ]${COLOR_RESET} Done!"; \
else \
echo "${COLOR_ERR}[ ERR ]${COLOR_RESET} Failed!"; \
fi
cleank:
@ cd kernel && make clean
cleanb:
@ cd boot && make clean
clear:
@clear