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