-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile.static
114 lines (87 loc) · 2.81 KB
/
Makefile.static
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
INCLUDE := -I src -I src/lib -I ext/picotcp/build/include -include src/lib/generic.h
ifeq ($(ARCH),arm)
PREFIX = arm-none-eabi
MAKE_CFLAGS = -mcpu=cortex-a7 -fpic -msoft-float
MAKE_ASFLAGS := $(MAKE_CFLAGS) -ffreestanding
AS := $(PREFIX)-gcc
else
PREFIX = i786-pc-xelix
MAKE_CFLAGS = -march=nehalem -mtune=skylake -mgeneral-regs-only -mhard-float -mpopcnt
MAKE_NASMFLAGS = -g -f elf
MAKE_ASFLAGS := $(MAKE_CFLAGS) -ffreestanding
AS = nasm
endif
CC := $(PREFIX)-gcc
OBJCOPY := $(PREFIX)-objcopy
QEMU := qemu-system-$(ARCH)
LD := $(CC)
MAKE_CFLAGS += -std=gnu2x -pipe -g -O3 -ffreestanding -fno-omit-frame-pointer -fstack-protector-strong -Wall -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wframe-larger-than=1024 -Wcast-align -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference $(INCLUDE)
MAKE_LDFLAGS := -T src/boot/$(ARCH)-linker.ld -nostdlib -lgcc
ifeq ($(shell uname -s), Darwin)
AS := $(shell find /usr/local/Cellar/nasm/*/bin/nasm)
endif
MAKE_CFLAGS += $(CFLAGS)
MAKE_QEMU_FLAGS = -vga qxl -m 1024 -cpu SandyBridge -serial mon:stdio -display sdl -no-reboot -device ac97 -d guest_errors,unimp,page -drive file=xelix.img,format=raw,if=ide -netdev bridge,id=mnet0,br=br.vms,helper=/usr/libexec/qemu-bridge-helper -device virtio-net,netdev=mnet0
MAKE_QEMU_FLAGS += $(QEMU_FLAGS)
MAKE_LDFLAGS += $(LDFLAGS)
.PHONY: all
all:
@make -j$(nproc) xelix.bin
ext/picotcp/build/lib/libpicotcp.a:
make -C ext/picotcp
.config:
util/kconfiglib/alldefconfig.py
src/lib/config.h: Kconfig .config
util/kconfiglib/genconfig.py --header-path src/lib/config.h
%.o: %.c src/lib/generic.h src/lib/config.h ext/picotcp/build/lib/libpicotcp.a
$(CC) $(MAKE_CFLAGS) -o $@ -c $<
%-asm.o: %.asm
$(AS) $(MAKE_NASMFLAGS) -o $@ $<
%-S.o: %.S
$(CC) $(MAKE_ASFLAGS) -o $@ -c $<
%-psf.o: %.psf
$(OBJCOPY) -O $(PREFIX) -B $(ARCH) -I binary -SK _binary_src_gfx_Tamsyn8x16r_psf_start $< $@
%-img.o: %.img
$(OBJCOPY) -O $(PREFIX) -B $(ARCH) -I binary -SK _binary_src_gfx_bootlogo_img_start $< $@
kernel7.img: xelix.bin
arm-none-eabi-objcopy xelix.bin -O binary kernel7.img
$(CC):
make -C toolchain
xelix.img: xelix.bin
-mkdir mnt
sudo losetup -P /dev/loop0 xelix.img
sudo mount /dev/loop0p1 mnt
sudo cp xelix.bin mnt/
make umount
.PHONY: run
run: xelix.img
$(QEMU) $(MAKE_QEMU_FLAGS)
.PHONY: clean
clean:
find -L src -type f -iname "*.o" -delete
.PHONY: land
land:
make -C land
.PHONY: image
image:
util/build-image.sh xelix.qcow2
.PHONY: mount_boot
mount_boot:
-mkdir mnt
sudo losetup -P /dev/loop0 xelix.img
sudo mount /dev/loop0p1 mnt
.PHONY: mount
mount:
sudo losetup -P /dev/loop0 xelix.img
sudo mount /dev/loop0p2 mnt
.PHONY: umount
umount:
sudo umount mnt
sleep 0.5
sudo losetup -d /dev/loop0
.PHONY: menuconfig
menuconfig:
util/kconfiglib/menuconfig.py
.PHONY: menuconfig
guiconfig:
util/kconfiglib/guiconfig.py