aboutsummaryrefslogtreecommitdiffstats
path: root/test/Makefile.tests
blob: 7eb189e5412b05f1048505efd01e60c246a93054 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
.PHONY: clean default

## Special targets to build a program from multiple source files
## 
ifdef PROG
  default:    $(PROG)
  .SECONDARY: $(PROG).clean.bc	## keep %.clean.bc from being deleted

  $(PROG).bc: $(OBJS)
	$(LLINK) -f $(OBJS) -o $@
endif

TOOLS    = $(LEVEL)/tools/Debug

LLC      = $(TOOLS)/llc
LAS      = $(TOOLS)/as
LDIS     = $(TOOLS)/dis 
LOPT     = $(TOOLS)/opt
LLINK    = $(TOOLS)/link
LLCFLAGS =

LCC      = /home/vadve/lattner/cvs/gcc_install/bin/gcc
LCFLAGS  = -DTORONTO -O2 $(LOCAL_CFLAGS) -Wall

LLCLIB   = $(LEVEL)/test/runtime.o
LIBS     = $(LLCLIB) $(LOCAL_LIBS)

ifeq ($(TRACE), yes)
    LLCFLAGS := $(LLCFLAGS) -trace
endif

CC      = /opt/SUNWspro/bin/cc
AS	= /opt/SUNWspro/bin/cc
DIS     = /usr/ccs/bin/dis
CFLAGS  = -g -xarch=v9
CCFLAGS = $(CFLAGS)
LDFLAGS = $(CFLAGS)
ASFLAGS = -c $(CFLAGS)


## Special target to force target-dependent library to be compiled
## directly to native code.
## 
$(LLCLIB):
	cd $(LEVEL)/test; $(MAKE) $(@F)

runtime.o: runtime.c
	$(CC) -c $(CCFLAGS) $<

clean :
	rm -f *.[123] *.bc *.mc *.s *.o a.out core $(PROG) 

%.mc: %.bc $(LLC) $(AS)
	@echo "Generating machine instructions for $<"
	$(LLC) -f -dsched y $(LLCFLAGS) $< > $@

%.trace.bc: %.bc $(LLC)
	$(LLC) -f -trace $(LLCFLAGS) $<

%.o: %.c
	$(LCC) $(LCFLAGS) -c $<

%.bc: %.ll
	$(LAS) -f $<

%.ll: %.bc
	$(LDIS) -f $<

%.clean.bc: %.bc
	$(LOPT) -cleangcc -raise -constprop -dce < $< > $@

%.s: %.bc
	$(LLC) -f $(LLCOPTS) $<

%: %.o $(LIBS)
	$(CC) -o $@ $(LDFLAGS) $< $(LIBS)

## 
## Use a single rule to go from %.bc to % to avoid ambiguity in
## llvm bytecode files and native object code files, both named %.o
## 
%: %.clean.bc $(LIBS)
	$(LLC) -f $(LLCFLAGS) -o $*.s $<
	$(AS) $(ASFLAGS) $*.s
	$(CC) -o $@ $(LDFLAGS) $*.o $(LIBS)

## Cancel built-in implicit rule that overrides the above rule
%: %.s

## The next two rules are for disassembling an executable or an object file
%.dis: %
	$(DIS) $< > $@

%.dis: %.o
	$(DIS) $< > $@