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