blob: ad9f2eabc7f1448143f2028dbc2e4c1648e5a4b6 [file] [log] [blame]
Chris Lattnere0d8daa2003-05-09 04:19:58 +00001##----------------------------------------------------------*- Makefile -*-===##
Chris Lattner919937d2003-07-25 22:26:17 +00002##
Chris Lattnerc89764e2002-01-22 16:56:41 +00003## Common rules for generating, linking, and compiling via LLVM. This is
4## used to implement a robust testing framework for LLVM
Chris Lattner919937d2003-07-25 22:26:17 +00005##
Chris Lattnere0d8daa2003-05-09 04:19:58 +00006##-------------------------------------------------------------------------===##
Vikram S. Adve977fa8d2001-12-15 01:13:42 +00007
Chris Lattner995663e2003-01-16 20:26:29 +00008# 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#
12ifdef TEST
13test::
14endif
15
Chris Lattnerb8586b72003-08-22 14:09:46 +000016# We do not want to make .d files for tests!
17DISABLE_AUTO_DEPENDENCIES=1
18
Vikram S. Adve977fa8d2001-12-15 01:13:42 +000019include ${LEVEL}/Makefile.common
20
Chris Lattner37e6f702003-01-21 21:31:29 +000021# Specify ENABLE_STATS on the command line to enable -stats and -time-passes
22# output from gccas and gccld.
Chris Lattner95518172002-09-30 19:23:55 +000023ifdef ENABLE_STATS
Chris Lattner37e6f702003-01-21 21:31:29 +000024STATS = -stats -time-passes
Chris Lattner95518172002-09-30 19:23:55 +000025endif
26
Vikram S. Adve4cceffe2001-11-05 00:18:30 +000027.PHONY: clean default
28
Chris Lattner52a4e852002-01-23 21:36:59 +000029# 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 Lattneraef65462002-04-07 08:11:07 +000034.PRECIOUS: Output/%.llvm.bc
35.PRECIOUS: Output/%.llvm
Vikram S. Advea46fb6b2001-11-06 17:09:49 +000036
Chris Lattner52a4e852002-01-23 21:36:59 +000037LCCFLAGS += -O2 -Wall
Chris Lattnera9028e62003-05-13 20:06:00 +000038LCXXFLAGS += -O2 -Wall
Chris Lattner52a4e852002-01-23 21:36:59 +000039LLCFLAGS =
Chris Lattner45983ee2003-06-28 22:35:46 +000040TESTRUNR = @echo Running test: $<; \
Reid Spencer18c57292005-02-18 20:24:09 +000041 PATH="$(LLVMTOOLCURRENT):$(LLVM_SRC_ROOT)/test/Scripts:$(PATH)" \
John Criswellee29d2a2003-09-06 15:12:21 +000042 $(LLVM_SRC_ROOT)/test/TestRunner.sh
Chris Lattner52a4e852002-01-23 21:36:59 +000043
Sumant Kowshikc961a292003-08-06 01:03:28 +000044LLCLIBS := $(LLCLIBS) -lm
Vikram S. Adve4cceffe2001-11-05 00:18:30 +000045
Vikram S. Advef9017b82002-08-30 03:27:36 +000046clean::
Vikram S. Adve12398742003-07-08 18:39:51 +000047 $(RM) -f a.out core
Chris Lattnerc89764e2002-01-22 16:56:41 +000048 $(RM) -rf Output/
Vikram S. Adve4cceffe2001-11-05 00:18:30 +000049
Chris Lattner6723add2002-02-12 15:39:38 +000050# Compile from X.c to Output/X.ll
John Criswellee29d2a2003-09-06 15:12:21 +000051Output/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES)
Reid Spencer6a901ec2004-12-24 03:44:24 +000052 -$(LLVMGCCWITHPATH) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@
Chris Lattnere5b27bd2001-12-09 16:55:43 +000053
Chris Lattnera9028e62003-05-13 20:06:00 +000054# Compile from X.cpp to Output/X.ll
John Criswellee29d2a2003-09-06 15:12:21 +000055Output/%.ll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES)
Reid Spencer6a901ec2004-12-24 03:44:24 +000056 -$(LLVMGXXWITHPATH) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
Chris Lattnera9028e62003-05-13 20:06:00 +000057
Chris Lattner707af6e2003-06-02 05:49:11 +000058# Compile from X.cc to Output/X.ll
John Criswellee29d2a2003-09-06 15:12:21 +000059Output/%.ll: %.cc $(LCC1XX) Output/.dir $(INCLUDES)
Reid Spencer6a901ec2004-12-24 03:44:24 +000060 -$(LLVMGXXWITHPATH) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
Chris Lattner707af6e2003-06-02 05:49:11 +000061
Chris Lattner6723add2002-02-12 15:39:38 +000062# 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 Lattner52a4e852002-01-23 21:36:59 +000065Output/%.bc: Output/%.ll $(LGCCAS)
Brian Gaeke844c5462004-01-13 21:59:51 +000066 -$(LGCCAS) $(STATS) $< -o $@
Chris Lattner52a4e852002-01-23 21:36:59 +000067
Chris Lattner6723add2002-02-12 15:39:38 +000068# 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 Gaeke5c59be92004-01-13 21:56:30 +000071Output/%.bc: %.ll $(LLVMAS) Output/.dir
72 -$(LLVMAS) -f $< -o $@
Chris Lattner52a4e852002-01-23 21:36:59 +000073
Vikram S. Advea46fb6b2001-11-06 17:09:49 +000074## Cancel built-in implicit rules that override above rules
Vikram S. Adve4cceffe2001-11-05 00:18:30 +000075%: %.s
76
Vikram S. Advea46fb6b2001-11-06 17:09:49 +000077%: %.c
78
79%.o: %.c
80