Put common rules for compiling programs into Makefile.target.
authorVikram S. Adve <vadve@cs.uiuc.edu>
Mon, 5 Nov 2001 00:18:30 +0000 (00:18 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Mon, 5 Nov 2001 00:18:30 +0000 (00:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1130 91177308-0d34-0410-b5e6-96231b3b80d8

test/Makefile
test/Makefile.target [new file with mode: 0644]
test/Makefile.tests [new file with mode: 0644]

index a9c7f75138e1a3249573e376c51d303c75d92b48..d7b3e62d9f0be2362ffe9b8bf5690b9848c5aa2b 100644 (file)
@@ -1,22 +1,4 @@
-LLC  := ../tools/Debug/llc
-LAS  := ../tools/Debug/as
-LDIS := ../tools/Debug/dis 
-LINK := ../tools/Debug/link
-LLCLIBS := runtime.o
-LLCOPTS := 
-
-ifeq ($(TRACE), yes)
-    LLCOPTS := -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)
-
+HERE  = ..
 
 TESTS := $(wildcard *.ll)
 
@@ -39,9 +21,6 @@ testcodegen : $(LLCTESTS:%.ll=%.mc)
 
 testsparc   : $(LLCTESTS:%.ll=%.s)
 
-clean :
-       rm -f *.[123] *.bc *.mc *.s *.o a.out core 
-
 %.asmdis: %
        @echo "Running assembler/disassembler test on $<"
        @./TestAsmDisasm.sh $<
@@ -50,30 +29,8 @@ clean :
        @echo "Running optimizier test on $<"
        @./TestOptimizer.sh $<
 
-%.bc: %.ll $(LAS)
-       $(LAS) -f $<
-
-%.mc: %.bc $(LLC) $(AS)
-       @echo "Generating machine instructions for $<"
-       $(LLC) -dsched y $(LLCOPTS) $< > $@
-
-%.trace.bc: %.bc $(LLC)
-       $(LLC) -f -trace $(LLCOPTS) $<
-
-%.s: %.bc $(LLC)
-       $(LLC) -f $(LLCOPTS) $<
-
-%: %.o $(LLCLIBS)
-       $(CC) -o $@ $(LDFLAGS) $< $(LLCLIBS)
-
-
-## 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) $< > $@
 
+## Rules for compiling %.ll, %.bc, %.s files and
+## for building native SPARC executables.
+## 
+include Makefile.target
diff --git a/test/Makefile.target b/test/Makefile.target
new file mode 100644 (file)
index 0000000..7eb189e
--- /dev/null
@@ -0,0 +1,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) $< > $@
+
+
diff --git a/test/Makefile.tests b/test/Makefile.tests
new file mode 100644 (file)
index 0000000..7eb189e
--- /dev/null
@@ -0,0 +1,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) $< > $@
+
+