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 # We do not want to make .d files for tests!
17 DISABLE_AUTO_DEPENDENCIES=1
19 include ${LEVEL}/Makefile.common
21 # Specify ENABLE_STATS on the command line to enable -stats and -time-passes
22 # output from gccas and gccld.
24 STATS = -stats -time-passes
29 # These files, which might be intermediate results, should not be deleted by
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
37 TOOLS = $(LLVMTOOLCURRENT)
39 # LLVM Tool Definitions...
41 LCC = $(LLVMGCC) ## FIXME: remove these definitions, use LLVMGCC directly
42 LCXX = $(LLVMGXX) ## FIXME: remove these definitions, use LLVMGXX directly
43 LAS = $(LLVMAS) ## FIXME: remove these definitions, use LLVMAS directly
47 LGCCAS = $(TOOLS)/gccas
48 LGCCLD = $(LGCCLDPROG) -L$(LLVMGCCDIR)/lib/gcc/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/lib
49 LDIS = $(TOOLS)/llvm-dis
51 LLINK = $(TOOLS)/llvm-link
52 LANALYZE = $(TOOLS)/analyze
53 LBUGPOINT= $(TOOLS)/bugpoint
56 LCXXFLAGS += -O2 -Wall
58 FAILURE = $(LLVM_SRC_ROOT)/test/Failure.sh
59 TESTRUNR = @echo Running test: $<; \
60 PATH=$(LLVMTOOLCURRENT):$(LLVM_SRC_ROOT)/test/Scripts:$(PATH) \
61 $(LLVM_SRC_ROOT)/test/TestRunner.sh
63 # Native Tool Definitions
67 ## If TRACE or TRACEM is "yes", set the appropriate llc flag (-trace or -tracem)
68 ## mark that tracing on, and set the TRACELIBS variable.
72 TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr.$(ARCH)
77 TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr.$(ARCH)
80 LLCLIBS := $(LLCLIBS) -lm
86 # Compile from X.c to Output/X.ll
87 Output/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES)
88 $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@
90 # Compile from X.cpp to Output/X.ll
91 Output/%.ll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES)
92 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
94 # Compile from X.cc to Output/X.ll
95 Output/%.ll: %.cc $(LCC1XX) Output/.dir $(INCLUDES)
96 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
98 # LLVM Assemble from Output/X.ll to Output/X.bc. Output/X.ll must have come
99 # from GCC output, so use GCCAS.
101 Output/%.bc: Output/%.ll $(LGCCAS)
102 $(LGCCAS) $(STATS) $< -o $@
104 # LLVM Assemble from X.ll to Output/X.bc. Because we are coming directly from
105 # LLVM source, use the non-transforming assembler.
107 Output/%.bc: %.ll $(LAS) Output/.dir
111 # Testing versions of provided utilities...
113 Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
114 @echo "======== Compiling $<"
115 $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ || \
116 ( rm -f $@; $(FAILURE) $@ )
118 Output/%.tll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES)
119 @echo "======== Compiling $<"
120 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ || \
121 ( rm -f $@; $(FAILURE) $@ )
123 Output/%.tbc: Output/%.tll $(LAS)
124 @echo "======== Assembling $<"
125 $(LAS) -f $< -o $@ || \
126 ( rm -f $@; $(FAILURE) $@ )
129 ## Cancel built-in implicit rules that override above rules