-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
305 lines (250 loc) · 6.18 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
# fn-dos 16bit.
# Compiling on gcc 11.4.0
# Linking on ld 2.38
BASE = your/base
BOOT_DIR = source/bootload
KERNEL_DIR = source
# Let's import the 32bit pmi.
# Levels
#DEP_L4 = ../pmi
#DEP_L3 = ../pmi
#DEP_L2 = ../pmi
#DEP_L1 = ../pmi
# 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/M86VD \
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/M86VD \
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/
# Create the virtual disk 0.
$(Q)$(NASM) diskimg/vd/fat/main.asm \
-I diskimg/vd/fat/ \
-o FNDOS.VHD
# Create backup for MBR 0.
$(Q)$(NASM) $(BOOT_DIR)/stage1.asm \
-I $(BOOT_DIR)/ \
-o BOOTLOAD.BIN
cp BOOTLOAD.BIN $(BASE)/
# bew kernel
# 16 bit kernel loader (KLDR.BIN)
$(Q)$(MAKE) -C $(KERNEL_DIR)/
# Copy to the target folder.
cp $(KERNEL_DIR)/bin/KERNEL.BIN $(BASE)/
# ---------
# CMD00.BIN
$(Q)$(MAKE) -C programs/cmd00/cmd00/
# Copy to the target folder.
cp programs/cmd00/cmd00/bin/CMD00.BIN $(BASE)/
# ---------
# CMD01.BIN
$(Q)$(MAKE) -C programs/cmd01/cmd01/
# Copy to the target folder.
cp programs/cmd01/cmd01/bin/CMD01.BIN $(BASE)/
# APP00.COM
$(Q)$(MAKE) -C programs/cmd01/app00/
# Copy to the target folder.
cp programs/cmd01/app00/bin/APP00.COM $(BASE)/
#----------------------------------
# () userland/
# Install BMPs from cali assets.
# Copy the assets/
# We can't survive without this one.
cp your/assets/themes/theme01/*.BMP $(BASE)/
@echo "~build-gramado-os end?"
# --------------------------------------
# Let's add a bit of shame in the project.
PHONY := copy-extras
copy-extras:
@echo "copy-extras"
# ------------------------
# LEVEL 4: (aurora/) 3D demos.
# -cp $(DEP_L4)/bin/DEMO00.BIN $(BASE)/
#
# ------------------------
# LEVEL 3: (browser/) browser.
# Teabox web browser
# ------------------------
# LEVEL 2: (commands/) Posix comands.
# -cp $(DEP_L2)/base/bin/CAT.BIN $(BASE)/
# ------------------------
# LEVEL 1: (de/) Display servers and applications.
@echo "~ copy-extras"
# --------------------------------------
#::2
# Step 2: /mnt/M86VD - Creating the directory to mount the VHD.
/mnt/M86VD:
@echo "========================="
@echo "Build: Creating the directory to mount the VHD ..."
sudo mkdir /mnt/M86VD
# --------------------------------------
#::3
# ~ Step 3: vhd-mount - Mounting the VHD.
vhd-mount:
@echo "=========================="
@echo "Build: Mounting the VHD ..."
-sudo umount /mnt/M86VD
sudo mount -t vfat -o loop,offset=32256 FNDOS.VHD /mnt/M86VD/
# --------------------------------------
#::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/M86VD
# --------------------------------------
#:::5
# ~ Step 5 vhd-unmount - Unmounting the VHD.
vhd-unmount:
@echo "======================"
@echo "Build: Unmounting the VHD ..."
sudo umount /mnt/M86VD
# --------------------------------------
# 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
# 16 programs and 32bit pmi.
-rm programs/bin/*.o
-rm programs/bin/*.BIN
#-rm programs/cmd00/bin/*.BIN
#-rm programs/cmd01/bin/*.BIN
-rm programs/cmd00/cmd00/bin/*.BIN
#-rm programs/cmd01/cmd01/bin/*.BIN
#...
# 16bit kernel
-rm $(KERNEL_DIR)/bin/*.o
-rm $(KERNEL_DIR)/bin/*.BIN
# ==================
# 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)/PROGRAMS/*.BIN
-rm -rf $(BASE)/USERS/*.BIN
@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=./FNDOS.VHD of=/dev/sda
danger-install-sdb:
sudo dd if=./FNDOS.VHD of=/dev/sdb
qemu-instance:
-cp ./FNDOS.VHD ./QEMU.VHD
#xxx-instance:
# -cp ./FNDOS.VHD ./XXX.VHD
# End