Fix ocaml "make check" tests, that wasn't finding the proper c++ compiler.
[oota-llvm.git] / test / Makefile
1 #===- test/Makefile ----------------------------------------*- Makefile -*--===#
2 #
3 #                     The LLVM Compiler Infrastructure
4 #
5 # This file is distributed under the University of Illinois Open Source
6 # License. See LICENSE.TXT for details.
7 #
8 #===------------------------------------------------------------------------===#
9
10 LEVEL = ..
11 DIRS  =
12
13 #
14 # Make Dejagnu the default for testing
15 #
16 all:: check-local
17
18 # Include other test rules
19 include Makefile.tests
20
21 #===------------------------------------------------------------------------===#
22 # DejaGNU testing support
23 #===------------------------------------------------------------------------===#
24
25 ifneq ($(GREP_OPTIONS),)
26 $(warning GREP_OPTIONS environment variable may interfere with test results)
27 endif
28
29 ifdef VERBOSE
30 RUNTESTFLAGS := $(VERBOSE)
31 endif
32
33 ifdef TESTSUITE
34 CLEANED_TESTSUITE := $(patsubst %/,%,$(TESTSUITE))
35 CLEANED_TESTSUITE := $(patsubst test/%,%,$(CLEANED_TESTSUITE))
36 RUNTESTFLAGS += --tool $(CLEANED_TESTSUITE)
37 endif
38
39 ifdef VG
40 VALGRIND := valgrind --tool=memcheck --quiet --trace-children=yes --error-exitcode=3 --leak-check=full
41 endif
42
43 IGNORE_TESTS :=
44
45 ifndef RUNLLVM2CPP
46 IGNORE_TESTS += llvm2cpp.exp
47 endif
48
49 IGNORE_TESTS += $(filter-out $(BINDINGS_TO_BUILD:=.exp),$(ALL_BINDINGS:=.exp))
50
51 ifdef IGNORE_TESTS
52 RUNTESTFLAGS += --ignore "$(strip $(IGNORE_TESTS))"
53 endif
54
55 # Both AuroraUX & Solaris do not have the -m flag for ulimit
56 ifeq ($(OS),SunOS)
57 ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -v 512000 ;
58 else
59 ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -m 512000 ; ulimit -v 512000 ;
60 endif
61
62 ifneq ($(RUNTEST),)
63 check-local:: site.exp
64         ( $(ULIMIT) \
65           PATH="$(LLVMToolDir):$(LLVM_SRC_ROOT)/test/Scripts:$(PATH)" \
66           $(RUNTEST) $(RUNTESTFLAGS) )
67 else
68 check-local:: site.exp
69         @echo "*** dejagnu not found.  Make sure 'runtest' is in your PATH, then reconfigure LLVM."
70 endif
71
72 ifdef TESTONE
73 CLEANED_TESTONE := $(patsubst %/,%,$(TESTONE))
74 CLEANED_TESTONE := $(patsubst test/%,%,$(CLEANED_TESTONE))
75 SUBDIR := $(shell dirname $(CLEANED_TESTONE))
76 TESTPATH := $(LLVM_SRC_ROOT)/test/$(CLEANED_TESTONE)
77 check-one: site.exp $(TCLSH)
78         $(Verb)( echo "source $(LLVM_OBJ_ROOT)/test/site.exp" ; \
79           echo "set subdir $(SUBDIR)" ; \
80           echo "proc pass  { msg } { puts \"PASS: \$$msg\" } "; \
81           echo "proc fail  { msg } { puts \"FAIL: \$$msg\" }" ; \
82           echo "proc xfail { msg } { puts \"XFAIL: \$$msg\" }" ; \
83           echo "proc xpass { msg } { puts \"XPASS: \$$msg\" }" ; \
84           echo "proc verbose args { }" ; \
85           echo "source $(LLVM_SRC_ROOT)/test/lib/llvm.exp" ; \
86           echo "RunLLVMTests $(TESTPATH)" ) | \
87         ( $(ULIMIT) \
88           PATH="$(LLVMToolDir):$(LLVM_SRC_ROOT)/test/Scripts:$(PATH)" \
89           $(TCLSH) )
90 endif
91
92 clean::
93         $(RM) -rf `find $(LLVM_OBJ_ROOT)/test -name Output -type d -print`
94
95 # dsymutil is used on the Darwin to manipulate DWARF debugging information.
96 ifeq ($(OS),Darwin)
97 DSYMUTIL=dsymutil
98 else
99 DSYMUTIL=true
100 endif
101 ifdef TargetCommonOpts
102 BUGPOINT_TOPTS="-gcc-tool-args $(TargetCommonOpts)"
103 else
104 BUGPOINT_TOPTS=""
105 endif
106
107 ifneq ($(OCAMLC),)
108 CC_FOR_OCAMLC := $(shell $(OCAMLC) -config | grep native_c_compiler | sed -e 's/native_c_compiler: //')
109 CXX_FOR_OCAMLC := $(subst gcc,g++,$(CC_FOR_OCAMLC))
110 endif
111
112 FORCE:
113
114 site.exp: FORCE
115         @echo 'Making a new site.exp file...'
116         @echo '## these variables are automatically generated by make ##' >site.tmp
117         @echo '# Do not edit here.  If you wish to override these values' >>site.tmp
118         @echo '# edit the last section' >>site.tmp
119         @echo 'set target_triplet "$(TARGET_TRIPLE)"' >> site.tmp
120         @echo 'set TARGETS_TO_BUILD "$(TARGETS_TO_BUILD)"' >> site.tmp
121         @echo 'set llvmgcc_langs "$(LLVMGCC_LANGS)"' >> site.tmp
122         @echo 'set llvmgcc_version "$(LLVMGCC_VERSION)"' >> site.tmp
123         @echo 'set prcontext "$(TCLSH) $(LLVM_SRC_ROOT)/test/Scripts/prcontext.tcl"' >> site.tmp
124         @echo 'set llvmtoolsdir "$(ToolDir)"' >>site.tmp
125         @echo 'set llvmlibsdir "$(LibDir)"' >>site.tmp
126         @echo 'set srcroot "$(LLVM_SRC_ROOT)"' >>site.tmp
127         @echo 'set objroot "$(LLVM_OBJ_ROOT)"' >>site.tmp
128         @echo 'set srcdir "$(LLVM_SRC_ROOT)/test"' >>site.tmp
129         @echo 'set objdir "$(LLVM_OBJ_ROOT)/test"' >>site.tmp
130         @echo 'set gccpath "$(CC)"' >>site.tmp
131         @echo 'set gxxpath "$(CXX)"' >>site.tmp
132         @echo 'set compile_c "' $(CC) $(CPP.Flags) $(TargetCommonOpts) $(CompileCommonOpts) -c '"' >>site.tmp
133         @echo 'set compile_cxx "' $(CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) $(CompileCommonOpts) -c '"' >> site.tmp
134         @echo 'set link "' $(CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) '"' >>site.tmp
135         @echo 'set llvmgcc "$(LLVMGCC) $(TargetCommonOpts) $(EXTRA_OPTIONS)"' >> site.tmp
136         @echo 'set llvmgxx "$(LLVMGCC) $(TargetCommonOpts) $(EXTRA_OPTIONS)"' >> site.tmp
137         @echo 'set llvmgccmajvers "$(LLVMGCC_MAJVERS)"' >> site.tmp
138         @echo 'set bugpoint_topts $(BUGPOINT_TOPTS)' >> site.tmp
139         @echo 'set shlibext "$(SHLIBEXT)"' >> site.tmp
140         @echo 'set ocamlc "$(OCAMLC) -cc \"$(CXX_FOR_OCAMLC)\" -I $(LibDir)/ocaml"' >> site.tmp
141         @echo 'set valgrind "$(VALGRIND)"' >> site.tmp
142         @echo 'set grep "$(GREP)"' >>site.tmp
143         @echo 'set gas "$(GAS)"' >>site.tmp
144         @echo 'set llvmdsymutil "$(DSYMUTIL)"' >>site.tmp
145         @echo '## All variables above are generated by configure. Do Not Edit ## ' >>site.tmp
146         @test ! -f site.exp || \
147         sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
148         @-rm -f site.bak
149         @test ! -f site.exp || mv site.exp site.bak
150         @mv site.tmp site.exp