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 ##-------------------------------------------------------------------------===##
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
14 include ${LEVEL}/Makefile.common
16 # Specify ENABLE_STATS on the command line to enable -stats and -time-passes
17 # output from gccas and gccld.
19 STATS = -stats -time-passes
25 # These files, which might be intermediate results, should not be deleted by
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
33 TOOLS = $(LLVMTOOLCURRENT)
35 # LLVM Tool Definitions...
37 LCC = $(LLVMGCCDIR)/bin/gcc
38 LCC1 = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1
39 LCXX = $(LLVMGCCDIR)/bin/g++
40 LCC1XX = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1plus
44 LGCCAS = $(TOOLS)/gccas
45 LGCCLD = $(TOOLS)/gccld -L$(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/lib
46 LGCCLDPROG = $(TOOLS)/gccld
50 LANALYZE = $(TOOLS)/analyze
51 LBUGPOINT= $(TOOLS)/bugpoint
54 LCXXFLAGS += -O2 -Wall
56 FAILURE = $(LEVEL)/test/Failure.sh
57 TESTRUNR = @echo Running test: $<; \
58 PATH=$(LLVMTOOLCURRENT):$(LEVEL)/test/Scripts:$(PATH) \
59 $(LEVEL)/test/TestRunner.sh
61 # Native Tool Definitions
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.
77 ifeq ($(DOTRACING), yes)
78 TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr.$(ARCH)
82 LLCLIBS := $(LLCLIBS) -lm
88 # Compile from X.c to Output/X.ll
89 Output/%.ll: $(SourceDir)%.c $(LCC1) Output/.dir $(INCLUDES)
90 $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@
92 # Compile from X.cpp to Output/X.ll
93 Output/%.ll: $(SourceDir)%.cpp $(LCC1XX) Output/.dir $(INCLUDES)
94 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
96 # Compile from X.cc to Output/X.ll
97 Output/%.ll: $(SourceDir)%.cc $(LCC1XX) Output/.dir $(INCLUDES)
98 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
100 # LLVM Assemble from Output/X.ll to Output/X.bc. Output/X.ll must have come
101 # from GCC output, so use GCCAS.
103 Output/%.bc: Output/%.ll $(LGCCAS)
104 $(LGCCAS) $(STATS) $< -o $@
106 # LLVM Assemble from X.ll to Output/X.bc. Because we are coming directly from
107 # LLVM source, use the non-transforming assembler.
109 Output/%.bc: %.ll $(LAS) Output/.dir
113 # Testing versions of provided utilities...
115 Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
116 @echo "======== Compiling $<"
117 $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ || \
118 ( rm -f $@; $(FAILURE) $@ )
120 Output/%.tll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES)
121 @echo "======== Compiling $<"
122 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ || \
123 ( rm -f $@; $(FAILURE) $@ )
125 Output/%.tbc: Output/%.tll $(LAS)
126 @echo "======== Assembling $<"
127 $(LAS) -f $< -o $@ || \
128 ( rm -f $@; $(FAILURE) $@ )
131 ## Cancel built-in implicit rules that override above rules