-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathMakefile
401 lines (328 loc) · 9.22 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
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# Polar D8 Kernel
# Codename: Lamb
# License: MIT License
# Compiling on gcc 11.4.0 (Ubuntu on wsl)
# Linking on ld 2.38
BASE = your/base
# Display server
DEP_L1 = ../de/ds
# Client-side GUI applications
DEP_L2 = ../de/apps
# 3D demos
DEP_L3 = ../games
# Make variables (CC, etc...)
AS = as
LD = ld
CC = gcc
AR = ar
MAKE = make
NASM = nasm
PYTHON = python
PYTHON2 = python2
PYTHON3 = python3
#
# Config
#
# verbose
# Quiet compilation or not.
ifndef CONFIG_USE_VERBOSE
CONFIG_USE_VERBOSE = 1
endif
ifeq ($(CONFIG_USE_VERBOSE),1)
# Not silent. It prints the commands.
Q =
else
# silent
Q = @
endif
# --------------------------------------
# == Start ====
# build: User command.
PHONY := all
all: \
build-gramado-os \
copy-extras \
/mnt/GRAMVD \
vhd-mount \
vhd-copy-files \
vhd-unmount \
clean
# Giving permitions to run.
chmod 755 ./run
chmod 755 ./runnokvm
# tests
chmod 755 ./runt1
chmod 755 ./runt2
@echo "Done?"
# --------------------------------------
# build: Developer comand 1.
# install
# Build the images and put them all into $(BASE)/ folder.
PHONY := install
install: do_install
do_install: \
build-gramado-os
# --------------------------------------
# build: Developer comand 2.
# image
# Copy all the files from $(BASE)/ to the VHD.
PHONY := image
image: do_image
do_image: \
/mnt/GRAMVD \
vhd-mount \
vhd-copy-files \
vhd-unmount \
# --------------------------------------
#::0
# ~ Step 0: gramado files.
PHONY := build-gramado-os
build-gramado-os:
@echo ":: [] Building VHD, bootloaders and kernel image."
# options:
# main.asm and main2.asm
# O mbr só consegue ler o root dir para pegar o BM.BIN
# See: stage1.asm
# O BM.BIN só consegue ler o root dir pra pegar o BL.BIN
# See: main.asm
# the kernel image
# O BL.BIN procura o kernel no diretorio GRAMADO/
# See: fs/loader.c
#===================================
# (1) boot/
# ::Build stuuf in boot/
$(Q)$(MAKE) -C boot/
# Copy stuff created in boot/
# Copy the virtual disk into the rootdir.
cp boot/GRAMHV.VHD .
# Copy bootloader stuff into rootdir.
cp boot/x86/bsp/bin/BM.BIN $(BASE)/
cp boot/x86/bsp/bin/BM2.BIN $(BASE)/
cp boot/x86/bsp/bin/BLGRAM.BIN $(BASE)/
# Copy bootloader stuff into GRAMADO/ folder.
cp boot/x86/bsp/bin/BM.BIN $(BASE)/GRAMADO
cp boot/x86/bsp/bin/BM2.BIN $(BASE)/GRAMADO
cp boot/x86/bsp/bin/BLGRAM.BIN $(BASE)/GRAMADO
cp boot/MBR0.BIN $(BASE)/GRAMADO
#===================================
# (2) kernel/
# ::Build kernel image.
$(Q)$(MAKE) -C kernel/
# Copy to the target folder.
# We need a backup
# The bootloader expect this.
# todo: We need to rethink this backup.
cp kernel/KERNEL.BIN $(BASE)/GRAMADO
cp kernel/KERNEL.BIN $(BASE)/DE
#===================================
# (3) mods/
# ::Build the ring0 module image.
$(Q)$(MAKE) -C mods/
# Copy the ring0 module image.
# Not dynlinked modules.
cp mods/bin/HVMOD0.BIN $(BASE)/
# cp mods/bin/HVMOD1.BIN $(BASE)/
cp mods/bin/HVMOD0.BIN $(BASE)/GRAMADO
# cp mods/bin/HVMOD1.BIN $(BASE)/GRAMADO
# ...
#===================================
# (4) udrivers/ in kernel project
$(Q)$(MAKE) -C udrivers/
-cp udrivers/bin/VGAD.BIN $(BASE)/GRAMADO/
#===================================
# (5) uservers/ in kernel project
# Build the network server and the first client.
$(Q)$(MAKE) -C uservers/
-cp uservers/bin/NET.BIN $(BASE)/GRAMADO/
-cp uservers/bin/NETD.BIN $(BASE)/GRAMADO/
#===================================
# (6) usys/ in kernel project
# Build the init process.
# Copy the init process.
# We can't survive without this one. (Only this one).
$(Q)$(MAKE) -C usys/
$(Q)$(MAKE) -C usys/commands/
# Copy
cp usys/bin/INIT.BIN $(BASE)/
-cp usys/commands/base/bin/REBOOT.BIN $(BASE)/
-cp usys/commands/base/bin/SHUTDOWN.BIN $(BASE)/
-cp usys/commands/sdk/bin/GRAMCNF.BIN $(BASE)/
# Well consolidated applications
-cp usys/bin/PUBSH.BIN $(BASE)/DE/
-cp usys/bin/SH7.BIN $(BASE)/DE/
-cp usys/bin/SHELL.BIN $(BASE)/DE/
# -cp usys/bin/SHELL00.BIN $(BASE)/DE/
-cp usys/bin/TASCII.BIN $(BASE)/DE/
-cp usys/bin/TPRINTF.BIN $(BASE)/DE/
-cp usys/commands/base/bin/CAT.BIN $(BASE)/DE/
-cp usys/commands/base/bin/UNAME.BIN $(BASE)/DE/
# Experimental applications
-cp usys/commands/base/bin/FALSE.BIN $(BASE)/DE/
-cp usys/commands/base/bin/TRUE.BIN $(BASE)/DE/
-cp usys/commands/extra/bin/CMP.BIN $(BASE)/DE/
-cp usys/commands/extra/bin/SHOWFUN.BIN $(BASE)/DE/
-cp usys/commands/extra/bin/SUM.BIN $(BASE)/DE/
#-cp usys/commands/sdk/bin/N9.BIN $(BASE)/DE/
#-cp usys/commands/sdk/bin/N10.BIN $(BASE)/DE/
#-cp usys/commands/sdk/bin/N11.BIN $(BASE)/DE/
#-cp usys/commands/extra/bin/UDPTEST.BIN $(BASE)/DE/
# Install BMPs from cali assets.
# Copy the assets/
# We can't survive without this one.
# cp your/assets/themes/theme01/*.BMP $(BASE)/
cp your/assets/themes/theme01/*.BMP $(BASE)/DE
@echo "~build-gramado-os end?"
# --------------------------------------
# Let's add a bit of shame in the project.
PHONY := copy-extras
copy-extras:
@echo "copy-extras"
# ------------------------
# LEVEL 1: (de/ds) Display servers
-cp $(DEP_L1)/ds00/bin/DS00.BIN $(BASE)/DE
#-cp $(DEP_L1)/ds01/bin/DS01.BIN $(BASE)/DE
# ------------------------
# LEVEL 2: (de/apps) Client-side GUI applications
-cp $(DEP_L2)/bin/TASKBAR.BIN $(BASE)/DE
-cp $(DEP_L2)/bin/XTB.BIN $(BASE)/DE
-cp $(DEP_L2)/bin/TERMINAL.BIN $(BASE)/DE
#-cp $(DEP_L2)/bin/GWS.BIN $(BASE)/DE
# Experimental applications
# These need the '#' prefix.
-cp $(DEP_L2)/bin/PUBTERM.BIN $(BASE)/DE/
-cp $(DEP_L2)/bin/DOC.BIN $(BASE)/DE/
-cp $(DEP_L2)/bin/GDM.BIN $(BASE)/DE/
-cp $(DEP_L2)/bin/EDITOR.BIN $(BASE)/DE/
# (browser/) browser.
# Teabox web browser
# Experimental applications
# These need the '@' prefix.
-cp $(DEP_L2)/browser/teabox/bin/TEABOX.BIN $(BASE)/DE/
# 3D demos.
-cp $(DEP_L3)/aurora/bin/DEMO00.BIN $(BASE)/DE/
-cp $(DEP_L3)/aurora/bin/DEMO01.BIN $(BASE)/DE/
@echo "~ copy-extras"
# --------------------------------------
#::2
# Step 2: /mnt/GRAMVD - Creating the directory to mount the VHD.
/mnt/GRAMVD:
@echo "========================="
@echo "Build: Creating the directory to mount the VHD ..."
sudo mkdir /mnt/GRAMVD
# --------------------------------------
#::3
# ~ Step 3: vhd-mount - Mounting the VHD.
vhd-mount:
@echo "=========================="
@echo "Build: Mounting the VHD ..."
-sudo umount /mnt/GRAMVD
sudo mount -t vfat -o loop,offset=32256 GRAMHV.VHD /mnt/GRAMVD/
# --------------------------------------
#::4
# ~ Step 4 vhd-copy-files - Copying files into the mounted VHD.
# Copying the $(BASE)/ folder into the mounted VHD.
vhd-copy-files:
@echo "========================="
@echo "Build: Copying files into the mounted VHD ..."
# Copy $(BASE)/
# sends everything from disk/ to root.
sudo cp -r $(BASE)/* /mnt/GRAMVD
# --------------------------------------
#:::5
# ~ Step 5 vhd-unmount - Unmounting the VHD.
vhd-unmount:
@echo "======================"
@echo "Build: Unmounting the VHD ..."
sudo umount /mnt/GRAMVD
# --------------------------------------
# Run on qemu using kvm.
PHONY := run
run: do_run
do_run:
sh ./run
# --------------------------------------
# Run on qemu with no kvm.
PHONY := runnokvm
runnokvm: do_runnokvm
do_runnokvm:
sh ./runnokvm
# --------------------------------------
# Basic clean.
clean:
-rm *.o
-rm *.BIN
-rm kernel/*.o
-rm kernel/*.BIN
@echo "~clean"
# --------------------------------------
# Clean up all the mess.
clean-all: clean
-rm *.o
-rm *.BIN
-rm *.VHD
-rm *.ISO
-rm boot/*.VHD
# ==================
# (1) boot/
# Clear boot images
# -rm -rf boot/arm/bin/*.BIN
-rm -rf boot/x86/bin/*.BIN
# ==================
# (2) kernel/
# Clear kernel image
-rm kernel/*.o
-rm kernel/*.BIN
-rm -rf kernel/KERNEL.BIN
# ==================
# (3) mods/
# Clear the ring0 module images
-rm -rf mods/*.o
-rm -rf mods/*.BIN
-rm -rf mods/bin/*.BIN
# ==================
# (4) usys/
# Clear INIT.BIN
-rm usys/bin/*.BIN
-rm usys/init/*.o
-rm usys/init/*.BIN
-rm uservers/netd/client/*.o
-rm uservers/netd/client/*.BIN
-rm uservers/netd/server/*.o
-rm uservers/netd/server/*.BIN
-rm usys/commands/bin/*.BIN
-rm usys/commands/init/*.o
# ==================
# Clear the disk cache
-rm -rf $(BASE)/*.BIN
-rm -rf $(BASE)/*.BMP
-rm -rf $(BASE)/EFI/BOOT/*.EFI
-rm -rf $(BASE)/GRAMADO/*.BIN
-rm -rf $(BASE)/DE/*.BIN
-rm -rf $(BASE)/DE/*.BMP
@echo "~clean-all"
# --------------------------------------
# Usage instructions.
usage:
@echo "Building everything:"
@echo "make all"
@echo "Clear the mess to restart:"
@echo "make clean-all"
@echo "Testing on qemu:"
@echo "./run"
@echo "./runnokvm"
# --------------------------------------
# Danger zone!
# This is gonna copy th image into the real HD.
# My host is running on sdb and i copy the image into sda.
# It is because the sda is in primary master IDE.
# Gramado has been tested on sda
# and the Fred's Linux host machine is on sdb.
danger-install-sda:
sudo dd if=./GRAMHV.VHD of=/dev/sda
danger-install-sdb:
sudo dd if=./GRAMHV.VHD of=/dev/sdb
qemu-instance:
-cp ./GRAMHV.VHD ./QEMU.VHD
#xxx-instance:
# -cp ./GRAMHV.VHD ./XXX.VHD
# End