1#
2# x86 system tests
3#
4# This currently builds only for i386. The common C code is built
5# with standard compiler flags however so we can support both by
6# adding additional boot files for x86_64.
7#
8
9I386_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/i386/system
10X64_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/x86_64/system
11
12# These objects provide the basic boot code and helper functions for all tests
13CRT_OBJS=boot.o
14
15ifeq ($(TARGET_X86_64), y)
16CRT_PATH=$(X64_SYSTEM_SRC)
17CFLAGS=-march=x86-64
18LINK_SCRIPT=$(X64_SYSTEM_SRC)/kernel.ld
19LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_x86_64
20else
21CRT_PATH=$(I386_SYSTEM_SRC)
22CFLAGS+=-m32
23LINK_SCRIPT=$(I386_SYSTEM_SRC)/kernel.ld
24LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_i386
25endif
26CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC)
27LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
28
29TESTS+=$(MULTIARCH_TESTS)
30
31# building head blobs
32.PRECIOUS: $(CRT_OBJS)
33
34%.o: $(CRT_PATH)/%.S
35	$(CC) $(CFLAGS) -c $< -o $@
36
37# Build and link the tests
38%: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
39	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
40
41memory: CFLAGS+=-DCHECK_UNALIGNED=1
42
43# Running
44QEMU_OPTS+=-device isa-debugcon,chardev=output -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel
45