-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmakefile
183 lines (127 loc) · 5.5 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
# Makefile for Orion-X3/Orion-X4/mx and derivatives
# Written in 2011
# This makefile is licensed under the WTFPL
export ARCH := x86_64
export PROJECT_DIR := $(shell pwd)
export UNAME := $(shell uname)
export SYSROOT := $(PROJECT_DIR)/build/sysroot
export INITRD_DIR := $(PROJECT_DIR)/build/initrd
export TOOLCHAIN := $(PROJECT_DIR)/build/toolchain
export CC := $(PROJECT_DIR)/build/toolchain/bin/x86_64-orionx-gcc
export CXX := $(PROJECT_DIR)/build/toolchain/bin/x86_64-orionx-g++
export AS := $(PROJECT_DIR)/build/toolchain/bin/x86_64-orionx-as
export LD := $(PROJECT_DIR)/build/toolchain/bin/x86_64-orionx-ld
export OBJCOPY := $(PROJECT_DIR)/build/toolchain/bin/x86_64-orionx-objcopy
export READELF := $(PROJECT_DIR)/build/toolchain/bin/x86_64-orionx-readelf
export STRIP := $(PROJECT_DIR)/build/toolchain/bin/x86_64-orionx-strip
export AR := $(PROJECT_DIR)/build/toolchain/bin/x86_64-orionx-ar
export RANLIB := $(PROJECT_DIR)/build/toolchain/bin/x86_64-orionx-ranlib
export INITRD := $(SYSROOT)/boot/initrd.tar
# used by kernel, libkrt, and libtinflate
export KERNEL_SSE_DISABLERS := -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-80387 -mno-fp-ret-in-387
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-builtin-variables
MEMORY := 256
QEMU_UEFI_BIOS := -bios utils/ovmf-x64/OVMF-pure-efi.fd
QEMU_UEFI_DISKIMG := -drive format=raw,file=build/disk.img
QEMU_BIOS_DISKIMG := -drive format=raw,file=build/disk-bios.img
QEMU_CPU_CONFIG := -smp 4 -cpu qemu64,fsgsbase=true,+xsave,+xsaveopt,+smep,+smap
QEMU_FLAGS := $(QEMU_CPU_CONFIG) -m $(MEMORY) -nodefaults -no-shutdown -no-reboot -vga std # -d exception,cpu_reset,int
QEMU_SERIAL := -chardev stdio,id=char0,logfile=build/serialout.log -serial chardev:char0
QEMU_E9_PORT_STDIO := -chardev stdio,id=qemu-debug-out -device isa-debugcon,chardev=qemu-debug-out
QEMU_E9_PORT_FILE := -chardev file,id=qemu-debug-out,path=build/serialout.log -device isa-debugcon,chardev=qemu-debug-out
# apparently osx echo does not do -e
UNAME_IDENT := $(shell uname)
ifeq ("$(UNAME_IDENT)","Darwin")
ECHO_CMD := "echo"
else
ECHO_CMD := "echo -e"
endif
BOCHS ?= bochs
QEMU ?= qemu-system-x86_64
VIRTUALBOX ?= VirtualBoxVM
.DEFAULT_GOAL = all
.PHONY: all clean build diskimage qemu debug clean-kernel export-headers make-initrd
all: qemu
run-only:
# starting qemu
@$(QEMU) $(QEMU_UEFI_BIOS) $(QEMU_UEFI_DISKIMG) $(QEMU_FLAGS) $(QEMU_E9_PORT_STDIO)
debug: diskimage
# starting qemu
@$(QEMU) $(QEMU_UEFI_BIOS) $(QEMU_UEFI_DISKIMG) $(QEMU_FLAGS) $(QEMU_E9_PORT_FILE) -monitor stdio -s
qemu: diskimage
# starting qemu
@$(QEMU) $(QEMU_UEFI_BIOS) $(QEMU_UEFI_DISKIMG) $(QEMU_FLAGS) $(QEMU_SERIAL) -s
qemu-monitor: diskimage
# starting qemu
@$(QEMU) $(QEMU_UEFI_BIOS) $(QEMU_UEFI_DISKIMG) $(QEMU_FLAGS) $(QEMU_E9_PORT_FILE) -monitor stdio
bios: diskimage
# starting qemu (bios)
@$(QEMU) $(QEMU_FLAGS) $(QEMU_BIOS_DISKIMG) $(QEMU_E9_PORT_STDIO)
bios-debug: diskimage
# starting qemu (bios)
@$(QEMU) $(QEMU_FLAGS) $(QEMU_BIOS_DISKIMG) $(QEMU_E9_PORT_FILE) -s -S -monitor stdio
vbox-debug: diskimage
# starting virtualbox (debug)
@$(VIRTUALBOX) --startvm "nx" --debug
vbox: diskimage
# starting virtualbox
@$(VIRTUALBOX) --startvm "nx"
bochs: diskimage
# starting bochs
@$(BOCHS) -qf utils/bochsrc.bxrc
diskimage: build
@utils/tools/update-diskimage.sh
make-folders:
@mkdir -p $(SYSROOT)/usr/include/nx/
@mkdir -p $(SYSROOT)/usr/include/svr/
@mkdir -p $(INITRD_DIR)/sys
@mkdir -p $(INITRD_DIR)/boot
@mkdir -p $(INITRD_DIR)/drivers
@mkdir -p $(INITRD_DIR)/services
export-headers: $(shell find libs/libc/include -type f) $(shell find libs/libm/include -type f) $(shell find libs/libnxsc/include -type f) $(shell find kernel/include/export -type f) $(shell find services/*/include -type f) | make-folders
-@find $(SYSROOT)/usr/include/ -type f | xargs rm
@cp -R kernel/include/export/* $(SYSROOT)/usr/include/nx/
@$(MAKE) -s -C libs/zst install-headers
@$(MAKE) -s -C libs/libc install-headers
@$(MAKE) -s -C libs/libm install-headers
@$(MAKE) -s -C libs/libnxsc install-headers
@$(MAKE) -s -C drivers install-headers
@$(MAKE) -s -C services install-headers
$(SYSROOT)/boot/nxkernel64: $(shell find kernel)
@$(MAKE) -s -C kernel
$(SYSROOT)/boot/bfxloader: $(shell find bfx)
@$(MAKE) -s -C bfx
compile: export-headers
@$(MAKE) -s -C libs/libc
@$(MAKE) -s -C libs/libm
@$(MAKE) -s -C libs/libnxsc
@$(MAKE) -s -C libs/libkrt
@$(MAKE) -s -C libs/miniz
@$(MAKE) -s -C efx
@$(MAKE) -s -C bfx
@$(MAKE) -s -C kernel
@$(MAKE) -s -C drivers
@$(MAKE) -s -C services
$(INITRD).gz: $(shell find $(INITRD_DIR) | sed 's/ /?/g') compile
@utils/tools/update-initrd.sh
make-initrd: $(INITRD).gz
build: make-initrd
clean:
@find "efx" -name "*.o" -delete
@find "bfx" -name "*.o" -delete
@find "libs" -name "*.o" -delete
@find "efx" -name "*.h.d" -delete
@find "bfx" -name "*.h.d" -delete
@find "libs" -name "*.h.d" -delete
@find "efx" -name "*.cpp.d" -delete
@find "bfx" -name "*.cpp.d" -delete
@find "libs" -name "*.cpp.d" -delete
@$(MAKE) -s -C kernel clean
@rm -f $(SYSROOT)/boot/efxloader
@rm -f $(SYSROOT)/boot/bfxloader
@rm -f $(SYSROOT)/boot/nxkernel64
@rm -f $(SYSROOT)/usr/lib/*.a
@rm -rf $(SYSROOT)/usr/include/*
clean-kernel:
@$(MAKE) -s -C kernel clean