Makefile.tests revision b0266b653694a99769f8f37be9ca26555f9ad8a8
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
16# We do not want to make .d files for tests! 
17DISABLE_AUTO_DEPENDENCIES=1
18
19include ${LEVEL}/Makefile.common
20
21# Specify ENABLE_STATS on the command line to enable -stats and -time-passes
22# output from gccas and gccld.
23ifdef ENABLE_STATS
24STATS = -stats -time-passes
25endif
26
27.PHONY: clean default
28
29# These files, which might be intermediate results, should not be deleted by
30# make
31.PRECIOUS: Output/%.bc  Output/%.ll
32.PRECIOUS: Output/%.tbc Output/%.tll
33.PRECIOUS: Output/.dir
34.PRECIOUS: Output/%.llvm.bc
35.PRECIOUS: Output/%.llvm
36
37# Find the location of the platform specific LLVM GCC libraries
38LLVMGCCLIBDIR=$(dir $(shell $(LLVMGCC) -print-file-name=libgcc.a))
39
40# LLVM Tool Definitions (LLVMGCC, LLVMGXX, LLVMAS are provided by Makefile.rules)
41LLI      = $(LLVMTOOLCURRENT)/lli$(EXEEXT)
42LLC      = $(LLVMTOOLCURRENT)/llc$(EXEEXT)
43LGCCAS   = $(LLVMTOOLCURRENT)/gccas$(EXEEXT)
44LGCCLD   = $(LGCCLDPROG) -L$(LLVMGCCLIBDIR) -L$(LLVMGCCDIR)/lib
45LDIS     = $(LLVMTOOLCURRENT)/llvm-dis$(EXEEXT)
46LOPT     = $(LLVMTOOLCURRENT)/opt$(EXEEXT)
47LLINK    = $(LLVMTOOLCURRENT)/llvm-link$(EXEEXT)
48LPROF    = $(LLVMTOOLCURRENT)/llvm-prof$(EXEEXT)
49LANALYZE = $(LLVMTOOLCURRENT)/analyze$(EXEEXT)
50LBUGPOINT= $(LLVMTOOLCURRENT)/bugpoint$(EXEEXT)
51
52LCCFLAGS  += -O2 -Wall
53LCXXFLAGS += -O2 -Wall
54LLCFLAGS =
55FAILURE  = $(LLVM_SRC_ROOT)/test/Failure.sh
56TESTRUNR = @echo Running test: $<; \
57             PATH=$(LLVMTOOLCURRENT):$(LLVM_SRC_ROOT)/test/Scripts:$(PATH) \
58                  $(LLVM_SRC_ROOT)/test/TestRunner.sh
59
60LLCLIBS := $(LLCLIBS) -lm
61
62clean::
63	$(RM) -f a.out core
64	$(RM) -rf Output/
65
66# Compile from X.c to Output/X.ll
67Output/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES)
68	-$(LLVMGCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@
69
70# Compile from X.cpp to Output/X.ll
71Output/%.ll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES)
72	-$(LLVMGXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
73
74# Compile from X.cc to Output/X.ll
75Output/%.ll: %.cc $(LCC1XX) Output/.dir $(INCLUDES)
76	-$(LLVMGXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
77
78# LLVM Assemble from Output/X.ll to Output/X.bc.  Output/X.ll must have come
79# from GCC output, so use GCCAS.
80#
81Output/%.bc: Output/%.ll $(LGCCAS)
82	-$(LGCCAS) $(STATS) $< -o $@
83
84# LLVM Assemble from X.ll to Output/X.bc.  Because we are coming directly from
85# LLVM source, use the non-transforming assembler.
86#
87Output/%.bc: %.ll $(LLVMAS) Output/.dir
88	-$(LLVMAS) -f $< -o $@
89
90## Cancel built-in implicit rules that override above rules
91%: %.s
92
93%: %.c
94
95%.o: %.c
96
97