Skip to content

Commit 04ec78f

Browse files
committed
replace build and test scripts with makefile
1 parent e3f4bb7 commit 04ec78f

File tree

5 files changed

+50
-44
lines changed

5 files changed

+50
-44
lines changed

README.md

+12-6
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,20 @@ So far the kernel uses a flat FAT12 file system and has a built-in command inter
1212

1313
## Compilation and running
1414

15-
The _build.bat_ script uses:
16-
- NASM to compile the sources,
17-
- ImDisk to save binaries on a floppy image.
15+
To create a disk image:
16+
```
17+
make
18+
sudo make install
19+
```
20+
21+
To run it:
22+
```
23+
make test
24+
```
1825

19-
The _test.bat_ script uses:
20-
- QEMU (`qemu-system-i386`) as an emulator for the OS.
26+
The `nasm` compiler is required for installation and `qemu-system-i386` for testing.
2127

22-
Both scripts should just work and can be used without any arguments.
28+
`make install` requires root permission level to mount the disk image and copy OS files onto it.
2329

2430
## Using the shell
2531

build.bat

-15
This file was deleted.

build.sh

-22
This file was deleted.

makefile

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
IMAGE ?= akeros.img
2+
3+
SYSTEM = \
4+
bootloader.sys\
5+
kernel.sys
6+
7+
PROGRAMS = \
8+
calc.prg
9+
10+
build: $(IMAGE) $(SYSTEM) $(PRORGAMS)
11+
12+
install: $(IMAGE)
13+
$(eval DIR := $(shell mktemp -d))
14+
mount -o loop $< $(DIR)
15+
sleep 0.5
16+
cp kernel.sys $(DIR)/
17+
cp README.md $(DIR)/
18+
cp $(PROGRAMS) $(DIR)/
19+
umount $(DIR)
20+
rm -r $(DIR)
21+
22+
.PHONY: test
23+
test:
24+
qemu-system-i386 -drive format=raw,file=$(IMAGE),index=0,if=floppy
25+
26+
.PHONY: clean
27+
clean:
28+
rm $(IMAGE) $(SYSTEM) $(PROGRAMS)
29+
30+
$(IMAGE): $(SYSTEM) $(PROGRAMS)
31+
dd if=/dev/zero bs=512 count=2880 > $(IMAGE)
32+
dd if=bootloader.sys of=$(IMAGE) conv=notrunc
33+
34+
%.sys:
35+
nasm -O0 -f bin -o $@ $(@:sys=asm)
36+
37+
%.prg:
38+
nasm -O0 -f bin -o $@ $(@:prg=asm)

test.bat

-1
This file was deleted.

0 commit comments

Comments
 (0)