Chris Lattner | e0d8daa | 2003-05-09 04:19:58 +0000 | [diff] [blame] | 1 | ##----------------------------------------------------------*- Makefile -*-===## |
Chris Lattner | c89764e | 2002-01-22 16:56:41 +0000 | [diff] [blame] | 2 | ## Common rules for generating, linking, and compiling via LLVM. This is |
| 3 | ## used to implement a robust testing framework for LLVM |
Chris Lattner | e0d8daa | 2003-05-09 04:19:58 +0000 | [diff] [blame] | 4 | ##-------------------------------------------------------------------------===## |
Vikram S. Adve | 977fa8d | 2001-12-15 01:13:42 +0000 | [diff] [blame] | 5 | |
Chris Lattner | 995663e | 2003-01-16 20:26:29 +0000 | [diff] [blame] | 6 | # If the user specified a TEST= option on the command line, we do not want to do |
| 7 | # the default testing type. Instead, we change the default target to be the |
| 8 | # test:: target. |
| 9 | # |
| 10 | ifdef TEST |
| 11 | test:: |
| 12 | endif |
| 13 | |
Vikram S. Adve | 977fa8d | 2001-12-15 01:13:42 +0000 | [diff] [blame] | 14 | include ${LEVEL}/Makefile.common |
| 15 | |
Chris Lattner | 37e6f70 | 2003-01-21 21:31:29 +0000 | [diff] [blame] | 16 | # Specify ENABLE_STATS on the command line to enable -stats and -time-passes |
| 17 | # output from gccas and gccld. |
Chris Lattner | 9551817 | 2002-09-30 19:23:55 +0000 | [diff] [blame] | 18 | ifdef ENABLE_STATS |
Chris Lattner | 37e6f70 | 2003-01-21 21:31:29 +0000 | [diff] [blame] | 19 | STATS = -stats -time-passes |
Chris Lattner | 9551817 | 2002-09-30 19:23:55 +0000 | [diff] [blame] | 20 | endif |
| 21 | |
| 22 | |
Vikram S. Adve | 4cceffe | 2001-11-05 00:18:30 +0000 | [diff] [blame] | 23 | .PHONY: clean default |
| 24 | |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 25 | # These files, which might be intermediate results, should not be deleted by |
| 26 | # make |
| 27 | .PRECIOUS: Output/%.bc Output/%.ll |
| 28 | .PRECIOUS: Output/%.tbc Output/%.tll |
| 29 | .PRECIOUS: Output/.dir |
Chris Lattner | aef6546 | 2002-04-07 08:11:07 +0000 | [diff] [blame] | 30 | .PRECIOUS: Output/%.llvm.bc |
| 31 | .PRECIOUS: Output/%.llvm |
Vikram S. Adve | a46fb6b | 2001-11-06 17:09:49 +0000 | [diff] [blame] | 32 | |
John Criswell | 246fcca | 2003-06-16 19:16:32 +0000 | [diff] [blame] | 33 | TOOLS = $(LLVMTOOLCURRENT) |
Chris Lattner | 60afae4 | 2002-11-09 00:50:02 +0000 | [diff] [blame] | 34 | |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 35 | # LLVM Tool Definitions... |
| 36 | # |
Chris Lattner | e0d8daa | 2003-05-09 04:19:58 +0000 | [diff] [blame] | 37 | LCC = $(LLVMGCCDIR)/bin/gcc |
| 38 | LCC1 = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1 |
Chris Lattner | a9028e6 | 2003-05-13 20:06:00 +0000 | [diff] [blame] | 39 | LCXX = $(LLVMGCCDIR)/bin/g++ |
| 40 | LCC1XX = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1plus |
Vikram S. Adve | 977fa8d | 2001-12-15 01:13:42 +0000 | [diff] [blame] | 41 | LLI = $(TOOLS)/lli |
Vikram S. Adve | 4cceffe | 2001-11-05 00:18:30 +0000 | [diff] [blame] | 42 | LLC = $(TOOLS)/llc |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 43 | LAS = $(TOOLS)/as |
| 44 | LGCCAS = $(TOOLS)/gccas |
Chris Lattner | a9028e6 | 2003-05-13 20:06:00 +0000 | [diff] [blame] | 45 | LGCCLD = $(TOOLS)/gccld -L$(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/lib |
Chris Lattner | 083de22 | 2003-06-26 05:28:00 +0000 | [diff] [blame] | 46 | LGCCLDPROG = $(TOOLS)/gccld |
Vikram S. Adve | 4cceffe | 2001-11-05 00:18:30 +0000 | [diff] [blame] | 47 | LDIS = $(TOOLS)/dis |
| 48 | LOPT = $(TOOLS)/opt |
| 49 | LLINK = $(TOOLS)/link |
Chris Lattner | 65fbd4a | 2002-06-24 21:35:50 +0000 | [diff] [blame] | 50 | LANALYZE = $(TOOLS)/analyze |
Chris Lattner | 8437f4a | 2002-11-19 21:57:18 +0000 | [diff] [blame] | 51 | LBUGPOINT= $(TOOLS)/bugpoint |
Vikram S. Adve | 4cceffe | 2001-11-05 00:18:30 +0000 | [diff] [blame] | 52 | |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 53 | LCCFLAGS += -O2 -Wall |
Chris Lattner | a9028e6 | 2003-05-13 20:06:00 +0000 | [diff] [blame] | 54 | LCXXFLAGS += -O2 -Wall |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 55 | LLCFLAGS = |
| 56 | FAILURE = $(LEVEL)/test/Failure.sh |
Chris Lattner | 45983ee | 2003-06-28 22:35:46 +0000 | [diff] [blame] | 57 | TESTRUNR = @echo Running test: $<; \ |
| 58 | PATH=$(LLVMTOOLCURRENT):$(LEVEL)/test/Scripts:$(PATH) \ |
| 59 | $(LEVEL)/test/TestRunner.sh |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 60 | |
| 61 | # Native Tool Definitions |
John Criswell | 01e6d2a | 2003-06-11 13:56:55 +0000 | [diff] [blame] | 62 | NATGCC = $(CC) |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 63 | CP = /bin/cp -f |
Vikram S. Adve | 4cceffe | 2001-11-05 00:18:30 +0000 | [diff] [blame] | 64 | |
Vikram S. Adve | 24672c3 | 2003-06-03 18:56:57 +0000 | [diff] [blame] | 65 | ## If TRACE or TRACEM is "yes", set the appropriate llc flag (-trace or -tracem) |
| 66 | ## mark that tracing on, and set the TRACELIBS variable. |
Vikram S. Adve | bae2876 | 2003-06-04 14:24:52 +0000 | [diff] [blame] | 67 | TRACEFLAGS = |
Vikram S. Adve | 4cceffe | 2001-11-05 00:18:30 +0000 | [diff] [blame] | 68 | ifeq ($(TRACE), yes) |
Vikram S. Adve | bae2876 | 2003-06-04 14:24:52 +0000 | [diff] [blame] | 69 | TRACEFLAGS += -trace |
Vikram S. Adve | 24672c3 | 2003-06-03 18:56:57 +0000 | [diff] [blame] | 70 | DOTRACING = yes |
Vikram S. Adve | 2a4d8d2 | 2002-05-19 15:47:52 +0000 | [diff] [blame] | 71 | else |
| 72 | ifeq ($(TRACEM), yes) |
Vikram S. Adve | bae2876 | 2003-06-04 14:24:52 +0000 | [diff] [blame] | 73 | TRACEFLAGS += -tracem |
Vikram S. Adve | 24672c3 | 2003-06-03 18:56:57 +0000 | [diff] [blame] | 74 | DOTRACING = yes |
Vikram S. Adve | 2a4d8d2 | 2002-05-19 15:47:52 +0000 | [diff] [blame] | 75 | endif |
Vikram S. Adve | 4cceffe | 2001-11-05 00:18:30 +0000 | [diff] [blame] | 76 | endif |
Vikram S. Adve | 24672c3 | 2003-06-03 18:56:57 +0000 | [diff] [blame] | 77 | ifeq ($(DOTRACING), yes) |
Vikram S. Adve | 1239874 | 2003-07-08 18:39:51 +0000 | [diff] [blame^] | 78 | TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr.$(ARCH) |
Vikram S. Adve | 24672c3 | 2003-06-03 18:56:57 +0000 | [diff] [blame] | 79 | endif |
| 80 | |
Vikram S. Adve | 2a4d8d2 | 2002-05-19 15:47:52 +0000 | [diff] [blame] | 81 | |
| 82 | LLCLIBS := $(LLCLIBS) -lm |
Vikram S. Adve | 4cceffe | 2001-11-05 00:18:30 +0000 | [diff] [blame] | 83 | |
Vikram S. Adve | f9017b8 | 2002-08-30 03:27:36 +0000 | [diff] [blame] | 84 | clean:: |
Vikram S. Adve | 1239874 | 2003-07-08 18:39:51 +0000 | [diff] [blame^] | 85 | $(RM) -f a.out core |
Chris Lattner | c89764e | 2002-01-22 16:56:41 +0000 | [diff] [blame] | 86 | $(RM) -rf Output/ |
Vikram S. Adve | 4cceffe | 2001-11-05 00:18:30 +0000 | [diff] [blame] | 87 | |
Chris Lattner | 6723add | 2002-02-12 15:39:38 +0000 | [diff] [blame] | 88 | # Compile from X.c to Output/X.ll |
Chris Lattner | 433f1d8 | 2003-05-17 22:33:18 +0000 | [diff] [blame] | 89 | Output/%.ll: $(SourceDir)%.c $(LCC1) Output/.dir $(INCLUDES) |
| 90 | $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ |
Chris Lattner | e5b27bd | 2001-12-09 16:55:43 +0000 | [diff] [blame] | 91 | |
Chris Lattner | a9028e6 | 2003-05-13 20:06:00 +0000 | [diff] [blame] | 92 | # Compile from X.cpp to Output/X.ll |
Chris Lattner | 433f1d8 | 2003-05-17 22:33:18 +0000 | [diff] [blame] | 93 | Output/%.ll: $(SourceDir)%.cpp $(LCC1XX) Output/.dir $(INCLUDES) |
| 94 | $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ |
Chris Lattner | a9028e6 | 2003-05-13 20:06:00 +0000 | [diff] [blame] | 95 | |
Chris Lattner | 707af6e | 2003-06-02 05:49:11 +0000 | [diff] [blame] | 96 | # Compile from X.cc to Output/X.ll |
| 97 | Output/%.ll: $(SourceDir)%.cc $(LCC1XX) Output/.dir $(INCLUDES) |
| 98 | $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ |
| 99 | |
Chris Lattner | 6723add | 2002-02-12 15:39:38 +0000 | [diff] [blame] | 100 | # LLVM Assemble from Output/X.ll to Output/X.bc. Output/X.ll must have come |
| 101 | # from GCC output, so use GCCAS. |
| 102 | # |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 103 | Output/%.bc: Output/%.ll $(LGCCAS) |
Chris Lattner | 9551817 | 2002-09-30 19:23:55 +0000 | [diff] [blame] | 104 | $(LGCCAS) $(STATS) $< -o $@ |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 105 | |
Chris Lattner | 6723add | 2002-02-12 15:39:38 +0000 | [diff] [blame] | 106 | # LLVM Assemble from X.ll to Output/X.bc. Because we are coming directly from |
| 107 | # LLVM source, use the non-transforming assembler. |
| 108 | # |
Chris Lattner | fbda7a0 | 2002-02-01 04:25:12 +0000 | [diff] [blame] | 109 | Output/%.bc: %.ll $(LAS) Output/.dir |
Chris Lattner | bafff33 | 2002-01-31 00:27:32 +0000 | [diff] [blame] | 110 | $(LAS) -f $< -o $@ |
Vikram S. Adve | 4cceffe | 2001-11-05 00:18:30 +0000 | [diff] [blame] | 111 | |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 112 | # |
| 113 | # Testing versions of provided utilities... |
| 114 | # |
Vikram S. Adve | 2a4d8d2 | 2002-05-19 15:47:52 +0000 | [diff] [blame] | 115 | Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES) |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 116 | @echo "======== Compiling $<" |
Chris Lattner | 433f1d8 | 2003-05-17 22:33:18 +0000 | [diff] [blame] | 117 | $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ || \ |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 118 | ( rm -f $@; $(FAILURE) $@ ) |
| 119 | |
Chris Lattner | a9028e6 | 2003-05-13 20:06:00 +0000 | [diff] [blame] | 120 | Output/%.tll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES) |
| 121 | @echo "======== Compiling $<" |
Chris Lattner | 433f1d8 | 2003-05-17 22:33:18 +0000 | [diff] [blame] | 122 | $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ || \ |
Chris Lattner | a9028e6 | 2003-05-13 20:06:00 +0000 | [diff] [blame] | 123 | ( rm -f $@; $(FAILURE) $@ ) |
| 124 | |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 125 | Output/%.tbc: Output/%.tll $(LAS) |
| 126 | @echo "======== Assembling $<" |
| 127 | $(LAS) -f $< -o $@ || \ |
| 128 | ( rm -f $@; $(FAILURE) $@ ) |
| 129 | |
| 130 | |
Vikram S. Adve | a46fb6b | 2001-11-06 17:09:49 +0000 | [diff] [blame] | 131 | ## Cancel built-in implicit rules that override above rules |
Vikram S. Adve | 4cceffe | 2001-11-05 00:18:30 +0000 | [diff] [blame] | 132 | %: %.s |
| 133 | |
Vikram S. Adve | a46fb6b | 2001-11-06 17:09:49 +0000 | [diff] [blame] | 134 | %: %.c |
| 135 | |
| 136 | %.o: %.c |
| 137 | |