Makefile.tests revision 054385a11aeb22f184d8619c14100577406c9a2c
1## -*-Makefile-*- 2##------------------------------------------------------------------------ 3## Common rules for generating, linking, and compiling via LLVM. 4##------------------------------------------------------------------------ 5 6.PHONY: clean default 7 8## keep %.linked.bc from being deleted 9.PRECIOUS: %.linked.bc 10 11 12TOOLS = $(LEVEL)/tools/Debug 13 14LLC = $(TOOLS)/llc 15LAS = $(TOOLS)/as 16LDIS = $(TOOLS)/dis 17LOPT = $(TOOLS)/opt 18LLINK = $(TOOLS)/link 19LLCFLAGS = 20 21LCC = /home/vadve/lattner/cvs/gcc_install/bin/gcc 22LCFLAGS = -O2 $(LOCAL_CFLAGS) -Wall 23 24LLCLIB = $(LEVEL)/test/runtime.o 25LIBS = $(LLCLIB) $(LOCAL_LIBS) 26 27ifeq ($(TRACE), yes) 28 LLCFLAGS := $(LLCFLAGS) -trace 29endif 30 31CC = /opt/SUNWspro/bin/cc 32AS = /opt/SUNWspro/bin/cc 33DIS = /usr/ccs/bin/dis 34CP = /bin/cp -p 35CFLAGS = -g -xarch=v9 36CCFLAGS = $(CFLAGS) 37LDFLAGS = $(CFLAGS) 38ASFLAGS = -c $(CFLAGS) 39 40## Special targets to build a program from multiple source files 41## 42ifdef 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 $@ 54 55 $(PROG).clean.bc: $(PROG).linked.bc 56 $(LOPT) -cleangcc -raise -constprop -dce < $< > $@ 57 58 $(PROG).native: $(OBJS:.o=.c) 59 gcc $(OBJS:.o=.c) -O2 $(LOCAL_CFLAGS) -Wall -o $@ 60 61endif 62 63## Special target to force target-dependent library to be compiled 64## directly to native code. 65## 66$(LLCLIB): 67 cd $(LEVEL)/test; $(MAKE) $(@F) 68 69runtime.o: runtime.c 70 $(CC) -c $(CCFLAGS) $< 71 72clean : 73 $(RM) *.[123] *.bc *.mc *.s *.o a.out core $(PROG) 74 75%.mc: %.bc $(LLC) $(AS) 76 @echo "Generating machine instructions for $<" 77 $(LLC) -f -dsched y $(LLCFLAGS) $< > $@ 78 79%.trace.bc: %.bc $(LLC) 80 $(LLC) -f -trace $(LLCFLAGS) $< 81 82## Leave this rule out to avoid problems in tests that have both .c and .ll 83## %.ll: %.c 84## $(LCC) $(LCFLAGS) -S $< -o $*.ll 85 86%.bc: %.c 87 $(LCC) $(LCFLAGS) -c $< -o $*.tmp.bc 88 $(LOPT) -cleangcc -raise -constprop -dce $*.tmp.bc -o $@ 89 $(RM) $*.tmp.bc 90 91%.bc: %.ll 92 $(LAS) -f $< 93 94%.linked.bc: %.bc 95 $(CP) $< $@ 96 97%.s: %.clean.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 119