-
Notifications
You must be signed in to change notification settings - Fork 265
/
Makefile
151 lines (124 loc) · 3.95 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#
# if you want the ram-disk device, define this to be the
# size in blocks.
#
RAMDISK = # -DRAMDISK=2048
# This is a basic Makefile for setting the general configuration
include Makefile.header
LDFLAGS += -Ttext 0 -e startup_32
CFLAGS += $(RAMDISK) -Iinclude
CPP += -Iinclude
#
# ROOT_DEV specifies the default root-device when making the image.
# This can be either FLOPPY, /dev/xxxx or empty, in which case the
# default of hd1(0301) is used by 'build'.
#
#ROOT_DEV= 021d # FLOPPY B
#ROOT_DEV= 0301 # hd1
ARCHIVES=kernel/kernel.o mm/mm.o fs/fs.o
DRIVERS =kernel/blk_drv/blk_drv.a kernel/chr_drv/chr_drv.a
MATH =kernel/math/math.a
LIBS =lib/lib.a
.c.s:
@$(CC) $(CFLAGS) -S -o $*.s $<
.s.o:
@$(AS) -o $*.o $<
.c.o:
@$(CC) $(CFLAGS) -c -o $*.o $<
all: Image
Image: boot/bootsect boot/setup kernel.sym ramfs FORCE
@cp -f images/kernel.sym images/kernel.tmp
@$(STRIP) images/kernel.tmp
@$(OBJCOPY) -O binary -R .note -R .comment images/kernel.tmp images/kernel
$(BUILD) boot/bootsect boot/setup images/kernel images/Image
@rm images/kernel.tmp
@rm -f images/kernel
@sync
init/main.o: FORCE
@make main.o -C init/
boot/head.o: boot/head.s FORCE
@make head.o -C boot/
kernel.sym: boot/head.o init/main.o \
$(ARCHIVES) $(DRIVERS) $(MATH) $(LIBS)
@$(LD) $(LDFLAGS) boot/head.o init/main.o \
$(ARCHIVES) \
$(DRIVERS) \
$(MATH) \
$(LIBS) \
-o images/kernel.sym
@nm images/kernel.sym | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aU] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)'| sort > images/kernel.map
kernel/math/math.a: FORCE
@make -C kernel/math
kernel/blk_drv/blk_drv.a: FORCE
@make -C kernel/blk_drv
kernel/chr_drv/chr_drv.a: FORCE
@make -C kernel/chr_drv
kernel/kernel.o: FORCE
@make -C kernel
mm/mm.o: FORCE
@make -C mm
fs/fs.o: FORCE
@make -C fs
lib/lib.a: FORCE
@make -C lib
boot/setup: boot/setup.s FORCE
@make setup -C boot
boot/bootsect: boot/bootsect.s FORCE
@make bootsect -C boot
clean:
@make clean -C rootfs
@rm -f images/Image images/kernel.map tmp_make core boot/bootsect boot/setup
@rm -f images/kernel.sym boot/*.o typescript* info bochsout.txt
@make clean -C callgraph
@for i in init mm fs kernel lib boot; do make clean -C $$i; done
distclean: clean
@rm -f tag* cscope* linux-0.11.*
dep:
@sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
@cp tmp_make Makefile
@for i in init fs kernel mm; do make dep -C $$i; done
# Test on emulators with different prebuilt rootfs
include Makefile.emulators
# Tags for source code reading
include Makefile.tags
# For Call graph generation
include Makefile.callgraph
FORCE: ;
help:
@echo "------------------Linux 0.11 Lab (http://tinylab.org/linux-0.11-lab)------------------"
@echo ""
@echo " :: Compile ::"
@echo ""
@echo " make --generate a kernel floppy Image with a fs on hda1"
@echo " make clean -- clean the object files"
@echo " make distclean -- only keep the source code files"
@echo ""
@echo " :: Test ::"
@echo ""
@echo " make start -- start the kernel in vm (qemu/bochs)"
@echo " make start-fd -- start the kernel with fs in floppy"
@echo " make start-hd -- start the kernel with fs in hard disk"
@echo ""
@echo ""
@echo " :: Debug ::"
@echo ""
@echo " make debug -- debug the kernel in qemu/bochs & gdb at port 1234"
@echo " make debug-fd -- debug the kernel with fs in floppy"
@echo " make debug-hd -- debug the kernel with fs in hard disk"
@echo ""
@echo " make switch -- switch the emulator: qemu and bochs"
@echo ""
@echo " :: Read ::"
@echo ""
@echo " make cscope -- genereate the cscope index databases"
@echo " make tags -- generate the tag file"
@echo " make cg -- generate callgraph of the default main entry"
@echo " make cg f=func d=dir|file b=browser -- generate callgraph of func in file/directory"
@echo ""
@echo " :: More ::"
@echo ""
@echo " >>> README.md <<<"
@echo ""
@echo " ~ Enjoy It ~"
@echo ""
@echo "-------------------Linux 0.11 Lab (http://tinylab.org/linux-0.11-lab)-------------------"