-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
202 lines (157 loc) · 6.56 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
PROJECTS:=kernel
SOURCE_PACKAGES:= photon libtest
export ONYX_ARCH:=$(shell scripts/onyx_arch.sh)
include usystem/Makefile
ALL_MODULES:=$(PROJECTS) $(SOURCE_PACKAGES) $(patsubst %, usystem/%, $(USYSTEM_PROJS))
.PHONY: all iso clean build-prep $(SYSTEM_HEADER_PROJECTS) $(PROJECTS) \
$(SOURCE_PACKAGES) build-cleanup musl
export DESTDIR:=$(PWD)/sysroot
export HOST?=$(shell scripts/arch-to-host.sh $(ONYX_ARCH))
export BUILDPKG_BIN?=$(PWD)/buildpkg/buildpkg
export BUILDPKG_BIN_PY_WRAPPER?=$(PWD)/buildpkg/buildpkg_gn_wrapper
ifneq ($(CLANG_PATH),)
export CLANG_ARGUMENTS:=--target=$(shell scripts/target-triplet-to-arch.sh $(HOST))-unknown-onyx
export CLANG_BIN:=$(CLANG_PATH)/bin
export AR:=$(CLANG_BIN)/llvm-ar
export CC:=$(CLANG_BIN)/clang $(CLANG_ARGUMENTS)
export CC_BARE_PATH:=$(CLANG_BIN)/clang
export AS:=$(CC)
export CXX:=$(CLANG_BIN)/clang++ $(CLANG_ARGUMENTS)
export NM:=$(CLANG_BIN)/llvm-nm
export LD:=$(CLANG_BIN)/ld
export STRIP:=$(CLANG_BIN)/llvm-strip
export RANLIB:=$(CLANG_BIN)/llvm-ranlib
export OBJCOPY:=$(CLANG_BIN)/llvm-objcopy
export ONYX_USING_CLANG:=yes
else
export AR:=$(HOST)-ar
export AS:=$(HOST)-as
export CC:=$(HOST)-gcc
export CC_BARE_PATH:=$(shell which $(CC))
export CXX:=$(HOST)-g++
export NM:=$(HOST)-nm
export LD:=$(HOST)-ld.bfd
export STRIP:=$(HOST)-strip
export RANLIB:=$(HOST)-ranlib
export OBJCOPY:=$(HOST)-objcopy
endif
export PREFIX:=/usr
export EXEC_PREFIX:=$(PREFIX)
export BOOTDIR:=/boot
export LIBDIR:=$(EXEC_PREFIX)/lib
export INCLUDEDIR:=$(PREFIX)/include
export BINDIR:=$(PREFIX)/bin
export MANDIR:=/usr/share/man
export PKGDIR:=/pkg
ifeq ($(ONYX_ARCH), riscv64)
ifeq ($(ONYX_USING_CLANG), yes)
export EXTRA_CFLAGS:=-mno-relax
endif
endif
export CFLAGS?=-O2 -g $(EXTRA_CFLAGS)
export CPPFLAGS:=
export SYSROOT=$(PWD)/sysroot
# Configure the cross-compiler to use the desired system root.
export CXX:=$(CXX) --sysroot=$(PWD)/sysroot
export CC:=$(CC) --sysroot=$(PWD)/sysroot
all: iso
clean:
for module in $(ALL_MODULES); do $(MAKE) -C $$module clean; done
cd usystem && gn clean out/ && cd ..
rm -rf sysroot
rm -rf initrd.tar.*
$(MAKE) -C musl clean
build-prep:
mkdir -p sysroot
install-packages: $(PROJECTS)
kernel-config-h:
$(MAKE) -C kernel/ include/onyx/config.h
kernel: install-headers
rm -f kernel/clang-tidy.out
$(MAKE) -C $@ install
musl: install-headers
scripts/check_reconf.sh musl --enable-debug --prefix=/usr --syslibdir=/usr/lib
$(MAKE) -C musl install-headers
$(MAKE) -C $@ install
wserver: $(SOURCE_PACKAGES)
$(MAKE) -C $@ install
singularity: musl install-packages wserver
$(MAKE) -C $@ install
$(SOURCE_PACKAGES): musl install-packages
$(MAKE) -C $@ install
$(USYSTEM_DFL_RULE_PROJS): musl install-packages
$(MAKE) -C usystem/$@ install
dash: musl install-packages
./scripts/check_reconf.sh usystem/dash --prefix=/usr --enable-static
$(MAKE) -C usystem/$@ install
ln -sf dash $(DESTDIR)$(BINDIR)/sh
install-headers: build-prep
$(MAKE) -C kernel install-headers
$(MAKE) -C photon install-headers
build-srcpackages: $(SOURCE_PACKAGES)
build-gn: musl libtest install-packages
cd usystem && ninja -C out/ system && ./copy_packages.sh && ./uncompress_packages.sh && cd ..
build-usystem: build-srcpackages $(USYSTEM_PROJS) build-gn
build-cleanup: build-usystem
cp kernel/.config sysroot/boot/config
# TODO: Do this in kernel/Makefile
$(NM) kernel/vmonyx-unstripped > Kernel.map
fullbuild: build-cleanup
iso: fullbuild
scripts/iso.sh
liveiso: fullbuild
scripts/iso.sh scripts/livecd-initrd.sh
fullbuild-plus-initrd: fullbuild
SYSTEM_ROOT=$(SYSROOT) scripts/geninitrd --compression-method none scripts/default-initrd.sh
fullbuild-plus-full-initrd: fullbuild
SYSTEM_ROOT=$(SYSROOT) scripts/geninitrd --compression-method none scripts/livecd-initrd.sh
qemu-riscv: fullbuild-plus-full-initrd
qemu-system-$(shell scripts/target-triplet-to-arch.sh $(HOST)) -kernel kernel/vmonyx -m 512M -machine virt \
-serial stdio -s -initrd initrd.tar -smp 4
qemu-arm64: fullbuild-plus-initrd
qemu-system-$(shell scripts/target-triplet-to-arch.sh $(HOST)) -kernel kernel/vmonyx -m 512M -machine virt \
-monitor stdio -cpu cortex-a53 -d int -s -no-shutdown -no-reboot -initrd initrd.tar
qemu: iso
qemu-system-$(shell scripts/target-triplet-to-arch.sh $(HOST)) \
-s -cdrom Onyx.iso -drive file=hdd.img,format=raw,media=disk,id=drive,if=none -m 512M \
-monitor stdio -boot d -netdev user,id=u1 -device virtio-net,netdev=u1 \
-object filter-dump,id=f1,netdev=u1,file=net.pcap \
-enable-kvm -cpu host,migratable=on,+invtsc -smp 4 -vga qxl \
-device usb-ehci -device usb-mouse \
-display gtk,gl=on -machine q35 -device nvme,drive=drive,serial=deadbeef
qemu-efi: iso
qemu-system-$(shell scripts/target-triplet-to-arch.sh $(HOST)) \
-s -cdrom Onyx.iso -drive file=hdd.img,format=raw,media=disk -m 512M \
-monitor stdio -boot d -netdev user,id=u1 -device virtio-net,netdev=u1 \
-object filter-dump,id=f1,netdev=u1,file=net.pcap \
-enable-kvm -cpu host,migratable=on,+invtsc -smp 4 -vga qxl \
-device usb-ehci -device usb-mouse \
-display gtk,gl=on -machine q35 -bios OVMF.fd
qemu-serial-stdio: iso
qemu-system-$(shell scripts/target-triplet-to-arch.sh $(HOST)) \
-s -cdrom Onyx.iso -drive file=hdd.img,format=raw,media=disk,aio=io_uring,cache=none,if=none,id=drive -m 4G \
-serial stdio -boot d -netdev user,id=u1 -device virtio-net,netdev=u1 \
-object filter-dump,id=f1,netdev=u1,file=net.pcap \
-enable-kvm -cpu host,migratable=on,+invtsc -smp 4 -vga qxl \
-device usb-ehci -device usb-mouse \
-display gtk,gl=on -machine q35 -device nvme,drive=drive,serial=deadbeef
ci-test-qemu: liveiso
qemu-system-$(shell scripts/target-triplet-to-arch.sh $(HOST)) \
-s -cdrom Onyx.iso -m 1G -serial stdio -boot d -netdev user,id=u1 \
-device virtio-net,netdev=u1 -object filter-dump,id=f1,netdev=u1,file=net.pcap \
-cpu Haswell --enable-kvm -smp 4 -vga qxl -device usb-ehci -device usb-mouse \
-display gtk,gl=on -machine q35
# -device pci-bridge,id=pci_b0,bus=pcie.0,chassis_nr=2,addr=10
# -device ati-vga,bus=pci_b0,addr=1 -device pxb-pcie,id=pcie.1,bus_nr=0x40
#-device ioh3420,id=root_port1,bus=pcie.1 -device ati-vga,bus=root_port1
intel-passthrough-qemu: iso
sudo qemu-system-x86_64 -vga none -display gtk,gl=on \
-device vfio-pci,sysfsdev=/sys/devices/pci0000\:00/0000\:00\:02.0/d507ce65-255a-4b85-88b5-0090410c0b5c,display=on,x-igd-opregion=on,\
ramfb=on,driver=vfio-pci-nohotplug \
-enable-kvm -s -cdrom Onyx.iso \
-machine q35 -drive file=hdd.img,format=raw,media=disk -m 512M \
-boot d -netdev user,id=u1 -device virtio-net,netdev=u1 \
-object filter-dump,id=f1,netdev=u1,file=net.pcap \
-smp 2 -cpu host,migratable=on,+invtsc
virtualbox: iso
virtualbox --startvm Onyx --dbg