blob: c4e7090687b882f035bd6b82d663b9990566a795 [file] [log] [blame]
Chris Lattnere0d8daa2003-05-09 04:19:58 +00001##----------------------------------------------------------*- Makefile -*-===##
Chris Lattnerc89764e2002-01-22 16:56:41 +00002## Common rules for generating, linking, and compiling via LLVM. This is
3## used to implement a robust testing framework for LLVM
Chris Lattnere0d8daa2003-05-09 04:19:58 +00004##-------------------------------------------------------------------------===##
Vikram S. Adve977fa8d2001-12-15 01:13:42 +00005
Chris Lattner995663e2003-01-16 20:26:29 +00006# 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#
10ifdef TEST
11test::
12endif
13
Vikram S. Adve977fa8d2001-12-15 01:13:42 +000014include ${LEVEL}/Makefile.common
15
Chris Lattner37e6f702003-01-21 21:31:29 +000016# Specify ENABLE_STATS on the command line to enable -stats and -time-passes
17# output from gccas and gccld.
Chris Lattner95518172002-09-30 19:23:55 +000018ifdef ENABLE_STATS
Chris Lattner37e6f702003-01-21 21:31:29 +000019STATS = -stats -time-passes
Chris Lattner95518172002-09-30 19:23:55 +000020endif
21
22
Vikram S. Adve4cceffe2001-11-05 00:18:30 +000023.PHONY: clean default
24
Chris Lattner52a4e852002-01-23 21:36:59 +000025# 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 Lattneraef65462002-04-07 08:11:07 +000030.PRECIOUS: Output/%.llvm.bc
31.PRECIOUS: Output/%.llvm
Vikram S. Advea46fb6b2001-11-06 17:09:49 +000032
John Criswell246fcca2003-06-16 19:16:32 +000033TOOLS = $(LLVMTOOLCURRENT)
Chris Lattner60afae42002-11-09 00:50:02 +000034
Chris Lattner52a4e852002-01-23 21:36:59 +000035# LLVM Tool Definitions...
36#
Chris Lattnere0d8daa2003-05-09 04:19:58 +000037LCC = $(LLVMGCCDIR)/bin/gcc
38LCC1 = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1
Chris Lattnera9028e62003-05-13 20:06:00 +000039LCXX = $(LLVMGCCDIR)/bin/g++
40LCC1XX = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1plus
Vikram S. Adve977fa8d2001-12-15 01:13:42 +000041LLI = $(TOOLS)/lli
Vikram S. Adve4cceffe2001-11-05 00:18:30 +000042LLC = $(TOOLS)/llc
Chris Lattner52a4e852002-01-23 21:36:59 +000043LAS = $(TOOLS)/as
44LGCCAS = $(TOOLS)/gccas
Chris Lattnera9028e62003-05-13 20:06:00 +000045LGCCLD = $(TOOLS)/gccld -L$(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/lib
Chris Lattner083de222003-06-26 05:28:00 +000046LGCCLDPROG = $(TOOLS)/gccld
Vikram S. Adve4cceffe2001-11-05 00:18:30 +000047LDIS = $(TOOLS)/dis
48LOPT = $(TOOLS)/opt
49LLINK = $(TOOLS)/link
Chris Lattner65fbd4a2002-06-24 21:35:50 +000050LANALYZE = $(TOOLS)/analyze
Chris Lattner8437f4a2002-11-19 21:57:18 +000051LBUGPOINT= $(TOOLS)/bugpoint
Vikram S. Adve4cceffe2001-11-05 00:18:30 +000052
Chris Lattner52a4e852002-01-23 21:36:59 +000053LCCFLAGS += -O2 -Wall
Chris Lattnera9028e62003-05-13 20:06:00 +000054LCXXFLAGS += -O2 -Wall
Chris Lattner52a4e852002-01-23 21:36:59 +000055LLCFLAGS =
56FAILURE = $(LEVEL)/test/Failure.sh
Chris Lattner45983ee2003-06-28 22:35:46 +000057TESTRUNR = @echo Running test: $<; \
58 PATH=$(LLVMTOOLCURRENT):$(LEVEL)/test/Scripts:$(PATH) \
59 $(LEVEL)/test/TestRunner.sh
Chris Lattner52a4e852002-01-23 21:36:59 +000060
61# Native Tool Definitions
John Criswell01e6d2a2003-06-11 13:56:55 +000062NATGCC = $(CC)
Chris Lattner52a4e852002-01-23 21:36:59 +000063CP = /bin/cp -f
Vikram S. Adve4cceffe2001-11-05 00:18:30 +000064
Vikram S. Adve24672c32003-06-03 18:56:57 +000065## 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. Advebae28762003-06-04 14:24:52 +000067TRACEFLAGS =
Vikram S. Adve4cceffe2001-11-05 00:18:30 +000068ifeq ($(TRACE), yes)
Vikram S. Advebae28762003-06-04 14:24:52 +000069 TRACEFLAGS += -trace
Vikram S. Adve24672c32003-06-03 18:56:57 +000070 DOTRACING = yes
Vikram S. Adve2a4d8d22002-05-19 15:47:52 +000071else
72 ifeq ($(TRACEM), yes)
Vikram S. Advebae28762003-06-04 14:24:52 +000073 TRACEFLAGS += -tracem
Vikram S. Adve24672c32003-06-03 18:56:57 +000074 DOTRACING = yes
Vikram S. Adve2a4d8d22002-05-19 15:47:52 +000075 endif
Vikram S. Adve4cceffe2001-11-05 00:18:30 +000076endif
Vikram S. Adve24672c32003-06-03 18:56:57 +000077ifeq ($(DOTRACING), yes)
Vikram S. Adve12398742003-07-08 18:39:51 +000078 TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr.$(ARCH)
Vikram S. Adve24672c32003-06-03 18:56:57 +000079endif
80
Vikram S. Adve2a4d8d22002-05-19 15:47:52 +000081
82LLCLIBS := $(LLCLIBS) -lm
Vikram S. Adve4cceffe2001-11-05 00:18:30 +000083
Vikram S. Advef9017b82002-08-30 03:27:36 +000084clean::
Vikram S. Adve12398742003-07-08 18:39:51 +000085 $(RM) -f a.out core
Chris Lattnerc89764e2002-01-22 16:56:41 +000086 $(RM) -rf Output/
Vikram S. Adve4cceffe2001-11-05 00:18:30 +000087
Chris Lattner6723add2002-02-12 15:39:38 +000088# Compile from X.c to Output/X.ll
Chris Lattner433f1d82003-05-17 22:33:18 +000089Output/%.ll: $(SourceDir)%.c $(LCC1) Output/.dir $(INCLUDES)
90 $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@
Chris Lattnere5b27bd2001-12-09 16:55:43 +000091
Chris Lattnera9028e62003-05-13 20:06:00 +000092# Compile from X.cpp to Output/X.ll
Chris Lattner433f1d82003-05-17 22:33:18 +000093Output/%.ll: $(SourceDir)%.cpp $(LCC1XX) Output/.dir $(INCLUDES)
94 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
Chris Lattnera9028e62003-05-13 20:06:00 +000095
Chris Lattner707af6e2003-06-02 05:49:11 +000096# Compile from X.cc to Output/X.ll
97Output/%.ll: $(SourceDir)%.cc $(LCC1XX) Output/.dir $(INCLUDES)
98 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
99
Chris Lattner6723add2002-02-12 15:39:38 +0000100# 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 Lattner52a4e852002-01-23 21:36:59 +0000103Output/%.bc: Output/%.ll $(LGCCAS)
Chris Lattner95518172002-09-30 19:23:55 +0000104 $(LGCCAS) $(STATS) $< -o $@
Chris Lattner52a4e852002-01-23 21:36:59 +0000105
Chris Lattner6723add2002-02-12 15:39:38 +0000106# 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 Lattnerfbda7a02002-02-01 04:25:12 +0000109Output/%.bc: %.ll $(LAS) Output/.dir
Chris Lattnerbafff332002-01-31 00:27:32 +0000110 $(LAS) -f $< -o $@
Vikram S. Adve4cceffe2001-11-05 00:18:30 +0000111
Chris Lattner52a4e852002-01-23 21:36:59 +0000112#
113# Testing versions of provided utilities...
114#
Vikram S. Adve2a4d8d22002-05-19 15:47:52 +0000115Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
Chris Lattner52a4e852002-01-23 21:36:59 +0000116 @echo "======== Compiling $<"
Chris Lattner433f1d82003-05-17 22:33:18 +0000117 $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ || \
Chris Lattner52a4e852002-01-23 21:36:59 +0000118 ( rm -f $@; $(FAILURE) $@ )
119
Chris Lattnera9028e62003-05-13 20:06:00 +0000120Output/%.tll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES)
121 @echo "======== Compiling $<"
Chris Lattner433f1d82003-05-17 22:33:18 +0000122 $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ || \
Chris Lattnera9028e62003-05-13 20:06:00 +0000123 ( rm -f $@; $(FAILURE) $@ )
124
Chris Lattner52a4e852002-01-23 21:36:59 +0000125Output/%.tbc: Output/%.tll $(LAS)
126 @echo "======== Assembling $<"
127 $(LAS) -f $< -o $@ || \
128 ( rm -f $@; $(FAILURE) $@ )
129
130
Vikram S. Advea46fb6b2001-11-06 17:09:49 +0000131## Cancel built-in implicit rules that override above rules
Vikram S. Adve4cceffe2001-11-05 00:18:30 +0000132%: %.s
133
Vikram S. Advea46fb6b2001-11-06 17:09:49 +0000134%: %.c
135
136%.o: %.c
137