Really fix Makefile to compile individual tests and Olden codes.
authorVikram S. Adve <vadve@cs.uiuc.edu>
Tue, 6 Nov 2001 17:09:49 +0000 (17:09 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Tue, 6 Nov 2001 17:09:49 +0000 (17:09 +0000)
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
test/Makefile.tests

index eb0ea0eb7d12146360697d8c7c4e9e689b3147d2..e95724c2f030552d886adbb70e08b67efa169f1f 100644 (file)
@@ -5,6 +5,9 @@
 
 .PHONY: clean default
 
 
 .PHONY: clean default
 
+## keep %.linked.bc from being deleted
+.PRECIOUS: %.linked.bc
+
 
 TOOLS    = $(LEVEL)/tools/Debug
 
 
 TOOLS    = $(LEVEL)/tools/Debug
 
@@ -28,6 +31,7 @@ endif
 CC      = /opt/SUNWspro/bin/cc
 AS     = /opt/SUNWspro/bin/cc
 DIS     = /usr/ccs/bin/dis
 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)
 CFLAGS  = -g -xarch=v9
 CCFLAGS = $(CFLAGS)
 LDFLAGS = $(CFLAGS)
@@ -37,14 +41,19 @@ ASFLAGS = -c $(CFLAGS)
 ## 
 ifdef PROG
 
 ## 
 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
 endif
 
 ## Special target to force target-dependent library to be compiled
@@ -57,7 +66,7 @@ runtime.o: runtime.c
        $(CC) -c $(CCFLAGS) $<
 
 clean :
        $(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 $<"
 
 %.mc: %.bc $(LLC) $(AS)
        @echo "Generating machine instructions for $<"
@@ -66,33 +75,35 @@ clean :
 %.trace.bc: %.bc $(LLC)
        $(LLC) -f -trace $(LLCFLAGS) $<
 
 %.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 $<
 
 
 %.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)
 
 %: %.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
 
 %: %.s
 
+%: %.c
+
+%.o: %.c
+
 ## The next two rules are for disassembling an executable or an object file
 %.dis: %
        $(DIS) $< > $@
 ## The next two rules are for disassembling an executable or an object file
 %.dis: %
        $(DIS) $< > $@
index eb0ea0eb7d12146360697d8c7c4e9e689b3147d2..e95724c2f030552d886adbb70e08b67efa169f1f 100644 (file)
@@ -5,6 +5,9 @@
 
 .PHONY: clean default
 
 
 .PHONY: clean default
 
+## keep %.linked.bc from being deleted
+.PRECIOUS: %.linked.bc
+
 
 TOOLS    = $(LEVEL)/tools/Debug
 
 
 TOOLS    = $(LEVEL)/tools/Debug
 
@@ -28,6 +31,7 @@ endif
 CC      = /opt/SUNWspro/bin/cc
 AS     = /opt/SUNWspro/bin/cc
 DIS     = /usr/ccs/bin/dis
 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)
 CFLAGS  = -g -xarch=v9
 CCFLAGS = $(CFLAGS)
 LDFLAGS = $(CFLAGS)
@@ -37,14 +41,19 @@ ASFLAGS = -c $(CFLAGS)
 ## 
 ifdef PROG
 
 ## 
 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
 endif
 
 ## Special target to force target-dependent library to be compiled
@@ -57,7 +66,7 @@ runtime.o: runtime.c
        $(CC) -c $(CCFLAGS) $<
 
 clean :
        $(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 $<"
 
 %.mc: %.bc $(LLC) $(AS)
        @echo "Generating machine instructions for $<"
@@ -66,33 +75,35 @@ clean :
 %.trace.bc: %.bc $(LLC)
        $(LLC) -f -trace $(LLCFLAGS) $<
 
 %.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 $<
 
 
 %.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)
 
 %: %.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
 
 %: %.s
 
+%: %.c
+
+%.o: %.c
+
 ## The next two rules are for disassembling an executable or an object file
 %.dis: %
        $(DIS) $< > $@
 ## The next two rules are for disassembling an executable or an object file
 %.dis: %
        $(DIS) $< > $@