Use _LOCAL_ gccas to build instead of Chris's
[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 ## keep %.linked.bc and %.s from being deleted while we're debugging
9 .PRECIOUS: %.linked.bc %.s
10
11
12 TOOLS    = $(LEVEL)/tools/Debug
13
14 LLC      = $(TOOLS)/llc
15 LAS      = $(TOOLS)/as
16 LDIS     = $(TOOLS)/dis 
17 LOPT     = $(TOOLS)/opt
18 LLINK    = $(TOOLS)/link
19 LGCCAS   = $(TOOLS)/gccas
20 LLCFLAGS =
21
22 LCC      = /home/vadve/lattner/cvs/gcc_install/bin/gcc
23 LCFLAGS  = -O2 $(LOCAL_LCFLAGS) -Wall
24
25 LLCLIB   = $(LEVEL)/test/runtime.o
26 LIBS     = $(LLCLIB) $(LOCAL_LIBS)
27
28 ifeq ($(TRACE), yes)
29     LLCFLAGS := $(LLCFLAGS) -trace
30 endif
31
32 CC      = /opt/SUNWspro/bin/cc
33 AS      = /opt/SUNWspro/bin/cc
34 DIS     = /usr/ccs/bin/dis
35 CP      = /bin/cp -p
36 CFLAGS  = -g -xarch=v9 $(LOCAL_CFLAGS)
37 CCFLAGS = $(CFLAGS)
38 LDFLAGS = $(CFLAGS) $(LOCAL_LDFLAGS)
39 ASFLAGS = -c $(CFLAGS)
40
41 ## Special targets to build a program from multiple source files
42 ## 
43 ifdef PROG
44
45   default:    $(PROG) $(PROG).native
46
47   ifeq ($(strip $(OBJS)),)
48     BCOBJS = $(PROG).bc
49   else
50     BCOBJS = $(OBJS:.o=.bc)
51   endif
52
53   $(PROG).linked.bc: $(BCOBJS)
54         $(LLINK) -f $(BCOBJS) -o $(PROG).tmp.bc
55         $(LOPT) -cleangcc -raise -constprop -dce $(PROG).tmp.bc -o $@ -f
56         $(RM) $(PROG).tmp.bc
57
58   $(PROG).native: $(OBJS:.o=.c)
59         $(CC) $(OBJS:.o=.c) -O $(LOCAL_LCFLAGS) $(CFLAGS) -lm -o $@
60 endif
61
62 ## Special target to force target-dependent library to be compiled
63 ## directly to native code.
64 ## 
65 $(LLCLIB): $(LLCLIB:.o=.c)
66         cd $(LEVEL)/test; $(MAKE) $(@F)
67
68 runtime.o: runtime.c
69         $(CC) -c $(CCFLAGS) $<
70
71 clean :
72         $(RM) *.[123] *.bc *.mc *.s *.o a.out core $(PROG) $(PROG).native
73
74 %.mc: %.bc $(LLC) $(AS)
75         @echo "Generating machine instructions for $<"
76         $(LLC) -f -dsched y $(LLCFLAGS) $< > $@
77
78 %.trace.bc: %.bc $(LLC)
79         $(LLC) -f -trace $(LLCFLAGS) $<
80
81 ## Leave this rule out to avoid problems in tests that have both .c and .ll
82 ## %.ll: %.c
83 ##      $(LCC) $(LCFLAGS) -S $< -o $*.ll
84
85 %.gll: %.c
86         $(LCC) $(LCFLAGS) -S $< -o $@
87
88 %.bc: %.gll
89         $(LGCCAS) $< -o $@
90
91 %.bc: %.ll
92         $(LAS) -f $<
93
94 %.linked.bc: %.bc
95         $(CP) $< $@
96
97 %.s: %.linked.bc
98         $(LLC) -f $(LLCFLAGS) $< -o $@
99
100 %: %.o $(LIBS)
101         $(CC) $(LDFLAGS) $< $(LIBS) -o $@
102
103
104 ## Cancel built-in implicit rules that override above rules
105 %: %.s
106
107 %: %.c
108
109 %.o: %.c
110
111 ## The next two rules are for disassembling an executable or an object file
112 %.dis: %
113         $(DIS) $< > $@
114
115 %.dis: %.o
116         $(DIS) $< > $@
117
118