1 ##----------------------------------------------------------*- Makefile -*-===##
3 ## Common rules for generating, linking, and compiling via LLVM. This is
4 ## used to implement a robust testing framework for LLVM
6 ##-------------------------------------------------------------------------===##
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
16 include ${LEVEL}/Makefile.common
18 # Specify ENABLE_STATS on the command line to enable -stats and -time-passes
19 # output from gccas and gccld.
21 STATS = -stats -time-passes
27 # These files, which might be intermediate results, should not be deleted by
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
35 TOOLS = $(LLVMTOOLCURRENT)
37 # LLVM Tool Definitions...
39 LCC = $(LLVMGCC) ## FIXME: remove these definitions, use LLVMGCC directly
40 LCXX = $(LLVMGXX) ## FIXME: remove these definitions, use LLVMGXX directly
41 LAS = $(LLVMAS) ## FIXME: remove these definitions, use LLVMAS directly
45 LGCCAS = $(TOOLS)/gccas
46 LGCCLD = $(TOOLS)/gccld -L$(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/lib
47 LGCCLDPROG = $(TOOLS)/gccld
51 LANALYZE = $(TOOLS)/analyze
52 LBUGPOINT= $(TOOLS)/bugpoint
55 LCXXFLAGS += -O2 -Wall
57 FAILURE = $(LEVEL)/test/Failure.sh
58 TESTRUNR = @echo Running test: $<; \
59 PATH=$(LLVMTOOLCURRENT):$(LEVEL)/test/Scripts:$(PATH) \
60 $(LEVEL)/test/TestRunner.sh
62 # Native Tool Definitions
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.
71 TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr.$(ARCH)
76 TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr.$(ARCH)
79 LLCLIBS := $(LLCLIBS) -lm
85 # Compile from X.c to Output/X.ll
86 Output/%.ll: $(SourceDir)%.c $(LCC1) Output/.dir $(INCLUDES)
87 $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@
89 # Compile from X.cpp to Output/X.ll
90 Output/%.ll: $(SourceDir)%.cpp $(LCC1XX) Output/.dir $(INCLUDES)
91 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
93 # Compile from X.cc to Output/X.ll
94 Output/%.ll: $(SourceDir)%.cc $(LCC1XX) Output/.dir $(INCLUDES)
95 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
97 # LLVM Assemble from Output/X.ll to Output/X.bc. Output/X.ll must have come
98 # from GCC output, so use GCCAS.
100 Output/%.bc: Output/%.ll $(LGCCAS)
101 $(LGCCAS) $(STATS) $< -o $@
103 # LLVM Assemble from X.ll to Output/X.bc. Because we are coming directly from
104 # LLVM source, use the non-transforming assembler.
106 Output/%.bc: %.ll $(LAS) Output/.dir
110 # Testing versions of provided utilities...
112 Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
113 @echo "======== Compiling $<"
114 $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ || \
115 ( rm -f $@; $(FAILURE) $@ )
117 Output/%.tll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES)
118 @echo "======== Compiling $<"
119 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ || \
120 ( rm -f $@; $(FAILURE) $@ )
122 Output/%.tbc: Output/%.tll $(LAS)
123 @echo "======== Assembling $<"
124 $(LAS) -f $< -o $@ || \
125 ( rm -f $@; $(FAILURE) $@ )
128 ## Cancel built-in implicit rules that override above rules