blob: c49cedd5cf897e1ec76f29d2f247967024bd2378 [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 =
John Criswellee29d2a2003-09-06 15:12:21 +000040FAILURE = $(LLVM_SRC_ROOT)/test/Failure.sh
Chris Lattner45983ee2003-06-28 22:35:46 +000041TESTRUNR = @echo Running test: $<; \
John Criswellee29d2a2003-09-06 15:12:21 +000042 PATH=$(LLVMTOOLCURRENT):$(LLVM_SRC_ROOT)/test/Scripts:$(PATH) \
43 $(LLVM_SRC_ROOT)/test/TestRunner.sh
Chris Lattner52a4e852002-01-23 21:36:59 +000044
Sumant Kowshikc961a292003-08-06 01:03:28 +000045LLCLIBS := $(LLCLIBS) -lm
Vikram S. Adve4cceffe2001-11-05 00:18:30 +000046
Vikram S. Advef9017b82002-08-30 03:27:36 +000047clean::
Vikram S. Adve12398742003-07-08 18:39:51 +000048 $(RM) -f a.out core
Chris Lattnerc89764e2002-01-22 16:56:41 +000049 $(RM) -rf Output/
Vikram S. Adve4cceffe2001-11-05 00:18:30 +000050
Chris Lattner6723add2002-02-12 15:39:38 +000051# Compile from X.c to Output/X.ll
John Criswellee29d2a2003-09-06 15:12:21 +000052Output/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES)
Brian Gaeke5c59be92004-01-13 21:56:30 +000053 -$(LLVMGCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@
Chris Lattnere5b27bd2001-12-09 16:55:43 +000054
Chris Lattnera9028e62003-05-13 20:06:00 +000055# Compile from X.cpp to Output/X.ll
John Criswellee29d2a2003-09-06 15:12:21 +000056Output/%.ll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES)
Brian Gaeke5c59be92004-01-13 21:56:30 +000057 -$(LLVMGXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
Chris Lattnera9028e62003-05-13 20:06:00 +000058
Chris Lattner707af6e2003-06-02 05:49:11 +000059# Compile from X.cc to Output/X.ll
John Criswellee29d2a2003-09-06 15:12:21 +000060Output/%.ll: %.cc $(LCC1XX) Output/.dir $(INCLUDES)
Brian Gaeke5c59be92004-01-13 21:56:30 +000061 -$(LLVMGXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
Chris Lattner707af6e2003-06-02 05:49:11 +000062
Chris Lattner6723add2002-02-12 15:39:38 +000063# LLVM Assemble from Output/X.ll to Output/X.bc. Output/X.ll must have come
64# from GCC output, so use GCCAS.
65#
Chris Lattner52a4e852002-01-23 21:36:59 +000066Output/%.bc: Output/%.ll $(LGCCAS)
Brian Gaeke844c5462004-01-13 21:59:51 +000067 -$(LGCCAS) $(STATS) $< -o $@
Chris Lattner52a4e852002-01-23 21:36:59 +000068
Chris Lattner6723add2002-02-12 15:39:38 +000069# LLVM Assemble from X.ll to Output/X.bc. Because we are coming directly from
70# LLVM source, use the non-transforming assembler.
71#
Brian Gaeke5c59be92004-01-13 21:56:30 +000072Output/%.bc: %.ll $(LLVMAS) Output/.dir
73 -$(LLVMAS) -f $< -o $@
Chris Lattner52a4e852002-01-23 21:36:59 +000074
Vikram S. Advea46fb6b2001-11-06 17:09:49 +000075## Cancel built-in implicit rules that override above rules
Vikram S. Adve4cceffe2001-11-05 00:18:30 +000076%: %.s
77
Vikram S. Advea46fb6b2001-11-06 17:09:49 +000078%: %.c
79
80%.o: %.c
81