Make gcc generate assembly files (%.ll) until Chris has a stable
[oota-llvm.git] / test / Makefile.tests
1 ## -*-Makefile-*-
2 ##------------------------------------------------------------------------
3 ## Common rules for generating, linking, and compiling via LLVM.
4 ##------------------------------------------------------------------------
5
6 .PHONY: clean default
7
8 ## Special targets to build a program from multiple source files
9 ## 
10 ifdef PROG
11   default:    $(PROG)
12   .SECONDARY: $(PROG).clean.bc  ## keep %.clean.bc from being deleted
13
14   $(PROG).bc: $(OBJS)
15         $(LLINK) -f $(OBJS) -o $@
16 endif
17
18 TOOLS    = $(LEVEL)/tools/Debug
19
20 LLC      = $(TOOLS)/llc
21 LAS      = $(TOOLS)/as
22 LDIS     = $(TOOLS)/dis 
23 LOPT     = $(TOOLS)/opt
24 LLINK    = $(TOOLS)/link
25 LLCFLAGS =
26
27 LCC      = /home/vadve/lattner/cvs/gcc_install/bin/gcc
28 LCFLAGS  = -O2 $(LOCAL_CFLAGS) -Wall
29
30 LLCLIB   = $(LEVEL)/test/runtime.o
31 LIBS     = $(LLCLIB) $(LOCAL_LIBS)
32
33 ifeq ($(TRACE), yes)
34     LLCFLAGS := $(LLCFLAGS) -trace
35 endif
36
37 CC      = /opt/SUNWspro/bin/cc
38 AS      = /opt/SUNWspro/bin/cc
39 DIS     = /usr/ccs/bin/dis
40 CFLAGS  = -g -xarch=v9
41 CCFLAGS = $(CFLAGS)
42 LDFLAGS = $(CFLAGS)
43 ASFLAGS = -c $(CFLAGS)
44
45
46 ## Special target to force target-dependent library to be compiled
47 ## directly to native code.
48 ## 
49 $(LLCLIB):
50         cd $(LEVEL)/test; $(MAKE) $(@F)
51
52 runtime.o: runtime.c
53         $(CC) -c $(CCFLAGS) $<
54
55 clean :
56         rm -f *.[123] *.bc *.mc *.s *.o a.out core $(PROG) 
57
58 %.mc: %.bc $(LLC) $(AS)
59         @echo "Generating machine instructions for $<"
60         $(LLC) -f -dsched y $(LLCFLAGS) $< > $@
61
62 %.trace.bc: %.bc $(LLC)
63         $(LLC) -f -trace $(LLCFLAGS) $<
64
65 %.o: %.c
66         $(LCC) $(LCFLAGS) -S -o $*.ll $<
67         $(LAS) -o $@ $*.ll
68
69 %.bc: %.ll
70         $(LAS) -f $<
71
72 %.clean.bc: %.bc
73         $(LOPT) -cleangcc -raise -constprop -dce < $< > $@
74
75 %.s: %.bc
76         $(LLC) -f $(LLCOPTS) $<
77
78 %: %.o $(LIBS)
79         $(CC) -o $@ $(LDFLAGS) $< $(LIBS)
80
81 ## 
82 ## Use a single rule to go from %.bc to % to avoid ambiguity in
83 ## llvm bytecode files and native object code files, both named %.o
84 ## 
85 %: %.clean.bc $(LIBS)
86         $(LLC) -f $(LLCFLAGS) -o $*.s $<
87         $(AS) $(ASFLAGS) $*.s
88         $(CC) -o $@ $(LDFLAGS) $*.o $(LIBS)
89
90 ## Cancel built-in implicit rule that overrides the above rule
91 %: %.s
92
93 ## The next two rules are for disassembling an executable or an object file
94 %.dis: %
95         $(DIS) $< > $@
96
97 %.dis: %.o
98         $(DIS) $< > $@
99
100