Makefile.tests revision 90c7d67b9d505354f8138d01df82c2fdcff6d5d2
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## NOTE: This is preliminary and will change in the future
7
8
9include ${LEVEL}/Makefile.common
10
11.PHONY: clean default
12
13# These files, which might be intermediate results, should not be deleted by
14# make
15.PRECIOUS: Output/%.bc  Output/%.ll
16.PRECIOUS: Output/%.tbc Output/%.tll
17.PRECIOUS: Output/.dir
18.PRECIOUS: Output/%.llvm.bc
19.PRECIOUS: Output/%.llvm
20
21# LLVM Tool Definitions...
22#
23LCC      = $(LLVMGCCDIR)/bin/llvm-gcc
24LCC1     = $(LLVMGCCDIR)/lib/gcc-lib/llvm/3.1/cc1
25TOOLS    = $(BUILD_ROOT_TOP)/tools/Debug
26LLI      = $(TOOLS)/lli
27LLC      = $(TOOLS)/llc
28LAS      = $(TOOLS)/as
29LGCCAS   = $(TOOLS)/gccas
30LGCCLD   = $(TOOLS)/gccld -L$(LLVMGCCDIR)/llvm/lib
31LDIS     = $(TOOLS)/dis 
32LOPT     = $(TOOLS)/opt
33LLINK    = $(TOOLS)/link
34LANALYZE = $(TOOLS)/analyze
35
36LCCFLAGS  += -O2 -Wall
37LLCFLAGS =
38FAILURE  = $(LEVEL)/test/Failure.sh
39TESTRUNR = $(LEVEL)/test/TestRunner.sh
40
41# Native Tool Definitions
42NATGCC  = /usr/dcs/software/supported/bin/gcc
43## CC      = /opt/SUNWspro/bin/cc
44## AS	= /opt/SUNWspro/bin/cc
45## DIS     = /usr/ccs/bin/dis
46## CFLAGS  += -g -xarch=v9
47CP	= /bin/cp -f
48
49
50ifeq ($(TRACE), yes)
51    LLCFLAGS += -trace basicblock
52    LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
53else
54    ifeq ($(TRACEM), yes)
55        LLCFLAGS += -trace function
56	LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
57    endif
58endif
59
60LLCLIBS := $(LLCLIBS) -lm
61
62clean::
63	$(RM) a.out core
64	$(RM) -rf Output/
65
66# Compile from X.c to Output/X.ll
67Output/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES)
68	$(LCC) $(LCCFLAGS) -S $< -o $@
69
70# LLVM Assemble from Output/X.ll to Output/X.bc.  Output/X.ll must have come
71# from GCC output, so use GCCAS.
72#
73Output/%.bc: Output/%.ll $(LGCCAS)
74	$(LGCCAS) $< -o $@
75
76# LLVM Assemble from X.ll to Output/X.bc.  Because we are coming directly from
77# LLVM source, use the non-transforming assembler.
78#
79Output/%.bc: %.ll $(LAS) Output/.dir
80	$(LAS) -f $< -o $@
81
82# Compile a linked program to machine code for this processor.
83#
84Output/%.llc.s: Output/%.llvm.bc
85	$(LLC) $(LLCFLAGS) -f $< -o $@
86
87# Assemble (and link) an LLVM-linked program using the system assembler...
88#
89Output/%.llc: Output/%.llc.s
90	$(CC) $(CFLAGS) $< $(LLCLIBS) -o $@
91
92#
93# Testing versions of provided utilities...
94#
95Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
96	@echo "======== Compiling $<"
97	$(LCC) $(LCCFLAGS) -S $< -o $@ || \
98	    ( rm -f $@; $(FAILURE) $@ )
99
100Output/%.tbc: Output/%.tll $(LAS)
101	@echo "======== Assembling $<"
102	$(LAS) -f $< -o $@ || \
103            ( rm -f $@; $(FAILURE) $@ )
104
105
106## Cancel built-in implicit rules that override above rules
107%: %.s
108
109%: %.c
110
111%.o: %.c
112
113