Enable the new C front-end for targets which define LLVMGCCARCH
[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 ifdef ENABLE_OPTIMIZED
34 TOOLS    = $(BUILD_ROOT_TOP)/tools/Release
35 else
36 TOOLS    = $(BUILD_ROOT_TOP)/tools/Debug
37 endif
38
39 # LLVM Tool Definitions...
40 #
41 ifdef LLVMGCCARCH # FIXME: Remove when new CFE is used on sparc as well!
42 LCC      = $(LLVMGCCDIR)/bin/gcc
43 LCC1     = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1
44 LGCCLD   = $(TOOLS)/gccld -L$(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/lib
45 else
46 LCC      = $(LLVMGCCDIR)/bin/llvm-gcc
47 LCC1     = $(LLVMGCCDIR)/lib/gcc-lib/llvm/3.1/cc1
48 LGCCLD   = $(TOOLS)/gccld -L$(LLVMGCCDIR)/llvm/lib
49 endif
50
51 LLI      = $(TOOLS)/lli
52 LLC      = $(TOOLS)/llc
53 LAS      = $(TOOLS)/as
54 LGCCAS   = $(TOOLS)/gccas
55 LDIS     = $(TOOLS)/dis 
56 LOPT     = $(TOOLS)/opt
57 LLINK    = $(TOOLS)/link
58 LANALYZE = $(TOOLS)/analyze
59 LBUGPOINT= $(TOOLS)/bugpoint
60
61 LCCFLAGS  += -O2 -Wall
62 LLCFLAGS =
63 FAILURE  = $(LEVEL)/test/Failure.sh
64 TESTRUNR = $(LEVEL)/test/TestRunner.sh
65
66 # Native Tool Definitions
67 NATGCC  = /usr/dcs/software/supported/bin/gcc
68 CP      = /bin/cp -f
69
70 ifndef DISABLE_LLC_DIFFS
71 CC      = /opt/SUNWspro/bin/cc
72 AS      = /opt/SUNWspro/bin/cc
73 DIS     = /usr/ccs/bin/dis
74 CFLAGS  += -g -xarch=v9
75 endif
76
77
78 ifeq ($(TRACE), yes)
79     LLCFLAGS += -trace basicblock
80     LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
81 else
82     ifeq ($(TRACEM), yes)
83         LLCFLAGS += -trace function
84         LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
85     endif
86 endif
87
88 LLCLIBS := $(LLCLIBS) -lm
89
90 clean::
91         $(RM) a.out core
92         $(RM) -rf Output/
93
94 # Compile from X.c to Output/X.ll
95 Output/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES)
96         $(LCC) $(LCCFLAGS) -S $< -o $@
97
98 # LLVM Assemble from Output/X.ll to Output/X.bc.  Output/X.ll must have come
99 # from GCC output, so use GCCAS.
100 #
101 Output/%.bc: Output/%.ll $(LGCCAS)
102         $(LGCCAS) $(STATS) $< -o $@
103
104 # LLVM Assemble from X.ll to Output/X.bc.  Because we are coming directly from
105 # LLVM source, use the non-transforming assembler.
106 #
107 Output/%.bc: %.ll $(LAS) Output/.dir
108         $(LAS) -f $< -o $@
109
110 # Compile a linked program to machine code for this processor.
111 #
112 Output/%.llc.s: Output/%.llvm.bc $(LLC)
113         $(LLC) $(LLCFLAGS) -f $< -o $@
114
115 # Assemble (and link) an LLVM-linked program using the system assembler...
116 #
117 Output/%.llc: Output/%.llc.s
118         $(CC) $(CFLAGS) $< $(LLCLIBS) -o $@
119
120 #
121 # Testing versions of provided utilities...
122 #
123 Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
124         @echo "======== Compiling $<"
125         $(LCC) $(LCCFLAGS) -S $< -o $@ || \
126             ( rm -f $@; $(FAILURE) $@ )
127
128 Output/%.tbc: Output/%.tll $(LAS)
129         @echo "======== Assembling $<"
130         $(LAS) -f $< -o $@ || \
131             ( rm -f $@; $(FAILURE) $@ )
132
133
134 ## Cancel built-in implicit rules that override above rules
135 %: %.s
136
137 %: %.c
138
139 %.o: %.c
140