Makefile.tests revision 98abb5286796f4f1c4f6e7f1f6407636ea8b04f4
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#
10ifdef TEST
11test::
12endif
13
14include ${LEVEL}/Makefile.common
15
16# Specify ENABLE_STATS on the command line to enable -stats and -time-passes
17# output from gccas and gccld.
18ifdef ENABLE_STATS
19STATS = -stats -time-passes
20endif
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
33ifdef ENABLE_OPTIMIZED
34TOOLS    = $(BUILD_ROOT_TOP)/tools/Release
35else
36TOOLS    = $(BUILD_ROOT_TOP)/tools/Debug
37endif
38
39# LLVM Tool Definitions...
40#
41LCC      = $(LLVMGCCDIR)/bin/gcc
42LCC1     = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1
43LGCCLD   = $(TOOLS)/gccld -L$(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/lib
44LLI      = $(TOOLS)/lli
45LLC      = $(TOOLS)/llc
46LAS      = $(TOOLS)/as
47LGCCAS   = $(TOOLS)/gccas
48LDIS     = $(TOOLS)/dis 
49LOPT     = $(TOOLS)/opt
50LLINK    = $(TOOLS)/link
51LANALYZE = $(TOOLS)/analyze
52LBUGPOINT= $(TOOLS)/bugpoint
53
54LCCFLAGS  += -O2 -Wall
55LLCFLAGS =
56FAILURE  = $(LEVEL)/test/Failure.sh
57TESTRUNR = $(LEVEL)/test/TestRunner.sh
58
59# Native Tool Definitions
60NATGCC  = /usr/dcs/software/supported/bin/gcc
61CP	= /bin/cp -f
62
63ifeq ($(TRACE), yes)
64    LLCFLAGS += -trace basicblock
65    LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
66else
67    ifeq ($(TRACEM), yes)
68	LLCFLAGS += -trace function
69	LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
70    endif
71endif
72
73LLCLIBS := $(LLCLIBS) -lm
74
75clean::
76	$(RM) a.out core
77	$(RM) -rf Output/
78
79# Compile from X.c to Output/X.ll
80Output/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES)
81	$(LCC) $(LCCFLAGS) -S $< -o $@
82
83# LLVM Assemble from Output/X.ll to Output/X.bc.  Output/X.ll must have come
84# from GCC output, so use GCCAS.
85#
86Output/%.bc: Output/%.ll $(LGCCAS)
87	$(LGCCAS) $(STATS) $< -o $@
88
89# LLVM Assemble from X.ll to Output/X.bc.  Because we are coming directly from
90# LLVM source, use the non-transforming assembler.
91#
92Output/%.bc: %.ll $(LAS) Output/.dir
93	$(LAS) -f $< -o $@
94
95#
96# Testing versions of provided utilities...
97#
98Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
99	@echo "======== Compiling $<"
100	$(LCC) $(LCCFLAGS) -S $< -o $@ || \
101	    ( rm -f $@; $(FAILURE) $@ )
102
103Output/%.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
116