13f705dfdSAndy Lutomirski.PHONY: all all_32 all_64 check_build32 clean run_tests
23f705dfdSAndy Lutomirski
3e22438f8SAndy LutomirskiTARGETS_C_BOTHBITS := sigreturn single_step_syscall sysret_ss_attrs
43f705dfdSAndy Lutomirski
53f705dfdSAndy LutomirskiBINARIES_32 := $(TARGETS_C_BOTHBITS:%=%_32)
63f705dfdSAndy LutomirskiBINARIES_64 := $(TARGETS_C_BOTHBITS:%=%_64)
73f705dfdSAndy Lutomirski
83f705dfdSAndy LutomirskiCFLAGS := -O2 -g -std=gnu99 -pthread -Wall
93f705dfdSAndy Lutomirski
103f705dfdSAndy LutomirskiUNAME_P := $(shell uname -p)
113f705dfdSAndy Lutomirski
123f705dfdSAndy Lutomirski# Always build 32-bit tests
133f705dfdSAndy Lutomirskiall: all_32
143f705dfdSAndy Lutomirski
153f705dfdSAndy Lutomirski# If we're on a 64-bit host, build 64-bit tests as well
163f705dfdSAndy Lutomirskiifeq ($(shell uname -p),x86_64)
173f705dfdSAndy Lutomirskiall: all_64
183f705dfdSAndy Lutomirskiendif
193f705dfdSAndy Lutomirski
203f705dfdSAndy Lutomirskiall_32: check_build32 $(BINARIES_32)
213f705dfdSAndy Lutomirski
223f705dfdSAndy Lutomirskiall_64: $(BINARIES_64)
233f705dfdSAndy Lutomirski
243f705dfdSAndy Lutomirskiclean:
253f705dfdSAndy Lutomirski	$(RM) $(BINARIES_32) $(BINARIES_64)
263f705dfdSAndy Lutomirski
273f705dfdSAndy Lutomirskirun_tests:
283f705dfdSAndy Lutomirski	./run_x86_tests.sh
293f705dfdSAndy Lutomirski
303f705dfdSAndy Lutomirski$(TARGETS_C_BOTHBITS:%=%_32): %_32: %.c
313f705dfdSAndy Lutomirski	$(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl
323f705dfdSAndy Lutomirski
333f705dfdSAndy Lutomirski$(TARGETS_C_BOTHBITS:%=%_64): %_64: %.c
343f705dfdSAndy Lutomirski	$(CC) -m64 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl
353f705dfdSAndy Lutomirski
363f705dfdSAndy Lutomirskicheck_build32:
373f705dfdSAndy Lutomirski	@if ! $(CC) -m32 -o /dev/null trivial_32bit_program.c; then	\
383f705dfdSAndy Lutomirski	  echo "Warning: you seem to have a broken 32-bit build" 2>&1; 	\
393f705dfdSAndy Lutomirski	  echo "environment.  If you are using a Debian-like";		\
403f705dfdSAndy Lutomirski	  echo " distribution, try:"; 					\
413f705dfdSAndy Lutomirski	  echo "";							\
423f705dfdSAndy Lutomirski	  echo "  apt-get install gcc-multilib libc6-i386 libc6-dev-i386"; \
433f705dfdSAndy Lutomirski	  echo "";							\
443f705dfdSAndy Lutomirski	  echo "If you are using a Fedora-like distribution, try:";	\
453f705dfdSAndy Lutomirski	  echo "";							\
463f705dfdSAndy Lutomirski	  echo "  yum install glibc-devel.*i686";			\
473f705dfdSAndy Lutomirski	  exit 1;							\
483f705dfdSAndy Lutomirski	fi
49e22438f8SAndy Lutomirski
50e22438f8SAndy Lutomirski# Some tests have additional dependencies.
51e22438f8SAndy Lutomirskisysret_ss_attrs_64: thunks.S
52