1e9886aceSAndy Lutomirskiall:
2e9886aceSAndy Lutomirski
3e9886aceSAndy Lutomirskiinclude ../lib.mk
4e9886aceSAndy Lutomirski
5e9886aceSAndy Lutomirski.PHONY: all all_32 all_64 warn_32bit_failure clean
63f705dfdSAndy Lutomirski
7e21d50f3SAndy LutomirskiTARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs syscall_nt ptrace_syscall \
86c25da5aSAndy Lutomirski			check_initial_reg_state sigreturn ldt_gdt
96c25da5aSAndy LutomirskiTARGETS_C_32BIT_ONLY := entry_from_vm86 syscall_arg_fault test_syscall_vdso unwind_vdso \
100f672809SAndy Lutomirski			test_FCMOV test_FCOMI test_FISTTP \
1165cacec1SAndy Lutomirski			vdso_restorer
123f705dfdSAndy Lutomirski
13c2affbf9SAndy LutomirskiTARGETS_C_32BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_32BIT_ONLY)
14c31b3425SAndy LutomirskiTARGETS_C_64BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_64BIT_ONLY)
15c2affbf9SAndy LutomirskiBINARIES_32 := $(TARGETS_C_32BIT_ALL:%=%_32)
16c31b3425SAndy LutomirskiBINARIES_64 := $(TARGETS_C_64BIT_ALL:%=%_64)
173f705dfdSAndy Lutomirski
183f705dfdSAndy LutomirskiCFLAGS := -O2 -g -std=gnu99 -pthread -Wall
193f705dfdSAndy Lutomirski
20f9ea4a33STyler BakerUNAME_M := $(shell uname -m)
21e9886aceSAndy LutomirskiCAN_BUILD_I386 := $(shell ./check_cc.sh $(CC) trivial_32bit_program.c -m32)
22e9886aceSAndy LutomirskiCAN_BUILD_X86_64 := $(shell ./check_cc.sh $(CC) trivial_64bit_program.c)
233f705dfdSAndy Lutomirski
24e9886aceSAndy Lutomirskiifeq ($(CAN_BUILD_I386),1)
253f705dfdSAndy Lutomirskiall: all_32
26c1e6e5cbSAndy LutomirskiTEST_PROGS += $(BINARIES_32)
27e9886aceSAndy Lutomirskiendif
28e9886aceSAndy Lutomirski
29e9886aceSAndy Lutomirskiifeq ($(CAN_BUILD_X86_64),1)
303f705dfdSAndy Lutomirskiall: all_64
3107620abeSTyler BakerTEST_PROGS += $(BINARIES_64)
323f705dfdSAndy Lutomirskiendif
333f705dfdSAndy Lutomirski
34e9886aceSAndy Lutomirskiall_32: $(BINARIES_32)
353f705dfdSAndy Lutomirski
363f705dfdSAndy Lutomirskiall_64: $(BINARIES_64)
373f705dfdSAndy Lutomirski
383f705dfdSAndy Lutomirskiclean:
393f705dfdSAndy Lutomirski	$(RM) $(BINARIES_32) $(BINARIES_64)
403f705dfdSAndy Lutomirski
41c2affbf9SAndy Lutomirski$(TARGETS_C_32BIT_ALL:%=%_32): %_32: %.c
4257ca6897SDenys Vlasenko	$(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl -lm
433f705dfdSAndy Lutomirski
44c31b3425SAndy Lutomirski$(TARGETS_C_64BIT_ALL:%=%_64): %_64: %.c
453f705dfdSAndy Lutomirski	$(CC) -m64 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl
463f705dfdSAndy Lutomirski
47e9886aceSAndy Lutomirski# x86_64 users should be encouraged to install 32-bit libraries
48e9886aceSAndy Lutomirskiifeq ($(CAN_BUILD_I386)$(CAN_BUILD_X86_64),01)
49e9886aceSAndy Lutomirskiall: warn_32bit_failure
50e9886aceSAndy Lutomirski
51e9886aceSAndy Lutomirskiwarn_32bit_failure:
52e9886aceSAndy Lutomirski	@echo "Warning: you seem to have a broken 32-bit build" 2>&1; 	\
53e9886aceSAndy Lutomirski	echo "environment.  This will reduce test coverage of 64-bit" 2>&1; \
54e9886aceSAndy Lutomirski	echo "kernels.  If you are using a Debian-like distribution," 2>&1; \
55e9886aceSAndy Lutomirski	echo "try:"; 2>&1; \
563f705dfdSAndy Lutomirski	echo "";							\
573f705dfdSAndy Lutomirski	echo "  apt-get install gcc-multilib libc6-i386 libc6-dev-i386"; \
583f705dfdSAndy Lutomirski	echo "";							\
593f705dfdSAndy Lutomirski	echo "If you are using a Fedora-like distribution, try:";	\
603f705dfdSAndy Lutomirski	echo "";							\
613f705dfdSAndy Lutomirski	echo "  yum install glibc-devel.*i686";				\
62e9886aceSAndy Lutomirski	exit 0;
63e9886aceSAndy Lutomirskiendif
64e22438f8SAndy Lutomirski
65e22438f8SAndy Lutomirski# Some tests have additional dependencies.
66e22438f8SAndy Lutomirskisysret_ss_attrs_64: thunks.S
6704235c00SAndy Lutomirskiptrace_syscall_32: raw_syscall_helper_32.S
68c25be94fSDenys Vlasenkotest_syscall_vdso_32: thunks_32.S
69e21d50f3SAndy Lutomirski
70e21d50f3SAndy Lutomirski# check_initial_reg_state is special: it needs a custom entry, and it
71e21d50f3SAndy Lutomirski# needs to be static so that its interpreter doesn't destroy its initial
72e21d50f3SAndy Lutomirski# state.
73e21d50f3SAndy Lutomirskicheck_initial_reg_state_32: CFLAGS += -Wl,-ereal_start -static
74e21d50f3SAndy Lutomirskicheck_initial_reg_state_64: CFLAGS += -Wl,-ereal_start -static
75