b5299faa3f30201790d93e42cbc22336c9616744
[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 ## NOTE: This is preliminary and will change in the future
7
8 include ${LEVEL}/Makefile.common
9
10 # Specify ENABLE_STATS on the command line to enable -stats output from gccas
11 # and gccld.
12 ifdef ENABLE_STATS
13 STATS = -stats
14 endif
15
16
17 .PHONY: clean default
18
19 # These files, which might be intermediate results, should not be deleted by
20 # make
21 .PRECIOUS: Output/%.bc  Output/%.ll
22 .PRECIOUS: Output/%.tbc Output/%.tll
23 .PRECIOUS: Output/.dir
24 .PRECIOUS: Output/%.llvm.bc
25 .PRECIOUS: Output/%.llvm
26
27 ifdef ENABLE_OPTIMIZED
28 TOOLS    = $(BUILD_ROOT_TOP)/tools/Release
29 else
30 TOOLS    = $(BUILD_ROOT_TOP)/tools/Debug
31 endif
32
33 # LLVM Tool Definitions...
34 #
35 LCC      = $(LLVMGCCDIR)/bin/llvm-gcc
36 LCC1     = $(LLVMGCCDIR)/lib/gcc-lib/llvm/3.1/cc1
37 LLI      = $(TOOLS)/lli
38 LLC      = $(TOOLS)/llc
39 LAS      = $(TOOLS)/as
40 LGCCAS   = $(TOOLS)/gccas
41 LGCCLD   = $(TOOLS)/gccld -L$(LLVMGCCDIR)/llvm/lib
42 LDIS     = $(TOOLS)/dis 
43 LOPT     = $(TOOLS)/opt
44 LLINK    = $(TOOLS)/link
45 LANALYZE = $(TOOLS)/analyze
46 LJELLO   = $(TOOLS)/jello
47 LBUGPOINT= $(TOOLS)/bugpoint
48
49 LCCFLAGS  += -O2 -Wall
50 LLCFLAGS =
51 FAILURE  = $(LEVEL)/test/Failure.sh
52 TESTRUNR = $(LEVEL)/test/TestRunner.sh
53
54 # Native Tool Definitions
55 NATGCC  = /usr/dcs/software/supported/bin/gcc
56 CP      = /bin/cp -f
57
58 ifndef DISABLE_LLC_DIFFS
59 CC      = /opt/SUNWspro/bin/cc
60 AS      = /opt/SUNWspro/bin/cc
61 DIS     = /usr/ccs/bin/dis
62 CFLAGS  += -g -xarch=v9
63 endif
64
65
66 ifeq ($(TRACE), yes)
67     LLCFLAGS += -trace basicblock
68     LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
69 else
70     ifeq ($(TRACEM), yes)
71         LLCFLAGS += -trace function
72         LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
73     endif
74 endif
75
76 LLCLIBS := $(LLCLIBS) -lm
77
78 clean::
79         $(RM) a.out core
80         $(RM) -rf Output/
81
82 # Compile from X.c to Output/X.ll
83 Output/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES)
84         $(LCC) $(LCCFLAGS) -S $< -o $@
85
86 # LLVM Assemble from Output/X.ll to Output/X.bc.  Output/X.ll must have come
87 # from GCC output, so use GCCAS.
88 #
89 Output/%.bc: Output/%.ll $(LGCCAS)
90         $(LGCCAS) $(STATS) $< -o $@
91
92 # LLVM Assemble from X.ll to Output/X.bc.  Because we are coming directly from
93 # LLVM source, use the non-transforming assembler.
94 #
95 Output/%.bc: %.ll $(LAS) Output/.dir
96         $(LAS) -f $< -o $@
97
98 # Compile a linked program to machine code for this processor.
99 #
100 Output/%.llc.s: Output/%.llvm.bc $(LLC)
101         $(LLC) $(LLCFLAGS) -f $< -o $@
102
103 # Assemble (and link) an LLVM-linked program using the system assembler...
104 #
105 Output/%.llc: Output/%.llc.s
106         $(CC) $(CFLAGS) $< $(LLCLIBS) -o $@
107
108 #
109 # Testing versions of provided utilities...
110 #
111 Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
112         @echo "======== Compiling $<"
113         $(LCC) $(LCCFLAGS) -S $< -o $@ || \
114             ( rm -f $@; $(FAILURE) $@ )
115
116 Output/%.tbc: Output/%.tll $(LAS)
117         @echo "======== Assembling $<"
118         $(LAS) -f $< -o $@ || \
119             ( rm -f $@; $(FAILURE) $@ )
120
121
122 ## Cancel built-in implicit rules that override above rules
123 %: %.s
124
125 %: %.c
126
127 %.o: %.c
128