blob: 393defd70e40a5eb65295277ef3cad474eada902 [file] [log] [blame]
Reid Spencer3d771cb2004-10-10 22:16:37 +00001#,===-- Makefile.rules.am - Common make rules for LLVM ------*- Makefile -*--===#
2#
3# The LLVM Compiler Infrastructure
4#
5# This file was developed by Reid Spencer and is distributed under the
6# University of Illinois Open Source License. See LICENSE.TXT for details.
7#
8#===------------------------------------------------------------------------===#
9
10# Options for all makefiles
11ACLOCAL_AMFLAGS = -I autoconf -I autoconf/m4 --output=autoconf/aclocal.m4
12AUTOMAKE_OPTIONS = foreign dejagnu dist-zip nostdinc
13
14#
15# Install Directories as local makefile variables
16#
17LLVM_PREFIX := @LLVM_PREFIX@
18LLVM_BINDIR := @LLVM_BINDIR@
19LLVM_LIBDIR := @LLVM_LIBDIR@
20LLVM_DATADIR := @LLVM_DATADIR@
21LLVM_DOCSDIR := @LLVM_DOCSDIR@
22LLVM_ETCDIR := @LLVM_ETCDIR@
23LLVM_INCLUDEDIR:= @LLVM_INCLUDEDIR@
24LLVM_INFODIR := @LLVM_INFODIR@
25LLVM_MANDIR := @LLVM_MANDIR@
26
27#
28# LLVM Specific C/C++ compiler flags
29#
30LLVM_COMMONFLAGS := -Wall -W -Wwrite-strings -Wno-unused -Wcast-align
31LLVM_CXXFLAGS :=
32LLVM_CFLAGS :=
33LLVM_CPPFLAGS := \
34 -I. \
35 -I$(srcdir) \
36 -I$(top_srcdir)/include \
37 -I$(top_builddir)/include \
38 -D_RENTRANT -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
39
40if ENABLE_PROFILED
41LLVM_CPPFLAGS += -DNDEBUG
42LLVM_CXXFLAGS += -pg -O3 -finline-functions -felide-constructors
43LLVM_CXXFLAGS += -pg -O3 -finline-functions
44LLVM_CFLAGS += -pg
45endif
46
47if ENABLE_OPTIMIZED
48LLVM_CPPFLAGS += -DNDEBUG
49LLVM_CXXFLAGS += -O3 -finline-functions -fomit-frame-pointer -felide-constructors
50else
51LLVM_CPPFLAGS += -D_DEBUG
52endif
53
54# Required tool definitions as macros so they can be overridden
55VERB := @
56SED := sed
57RM := rm
58CMP := cmp
59MV := mv
60ECHO := echo
61IGNORE := true
62LINKLIB := ${LIBTOOL} --tag=CXX --mode=link $(CXX) -o
63
64BURG := $(top_builddir)/utils/Burg/burg$(EXEEXT)
65RunBurg := $(BURG) -I
66TBLGEN := $(top_builddir)/utils/TableGen/TableGen$(EXEEXT)
67LGCCLDPROG := $(top_builddir)/tools/gccld/gccld$(EXEEXT)
68
69
70# Set up the standard automake variables
71#
72AM_CPPFLAGS = $(LLVM_CPPFLAGS)
73AM_CXXFLAGS = $(LLVM_COMMONFLAGS) $(LLVM_CXXFLAGS)
74AM_CFLAGS = $(LLVM_COMMONFLAGS) $(LLVM_CFLAGS)
75
76# LLVM GMake Function macros
77FIXOBJ = $(top_builddir)/lib/$(2)/LLVM$(1).o
78FIXLIB = $(top_builddir)/lib/$(2)/libLLVM$(1).a
Reid Spencerf8f33052004-10-10 22:54:46 +000079FINDPATH = $(if $(findstring Core,$(1)),VMCore,$(strip \
80 $(if $(findstring Support,$(1)),Support,$(strip \
Reid Spencer3d771cb2004-10-10 22:16:37 +000081 $(if $(findstring System,$(1)),System,$(strip \
Reid Spencerf8f33052004-10-10 22:54:46 +000082 $(if $(findstring BCReader,$(1)),Bytecode/Reader,$(strip \
83 $(if $(findstring BCWriter,$(1)),Bytecode/Writer,$(strip \
84 $(if $(findstring AsmParser,$(1)),AsmParser,$(strip \
85 $(if $(findstring Analysis,$(1)),Analysis,$(strip \
86 $(if $(findstring Target,$(1)),Target,$(strip \
87 $(if $(findstring Transforms,$(1)),Transforms,$(strip \
Reid Spencer3d771cb2004-10-10 22:16:37 +000088 $(if $(findstring IPA,$(1)),Analysis/IPA,$(strip \
89 $(if $(findstring DataStructure,$(1)),Analysis/DataStructure,$(strip \
Reid Spencer3d771cb2004-10-10 22:16:37 +000090 $(if $(findstring IPO,$(1)),Transforms/IPO,$(strip \
91 $(if $(findstring Instrument,$(1)),Transforms/Instrumentation,$(strip \
92 $(if $(findstring ScalarOpts,$(1)),Transforms/Scalar,$(strip \
93 $(if $(findstring TransformUtils,$(1)),Transforms/Utils,$(strip \
Reid Spencer3d771cb2004-10-10 22:16:37 +000094 $(if $(findstring ModuloScheduling,$(1)),CodeGen/ModuloScheduling,$(strip \
95 $(if $(findstring SelectionDAG,$(1)),CodeGen/SelectionDAG,$(strip \
Reid Spencerf8f33052004-10-10 22:54:46 +000096 $(if $(findstring ProfilePaths,$(1)),Transforms/Instrumentation/ProfilePaths,$(strip \
Reid Spencer3d771cb2004-10-10 22:16:37 +000097 $(if $(findstring CodeGen,$(1)),CodeGen,$(strip \
Reid Spencerf8f33052004-10-10 22:54:46 +000098 $(if $(findstring CWriter,$(1)),Target/CBackend,$(strip \
99 $(if $(findstring PowerPC,$(1)),Target/PowerPC,$(strip \
100 $(if $(findstring Skeleton,$(1)),Target/Skeleton,$(strip \
101 $(if $(findstring SparcV9InstrSched,$(1)),Target/SparcV9/InstrSched,$(strip \
102 $(if $(findstring SparcV9LiveVar,$(1)),Target/SparcV9/LiveVar,$(strip \
103 $(if $(findstring SparcV9RegAlloc,$(1)),Target/SparcV9/RegAlloc,$(strip \
104 $(if $(findstring SparcV9,$(1)),Target/SparcV9,$(strip \
105 $(if $(findstring X86,$(1)),Target/X86,$(strip \
Reid Spencer3d771cb2004-10-10 22:16:37 +0000106 $(if $(findstring Debugger,$(1)),Debugger,$(strip \
107 $(if $(findstring Interpreter,$(1)),ExecutionEngine/Interpreter,$(strip \
108 $(if $(findstring JIT,$(1)),ExecutionEngine/JIT,$(strip \
109 $(if $(findstring ExecutionEngine,$(1)),ExecutionEngine,$(strip \
Reid Spencer3d771cb2004-10-10 22:16:37 +0000110 $(if $(findstring Hello,$(1)),Transforms/Hello,$strip \
111 PATH_TO_UNKNOWN_OBJECT)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
112
113GETOBJ = $(call FIXOBJ,$(1),$(call FINDPATH,$(1)))
114GETLIB = $(call FIXLIB,$(1),$(call FINDPATH,$(1)))
115GETOBJS = $(foreach I,$(1) $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9) $(10),$(call GETOBJ,$(I)))
116GETLIBS = $(foreach I,$(1) $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9) $(10),$(call GETLIB,$(I)))
117
118# LLVM Rules
119
120%.cpp: %.l
121 @${ECHO} Flexing $<
122 $(VERB) $(FLEX) -t $< | \
123 $(SED) '/^find_rule/d' | \
124 $(SED) 's/void yyunput/inline void yyunput/' | \
125 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
126 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' > $@.tmp
127 $(VERB) $(CMP) -s $@ $@.tmp > /dev/null || ${MV} -f $@.tmp $@
128 @# remove the output of flex if it didn't get moved over...
129 @$(RM) -f $@.tmp
130
131SUFFIXES = .td
132
133%.c: %.y # Cancel built-in rules for yacc
134
135%.h: %.y # Cancel built-in rules for yacc
136
137%.cpp %.h : %.y
138 @${ECHO} "Bisoning `basename $<`"
139 $(VERB) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
140 $(VERB) $(CMP) -s $*.tab.c $*.cpp > /dev/null || ${MV} -f $*.tab.c $*.cpp
141 $(VERB) $(CMP) -s $*.tab.h $*.h > /dev/null || ${MV} -f $*.tab.h $*.h
142 @# If the files were not updated, don't leave them lying around...
143 @$(RM) -f $*.tab.c $*.tab.h
144
145
146%GenRegisterNames.inc : %.td
147 @echo "Building $< register names with tblgen"
148 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-enums -o $@
149
150%GenRegisterInfo.h.inc : %.td
151 @echo "Building $< register information header with tblgen"
152 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-desc-header -o $@
153
154%GenRegisterInfo.inc : %.td
155 @echo "Building $< register info implementation with tblgen"
156 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-desc -o $@
157
158%GenInstrNames.inc : %.td
159 @echo "Building $< instruction names with tblgen"
160 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-enums -o $@
161
162%GenInstrInfo.inc : %.td
163 @echo "Building $< instruction information with tblgen"
164 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-desc -o $@
165
166%GenAsmWriter.inc : %.td
167 @echo "Building $< assembly writer with tblgen"
168 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -o $@
169
170%GenATTAsmWriter.inc : %.td
171 @echo "Building $< AT&T assembly writer with tblgen"
172 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -o $@
173
174%GenIntelAsmWriter.inc : %.td
175 @echo "Building $< Intel assembly writer with tblgen"
176 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -asmwriternum=1 -o $@
177
178%GenInstrSelector.inc: %.td
179 @echo "Building $< instruction selector with tblgen"
180 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-selector -o $@
181
182TDFILES = $(wildcard $(srcdir)/*.td ) $(srcdir)/../Target.td