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 ifdef ENABLE_OPTIMIZED
34 TOOLS = $(BUILD_OBJ_ROOT)/tools/Release
36 TOOLS = $(BUILD_OBJ_ROOT)/tools/Debug
39 # LLVM Tool Definitions...
41 LCC = $(LLVMGCCDIR)/bin/gcc
42 LCC1 = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1
43 LCXX = $(LLVMGCCDIR)/bin/g++
44 LCC1XX = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1plus
48 LGCCAS = $(TOOLS)/gccas
49 LGCCLD = $(TOOLS)/gccld -L$(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/lib
53 LANALYZE = $(TOOLS)/analyze
54 LBUGPOINT= $(TOOLS)/bugpoint
57 LCXXFLAGS += -O2 -Wall
59 FAILURE = $(LEVEL)/test/Failure.sh
60 TESTRUNR = $(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.
78 ifeq ($(DOTRACING), yes)
79 TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
83 LLCLIBS := $(LLCLIBS) -lm
89 # Compile from X.c to Output/X.ll
90 Output/%.ll: $(SourceDir)%.c $(LCC1) Output/.dir $(INCLUDES)
91 $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@
93 # Compile from X.cpp to Output/X.ll
94 Output/%.ll: $(SourceDir)%.cpp $(LCC1XX) Output/.dir $(INCLUDES)
95 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
97 # Compile from X.cc to Output/X.ll
98 Output/%.ll: $(SourceDir)%.cc $(LCC1XX) Output/.dir $(INCLUDES)
99 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
101 # LLVM Assemble from Output/X.ll to Output/X.bc. Output/X.ll must have come
102 # from GCC output, so use GCCAS.
104 Output/%.bc: Output/%.ll $(LGCCAS)
105 $(LGCCAS) $(STATS) $< -o $@
107 # LLVM Assemble from X.ll to Output/X.bc. Because we are coming directly from
108 # LLVM source, use the non-transforming assembler.
110 Output/%.bc: %.ll $(LAS) Output/.dir
114 # Testing versions of provided utilities...
116 Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
117 @echo "======== Compiling $<"
118 $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ || \
119 ( rm -f $@; $(FAILURE) $@ )
121 Output/%.tll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES)
122 @echo "======== Compiling $<"
123 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ || \
124 ( rm -f $@; $(FAILURE) $@ )
126 Output/%.tbc: Output/%.tll $(LAS)
127 @echo "======== Assembling $<"
128 $(LAS) -f $< -o $@ || \
129 ( rm -f $@; $(FAILURE) $@ )
132 ## Cancel built-in implicit rules that override above rules