13f705dfdSAndy Lutomirski.PHONY: all all_32 all_64 check_build32 clean run_tests 23f705dfdSAndy Lutomirski 30a15584dSAndy LutomirskiTARGETS_C_BOTHBITS := sigreturn single_step_syscall 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 101872d01aSTyler Bakerall: 111872d01aSTyler Baker 12f9ea4a33STyler BakerUNAME_M := $(shell uname -m) 133f705dfdSAndy Lutomirski 141872d01aSTyler Bakerifeq ($(CROSS_COMPILE),) 153f705dfdSAndy Lutomirski# Always build 32-bit tests 163f705dfdSAndy Lutomirskiall: all_32 1707620abeSTyler Baker# Install 32-bit tests 1807620abeSTyler BakerTEST_PROGS += $(BINARIES_32) run_x86_tests.sh 193f705dfdSAndy Lutomirski# If we're on a 64-bit host, build 64-bit tests as well 20f9ea4a33STyler Bakerifeq ($(UNAME_M),x86_64) 213f705dfdSAndy Lutomirskiall: all_64 2207620abeSTyler Baker# Install 64-bit tests 2307620abeSTyler BakerTEST_PROGS += $(BINARIES_64) 243f705dfdSAndy Lutomirskiendif 251872d01aSTyler Bakerendif 263f705dfdSAndy Lutomirski 273f705dfdSAndy Lutomirskiall_32: check_build32 $(BINARIES_32) 283f705dfdSAndy Lutomirski 293f705dfdSAndy Lutomirskiall_64: $(BINARIES_64) 303f705dfdSAndy Lutomirski 3107620abeSTyler Bakerinclude ../lib.mk 3207620abeSTyler Baker 333f705dfdSAndy Lutomirskiclean: 343f705dfdSAndy Lutomirski $(RM) $(BINARIES_32) $(BINARIES_64) 353f705dfdSAndy Lutomirski 363f705dfdSAndy Lutomirskirun_tests: 373f705dfdSAndy Lutomirski ./run_x86_tests.sh 383f705dfdSAndy Lutomirski 393f705dfdSAndy Lutomirski$(TARGETS_C_BOTHBITS:%=%_32): %_32: %.c 403f705dfdSAndy Lutomirski $(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl 413f705dfdSAndy Lutomirski 423f705dfdSAndy Lutomirski$(TARGETS_C_BOTHBITS:%=%_64): %_64: %.c 433f705dfdSAndy Lutomirski $(CC) -m64 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl 443f705dfdSAndy Lutomirski 453f705dfdSAndy Lutomirskicheck_build32: 463f705dfdSAndy Lutomirski @if ! $(CC) -m32 -o /dev/null trivial_32bit_program.c; then \ 473f705dfdSAndy Lutomirski echo "Warning: you seem to have a broken 32-bit build" 2>&1; \ 483f705dfdSAndy Lutomirski echo "environment. If you are using a Debian-like"; \ 493f705dfdSAndy Lutomirski echo " distribution, try:"; \ 503f705dfdSAndy Lutomirski echo ""; \ 513f705dfdSAndy Lutomirski echo " apt-get install gcc-multilib libc6-i386 libc6-dev-i386"; \ 523f705dfdSAndy Lutomirski echo ""; \ 533f705dfdSAndy Lutomirski echo "If you are using a Fedora-like distribution, try:"; \ 543f705dfdSAndy Lutomirski echo ""; \ 553f705dfdSAndy Lutomirski echo " yum install glibc-devel.*i686"; \ 563f705dfdSAndy Lutomirski exit 1; \ 573f705dfdSAndy Lutomirski fi 58