From a46fb6bb901d0dea25281b24a8eff89a2e39ce46 Mon Sep 17 00:00:00 2001 From: "Vikram S. Adve" Date: Tue, 6 Nov 2001 17:09:49 +0000 Subject: [PATCH] Really fix Makefile to compile individual tests and Olden codes. by using a better naming scheme. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1156 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Makefile.target | 57 ++++++++++++++++++++++++++------------------ test/Makefile.tests | 57 ++++++++++++++++++++++++++------------------ 2 files changed, 68 insertions(+), 46 deletions(-) diff --git a/test/Makefile.target b/test/Makefile.target index eb0ea0eb7d1..e95724c2f03 100644 --- a/test/Makefile.target +++ b/test/Makefile.target @@ -5,6 +5,9 @@ .PHONY: clean default +## keep %.linked.bc from being deleted +.PRECIOUS: %.linked.bc + TOOLS = $(LEVEL)/tools/Debug @@ -28,6 +31,7 @@ endif CC = /opt/SUNWspro/bin/cc AS = /opt/SUNWspro/bin/cc DIS = /usr/ccs/bin/dis +CP = /bin/cp -p CFLAGS = -g -xarch=v9 CCFLAGS = $(CFLAGS) LDFLAGS = $(CFLAGS) @@ -37,14 +41,19 @@ ASFLAGS = -c $(CFLAGS) ## ifdef PROG -default: $(PROG).clean.bc $(PROG).native - #.SECONDARY: $(PROG).clean.bc ## keep %.clean.bc from being deleted + default: $(PROG) $(PROG).native + + ifeq ($(strip $(OBJS)),) + BCOBJS = $(PROG).bc + else + BCOBJS = $(OBJS:.o=.bc) + endif -$(PROG).bc: $(OBJS) - $(LLINK) -f $(OBJS) -o $@ + $(PROG).linked.bc: $(BCOBJS) + $(LLINK) -f $(BCOBJS) -o $@ -$(PROG).native: $(OBJS:.o=.c) - gcc -o $@ $(OBJS:.o=.c) -O2 $(LOCAL_CFLAGS) -Wall + $(PROG).native: $(OBJS:.o=.c) + gcc $(OBJS:.o=.c) -O2 $(LOCAL_CFLAGS) -Wall -o $@ endif ## Special target to force target-dependent library to be compiled @@ -57,7 +66,7 @@ runtime.o: runtime.c $(CC) -c $(CCFLAGS) $< clean : - rm -f *.[123] *.bc *.mc *.s *.o a.out core $(PROG) + $(RM) *.[123] *.bc *.mc *.s *.o a.out core $(PROG) %.mc: %.bc $(LLC) $(AS) @echo "Generating machine instructions for $<" @@ -66,33 +75,35 @@ clean : %.trace.bc: %.bc $(LLC) $(LLC) -f -trace $(LLCFLAGS) $< -%.o: %.c - $(LCC) $(LCFLAGS) $< -c -o $@ +## Leave this rule out to avoid problems in tests that have both .c and .ll +## %.ll: %.c +## $(LCC) $(LCFLAGS) -S $< -o $*.ll + +%.bc: %.c + $(LCC) $(LCFLAGS) -c $< -o $*.tmp.bc + $(LOPT) -cleangcc -raise -constprop -dce $*.tmp.bc -o $@ + $(RM) $*.tmp.bc %.bc: %.ll $(LAS) -f $< -%.clean.bc: %.bc - $(LOPT) -cleangcc -raise -constprop -dce < $< > $@ +%.linked.bc: %.bc + $(CP) $< $@ -%.s: %.bc - $(LLC) -f $(LLCOPTS) $< +%.s: %.linked.bc + $(LLC) -f $(LLCFLAGS) $< -o $@ %: %.o $(LIBS) - $(CC) -o $@ $(LDFLAGS) $< $(LIBS) + $(CC) $(LDFLAGS) $< $(LIBS) -o $@ -## -## 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 +## Cancel built-in implicit rules that override above rules %: %.s +%: %.c + +%.o: %.c + ## The next two rules are for disassembling an executable or an object file %.dis: % $(DIS) $< > $@ diff --git a/test/Makefile.tests b/test/Makefile.tests index eb0ea0eb7d1..e95724c2f03 100644 --- a/test/Makefile.tests +++ b/test/Makefile.tests @@ -5,6 +5,9 @@ .PHONY: clean default +## keep %.linked.bc from being deleted +.PRECIOUS: %.linked.bc + TOOLS = $(LEVEL)/tools/Debug @@ -28,6 +31,7 @@ endif CC = /opt/SUNWspro/bin/cc AS = /opt/SUNWspro/bin/cc DIS = /usr/ccs/bin/dis +CP = /bin/cp -p CFLAGS = -g -xarch=v9 CCFLAGS = $(CFLAGS) LDFLAGS = $(CFLAGS) @@ -37,14 +41,19 @@ ASFLAGS = -c $(CFLAGS) ## ifdef PROG -default: $(PROG).clean.bc $(PROG).native - #.SECONDARY: $(PROG).clean.bc ## keep %.clean.bc from being deleted + default: $(PROG) $(PROG).native + + ifeq ($(strip $(OBJS)),) + BCOBJS = $(PROG).bc + else + BCOBJS = $(OBJS:.o=.bc) + endif -$(PROG).bc: $(OBJS) - $(LLINK) -f $(OBJS) -o $@ + $(PROG).linked.bc: $(BCOBJS) + $(LLINK) -f $(BCOBJS) -o $@ -$(PROG).native: $(OBJS:.o=.c) - gcc -o $@ $(OBJS:.o=.c) -O2 $(LOCAL_CFLAGS) -Wall + $(PROG).native: $(OBJS:.o=.c) + gcc $(OBJS:.o=.c) -O2 $(LOCAL_CFLAGS) -Wall -o $@ endif ## Special target to force target-dependent library to be compiled @@ -57,7 +66,7 @@ runtime.o: runtime.c $(CC) -c $(CCFLAGS) $< clean : - rm -f *.[123] *.bc *.mc *.s *.o a.out core $(PROG) + $(RM) *.[123] *.bc *.mc *.s *.o a.out core $(PROG) %.mc: %.bc $(LLC) $(AS) @echo "Generating machine instructions for $<" @@ -66,33 +75,35 @@ clean : %.trace.bc: %.bc $(LLC) $(LLC) -f -trace $(LLCFLAGS) $< -%.o: %.c - $(LCC) $(LCFLAGS) $< -c -o $@ +## Leave this rule out to avoid problems in tests that have both .c and .ll +## %.ll: %.c +## $(LCC) $(LCFLAGS) -S $< -o $*.ll + +%.bc: %.c + $(LCC) $(LCFLAGS) -c $< -o $*.tmp.bc + $(LOPT) -cleangcc -raise -constprop -dce $*.tmp.bc -o $@ + $(RM) $*.tmp.bc %.bc: %.ll $(LAS) -f $< -%.clean.bc: %.bc - $(LOPT) -cleangcc -raise -constprop -dce < $< > $@ +%.linked.bc: %.bc + $(CP) $< $@ -%.s: %.bc - $(LLC) -f $(LLCOPTS) $< +%.s: %.linked.bc + $(LLC) -f $(LLCFLAGS) $< -o $@ %: %.o $(LIBS) - $(CC) -o $@ $(LDFLAGS) $< $(LIBS) + $(CC) $(LDFLAGS) $< $(LIBS) -o $@ -## -## 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 +## Cancel built-in implicit rules that override above rules %: %.s +%: %.c + +%.o: %.c + ## The next two rules are for disassembling an executable or an object file %.dis: % $(DIS) $< > $@ -- 2.34.1