Reconfigured the TOOLS variable so that it points to the current set of tools
[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 LDIS     = $(TOOLS)/dis 
47 LOPT     = $(TOOLS)/opt
48 LLINK    = $(TOOLS)/link
49 LANALYZE = $(TOOLS)/analyze
50 LBUGPOINT= $(TOOLS)/bugpoint
51
52 LCCFLAGS  += -O2 -Wall
53 LCXXFLAGS += -O2 -Wall
54 LLCFLAGS =
55 FAILURE  = $(LEVEL)/test/Failure.sh
56 TESTRUNR = PATH=$(LLVMTOOLCURRENT) $(LEVEL)/test/TestRunner.sh
57
58 # Native Tool Definitions
59 NATGCC  = $(CC)
60 CP      = /bin/cp -f
61
62 ## If TRACE or TRACEM is "yes", set the appropriate llc flag (-trace or -tracem)
63 ## mark that tracing on, and set the TRACELIBS variable.
64 TRACEFLAGS = 
65 ifeq ($(TRACE), yes)
66     TRACEFLAGS += -trace
67     DOTRACING = yes
68 else
69     ifeq ($(TRACEM), yes)
70         TRACEFLAGS += -tracem
71         DOTRACING = yes
72     endif
73 endif
74 ifeq ($(DOTRACING), yes)
75     TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
76 endif
77
78
79 LLCLIBS := $(LLCLIBS) -lm
80
81 clean::
82         $(RM) a.out core
83         $(RM) -rf Output/
84
85 # Compile from X.c to Output/X.ll
86 Output/%.ll: $(SourceDir)%.c $(LCC1) Output/.dir $(INCLUDES)
87         $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@
88
89 # Compile from X.cpp to Output/X.ll
90 Output/%.ll: $(SourceDir)%.cpp $(LCC1XX) Output/.dir $(INCLUDES)
91         $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
92
93 # Compile from X.cc to Output/X.ll
94 Output/%.ll: $(SourceDir)%.cc $(LCC1XX) Output/.dir $(INCLUDES)
95         $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
96
97 # LLVM Assemble from Output/X.ll to Output/X.bc.  Output/X.ll must have come
98 # from GCC output, so use GCCAS.
99 #
100 Output/%.bc: Output/%.ll $(LGCCAS)
101         $(LGCCAS) $(STATS) $< -o $@
102
103 # LLVM Assemble from X.ll to Output/X.bc.  Because we are coming directly from
104 # LLVM source, use the non-transforming assembler.
105 #
106 Output/%.bc: %.ll $(LAS) Output/.dir
107         $(LAS) -f $< -o $@
108
109 #
110 # Testing versions of provided utilities...
111 #
112 Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
113         @echo "======== Compiling $<"
114         $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ || \
115             ( rm -f $@; $(FAILURE) $@ )
116
117 Output/%.tll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES)
118         @echo "======== Compiling $<"
119         $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ || \
120             ( rm -f $@; $(FAILURE) $@ )
121
122 Output/%.tbc: Output/%.tll $(LAS)
123         @echo "======== Assembling $<"
124         $(LAS) -f $< -o $@ || \
125             ( rm -f $@; $(FAILURE) $@ )
126
127
128 ## Cancel built-in implicit rules that override above rules
129 %: %.s
130
131 %: %.c
132
133 %.o: %.c
134