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