escape special char when handling CXX_FOR_OCAMLOPT
[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 all:: check-local
14
15 # Include other test rules
16 include Makefile.tests
17
18 #===------------------------------------------------------------------------===#
19 # DejaGNU testing support
20 #===------------------------------------------------------------------------===#
21
22 ifneq ($(GREP_OPTIONS),)
23 $(warning GREP_OPTIONS environment variable may interfere with test results)
24 endif
25
26 ifdef VERBOSE
27 LIT_ARGS := -v
28 else
29 LIT_ARGS := -s -v
30 endif
31
32 # -jN causes crash on Cygwin's python.
33 ifneq (,$(filter $(HOST_OS),Cygwin))
34   LIT_ARGS += -j1
35 endif
36
37 ifdef TESTSUITE
38 LIT_TESTSUITE := $(TESTSUITE)
39 CLEANED_TESTSUITE := $(patsubst %/,%,$(TESTSUITE))
40 CLEANED_TESTSUITE := $(patsubst test/%,%,$(CLEANED_TESTSUITE))
41 else
42 LIT_TESTSUITE := .
43 endif
44
45 ifdef VG
46 VALGRIND := valgrind --tool=memcheck --quiet --trace-children=yes --error-exitcode=3 --leak-check=full $(VALGRIND_EXTRA_ARGS)
47 endif
48
49 # Check what to run for -all.
50 LIT_ALL_TESTSUITES := $(LIT_TESTSUITE)
51
52 extra-site-cfgs::
53 .PHONY: extra-site-cfgs
54
55 ifneq ($(strip $(filter check-local-all,$(MAKECMDGOALS))),)
56 ifndef TESTSUITE
57 ifeq ($(shell test -f $(PROJ_OBJ_DIR)/../tools/clang/Makefile && echo OK), OK)
58 LIT_ALL_TESTSUITES += $(PROJ_OBJ_DIR)/../tools/clang/test
59
60 # Force creation of Clang's lit.site.cfg.
61 clang-site-cfg: FORCE
62         $(MAKE) -C $(PROJ_OBJ_DIR)/../tools/clang/test lit.site.cfg Unit/lit.site.cfg
63 extra-site-cfgs:: clang-site-cfg
64 endif
65
66 ifeq ($(shell test -f $(PROJ_OBJ_DIR)/../tools/clang/tools/extra/Makefile && echo OK), OK)
67 LIT_ALL_TESTSUITES += $(PROJ_OBJ_DIR)/../tools/clang/tools/extra/test
68
69 # Force creation of Clang Tools' lit.site.cfg.
70 clang-tools-site-cfg: FORCE
71         $(MAKE) -C $(PROJ_OBJ_DIR)/../tools/clang/tools/extra/test lit.site.cfg
72 extra-site-cfgs:: clang-tools-site-cfg
73 endif
74 endif
75 endif
76
77 # ulimits like these are redundantly enforced by the buildbots, so
78 # just removing them here won't work.
79 # Both AuroraUX & Solaris do not have the -m flag for ulimit
80 ifeq ($(HOST_OS),SunOS)
81 ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -v 512000 ;
82 else # !SunOS
83 ifeq ($(HOST_OS),AuroraUX)
84 ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -v 512000 ;
85 else # !AuroraUX
86 # Fedora 13 x86-64 python fails with -v 76800
87 ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -m 512000 ; ulimit -v 1024000 ;
88 endif # AuroraUX
89 endif # SunOS
90
91 check-local:: lit.site.cfg Unit/lit.site.cfg
92         ( $(ULIMIT) \
93           $(LLVM_SRC_ROOT)/utils/lit/lit.py $(LIT_ARGS) $(LIT_TESTSUITE) )
94
95 # This is a legacy alias dating from when both DejaGNU and lit were in use.
96 check-local-lit:: check-local
97
98 check-local-all:: lit.site.cfg Unit/lit.site.cfg extra-site-cfgs
99         ( $(ULIMIT) \
100           $(LLVM_SRC_ROOT)/utils/lit/lit.py $(LIT_ARGS) $(LIT_ALL_TESTSUITES) )
101
102 clean::
103         $(RM) -rf `find $(LLVM_OBJ_ROOT)/test -name Output -type d -print`
104
105 # dsymutil is used on the Darwin to manipulate DWARF debugging information.
106 ifeq ($(TARGET_OS),Darwin)
107 DSYMUTIL=dsymutil
108 else
109 DSYMUTIL=true
110 endif
111
112 ifneq ($(OCAMLOPT),)
113 CC_FOR_OCAMLOPT := $(shell $(OCAMLOPT) -config | grep native_c_compiler | sed -e 's/native_c_compiler: //')
114 CXX_FOR_OCAMLOPT := $(subst gcc,g++,$(CC_FOR_OCAMLOPT))
115 endif
116
117 FORCE:
118
119 ifeq ($(DISABLE_ASSERTIONS),1)
120 ENABLE_ASSERTIONS=0
121 else
122 ENABLE_ASSERTIONS=1
123 endif
124
125 lit.site.cfg: FORCE
126         @echo "Making LLVM 'lit.site.cfg' file..."
127         @$(ECHOPATH) s=@TARGET_TRIPLE@=$(TARGET_TRIPLE)=g > lit.tmp
128         @$(ECHOPATH) s=@LLVM_SOURCE_DIR@=$(LLVM_SRC_ROOT)=g >> lit.tmp
129         @$(ECHOPATH) s=@LLVM_BINARY_DIR@=$(LLVM_OBJ_ROOT)=g >> lit.tmp
130         @$(ECHOPATH) s=@LLVM_TOOLS_DIR@=$(ToolDir)=g >> lit.tmp
131         @$(ECHOPATH) s=@SHLIBDIR@=$(SharedLibDir)=g >> lit.tmp
132         @$(ECHOPATH) s=@SHLIBEXT@=$(SHLIBEXT)=g >> lit.tmp
133         @$(ECHOPATH) s=@PYTHON_EXECUTABLE@=python=g >> lit.tmp
134         @$(ECHOPATH) s=@OCAMLOPT@=$(OCAMLOPT) -cc \\\\\"$(subst =,"\\=",$(CXX_FOR_OCAMLOPT))\\\\\" -I $(LibDir)/ocaml=g >> lit.tmp
135         @$(ECHOPATH) s=@ENABLE_SHARED@=$(ENABLE_SHARED)=g >> lit.tmp
136         @$(ECHOPATH) s=@ENABLE_ASSERTIONS@=$(ENABLE_ASSERTIONS)=g >> lit.tmp
137         @$(ECHOPATH) s=@TARGETS_TO_BUILD@=$(TARGETS_TO_BUILD)=g >> lit.tmp
138         @$(ECHOPATH) s=@LLVM_BINDINGS@=$(BINDINGS_TO_BUILD)=g >> lit.tmp
139         @$(ECHOPATH) s=@HOST_OS@=$(HOST_OS)=g >> lit.tmp
140         @$(ECHOPATH) s=@HOST_ARCH@=$(HOST_ARCH)=g >> lit.tmp
141         @sed -f lit.tmp $(PROJ_SRC_DIR)/lit.site.cfg.in > $@
142         @-rm -f lit.tmp
143
144 Unit/lit.site.cfg: $(PROJ_OBJ_DIR)/Unit/.dir FORCE
145         @echo "Making LLVM unittest 'lit.site.cfg' file..."
146         @$(ECHOPATH) s=@LLVM_SOURCE_DIR@=$(LLVM_SRC_ROOT)=g > unit.tmp
147         @$(ECHOPATH) s=@LLVM_BINARY_DIR@=$(LLVM_OBJ_ROOT)=g >> unit.tmp
148         @$(ECHOPATH) s=@LLVM_TOOLS_DIR@=$(ToolDir)=g >> unit.tmp
149         @$(ECHOPATH) s=@LLVM_BUILD_MODE@=$(BuildMode)=g >> unit.tmp
150         @$(ECHOPATH) s=@ENABLE_SHARED@=$(ENABLE_SHARED)=g >> unit.tmp
151         @$(ECHOPATH) s=@SHLIBDIR@=$(SharedLibDir)=g >> unit.tmp
152         @$(ECHOPATH) s=@SHLIBPATH_VAR@=$(SHLIBPATH_VAR)=g >> unit.tmp
153         @$(ECHOPATH) s=@HOST_OS@=$(HOST_OS)=g >> unit.tmp
154         @$(ECHOPATH) s=@HOST_ARCH@=$(HOST_ARCH)=g >> lit.tmp
155         @sed -f unit.tmp $(PROJ_SRC_DIR)/Unit/lit.site.cfg.in > $@
156         @-rm -f unit.tmp