Add the test/Scripts directory to the path used by TestRunner
[oota-llvm.git] / test / Makefile.tests
1 ##----------------------------------------------------------*- Makefile -*-===##
2 ## Common rules for generating, linking, and compiling via LLVM.  This is
3 ## used to implement a robust testing framework for LLVM
4 ##-------------------------------------------------------------------------===##
5
6 # If the user specified a TEST= option on the command line, we do not want to do
7 # the default testing type.  Instead, we change the default target to be the
8 # test:: target.
9 #
10 ifdef TEST
11 test::
12 endif
13
14 include ${LEVEL}/Makefile.common
15
16 # Specify ENABLE_STATS on the command line to enable -stats and -time-passes
17 # output from gccas and gccld.
18 ifdef ENABLE_STATS
19 STATS = -stats -time-passes
20 endif
21
22
23 .PHONY: clean default
24
25 # These files, which might be intermediate results, should not be deleted by
26 # make
27 .PRECIOUS: Output/%.bc  Output/%.ll
28 .PRECIOUS: Output/%.tbc Output/%.tll
29 .PRECIOUS: Output/.dir
30 .PRECIOUS: Output/%.llvm.bc
31 .PRECIOUS: Output/%.llvm
32
33 TOOLS    = $(LLVMTOOLCURRENT)
34
35 # LLVM Tool Definitions...
36 #
37 LCC      = $(LLVMGCCDIR)/bin/gcc
38 LCC1     = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1
39 LCXX     = $(LLVMGCCDIR)/bin/g++
40 LCC1XX   = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1plus
41 LLI      = $(TOOLS)/lli
42 LLC      = $(TOOLS)/llc
43 LAS      = $(TOOLS)/as
44 LGCCAS   = $(TOOLS)/gccas
45 LGCCLD   = $(TOOLS)/gccld -L$(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/lib
46 LGCCLDPROG = $(TOOLS)/gccld
47 LDIS     = $(TOOLS)/dis 
48 LOPT     = $(TOOLS)/opt
49 LLINK    = $(TOOLS)/link
50 LANALYZE = $(TOOLS)/analyze
51 LBUGPOINT= $(TOOLS)/bugpoint
52
53 LCCFLAGS  += -O2 -Wall
54 LCXXFLAGS += -O2 -Wall
55 LLCFLAGS =
56 FAILURE  = $(LEVEL)/test/Failure.sh
57 TESTRUNR = PATH=$(LLVMTOOLCURRENT):$(LEVEL)/test/Scripts:$(PATH) \
58                $(LEVEL)/test/TestRunner.sh
59
60 # Native Tool Definitions
61 NATGCC  = $(CC)
62 CP      = /bin/cp -f
63
64 ## If TRACE or TRACEM is "yes", set the appropriate llc flag (-trace or -tracem)
65 ## mark that tracing on, and set the TRACELIBS variable.
66 TRACEFLAGS = 
67 ifeq ($(TRACE), yes)
68     TRACEFLAGS += -trace
69     DOTRACING = yes
70 else
71     ifeq ($(TRACEM), yes)
72         TRACEFLAGS += -tracem
73         DOTRACING = yes
74     endif
75 endif
76 ifeq ($(DOTRACING), yes)
77     TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
78 endif
79
80
81 LLCLIBS := $(LLCLIBS) -lm
82
83 clean::
84         $(RM) a.out core
85         $(RM) -rf Output/
86
87 # Compile from X.c to Output/X.ll
88 Output/%.ll: $(SourceDir)%.c $(LCC1) Output/.dir $(INCLUDES)
89         $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@
90
91 # Compile from X.cpp to Output/X.ll
92 Output/%.ll: $(SourceDir)%.cpp $(LCC1XX) Output/.dir $(INCLUDES)
93         $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
94
95 # Compile from X.cc to Output/X.ll
96 Output/%.ll: $(SourceDir)%.cc $(LCC1XX) Output/.dir $(INCLUDES)
97         $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
98
99 # LLVM Assemble from Output/X.ll to Output/X.bc.  Output/X.ll must have come
100 # from GCC output, so use GCCAS.
101 #
102 Output/%.bc: Output/%.ll $(LGCCAS)
103         $(LGCCAS) $(STATS) $< -o $@
104
105 # LLVM Assemble from X.ll to Output/X.bc.  Because we are coming directly from
106 # LLVM source, use the non-transforming assembler.
107 #
108 Output/%.bc: %.ll $(LAS) Output/.dir
109         $(LAS) -f $< -o $@
110
111 #
112 # Testing versions of provided utilities...
113 #
114 Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
115         @echo "======== Compiling $<"
116         $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ || \
117             ( rm -f $@; $(FAILURE) $@ )
118
119 Output/%.tll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES)
120         @echo "======== Compiling $<"
121         $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ || \
122             ( rm -f $@; $(FAILURE) $@ )
123
124 Output/%.tbc: Output/%.tll $(LAS)
125         @echo "======== Assembling $<"
126         $(LAS) -f $< -o $@ || \
127             ( rm -f $@; $(FAILURE) $@ )
128
129
130 ## Cancel built-in implicit rules that override above rules
131 %: %.s
132
133 %: %.c
134
135 %.o: %.c
136