-
Notifications
You must be signed in to change notification settings - Fork 0
/
cbuild.sh
executable file
·192 lines (156 loc) · 3.4 KB
/
cbuild.sh
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/bin/bash
set -e
. ./shlib/platform.sh
. ./shlib/common.sh
echo ""
echo ""
echo "RCOMP"
rm -f ./kernel/Exec/Memory.o ./kernel/Exec/BBase.o ./kernel/Types/BList.o ./kernel/Types/BSymbolTable.o
cd tools/rcomp-src && make
echo ""
echo ""
echo "DISK-TOOL"
rm -f ./kernel/Exec/Memory.o ./kernel/Exec/BBase.o ./kernel/Types/BList.o ./kernel/Types/BSymbolTable.o
cd $TOP_DIR/tools/disk-tool && make
cd $TOP_DIR
echo $TOP_DIR
pwd
CRTBEGIN_OBJ=`$GCC -print-file-name=crtbegin.o`
#echo ""
#echo $CRTBEGIN_OBJ
#echo ""
CRTEND_OBJ=`$GCC -print-file-name=crtend.o`
#echo "CRTBEGIN" $CRTBEGIN_OBJ
#export KERNEL="crti.o $CRTBEGIN_OBJ main.o kernel_start.o $CRTEND_OBJ crtn.o "
#export KERNEL="crti.o $CRTBEGIN_OBJ kernel_main.o kernel_start.o $CRTEND_OBJ crtn.o "
# export KERNEL="$CRTBEGIN_OBJ kernel_main.o kernel_start.o $CRTEND_OBJ "
export KERNEL="kernel_main.o kernel_start.o"
#echo $INCLUDE_PATH
#echo $LIBS
#echo $CFLAGS
#############################
echo ""
echo ""
echo "BUILDING BOOT SECTOR"
cd $TOP_DIR/boot
nasm -f bin -l boot.lst $KGFX -o boot.img boot.asm
ls -l boot.img
cd ..
#############################
echo ""
echo ""
echo "Generating console font"
cd kernel/Graphics/font/console
FFILE=$KFONT
if [[ ! -e $FFILE ]]; then
gzip -d $FFILE.gz
$OBJCOPY -O elf64-x86-64 -B i386 -I binary $FFILE ../../kfont.o
gzip $FFILE
else
$OBJCOPY -O elf64-x86-64 -B i386 -I binary $FFILE ../../kfont.o
fi
cd ../../../..
echo ""
echo ""
echo "BUILDING KERNEL"
cd kernel
echo ""
echo ""
echo " COMPILING"
echo " nasm -f elf -o kernel_start.o kernel_start.asm"
nasm -f elf64 -o kernel_start.o -l kernel_start.lst kernel_start.asm
echo " $GCC -c -o crti.o crti.s"
$GCC -c -o crti.o crti.s
echo " $GCC -c -o crtn.o crtn.s"
$GCC -c -o crtn.o crtn.s
echo ""
echo ""
echo " BUILDING EXEC"
cd Exec
make
cd ..
# echo ""
# echo ""
# echo " BUILDING FILESYSTEMS"
# cd FileSystems
# make
# cd ..
echo ""
echo ""
echo " BUILDING INSPIRATION"
cd Inspiration
make
cd ..
#echo ""
#echo ""
#echo " BUILDING X86"
#cd Exec/x86
#make
#cd ../..
echo ""
echo ""
echo " ============== BUILDING POSIX"
cd posix
make
cd ..
echo ""
echo ""
echo " ============== BUILDING EXAMPLES"
cd ../Examples
make
cd ../kernel
echo " $GCC -c $CFLAGS -o kernel_main.o kernel_main.cpp"
$GCC -g -c $CFLAGS $INCLUDE_PATH -o kernel_main.o kernel_main.cpp
#############################
echo ""
echo ""
echo " LINKING"
echo " ld -m64 -Tconfig.ld -o kernel.elf $KERNEL ${LIBS}"
EXAMPLES=../Examples/*.o
ld -e _start -Tconfig.ld -o kernel.elf $KERNEL $EXAMPLES $LIBS -lexec
echo " objcopy -O binary kernel.elf kernel.img"
objcopy -O binary kernel.elf kernel.img
cd ..
echo ""
echo ""
echo " Building build-img tools"
cd tools
make
echo ""
echo ""
echo "Building disk image"
cd ..
cd iso
./make-iso.sh
cd ..
./tools/build-img boot/boot.img kernel/kernel.img iso/fs.img
echo ""
echo ""
rm -f c.img
bximage -q -mode=create -hd=12M -imgmode=flat c.img c.img
echo "cat < bare.img 1<>c.img"
cat < iso/bare.img 1<>c.img
chmod 644 c.img
#cat boot.img kernel.img > drive.img
echo ""
echo ""
#############################
if [ "$WSL" != "" ]; then
echo "WSL! copy to C:\dev"
cp bochsrc /mnt/c/dev/
cp bare.img /mnt/c/dev
fi
echo ""
echo "COMPLETE!"
ls -l */*.img
echo ""
ls -l *.img
echo ""
if [ "$WSL" != "" ]; then
echo "=== WSL c:\dev"
ls -l /mnt/c/dev
echo " "
fi
nm kernel/kernel.elf | grep " T " | awk '{ print $1" "$3 }' > kernel.sym
echo ""
wc -l kernel.sym