-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.rules
641 lines (504 loc) · 19.2 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
#===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
# This file is included by all of the LLVM makefiles. For details on how to use
# it properly, please see the document MakefileGuide.html in the docs directory.
# TARGETS: Define standard targets that can be invoked
# Define the various target sets
RecursiveTargets := all clean clean-all install uninstall
LocalTargets := all-local clean-local clean-all-local check-local \
install-local uninstall-local
TopLevelTargets := check dist-clean
UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
InternalTargets := preconditions
# INITIALIZATION: Basic things the makefile needs
# Set the VPATH so that we can find source files.
VPATH=$(PROJ_SRC_DIR)
# Reset the list of suffixes we know how to build.
.SUFFIXES:
.SUFFIXES: .c .cpp .cc .h .hpp .o .a
.SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
# Mark all of these targets as phony to avoid implicit rule search
.PHONY: $(UserTargets) $(InternalTargets)
# Make sure all the user-target rules are double colon rules and
# they are defined first.
$(UserTargets)::
# PRECONDITIONS: that which must be built/checked first
SrcMakefiles := $(filter %Makefile %Makefile.tests,\
$(wildcard $(PROJ_SRC_DIR)/Makefile*))
ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
PreConditions := $(ObjMakefiles)
PreConditions += $(MakefileCommon)
PreConditions += $(MakefileConfig)
preconditions: $(PreConditions)
# Make sure the BUILT_SOURCES are built first
$(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
clean-all-local::
ifneq ($(strip $(BUILT_SOURCES)),)
-$(Verb) $(RM) -f $(BUILT_SOURCES)
endif
$(BUILT_SOURCES) : $(ObjMakefiles)
ifndef PROJ_MAKEFILE
PROJ_MAKEFILE := $(PROJ_OBJ_DIR)/Makefile
endif
# Set up the basic dependencies
$(UserTargets):: $(PreConditions)
all:: all-local
clean:: clean-local
clean-all:: clean-local clean-all-local
install:: install-local
uninstall:: uninstall-local
install-local:: all-local
# VARIABLES: Set up various variables based on configuration data
# Variable for if this make is for a "cleaning" target
ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
IS_CLEANING_TARGET=1
endif
# Variables derived from configuration we are building
CPP.Defines :=
ifeq ($(ENABLE_OPTIMIZED),1)
BuildMode := Release
OmitFramePointer := -fomit-frame-pointer
CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
LD.Flags += $(OPTIMIZE_OPTION)
ifdef DEBUG_SYMBOLS
BuildMode := $(BuildMode)+Debug
CXX.Flags += -g
C.Flags += -g
LD.Flags += -g
KEEP_SYMBOLS := 1
endif
else
ifdef NO_DEBUG_SYMBOLS
BuildMode := Unoptimized
CXX.Flags +=
C.Flags +=
LD.Flags +=
KEEP_SYMBOLS := 1
else
BuildMode := Debug
CXX.Flags += -g
C.Flags += -g
LD.Flags += -g
KEEP_SYMBOLS := 1
endif
endif
ifeq ($(ENABLE_WERROR),1)
CXX.Flags += -Werror
C.Flags += -Werror
endif
ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
CXX.Flags += -fvisibility-inlines-hidden
endif
CXX.Flags += -fno-exceptions
CXX.Flags += -fno-rtti
# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
# then disable assertions by defining the appropriate preprocessor symbols.
ifeq ($(DISABLE_ASSERTIONS),1)
CPP.Defines += -DNDEBUG
else
BuildMode := $(BuildMode)+Asserts
CPP.Defines += -D_DEBUG
endif
# If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
# configured), then enable expensive checks by defining the
# appropriate preprocessor symbols.
ifeq ($(ENABLE_EXPENSIVE_CHECKS),1)
BuildMode := $(BuildMode)+Checks
CPP.Defines += -DXDEBUG
endif
DOTDIR_TIMESTAMP_COMMAND := $(DATE)
CXX.Flags += -Woverloaded-virtual
CPP.BaseFlags += $(CPP.Defines)
AR.Flags := cru
# Directory locations
ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
ObjDir := $(ObjRootDir)
LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
# Locations of shared libraries
SharedPrefix := lib
SharedLibDir := $(LibDir)
LLVMSharedLibDir := $(LLVMLibDir)
# Full Paths To Compiled Tools and Utilities
EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
Echo := @$(EchoCmd)
LLVMToolDir := $(shell $(LLVM_CONFIG) --bindir)
LLVMLibDir := $(shell $(LLVM_CONFIG) --libdir)
LLVMIncludeDir := $(shell $(LLVM_CONFIG) --includedir)
ifndef LLVM_TBLGEN
LLVM_TBLGEN := $(LLVMToolDir)/llvm-tblgen$(EXEEXT)
endif
SharedLinkOptions=-shared
ifdef TOOL_VERBOSE
C.Flags += -v
CXX.Flags += -v
LD.Flags += -v
VERBOSE := 1
endif
# Adjust settings for verbose mode
ifndef VERBOSE
Verb := @
AR.Flags += >/dev/null 2>/dev/null
endif
# By default, strip symbol information from executable
ifndef KEEP_SYMBOLS
Strip := $(PLATFORMSTRIPOPTS)
StripWarnMsg := "(without symbols)"
Install.StripFlag += -s
endif
ifdef TOOL_NO_EXPORTS
DynamicFlags :=
else
DynamicFlag := $(RDYNAMIC)
endif
# Adjust linker flags for building an executable
ifdef TOOLNAME
LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
LD.Flags += $(RPATH) -Wl,$(ToolDir) $(DynamicFlag)
endif
# Options To Invoke Tools
ifdef EXTRA_LD_OPTIONS
LD.Flags += $(EXTRA_LD_OPTIONS)
endif
ifndef NO_PEDANTIC
CompileCommonOpts += -pedantic -Wno-long-long
endif
CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
$(EXTRA_OPTIONS)
# Enable cast-qual for C++; the workaround is to use const_cast.
CXX.Flags += -Wcast-qual
LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
# All -I flags should go here, so that they don't confuse llvm-config.
CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
$(patsubst %,-I%/include,\
$(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
$(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
-I$(LLVMIncludeDir) $(CPP.BaseFlags)
Compile.Wrapper :=
Compile.C = $(Compile.Wrapper) \
$(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
$(TargetCommonOpts) $(CompileCommonOpts) -c
Compile.CXX = $(Compile.Wrapper) \
$(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
$(TargetCommonOpts) $(CompileCommonOpts) -c
Link = $(Compile.Wrapper) \
$(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(LD.Flags) \
$(LDFLAGS) $(TargetCommonOpts) $(CompileCommonOpts) $(Strip)
ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
ScriptInstall = $(INSTALL) -m 0755
DataInstall = $(INSTALL) -m 0644
TableGen.Flags= -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
-I $(call SYSPATH, $(LLVMIncludeDir)) \
-I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
-I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
LLVMTableGen = $(LLVM_TBLGEN) $(TableGen.Flags)
Archive = $(AR) $(AR.Flags)
ifdef RANLIB
Ranlib = $(RANLIB)
else
Ranlib = ranlib
endif
AliasTool = ln -s
# Get the list of source files and compute object file
# names from them.
ifndef SOURCES
Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
$(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
else
Sources := $(SOURCES)
endif
ifdef BUILT_SOURCES
Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
endif
BaseNameSources := $(sort $(basename $(Sources)))
ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
ECHOPATH := $(Verb)$(ECHO)
# DIRECTORIES: Handle recursive descent of directory structure
# Provide rules to make install dirs. This must be early
# in the file so they get built before dependencies
$(DESTDIR)$(PROJ_bindir)::
$(Verb) $(MKDIR) $@
# To create other directories, as needed, and timestamp their creation
%/.dir:
$(Verb) $(MKDIR) $* > /dev/null
$(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
# Handle the DIRS options for sequential construction
SubDirs :=
ifdef DIRS
SubDirs += $(DIRS)
ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
$(RecursiveTargets)::
$(Verb) for dir in $(DIRS); do \
if ([ ! -f $$dir/Makefile ] || \
command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
$(MKDIR) $$dir; \
$(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
fi; \
($(MAKE) -C $$dir $@ ) || exit 1; \
done
else
$(RecursiveTargets)::
$(Verb) for dir in $(DIRS); do \
($(MAKE) -C $$dir $@ ) || exit 1; \
done
endif
endif
# Handle the PARALLEL_DIRS options for parallel construction
ifdef PARALLEL_DIRS
SubDirs += $(PARALLEL_DIRS)
# Unfortunately, this list must be maintained if new recursive targets are added
all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
$(ParallelTargets) :
$(Verb) \
SD=$(PROJ_SRC_DIR)/$(@D); \
DD=$(@D); \
if [ ! -f $$SD/Makefile ]; then \
SD=$(@D); \
DD=$(notdir $(@D)); \
fi; \
if ([ ! -f $$DD/Makefile ] || \
command test $$DD/Makefile -ot \
$$SD/Makefile ); then \
$(MKDIR) $$DD; \
$(CP) $$SD/Makefile $$DD/Makefile; \
fi; \
$(MAKE) -C $$DD $(subst $(@D)/.make,,$@)
endif
# Set up variables for building libraries
# Define various command line options pertaining to the
# libraries needed when linking. There are "Proj" libs
# (defined by the user's project) and "LLVM" libs (defined
# by the LLVM project).
ifdef USEDLIBS
ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
endif
ifdef LLVMLIBS
LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
endif
ifndef IS_CLEANING_TARGET
ifdef LINK_COMPONENTS
LLVMConfigLibs := $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)
ifeq ($(LLVMConfigLibs),Error)
$(error llvm-config --libs failed)
endif
LLVMLibsOptions += $(LLVMConfigLibs)
LLVMConfigLibfiles := $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS) || echo Error)
ifeq ($(LLVMConfigLibfiles),Error)
$(error llvm-config --libfiles failed)
endif
LLVMLibsPaths += $(LLVMConfigLibfiles)
endif
endif
# Library Build Rules: Four ways to build a library
# if we're building a library ...
ifdef LIBRARYNAME
# Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
LIBRARYNAME := $(strip $(LIBRARYNAME))
BaseLibName.A := lib$(LIBRARYNAME).a
BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
LibName.A := $(LibDir)/$(BaseLibName.A)
LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
LibName.O := $(LibDir)/$(LIBRARYNAME).o
# Library Targets:
# If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
# building an archive.
ifndef NO_BUILD_ARCHIVE
ifndef BUILD_ARCHIVE
ifndef LOADABLE_MODULE
BUILD_ARCHIVE = 1
endif
endif
endif
# Archive Library Targets:
# If the user wanted a regular archive library built,
# then we provide targets for building them.
ifdef BUILD_ARCHIVE
all-local:: $(LibName.A)
$(LibName.A): $(ObjectsO) $(LibDir)/.dir
$(Echo) Building $(BuildMode) Archive Library $(notdir $@)
-$(Verb) $(RM) -f $@
$(Verb) $(Archive) $@ $(ObjectsO)
$(Verb) $(Ranlib) $@
clean-local::
ifneq ($(strip $(LibName.A)),)
-$(Verb) $(RM) -f $(LibName.A)
endif
install-local::
$(Echo) Install circumvented with NO_INSTALL
uninstall-local::
$(Echo) Uninstall circumvented with NO_INSTALL
endif
# endif LIBRARYNAME
endif
# Tool Build Rules: Build executable tool based on TOOLNAME option
ifdef TOOLNAME
# Set up variables for building a tool.
TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
ToolBuildPath := $(ToolDir)/$(TOOLEXENAME)
# Provide targets for building the tools
all-local:: $(ToolBuildPath)
clean-local::
ifneq ($(strip $(ToolBuildPath)),)
-$(Verb) $(RM) -f $(ToolBuildPath)
endif
$(ToolBuildPath): $(ToolDir)/.dir
$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
$(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
$(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
$(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
$(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
$(StripWarnMsg)
ifdef NO_INSTALL
install-local::
$(Echo) Install circumvented with NO_INSTALL
uninstall-local::
$(Echo) Uninstall circumvented with NO_INSTALL
else
ToolBinDir = $(DESTDIR)$(PROJ_bindir)
DestTool = $(ToolBinDir)/$(program_prefix)$(TOOLEXENAME)
install-local:: $(DestTool)
$(DestTool): $(ToolBuildPath)
$(Echo) Installing $(BuildMode) $(DestTool)
$(Verb) $(MKDIR) $(ToolBinDir)
$(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
uninstall-local::
$(Echo) Uninstalling $(BuildMode) $(DestTool)
-$(Verb) $(RM) -f $(DestTool)
endif
endif
# Create .o files in the ObjDir directory from the .cpp and .c files...
DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
-MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
# If the build succeeded, move the dependency file over, otherwise
# remove it.
DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
$(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
$(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
$(DEPEND_MOVEFILE)
$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
$(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
$(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
$(DEPEND_MOVEFILE)
$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
$(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
$(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
$(DEPEND_MOVEFILE)
# TABLEGEN: Provide rules for running tblgen to produce *.inc files
ifdef TARGET
TABLEGEN_INC_FILES_COMMON = 1
endif
ifdef TABLEGEN_INC_FILES_COMMON
INCFiles := $(filter %.inc,$(BUILT_SOURCES))
INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
.PRECIOUS: $(INCTMPFiles) $(INCFiles)
# INCFiles rule: All of the tblgen generated files are emitted to
# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
# us to only "touch" the real file if the contents of it change. IOW, if
# tblgen is modified, all of the .inc.tmp files are regenerated, but no
# dependencies of the .inc files are, unless the contents of the .inc file
# changes.
$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
$(Verb) $(CMP) -s $@ $< || $(CP) $< $@
endif # TABLEGEN_INC_FILES_COMMON
ifdef TARGET
TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
$(LLVMIncludeDir)/llvm/Target/Target.td \
$(LLVMIncludeDir)/llvm/Target/TargetCallingConv.td \
$(LLVMIncludeDir)/llvm/Target/TargetSchedule.td \
$(LLVMIncludeDir)/llvm/Target/TargetSelectionDAG.td \
$(LLVMIncludeDir)/llvm/CodeGen/ValueTypes.td) \
$(wildcard $(LLVMIncludeDir)/llvm/Intrinsics*.td)
# All .inc.tmp files depend on the .td files.
$(INCTMPFiles) : $(TDFiles)
$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
$(Echo) "Building $(<F) register info implementation with tblgen"
$(Verb) $(LLVMTableGen) -gen-register-info -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
$(Echo) "Building $(<F) instruction information with tblgen"
$(Verb) $(LLVMTableGen) -gen-instr-info -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
$(Echo) "Building $(<F) assembly writer with tblgen"
$(Verb) $(LLVMTableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
$(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
$(Echo) "Building $(<F) assembly matcher with tblgen"
$(Verb) $(LLVMTableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenMCCodeEmitter.inc.tmp): \
$(ObjDir)/%GenMCCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
$(Echo) "Building $(<F) MC code emitter with tblgen"
$(Verb) $(LLVMTableGen) -gen-emitter -mc-emitter -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
$(Echo) "Building $(<F) code emitter with tblgen"
$(Verb) $(LLVMTableGen) -gen-emitter -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
$(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
$(Verb) $(LLVMTableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenSubtargetInfo.inc.tmp): \
$(ObjDir)/%GenSubtargetInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
$(Echo) "Building $(<F) subtarget information with tblgen"
$(Verb) $(LLVMTableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
$(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
$(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
$(Echo) "Building $(<F) calling convention information with tblgen"
$(Verb) $(LLVMTableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
clean-local::
-$(Verb) $(RM) -f $(INCFiles)
endif # TARGET
# This rules ensures that header files that are removed still have a rule for
# which they can be "generated." This allows make to ignore them and
# reproduce the dependency lists.
%.h:: ;
%.hpp:: ;
# Define clean-local to clean the current directory. Note that this uses a
# very conservative approach ensuring that empty variables do not cause
# errors or disastrous removal.
clean-local::
ifneq ($(strip $(ObjRootDir)),)
-$(Verb) $(RM) -rf $(ObjRootDir)
endif
ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
-$(Verb) $(RM) -f *$(SHLIBEXT)
endif
clean-all-local::
-$(Verb) $(RM) -rf Debug Release Profile
# DEPENDENCIES: Include the dependency files if we should
ifndef DISABLE_AUTO_DEPENDENCIES
# If its not one of the cleaning targets
ifndef IS_CLEANING_TARGET
# Get the list of dependency files
DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
-include $(DependFiles) ""
endif
endif