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