blob: 5d1dc4b9723e80a0c456e6e170f1575917a6b129 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001#===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
2#
3# The LLVM Compiler Infrastructure
4#
Chris Lattner3876aa72007-12-29 20:11:13 +00005# This file is distributed under the University of Illinois Open Source
6# License. See LICENSE.TXT for details.
Misha Brukman89fe5162009-01-08 02:11:55 +00007#
Dan Gohmanf17a25c2007-07-18 16:29:46 +00008#===------------------------------------------------------------------------===#
9#
10# This file is included by all of the LLVM makefiles. For details on how to use
11# it properly, please see the document MakefileGuide.html in the docs directory.
12#
13#===-----------------------------------------------------------------------====#
14
15################################################################################
16# TARGETS: Define standard targets that can be invoked
17################################################################################
18
19#--------------------------------------------------------------------
20# Define the various target sets
21#--------------------------------------------------------------------
22RecursiveTargets := all clean clean-all install uninstall install-bytecode
23LocalTargets := all-local clean-local clean-all-local check-local \
24 install-local printvars uninstall-local \
Bill Wendling2e3646a2009-01-04 23:12:21 +000025 install-bytecode-local unittests
Chris Lattner42596062007-09-26 06:10:47 +000026TopLevelTargets := check dist dist-check dist-clean dist-gzip dist-bzip2 \
Bill Wendling2e3646a2009-01-04 23:12:21 +000027 dist-zip unittests
Dan Gohmanf17a25c2007-07-18 16:29:46 +000028UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
29InternalTargets := preconditions distdir dist-hook
30
31################################################################################
32# INITIALIZATION: Basic things the makefile needs
33################################################################################
34
35#--------------------------------------------------------------------
36# Set the VPATH so that we can find source files.
37#--------------------------------------------------------------------
38VPATH=$(PROJ_SRC_DIR)
39
40#--------------------------------------------------------------------
41# Reset the list of suffixes we know how to build.
42#--------------------------------------------------------------------
43.SUFFIXES:
Nick Lewycky8d91e192009-02-26 07:44:16 +000044.SUFFIXES: .c .cpp .cc .h .hpp .o .a .bc .td .ps .dot .ll
Dan Gohmanf17a25c2007-07-18 16:29:46 +000045.SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
46
47#--------------------------------------------------------------------
48# Mark all of these targets as phony to avoid implicit rule search
49#--------------------------------------------------------------------
50.PHONY: $(UserTargets) $(InternalTargets)
51
52#--------------------------------------------------------------------
Misha Brukman89fe5162009-01-08 02:11:55 +000053# Make sure all the user-target rules are double colon rules and
Dan Gohmanf17a25c2007-07-18 16:29:46 +000054# they are defined first.
55#--------------------------------------------------------------------
56
57$(UserTargets)::
58
59################################################################################
60# PRECONDITIONS: that which must be built/checked first
61################################################################################
62
63SrcMakefiles := $(filter %Makefile %Makefile.tests,\
64 $(wildcard $(PROJ_SRC_DIR)/Makefile*))
65ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
66ConfigureScript := $(PROJ_SRC_ROOT)/configure
67ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
68MakefileConfigIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
69MakefileCommonIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
70MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
71MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
72PreConditions := $(ConfigStatusScript) $(ObjMakefiles)
73ifneq ($(MakefileCommonIn),)
74PreConditions += $(MakefileCommon)
75endif
76
77ifneq ($(MakefileConfigIn),)
78PreConditions += $(MakefileConfig)
79endif
80
81preconditions: $(PreConditions)
82
83#------------------------------------------------------------------------
84# Make sure the BUILT_SOURCES are built first
85#------------------------------------------------------------------------
86$(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
87
88clean-all-local::
89ifneq ($(strip $(BUILT_SOURCES)),)
90 -$(Verb) $(RM) -f $(BUILT_SOURCES)
91endif
92
93ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
94spotless:
95 $(Verb) if test -x config.status ; then \
96 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
97 $(MKDIR) .spotless.save ; \
98 $(MV) config.status .spotless.save ; \
99 $(MV) mklib .spotless.save ; \
100 $(MV) projects .spotless.save ; \
101 $(RM) -rf * ; \
102 $(MV) .spotless.save/config.status . ; \
103 $(MV) .spotless.save/mklib . ; \
104 $(MV) .spotless.save/projects . ; \
105 $(RM) -rf .spotless.save ; \
106 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
107 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
108 $(ConfigStatusScript) ; \
109 else \
110 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
111 fi
112else
113spotless:
114 $(EchoCmd) "spotless target not supported for objdir == srcdir"
115endif
116
117$(BUILT_SOURCES) : $(ObjMakefiles)
118
119#------------------------------------------------------------------------
120# Make sure we're not using a stale configuration
121#------------------------------------------------------------------------
122reconfigure:
123 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
124 $(Verb) cd $(PROJ_OBJ_ROOT) && \
125 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
126 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
127 fi ; \
128 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
129 $(ConfigStatusScript)
130
Anton Korobeynikovd26284c2009-08-14 18:53:19 +0000131# FIXME: The {PIC16,MSP430}/AsmPrinter line here is a hack to force a reconfigure to pick
Daniel Dunbare74973d2009-08-13 17:22:49 +0000132# up AsmPrinter changes. Remove it after a reasonable delay from 2009-08-13.
133
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000134.PRECIOUS: $(ConfigStatusScript)
Anton Korobeynikovd26284c2009-08-14 18:53:19 +0000135$(ConfigStatusScript): $(ConfigureScript) $(LLVM_SRC_ROOT)/lib/Target/PIC16/AsmPrinter/Makefile $(LLVM_SRC_ROOT)/lib/Target/MSP430/AsmPrinter/Makefile
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000136 $(Echo) Reconfiguring with $<
137 $(Verb) cd $(PROJ_OBJ_ROOT) && \
138 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
139 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
140 fi ; \
141 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
142 $(ConfigStatusScript)
143
144#------------------------------------------------------------------------
145# Make sure the configuration makefile is up to date
146#------------------------------------------------------------------------
147ifneq ($(MakefileConfigIn),)
148$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
149 $(Echo) Regenerating $@
150 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
151endif
152
153ifneq ($(MakefileCommonIn),)
154$(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
155 $(Echo) Regenerating $@
156 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
157endif
158
159#------------------------------------------------------------------------
160# If the Makefile in the source tree has been updated, copy it over into the
161# build tree. But, only do this if the source and object makefiles differ
162#------------------------------------------------------------------------
163ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
164
Gordon Henriksen4290f662008-03-10 15:58:40 +0000165Makefile: $(PROJ_SRC_DIR)/Makefile $(ExtraMakefiles)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000166 $(Echo) "Updating Makefile"
167 $(Verb) $(MKDIR) $(@D)
168 $(Verb) $(CP) -f $< $@
169
170# Copy the Makefile.* files unless we're in the root directory which avoids
171# the copying of Makefile.config.in or other things that should be explicitly
172# taken care of.
173$(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
174 @case '$?' in \
175 *Makefile.rules) ;; \
176 *.in) ;; \
Gordon Henriksen4290f662008-03-10 15:58:40 +0000177 *) $(EchoCmd) "Updating $(@F)" ; \
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000178 $(MKDIR) $(@D) ; \
179 $(CP) -f $< $@ ;; \
180 esac
Gabor Greif14c4c8e2008-02-27 13:34:15 +0000181
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000182endif
183
184#------------------------------------------------------------------------
185# Set up the basic dependencies
186#------------------------------------------------------------------------
187$(UserTargets):: $(PreConditions)
188
189all:: all-local
Anton Korobeynikov06565172008-11-10 07:33:13 +0000190clean:: clean-local
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000191clean-all:: clean-local clean-all-local
192install:: install-local
193uninstall:: uninstall-local
Misha Brukman89fe5162009-01-08 02:11:55 +0000194install-local:: all-local
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000195install-bytecode:: install-bytecode-local
196
197###############################################################################
Mikhail Glushenkov5f7ba0f2009-03-02 09:04:13 +0000198# LLVMC: Provide rules for compiling llvmc plugins
199###############################################################################
200
201ifdef LLVMC_PLUGIN
202
203LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN))
Mikhail Glushenkovd500a272009-06-23 20:46:48 +0000204CPP.Flags += -DLLVMC_PLUGIN_NAME=$(LLVMC_PLUGIN)
Mikhail Glushenkov5f7ba0f2009-03-02 09:04:13 +0000205REQUIRES_EH := 1
Mikhail Glushenkov928de572009-07-03 03:52:47 +0000206
207ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
208 LD.Flags += -lCompilerDriver
209endif
Mikhail Glushenkov5f7ba0f2009-03-02 09:04:13 +0000210
211# Build a dynamic library if the user runs `make` directly from the plugin
212# directory.
213ifndef LLVMC_BUILTIN_PLUGIN
Mikhail Glushenkov928de572009-07-03 03:52:47 +0000214 LOADABLE_MODULE = 1
Mikhail Glushenkov5f7ba0f2009-03-02 09:04:13 +0000215endif
216
217# TableGen stuff...
218ifneq ($(BUILT_SOURCES),)
Mikhail Glushenkov928de572009-07-03 03:52:47 +0000219 LLVMC_BUILD_AUTOGENERATED_INC=1
Mikhail Glushenkov5f7ba0f2009-03-02 09:04:13 +0000220endif
221
222endif # LLVMC_PLUGIN
223
Mikhail Glushenkovbe76ef22009-06-25 01:07:00 +0000224ifdef LLVMC_BASED_DRIVER
225
226TOOLNAME = $(LLVMC_BASED_DRIVER)
Mikhail Glushenkov928de572009-07-03 03:52:47 +0000227
Mikhail Glushenkovbe76ef22009-06-25 01:07:00 +0000228REQUIRES_EH := 1
Mikhail Glushenkov928de572009-07-03 03:52:47 +0000229
230ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
231 LD.Flags += -lCompilerDriver
232else
233 LLVMLIBS = CompilerDriver.a
234 LINK_COMPONENTS = support system
235endif
Mikhail Glushenkovbe76ef22009-06-25 01:07:00 +0000236
237# Preprocessor magic that generates references to static variables in built-in
238# plugins.
239ifneq ($(LLVMC_BUILTIN_PLUGINS),)
240
241USEDLIBS += $(patsubst %,plugin_llvmc_%.a,$(LLVMC_BUILTIN_PLUGINS))
242
243LLVMC_BUILTIN_PLUGIN_1 = $(word 1, $(LLVMC_BUILTIN_PLUGINS))
244LLVMC_BUILTIN_PLUGIN_2 = $(word 2, $(LLVMC_BUILTIN_PLUGINS))
245LLVMC_BUILTIN_PLUGIN_3 = $(word 3, $(LLVMC_BUILTIN_PLUGINS))
246LLVMC_BUILTIN_PLUGIN_4 = $(word 4, $(LLVMC_BUILTIN_PLUGINS))
247LLVMC_BUILTIN_PLUGIN_5 = $(word 5, $(LLVMC_BUILTIN_PLUGINS))
248
249ifneq ($(LLVMC_BUILTIN_PLUGIN_1),)
250CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_1=$(LLVMC_BUILTIN_PLUGIN_1)
251endif
252
253ifneq ($(LLVMC_BUILTIN_PLUGIN_2),)
254CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_2=$(LLVMC_BUILTIN_PLUGIN_2)
255endif
256
257ifneq ($(LLVMC_BUILTIN_PLUGIN_3),)
258CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_3=$(LLVMC_BUILTIN_PLUGIN_3)
259endif
260
261ifneq ($(LLVMC_BUILTIN_PLUGIN_4),)
262CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_4=$(LLVMC_BUILTIN_PLUGIN_4)
263endif
264
265ifneq ($(LLVMC_BUILTIN_PLUGIN_5),)
266CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_5)
267endif
268
269endif
270
271endif # LLVMC_BASED_DRIVER
272
Mikhail Glushenkov5f7ba0f2009-03-02 09:04:13 +0000273###############################################################################
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274# VARIABLES: Set up various variables based on configuration data
275###############################################################################
276
Daniel Dunbara89194e2008-10-03 19:11:19 +0000277# Variable for if this make is for a "cleaning" target
278ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
279 IS_CLEANING_TARGET=1
280endif
281
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000282#--------------------------------------------------------------------
283# Variables derived from configuration we are building
284#--------------------------------------------------------------------
285
286CPP.Defines :=
287# OPTIMIZE_OPTION - The optimization level option we want to build LLVM with
288# this can be overridden on the make command line.
Evan Cheng107dae12009-04-20 22:16:40 +0000289ifndef OPTIMIZE_OPTION
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000290 ifneq ($(HOST_OS),MingW)
Evan Cheng107dae12009-04-20 22:16:40 +0000291 OPTIMIZE_OPTION := -O3
292 else
293 OPTIMIZE_OPTION := -O2
294 endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000295endif
296
David Greene8cd590c2009-04-17 14:49:22 +0000297ifeq ($(ENABLE_OPTIMIZED),1)
298 BuildMode := Release
299 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000300 ifneq ($(HOST_OS),FreeBSD)
301 ifneq ($(HOST_OS),Darwin)
David Greene8cd590c2009-04-17 14:49:22 +0000302 OmitFramePointer := -fomit-frame-pointer
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000303 endif
David Greene8cd590c2009-04-17 14:49:22 +0000304 endif
305
306 # Darwin requires -fstrict-aliasing to be explicitly enabled.
Evan Cheng95e92ae2009-04-20 22:49:59 +0000307 # Avoid -fstrict-aliasing on Darwin for now, there are unresolved issues
308 # with -fstrict-aliasing and ipa-type-escape radr://6756684
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000309 #ifeq ($(HOST_OS),Darwin)
Evan Cheng107dae12009-04-20 22:16:40 +0000310 # EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
311 #endif
David Greene8cd590c2009-04-17 14:49:22 +0000312 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
313 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
314 LD.Flags += $(OPTIMIZE_OPTION)
315else
316 BuildMode := Debug
317 CXX.Flags += -g
318 C.Flags += -g
319 LD.Flags += -g
320 KEEP_SYMBOLS := 1
321endif
322
323ifeq ($(ENABLE_PROFILING),1)
324 BuildMode := $(BuildMode)+Profile
325 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
326 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
327 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg -g
328 KEEP_SYMBOLS := 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000329endif
330
Daniel Dunbar886e1832008-09-02 17:35:16 +0000331#ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
332# CXX.Flags += -fvisibility-inlines-hidden
333#endif
334
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000335# IF REQUIRES_EH=1 is specified then don't disable exceptions
336ifndef REQUIRES_EH
337 CXX.Flags += -fno-exceptions
338endif
339
Nicolas Geoffray0820ccc2009-08-19 22:04:44 +0000340ifdef REQUIRES_FRAME_POINTER
341 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags))
342 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags))
343 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags))
344endif
345
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000346# IF REQUIRES_RTTI=1 is specified then don't disable run-time type id
347ifndef REQUIRES_RTTI
348# CXX.Flags += -fno-rtti
349endif
350
Daniel Dunbar3fd1aa72009-03-13 20:59:41 +0000351ifdef ENABLE_COVERAGE
352 BuildMode := $(BuildMode)+Coverage
Chris Lattner20cba1c2009-06-16 23:00:42 +0000353 CXX.Flags += -ftest-coverage -fprofile-arcs
354 C.Flags += -ftest-coverage -fprofile-arcs
Daniel Dunbar3fd1aa72009-03-13 20:59:41 +0000355endif
356
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000357# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
358# then disable assertions by defining the appropriate preprocessor symbols.
359ifdef DISABLE_ASSERTIONS
Duncan Sands86a7a222009-03-27 11:35:00 +0000360 # Indicate that assertions are turned off using a minus sign
361 BuildMode := $(BuildMode)-Asserts
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000362 CPP.Defines += -DNDEBUG
363else
364 CPP.Defines += -D_DEBUG
365endif
366
Misha Brukman89fe5162009-01-08 02:11:55 +0000367# If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
368# configured), then enable expensive checks by defining the
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369# appropriate preprocessor symbols.
370ifdef ENABLE_EXPENSIVE_CHECKS
371 BuildMode := $(BuildMode)+Checks
Duncan Sands871e55f2008-12-09 21:33:20 +0000372 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000373endif
374
Nick Lewycky8d91e192009-02-26 07:44:16 +0000375# LOADABLE_MODULE implies several other things so we force them to be
376# defined/on.
377ifdef LOADABLE_MODULE
378 SHARED_LIBRARY := 1
Nick Lewycky8d91e192009-02-26 07:44:16 +0000379 LINK_LIBS_IN_SHARED := 1
380endif
381
382ifdef SHARED_LIBRARY
383 ENABLE_PIC := 1
384 PIC_FLAG = "(PIC)"
385endif
386
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000387ifeq ($(ENABLE_PIC),1)
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000388 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
Nick Lewycky5b882f22009-02-21 08:41:09 +0000389 # Nothing. Win32 defaults to PIC and warns when given -fPIC
390 else
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000391 ifeq ($(HOST_OS),Darwin)
Nick Lewycky8d91e192009-02-26 07:44:16 +0000392 # Common symbols not allowed in dylib files
Nick Lewycky5b882f22009-02-21 08:41:09 +0000393 CXX.Flags += -fno-common
394 C.Flags += -fno-common
395 else
396 # Linux and others; pass -fPIC
397 CXX.Flags += -fPIC
398 C.Flags += -fPIC
399 endif
400 endif
Mike Stump8efa3542009-05-08 23:08:58 +0000401else
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000402 ifeq ($(HOST_OS),Darwin)
Mike Stump8efa3542009-05-08 23:08:58 +0000403 CXX.Flags += -mdynamic-no-pic
404 C.Flags += -mdynamic-no-pic
405 endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000406endif
407
Eric Christopher06bf4822009-08-18 03:23:40 +0000408CXX.Flags += -Woverloaded-virtual
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000409CPP.BaseFlags += $(CPP.Defines)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410AR.Flags := cru
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000411
412# Make Floating point IEEE compliant on Alpha.
413ifeq ($(ARCH),Alpha)
414 CXX.Flags += -mieee
415 CPP.BaseFlags += -mieee
416ifeq ($(ENABLE_PIC),0)
417 CXX.Flags += -fPIC
418 CPP.BaseFlags += -fPIC
419endif
420endif
421
422ifeq ($(ARCH),Alpha)
423 LD.Flags += -Wl,--no-relax
424endif
425
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000426ifeq ($(HOST_OS),MingW)
Anton Korobeynikov025ddd42009-05-04 10:25:30 +0000427 ifeq ($(LLVM_CROSS_COMPILING),1)
428 # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
429 ifdef TOOLNAME
430 LD.Flags += -Wl,--allow-multiple-definition
431 endif
432 endif
433endif
434
Jay Foad188e6472009-05-15 18:13:31 +0000435ifdef ENABLE_EXPENSIVE_CHECKS
436 # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above.
437 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160
438 CXX.Flags := $(filter-out -fno-rtti,$(CXX.Flags))
Daniel Dunbar3b8513d2009-09-03 08:41:19 +0000439 CXXFLAGS := $(filter-out -fno-rtti,$(CXXFLAGS))
Jay Foad188e6472009-05-15 18:13:31 +0000440endif
441
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000442#--------------------------------------------------------------------
443# Directory locations
444#--------------------------------------------------------------------
Jim Grosbache4c032e2008-10-02 22:56:44 +0000445TargetMode :=
446ifeq ($(LLVM_CROSS_COMPILING),1)
Anton Korobeynikov06565172008-11-10 07:33:13 +0000447 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
Jim Grosbache4c032e2008-10-02 22:56:44 +0000448endif
449
450ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
Anton Korobeynikov06565172008-11-10 07:33:13 +0000451ObjDir := $(ObjRootDir)
452LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
453ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
454ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
455LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
456LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
457LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000458CFERuntimeLibDir := $(LLVMGCCDIR)/lib
459
460#--------------------------------------------------------------------
461# Full Paths To Compiled Tools and Utilities
462#--------------------------------------------------------------------
463EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
464Echo = @$(EchoCmd)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000465ifndef LLVMAS
466LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
467endif
468ifndef TBLGEN
469 ifeq ($(LLVM_CROSS_COMPILING),1)
Anton Korobeynikov06565172008-11-10 07:33:13 +0000470 TBLGEN := $(BuildLLVMToolDir)/tblgen$(BUILD_EXEEXT)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000471 else
472 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
473 endif
474endif
Misha Brukman89fe5162009-01-08 02:11:55 +0000475LLVM_CONFIG := $(LLVMToolDir)/llvm-config
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000476ifndef LLVMLD
477LLVMLD := $(LLVMToolDir)/llvm-ld$(EXEEXT)
478endif
479ifndef LLVMDIS
480LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
481endif
482ifndef LLI
483LLI := $(LLVMToolDir)/lli$(EXEEXT)
484endif
485ifndef LLC
486LLC := $(LLVMToolDir)/llc$(EXEEXT)
487endif
488ifndef LOPT
489LOPT := $(LLVMToolDir)/opt$(EXEEXT)
490endif
491ifndef LBUGPOINT
492LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
493endif
494ifndef LUPGRADE
495LUPGRADE := $(LLVMToolDir)/llvm-upgrade$(EXEEXT)
496endif
497ifeq ($(LLVMGCC_MAJVERS),3)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000498LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
499LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
500else
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501LLVMGCCWITHPATH := $(LLVMGCC)
502LLVMGXXWITHPATH := $(LLVMGXX)
503endif
504
505#--------------------------------------------------------------------
506# Adjust to user's request
507#--------------------------------------------------------------------
508
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000509ifeq ($(HOST_OS),Darwin)
Scott Michelf9c9d7e2009-03-12 21:03:53 +0000510 DARWIN_VERSION := `sw_vers -productVersion`
511 # Strip a number like 10.4.7 to 10.4
512 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
513 # Get "4" out of 10.4 for later pieces in the makefile.
514 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
Bill Wendling3c0d23b2009-03-22 08:28:45 +0000515
Julien Lerouge64e1db82009-03-27 18:18:00 +0000516 SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress \
517 -dynamiclib -mmacosx-version-min=$(DARWIN_VERSION)
Scott Michelf9c9d7e2009-03-12 21:03:53 +0000518else
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000519 ifeq ($(HOST_OS),Cygwin)
Scott Michelf9c9d7e2009-03-12 21:03:53 +0000520 SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
Mikhail Glushenkov928de572009-07-03 03:52:47 +0000521 -Wl,--enable-auto-import -Wl,--enable-auto-image-base
Scott Michelf9c9d7e2009-03-12 21:03:53 +0000522 else
523 SharedLinkOptions=-shared
524 endif
525endif
526
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000527ifeq ($(TARGET_OS),Darwin)
528 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
529endif
530
Nick Lewycky8d91e192009-02-26 07:44:16 +0000531# Adjust LD.Flags depending on the kind of library that is to be built. Note
532# that if LOADABLE_MODULE is specified then the resulting shared library can
533# be opened with dlopen.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000534ifdef LOADABLE_MODULE
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535 LD.Flags += -module
536endif
537
538ifdef SHARED_LIBRARY
Scott Michelf9c9d7e2009-03-12 21:03:53 +0000539ifneq ($(DARWIN_MAJVERS),4)
Nick Lewycky12015c12009-03-03 04:55:15 +0000540 LD.Flags += $(RPATH) -Wl,$(LibDir)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000541endif
Scott Michelf9c9d7e2009-03-12 21:03:53 +0000542endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543
544ifdef TOOL_VERBOSE
545 C.Flags += -v
546 CXX.Flags += -v
547 LD.Flags += -v
548 VERBOSE := 1
549endif
550
551# Adjust settings for verbose mode
552ifndef VERBOSE
553 Verb := @
Reid Spencerdfb3d5b2007-07-23 08:20:46 +0000554 AR.Flags += >/dev/null 2>/dev/null
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000555 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
556else
Misha Brukman89fe5162009-01-08 02:11:55 +0000557 ConfigureScriptFLAGS :=
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000558endif
559
560# By default, strip symbol information from executable
561ifndef KEEP_SYMBOLS
562 Strip := $(PLATFORMSTRIPOPTS)
563 StripWarnMsg := "(without symbols)"
564 Install.StripFlag += -s
565endif
566
567# Adjust linker flags for building an executable
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000568ifneq ($(HOST_OS),Darwin)
Scott Michelf9c9d7e2009-03-12 21:03:53 +0000569ifneq ($(DARWIN_MAJVERS),4)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000570ifdef TOOLNAME
571ifdef EXAMPLE_TOOL
Nick Lewyckyaca7e1c2009-03-07 22:17:05 +0000572 LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000573else
Nick Lewyckyaca7e1c2009-03-07 22:17:05 +0000574 LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000575endif
576endif
Nick Lewycky8d91e192009-02-26 07:44:16 +0000577endif
Nick Lewycky8d91e192009-02-26 07:44:16 +0000578endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000579
580#----------------------------------------------------------
581# Options To Invoke Tools
582#----------------------------------------------------------
583
Daniel Dunbarb47afd52009-05-12 07:26:49 +0000584ifndef NO_PEDANTIC
Duncan Sands7d9ea942009-06-19 12:40:30 +0000585CompileCommonOpts += -pedantic -Wno-long-long
Daniel Dunbarb47afd52009-05-12 07:26:49 +0000586endif
Duncan Sands7d9ea942009-06-19 12:40:30 +0000587CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
588 $(EXTRA_OPTIONS)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000589
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000590ifeq ($(HOST_OS),HP-UX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000591 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
592endif
593
594# If we are building a universal binary on Mac OS/X, pass extra options. This
595# is useful to people that want to link the LLVM libraries into their universal
596# apps.
597#
598# The following can be optionally specified:
599# UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
600# For Mac OS/X 10.4 Intel machines, the traditional one is:
601# UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
602# UNIVERSAL_ARCH can be optionally specified to be a list of architectures
603# to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
604# i386/ppc only.
605ifdef UNIVERSAL
606 ifndef UNIVERSAL_ARCH
607 UNIVERSAL_ARCH := i386 ppc
608 endif
609 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
610 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000611 ifdef UNIVERSAL_SDK_PATH
612 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000613 endif
614
615 # Building universal cannot compute dependencies automatically.
616 DISABLE_AUTO_DEPENDENCIES=1
Evan Chengd6ad5ff2009-03-09 18:28:37 +0000617else
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000618 ifeq ($(TARGET_OS),Darwin)
Bill Wendling025cce52009-03-12 04:10:09 +0000619 ifeq ($(ARCH),x86_64)
Evan Chengd1f1fc12009-03-23 03:45:56 +0000620 TargetCommonOpts = -m64
Bill Wendling025cce52009-03-12 04:10:09 +0000621 else
622 ifeq ($(ARCH),x86)
Evan Chengd1f1fc12009-03-23 03:45:56 +0000623 TargetCommonOpts = -m32
Bill Wendling025cce52009-03-12 04:10:09 +0000624 endif
Evan Chengd6ad5ff2009-03-09 18:28:37 +0000625 endif
626 endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000627endif
628
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000629ifeq ($(HOST_OS),SunOS)
Chris Lattner35c997c2008-06-24 17:44:42 +0000630CPP.BaseFlags += -include llvm/System/Solaris.h
631endif
632
Misha Brukman89fe5162009-01-08 02:11:55 +0000633LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
Dan Gohman5a5e6e92008-10-17 01:33:43 +0000634CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000635# All -I flags should go here, so that they don't confuse llvm-config.
Duncan Sands3b960292008-01-28 17:38:30 +0000636CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
637 $(patsubst %,-I%/include,\
Chris Lattner6ee48752008-01-28 04:18:41 +0000638 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
639 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
640 $(CPP.BaseFlags)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000641
Daniel Dunbar3fd1aa72009-03-13 20:59:41 +0000642ifeq ($(BUILD_COMPONENT), 1)
Eric Christopher06bf4822009-08-18 03:23:40 +0000643 Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000644 $(TargetCommonOpts) $(CompileCommonOpts) -c
Eric Christopher06bf4822009-08-18 03:23:40 +0000645 Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
646 $(CPPFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000647 $(TargetCommonOpts) $(CompileCommonOpts) -c
Eric Christopher06bf4822009-08-18 03:23:40 +0000648 Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CPPFLAGS) $(TargetCommonOpts) \
Chris Lattner20cba1c2009-06-16 23:00:42 +0000649 $(CompileCommonOpts) $(CXX.Flags) -E
Eric Christopherd631dfc2009-08-18 18:07:35 +0000650 Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
651 $(LDFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000652 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
Jim Grosbache4c032e2008-10-02 22:56:44 +0000653else
Eric Christopher06bf4822009-08-18 03:23:40 +0000654 Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000655 $(TargetCommonOpts) $(CompileCommonOpts) -c
Eric Christopher06bf4822009-08-18 03:23:40 +0000656 Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000657 $(TargetCommonOpts) $(CompileCommonOpts) -c
Eric Christopher06bf4822009-08-18 03:23:40 +0000658 Preprocess.CXX= $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
Chris Lattner20cba1c2009-06-16 23:00:42 +0000659 $(CompileCommonOpts) $(CXX.Flags) -E
Eric Christopherd631dfc2009-08-18 18:07:35 +0000660 Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(LDFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000661 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
Jim Grosbache4c032e2008-10-02 22:56:44 +0000662endif
663
Eric Christopher06bf4822009-08-18 03:23:40 +0000664BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) $(CFLAGS) \
665 $(CPPFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000666 $(TargetCommonOpts) $(CompileCommonOpts)
Eric Christopher06bf4822009-08-18 03:23:40 +0000667Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000668 $(TargetCommonOpts) $(CompileCommonOpts) -E
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000669
Eric Christopher06bf4822009-08-18 03:23:40 +0000670BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
671 $(CPPFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000672 $(TargetCommonOpts) $(CompileCommonOpts)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000673
Misha Brukman89fe5162009-01-08 02:11:55 +0000674ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
675ScriptInstall = $(INSTALL) -m 0755
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676DataInstall = $(INSTALL) -m 0644
Chris Lattner1b0a3a12008-01-15 23:27:40 +0000677
678# When compiling under Mingw/Cygwin, the tblgen tool expects Windows
679# paths. In this case, the SYSPATH function (defined in
680# Makefile.config) transforms Unix paths into Windows paths.
681TableGen = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
Mikhail Glushenkov3e6bf9a2009-01-09 16:31:01 +0000682 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
Chris Lattner1b0a3a12008-01-15 23:27:40 +0000683 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
684 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
685
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000686Archive = $(AR) $(AR.Flags)
687LArchive = $(LLVMToolDir)/llvm-ar rcsf
688ifdef RANLIB
689Ranlib = $(RANLIB)
690else
691Ranlib = ranlib
692endif
693
694#----------------------------------------------------------
Misha Brukman89fe5162009-01-08 02:11:55 +0000695# Get the list of source files and compute object file
696# names from them.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000697#----------------------------------------------------------
698
699ifndef SOURCES
700 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
Chris Lattnerbfaed4c2009-01-02 07:16:45 +0000701 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702else
703 Sources := $(SOURCES)
Misha Brukman89fe5162009-01-08 02:11:55 +0000704endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000705
706ifdef BUILT_SOURCES
Chris Lattnerbfaed4c2009-01-02 07:16:45 +0000707Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000708endif
709
710BaseNameSources := $(sort $(basename $(Sources)))
711
712ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000713ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
714
715###############################################################################
716# DIRECTORIES: Handle recursive descent of directory structure
717###############################################################################
718
719#---------------------------------------------------------
720# Provide rules to make install dirs. This must be early
721# in the file so they get built before dependencies
722#---------------------------------------------------------
723
Mike Stump98f72e02009-02-12 23:45:11 +0000724$(PROJ_bindir) $(PROJ_libdir) $(PROJ_includedir) $(PROJ_etcdir)::
Mike Stumpf0feefd2009-01-22 03:24:22 +0000725 $(Verb) $(MKDIR) $@
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000726
727# To create other directories, as needed, and timestamp their creation
728%/.dir:
729 $(Verb) $(MKDIR) $* > /dev/null
730 $(Verb) $(DATE) > $@
731
732.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
733.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
734
735#---------------------------------------------------------
736# Handle the DIRS options for sequential construction
737#---------------------------------------------------------
738
Misha Brukman89fe5162009-01-08 02:11:55 +0000739SubDirs :=
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000740ifdef DIRS
741SubDirs += $(DIRS)
742
743ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
744$(RecursiveTargets)::
745 $(Verb) for dir in $(DIRS); do \
746 if [ ! -f $$dir/Makefile ]; then \
747 $(MKDIR) $$dir; \
748 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
749 fi; \
750 ($(MAKE) -C $$dir $@ ) || exit 1; \
751 done
752else
753$(RecursiveTargets)::
754 $(Verb) for dir in $(DIRS); do \
755 ($(MAKE) -C $$dir $@ ) || exit 1; \
756 done
757endif
758
759endif
760
761#---------------------------------------------------------
762# Handle the EXPERIMENTAL_DIRS options ensuring success
763# after each directory is built.
764#---------------------------------------------------------
765ifdef EXPERIMENTAL_DIRS
766$(RecursiveTargets)::
767 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
768 if [ ! -f $$dir/Makefile ]; then \
769 $(MKDIR) $$dir; \
770 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
771 fi; \
772 ($(MAKE) -C $$dir $@ ) || exit 0; \
773 done
774endif
775
776#-----------------------------------------------------------
Mike Stump0fec3192009-01-24 00:00:41 +0000777# Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
778#-----------------------------------------------------------
779ifdef OPTIONAL_PARALLEL_DIRS
780 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
781endif
782
783#-----------------------------------------------------------
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000784# Handle the PARALLEL_DIRS options for parallel construction
785#-----------------------------------------------------------
786ifdef PARALLEL_DIRS
787
788SubDirs += $(PARALLEL_DIRS)
789
790# Unfortunately, this list must be maintained if new recursive targets are added
791all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
792clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
793clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
794install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
795uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
796install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
797
798ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
799
800$(ParallelTargets) :
801 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
802 $(MKDIR) $(@D); \
803 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
804 fi; \
805 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
806endif
807
808#---------------------------------------------------------
809# Handle the OPTIONAL_DIRS options for directores that may
810# or may not exist.
811#---------------------------------------------------------
812ifdef OPTIONAL_DIRS
813
814SubDirs += $(OPTIONAL_DIRS)
815
816ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
817$(RecursiveTargets)::
818 $(Verb) for dir in $(OPTIONAL_DIRS); do \
819 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
820 if [ ! -f $$dir/Makefile ]; then \
821 $(MKDIR) $$dir; \
822 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
823 fi; \
824 ($(MAKE) -C$$dir $@ ) || exit 1; \
825 fi \
826 done
827else
828$(RecursiveTargets)::
829 $(Verb) for dir in $(OPTIONAL_DIRS); do \
830 ($(MAKE) -C$$dir $@ ) || exit 1; \
831 done
832endif
833endif
834
835#---------------------------------------------------------
836# Handle the CONFIG_FILES options
837#---------------------------------------------------------
838ifdef CONFIG_FILES
839
840ifdef NO_INSTALL
841install-local::
842 $(Echo) Install circumvented with NO_INSTALL
843uninstall-local::
844 $(Echo) UnInstall circumvented with NO_INSTALL
845else
846install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
847 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
848 $(Verb)for file in $(CONFIG_FILES); do \
849 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
850 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
851 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
852 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
853 else \
854 $(ECHO) Error: cannot find config file $${file}. ; \
855 fi \
856 done
857
858uninstall-local::
859 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
860 $(Verb)for file in $(CONFIG_FILES); do \
861 $(RM) -f $(PROJ_etcdir)/$${file} ; \
862 done
863endif
864
865endif
866
867###############################################################################
868# Set up variables for building libararies
869###############################################################################
870
871#---------------------------------------------------------
872# Define various command line options pertaining to the
Misha Brukman89fe5162009-01-08 02:11:55 +0000873# libraries needed when linking. There are "Proj" libs
874# (defined by the user's project) and "LLVM" libs (defined
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875# by the LLVM project).
876#---------------------------------------------------------
877
878ifdef USEDLIBS
879ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
880ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
881ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
882ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
883endif
884
885ifdef LLVMLIBS
886LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
887LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
888LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
889LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
890endif
891
Daniel Dunbara89194e2008-10-03 19:11:19 +0000892ifndef IS_CLEANING_TARGET
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000893ifdef LINK_COMPONENTS
894
895# If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
896# clean in tools, then do a make in tools (instead of at the top level).
897$(LLVM_CONFIG):
898 @echo "*** llvm-config doesn't exist - rebuilding it."
899 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
Gabor Greif14c4c8e2008-02-27 13:34:15 +0000900
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000901$(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
902
Mikhail Glushenkovfc320822009-03-03 10:03:27 +0000903LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
904LLVMLibsPaths += $(LLVM_CONFIG) \
Misha Brukmanfc6ae992009-08-17 15:31:24 +0000905 $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906endif
907endif
908
909###############################################################################
910# Library Build Rules: Four ways to build a library
911###############################################################################
912
913#---------------------------------------------------------
914# Bytecode Module Targets:
915# If the user set MODULE_NAME then they want to build a
916# bytecode module from the sources. We compile all the
917# sources and link it together into a single bytecode
918# module.
919#---------------------------------------------------------
920
921ifdef MODULE_NAME
922ifeq ($(strip $(LLVMGCC)),)
923$(warning Modules require llvm-gcc but no llvm-gcc is available ****)
924else
925
926Module := $(LibDir)/$(MODULE_NAME).bc
Andrew Lenharthd0020772008-02-25 22:41:55 +0000927LinkModule := $(LLVMLD) -L$(CFERuntimeLibDir) -r
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000928
929
930ifdef EXPORTED_SYMBOL_FILE
931LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
932endif
933
934$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
935 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
936 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
937
938all-local:: $(Module)
939
940clean-local::
941ifneq ($(strip $(Module)),)
942 -$(Verb) $(RM) -f $(Module)
943endif
944
945ifdef BYTECODE_DESTINATION
946ModuleDestDir := $(BYTECODE_DESTINATION)
947else
948ModuleDestDir := $(PROJ_libdir)
949endif
950
951ifdef NO_INSTALL
952install-local::
953 $(Echo) Install circumvented with NO_INSTALL
954uninstall-local::
955 $(Echo) Uninstall circumvented with NO_INSTALL
956else
957DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
958
959install-module:: $(DestModule)
960install-local:: $(DestModule)
961
Misha Brukman89fe5162009-01-08 02:11:55 +0000962$(DestModule): $(ModuleDestDir) $(Module)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
964 $(Verb) $(DataInstall) $(Module) $(DestModule)
965
966uninstall-local::
967 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
968 -$(Verb) $(RM) -f $(DestModule)
969endif
970
971endif
972endif
973
974# if we're building a library ...
975ifdef LIBRARYNAME
976
Misha Brukmanfc6ae992009-08-17 15:31:24 +0000977# Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978LIBRARYNAME := $(strip $(LIBRARYNAME))
979ifdef LOADABLE_MODULE
Nick Lewycky8d91e192009-02-26 07:44:16 +0000980LibName.A := $(LibDir)/$(LIBRARYNAME).a
981LibName.SO := $(LibDir)/$(LIBRARYNAME)$(SHLIBEXT)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982else
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
Nick Lewycky8d91e192009-02-26 07:44:16 +0000984LibName.SO := $(LibDir)/lib$(LIBRARYNAME)$(SHLIBEXT)
985endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986LibName.O := $(LibDir)/$(LIBRARYNAME).o
987LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
988
989#---------------------------------------------------------
990# Shared Library Targets:
991# If the user asked for a shared library to be built
992# with the SHARED_LIBRARY variable, then we provide
993# targets for building them.
994#---------------------------------------------------------
995ifdef SHARED_LIBRARY
996
Nick Lewycky8d91e192009-02-26 07:44:16 +0000997all-local:: $(LibName.SO)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998
999ifdef LINK_LIBS_IN_SHARED
1000ifdef LOADABLE_MODULE
1001SharedLibKindMessage := "Loadable Module"
1002else
1003SharedLibKindMessage := "Shared Library"
1004endif
Nick Lewycky8d91e192009-02-26 07:44:16 +00001005$(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(LibDir)/.dir
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1007 $(LIBRARYNAME)$(SHLIBEXT)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001008 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
Edwin Töröke59edce2009-05-26 19:11:47 +00001009 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010else
Nick Lewycky8d91e192009-02-26 07:44:16 +00001011$(LibName.SO): $(ObjectsO) $(LibDir)/.dir
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001013 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014endif
1015
1016clean-local::
Nick Lewycky8d91e192009-02-26 07:44:16 +00001017ifneq ($(strip $(LibName.SO)),)
1018 -$(Verb) $(RM) -f $(LibName.SO)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001019endif
1020
1021ifdef NO_INSTALL
1022install-local::
1023 $(Echo) Install circumvented with NO_INSTALL
1024uninstall-local::
1025 $(Echo) Uninstall circumvented with NO_INSTALL
1026else
1027DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
1028
1029install-local:: $(DestSharedLib)
1030
Nick Lewycky8d91e192009-02-26 07:44:16 +00001031$(DestSharedLib): $(LibName.SO) $(PROJ_libdir)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001033 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001034
Misha Brukman89fe5162009-01-08 02:11:55 +00001035uninstall-local::
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001036 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1037 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
1038endif
1039endif
1040
1041#---------------------------------------------------------
1042# Bytecode Library Targets:
1043# If the user asked for a bytecode library to be built
Misha Brukman89fe5162009-01-08 02:11:55 +00001044# with the BYTECODE_LIBRARY variable, then we provide
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001045# targets for building them.
1046#---------------------------------------------------------
1047ifdef BYTECODE_LIBRARY
1048ifeq ($(strip $(LLVMGCC)),)
1049$(warning Bytecode libraries require llvm-gcc which could not be found ****)
1050else
1051
1052all-local:: $(LibName.BCA)
1053
1054ifdef EXPORTED_SYMBOL_FILE
1055BCLinkLib = $(LLVMLD) -L$(CFERuntimeLibDir) \
1056 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
1057
1058$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
1059 $(LLVMToolDir)/llvm-ar
1060 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
1061 "(internalize)"
Daniel Dunbarc6750c92009-08-28 16:14:46 +00001062 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).internalize $(ObjectsBC)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001063 $(Verb) $(RM) -f $@
Daniel Dunbarc6750c92009-08-28 16:14:46 +00001064 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).internalize.bc
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065else
1066$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
1067 $(LLVMToolDir)/llvm-ar
1068 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
1069 $(Verb) $(RM) -f $@
1070 $(Verb) $(LArchive) $@ $(ObjectsBC)
1071
1072endif
1073
1074clean-local::
1075ifneq ($(strip $(LibName.BCA)),)
1076 -$(Verb) $(RM) -f $(LibName.BCA)
1077endif
1078
1079ifdef BYTECODE_DESTINATION
1080BytecodeDestDir := $(BYTECODE_DESTINATION)
1081else
1082BytecodeDestDir := $(PROJ_libdir)
1083endif
1084
Daniel Dunbar659cef82009-05-12 05:35:40 +00001085DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).bca
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001086
1087install-bytecode-local:: $(DestBytecodeLib)
1088
1089ifdef NO_INSTALL
1090install-local::
1091 $(Echo) Install circumvented with NO_INSTALL
1092uninstall-local::
1093 $(Echo) Uninstall circumvented with NO_INSTALL
1094else
1095install-local:: $(DestBytecodeLib)
1096
Mike Stump98f72e02009-02-12 23:45:11 +00001097$(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1099 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
1100
1101uninstall-local::
1102 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1103 -$(Verb) $(RM) -f $(DestBytecodeLib)
1104endif
1105endif
1106endif
1107
1108#---------------------------------------------------------
Chris Lattner20cba1c2009-06-16 23:00:42 +00001109# Library Targets:
1110# If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1111# building an archive.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001112#---------------------------------------------------------
1113ifndef BUILD_ARCHIVE
Chris Lattner20cba1c2009-06-16 23:00:42 +00001114ifndef LOADABLE_MODULE
1115BUILD_ARCHIVE = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001116endif
1117endif
1118
1119#---------------------------------------------------------
1120# Archive Library Targets:
Misha Brukman89fe5162009-01-08 02:11:55 +00001121# If the user wanted a regular archive library built,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001122# then we provide targets for building them.
1123#---------------------------------------------------------
1124ifdef BUILD_ARCHIVE
1125
1126all-local:: $(LibName.A)
1127
1128$(LibName.A): $(ObjectsO) $(LibDir)/.dir
1129 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1130 -$(Verb) $(RM) -f $@
Bill Wendling3d6df102009-01-03 22:46:50 +00001131 $(Verb) $(Archive) $@ $(ObjectsO)
1132 $(Verb) $(Ranlib) $@
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001133
1134clean-local::
1135ifneq ($(strip $(LibName.A)),)
1136 -$(Verb) $(RM) -f $(LibName.A)
1137endif
1138
1139ifdef NO_INSTALL
1140install-local::
1141 $(Echo) Install circumvented with NO_INSTALL
1142uninstall-local::
1143 $(Echo) Uninstall circumvented with NO_INSTALL
1144else
1145DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
1146
1147install-local:: $(DestArchiveLib)
1148
Mike Stump98f72e02009-02-12 23:45:11 +00001149$(DestArchiveLib): $(LibName.A) $(PROJ_libdir)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001150 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1151 $(Verb) $(MKDIR) $(PROJ_libdir)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001152 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001153
1154uninstall-local::
1155 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1156 -$(Verb) $(RM) -f $(DestArchiveLib)
1157endif
1158endif
1159
1160# endif LIBRARYNAME
Misha Brukman89fe5162009-01-08 02:11:55 +00001161endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001162
1163###############################################################################
1164# Tool Build Rules: Build executable tool based on TOOLNAME option
1165###############################################################################
1166
1167ifdef TOOLNAME
1168
1169#---------------------------------------------------------
1170# Set up variables for building a tool.
1171#---------------------------------------------------------
1172ifdef EXAMPLE_TOOL
1173ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
1174else
1175ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
1176endif
1177
1178#---------------------------------------------------------
Chris Lattner8b04ea72009-02-26 17:47:49 +00001179# Prune Exports
1180#---------------------------------------------------------
1181
1182# If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1183# not exporting all of the weak symbols from the binary. This reduces dyld
1184# startup time by 4x on darwin in some cases.
1185ifdef TOOL_NO_EXPORTS
Anton Korobeynikov92c51812009-08-18 00:40:33 +00001186ifeq ($(HOST_OS),Darwin)
Chris Lattnerc6c51352009-03-10 17:15:56 +00001187
1188# Tiger tools don't support this.
1189ifneq ($(DARWIN_MAJVERS),4)
Chris Lattner8b04ea72009-02-26 17:47:49 +00001190LD.Flags += -Wl,-exported_symbol -Wl,_main
1191endif
Chris Lattnerc6c51352009-03-10 17:15:56 +00001192endif
Chris Lattner8b04ea72009-02-26 17:47:49 +00001193
Anton Korobeynikov92c51812009-08-18 00:40:33 +00001194ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD))
Chris Lattner7c024612009-02-26 18:38:40 +00001195LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
Chris Lattner8b04ea72009-02-26 17:47:49 +00001196endif
1197endif
1198
1199
1200#---------------------------------------------------------
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001201# Provide targets for building the tools
1202#---------------------------------------------------------
1203all-local:: $(ToolBuildPath)
1204
1205clean-local::
1206ifneq ($(strip $(ToolBuildPath)),)
1207 -$(Verb) $(RM) -f $(ToolBuildPath)
1208endif
1209
1210ifdef EXAMPLE_TOOL
1211$(ToolBuildPath): $(ExmplDir)/.dir
1212else
1213$(ToolBuildPath): $(ToolDir)/.dir
1214endif
1215
1216$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1217 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001218 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001219 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1220 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
Misha Brukman89fe5162009-01-08 02:11:55 +00001221 $(StripWarnMsg)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001222
1223ifdef NO_INSTALL
1224install-local::
1225 $(Echo) Install circumvented with NO_INSTALL
1226uninstall-local::
1227 $(Echo) Uninstall circumvented with NO_INSTALL
1228else
Anton Korobeynikovfffdd942009-08-05 09:37:43 +00001229DestTool = $(PROJ_bindir)/$(TOOLNAME)$(EXEEXT)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001230
1231install-local:: $(DestTool)
1232
Mike Stump98f72e02009-02-12 23:45:11 +00001233$(DestTool): $(ToolBuildPath) $(PROJ_bindir)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001234 $(Echo) Installing $(BuildMode) $(DestTool)
1235 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1236
1237uninstall-local::
1238 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1239 -$(Verb) $(RM) -f $(DestTool)
1240endif
1241endif
1242
1243###############################################################################
Misha Brukman89fe5162009-01-08 02:11:55 +00001244# Object Build Rules: Build object files based on sources
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001245###############################################################################
1246
1247# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
Anton Korobeynikov92c51812009-08-18 00:40:33 +00001248ifeq ($(HOST_OS),HP-UX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001249 DISABLE_AUTO_DEPENDENCIES=1
1250endif
1251
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001252# Provide rule sets for when dependency generation is enabled
1253ifndef DISABLE_AUTO_DEPENDENCIES
1254
1255#---------------------------------------------------------
Nick Lewycky8d91e192009-02-26 07:44:16 +00001256# Create .o files in the ObjDir directory from the .cpp and .c files...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001257#---------------------------------------------------------
1258
Chris Lattner87fd1ec2007-12-31 23:58:31 +00001259DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
Nick Lewycky8d91e192009-02-26 07:44:16 +00001260 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
Gabor Greif14c4c8e2008-02-27 13:34:15 +00001261
Daniel Dunbar285108f2009-05-12 06:35:50 +00001262# If the build succeeded, move the dependency file over, otherwise
1263# remove it.
Chris Lattner87fd1ec2007-12-31 23:58:31 +00001264DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1265 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1266
Nick Lewycky8d91e192009-02-26 07:44:16 +00001267$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001268 $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001269 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
Chris Lattner87fd1ec2007-12-31 23:58:31 +00001270 $(DEPEND_MOVEFILE)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001271
Nick Lewycky8d91e192009-02-26 07:44:16 +00001272$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001273 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001274 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
Chris Lattner87fd1ec2007-12-31 23:58:31 +00001275 $(DEPEND_MOVEFILE)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001276
Nick Lewycky8d91e192009-02-26 07:44:16 +00001277$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001278 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001279 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
Chris Lattner87fd1ec2007-12-31 23:58:31 +00001280 $(DEPEND_MOVEFILE)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281
1282#---------------------------------------------------------
1283# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1284#---------------------------------------------------------
1285
Daniel Dunbar285108f2009-05-12 06:35:50 +00001286BC_DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.bc.d.tmp" \
1287 -MT "$(ObjDir)/$*.ll" -MT "$(ObjDir)/$*.bc.d"
1288
1289# If the build succeeded, move the dependency file over, otherwise
1290# remove it.
1291BC_DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.bc.d.tmp" "$(ObjDir)/$*.bc.d"; \
1292 else $(RM) "$(ObjDir)/$*.bc.d.tmp"; exit 1; fi
1293
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001294$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1295 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Daniel Dunbar285108f2009-05-12 06:35:50 +00001296 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1297 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1298 $(BC_DEPEND_MOVEFILE)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299
1300$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1301 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Daniel Dunbar285108f2009-05-12 06:35:50 +00001302 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1303 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1304 $(BC_DEPEND_MOVEFILE)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001305
1306$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1307 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Daniel Dunbar285108f2009-05-12 06:35:50 +00001308 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1309 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1310 $(BC_DEPEND_MOVEFILE)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001311
1312# Provide alternate rule sets if dependencies are disabled
1313else
1314
Nick Lewycky8d91e192009-02-26 07:44:16 +00001315$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001316 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001317 $(Compile.CXX) $< -o $@
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001318
Nick Lewycky8d91e192009-02-26 07:44:16 +00001319$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001320 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001321 $(Compile.CXX) $< -o $@
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001322
Nick Lewycky8d91e192009-02-26 07:44:16 +00001323$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001324 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001325 $(Compile.C) $< -o $@
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001326
1327$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1328 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1329 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330
1331$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1332 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1333 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001334
1335$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1336 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1337 $(BCCompile.C) $< -o $@ -S -emit-llvm
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001338
1339endif
1340
1341
1342## Rules for building preprocessed (.i/.ii) outputs.
1343$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1344 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1345 $(Verb) $(Preprocess.CXX) $< -o $@
1346
1347$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1348 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1349 $(Verb) $(Preprocess.CXX) $< -o $@
1350
1351$(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1352 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1353 $(Verb) $(Preprocess.C) $< -o $@
1354
1355
1356$(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1357 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001358 $(Compile.CXX) $< -o $@ -S
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359
1360$(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1361 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001362 $(Compile.CXX) $< -o $@ -S
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001363
1364$(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1365 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001366 $(Compile.C) $< -o $@ -S
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001367
1368
1369# make the C and C++ compilers strip debug info out of bytecode libraries.
1370ifdef DEBUG_RUNTIME
Dan Gohman25de0de2009-09-08 15:52:56 +00001371$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Dan Gohman25de0de2009-09-08 15:52:56 +00001373 $(Verb) $(LOPT) $< -std-compile-opts -o $@
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001374else
Dan Gohman25de0de2009-09-08 15:52:56 +00001375$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001376 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Dan Gohman25de0de2009-09-08 15:52:56 +00001377 $(Verb) $(LOPT) $< -std-compile-opts -strip-debug -o $@
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001378endif
1379
1380
1381#---------------------------------------------------------
1382# Provide rule to build .bc files from .ll sources,
1383# regardless of dependencies
1384#---------------------------------------------------------
1385$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1386 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1387 $(Verb) $(LLVMAS) $< -f -o $@
1388
1389###############################################################################
1390# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1391###############################################################################
1392
1393ifdef TARGET
Mikhail Glushenkov72145e32009-03-02 09:42:59 +00001394TABLEGEN_INC_FILES_COMMON = 1
1395endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001396
Mikhail Glushenkov72145e32009-03-02 09:42:59 +00001397ifdef LLVMC_BUILD_AUTOGENERATED_INC
1398TABLEGEN_INC_FILES_COMMON = 1
1399endif
1400
1401ifdef TABLEGEN_INC_FILES_COMMON
1402
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001403INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1404INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1405.PRECIOUS: $(INCTMPFiles) $(INCFiles)
1406
Misha Brukman89fe5162009-01-08 02:11:55 +00001407# INCFiles rule: All of the tblgen generated files are emitted to
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001408# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1409# us to only "touch" the real file if the contents of it change. IOW, if
Daniel Dunbar90f3e7f2008-11-03 17:33:36 +00001410# tblgen is modified, all of the .inc.tmp files are regenerated, but no
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001411# dependencies of the .inc files are, unless the contents of the .inc file
1412# changes.
1413$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1414 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1415
Mikhail Glushenkov72145e32009-03-02 09:42:59 +00001416endif # TABLEGEN_INC_FILES_COMMON
1417
1418ifdef TARGET
1419
1420TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1421 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1422 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1423 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1424 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1425 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1426 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1427
Rafael Espindola4d8cd532009-03-10 17:58:54 +00001428# All of these files depend on tblgen and the .td files.
1429$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1430
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001431$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1432$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1433 $(Echo) "Building $(<F) register names with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001434 $(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001435
1436$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1437$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1438 $(Echo) "Building $(<F) register information header with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001439 $(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001440
1441$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1442$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1443 $(Echo) "Building $(<F) register info implementation with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001444 $(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001445
1446$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1447$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1448 $(Echo) "Building $(<F) instruction names with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001449 $(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001450
1451$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1452$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1453 $(Echo) "Building $(<F) instruction information with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001454 $(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001455
1456$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1457$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1458 $(Echo) "Building $(<F) assembly writer with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001459 $(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001460
1461$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1462$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1463 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Misha Brukman89fe5162009-01-08 02:11:55 +00001464 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001465
Daniel Dunbara9b43082009-07-13 18:35:35 +00001466$(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1467$(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir
1468 $(Echo) "Building $(<F) assembly matcher with tblgen"
1469 $(Verb) $(TableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1470
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1472$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1473 $(Echo) "Building $(<F) code emitter with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001474 $(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001475
1476$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1477$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
Dan Gohmanb75dead2008-08-13 20:19:35 +00001478 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001479 $(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001480
Dan Gohmanb75dead2008-08-13 20:19:35 +00001481$(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1482$(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
1483 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1484 $(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1485
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001486$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1487$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1488 $(Echo) "Building $(<F) subtarget information with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001489 $(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001490
1491$(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1492$(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1493 $(Echo) "Building $(<F) calling convention information with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001494 $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001495
Dale Johannesenfe5921a2009-02-05 01:49:45 +00001496$(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1497$(ObjDir)/%GenIntrinsics.inc.tmp : Intrinsics%.td $(ObjDir)/.dir
1498 $(Echo) "Building $(<F) calling convention information with tblgen"
1499 $(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1500
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001501clean-local::
1502 -$(Verb) $(RM) -f $(INCFiles)
1503
Mikhail Glushenkov72145e32009-03-02 09:42:59 +00001504endif # TARGET
1505
1506ifdef LLVMC_BUILD_AUTOGENERATED_INC
1507
Mikhail Glushenkov3b335a42009-04-21 19:46:10 +00001508LLVMCPluginSrc := $(sort $(strip $(wildcard $(PROJ_SRC_DIR)/*.td)) \
1509 $(strip $(wildcard $(PROJ_OBJ_DIR)/*.td)))
Mikhail Glushenkov72145e32009-03-02 09:42:59 +00001510
1511TDFiles := $(LLVMCPluginSrc) \
1512 $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
1513
1514$(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
1515 $(TBLGEN) $(TD_COMMON)
1516 $(Echo) "Building LLVMC configuration library with tblgen"
1517 $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
1518
1519endif # LLVMC_BUILD_AUTOGENERATED_INC
1520
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001521###############################################################################
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001522# OTHER RULES: Other rules needed
1523###############################################################################
1524
1525# To create postscript files from dot files...
1526ifneq ($(DOT),false)
1527%.ps: %.dot
1528 $(DOT) -Tps < $< > $@
1529else
1530%.ps: %.dot
1531 $(Echo) "Cannot build $@: The program dot is not installed"
1532endif
1533
1534# This rules ensures that header files that are removed still have a rule for
1535# which they can be "generated." This allows make to ignore them and
1536# reproduce the dependency lists.
1537%.h:: ;
1538%.hpp:: ;
1539
1540# Define clean-local to clean the current directory. Note that this uses a
Misha Brukman89fe5162009-01-08 02:11:55 +00001541# very conservative approach ensuring that empty variables do not cause
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001542# errors or disastrous removal.
1543clean-local::
Jim Grosbache4c032e2008-10-02 22:56:44 +00001544ifneq ($(strip $(ObjRootDir)),)
1545 -$(Verb) $(RM) -rf $(ObjRootDir)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001546endif
1547 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1548ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1549 -$(Verb) $(RM) -f *$(SHLIBEXT)
1550endif
1551
1552clean-all-local::
1553 -$(Verb) $(RM) -rf Debug Release Profile
1554
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001555
1556###############################################################################
1557# DEPENDENCIES: Include the dependency files if we should
1558###############################################################################
1559ifndef DISABLE_AUTO_DEPENDENCIES
1560
1561# If its not one of the cleaning targets
Daniel Dunbara89194e2008-10-03 19:11:19 +00001562ifndef IS_CLEANING_TARGET
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001563
1564# Get the list of dependency files
Daniel Dunbar285108f2009-05-12 06:35:50 +00001565DependSourceFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1566DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1567
1568# Include bitcode dependency files if using bitcode libraries
1569ifdef BYTECODE_LIBRARY
1570DependFiles += $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
1571endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001572
Reid Spencerdfb3d5b2007-07-23 08:20:46 +00001573-include $(DependFiles) ""
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001574
1575endif
1576
Misha Brukman89fe5162009-01-08 02:11:55 +00001577endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001578
1579###############################################################################
1580# CHECK: Running the test suite
1581###############################################################################
1582
Bill Wendlingea4af672009-04-09 18:26:57 +00001583check::
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001584 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1585 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1586 $(EchoCmd) Running test suite ; \
1587 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1588 TESTSUITE=$(TESTSUITE) ; \
1589 else \
1590 $(EchoCmd) No Makefile in test directory ; \
1591 fi ; \
1592 else \
1593 $(EchoCmd) No test directory ; \
1594 fi
1595
Daniel Dunbar12ffa4d2009-09-08 05:31:44 +00001596check-lit::
1597 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1598 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1599 $(EchoCmd) Running test suite ; \
1600 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-lit ; \
1601 else \
1602 $(EchoCmd) No Makefile in test directory ; \
1603 fi ; \
1604 else \
1605 $(EchoCmd) No test directory ; \
1606 fi
1607
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001608###############################################################################
Bill Wendling2e3646a2009-01-04 23:12:21 +00001609# UNITTESTS: Running the unittests test suite
1610###############################################################################
1611
Bill Wendlingea4af672009-04-09 18:26:57 +00001612unittests::
Bill Wendling2e3646a2009-01-04 23:12:21 +00001613 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1614 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1615 $(EchoCmd) Running unittests test suite ; \
1616 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests ; \
1617 else \
1618 $(EchoCmd) No Makefile in unittests directory ; \
1619 fi ; \
1620 else \
1621 $(EchoCmd) No unittests directory ; \
1622 fi
1623
1624###############################################################################
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001625# DISTRIBUTION: Handle construction of a distribution tarball
1626###############################################################################
1627
1628#------------------------------------------------------------------------
1629# Define distribution related variables
1630#------------------------------------------------------------------------
1631DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1632DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1633TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1634DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1635DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1636DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1637DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1638 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1639 Makefile.config.in configure autoconf
1640DistOther := $(notdir $(wildcard \
1641 $(PROJ_SRC_DIR)/*.h \
1642 $(PROJ_SRC_DIR)/*.td \
1643 $(PROJ_SRC_DIR)/*.def \
1644 $(PROJ_SRC_DIR)/*.ll \
1645 $(PROJ_SRC_DIR)/*.in))
1646DistSubDirs := $(SubDirs)
1647DistSources = $(Sources) $(EXTRA_DIST)
1648DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1649
1650#------------------------------------------------------------------------
1651# We MUST build distribution with OBJ_DIR != SRC_DIR
1652#------------------------------------------------------------------------
1653ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1654dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1655 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1656
1657else
1658
1659#------------------------------------------------------------------------
1660# Prevent attempt to run dist targets from anywhere but the top level
1661#------------------------------------------------------------------------
1662ifneq ($(LEVEL),.)
1663dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1664 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1665else
1666
1667#------------------------------------------------------------------------
1668# Provide the top level targets
1669#------------------------------------------------------------------------
1670
1671dist-gzip:: $(DistTarGZip)
1672
1673$(DistTarGZip) : $(TopDistDir)/.makedistdir
1674 $(Echo) Packing gzipped distribution tar file.
1675 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1676 $(GZIP) -c > "$(DistTarGZip)"
1677
1678dist-bzip2:: $(DistTarBZ2)
1679
1680$(DistTarBZ2) : $(TopDistDir)/.makedistdir
1681 $(Echo) Packing bzipped distribution tar file.
1682 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1683 $(BZIP2) -c >$(DistTarBZ2)
1684
1685dist-zip:: $(DistZip)
1686
1687$(DistZip) : $(TopDistDir)/.makedistdir
1688 $(Echo) Packing zipped distribution file.
1689 $(Verb) rm -f $(DistZip)
1690 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1691
Misha Brukman89fe5162009-01-08 02:11:55 +00001692dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001693 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1694
1695DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1696
1697dist-check:: $(DistTarGZip)
1698 $(Echo) Checking distribution tar file.
1699 $(Verb) if test -d $(DistCheckDir) ; then \
1700 $(RM) -rf $(DistCheckDir) ; \
1701 fi
1702 $(Verb) $(MKDIR) $(DistCheckDir)
1703 $(Verb) cd $(DistCheckDir) && \
1704 $(MKDIR) $(DistCheckDir)/build && \
1705 $(MKDIR) $(DistCheckDir)/install && \
1706 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1707 cd build && \
1708 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1709 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1710 $(MAKE) all && \
1711 $(MAKE) check && \
Bill Wendling2e3646a2009-01-04 23:12:21 +00001712 $(MAKE) unittests && \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001713 $(MAKE) install && \
1714 $(MAKE) uninstall && \
1715 $(MAKE) dist-clean && \
1716 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1717
1718dist-clean::
1719 $(Echo) Cleaning distribution files
1720 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1721 $(DistCheckDir)
1722
1723endif
1724
1725#------------------------------------------------------------------------
1726# Provide the recursive distdir target for building the distribution directory
1727#------------------------------------------------------------------------
1728distdir: $(DistDir)/.makedistdir
1729$(DistDir)/.makedistdir: $(DistSources)
1730 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1731 if test -d "$(DistDir)" ; then \
1732 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1733 exit 1 ; \
1734 fi ; \
1735 $(EchoCmd) Removing old $(DistDir) ; \
1736 $(RM) -rf $(DistDir); \
1737 $(EchoCmd) Making 'all' to verify build ; \
1738 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1739 fi
1740 $(Echo) Building Distribution Directory $(DistDir)
Misha Brukman89fe5162009-01-08 02:11:55 +00001741 $(Verb) $(MKDIR) $(DistDir)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001742 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1743 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1744 for file in $(DistFiles) ; do \
1745 case "$$file" in \
1746 $(PROJ_SRC_DIR)/*) \
1747 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1748 ;; \
1749 $(PROJ_SRC_ROOT)/*) \
1750 file=`echo "$$file" | \
1751 sed "s#^$$srcrootstrip/##"` \
1752 ;; \
1753 esac; \
1754 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1755 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1756 from_dir="$(PROJ_SRC_DIR)" ; \
1757 elif test -f "$$file" || test -d "$$file" ; then \
1758 from_dir=. ; \
1759 fi ; \
1760 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1761 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1762 to_dir="$(DistDir)/$$dir"; \
1763 $(MKDIR) "$$to_dir" ; \
1764 else \
1765 to_dir="$(DistDir)"; \
1766 fi; \
1767 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1768 if test -n "$$mid_dir" ; then \
1769 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1770 fi ; \
1771 if test -d "$$from_dir/$$file"; then \
1772 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1773 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1774 cd $(PROJ_SRC_DIR) ; \
1775 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1776 ( cd $$to_dir ; $(TAR) xf - ) ; \
1777 cd $(PROJ_OBJ_DIR) ; \
1778 else \
1779 cd $$from_dir ; \
1780 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1781 ( cd $$to_dir ; $(TAR) xf - ) ; \
1782 cd $(PROJ_OBJ_DIR) ; \
1783 fi; \
1784 elif test -f "$$from_dir/$$file" ; then \
1785 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1786 elif test -L "$$from_dir/$$file" ; then \
1787 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1788 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1789 $(EchoCmd) "===== WARNING: Distribution Source " \
1790 "$$from_dir/$$file Not Found!" ; \
1791 elif test "$(Verb)" != '@' ; then \
1792 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1793 fi; \
1794 done
1795 $(Verb) for subdir in $(DistSubDirs) ; do \
1796 if test "$$subdir" \!= "." ; then \
1797 new_distdir="$(DistDir)/$$subdir" ; \
1798 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1799 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1800 DistDir="$$new_distdir" distdir ) || exit 1; \
1801 fi; \
1802 done
1803 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1804 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1805 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1806 -name .svn \) -print` ;\
1807 $(MAKE) dist-hook ; \
1808 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1809 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1810 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1811 -o ! -type d ! -perm -444 -exec \
1812 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1813 || chmod -R a+r $(DistDir) ; \
1814 fi
1815
1816# This is invoked by distdir target, define it as a no-op to avoid errors if not
1817# defined by user.
1818dist-hook::
1819
1820endif
1821
1822###############################################################################
1823# TOP LEVEL - targets only to apply at the top level directory
1824###############################################################################
1825
1826ifeq ($(LEVEL),.)
1827
1828#------------------------------------------------------------------------
1829# Install support for the project's include files:
1830#------------------------------------------------------------------------
1831ifdef NO_INSTALL
1832install-local::
1833 $(Echo) Install circumvented with NO_INSTALL
1834uninstall-local::
1835 $(Echo) Uninstall circumvented with NO_INSTALL
1836else
1837install-local::
1838 $(Echo) Installing include files
1839 $(Verb) $(MKDIR) $(PROJ_includedir)
1840 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1841 cd $(PROJ_SRC_ROOT)/include && \
Chris Lattnerbfaed4c2009-01-02 07:16:45 +00001842 for hdr in `find . -type f '!' '(' -name '*~' \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001843 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
1844 grep -v .svn` ; do \
1845 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1846 if test \! -d "$$instdir" ; then \
1847 $(EchoCmd) Making install directory $$instdir ; \
1848 $(MKDIR) $$instdir ;\
1849 fi ; \
1850 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1851 done ; \
1852 fi
1853ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
1854 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1855 cd $(PROJ_OBJ_ROOT)/include && \
1856 for hdr in `find . -type f -print | grep -v CVS` ; do \
1857 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1858 done ; \
1859 fi
1860endif
1861
1862uninstall-local::
1863 $(Echo) Uninstalling include files
1864 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1865 cd $(PROJ_SRC_ROOT)/include && \
1866 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
Chris Lattnerbfaed4c2009-01-02 07:16:45 +00001867 '!' '(' -name '*~' -o -name '.#*' \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001868 -o -name '*.in' ')' -print ')' | \
1869 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
1870 cd $(PROJ_SRC_ROOT)/include && \
1871 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1872 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1873 fi
1874endif
1875endif
1876
1877check-line-length:
Gabor Greifb91ea9d2008-05-15 10:04:30 +00001878 @echo searching for overlength lines in files: $(Sources)
1879 @echo
1880 @echo
Gabor Greif3033d032008-08-28 22:32:39 +00001881 egrep -n '.{81}' $(Sources) /dev/null
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001882
1883check-for-tabs:
Gabor Greifb91ea9d2008-05-15 10:04:30 +00001884 @echo searching for tabs in files: $(Sources)
1885 @echo
1886 @echo
Gabor Greif3033d032008-08-28 22:32:39 +00001887 egrep -n ' ' $(Sources) /dev/null
Gabor Greifb91ea9d2008-05-15 10:04:30 +00001888
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001889check-footprint:
1890 @ls -l $(LibDir) | awk '\
1891 BEGIN { sum = 0; } \
1892 { sum += $$5; } \
1893 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1894 @ls -l $(ToolDir) | awk '\
1895 BEGIN { sum = 0; } \
1896 { sum += $$5; } \
1897 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1898#------------------------------------------------------------------------
1899# Print out the directories used for building
1900#------------------------------------------------------------------------
1901printvars::
1902 $(Echo) "BuildMode : " '$(BuildMode)'
1903 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1904 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1905 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1906 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1907 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1908 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1909 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1910 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1911 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1912 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
1913 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
1914 $(Echo) "UserTargets : " '$(UserTargets)'
1915 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1916 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1917 $(Echo) "ObjDir : " '$(ObjDir)'
1918 $(Echo) "LibDir : " '$(LibDir)'
1919 $(Echo) "ToolDir : " '$(ToolDir)'
1920 $(Echo) "ExmplDir : " '$(ExmplDir)'
1921 $(Echo) "Sources : " '$(Sources)'
1922 $(Echo) "TDFiles : " '$(TDFiles)'
1923 $(Echo) "INCFiles : " '$(INCFiles)'
1924 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1925 $(Echo) "PreConditions: " '$(PreConditions)'
1926 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1927 $(Echo) "Compile.C : " '$(Compile.C)'
1928 $(Echo) "Archive : " '$(Archive)'
1929 $(Echo) "YaccFiles : " '$(YaccFiles)'
1930 $(Echo) "LexFiles : " '$(LexFiles)'
1931 $(Echo) "Module : " '$(Module)'
1932 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
1933 $(Echo) "SubDirs : " '$(SubDirs)'
1934 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
1935 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
Daniel Dunbar190b3d52009-02-21 20:42:39 +00001936
1937###
1938# Debugging
1939
Daniel Dunbara6b02752009-03-06 22:23:25 +00001940# General debugging rule, use 'make dbg-print-XXX' to print the
Daniel Dunbar190b3d52009-02-21 20:42:39 +00001941# definition, value and origin of XXX.
Daniel Dunbara6b02752009-03-06 22:23:25 +00001942make-print-%:
Daniel Dunbar190b3d52009-02-21 20:42:39 +00001943 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))