Reorder paramters to make the command line more easily modifiable
[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
9 TOOLS    = $(LEVEL)/tools/Debug
10
11 LLC      = $(TOOLS)/llc
12 LAS      = $(TOOLS)/as
13 LDIS     = $(TOOLS)/dis 
14 LOPT     = $(TOOLS)/opt
15 LLINK    = $(TOOLS)/link
16 LLCFLAGS =
17
18 LCC      = /home/vadve/lattner/cvs/gcc_install/bin/gcc
19 LCFLAGS  = -O2 $(LOCAL_CFLAGS) -Wall
20
21 LLCLIB   = $(LEVEL)/test/runtime.o
22 LIBS     = $(LLCLIB) $(LOCAL_LIBS)
23
24 ifeq ($(TRACE), yes)
25     LLCFLAGS := $(LLCFLAGS) -trace
26 endif
27
28 CC      = /opt/SUNWspro/bin/cc
29 AS      = /opt/SUNWspro/bin/cc
30 DIS     = /usr/ccs/bin/dis
31 CFLAGS  = -g -xarch=v9
32 CCFLAGS = $(CFLAGS)
33 LDFLAGS = $(CFLAGS)
34 ASFLAGS = -c $(CFLAGS)
35
36 ## Special targets to build a program from multiple source files
37 ## 
38 ifdef PROG
39
40 default:    $(PROG).clean.bc $(PROG).native
41   #.SECONDARY: $(PROG).clean.bc ## keep %.clean.bc from being deleted
42
43 $(PROG).bc: $(OBJS)
44         $(LLINK) -f $(OBJS) -o $@
45
46 $(PROG).native: $(OBJS:.o=.c)
47         gcc -o $@ $(OBJS:.o=.c) -O2 $(LOCAL_CFLAGS) -Wall
48 endif
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