Revision 2b2e59e6

b/configure
92 92
libs_tools=""
93 93
audio_pt_int=""
94 94
audio_win_int=""
95
cc_i386=i386-pc-linux-gnu-gcc
95 96

  
96 97
# parse CC options first
97 98
for opt do
......
789 790
    i386)
790 791
           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
791 792
           LDFLAGS="-m32 $LDFLAGS"
793
           cc_i386='$(CC) -m32'
792 794
           helper_cflags="-fomit-frame-pointer"
793 795
           host_guest_base="yes"
794 796
           ;;
795 797
    x86_64)
796 798
           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
797 799
           LDFLAGS="-m64 $LDFLAGS"
800
           cc_i386='$(CC) -m32'
798 801
           host_guest_base="yes"
799 802
           ;;
800 803
    arm*)
......
2640 2643
echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2641 2644
echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2642 2645
echo "CC=$cc" >> $config_host_mak
2646
echo "CC_I386=$cc_i386" >> $config_host_mak
2643 2647
echo "HOST_CC=$host_cc" >> $config_host_mak
2644 2648
if test "$sparse" = "yes" ; then
2645 2649
  echo "CC      := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
b/rules.mak
42 42
VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.texi
43 43
set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1)))
44 44

  
45
# find-in-path
46
# Usage: $(call find-in-path, prog)
47
# Looks in the PATH if the argument contains no slash, else only considers one
48
# specific directory.  Returns an # empty string if the program doesn't exist
49
# there.
50
find-in-path = $(if $(find-string /, $1), \
51
        $(wildcard $1), \
52
        $(wildcard $(patsubst %, %/$1, $(subst :, ,$(PATH)))))
53

  
45 54
# Generate timestamp files for .h include files
46 55

  
47 56
%.h: %.h-timestamp
b/tests/Makefile
3 3

  
4 4
$(call set-vpath, $(SRC_PATH)/tests)
5 5

  
6
QEMU=../i386-linux-user/qemu-i386
7
QEMU_X86_64=../x86_64-linux-user/qemu-x86_64
8
CC_X86_64=$(CC_I386) -m64
9

  
6 10
CFLAGS=-Wall -O2 -g -fno-strict-aliasing -I..
7 11
#CFLAGS+=-msse2
8 12
LDFLAGS=
9 13

  
10
ifeq ($(ARCH),i386)
11
TESTS=linux-test testthread sha1-i386 test-i386
14
# TODO: automatically detect ARM and MIPS compilers, and run those too
15

  
16
# runcom maps page 0, so it requires root privileges
17
# also, pi_10.com runs indefinitely
18

  
19
I386_TESTS=hello-i386 \
20
	   linux-test \
21
	   testthread \
22
	   sha1-i386 \
23
	   test-i386 \
24
	   test-mmap \
25
	   # runcom
26

  
27
# native i386 compilers sometimes are not biarch.  assume cross-compilers are
28
ifneq ($(ARCH),i386)
29
I386_TESTS+=run-test-x86_64
12 30
endif
13
ifeq ($(ARCH),x86_64)
14
TESTS=test-x86_64
31

  
32
TESTS = test_path
33
ifneq ($(call find-in-path, $(CC_I386)),)
34
TESTS += $(I386_TESTS)
15 35
endif
16
TESTS+=sha1# test_path
17
#TESTS+=test_path
18
#TESTS+=runcom
19 36

  
20
QEMU=../i386-linux-user/qemu-i386
37
all: $(patsubst %,run-%,$(TESTS))
38

  
39
# rules to run tests
40

  
41
.PHONY: $(patsubst %,run-%,$(TESTS))
42

  
43
run-%: %
44
	-$(QEMU) ./$*
45

  
46
run-hello-i386: hello-i386
47
run-linux-test: linux-test
48
run-testthread: testthread
49
run-sha1-i386: sha1-i386
50

  
51
run-test-i386: test-i386
52
	./test-i386 > test-i386.ref
53
	-$(QEMU) test-i386 > test-i386.out
54
	@if diff -u test-i386.ref test-i386.out ; then echo "Auto Test OK"; fi
55

  
56
run-test-x86_64: test-x86_64
57
	./test-x86_64 > test-x86_64.ref
