forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile_rules
227 lines (173 loc) · 6.85 KB
/
Makefile_rules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#,===-- Makefile.rules.am - Common make rules for LLVM ------*- Makefile -*--===#
#
# The LLVM Compiler Infrastructure
#
# This file was developed by Reid Spencer and is distributed under the
# University of Illinois Open Source License. See LICENSE.TXT for details.
#
#===------------------------------------------------------------------------===#
#
# LLVM Specific C/C++ compiler flags
#
# Locations of built programs/libraries
LDIR := $(top_builddir)/$(BUILDMODE)/lib
BDIR := $(top_builddir)/$(BUILDMODE)/bin
DDIR := $(top_builddir)/$(BUILDMODE)/data
EDIR := $(top_builddir)/$(BUILDMODE)/etc
BCDIR := $(top_builddir)/$(BUILDMODE)/bclib
CXXFLAGS :=
CFLAGS :=
LLVM_COMMONFLAGS := -Wall -W -Wwrite-strings -Wno-unused -Wcast-align
LLVM_CXXFLAGS := $(LLVM_COMMONFLAGS)
LLVM_CFLAGS := $(LLVM_COMMONFLAGS)
LLVM_CPPFLAGS := -I. -I$(srcdir) -I$(top_srcdir)/include \
-I$(top_builddir)/include -D_RENTRANT -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
ifeq ($(BUILDMODE),Profile)
LLVM_CPPFLAGS += -DNDEBUG
LLVM_CXXFLAGS += -pg -O3 -finline-functions -felide-constructors
LLVM_CFLAGS += -pg
else
ifeq ($(BUILDMODE),Release)
LLVM_CPPFLAGS += -DNDEBUG
LLVM_CXXFLAGS += -O3 -finline-functions -fomit-frame-pointer -felide-constructors
LLVM_CFLAGS += -O3
else
LLVM_CPPFLAGS += -D_DEBUG
LLVM_CXXFLAGS += -O1
LLVM_CFLAGS += -O1
endif
endif
# Set up the standard automake variables
#
AM_CPPFLAGS = $(LLVM_CPPFLAGS)
AM_CXXFLAGS = $(LLVM_COMMONFLAGS) $(LLVM_CXXFLAGS)
AM_CFLAGS = $(LLVM_COMMONFLAGS) $(LLVM_CFLAGS)
AM_LDFLAGS = -L$(LDIR)
# Required tool definitions as macros so they can be overridden
LINKLIB := ${LIBTOOL} --tag=CXX --mode=link $(CXX) -o
BURG := $(top_builddir)/utils/Burg/burg$(EXEEXT)
RunBurg := $(BURG) -I
TBLGEN := $(top_builddir)/utils/TableGen/TableGen$(EXEEXT)
LLVMGCC := PATH=$(BDIR):$(PATH) $(LLVMGCCDIR)/bin/gcc
LLVMGXX := PATH=$(BDIR):$(PATH) $(LLVMGCCDIR)/bin/g++
LLVMAS := $(BDIR)/llvm-as$(EXEEXT)
LLVMGCCLD := $(BDIR)/gccld$(EXEEXT)
# LLVM GNU Make Function macros
GETOBJ = $(patsubst %,$(LDIR)/LLVM%.o,$(1))
GETLIB = $(patsubst %,-lLLVM%,$(1))
GETOBJS = $(foreach I,$(1) $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9) $(10),$(call GETOBJ,$(I)))
GETLIBS = $(foreach I,$(1) $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9) $(10),$(call GETLIB,$(I)))
# LLVM Rules
ifdef lib_LIBRARIES
lib_LINKS_TO_MAKE = $(foreach L,$(lib_LIBRARIES),$(patsubst lib%.a,$(LDIR)/lib%.a,$(L)))
all-am : $(lib_LINKS_TO_MAKE)
$(LDIR)/lib%.a : $(LDIR) lib%.a
cwd=`pwd` ; cd $(LDIR) ; $(RM) -f lib$*.a ; $(LN) -s $${cwd}/lib$*.a .
$(LDIR):
$(MKDIR) $(LDIR)
endif
ifdef bin_PROGRAMS
bin_LINKS_TO_MAKE = $(foreach P,$(bin_PROGRAMS),$(patsubst %,$(BDIR)/%,$(P)))
all-am : $(bin_LINKS_TO_MAKE)
$(BDIR)/% : $(BDIR) %
cwd=`pwd` ; cd $(BDIR) ; $(RM) -f $* ; $(LN) -s $${cwd}/$* .
$(BDIR):
$(MKDIR) $(BDIR)
endif
ifdef PRELINK
PRELINK_LIB_NAME = $(LDIR)/$(patsubst lib%.a,%.o,$(PRELINK))
PRELINK_VAR_NAME = $(patsubst lib%.a,lib%_a,$(PRELINK))_OBJECTS
PRELINK_OBJECTS = $($(PRELINK_VAR_NAME))
all-am: $(PRELINK_LIB_NAME)
$(PRELINK_LIB_NAME) : $(PRELINK_OBJECTS)
$(LIBTOOL) --mode=link $(CXX) -o $(PRELINK_LIB_NAME) $(PRELINK_OBJECTS)
clean-am: clean-relink
clean-relink:
$(RM) -f $(PRELINK_LIB_NAME)
install-am: install-prelink
install-prelink:
@${ECHO} ======= Installing $(PRELINK) library =======
$(INSTALL_DATA) '$(PRELINK_LIB_NAME)' $(DESTDIR)$(libdir)
endif
ifdef BYTECODE_LIBRARY
BCL_LIB_NAME = $(BCDIR)/$(patsubst lib%.a,%.bc,$(BYTECODE_LIBRARY))
BCL_VAR_NAME = $(patsubst lib%.a,lib%_a,$(BYTECODE_LIBRARY))_OBJECTS
BCL_OBJECTS = $(patsubst %.o,%.bc,$($(BCL_VAR_NAME)))
LinkBCLib := $(LLVMGCC) -shared -nostdlib
ifdef EXPORTED_SYMBOL_LIST
LinkBCLib += -Xlinker -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
else
LinkBCLib += -Xlinker -disable-internalize
endif
all-am: $(BCDIR) $(BCL_LIB_NAME)
$(BCL_LIB_NAME) : $(BCL_OBJECTS)
$(LinkBCLib) -o $@ $(BCL_OBJECTS) $(LibSubDirs) $(LibLinkOpts)
$(BCDIR):
$(MKDIR) $(BCDIR)
clean-am: clean-bcl
clean-bcl:
$(RM) -f $(BCL_LIB_NAME) *.bc
install-am: install-bcl
intall-bcl:
$(INSTALL_DATA) '$(BCL_LIB_NAME)' $(DESTDIR)$(libdir)
endif
%.cpp: %.l
@${ECHO} Flexing $<
$(VERB) $(FLEX) -t $< | \
$(SED) '/^find_rule/d' | \
$(SED) 's/void yyunput/inline void yyunput/' | \
$(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
$(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' > [email protected]
$(VERB) $(CMP) -s $@ [email protected] > /dev/null || ${MV} -f [email protected] $@
@# remove the output of flex if it didn't get moved over...
@$(RM) -f [email protected]
SUFFIXES = .td
%.c: %.y # Cancel built-in rules for yacc
%.h: %.y # Cancel built-in rules for yacc
%.cpp %.h : %.y
@${ECHO} "Bisoning `basename $<`"
$(VERB) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
$(VERB) $(CMP) -s $*.tab.c $*.cpp > /dev/null || ${MV} -f $*.tab.c $*.cpp
$(VERB) $(CMP) -s $*.tab.h $*.h > /dev/null || ${MV} -f $*.tab.h $*.h
@# If the files were not updated, don't leave them lying around...
@$(RM) -f $*.tab.c $*.tab.h
%.bc : %.cpp
@${ECHO} "Compiling $*.cpp to bytecode"
$(VERB) $(LLVMGXX) $(AM_CPPFLAGS) $(AM_CXXFLAGS) -c $< -o $@
%.bc : %.c
@${ECHO} "Compiling $*.c to bytecode"
$(VERB) $(LLVMGCC) $(AM_CPPFLAGS) $(AM_CFLAGS) -c $< -o $@
%.bc : %.ll
@${ECHO} "Compiling $*.ll to bytecode"
$(VERB) $(LLVMAS) $< -f -o $@
%GenRegisterNames.inc : %.td
@echo "Building $< register names with tblgen"
$(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-enums -o $@
%GenRegisterInfo.h.inc : %.td
@echo "Building $< register information header with tblgen"
$(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-desc-header -o $@
%GenRegisterInfo.inc : %.td
@echo "Building $< register info implementation with tblgen"
$(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-desc -o $@
%GenInstrNames.inc : %.td
@echo "Building $< instruction names with tblgen"
$(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-enums -o $@
%GenInstrInfo.inc : %.td
@echo "Building $< instruction information with tblgen"
$(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-desc -o $@
%GenAsmWriter.inc : %.td
@echo "Building $< assembly writer with tblgen"
$(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -o $@
%GenATTAsmWriter.inc : %.td
@echo "Building $< AT&T assembly writer with tblgen"
$(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -o $@
%GenIntelAsmWriter.inc : %.td
@echo "Building $< Intel assembly writer with tblgen"
$(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -asmwriternum=1 -o $@
%GenInstrSelector.inc: %.td
@echo "Building $< instruction selector with tblgen"
$(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-selector -o $@
%GenCodeEmitter.inc:: %.td $(TDFILES) $(TBLGEN)
@echo "Building $< code emitter with tblgen"
$(VERB) $(TBLGEN) -I $(srcdir) $< -gen-emitter -o $@
TDFILES = $(wildcard $(srcdir)/*.td ) $(srcdir)/../Target.td