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 ## NOTE: This is preliminary and will change in the future
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 ifdef ENABLE_OPTIMIZED
36 TOOLS = $(BUILD_ROOT_TOP)/tools/Release
38 TOOLS = $(BUILD_ROOT_TOP)/tools/Debug
41 # LLVM Tool Definitions...
43 LCC = $(LLVMGCCDIR)/bin/llvm-gcc
44 LCC1 = $(LLVMGCCDIR)/lib/gcc-lib/llvm/3.1/cc1
48 LGCCAS = $(TOOLS)/gccas
49 LGCCLD = $(TOOLS)/gccld -L$(LLVMGCCDIR)/llvm/lib
53 LANALYZE = $(TOOLS)/analyze
54 LBUGPOINT= $(TOOLS)/bugpoint
58 FAILURE = $(LEVEL)/test/Failure.sh
59 TESTRUNR = $(LEVEL)/test/TestRunner.sh
61 # Native Tool Definitions
62 NATGCC = /usr/dcs/software/supported/bin/gcc
65 ifndef DISABLE_LLC_DIFFS
66 CC = /opt/SUNWspro/bin/cc
67 AS = /opt/SUNWspro/bin/cc
68 DIS = /usr/ccs/bin/dis
69 CFLAGS += -g -xarch=v9
74 LLCFLAGS += -trace basicblock
75 LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
78 LLCFLAGS += -trace function
79 LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
83 LLCLIBS := $(LLCLIBS) -lm
89 # Compile from X.c to Output/X.ll
90 Output/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES)
91 $(LCC) $(LCCFLAGS) -S $< -o $@
93 # LLVM Assemble from Output/X.ll to Output/X.bc. Output/X.ll must have come
94 # from GCC output, so use GCCAS.
96 Output/%.bc: Output/%.ll $(LGCCAS)
97 $(LGCCAS) $(STATS) $< -o $@
99 # LLVM Assemble from X.ll to Output/X.bc. Because we are coming directly from
100 # LLVM source, use the non-transforming assembler.
102 Output/%.bc: %.ll $(LAS) Output/.dir
105 # Compile a linked program to machine code for this processor.
107 Output/%.llc.s: Output/%.llvm.bc $(LLC)
108 $(LLC) $(LLCFLAGS) -f $< -o $@
110 # Assemble (and link) an LLVM-linked program using the system assembler...
112 Output/%.llc: Output/%.llc.s
113 $(CC) $(CFLAGS) $< $(LLCLIBS) -o $@
116 # Testing versions of provided utilities...
118 Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
119 @echo "======== Compiling $<"
120 $(LCC) $(LCCFLAGS) -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