Eliminate hardcoded paths using LLVMGCCDIR variable.
[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/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)/lib/gcc-lib/llvm/3.1/
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 CC      = /opt/SUNWspro/bin/cc
44 AS      = /opt/SUNWspro/bin/cc
45 DIS     = /usr/ccs/bin/dis
46 CP      = /bin/cp -f
47 CFLAGS  += -g -xarch=v9
48
49
50 ifeq ($(TRACE), yes)
51     LLCFLAGS += -trace basicblock
52     LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
53 else
54     ifeq ($(TRACEM), yes)
55         LLCFLAGS += -trace function
56         LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
57     endif
58 endif
59
60 LLCLIBS := $(LLCLIBS) -lm
61
62 clean::
63         $(RM) a.out core
64         $(RM) -rf Output/
65
66 # Compile from X.c to Output/X.ll
67 Output/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES)
68         $(LCC) $(LCCFLAGS) -S $< -o $@
69
70 # LLVM Assemble from Output/X.ll to Output/X.bc.  Output/X.ll must have come
71 # from GCC output, so use GCCAS.
72 #
73 Output/%.bc: Output/%.ll $(LGCCAS)
74         $(LGCCAS) $< -o $@
75
76 # LLVM Assemble from X.ll to Output/X.bc.  Because we are coming directly from
77 # LLVM source, use the non-transforming assembler.
78 #
79 Output/%.bc: %.ll $(LAS) Output/.dir
80         $(LAS) -f $< -o $@
81
82 # Compile a linked program to machine code for this processor.
83 #
84 Output/%.llc.s: Output/%.llvm.bc
85         $(LLC) $(LLCFLAGS) -f $< -o $@
86
87 # Assemble (and link) an LLVM-linked program using the system assembler...
88 #
89 Output/%.llc: Output/%.llc.s
90         $(CC) $(CFLAGS) $< $(LLCLIBS) -o $@
91
92 #
93 # Testing versions of provided utilities...
94 #
95 Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
96         @echo "======== Compiling $<"
97         $(LCC) $(LCCFLAGS) -S $< -o $@ || \
98             ( rm -f $@; $(FAILURE) $@ )
99
100 Output/%.tbc: Output/%.tll $(LAS)
101         @echo "======== Assembling $<"
102         $(LAS) -f $< -o $@ || \
103             ( rm -f $@; $(FAILURE) $@ )
104
105
106 ## Cancel built-in implicit rules that override above rules
107 %: %.s
108
109 %: %.c
110
111 %.o: %.c
112