forked from Pisces52246/OSdesign
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile~
135 lines (99 loc) · 4.63 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
######################
# Makefile for Tinix #
######################
# Entry point of Tinix
# It must be as same as 'KernelEntryPointPhyAddr' in load.inc!!!
ENTRYPOINT = 0x30400
# Offset of entry point in kernel file
# It depends on ENTRYPOINT
ENTRYOFFSET = 0x400
# Programs, flags, etc.
ASM = nasm
DASM = ndisasm
CC = gcc
LD = ld
ASMBFLAGS = -I boot/include/
ASMKFLAGS = -I include/ -f elf
CFLAGS = -I include/ -c -fno-builtin -fno-stack-protector -m32
LDFLAGS = -s -Ttext $(ENTRYPOINT) -m elf_i386
DASMFLAGS = -u -o $(ENTRYPOINT) -e $(ENTRYOFFSET)
# This Program
TINIXBOOT = boot/boot.bin boot/loader.bin
TINIXKERNEL = kernel.bin
OBJS = kernel/kernel.o kernel/syscall.o kernel/start.o kernel/main.o\
kernel/clock.o kernel/i8259.o kernel/global.o kernel/protect.o\
kernel/proc.o kernel/keyboard.o kernel/tty.o kernel/console.o\
kernel/printf.o kernel/vsprintf.o\
lib/klib.o lib/klibc.o lib/string.o
DASMOUTPUT = kernel.bin.asm
# All Phony Targets
.PHONY : everything final image clean realclean disasm all buildimg
# Default starting position
everything : $(TINIXBOOT) $(TINIXKERNEL)
all : realclean everything
final : all clean
image : final buildimg
clean :
rm -f $(OBJS)
realclean :
rm -f $(OBJS) $(TINIXBOOT) $(TINIXKERNEL)
disasm :
$(DASM) $(DASMFLAGS) $(TINIXKERNEL) > $(DASMOUTPUT)
# Write "boot.bin" & "loader.bin" into floppy image "TINIX.IMG"
# We assume that "TINIX.IMG" exists in current folder
buildimg :
mount TINIX.IMG /tmp/Tinix -o loop
cp -f boot/loader.bin /tmp/Tinix/
cp -f kernel.bin /tmp/Tinix
umount /tmp/Tinix
boot/boot.bin : boot/boot.asm boot/include/load.inc boot/include/fat12hdr.inc
$(ASM) $(ASMBFLAGS) -o $@ $<
boot/loader.bin : boot/loader.asm boot/include/load.inc boot/include/fat12hdr.inc boot/include/pm.inc
$(ASM) $(ASMBFLAGS) -o $@ $<
$(TINIXKERNEL) : $(OBJS)
$(LD) $(LDFLAGS) -o $(TINIXKERNEL) $(OBJS)
kernel/kernel.o : kernel/kernel.asm include/sconst.inc
$(ASM) $(ASMKFLAGS) -o $@ $<
kernel/syscall.o : kernel/syscall.asm include/sconst.inc
$(ASM) $(ASMKFLAGS) -o $@ $<
kernel/start.o: kernel/start.c include/type.h include/const.h include/protect.h include/string.h include/proc.h include/proto.h \
include/tty.h include/console.h include/global.h
$(CC) $(CFLAGS) -o $@ $<
kernel/main.o: kernel/main.c include/type.h include/const.h include/protect.h include/string.h include/proc.h include/proto.h \
include/tty.h include/console.h include/global.h
$(CC) $(CFLAGS) -o $@ $<
kernel/i8259.o: kernel/i8259.c include/type.h include/const.h include/protect.h include/string.h include/proc.h \
include/tty.h include/console.h include/global.h include/proto.h
$(CC) $(CFLAGS) -o $@ $<
kernel/global.o: kernel/global.c include/type.h include/const.h include/protect.h include/proc.h \
include/tty.h include/console.h include/global.h include/proto.h
$(CC) $(CFLAGS) -o $@ $<
kernel/protect.o: kernel/protect.c include/type.h include/const.h include/protect.h include/proc.h include/proto.h \
include/tty.h include/console.h include/global.h
$(CC) $(CFLAGS) -o $@ $<
kernel/clock.o: kernel/clock.c include/type.h include/const.h include/protect.h include/string.h include/proc.h \
include/tty.h include/console.h include/global.h include/proto.h
$(CC) $(CFLAGS) -o $@ $<
kernel/proc.o: kernel/proc.c include/type.h include/const.h include/protect.h include/string.h include/proc.h include/proto.h \
include/tty.h include/console.h include/global.h
$(CC) $(CFLAGS) -o $@ $<
kernel/keyboard.o: kernel/keyboard.c include/type.h include/const.h include/protect.h include/string.h include/proc.h \
include/tty.h include/console.h include/global.h include/keyboard.h include/keymap.h include/proto.h
$(CC) $(CFLAGS) -o $@ $<
kernel/tty.o: kernel/tty.c include/type.h include/const.h include/protect.h include/string.h include/proc.h \
include/tty.h include/console.h include/global.h include/keyboard.h include/proto.h
$(CC) $(CFLAGS) -o $@ $<
kernel/console.o: kernel/console.c include/type.h include/const.h include/protect.h include/string.h include/proc.h \
include/tty.h include/console.h include/global.h include/keyboard.h include/proto.h
$(CC) $(CFLAGS) -o $@ $<
kernel/vsprintf.o: kernel/vsprintf.c include/type.h include/const.h include/string.h
$(CC) $(CFLAGS) -o $@ $<
kernel/printf.o: kernel/printf.c include/type.h include/const.h
$(CC) $(CFLAGS) -o $@ $<
lib/klibc.o: lib/klib.c include/type.h include/const.h include/protect.h include/string.h include/proc.h include/proto.h \
include/tty.h include/console.h include/global.h
$(CC) $(CFLAGS) -o $@ $<
lib/klib.o : lib/klib.asm include/sconst.inc
$(ASM) $(ASMKFLAGS) -o $@ $<
lib/string.o : lib/string.asm
$(ASM) $(ASMKFLAGS) -o $@ $<