Makefile.tests revision 781128c4f9463771032fc5e27977820761ec8260
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
33TOOLS    = $(LLVMTOOLCURRENT)
34
35# LLVM Tool Definitions...
36#
37LCC      = $(LLVMGCCDIR)/bin/gcc
38LCC1     = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1
39LCXX     = $(LLVMGCCDIR)/bin/g++
40LCC1XX   = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1plus
41LLI      = $(TOOLS)/lli
42LLC      = $(TOOLS)/llc
43LAS      = $(TOOLS)/as
44LGCCAS   = $(TOOLS)/gccas
45LGCCLD   = $(TOOLS)/gccld -L$(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/lib
46LGCCLDPROG = $(TOOLS)/gccld
47LDIS     = $(TOOLS)/dis 
48LOPT     = $(TOOLS)/opt
49LLINK    = $(TOOLS)/link
50LANALYZE = $(TOOLS)/analyze
51LBUGPOINT= $(TOOLS)/bugpoint
52
53LCCFLAGS  += -O2 -Wall
54LCXXFLAGS += -O2 -Wall
55LLCFLAGS =
56FAILURE  = $(LEVEL)/test/Failure.sh
57TESTRUNR = @echo Running test: $<; \
58             PATH=$(LLVMTOOLCURRENT):$(LEVEL)/test/Scripts:$(PATH) \
59                  $(LEVEL)/test/TestRunner.sh
60
61# Native Tool Definitions
62NATGCC  = $(CC)
63CP	= /bin/cp -f
64
65## If TRACE or TRACEM is "yes", set the appropriate llc flag (-trace or -tracem)
66## mark that tracing on, and set the TRACELIBS variable.
67TRACEFLAGS = 
68DOTRACING  =
69ifeq ($(TRACE), yes)
70    TRACEFLAGS += -trace
71    DOTRACING = yes
72else
73    ifeq ($(TRACEM), yes)
74	TRACEFLAGS += -tracem
75	DOTRACING = yes
76    endif
77endif
78ifdef DOTRACING
79    TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr.$(ARCH)
80endif
81
82
83LLCLIBS := $(LLCLIBS) -lm
84
85clean::
86	$(RM) -f a.out core
87	$(RM) -rf Output/
88
89# Compile from X.c to Output/X.ll
90Output/%.ll: $(SourceDir)%.c $(LCC1) Output/.dir $(INCLUDES)
91	$(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@
92
93# Compile from X.cpp to Output/X.ll
94Output/%.ll: $(SourceDir)%.cpp $(LCC1XX) Output/.dir $(INCLUDES)
95	$(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
96
97# Compile from X.cc to Output/X.ll
98Output/%.ll: $(SourceDir)%.cc $(LCC1XX) Output/.dir $(INCLUDES)
99	$(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
100
101# LLVM Assemble from Output/X.ll to Output/X.bc.  Output/X.ll must have come
102# from GCC output, so use GCCAS.
103#
104Output/%.bc: Output/%.ll $(LGCCAS)
105	$(LGCCAS) $(STATS) $< -o $@
106
107# LLVM Assemble from X.ll to Output/X.bc.  Because we are coming directly from
108# LLVM source, use the non-transforming assembler.
109#
110Output/%.bc: %.ll $(LAS) Output/.dir
111	$(LAS) -f $< -o $@
112
113#
114# Testing versions of provided utilities...
115#
116Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
117	@echo "======== Compiling $<"
118	$(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ || \
119	    ( rm -f $@; $(FAILURE) $@ )
120
121Output/%.tll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES)
122	@echo "======== Compiling $<"
123	$(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ || \
124	    ( rm -f $@; $(FAILURE) $@ )
125
126Output/%.tbc: Output/%.tll $(LAS)
127	@echo "======== Assembling $<"
128	$(LAS) -f $< -o $@ || \
129            ( rm -f $@; $(FAILURE) $@ )
130
131
132## Cancel built-in implicit rules that override above rules
133%: %.s
134
135%: %.c
136
137%.o: %.c
138
139