Chris Lattner | e0d8daa | 2003-05-09 04:19:58 +0000 | [diff] [blame] | 1 | ##----------------------------------------------------------*- Makefile -*-===## |
Chris Lattner | 919937d | 2003-07-25 22:26:17 +0000 | [diff] [blame] | 2 | ## |
Chris Lattner | c89764e | 2002-01-22 16:56:41 +0000 | [diff] [blame] | 3 | ## Common rules for generating, linking, and compiling via LLVM. This is |
| 4 | ## used to implement a robust testing framework for LLVM |
Chris Lattner | 919937d | 2003-07-25 22:26:17 +0000 | [diff] [blame] | 5 | ## |
Chris Lattner | e0d8daa | 2003-05-09 04:19:58 +0000 | [diff] [blame] | 6 | ##-------------------------------------------------------------------------===## |
Vikram S. Adve | 977fa8d | 2001-12-15 01:13:42 +0000 | [diff] [blame] | 7 | |
Chris Lattner | 995663e | 2003-01-16 20:26:29 +0000 | [diff] [blame] | 8 | # If the user specified a TEST= option on the command line, we do not want to do |
| 9 | # the default testing type. Instead, we change the default target to be the |
| 10 | # test:: target. |
| 11 | # |
| 12 | ifdef TEST |
| 13 | test:: |
| 14 | endif |
| 15 | |
Chris Lattner | b8586b7 | 2003-08-22 14:09:46 +0000 | [diff] [blame] | 16 | # We do not want to make .d files for tests! |
| 17 | DISABLE_AUTO_DEPENDENCIES=1 |
| 18 | |
Vikram S. Adve | 977fa8d | 2001-12-15 01:13:42 +0000 | [diff] [blame] | 19 | include ${LEVEL}/Makefile.common |
| 20 | |
Chris Lattner | 37e6f70 | 2003-01-21 21:31:29 +0000 | [diff] [blame] | 21 | # Specify ENABLE_STATS on the command line to enable -stats and -time-passes |
| 22 | # output from gccas and gccld. |
Chris Lattner | 9551817 | 2002-09-30 19:23:55 +0000 | [diff] [blame] | 23 | ifdef ENABLE_STATS |
Chris Lattner | 37e6f70 | 2003-01-21 21:31:29 +0000 | [diff] [blame] | 24 | STATS = -stats -time-passes |
Chris Lattner | 9551817 | 2002-09-30 19:23:55 +0000 | [diff] [blame] | 25 | endif |
| 26 | |
Vikram S. Adve | 4cceffe | 2001-11-05 00:18:30 +0000 | [diff] [blame] | 27 | .PHONY: clean default |
| 28 | |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 29 | # These files, which might be intermediate results, should not be deleted by |
| 30 | # make |
| 31 | .PRECIOUS: Output/%.bc Output/%.ll |
| 32 | .PRECIOUS: Output/%.tbc Output/%.tll |
| 33 | .PRECIOUS: Output/.dir |
Chris Lattner | aef6546 | 2002-04-07 08:11:07 +0000 | [diff] [blame] | 34 | .PRECIOUS: Output/%.llvm.bc |
| 35 | .PRECIOUS: Output/%.llvm |
Vikram S. Adve | a46fb6b | 2001-11-06 17:09:49 +0000 | [diff] [blame] | 36 | |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 37 | LCCFLAGS += -O2 -Wall |
Chris Lattner | a9028e6 | 2003-05-13 20:06:00 +0000 | [diff] [blame] | 38 | LCXXFLAGS += -O2 -Wall |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 39 | LLCFLAGS = |
Chris Lattner | 45983ee | 2003-06-28 22:35:46 +0000 | [diff] [blame] | 40 | TESTRUNR = @echo Running test: $<; \ |
Reid Spencer | 18c5729 | 2005-02-18 20:24:09 +0000 | [diff] [blame] | 41 | PATH="$(LLVMTOOLCURRENT):$(LLVM_SRC_ROOT)/test/Scripts:$(PATH)" \ |
John Criswell | ee29d2a | 2003-09-06 15:12:21 +0000 | [diff] [blame] | 42 | $(LLVM_SRC_ROOT)/test/TestRunner.sh |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 43 | |
Sumant Kowshik | c961a29 | 2003-08-06 01:03:28 +0000 | [diff] [blame] | 44 | LLCLIBS := $(LLCLIBS) -lm |
Vikram S. Adve | 4cceffe | 2001-11-05 00:18:30 +0000 | [diff] [blame] | 45 | |
Vikram S. Adve | f9017b8 | 2002-08-30 03:27:36 +0000 | [diff] [blame] | 46 | clean:: |
Vikram S. Adve | 1239874 | 2003-07-08 18:39:51 +0000 | [diff] [blame] | 47 | $(RM) -f a.out core |
Chris Lattner | c89764e | 2002-01-22 16:56:41 +0000 | [diff] [blame] | 48 | $(RM) -rf Output/ |
Vikram S. Adve | 4cceffe | 2001-11-05 00:18:30 +0000 | [diff] [blame] | 49 | |
Chris Lattner | 6723add | 2002-02-12 15:39:38 +0000 | [diff] [blame] | 50 | # Compile from X.c to Output/X.ll |
John Criswell | ee29d2a | 2003-09-06 15:12:21 +0000 | [diff] [blame] | 51 | Output/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES) |
Reid Spencer | 6a901ec | 2004-12-24 03:44:24 +0000 | [diff] [blame] | 52 | -$(LLVMGCCWITHPATH) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ |
Chris Lattner | e5b27bd | 2001-12-09 16:55:43 +0000 | [diff] [blame] | 53 | |
Chris Lattner | a9028e6 | 2003-05-13 20:06:00 +0000 | [diff] [blame] | 54 | # Compile from X.cpp to Output/X.ll |
John Criswell | ee29d2a | 2003-09-06 15:12:21 +0000 | [diff] [blame] | 55 | Output/%.ll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES) |
Reid Spencer | 6a901ec | 2004-12-24 03:44:24 +0000 | [diff] [blame] | 56 | -$(LLVMGXXWITHPATH) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ |
Chris Lattner | a9028e6 | 2003-05-13 20:06:00 +0000 | [diff] [blame] | 57 | |
Chris Lattner | 707af6e | 2003-06-02 05:49:11 +0000 | [diff] [blame] | 58 | # Compile from X.cc to Output/X.ll |
John Criswell | ee29d2a | 2003-09-06 15:12:21 +0000 | [diff] [blame] | 59 | Output/%.ll: %.cc $(LCC1XX) Output/.dir $(INCLUDES) |
Reid Spencer | 6a901ec | 2004-12-24 03:44:24 +0000 | [diff] [blame] | 60 | -$(LLVMGXXWITHPATH) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ |
Chris Lattner | 707af6e | 2003-06-02 05:49:11 +0000 | [diff] [blame] | 61 | |
Chris Lattner | 6723add | 2002-02-12 15:39:38 +0000 | [diff] [blame] | 62 | # LLVM Assemble from Output/X.ll to Output/X.bc. Output/X.ll must have come |
| 63 | # from GCC output, so use GCCAS. |
| 64 | # |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 65 | Output/%.bc: Output/%.ll $(LGCCAS) |
Brian Gaeke | 844c546 | 2004-01-13 21:59:51 +0000 | [diff] [blame] | 66 | -$(LGCCAS) $(STATS) $< -o $@ |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 67 | |
Chris Lattner | 6723add | 2002-02-12 15:39:38 +0000 | [diff] [blame] | 68 | # LLVM Assemble from X.ll to Output/X.bc. Because we are coming directly from |
| 69 | # LLVM source, use the non-transforming assembler. |
| 70 | # |
Brian Gaeke | 5c59be9 | 2004-01-13 21:56:30 +0000 | [diff] [blame] | 71 | Output/%.bc: %.ll $(LLVMAS) Output/.dir |
| 72 | -$(LLVMAS) -f $< -o $@ |
Chris Lattner | 52a4e85 | 2002-01-23 21:36:59 +0000 | [diff] [blame] | 73 | |
Vikram S. Adve | a46fb6b | 2001-11-06 17:09:49 +0000 | [diff] [blame] | 74 | ## Cancel built-in implicit rules that override above rules |
Vikram S. Adve | 4cceffe | 2001-11-05 00:18:30 +0000 | [diff] [blame] | 75 | %: %.s |
| 76 | |
Vikram S. Adve | a46fb6b | 2001-11-06 17:09:49 +0000 | [diff] [blame] | 77 | %: %.c |
| 78 | |
| 79 | %.o: %.c |
| 80 | |