Makefile.tests revision 01e6d2a4c7efcb030c58c2fa17f74ab4610b4463
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 33ifdef ENABLE_OPTIMIZED 34TOOLS = $(BUILD_OBJ_ROOT)/tools/Release 35else 36TOOLS = $(BUILD_OBJ_ROOT)/tools/Debug 37endif 38 39# LLVM Tool Definitions... 40# 41LCC = $(LLVMGCCDIR)/bin/gcc 42LCC1 = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1 43LCXX = $(LLVMGCCDIR)/bin/g++ 44LCC1XX = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1plus 45LLI = $(TOOLS)/lli 46LLC = $(TOOLS)/llc 47LAS = $(TOOLS)/as 48LGCCAS = $(TOOLS)/gccas 49LGCCLD = $(TOOLS)/gccld -L$(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/lib 50LDIS = $(TOOLS)/dis 51LOPT = $(TOOLS)/opt 52LLINK = $(TOOLS)/link 53LANALYZE = $(TOOLS)/analyze 54LBUGPOINT= $(TOOLS)/bugpoint 55 56LCCFLAGS += -O2 -Wall 57LCXXFLAGS += -O2 -Wall 58LLCFLAGS = 59FAILURE = $(LEVEL)/test/Failure.sh 60TESTRUNR = $(LEVEL)/test/TestRunner.sh 61 62# Native Tool Definitions 63NATGCC = $(CC) 64CP = /bin/cp -f 65 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. 68TRACEFLAGS = 69ifeq ($(TRACE), yes) 70 TRACEFLAGS += -trace 71 DOTRACING = yes 72else 73 ifeq ($(TRACEM), yes) 74 TRACEFLAGS += -tracem 75 DOTRACING = yes 76 endif 77endif 78ifeq ($(DOTRACING), yes) 79 TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr64 80endif 81 82 83LLCLIBS := $(LLCLIBS) -lm 84 85clean:: 86 $(RM) a.out core 87 $(RM) -rf Output/ 88 89# Compile from X.c to Output/X.ll 90Output/%.ll: $(SourceDir)%.c $(LCC1) Output/.dir $(INCLUDES) 91 $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ 92 93# Compile from X.cpp to Output/X.ll 94Output/%.ll: $(SourceDir)%.cpp $(LCC1XX) Output/.dir $(INCLUDES) 95 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ 96 97# Compile from X.cc to Output/X.ll 98Output/%.ll: $(SourceDir)%.cc $(LCC1XX) Output/.dir $(INCLUDES) 99 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ 100 101# LLVM Assemble from Output/X.ll to Output/X.bc. Output/X.ll must have come 102# from GCC output, so use GCCAS. 103# 104Output/%.bc: Output/%.ll $(LGCCAS) 105 $(LGCCAS) $(STATS) $< -o $@ 106 107# LLVM Assemble from X.ll to Output/X.bc. Because we are coming directly from 108# LLVM source, use the non-transforming assembler. 109# 110Output/%.bc: %.ll $(LAS) Output/.dir 111 $(LAS) -f $< -o $@ 112 113# 114# Testing versions of provided utilities... 115# 116Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES) 117 @echo "======== Compiling $<" 118 $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ || \ 119 ( rm -f $@; $(FAILURE) $@ ) 120 121Output/%.tll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES) 122 @echo "======== Compiling $<" 123 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ || \ 124 ( rm -f $@; $(FAILURE) $@ ) 125 126Output/%.tbc: Output/%.tll $(LAS) 127 @echo "======== Assembling $<" 128 $(LAS) -f $< -o $@ || \ 129 ( rm -f $@; $(FAILURE) $@ ) 130 131 132## Cancel built-in implicit rules that override above rules 133%: %.s 134 135%: %.c 136 137%.o: %.c 138 139