aboutsummaryrefslogtreecommitdiff
path: root/tests/scripts/makefile
blob: ed2b2b4b087d6efa6ecf39d94528ad47d075a436 (plain) (blame)
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
.PHONY: all
all: check

ARCH		?= riscv64
CROSS_COMPILE	?= $(ARCH)-unknown-elf-

LLVM		?= 0
COMPILER	!= [ "$(LLVM)" != "0" ] \
			&& echo clang --target="$(CROSS_COMPILE)" \
			|| echo $(CROSS_COMPILE)gcc

include common/arch/$(ARCH)/source.mk

OBFLAGS		:= -ffreestanding -nostdlib -std=c17 -g -O2
INCLUDEFLAGS	:= -I ../include -I.
WARNFLAGS	:= -Wall -Wextra
DEPFLAGS	= -MT $@ -MMD -MP -MF $@.d
COMPILE_TEST	= $(COMPILER) $(WARNFLAGS) $(INCLUDEFLAGS) $(DEPFLAGS) $(OBFLAGS) $(ARCH_FLAGS)

GEN_INITRD	:= cpio -H newc -o >
QEMU		:= qemu-system-$(ARCH) -machine virt -kernel ../kmi.bin \
		   -serial stdio \
		   -monitor none \
		   -nographic \
		   -no-reboot \
		   -m 128M \
		   -initrd

KMI		:= ../kmi.bin
COMMON		:= build/printf.o

build/printf.o: common/printf.c $(KMI)
	$(COMPILE_TEST) -c common/printf.c -o build/printf.o

include tests.mk

.PHONY: check
check: $(TESTS)
	@cd reports; for d in * ; do				\
		if [ ! -f "$$d/OK" ]; then			\
			echo "BROKEN: $$d" ;			\
		elif [ "$$(tail -n1 $$d/OK)" != "OK" ]; then	\
			echo "FAIL: $$d" ;			\
		fi						\
	done
	@echo "Done."