1.PHONY: all all_32 all_64 check_build32 clean run_tests
2
3TARGETS_C_BOTHBITS := sigreturn single_step_syscall
4
5BINARIES_32 := $(TARGETS_C_BOTHBITS:%=%_32)
6BINARIES_64 := $(TARGETS_C_BOTHBITS:%=%_64)
7
8CFLAGS := -O2 -g -std=gnu99 -pthread -Wall
9
10UNAME_P := $(shell uname -p)
11
12# Always build 32-bit tests
13all: all_32
14
15# If we're on a 64-bit host, build 64-bit tests as well
16ifeq ($(shell uname -p),x86_64)
17all: all_64
18endif
19
20all_32: check_build32 $(BINARIES_32)
21
22all_64: $(BINARIES_64)
23
24clean:
25	$(RM) $(BINARIES_32) $(BINARIES_64)
26
27run_tests:
28	./run_x86_tests.sh
29
30$(TARGETS_C_BOTHBITS:%=%_32): %_32: %.c
31	$(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl
32
33$(TARGETS_C_BOTHBITS:%=%_64): %_64: %.c
34	$(CC) -m64 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl
35
36check_build32:
37	@if ! $(CC) -m32 -o /dev/null trivial_32bit_program.c; then	\
38	  echo "Warning: you seem to have a broken 32-bit build" 2>&1; 	\
39	  echo "environment.  If you are using a Debian-like";		\
40	  echo " distribution, try:"; 					\
41	  echo "";							\
42	  echo "  apt-get install gcc-multilib libc6-i386 libc6-dev-i386"; \
43	  echo "";							\
44	  echo "If you are using a Fedora-like distribution, try:";	\
45	  echo "";							\
46	  echo "  yum install glibc-devel.*i686";			\
47	  exit 1;							\
48	fi
49