Updated the name of the linker to llvm-link.
[oota-llvm.git] / test / Makefile.tests
1 ##----------------------------------------------------------*- Makefile -*-===##
2 ##
3 ## Common rules for generating, linking, and compiling via LLVM.  This is
4 ## used to implement a robust testing framework for LLVM
5 ##
6 ##-------------------------------------------------------------------------===##
7
8 # If the user specified a TEST= option on the command line, we do not want to do
9 # the default testing type.  Instead, we change the default target to be the
10 # test:: target.
11 #
12 ifdef TEST
13 test::
14 endif
15
16 # We do not want to make .d files for tests! 
17 DISABLE_AUTO_DEPENDENCIES=1
18
19 include ${LEVEL}/Makefile.common
20
21 # Specify ENABLE_STATS on the command line to enable -stats and -time-passes
22 # output from gccas and gccld.
23 ifdef ENABLE_STATS
24 STATS = -stats -time-passes
25 endif
26
27 .PHONY: clean default
28
29 # These files, which might be intermediate results, should not be deleted by
30 # make
31 .PRECIOUS: Output/%.bc  Output/%.ll
32 .PRECIOUS: Output/%.tbc Output/%.tll
33 .PRECIOUS: Output/.dir
34 .PRECIOUS: Output/%.llvm.bc
35 .PRECIOUS: Output/%.llvm
36
37 TOOLS    = $(LLVMTOOLCURRENT)
38
39 # LLVM Tool Definitions...
40 #
41 LCC      = $(LLVMGCC)   ## FIXME: remove these definitions, use LLVMGCC directly
42 LCXX     = $(LLVMGXX)   ## FIXME: remove these definitions, use LLVMGXX directly
43 LAS      = $(LLVMAS)    ## FIXME: remove these definitions, use LLVMAS directly
44
45 LLI      = $(TOOLS)/lli
46 LLC      = $(TOOLS)/llc
47 LGCCAS   = $(TOOLS)/gccas
48 LGCCLD   = $(TOOLS)/gccld -L$(LLVMGCCDIR)/lib/gcc/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/lib
49 LGCCLDPROG = $(TOOLS)/gccld
50 LDIS     = $(TOOLS)/llvm-dis 
51 LOPT     = $(TOOLS)/opt
52 LLINK    = $(TOOLS)/llvm-link
53 LANALYZE = $(TOOLS)/analyze
54 LBUGPOINT= $(TOOLS)/bugpoint
55
56 LCCFLAGS  += -O2 -Wall
57 LCXXFLAGS += -O2 -Wall
58 LLCFLAGS =
59 FAILURE  = $(LLVM_SRC_ROOT)/test/Failure.sh
60 TESTRUNR = @echo Running test: $<; \
61              PATH=$(LLVMTOOLCURRENT):$(LLVM_SRC_ROOT)/test/Scripts:$(PATH) \
62                   $(LLVM_SRC_ROOT)/test/TestRunner.sh
63
64 # Native Tool Definitions
65 NATGCC  = $(CC)
66 CP      = /bin/cp -f
67
68 ## If TRACE or TRACEM is "yes", set the appropriate llc flag (-trace or -tracem)
69 ## mark that tracing on, and set the TRACELIBS variable.
70 TRACEFLAGS = 
71 ifeq ($(TRACE), yes)
72     TRACEFLAGS = -trace
73     TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr.$(ARCH)
74 endif
75
76 ifeq ($(TRACEM), yes)
77     TRACEFLAGS = -tracem
78     TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr.$(ARCH)
79 endif
80
81 LLCLIBS := $(LLCLIBS) -lm
82
83 clean::
84         $(RM) -f a.out core
85         $(RM) -rf Output/
86
87 # Compile from X.c to Output/X.ll
88 Output/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES)
89         $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@
90
91 # Compile from X.cpp to Output/X.ll
92 Output/%.ll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES)
93         $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
94
95 # Compile from X.cc to Output/X.ll
96 Output/%.ll: %.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