Makefile.tests revision 083de22d9fe81dac433d2a449fb8c0326920cf4f
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##-------------------------------------------------------------------------===## 5 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 8# test:: target. 9# 10ifdef TEST 11test:: 12endif 13 14include ${LEVEL}/Makefile.common 15 16# Specify ENABLE_STATS on the command line to enable -stats and -time-passes 17# output from gccas and gccld. 18ifdef ENABLE_STATS 19STATS = -stats -time-passes 20endif 21 22 23.PHONY: clean default 24 25# These files, which might be intermediate results, should not be deleted by 26# make 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 32 33TOOLS = $(LLVMTOOLCURRENT) 34 35# LLVM Tool Definitions... 36# 37LCC = $(LLVMGCCDIR)/bin/gcc 38LCC1 = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1 39LCXX = $(LLVMGCCDIR)/bin/g++ 40LCC1XX = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1plus 41LLI = $(TOOLS)/lli 42LLC = $(TOOLS)/llc 43LAS = $(TOOLS)/as 44LGCCAS = $(TOOLS)/gccas 45LGCCLD = $(TOOLS)/gccld -L$(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/lib 46LGCCLDPROG = $(TOOLS)/gccld 47LDIS = $(TOOLS)/dis 48LOPT = $(TOOLS)/opt 49LLINK = $(TOOLS)/link 50LANALYZE = $(TOOLS)/analyze 51LBUGPOINT= $(TOOLS)/bugpoint 52 53LCCFLAGS += -O2 -Wall 54LCXXFLAGS += -O2 -Wall 55LLCFLAGS = 56FAILURE = $(LEVEL)/test/Failure.sh 57TESTRUNR = PATH=$(LLVMTOOLCURRENT):$(PATH) $(LEVEL)/test/TestRunner.sh 58 59# Native Tool Definitions 60NATGCC = $(CC) 61CP = /bin/cp -f 62 63## If TRACE or TRACEM is "yes", set the appropriate llc flag (-trace or -tracem) 64## mark that tracing on, and set the TRACELIBS variable. 65TRACEFLAGS = 66ifeq ($(TRACE), yes) 67 TRACEFLAGS += -trace 68 DOTRACING = yes 69else 70 ifeq ($(TRACEM), yes) 71 TRACEFLAGS += -tracem 72 DOTRACING = yes 73 endif 74endif 75ifeq ($(DOTRACING), yes) 76 TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr64 77endif 78 79 80LLCLIBS := $(LLCLIBS) -lm 81 82clean:: 83 $(RM) a.out core 84 $(RM) -rf Output/ 85 86# Compile from X.c to Output/X.ll 87Output/%.ll: $(SourceDir)%.c $(LCC1) Output/.dir $(INCLUDES) 88 $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ 89 90# Compile from X.cpp to Output/X.ll 91Output/%.ll: $(SourceDir)%.cpp $(LCC1XX) Output/.dir $(INCLUDES) 92 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ 93 94# Compile from X.cc to Output/X.ll 95Output/%.ll: $(SourceDir)%.cc $(LCC1XX) Output/.dir $(INCLUDES) 96 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ 97 98# LLVM Assemble from Output/X.ll to Output/X.bc. Output/X.ll must have come 99# from GCC output, so use GCCAS. 100# 101Output/%.bc: Output/%.ll $(LGCCAS) 102 $(LGCCAS) $(STATS) $< -o $@ 103 104# LLVM Assemble from X.ll to Output/X.bc. Because we are coming directly from 105# LLVM source, use the non-transforming assembler. 106# 107Output/%.bc: %.ll $(LAS) Output/.dir 108 $(LAS) -f $< -o $@ 109 110# 111# Testing versions of provided utilities... 112# 113Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES) 114 @echo "======== Compiling $<" 115 $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ || \ 116 ( rm -f $@; $(FAILURE) $@ ) 117 118Output/%.tll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES) 119 @echo "======== Compiling $<" 120 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ || \ 121 ( rm -f $@; $(FAILURE) $@ ) 122 123Output/%.tbc: Output/%.tll $(LAS) 124 @echo "======== Assembling $<" 125 $(LAS) -f $< -o $@ || \ 126 ( rm -f $@; $(FAILURE) $@ ) 127 128 129## Cancel built-in implicit rules that override above rules 130%: %.s 131 132%: %.c 133 134%.o: %.c 135 136