166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman##----------------------------------------------------------*- Makefile -*-===## 266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman## 366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman## Common rules for generating, linking, and compiling via LLVM. This is 466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman## used to implement a robust testing framework for LLVM 566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman## 666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman##-------------------------------------------------------------------------===## 766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# If the user specified a TEST= option on the command line, we do not want to do 966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# the default testing type. Instead, we change the default target to be the 1066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# test:: target. 1166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# 1266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanifdef TEST 1366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumantest:: 1466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanendif 1566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 1666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# We do not want to make .d files for tests! 1766b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanDISABLE_AUTO_DEPENDENCIES=1 1866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 1966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumaninclude ${LEVEL}/Makefile.common 2066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 2166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# Specify ENABLE_STATS on the command line to enable -stats and -time-passes 2266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# output from gccas and gccld. 2366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanifdef ENABLE_STATS 2466b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanSTATS = -stats -time-passes 2566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanendif 2666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 2766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman.PHONY: clean default 2866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 2966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# These files, which might be intermediate results, should not be deleted by 3066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# make 3166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman.PRECIOUS: Output/%.bc Output/%.ll 3266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman.PRECIOUS: Output/%.tbc Output/%.tll 3366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman.PRECIOUS: Output/.dir 3466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman.PRECIOUS: Output/%.llvm.bc 3566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman.PRECIOUS: Output/%.llvm 3666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 3766b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanLCCFLAGS += -O2 -Wall 3866b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanLCXXFLAGS += -O2 -Wall 3966b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanLLCFLAGS = 4066b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanTESTRUNR = @echo Running test: $<; \ 4166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman PATH="$(LLVMTOOLCURRENT):$(LLVM_SRC_ROOT)/test/Scripts:$(PATH)" \ 4266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman $(LLVM_SRC_ROOT)/test/TestRunner.sh 4366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 4466b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanLLCLIBS := $(LLCLIBS) -lm 4566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 4666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanclean:: 4766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman $(RM) -f a.out core 4866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman $(RM) -rf Output/ 4966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 5066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# Compile from X.c to Output/X.ll 5166b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanOutput/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES) 5266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman -$(LLVMCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ 5366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 5466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# Compile from X.cpp to Output/X.ll 5566b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanOutput/%.ll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES) 5666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman -$(LLVMCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ 5766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 5866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# Compile from X.cc to Output/X.ll 5966b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanOutput/%.ll: %.cc $(LCC1XX) Output/.dir $(INCLUDES) 6066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman -$(LLVMCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ 6166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 6266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# LLVM Assemble from Output/X.ll to Output/X.bc. Output/X.ll must have come 6366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# from GCC output, so use GCCAS. 6466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# 6566b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanOutput/%.bc: Output/%.ll $(LGCCAS) 6666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman -$(LGCCAS) $(STATS) $< -o $@ 6766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 6866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# LLVM Assemble from X.ll to Output/X.bc. Because we are coming directly from 6966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# LLVM source, use the non-transforming assembler. 7066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# 7166b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanOutput/%.bc: %.ll $(LLVMAS) Output/.dir 7266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman -$(LLVMAS) $< -o $@ 7366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 7466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman## Cancel built-in implicit rules that override above rules 7566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman%: %.s 7666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 7766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman%: %.c 7866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 7966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman%.o: %.c 8066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 81