Makefile.tests revision 9575a18c98b382038ddfe997a91389f0e73ba202
1##----------------------------------------------------------*- Makefile -*-===##
2##
3## Common rules for generating, linking, and compiling via LLVM.  This is
4## used to implement a robust testing framework for LLVM
5##
6##-------------------------------------------------------------------------===##
7
8# If the user specified a TEST= option on the command line, we do not want to do
9# the default testing type.  Instead, we change the default target to be the
10# test:: target.
11#
12ifdef TEST
13test::
14endif
15
16include ${LEVEL}/Makefile.common
17
18# Specify ENABLE_STATS on the command line to enable -stats and -time-passes
19# output from gccas and gccld.
20ifdef ENABLE_STATS
21STATS = -stats -time-passes
22endif
23
24
25.PHONY: clean default
26
27# These files, which might be intermediate results, should not be deleted by
28# make
29.PRECIOUS: Output/%.bc  Output/%.ll
30.PRECIOUS: Output/%.tbc Output/%.tll
31.PRECIOUS: Output/.dir
32.PRECIOUS: Output/%.llvm.bc
33.PRECIOUS: Output/%.llvm
34
35TOOLS    = $(LLVMTOOLCURRENT)
36
37# LLVM Tool Definitions...
38#
39LCC      = $(LLVMGCC)   ## FIXME: remove these definitions, use LLVMGCC directly
40LCXX     = $(LLVMGXX)   ## FIXME: remove these definitions, use LLVMGXX directly
41LAS      = $(LLVMAS)    ## FIXME: remove these definitions, use LLVMAS directly
42
43LLI      = $(TOOLS)/lli
44LLC      = $(TOOLS)/llc
45LGCCAS   = $(TOOLS)/gccas
46LGCCLD   = $(TOOLS)/gccld -L$(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/lib
47LGCCLDPROG = $(TOOLS)/gccld
48LDIS     = $(TOOLS)/dis 
49LOPT     = $(TOOLS)/opt
50LLINK    = $(TOOLS)/link
51LANALYZE = $(TOOLS)/analyze
52LBUGPOINT= $(TOOLS)/bugpoint
53
54LCCFLAGS  += -O2 -Wall
55LCXXFLAGS += -O2 -Wall
56LLCFLAGS =
57FAILURE  = $(LEVEL)/test/Failure.sh
58TESTRUNR = @echo Running test: $<; \
59             PATH=$(LLVMTOOLCURRENT):$(LEVEL)/test/Scripts:$(PATH) \
60                  $(LEVEL)/test/TestRunner.sh
61
62# Native Tool Definitions
63NATGCC  = $(CC)
64CP	= /bin/cp -f
65
66## If TRACE or TRACEM is "yes", set the appropriate llc flag (-trace or -tracem)
67## mark that tracing on, and set the TRACELIBS variable.
68TRACEFLAGS = 
69ifeq ($(TRACE), yes)
70    TRACEFLAGS = -trace
71    TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr.$(ARCH)
72endif
73
74ifeq ($(TRACEM), yes)
75    TRACEFLAGS = -tracem
76    TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr.$(ARCH)
77endif
78
79LLCLIBS := $(LLCLIBS) -lm
80
81clean::
82	$(RM) -f a.out core
83	$(RM) -rf Output/
84
85# Compile from X.c to Output/X.ll
86Output/%.ll: $(SourceDir)%.c $(LCC1) Output/.dir $(INCLUDES)
87	$(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@
88
89# Compile from X.cpp to Output/X.ll
90Output/%.ll: $(SourceDir)%.cpp $(LCC1XX) Output/.dir $(INCLUDES)
91	$(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
92
93# Compile from X.cc to Output/X.ll
94Output/%.ll: $(SourceDir)%.cc $(LCC1XX) Output/.dir $(INCLUDES)
95	$(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
96
97# LLVM Assemble from Output/X.ll to Output/X.bc.  Output/X.ll must have come
98# from GCC output, so use GCCAS.
99#
100Output/%.bc: Output/%.ll $(LGCCAS)
101	$(LGCCAS) $(STATS) $< -o $@
102
103# LLVM Assemble from X.ll to Output/X.bc.  Because we are coming directly from
104# LLVM source, use the non-transforming assembler.
105#
106Output/%.bc: %.ll $(LAS) Output/.dir
107	$(LAS) -f $< -o $@
108
109#
110# Testing versions of provided utilities...
111#
112Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
113	@echo "======== Compiling $<"
114	$(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ || \
115	    ( rm -f $@; $(FAILURE) $@ )
116
117Output/%.tll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES)
118	@echo "======== Compiling $<"
119	$(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ || \
120	    ( rm -f $@; $(FAILURE) $@ )
121
122Output/%.tbc: Output/%.tll $(LAS)
123	@echo "======== Assembling $<"
124	$(LAS) -f $< -o $@ || \
125            ( rm -f $@; $(FAILURE) $@ )
126
127
128## Cancel built-in implicit rules that override above rules
129%: %.s
130
131%: %.c
132
133%.o: %.c
134
135