1e9886aceSAndy Lutomirskiall:
2e9886aceSAndy Lutomirski
3e9886aceSAndy Lutomirskiinclude ../lib.mk
4e9886aceSAndy Lutomirski
5e9886aceSAndy Lutomirski.PHONY: all all_32 all_64 warn_32bit_failure clean
63f705dfdSAndy Lutomirski
70f672809SAndy LutomirskiTARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs syscall_nt ptrace_syscall
8ce4d72faSLinus TorvaldsTARGETS_C_32BIT_ONLY := entry_from_vm86 syscall_arg_fault sigreturn test_syscall_vdso unwind_vdso \
90f672809SAndy Lutomirski			test_FCMOV test_FCOMI test_FISTTP \
100f672809SAndy Lutomirski			ldt_gdt
113f705dfdSAndy Lutomirski
12c2affbf9SAndy LutomirskiTARGETS_C_32BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_32BIT_ONLY)
13c2affbf9SAndy LutomirskiBINARIES_32 := $(TARGETS_C_32BIT_ALL:%=%_32)
143f705dfdSAndy LutomirskiBINARIES_64 := $(TARGETS_C_BOTHBITS:%=%_64)
153f705dfdSAndy Lutomirski
163f705dfdSAndy LutomirskiCFLAGS := -O2 -g -std=gnu99 -pthread -Wall
173f705dfdSAndy Lutomirski
18f9ea4a33STyler BakerUNAME_M := $(shell uname -m)
19e9886aceSAndy LutomirskiCAN_BUILD_I386 := $(shell ./check_cc.sh $(CC) trivial_32bit_program.c -m32)
20e9886aceSAndy LutomirskiCAN_BUILD_X86_64 := $(shell ./check_cc.sh $(CC) trivial_64bit_program.c)
213f705dfdSAndy Lutomirski
22e9886aceSAndy Lutomirskiifeq ($(CAN_BUILD_I386),1)
233f705dfdSAndy Lutomirskiall: all_32
24c1e6e5cbSAndy LutomirskiTEST_PROGS += $(BINARIES_32)
25e9886aceSAndy Lutomirskiendif
26e9886aceSAndy Lutomirski
27e9886aceSAndy Lutomirskiifeq ($(CAN_BUILD_X86_64),1)
283f705dfdSAndy Lutomirskiall: all_64
2907620abeSTyler BakerTEST_PROGS += $(BINARIES_64)
303f705dfdSAndy Lutomirskiendif
313f705dfdSAndy Lutomirski
32e9886aceSAndy Lutomirskiall_32: $(BINARIES_32)
333f705dfdSAndy Lutomirski
343f705dfdSAndy Lutomirskiall_64: $(BINARIES_64)
353f705dfdSAndy Lutomirski
363f705dfdSAndy Lutomirskiclean:
373f705dfdSAndy Lutomirski	$(RM) $(BINARIES_32) $(BINARIES_64)
383f705dfdSAndy Lutomirski
39c2affbf9SAndy Lutomirski$(TARGETS_C_32BIT_ALL:%=%_32): %_32: %.c
4057ca6897SDenys Vlasenko	$(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl -lm
413f705dfdSAndy Lutomirski
423f705dfdSAndy Lutomirski$(TARGETS_C_BOTHBITS:%=%_64): %_64: %.c
433f705dfdSAndy Lutomirski	$(CC) -m64 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl
443f705dfdSAndy Lutomirski
45e9886aceSAndy Lutomirski# x86_64 users should be encouraged to install 32-bit libraries
46e9886aceSAndy Lutomirskiifeq ($(CAN_BUILD_I386)$(CAN_BUILD_X86_64),01)
47e9886aceSAndy Lutomirskiall: warn_32bit_failure
48e9886aceSAndy Lutomirski
49e9886aceSAndy Lutomirskiwarn_32bit_failure:
50e9886aceSAndy Lutomirski	@echo "Warning: you seem to have a broken 32-bit build" 2>&1; 	\
51e9886aceSAndy Lutomirski	echo "environment.  This will reduce test coverage of 64-bit" 2>&1; \
52e9886aceSAndy Lutomirski	echo "kernels.  If you are using a Debian-like distribution," 2>&1; \
53e9886aceSAndy Lutomirski	echo "try:"; 2>&1; \
543f705dfdSAndy Lutomirski	echo "";							\
553f705dfdSAndy Lutomirski	echo "  apt-get install gcc-multilib libc6-i386 libc6-dev-i386"; \
563f705dfdSAndy Lutomirski	echo "";							\
573f705dfdSAndy Lutomirski	echo "If you are using a Fedora-like distribution, try:";	\
583f705dfdSAndy Lutomirski	echo "";							\
593f705dfdSAndy Lutomirski	echo "  yum install glibc-devel.*i686";				\
60e9886aceSAndy Lutomirski	exit 0;
61e9886aceSAndy Lutomirskiendif
62e22438f8SAndy Lutomirski
63e22438f8SAndy Lutomirski# Some tests have additional dependencies.
64e22438f8SAndy Lutomirskisysret_ss_attrs_64: thunks.S
6504235c00SAndy Lutomirskiptrace_syscall_32: raw_syscall_helper_32.S
66c25be94fSDenys Vlasenkotest_syscall_vdso_32: thunks_32.S
67