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