58
	-$(QEMU_X86_64) test-x86_64 > test-x86_64.out
59
	@if diff -u test-x86_64.ref test-x86_64.out ; then echo "Auto Test OK"; fi
60

  
61
run-test-mmap: test-mmap
62
	-$(QEMU) ./test-mmap
63
	-$(QEMU) -p 8192 ./test-mmap 8192
64
	-$(QEMU) -p 16384 ./test-mmap 16384
65
	-$(QEMU) -p 32768 ./test-mmap 32768
66

  
67
run-runcom: runcom
68
	-$(QEMU) ./runcom $(SRC_PATH)/tests/pi_10.com
69

  
70
run-test_path: test_path
71
	./test_path
72

  
73
# rules to compile tests
21 74

  
22
all: $(TESTS)
75
test_path: test_path.o
76
test_path.o: test_path.c
23 77

  
24 78
hello-i386: hello-i386.c
25
	$(CC) -nostdlib $(CFLAGS) -static $(LDFLAGS) -o $@ $<
79
	$(CC_I386) -nostdlib $(CFLAGS) -static $(LDFLAGS) -o $@ $<
26 80
	strip $@
27 81

  
28 82
testthread: testthread.c
29
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lpthread
30

  
31
test_path: test_path.c
32
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
33
	./$@ || { rm $@; exit 1; }
83
	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< -lpthread
34 84

  
35 85
# i386/x86_64 emulation test (test various opcodes) */
36 86
test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
37 87
           test-i386.h test-i386-shift.h test-i386-muldiv.h
38
	$(CC) -m32 $(CFLAGS) $(LDFLAGS) -static -o $@ \
88
	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ \
39 89
              $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
40 90

  
41 91
test-x86_64: test-i386.c \
42 92
           test-i386.h test-i386-shift.h test-i386-muldiv.h
43
	$(CC) -m64 $(CFLAGS) $(LDFLAGS) -static -o $@ $(<D)/test-i386.c -lm
44

  
45
ifeq ($(ARCH),i386)
46
test: test-i386
47
	./test-i386 > test-i386.ref
48
else
49
test:
50
endif
51
	$(QEMU) test-i386 > test-i386.out
52
	@if diff -u test-i386.ref test-i386.out ; then echo "Auto Test OK"; fi
53

  
54
.PHONY: test-mmap
55
test-mmap: test-mmap.c
56
	$(CC) $(CFLAGS) -Wall -static -O2 $(LDFLAGS) -o $@ $<
57
	-./test-mmap
58
	-$(QEMU) ./test-mmap
59
	-$(QEMU) -p 8192 ./test-mmap 8192
60
	-$(QEMU) -p 16384 ./test-mmap 16384
61
	-$(QEMU) -p 32768 ./test-mmap 32768
93
	$(CC_X86_64) $(CFLAGS) $(LDFLAGS) -o $@ $(<D)/test-i386.c -lm
62 94

  
63 95
# generic Linux and CPU test
64 96
linux-test: linux-test.c
65
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lm
97
	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< -lm
98

  
99
# vm86 test
100
runcom: runcom.c
101
	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $<
102

  
103
test-mmap: test-mmap.c
104
	$(CC_I386) -m32 $(CFLAGS) -Wall -O2 $(LDFLAGS) -o $@ $<
66 105

  
67 106
# speed test
68 107
sha1-i386: sha1.c
69
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
108
	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $<
70 109

  
71 110
sha1: sha1.c
72
	$(HOST_CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
111
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
73 112

  
74 113
speed: sha1 sha1-i386
75 114
	time ./sha1
76 115
	time $(QEMU) ./sha1-i386
77 116

  
78
# vm86 test
79
runcom: runcom.c
80
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
81

  
117
# broken test
82 118
# NOTE: -fomit-frame-pointer is currently needed : this is a bug in libqemu
83 119
qruncom: qruncom.c ../ioport-user.c ../i386-user/libqemu.a
84 120
	$(CC) $(CFLAGS) -fomit-frame-pointer $(LDFLAGS) -I../target-i386 -I.. -I../i386-user -I../fpu \

Also available in: Unified diff