-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile
90 lines (72 loc) · 2.72 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
#PSOS Development Build
#https://github.com/TheBenPerson/PSOS/tree/dev
#Copyright (C) 2016 - 2017 Ben Stockett <thebenstockett@gmail.com>
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.
#filesystem options
CLUSTERS := 4085
ENTRIES := 256
FAT_SIZE := $(shell let "FAT_SIZE = ($(CLUSTERS) + 256 - 1) / 256"; echo $$FAT_SIZE)
#kernel options
KERNEL_SEGMENT := 0x7E0
DRIVERS := kbd.o pit.o rtc.o spkr.o storage.o vga.o
LIBS := arch.o math.o string.o
#flags
export CPATH := $(shell find src -type d | tr '\n' ':')
DEF := -DKERNEL_SEGMENT=$(KERNEL_SEGMENT) -DCLUSTERS=$(CLUSTERS) -DENTRIES=$(ENTRIES) -DFAT_SIZE=$(FAT_SIZE)
CF := $(DEF) -masm=intel -Wno-int-conversion -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -march=i386 -m16
LF := -c -ffreestanding -Os -fno-pie -fno-pic -fno-stack-protector
#build directories
ROOT := bin
OBJ := $(ROOT)/obj
FS := $(ROOT)/fs
IMG := $(ROOT)/img
ISO := $(ROOT)/iso
#default targets
all: $(addprefix $(ROOT)/, PSOS.img PSOS.iso)
$(ROOT)/PSOS.img: $(addprefix $(IMG)/, loader.img kernel.img fs.img)
cat $^ > $@
@setterm --foreground red
#
# root will only be used for mounting PSOS.img to add the rootfs
# check the makefile if you don't believe me
#
@setterm --default
sudo mount $@ mnt
sudo cp -r $(FS)/* mnt/. > /dev/null
sudo umount mnt
cp $@ $(ISO)/.
$(ROOT)/PSOS.iso: $(ROOT)/PSOS.img
truncate -s 2880K $(ISO)/PSOS.img
mkisofs -o $@ -V PSOS-dev -b PSOS.img $(ISO)
include src/loader/makefile
include src/kernel/makefile
include src/fs/makefile
include src/lib/makefile
#aliases for explicit targets
%.o: $(OBJ)/%.o
#made $@
%.bin: $(FS)/%.bin
#made $@
PSOS.img: $(ROOT)/PSOS.img
#made $@
%.img: $(IMG)/%.img
#made $@
%.iso: $(ROOT)/%.iso
#made $@
.PHONY: clean
clean:
-rm $(OBJ)/* $(FS)/* $(IMG)/* $(ROOT)/* 2> /dev/null