Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
436 lines (357 loc) · 16.6 KB
/
Copy pathMakefile
File metadata and controls
436 lines (357 loc) · 16.6 KB
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# SPDX-License-Identifier: BSD-3-Clause
#
# Copyright (c) 2018, Tulio A M Mendes <tadryanom@hotmail.com>
# All rights reserved.
# See LICENSE for details.
#
# Source: https://github.com/tadryanom/AdrOS
#
# AdrOS Makefile
# Usage: make ARCH=x86 (default) | arm | riscv | mips
ARCH ?= x86
KERNEL_NAME := adros-$(ARCH).bin
# Directories
SRC_DIR := src
BUILD_DIR := build/$(ARCH)
.DEFAULT_GOAL := all
# --- Submodule auto-init ---
# If any submodule source is missing, run git submodule update.
LWIP_SENTINEL := third_party/lwip/src/core/init.c
DOOM_SENTINEL := user/doom/doomgeneric/doomgeneric/doomgeneric.h
$(LWIP_SENTINEL) $(DOOM_SENTINEL):
@echo " GIT Initializing submodules..."
@git submodule update --init --recursive
# Apply lwIP patches (once, after submodule init)
.lwip_patched: $(LWIP_SENTINEL)
@if git apply --check patches/lwip-tcpip-volatile.patch 2>/dev/null; then \
git apply patches/lwip-tcpip-volatile.patch; \
echo " PATCH lwip-tcpip-volatile"; \
fi
@touch $@
# Minimal kernel sources shared across all architectures
KERNEL_COMMON := main.c console.c utils.c cmdline.c driver.c cpu_features.c
C_SOURCES := $(addprefix $(SRC_DIR)/kernel/,$(KERNEL_COMMON))
# HAL sources (architecture-specific)
C_SOURCES += $(wildcard $(SRC_DIR)/hal/$(ARCH)/*.c)
# --- x86 Configuration ---
ifeq ($(ARCH),x86)
# KERNEL TRICK: Dynamically creates fake headers in memory/temporary folder
_DUMMY_HEADERS := $(shell mkdir -p build/_headers && touch build/_headers/string.h build/_headers/stdio.h build/_headers/stdlib.h)
# x86 gets ALL kernel sources, drivers, and mm
C_SOURCES := $(wildcard $(SRC_DIR)/kernel/*.c)
C_SOURCES += $(wildcard $(SRC_DIR)/drivers/*.c)
C_SOURCES += $(wildcard $(SRC_DIR)/mm/*.c)
C_SOURCES += $(wildcard $(SRC_DIR)/hal/$(ARCH)/*.c)
# Default Toolchain Prefix (can be overridden)
ifdef CROSS
TOOLPREFIX = i686-elf-
override CC = $(TOOLPREFIX)gcc
override AS = $(TOOLPREFIX)as
override LD = $(TOOLPREFIX)ld
else
CC ?= $(TOOLPREFIX)gcc
AS ?= $(TOOLPREFIX)as
LD ?= $(TOOLPREFIX)ld
endif
# lwIP sources (NO_SYS=0, IPv4, threaded API + sockets)
LWIPDIR := third_party/lwip/src
LWIP_CORE := $(LWIPDIR)/core/init.c $(LWIPDIR)/core/def.c $(LWIPDIR)/core/inet_chksum.c \
$(LWIPDIR)/core/ip.c $(LWIPDIR)/core/mem.c $(LWIPDIR)/core/memp.c \
$(LWIPDIR)/core/netif.c $(LWIPDIR)/core/pbuf.c $(LWIPDIR)/core/raw.c \
$(LWIPDIR)/core/stats.c $(LWIPDIR)/core/sys.c $(LWIPDIR)/core/tcp.c \
$(LWIPDIR)/core/tcp_in.c $(LWIPDIR)/core/tcp_out.c $(LWIPDIR)/core/timeouts.c \
$(LWIPDIR)/core/udp.c $(LWIPDIR)/core/dns.c
LWIP_IPV4 := $(LWIPDIR)/core/ipv4/etharp.c $(LWIPDIR)/core/ipv4/icmp.c \
$(LWIPDIR)/core/ipv4/ip4.c $(LWIPDIR)/core/ipv4/ip4_addr.c \
$(LWIPDIR)/core/ipv4/ip4_frag.c $(LWIPDIR)/core/ipv4/dhcp.c \
$(LWIPDIR)/core/ipv4/acd.c
LWIP_IPV6 := $(LWIPDIR)/core/ipv6/ethip6.c $(LWIPDIR)/core/ipv6/icmp6.c \
$(LWIPDIR)/core/ipv6/inet6.c $(LWIPDIR)/core/ipv6/ip6.c \
$(LWIPDIR)/core/ipv6/ip6_addr.c $(LWIPDIR)/core/ipv6/ip6_frag.c \
$(LWIPDIR)/core/ipv6/mld6.c $(LWIPDIR)/core/ipv6/nd6.c
LWIP_NETIF := $(LWIPDIR)/netif/ethernet.c
LWIP_API := $(LWIPDIR)/api/api_lib.c $(LWIPDIR)/api/api_msg.c \
$(LWIPDIR)/api/err.c $(LWIPDIR)/api/if_api.c $(LWIPDIR)/api/netbuf.c \
$(LWIPDIR)/api/netifapi.c $(LWIPDIR)/api/tcpip.c
LWIP_SOURCES := $(LWIP_CORE) $(LWIP_IPV4) $(LWIP_IPV6) $(LWIP_NETIF) $(LWIP_API)
NET_SOURCES := $(wildcard $(SRC_DIR)/net/*.c) $(wildcard $(SRC_DIR)/net/lwip_port/*.c)
C_SOURCES += $(NET_SOURCES)
# Mandatory Architecture Flags
ARCH_CFLAGS := -m32 -ffreestanding -fno-builtin -nostdlib -U_FORTIFY_SOURCE -mno-sse -mno-mmx \
-Ibuild/_headers \
-Iinclude -Iinclude/net -Ithird_party/lwip/src/include \
-include utils.h
ARCH_LDFLAGS := -m elf_i386 -T $(SRC_DIR)/arch/x86/linker.ld
ARCH_ASFLAGS := --32
# Default User Flags (Allow override via make CFLAGS=...)
CFLAGS ?= -O2 -Wall -Wextra -Werror -Wno-error=cpp
# Merge Flags
CFLAGS := $(ARCH_CFLAGS) $(CFLAGS) -MMD -MP
LDFLAGS := $(ARCH_LDFLAGS) $(LDFLAGS)
ASFLAGS := $(ARCH_ASFLAGS) $(ASFLAGS)
ASM_SOURCES := $(wildcard $(SRC_DIR)/arch/x86/*.S)
C_SOURCES += $(wildcard $(SRC_DIR)/arch/x86/*.c)
# Userspace cross-compiler (always i686-elf, even when kernel CC differs)
USER_CC ?= i686-elf-gcc
USER_LD ?= i686-elf-ld
USER_AR ?= i686-elf-ar
# User build output directory (under build/$ARCH/ to keep arch-separated)
USER_BUILD := build/$(ARCH)/user
# List of dynamically-linked user commands (built via user/cmds/<name>/Makefile)
USER_CMD_NAMES := echo sh cat ls mkdir rm cp mv touch ln \
head tail wc sort uniq cut \
chmod chown chgrp \
date hostname uptime \
mount umount env kill sleep \
clear ps df free tee \
basename dirname rmdir \
grep id uname dmesg \
printenv tr dd pwd stat \
sed awk who top du find which \
login init initrd_init
# ELF paths for dynamically-linked commands
USER_CMD_ELFS := $(foreach cmd,$(USER_CMD_NAMES),$(USER_BUILD)/cmds/$(cmd)/$(cmd).elf)
# Special builds (not dynamically-linked via common.mk)
FULLTEST_ELF := $(USER_BUILD)/cmds/fulltest/fulltest.elf
LDSO_ELF := $(USER_BUILD)/cmds/ldso/ld.so
PIE_SO := $(USER_BUILD)/cmds/pie_test/libpietest.so
PIE_ELF := $(USER_BUILD)/cmds/pie_test/pie_test.elf
# ulibc
ULIBC_DIR := user/ulibc
ULIBC_SO := $(USER_BUILD)/ulibc/libc.so
ULIBC_LIB := $(USER_BUILD)/ulibc/libulibc.a
# doom
DOOM_ELF := user/doom/doom.elf
INITRD_IMG := initrd.img
MKINITRD := tools/mkinitrd
endif
# --- ARM64 Configuration ---
ifeq ($(ARCH),arm)
CC ?= aarch64-linux-gnu-gcc
AS ?= aarch64-linux-gnu-as
LD ?= aarch64-linux-gnu-ld
OBJCOPY := aarch64-linux-gnu-objcopy
CFLAGS := -ffreestanding -O2 -Wall -Wextra -Werror -Wno-error=cpp -mno-outline-atomics -Iinclude
LDFLAGS := -T $(SRC_DIR)/arch/arm/linker.ld
ASFLAGS :=
ASM_SOURCES := $(wildcard $(SRC_DIR)/arch/arm/*.S)
C_SOURCES += $(wildcard $(SRC_DIR)/arch/arm/*.c)
endif
# --- RISC-V 64 Configuration ---
ifeq ($(ARCH),riscv)
CC ?= riscv64-linux-gnu-gcc
AS ?= riscv64-linux-gnu-as
LD ?= riscv64-linux-gnu-ld
OBJCOPY := riscv64-linux-gnu-objcopy
CFLAGS := -ffreestanding -O2 -Wall -Wextra -Werror -Wno-error=cpp -Iinclude -mcmodel=medany
LDFLAGS := -T $(SRC_DIR)/arch/riscv/linker.ld
ASFLAGS :=
ASM_SOURCES := $(wildcard $(SRC_DIR)/arch/riscv/*.S)
C_SOURCES += $(wildcard $(SRC_DIR)/arch/riscv/*.c)
endif
# --- MIPS 32 Configuration ---
ifeq ($(ARCH),mips)
CC ?= mipsel-linux-gnu-gcc
AS ?= mipsel-linux-gnu-as
LD ?= mipsel-linux-gnu-ld
CFLAGS := -ffreestanding -O2 -Wall -Wextra -Werror -Wno-error=cpp -Iinclude -mabi=32 -march=mips32r2 -mno-abicalls -fno-pic -G0
LDFLAGS := -T $(SRC_DIR)/arch/mips/linker.ld
ASFLAGS := -march=mips32r2
ASM_SOURCES := $(wildcard $(SRC_DIR)/arch/mips/*.S)
C_SOURCES += $(wildcard $(SRC_DIR)/arch/mips/*.c)
endif
# lwIP object files (compiled from third_party, separate pattern)
LWIP_OBJ := $(patsubst %.c, $(BUILD_DIR)/lwip/%.o, $(LWIP_SOURCES))
# Object generation
OBJ := $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(C_SOURCES))
OBJ += $(patsubst $(SRC_DIR)/%.S, $(BUILD_DIR)/%.o, $(ASM_SOURCES))
OBJ += $(LWIP_OBJ)
QEMU_DFLAGS :=
ifneq ($(QEMU_DEBUG),)
QEMU_DFLAGS := -d guest_errors,cpu_reset -D qemu.log
endif
ifneq ($(QEMU_INT),)
QEMU_DFLAGS := $(QEMU_DFLAGS) -d int
endif
BOOT_OBJ := $(BUILD_DIR)/arch/$(ARCH)/boot.o
KERNEL_OBJ := $(filter-out $(BOOT_OBJ), $(OBJ))
all: $(KERNEL_NAME)
$(KERNEL_NAME): .lwip_patched $(OBJ)
@echo " LD $@"
@$(LD) $(LDFLAGS) -n -o $@ $(BOOT_OBJ) $(KERNEL_OBJ) $(shell $(CC) $(ARCH_CFLAGS) -print-libgcc-file-name)
iso: $(KERNEL_NAME) $(INITRD_IMG)
@mkdir -p iso/boot
@cp -f $(KERNEL_NAME) iso/boot/$(KERNEL_NAME)
@cp -f $(INITRD_IMG) iso/boot/$(INITRD_IMG)
@echo " GRUB-MKRESCUE adros-$(ARCH).iso"
@grub-mkrescue -o adros-$(ARCH).iso iso > /dev/null
$(MKINITRD): tools/mkinitrd.c include/xxhash32.h
@gcc -Iinclude tools/mkinitrd.c -o $(MKINITRD)
# --- ulibc build (output into build/$ARCH/user/ulibc/) ---
ULIBC_BUILDDIR := $(CURDIR)/$(USER_BUILD)/ulibc
$(ULIBC_LIB) $(ULIBC_SO): FORCE
@$(MAKE) -C $(ULIBC_DIR) CC="$(USER_CC)" AS="$(USER_CC:gcc=as)" AR="$(USER_AR)" LD="$(USER_LD)" \
BUILDDIR="$(ULIBC_BUILDDIR)" \
$(ULIBC_BUILDDIR)/libulibc.a $(ULIBC_BUILDDIR)/libc.so --no-print-directory
FORCE:
# --- Special builds (fulltest, ldso, pie_test) ---
$(FULLTEST_ELF): user/cmds/fulltest/fulltest.c user/cmds/fulltest/errno.c user/linker.ld
@$(MAKE) --no-print-directory -C user/cmds/fulltest TOPDIR=$(CURDIR) BUILDDIR=$(CURDIR)/$(USER_BUILD)/cmds/fulltest USER_CC="$(USER_CC)"
$(LDSO_ELF): user/cmds/ldso/ldso.c user/ldso_linker.ld
@$(MAKE) --no-print-directory -C user/cmds/ldso TOPDIR=$(CURDIR) BUILDDIR=$(CURDIR)/$(USER_BUILD)/cmds/ldso USER_CC="$(USER_CC)"
$(PIE_SO) $(PIE_ELF): user/cmds/pie_test/pie_main.c user/cmds/pie_test/pie_func.c user/pie_linker.ld
@$(MAKE) --no-print-directory -C user/cmds/pie_test TOPDIR=$(CURDIR) BUILDDIR=$(CURDIR)/$(USER_BUILD)/cmds/pie_test USER_CC="$(USER_CC)" USER_LD="$(USER_LD)"
# --- Dynamically-linked user commands (generic rule via sub-Makefiles) ---
# Use absolute paths so they work from sub-Makefile directories
ABS_ULIBC := $(CURDIR)/$(ULIBC_DIR)
ABS_DYN_CC := $(USER_CC) -m32 -ffreestanding -nostdlib -O2 -Wall -Wextra -fPIC -fno-plt -I$(ABS_ULIBC)/include
ABS_DYN_LD := $(USER_LD) -m elf_i386 --dynamic-linker=/lib/ld.so -T $(CURDIR)/user/dyn_linker.ld -L$(ULIBC_BUILDDIR) -rpath /lib --unresolved-symbols=ignore-in-shared-libs -z noexecstack
# Generate build rules for each dynamically-linked command
define USER_CMD_RULE
$(USER_BUILD)/cmds/$(1)/$(1).elf: user/cmds/$(1)/$(1).c user/dyn_linker.ld $(ULIBC_SO) $(ULIBC_LIB)
@$$(MAKE) --no-print-directory -C user/cmds/$(1) TOPDIR=$$(CURDIR) \
BUILDDIR=$$(CURDIR)/$(USER_BUILD)/cmds/$(1) \
DYN_CC="$$(ABS_DYN_CC)" DYN_LD="$$(ABS_DYN_LD)" CRT0="$(ULIBC_BUILDDIR)/crt0.o"
endef
$(foreach cmd,$(USER_CMD_NAMES),$(eval $(call USER_CMD_RULE,$(cmd))))
# Commands that go to /bin/ in rootfs (all except init)
USER_BIN_NAMES := $(filter-out init,$(USER_CMD_NAMES))
# Build INITRD_FILES list: <elf>:<rootfs-path>
FSTAB := rootfs/etc/fstab
RCS := rootfs/etc/init.d/rcS
PASSWD := rootfs/etc/passwd
SHADOW := rootfs/etc/shadow
INITRD_FILES := $(FULLTEST_ELF):sbin/fulltest \
$(USER_BUILD)/cmds/init/init.elf:sbin/init \
$(foreach cmd,$(USER_BIN_NAMES),$(USER_BUILD)/cmds/$(cmd)/$(cmd).elf:bin/$(cmd)) \
$(LDSO_ELF):lib/ld.so $(ULIBC_SO):lib/libc.so \
$(PIE_SO):lib/libpietest.so $(PIE_ELF):bin/pie_test \
$(FSTAB):etc/fstab $(RCS):etc/init.d/rcS $(PASSWD):etc/passwd $(SHADOW):etc/shadow
INITRD_DEPS := $(MKINITRD) $(FULLTEST_ELF) $(USER_CMD_ELFS) $(LDSO_ELF) $(ULIBC_SO) $(PIE_SO) $(PIE_ELF) $(FSTAB) $(RCS) $(PASSWD) $(SHADOW)
# doom (build via 'make doom', included in initrd if present)
doom: $(DOOM_SENTINEL) $(ULIBC_LIB) $(ULIBC_SO)
@$(MAKE) --no-print-directory -C user/doom TOPDIR=$(CURDIR) ULIBC_BUILDDIR="$(ULIBC_BUILDDIR)"
# Include doom.elf if it has been built
ifneq ($(wildcard $(DOOM_ELF)),)
INITRD_FILES += $(DOOM_ELF):usr/games/doom
INITRD_DEPS += $(DOOM_ELF)
endif
$(INITRD_IMG): $(INITRD_DEPS)
@./$(MKINITRD) $(INITRD_IMG) $(INITRD_FILES)
run: iso
@rm -f serial.log qemu.log
@test -f disk.img || dd if=/dev/zero of=disk.img bs=1M count=4 2>/dev/null
@qemu-system-i386 -boot d -cdrom adros-$(ARCH).iso -m 128M -display none \
-drive file=disk.img,if=ide,format=raw \
-nic user,model=e1000 \
-serial file:serial.log -monitor none -no-reboot -no-shutdown \
-cpu qemu32,+nx \
$(QEMU_DFLAGS)
run-arm: adros-arm.bin
@rm -f serial-arm.log
@qemu-system-aarch64 -M virt -cpu cortex-a57 -m 128M -nographic \
-kernel adros-arm.bin -serial mon:stdio $(QEMU_DFLAGS)
run-riscv: adros-riscv.bin
@rm -f serial-riscv.log
@qemu-system-riscv64 -M virt -m 128M -nographic -bios none \
-kernel adros-riscv.bin -serial mon:stdio $(QEMU_DFLAGS)
run-mips: adros-mips.bin
@rm -f serial-mips.log
@qemu-system-mipsel -M malta -m 128M -nographic \
-kernel adros-mips.bin -serial mon:stdio $(QEMU_DFLAGS)
# ---- Static Analysis ----
cppcheck:
@cppcheck --version >/dev/null
@cppcheck --quiet --enable=warning,performance,portability --error-exitcode=1 \
-I include $(SRC_DIR)
# Sparse: kernel-oriented semantic checker (type safety, NULL, bitwise vs logical)
SPARSE_FLAGS := -m32 -D__i386__ -D__linux__ -Iinclude -Iinclude/net -Ithird_party/lwip/src/include
SPARSE_SRCS := $(filter-out $(wildcard $(SRC_DIR)/arch/arm/*.c) \
$(wildcard $(SRC_DIR)/arch/riscv/*.c) \
$(wildcard $(SRC_DIR)/arch/mips/*.c) \
$(wildcard $(SRC_DIR)/hal/arm/*.c) \
$(wildcard $(SRC_DIR)/hal/riscv/*.c) \
$(wildcard $(SRC_DIR)/hal/mips/*.c), $(C_SOURCES))
sparse:
@echo "[SPARSE] Running sparse on $(words $(SPARSE_SRCS)) files..."
@fail=0; \
for f in $(SPARSE_SRCS); do \
sparse $(SPARSE_FLAGS) $$f 2>&1; \
done
@echo "[SPARSE] Done."
# GCC -fanalyzer: interprocedural static analysis (use-after-free, NULL deref, etc)
ANALYZER_FLAGS := -m32 -ffreestanding -fanalyzer -fsyntax-only -Iinclude -Iinclude/net -Ithird_party/lwip/src/include -O2 -Wno-cpp
analyzer:
@echo "[ANALYZER] Running gcc -fanalyzer on $(words $(SPARSE_SRCS)) files..."
@fail=0; \
for f in $(SPARSE_SRCS); do \
$(CC) $(ANALYZER_FLAGS) $$f 2>&1 | grep -v "^$$" || true; \
done
@echo "[ANALYZER] Done."
# Combined static analysis: cppcheck + sparse
check: cppcheck sparse
@echo "[CHECK] All static analysis passed."
# ---- Automated Smoke Test (QEMU + expect) ----
SMOKE_SMP ?= 4
SMOKE_TIMEOUT ?= 120
test: iso
@echo "[TEST] Running smoke test (SMP=$(SMOKE_SMP), timeout=$(SMOKE_TIMEOUT)s)..."
@expect tests/smoke_test.exp $(SMOKE_SMP) $(SMOKE_TIMEOUT)
test-1cpu: iso
@echo "[TEST] Running smoke test (SMP=1, timeout=50s)..."
@expect tests/smoke_test.exp 1 50
test-battery: iso
@echo "[TEST] Running full test battery (multi-disk, ping, VFS)..."
@expect tests/test_battery.exp $(SMOKE_TIMEOUT)
# ---- Host-Side Unit Tests ----
test-host:
@mkdir -p build/host
@echo "[TEST-HOST] Compiling tests/test_utils.c..."
@gcc -m32 -Wall -Wextra -Werror -Iinclude -o build/host/test_utils tests/test_utils.c
@./build/host/test_utils
@echo "[TEST-HOST] Compiling tests/test_security.c..."
@gcc -m32 -Wall -Wextra -Werror -Iinclude -o build/host/test_security tests/test_security.c
@./build/host/test_security
@echo "[TEST-HOST] Running userspace utility tests..."
@bash tests/test_host_utils.sh
# ---- GDB Scripted Checks (requires QEMU + GDB) ----
test-gdb: $(KERNEL_NAME) iso
@echo "[TEST-GDB] Starting QEMU with GDB stub..."
@rm -f serial.log
@test -f disk.img || dd if=/dev/zero of=disk.img bs=1M count=4 2>/dev/null
@qemu-system-i386 -smp 4 -boot d -cdrom adros-$(ARCH).iso -m 128M -display none \
-drive file=disk.img,if=ide,format=raw \
-serial file:serial.log -monitor none -no-reboot -no-shutdown \
-s -S &
@sleep 1
@gdb -batch -nx -x tests/gdb_checks.py adros-$(ARCH).bin || true
@-pkill -f "qemu-system-i386.*-s -S" 2>/dev/null || true
# ---- All Tests ----
test-all: check test-host test
@echo "[TEST-ALL] All tests passed."
scan-build:
@command -v scan-build >/dev/null
@scan-build --status-bugs $(MAKE) ARCH=$(ARCH) $(if $(CROSS),CROSS=$(CROSS),) all
mkinitrd-asan: $(FULLTEST_ELF)
@mkdir -p build/host
@gcc -g -O1 -fno-omit-frame-pointer -fsanitize=address,undefined tools/mkinitrd.c -o build/host/mkinitrd-asan
@./build/host/mkinitrd-asan build/host/$(INITRD_IMG).asan $(FULLTEST_ELF):sbin/fulltest
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(dir $@)
@echo " CC $<"
@$(CC) $(CFLAGS) -c $< -o $@
-include $(wildcard $(BUILD_DIR)/**/*.d)
# lwIP sources (compiled with relaxed warnings)
$(BUILD_DIR)/lwip/%.o: %.c
@mkdir -p $(dir $@)
@echo " CC $< (lwIP)"
@$(CC) $(CFLAGS) -Wno-address -w -c $< -o $@
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.S
@mkdir -p $(dir $@)
@echo " AS $<"
@$(AS) $(ASFLAGS) $< -o $@
clean:
rm -rf build $(KERNEL_NAME) $(INITRD_IMG) adros-*.iso .lwip_patched
@$(MAKE) -C user/ulibc clean --no-print-directory 2>/dev/null || true
@if [ -f user/doom/Makefile ]; then $(MAKE) -C user/doom clean --no-print-directory 2>/dev/null || true; fi
.PHONY: all clean iso run run-arm run-riscv run-mips doom cppcheck sparse analyzer check test test-1cpu test-battery test-host test-gdb test-all scan-build mkinitrd-asan