blob: 6cc4bd3cf3bbe4dd7dbf3eef34d98f5cb916708d [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#--------------------------------------------------------------------
Daniel Dunbar4f1c6552009-09-13 22:39:27 +000022RecursiveTargets := all clean clean-all install uninstall install-bytecode \
23 unitcheck
Dan Gohmanf17a25c2007-07-18 16:29:46 +000024LocalTargets := all-local clean-local clean-all-local check-local \
25 install-local printvars uninstall-local \
Daniel Dunbar4f1c6552009-09-13 22:39:27 +000026 install-bytecode-local
Chris Lattner42596062007-09-26 06:10:47 +000027TopLevelTargets := check dist dist-check dist-clean dist-gzip dist-bzip2 \
Bill Wendling2e3646a2009-01-04 23:12:21 +000028 dist-zip unittests
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
30InternalTargets := preconditions distdir dist-hook
31
32################################################################################
33# INITIALIZATION: Basic things the makefile needs
34################################################################################
35
36#--------------------------------------------------------------------
37# Set the VPATH so that we can find source files.
38#--------------------------------------------------------------------
39VPATH=$(PROJ_SRC_DIR)
40
41#--------------------------------------------------------------------
42# Reset the list of suffixes we know how to build.
43#--------------------------------------------------------------------
44.SUFFIXES:
Nick Lewycky8d91e192009-02-26 07:44:16 +000045.SUFFIXES: .c .cpp .cc .h .hpp .o .a .bc .td .ps .dot .ll
Dan Gohmanf17a25c2007-07-18 16:29:46 +000046.SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
47
48#--------------------------------------------------------------------
49# Mark all of these targets as phony to avoid implicit rule search
50#--------------------------------------------------------------------
51.PHONY: $(UserTargets) $(InternalTargets)
52
53#--------------------------------------------------------------------
Misha Brukman89fe5162009-01-08 02:11:55 +000054# Make sure all the user-target rules are double colon rules and
Dan Gohmanf17a25c2007-07-18 16:29:46 +000055# they are defined first.
56#--------------------------------------------------------------------
57
58$(UserTargets)::
59
60################################################################################
61# PRECONDITIONS: that which must be built/checked first
62################################################################################
63
64SrcMakefiles := $(filter %Makefile %Makefile.tests,\
65 $(wildcard $(PROJ_SRC_DIR)/Makefile*))
66ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
67ConfigureScript := $(PROJ_SRC_ROOT)/configure
68ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
69MakefileConfigIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
70MakefileCommonIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
71MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
72MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
73PreConditions := $(ConfigStatusScript) $(ObjMakefiles)
74ifneq ($(MakefileCommonIn),)
75PreConditions += $(MakefileCommon)
76endif
77
78ifneq ($(MakefileConfigIn),)
79PreConditions += $(MakefileConfig)
80endif
81
82preconditions: $(PreConditions)
83
84#------------------------------------------------------------------------
85# Make sure the BUILT_SOURCES are built first
86#------------------------------------------------------------------------
87$(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
88
89clean-all-local::
90ifneq ($(strip $(BUILT_SOURCES)),)
91 -$(Verb) $(RM) -f $(BUILT_SOURCES)
92endif
93
94ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
95spotless:
96 $(Verb) if test -x config.status ; then \
97 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
98 $(MKDIR) .spotless.save ; \
99 $(MV) config.status .spotless.save ; \
100 $(MV) mklib .spotless.save ; \
101 $(MV) projects .spotless.save ; \
102 $(RM) -rf * ; \
103 $(MV) .spotless.save/config.status . ; \
104 $(MV) .spotless.save/mklib . ; \
105 $(MV) .spotless.save/projects . ; \
106 $(RM) -rf .spotless.save ; \
107 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
108 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
109 $(ConfigStatusScript) ; \
110 else \
111 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
112 fi
113else
114spotless:
115 $(EchoCmd) "spotless target not supported for objdir == srcdir"
116endif
117
118$(BUILT_SOURCES) : $(ObjMakefiles)
119
120#------------------------------------------------------------------------
121# Make sure we're not using a stale configuration
122#------------------------------------------------------------------------
123reconfigure:
124 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
125 $(Verb) cd $(PROJ_OBJ_ROOT) && \
126 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
127 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
128 fi ; \
129 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
130 $(ConfigStatusScript)
131
Anton Korobeynikovd26284c2009-08-14 18:53:19 +0000132# FIXME: The {PIC16,MSP430}/AsmPrinter line here is a hack to force a reconfigure to pick
Daniel Dunbare74973d2009-08-13 17:22:49 +0000133# up AsmPrinter changes. Remove it after a reasonable delay from 2009-08-13.
134
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000135.PRECIOUS: $(ConfigStatusScript)
Anton Korobeynikovd26284c2009-08-14 18:53:19 +0000136$(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 +0000137 $(Echo) Reconfiguring with $<
138 $(Verb) cd $(PROJ_OBJ_ROOT) && \
139 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
140 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
141 fi ; \
142 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
143 $(ConfigStatusScript)
144
145#------------------------------------------------------------------------
146# Make sure the configuration makefile is up to date
147#------------------------------------------------------------------------
148ifneq ($(MakefileConfigIn),)
149$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
150 $(Echo) Regenerating $@
151 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
152endif
153
154ifneq ($(MakefileCommonIn),)
155$(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
156 $(Echo) Regenerating $@
157 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
158endif
159
160#------------------------------------------------------------------------
161# If the Makefile in the source tree has been updated, copy it over into the
162# build tree. But, only do this if the source and object makefiles differ
163#------------------------------------------------------------------------
164ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
165
Gordon Henriksen4290f662008-03-10 15:58:40 +0000166Makefile: $(PROJ_SRC_DIR)/Makefile $(ExtraMakefiles)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000167 $(Echo) "Updating Makefile"
168 $(Verb) $(MKDIR) $(@D)
169 $(Verb) $(CP) -f $< $@
170
171# Copy the Makefile.* files unless we're in the root directory which avoids
172# the copying of Makefile.config.in or other things that should be explicitly
173# taken care of.
174$(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
175 @case '$?' in \
176 *Makefile.rules) ;; \
177 *.in) ;; \
Gordon Henriksen4290f662008-03-10 15:58:40 +0000178 *) $(EchoCmd) "Updating $(@F)" ; \
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000179 $(MKDIR) $(@D) ; \
180 $(CP) -f $< $@ ;; \
181 esac
Gabor Greif14c4c8e2008-02-27 13:34:15 +0000182
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000183endif
184
185#------------------------------------------------------------------------
186# Set up the basic dependencies
187#------------------------------------------------------------------------
188$(UserTargets):: $(PreConditions)
189
190all:: all-local
Anton Korobeynikov06565172008-11-10 07:33:13 +0000191clean:: clean-local
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192clean-all:: clean-local clean-all-local
193install:: install-local
194uninstall:: uninstall-local
Misha Brukman89fe5162009-01-08 02:11:55 +0000195install-local:: all-local
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000196install-bytecode:: install-bytecode-local
197
198###############################################################################
Mikhail Glushenkov5f7ba0f2009-03-02 09:04:13 +0000199# LLVMC: Provide rules for compiling llvmc plugins
200###############################################################################
201
202ifdef LLVMC_PLUGIN
203
204LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN))
Mikhail Glushenkovd500a272009-06-23 20:46:48 +0000205CPP.Flags += -DLLVMC_PLUGIN_NAME=$(LLVMC_PLUGIN)
Mikhail Glushenkov5f7ba0f2009-03-02 09:04:13 +0000206REQUIRES_EH := 1
Mikhail Glushenkov928de572009-07-03 03:52:47 +0000207
208ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
209 LD.Flags += -lCompilerDriver
210endif
Mikhail Glushenkov5f7ba0f2009-03-02 09:04:13 +0000211
212# Build a dynamic library if the user runs `make` directly from the plugin
213# directory.
214ifndef LLVMC_BUILTIN_PLUGIN
Mikhail Glushenkov928de572009-07-03 03:52:47 +0000215 LOADABLE_MODULE = 1
Mikhail Glushenkov5f7ba0f2009-03-02 09:04:13 +0000216endif
217
218# TableGen stuff...
219ifneq ($(BUILT_SOURCES),)
Mikhail Glushenkov928de572009-07-03 03:52:47 +0000220 LLVMC_BUILD_AUTOGENERATED_INC=1
Mikhail Glushenkov5f7ba0f2009-03-02 09:04:13 +0000221endif
222
223endif # LLVMC_PLUGIN
224
Mikhail Glushenkovbe76ef22009-06-25 01:07:00 +0000225ifdef LLVMC_BASED_DRIVER
226
227TOOLNAME = $(LLVMC_BASED_DRIVER)
Mikhail Glushenkov928de572009-07-03 03:52:47 +0000228
Mikhail Glushenkovbe76ef22009-06-25 01:07:00 +0000229REQUIRES_EH := 1
Mikhail Glushenkov928de572009-07-03 03:52:47 +0000230
231ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
232 LD.Flags += -lCompilerDriver
233else
234 LLVMLIBS = CompilerDriver.a
235 LINK_COMPONENTS = support system
236endif
Mikhail Glushenkovbe76ef22009-06-25 01:07:00 +0000237
238# Preprocessor magic that generates references to static variables in built-in
239# plugins.
240ifneq ($(LLVMC_BUILTIN_PLUGINS),)
241
242USEDLIBS += $(patsubst %,plugin_llvmc_%.a,$(LLVMC_BUILTIN_PLUGINS))
243
244LLVMC_BUILTIN_PLUGIN_1 = $(word 1, $(LLVMC_BUILTIN_PLUGINS))
245LLVMC_BUILTIN_PLUGIN_2 = $(word 2, $(LLVMC_BUILTIN_PLUGINS))
246LLVMC_BUILTIN_PLUGIN_3 = $(word 3, $(LLVMC_BUILTIN_PLUGINS))
247LLVMC_BUILTIN_PLUGIN_4 = $(word 4, $(LLVMC_BUILTIN_PLUGINS))
248LLVMC_BUILTIN_PLUGIN_5 = $(word 5, $(LLVMC_BUILTIN_PLUGINS))
249
250ifneq ($(LLVMC_BUILTIN_PLUGIN_1),)
251CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_1=$(LLVMC_BUILTIN_PLUGIN_1)
252endif
253
254ifneq ($(LLVMC_BUILTIN_PLUGIN_2),)
255CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_2=$(LLVMC_BUILTIN_PLUGIN_2)
256endif
257
258ifneq ($(LLVMC_BUILTIN_PLUGIN_3),)
259CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_3=$(LLVMC_BUILTIN_PLUGIN_3)
260endif
261
262ifneq ($(LLVMC_BUILTIN_PLUGIN_4),)
263CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_4=$(LLVMC_BUILTIN_PLUGIN_4)
264endif
265
266ifneq ($(LLVMC_BUILTIN_PLUGIN_5),)
267CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_5)
268endif
269
270endif
271
272endif # LLVMC_BASED_DRIVER
273
Mikhail Glushenkov5f7ba0f2009-03-02 09:04:13 +0000274###############################################################################
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000275# VARIABLES: Set up various variables based on configuration data
276###############################################################################
277
Daniel Dunbara89194e2008-10-03 19:11:19 +0000278# Variable for if this make is for a "cleaning" target
279ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
280 IS_CLEANING_TARGET=1
281endif
282
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000283#--------------------------------------------------------------------
284# Variables derived from configuration we are building
285#--------------------------------------------------------------------
286
287CPP.Defines :=
288# OPTIMIZE_OPTION - The optimization level option we want to build LLVM with
289# this can be overridden on the make command line.
Evan Cheng107dae12009-04-20 22:16:40 +0000290ifndef OPTIMIZE_OPTION
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000291 ifneq ($(HOST_OS),MingW)
Evan Cheng107dae12009-04-20 22:16:40 +0000292 OPTIMIZE_OPTION := -O3
293 else
294 OPTIMIZE_OPTION := -O2
295 endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000296endif
297
David Greene8cd590c2009-04-17 14:49:22 +0000298ifeq ($(ENABLE_OPTIMIZED),1)
299 BuildMode := Release
300 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000301 ifneq ($(HOST_OS),FreeBSD)
302 ifneq ($(HOST_OS),Darwin)
David Greene8cd590c2009-04-17 14:49:22 +0000303 OmitFramePointer := -fomit-frame-pointer
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000304 endif
David Greene8cd590c2009-04-17 14:49:22 +0000305 endif
306
307 # Darwin requires -fstrict-aliasing to be explicitly enabled.
Evan Cheng95e92ae2009-04-20 22:49:59 +0000308 # Avoid -fstrict-aliasing on Darwin for now, there are unresolved issues
309 # with -fstrict-aliasing and ipa-type-escape radr://6756684
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000310 #ifeq ($(HOST_OS),Darwin)
Evan Cheng107dae12009-04-20 22:16:40 +0000311 # EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
312 #endif
David Greene8cd590c2009-04-17 14:49:22 +0000313 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
314 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
315 LD.Flags += $(OPTIMIZE_OPTION)
316else
317 BuildMode := Debug
318 CXX.Flags += -g
319 C.Flags += -g
320 LD.Flags += -g
321 KEEP_SYMBOLS := 1
322endif
323
324ifeq ($(ENABLE_PROFILING),1)
325 BuildMode := $(BuildMode)+Profile
326 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
327 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
328 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg -g
329 KEEP_SYMBOLS := 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000330endif
331
Daniel Dunbar886e1832008-09-02 17:35:16 +0000332#ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
333# CXX.Flags += -fvisibility-inlines-hidden
334#endif
335
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000336# IF REQUIRES_EH=1 is specified then don't disable exceptions
337ifndef REQUIRES_EH
338 CXX.Flags += -fno-exceptions
339endif
340
Nicolas Geoffray0820ccc2009-08-19 22:04:44 +0000341ifdef REQUIRES_FRAME_POINTER
342 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags))
343 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags))
344 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags))
345endif
346
Daniel Dunbard11bf272009-09-11 15:47:24 +0000347# If REQUIRES_RTTI=1 is specified then don't disable run-time type id.
348ifeq ($(REQUIRES_RTTI), 1)
Daniel Dunbar79857172009-09-11 15:45:13 +0000349 CXX.Flags := $(filter-out -fno-rtti,$(CXX.Flags))
350 CXXFLAGS := $(filter-out -fno-rtti,$(CXXFLAGS))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000351endif
352
Daniel Dunbar3fd1aa72009-03-13 20:59:41 +0000353ifdef ENABLE_COVERAGE
354 BuildMode := $(BuildMode)+Coverage
Chris Lattner20cba1c2009-06-16 23:00:42 +0000355 CXX.Flags += -ftest-coverage -fprofile-arcs
356 C.Flags += -ftest-coverage -fprofile-arcs
Daniel Dunbar3fd1aa72009-03-13 20:59:41 +0000357endif
358
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000359# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
360# then disable assertions by defining the appropriate preprocessor symbols.
361ifdef DISABLE_ASSERTIONS
Duncan Sands86a7a222009-03-27 11:35:00 +0000362 # Indicate that assertions are turned off using a minus sign
363 BuildMode := $(BuildMode)-Asserts
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000364 CPP.Defines += -DNDEBUG
365else
366 CPP.Defines += -D_DEBUG
367endif
368
Misha Brukman89fe5162009-01-08 02:11:55 +0000369# If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
370# configured), then enable expensive checks by defining the
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000371# appropriate preprocessor symbols.
372ifdef ENABLE_EXPENSIVE_CHECKS
373 BuildMode := $(BuildMode)+Checks
Duncan Sands871e55f2008-12-09 21:33:20 +0000374 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000375endif
376
Nick Lewycky8d91e192009-02-26 07:44:16 +0000377# LOADABLE_MODULE implies several other things so we force them to be
378# defined/on.
379ifdef LOADABLE_MODULE
380 SHARED_LIBRARY := 1
Nick Lewycky8d91e192009-02-26 07:44:16 +0000381 LINK_LIBS_IN_SHARED := 1
382endif
383
384ifdef SHARED_LIBRARY
385 ENABLE_PIC := 1
386 PIC_FLAG = "(PIC)"
387endif
388
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000389ifeq ($(ENABLE_PIC),1)
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000390 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
Nick Lewycky5b882f22009-02-21 08:41:09 +0000391 # Nothing. Win32 defaults to PIC and warns when given -fPIC
392 else
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000393 ifeq ($(HOST_OS),Darwin)
Nick Lewycky8d91e192009-02-26 07:44:16 +0000394 # Common symbols not allowed in dylib files
Nick Lewycky5b882f22009-02-21 08:41:09 +0000395 CXX.Flags += -fno-common
396 C.Flags += -fno-common
397 else
398 # Linux and others; pass -fPIC
399 CXX.Flags += -fPIC
400 C.Flags += -fPIC
401 endif
402 endif
Mike Stump8efa3542009-05-08 23:08:58 +0000403else
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000404 ifeq ($(HOST_OS),Darwin)
Mike Stump8efa3542009-05-08 23:08:58 +0000405 CXX.Flags += -mdynamic-no-pic
406 C.Flags += -mdynamic-no-pic
407 endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000408endif
409
Eric Christopher06bf4822009-08-18 03:23:40 +0000410CXX.Flags += -Woverloaded-virtual
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000411CPP.BaseFlags += $(CPP.Defines)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000412AR.Flags := cru
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000413
414# Make Floating point IEEE compliant on Alpha.
415ifeq ($(ARCH),Alpha)
416 CXX.Flags += -mieee
417 CPP.BaseFlags += -mieee
418ifeq ($(ENABLE_PIC),0)
419 CXX.Flags += -fPIC
420 CPP.BaseFlags += -fPIC
421endif
422endif
423
424ifeq ($(ARCH),Alpha)
425 LD.Flags += -Wl,--no-relax
426endif
427
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000428ifeq ($(HOST_OS),MingW)
Anton Korobeynikov025ddd42009-05-04 10:25:30 +0000429 ifeq ($(LLVM_CROSS_COMPILING),1)
430 # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
431 ifdef TOOLNAME
432 LD.Flags += -Wl,--allow-multiple-definition
433 endif
434 endif
435endif
436
Jay Foad188e6472009-05-15 18:13:31 +0000437ifdef ENABLE_EXPENSIVE_CHECKS
438 # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above.
439 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160
440 CXX.Flags := $(filter-out -fno-rtti,$(CXX.Flags))
Daniel Dunbar3b8513d2009-09-03 08:41:19 +0000441 CXXFLAGS := $(filter-out -fno-rtti,$(CXXFLAGS))
Jay Foad188e6472009-05-15 18:13:31 +0000442endif
443
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000444#--------------------------------------------------------------------
445# Directory locations
446#--------------------------------------------------------------------
Jim Grosbache4c032e2008-10-02 22:56:44 +0000447TargetMode :=
448ifeq ($(LLVM_CROSS_COMPILING),1)
Anton Korobeynikov06565172008-11-10 07:33:13 +0000449 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
Jim Grosbache4c032e2008-10-02 22:56:44 +0000450endif
451
452ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
Anton Korobeynikov06565172008-11-10 07:33:13 +0000453ObjDir := $(ObjRootDir)
454LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
455ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
456ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
457LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
458LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
459LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000460CFERuntimeLibDir := $(LLVMGCCDIR)/lib
461
462#--------------------------------------------------------------------
463# Full Paths To Compiled Tools and Utilities
464#--------------------------------------------------------------------
465EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
466Echo = @$(EchoCmd)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000467ifndef LLVMAS
468LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
469endif
470ifndef TBLGEN
471 ifeq ($(LLVM_CROSS_COMPILING),1)
Anton Korobeynikov06565172008-11-10 07:33:13 +0000472 TBLGEN := $(BuildLLVMToolDir)/tblgen$(BUILD_EXEEXT)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000473 else
474 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
475 endif
476endif
Misha Brukman89fe5162009-01-08 02:11:55 +0000477LLVM_CONFIG := $(LLVMToolDir)/llvm-config
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000478ifndef LLVMLD
479LLVMLD := $(LLVMToolDir)/llvm-ld$(EXEEXT)
480endif
481ifndef LLVMDIS
482LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
483endif
484ifndef LLI
485LLI := $(LLVMToolDir)/lli$(EXEEXT)
486endif
487ifndef LLC
488LLC := $(LLVMToolDir)/llc$(EXEEXT)
489endif
490ifndef LOPT
491LOPT := $(LLVMToolDir)/opt$(EXEEXT)
492endif
493ifndef LBUGPOINT
494LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
495endif
496ifndef LUPGRADE
497LUPGRADE := $(LLVMToolDir)/llvm-upgrade$(EXEEXT)
498endif
499ifeq ($(LLVMGCC_MAJVERS),3)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000500LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
501LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
502else
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000503LLVMGCCWITHPATH := $(LLVMGCC)
504LLVMGXXWITHPATH := $(LLVMGXX)
505endif
506
507#--------------------------------------------------------------------
508# Adjust to user's request
509#--------------------------------------------------------------------
510
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000511ifeq ($(HOST_OS),Darwin)
Scott Michelf9c9d7e2009-03-12 21:03:53 +0000512 DARWIN_VERSION := `sw_vers -productVersion`
513 # Strip a number like 10.4.7 to 10.4
514 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
515 # Get "4" out of 10.4 for later pieces in the makefile.
516 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
Bill Wendling3c0d23b2009-03-22 08:28:45 +0000517
Julien Lerouge64e1db82009-03-27 18:18:00 +0000518 SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress \
Evan Chenge951aca2009-09-08 18:52:20 +0000519 -dynamiclib
520 ifneq ($(ARCH),ARM)
521 SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
522 endif
Scott Michelf9c9d7e2009-03-12 21:03:53 +0000523else
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000524 ifeq ($(HOST_OS),Cygwin)
Scott Michelf9c9d7e2009-03-12 21:03:53 +0000525 SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
Mikhail Glushenkov928de572009-07-03 03:52:47 +0000526 -Wl,--enable-auto-import -Wl,--enable-auto-image-base
Scott Michelf9c9d7e2009-03-12 21:03:53 +0000527 else
528 SharedLinkOptions=-shared
529 endif
530endif
531
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000532ifeq ($(TARGET_OS),Darwin)
Evan Chenge951aca2009-09-08 18:52:20 +0000533 ifneq ($(ARCH),ARM)
534 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
535 endif
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000536endif
537
Nick Lewycky8d91e192009-02-26 07:44:16 +0000538# Adjust LD.Flags depending on the kind of library that is to be built. Note
539# that if LOADABLE_MODULE is specified then the resulting shared library can
540# be opened with dlopen.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000541ifdef LOADABLE_MODULE
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000542 LD.Flags += -module
543endif
544
545ifdef SHARED_LIBRARY
Scott Michelf9c9d7e2009-03-12 21:03:53 +0000546ifneq ($(DARWIN_MAJVERS),4)
Nick Lewycky12015c12009-03-03 04:55:15 +0000547 LD.Flags += $(RPATH) -Wl,$(LibDir)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000548endif
Scott Michelf9c9d7e2009-03-12 21:03:53 +0000549endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000550
551ifdef TOOL_VERBOSE
552 C.Flags += -v
553 CXX.Flags += -v
554 LD.Flags += -v
555 VERBOSE := 1
556endif
557
558# Adjust settings for verbose mode
559ifndef VERBOSE
560 Verb := @
Reid Spencerdfb3d5b2007-07-23 08:20:46 +0000561 AR.Flags += >/dev/null 2>/dev/null
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000562 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
563else
Misha Brukman89fe5162009-01-08 02:11:55 +0000564 ConfigureScriptFLAGS :=
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000565endif
566
567# By default, strip symbol information from executable
568ifndef KEEP_SYMBOLS
569 Strip := $(PLATFORMSTRIPOPTS)
570 StripWarnMsg := "(without symbols)"
571 Install.StripFlag += -s
572endif
573
574# Adjust linker flags for building an executable
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000575ifneq ($(HOST_OS),Darwin)
Scott Michelf9c9d7e2009-03-12 21:03:53 +0000576ifneq ($(DARWIN_MAJVERS),4)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000577ifdef TOOLNAME
578ifdef EXAMPLE_TOOL
Nick Lewyckyaca7e1c2009-03-07 22:17:05 +0000579 LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000580else
Nick Lewyckyaca7e1c2009-03-07 22:17:05 +0000581 LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000582endif
583endif
Nick Lewycky8d91e192009-02-26 07:44:16 +0000584endif
Nick Lewycky8d91e192009-02-26 07:44:16 +0000585endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586
587#----------------------------------------------------------
588# Options To Invoke Tools
589#----------------------------------------------------------
590
Daniel Dunbarb47afd52009-05-12 07:26:49 +0000591ifndef NO_PEDANTIC
Duncan Sands7d9ea942009-06-19 12:40:30 +0000592CompileCommonOpts += -pedantic -Wno-long-long
Daniel Dunbarb47afd52009-05-12 07:26:49 +0000593endif
Duncan Sands7d9ea942009-06-19 12:40:30 +0000594CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
595 $(EXTRA_OPTIONS)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000596
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000597ifeq ($(HOST_OS),HP-UX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000598 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
599endif
600
601# If we are building a universal binary on Mac OS/X, pass extra options. This
602# is useful to people that want to link the LLVM libraries into their universal
603# apps.
604#
605# The following can be optionally specified:
606# UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
607# For Mac OS/X 10.4 Intel machines, the traditional one is:
608# UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
609# UNIVERSAL_ARCH can be optionally specified to be a list of architectures
610# to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
611# i386/ppc only.
612ifdef UNIVERSAL
613 ifndef UNIVERSAL_ARCH
614 UNIVERSAL_ARCH := i386 ppc
615 endif
616 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
617 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000618 ifdef UNIVERSAL_SDK_PATH
619 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000620 endif
621
622 # Building universal cannot compute dependencies automatically.
623 DISABLE_AUTO_DEPENDENCIES=1
Evan Chengd6ad5ff2009-03-09 18:28:37 +0000624else
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000625 ifeq ($(TARGET_OS),Darwin)
Bill Wendling025cce52009-03-12 04:10:09 +0000626 ifeq ($(ARCH),x86_64)
Evan Chengd1f1fc12009-03-23 03:45:56 +0000627 TargetCommonOpts = -m64
Bill Wendling025cce52009-03-12 04:10:09 +0000628 else
629 ifeq ($(ARCH),x86)
Evan Chengd1f1fc12009-03-23 03:45:56 +0000630 TargetCommonOpts = -m32
Bill Wendling025cce52009-03-12 04:10:09 +0000631 endif
Evan Chengd6ad5ff2009-03-09 18:28:37 +0000632 endif
633 endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000634endif
635
Anton Korobeynikov92c51812009-08-18 00:40:33 +0000636ifeq ($(HOST_OS),SunOS)
Chris Lattner35c997c2008-06-24 17:44:42 +0000637CPP.BaseFlags += -include llvm/System/Solaris.h
638endif
639
Misha Brukman89fe5162009-01-08 02:11:55 +0000640LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
Dan Gohman5a5e6e92008-10-17 01:33:43 +0000641CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000642# All -I flags should go here, so that they don't confuse llvm-config.
Duncan Sands3b960292008-01-28 17:38:30 +0000643CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
644 $(patsubst %,-I%/include,\
Chris Lattner6ee48752008-01-28 04:18:41 +0000645 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
646 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
647 $(CPP.BaseFlags)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000648
Daniel Dunbar3fd1aa72009-03-13 20:59:41 +0000649ifeq ($(BUILD_COMPONENT), 1)
Eric Christopher06bf4822009-08-18 03:23:40 +0000650 Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000651 $(TargetCommonOpts) $(CompileCommonOpts) -c
Eric Christopher06bf4822009-08-18 03:23:40 +0000652 Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
653 $(CPPFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000654 $(TargetCommonOpts) $(CompileCommonOpts) -c
Eric Christopher06bf4822009-08-18 03:23:40 +0000655 Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CPPFLAGS) $(TargetCommonOpts) \
Chris Lattner20cba1c2009-06-16 23:00:42 +0000656 $(CompileCommonOpts) $(CXX.Flags) -E
Eric Christopherd631dfc2009-08-18 18:07:35 +0000657 Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
658 $(LDFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000659 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
Jim Grosbache4c032e2008-10-02 22:56:44 +0000660else
Eric Christopher06bf4822009-08-18 03:23:40 +0000661 Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000662 $(TargetCommonOpts) $(CompileCommonOpts) -c
Eric Christopher06bf4822009-08-18 03:23:40 +0000663 Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000664 $(TargetCommonOpts) $(CompileCommonOpts) -c
Eric Christopher06bf4822009-08-18 03:23:40 +0000665 Preprocess.CXX= $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
Chris Lattner20cba1c2009-06-16 23:00:42 +0000666 $(CompileCommonOpts) $(CXX.Flags) -E
Eric Christopherd631dfc2009-08-18 18:07:35 +0000667 Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(LDFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000668 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
Jim Grosbache4c032e2008-10-02 22:56:44 +0000669endif
670
Eric Christopher06bf4822009-08-18 03:23:40 +0000671BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) $(CFLAGS) \
672 $(CPPFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000673 $(TargetCommonOpts) $(CompileCommonOpts)
Eric Christopher06bf4822009-08-18 03:23:40 +0000674Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000675 $(TargetCommonOpts) $(CompileCommonOpts) -E
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676
Eric Christopher06bf4822009-08-18 03:23:40 +0000677BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
678 $(CPPFLAGS) \
Evan Chengd1f1fc12009-03-23 03:45:56 +0000679 $(TargetCommonOpts) $(CompileCommonOpts)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000680
Misha Brukman89fe5162009-01-08 02:11:55 +0000681ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
682ScriptInstall = $(INSTALL) -m 0755
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000683DataInstall = $(INSTALL) -m 0644
Chris Lattner1b0a3a12008-01-15 23:27:40 +0000684
685# When compiling under Mingw/Cygwin, the tblgen tool expects Windows
686# paths. In this case, the SYSPATH function (defined in
687# Makefile.config) transforms Unix paths into Windows paths.
688TableGen = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
Mikhail Glushenkov3e6bf9a2009-01-09 16:31:01 +0000689 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
Chris Lattner1b0a3a12008-01-15 23:27:40 +0000690 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
691 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
692
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000693Archive = $(AR) $(AR.Flags)
694LArchive = $(LLVMToolDir)/llvm-ar rcsf
695ifdef RANLIB
696Ranlib = $(RANLIB)
697else
698Ranlib = ranlib
699endif
700
701#----------------------------------------------------------
Misha Brukman89fe5162009-01-08 02:11:55 +0000702# Get the list of source files and compute object file
703# names from them.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000704#----------------------------------------------------------
705
706ifndef SOURCES
707 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
Chris Lattnerbfaed4c2009-01-02 07:16:45 +0000708 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000709else
710 Sources := $(SOURCES)
Misha Brukman89fe5162009-01-08 02:11:55 +0000711endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000712
713ifdef BUILT_SOURCES
Chris Lattnerbfaed4c2009-01-02 07:16:45 +0000714Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000715endif
716
717BaseNameSources := $(sort $(basename $(Sources)))
718
719ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000720ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
721
722###############################################################################
723# DIRECTORIES: Handle recursive descent of directory structure
724###############################################################################
725
726#---------------------------------------------------------
727# Provide rules to make install dirs. This must be early
728# in the file so they get built before dependencies
729#---------------------------------------------------------
730
Mike Stump98f72e02009-02-12 23:45:11 +0000731$(PROJ_bindir) $(PROJ_libdir) $(PROJ_includedir) $(PROJ_etcdir)::
Mike Stumpf0feefd2009-01-22 03:24:22 +0000732 $(Verb) $(MKDIR) $@
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000733
734# To create other directories, as needed, and timestamp their creation
735%/.dir:
736 $(Verb) $(MKDIR) $* > /dev/null
737 $(Verb) $(DATE) > $@
738
739.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
740.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
741
742#---------------------------------------------------------
743# Handle the DIRS options for sequential construction
744#---------------------------------------------------------
745
Misha Brukman89fe5162009-01-08 02:11:55 +0000746SubDirs :=
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000747ifdef DIRS
748SubDirs += $(DIRS)
749
750ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
751$(RecursiveTargets)::
752 $(Verb) for dir in $(DIRS); do \
753 if [ ! -f $$dir/Makefile ]; then \
754 $(MKDIR) $$dir; \
755 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
756 fi; \
757 ($(MAKE) -C $$dir $@ ) || exit 1; \
758 done
759else
760$(RecursiveTargets)::
761 $(Verb) for dir in $(DIRS); do \
762 ($(MAKE) -C $$dir $@ ) || exit 1; \
763 done
764endif
765
766endif
767
768#---------------------------------------------------------
769# Handle the EXPERIMENTAL_DIRS options ensuring success
770# after each directory is built.
771#---------------------------------------------------------
772ifdef EXPERIMENTAL_DIRS
773$(RecursiveTargets)::
774 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
775 if [ ! -f $$dir/Makefile ]; then \
776 $(MKDIR) $$dir; \
777 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
778 fi; \
779 ($(MAKE) -C $$dir $@ ) || exit 0; \
780 done
781endif
782
783#-----------------------------------------------------------
Mike Stump0fec3192009-01-24 00:00:41 +0000784# Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
785#-----------------------------------------------------------
786ifdef OPTIONAL_PARALLEL_DIRS
787 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
788endif
789
790#-----------------------------------------------------------
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791# Handle the PARALLEL_DIRS options for parallel construction
792#-----------------------------------------------------------
793ifdef PARALLEL_DIRS
794
795SubDirs += $(PARALLEL_DIRS)
796
797# Unfortunately, this list must be maintained if new recursive targets are added
798all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
799clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
800clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
801install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
802uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
803install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Daniel Dunbar4f1c6552009-09-13 22:39:27 +0000804unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000805
806ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
807
808$(ParallelTargets) :
809 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
810 $(MKDIR) $(@D); \
811 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
812 fi; \
813 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
814endif
815
816#---------------------------------------------------------
817# Handle the OPTIONAL_DIRS options for directores that may
818# or may not exist.
819#---------------------------------------------------------
820ifdef OPTIONAL_DIRS
821
822SubDirs += $(OPTIONAL_DIRS)
823
824ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
825$(RecursiveTargets)::
826 $(Verb) for dir in $(OPTIONAL_DIRS); do \
827 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
828 if [ ! -f $$dir/Makefile ]; then \
829 $(MKDIR) $$dir; \
830 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
831 fi; \
832 ($(MAKE) -C$$dir $@ ) || exit 1; \
833 fi \
834 done
835else
836$(RecursiveTargets)::
837 $(Verb) for dir in $(OPTIONAL_DIRS); do \
838 ($(MAKE) -C$$dir $@ ) || exit 1; \
839 done
840endif
841endif
842
843#---------------------------------------------------------
844# Handle the CONFIG_FILES options
845#---------------------------------------------------------
846ifdef CONFIG_FILES
847
848ifdef NO_INSTALL
849install-local::
850 $(Echo) Install circumvented with NO_INSTALL
851uninstall-local::
852 $(Echo) UnInstall circumvented with NO_INSTALL
853else
854install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
855 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
856 $(Verb)for file in $(CONFIG_FILES); do \
857 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
858 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
859 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
860 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
861 else \
862 $(ECHO) Error: cannot find config file $${file}. ; \
863 fi \
864 done
865
866uninstall-local::
867 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
868 $(Verb)for file in $(CONFIG_FILES); do \
869 $(RM) -f $(PROJ_etcdir)/$${file} ; \
870 done
871endif
872
873endif
874
875###############################################################################
876# Set up variables for building libararies
877###############################################################################
878
879#---------------------------------------------------------
880# Define various command line options pertaining to the
Misha Brukman89fe5162009-01-08 02:11:55 +0000881# libraries needed when linking. There are "Proj" libs
882# (defined by the user's project) and "LLVM" libs (defined
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000883# by the LLVM project).
884#---------------------------------------------------------
885
886ifdef USEDLIBS
887ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
888ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
889ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
890ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
891endif
892
893ifdef LLVMLIBS
894LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
895LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
896LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
897LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
898endif
899
Daniel Dunbara89194e2008-10-03 19:11:19 +0000900ifndef IS_CLEANING_TARGET
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000901ifdef LINK_COMPONENTS
902
903# If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
904# clean in tools, then do a make in tools (instead of at the top level).
905$(LLVM_CONFIG):
906 @echo "*** llvm-config doesn't exist - rebuilding it."
907 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
Gabor Greif14c4c8e2008-02-27 13:34:15 +0000908
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909$(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
910
Mikhail Glushenkovfc320822009-03-03 10:03:27 +0000911LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
912LLVMLibsPaths += $(LLVM_CONFIG) \
Misha Brukmanfc6ae992009-08-17 15:31:24 +0000913 $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000914endif
915endif
916
917###############################################################################
918# Library Build Rules: Four ways to build a library
919###############################################################################
920
921#---------------------------------------------------------
922# Bytecode Module Targets:
923# If the user set MODULE_NAME then they want to build a
924# bytecode module from the sources. We compile all the
925# sources and link it together into a single bytecode
926# module.
927#---------------------------------------------------------
928
929ifdef MODULE_NAME
930ifeq ($(strip $(LLVMGCC)),)
931$(warning Modules require llvm-gcc but no llvm-gcc is available ****)
932else
933
934Module := $(LibDir)/$(MODULE_NAME).bc
Andrew Lenharthd0020772008-02-25 22:41:55 +0000935LinkModule := $(LLVMLD) -L$(CFERuntimeLibDir) -r
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000936
937
938ifdef EXPORTED_SYMBOL_FILE
939LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
940endif
941
942$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
943 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
944 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
945
946all-local:: $(Module)
947
948clean-local::
949ifneq ($(strip $(Module)),)
950 -$(Verb) $(RM) -f $(Module)
951endif
952
953ifdef BYTECODE_DESTINATION
954ModuleDestDir := $(BYTECODE_DESTINATION)
955else
956ModuleDestDir := $(PROJ_libdir)
957endif
958
959ifdef NO_INSTALL
960install-local::
961 $(Echo) Install circumvented with NO_INSTALL
962uninstall-local::
963 $(Echo) Uninstall circumvented with NO_INSTALL
964else
965DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
966
967install-module:: $(DestModule)
968install-local:: $(DestModule)
969
Misha Brukman89fe5162009-01-08 02:11:55 +0000970$(DestModule): $(ModuleDestDir) $(Module)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
972 $(Verb) $(DataInstall) $(Module) $(DestModule)
973
974uninstall-local::
975 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
976 -$(Verb) $(RM) -f $(DestModule)
977endif
978
979endif
980endif
981
982# if we're building a library ...
983ifdef LIBRARYNAME
984
Misha Brukmanfc6ae992009-08-17 15:31:24 +0000985# Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986LIBRARYNAME := $(strip $(LIBRARYNAME))
987ifdef LOADABLE_MODULE
Nick Lewycky8d91e192009-02-26 07:44:16 +0000988LibName.A := $(LibDir)/$(LIBRARYNAME).a
989LibName.SO := $(LibDir)/$(LIBRARYNAME)$(SHLIBEXT)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990else
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000991LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
Nick Lewycky8d91e192009-02-26 07:44:16 +0000992LibName.SO := $(LibDir)/lib$(LIBRARYNAME)$(SHLIBEXT)
993endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994LibName.O := $(LibDir)/$(LIBRARYNAME).o
995LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
996
997#---------------------------------------------------------
998# Shared Library Targets:
999# If the user asked for a shared library to be built
1000# with the SHARED_LIBRARY variable, then we provide
1001# targets for building them.
1002#---------------------------------------------------------
1003ifdef SHARED_LIBRARY
1004
Nick Lewycky8d91e192009-02-26 07:44:16 +00001005all-local:: $(LibName.SO)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006
1007ifdef LINK_LIBS_IN_SHARED
1008ifdef LOADABLE_MODULE
1009SharedLibKindMessage := "Loadable Module"
1010else
1011SharedLibKindMessage := "Shared Library"
1012endif
Nick Lewycky8d91e192009-02-26 07:44:16 +00001013$(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(LibDir)/.dir
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1015 $(LIBRARYNAME)$(SHLIBEXT)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001016 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
Edwin Töröke59edce2009-05-26 19:11:47 +00001017 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018else
Nick Lewycky8d91e192009-02-26 07:44:16 +00001019$(LibName.SO): $(ObjectsO) $(LibDir)/.dir
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001020 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001021 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022endif
1023
1024clean-local::
Nick Lewycky8d91e192009-02-26 07:44:16 +00001025ifneq ($(strip $(LibName.SO)),)
1026 -$(Verb) $(RM) -f $(LibName.SO)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001027endif
1028
1029ifdef NO_INSTALL
1030install-local::
1031 $(Echo) Install circumvented with NO_INSTALL
1032uninstall-local::
1033 $(Echo) Uninstall circumvented with NO_INSTALL
1034else
1035DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
1036
1037install-local:: $(DestSharedLib)
1038
Nick Lewycky8d91e192009-02-26 07:44:16 +00001039$(DestSharedLib): $(LibName.SO) $(PROJ_libdir)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001041 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001042
Misha Brukman89fe5162009-01-08 02:11:55 +00001043uninstall-local::
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
1045 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
1046endif
1047endif
1048
1049#---------------------------------------------------------
1050# Bytecode Library Targets:
1051# If the user asked for a bytecode library to be built
Misha Brukman89fe5162009-01-08 02:11:55 +00001052# with the BYTECODE_LIBRARY variable, then we provide
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001053# targets for building them.
1054#---------------------------------------------------------
1055ifdef BYTECODE_LIBRARY
1056ifeq ($(strip $(LLVMGCC)),)
1057$(warning Bytecode libraries require llvm-gcc which could not be found ****)
1058else
1059
1060all-local:: $(LibName.BCA)
1061
1062ifdef EXPORTED_SYMBOL_FILE
1063BCLinkLib = $(LLVMLD) -L$(CFERuntimeLibDir) \
1064 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
1065
1066$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
1067 $(LLVMToolDir)/llvm-ar
1068 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
1069 "(internalize)"
Daniel Dunbarc6750c92009-08-28 16:14:46 +00001070 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).internalize $(ObjectsBC)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071 $(Verb) $(RM) -f $@
Daniel Dunbarc6750c92009-08-28 16:14:46 +00001072 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).internalize.bc
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073else
1074$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
1075 $(LLVMToolDir)/llvm-ar
1076 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
1077 $(Verb) $(RM) -f $@
1078 $(Verb) $(LArchive) $@ $(ObjectsBC)
1079
1080endif
1081
1082clean-local::
1083ifneq ($(strip $(LibName.BCA)),)
1084 -$(Verb) $(RM) -f $(LibName.BCA)
1085endif
1086
1087ifdef BYTECODE_DESTINATION
1088BytecodeDestDir := $(BYTECODE_DESTINATION)
1089else
1090BytecodeDestDir := $(PROJ_libdir)
1091endif
1092
Daniel Dunbar659cef82009-05-12 05:35:40 +00001093DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).bca
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094
1095install-bytecode-local:: $(DestBytecodeLib)
1096
1097ifdef NO_INSTALL
1098install-local::
1099 $(Echo) Install circumvented with NO_INSTALL
1100uninstall-local::
1101 $(Echo) Uninstall circumvented with NO_INSTALL
1102else
1103install-local:: $(DestBytecodeLib)
1104
Mike Stump98f72e02009-02-12 23:45:11 +00001105$(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001106 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1107 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
1108
1109uninstall-local::
1110 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
1111 -$(Verb) $(RM) -f $(DestBytecodeLib)
1112endif
1113endif
1114endif
1115
1116#---------------------------------------------------------
Chris Lattner20cba1c2009-06-16 23:00:42 +00001117# Library Targets:
1118# If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1119# building an archive.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001120#---------------------------------------------------------
1121ifndef BUILD_ARCHIVE
Chris Lattner20cba1c2009-06-16 23:00:42 +00001122ifndef LOADABLE_MODULE
1123BUILD_ARCHIVE = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001124endif
1125endif
1126
1127#---------------------------------------------------------
1128# Archive Library Targets:
Misha Brukman89fe5162009-01-08 02:11:55 +00001129# If the user wanted a regular archive library built,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001130# then we provide targets for building them.
1131#---------------------------------------------------------
1132ifdef BUILD_ARCHIVE
1133
1134all-local:: $(LibName.A)
1135
1136$(LibName.A): $(ObjectsO) $(LibDir)/.dir
1137 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
1138 -$(Verb) $(RM) -f $@
Bill Wendling3d6df102009-01-03 22:46:50 +00001139 $(Verb) $(Archive) $@ $(ObjectsO)
1140 $(Verb) $(Ranlib) $@
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001141
1142clean-local::
1143ifneq ($(strip $(LibName.A)),)
1144 -$(Verb) $(RM) -f $(LibName.A)
1145endif
1146
1147ifdef NO_INSTALL
1148install-local::
1149 $(Echo) Install circumvented with NO_INSTALL
1150uninstall-local::
1151 $(Echo) Uninstall circumvented with NO_INSTALL
1152else
1153DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
1154
1155install-local:: $(DestArchiveLib)
1156
Mike Stump98f72e02009-02-12 23:45:11 +00001157$(DestArchiveLib): $(LibName.A) $(PROJ_libdir)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
1159 $(Verb) $(MKDIR) $(PROJ_libdir)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001160 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001161
1162uninstall-local::
1163 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
1164 -$(Verb) $(RM) -f $(DestArchiveLib)
1165endif
1166endif
1167
1168# endif LIBRARYNAME
Misha Brukman89fe5162009-01-08 02:11:55 +00001169endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001170
1171###############################################################################
1172# Tool Build Rules: Build executable tool based on TOOLNAME option
1173###############################################################################
1174
1175ifdef TOOLNAME
1176
1177#---------------------------------------------------------
1178# Set up variables for building a tool.
1179#---------------------------------------------------------
1180ifdef EXAMPLE_TOOL
1181ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
1182else
1183ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
1184endif
1185
1186#---------------------------------------------------------
Chris Lattner8b04ea72009-02-26 17:47:49 +00001187# Prune Exports
1188#---------------------------------------------------------
1189
1190# If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1191# not exporting all of the weak symbols from the binary. This reduces dyld
1192# startup time by 4x on darwin in some cases.
1193ifdef TOOL_NO_EXPORTS
Anton Korobeynikov92c51812009-08-18 00:40:33 +00001194ifeq ($(HOST_OS),Darwin)
Chris Lattnerc6c51352009-03-10 17:15:56 +00001195
1196# Tiger tools don't support this.
1197ifneq ($(DARWIN_MAJVERS),4)
Chris Lattner8b04ea72009-02-26 17:47:49 +00001198LD.Flags += -Wl,-exported_symbol -Wl,_main
1199endif
Chris Lattnerc6c51352009-03-10 17:15:56 +00001200endif
Chris Lattner8b04ea72009-02-26 17:47:49 +00001201
Anton Korobeynikov92c51812009-08-18 00:40:33 +00001202ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD))
Chris Lattner7c024612009-02-26 18:38:40 +00001203LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
Chris Lattner8b04ea72009-02-26 17:47:49 +00001204endif
1205endif
1206
1207
1208#---------------------------------------------------------
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001209# Provide targets for building the tools
1210#---------------------------------------------------------
1211all-local:: $(ToolBuildPath)
1212
1213clean-local::
1214ifneq ($(strip $(ToolBuildPath)),)
1215 -$(Verb) $(RM) -f $(ToolBuildPath)
1216endif
1217
1218ifdef EXAMPLE_TOOL
1219$(ToolBuildPath): $(ExmplDir)/.dir
1220else
1221$(ToolBuildPath): $(ToolDir)/.dir
1222endif
1223
1224$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
1225 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001226 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001227 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
1228 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
Misha Brukman89fe5162009-01-08 02:11:55 +00001229 $(StripWarnMsg)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001230
1231ifdef NO_INSTALL
1232install-local::
1233 $(Echo) Install circumvented with NO_INSTALL
1234uninstall-local::
1235 $(Echo) Uninstall circumvented with NO_INSTALL
1236else
Anton Korobeynikovfffdd942009-08-05 09:37:43 +00001237DestTool = $(PROJ_bindir)/$(TOOLNAME)$(EXEEXT)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001238
1239install-local:: $(DestTool)
1240
Mike Stump98f72e02009-02-12 23:45:11 +00001241$(DestTool): $(ToolBuildPath) $(PROJ_bindir)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001242 $(Echo) Installing $(BuildMode) $(DestTool)
1243 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
1244
1245uninstall-local::
1246 $(Echo) Uninstalling $(BuildMode) $(DestTool)
1247 -$(Verb) $(RM) -f $(DestTool)
1248endif
1249endif
1250
1251###############################################################################
Misha Brukman89fe5162009-01-08 02:11:55 +00001252# Object Build Rules: Build object files based on sources
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253###############################################################################
1254
1255# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
Anton Korobeynikov92c51812009-08-18 00:40:33 +00001256ifeq ($(HOST_OS),HP-UX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001257 DISABLE_AUTO_DEPENDENCIES=1
1258endif
1259
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260# Provide rule sets for when dependency generation is enabled
1261ifndef DISABLE_AUTO_DEPENDENCIES
1262
1263#---------------------------------------------------------
Nick Lewycky8d91e192009-02-26 07:44:16 +00001264# Create .o files in the ObjDir directory from the .cpp and .c files...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265#---------------------------------------------------------
1266
Chris Lattner87fd1ec2007-12-31 23:58:31 +00001267DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
Nick Lewycky8d91e192009-02-26 07:44:16 +00001268 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
Gabor Greif14c4c8e2008-02-27 13:34:15 +00001269
Daniel Dunbar285108f2009-05-12 06:35:50 +00001270# If the build succeeded, move the dependency file over, otherwise
1271# remove it.
Chris Lattner87fd1ec2007-12-31 23:58:31 +00001272DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1273 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1274
Nick Lewycky8d91e192009-02-26 07:44:16 +00001275$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001276 $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001277 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
Chris Lattner87fd1ec2007-12-31 23:58:31 +00001278 $(DEPEND_MOVEFILE)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001279
Nick Lewycky8d91e192009-02-26 07:44:16 +00001280$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001282 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
Chris Lattner87fd1ec2007-12-31 23:58:31 +00001283 $(DEPEND_MOVEFILE)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001284
Nick Lewycky8d91e192009-02-26 07:44:16 +00001285$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001286 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001287 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
Chris Lattner87fd1ec2007-12-31 23:58:31 +00001288 $(DEPEND_MOVEFILE)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001289
1290#---------------------------------------------------------
1291# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
1292#---------------------------------------------------------
1293
Daniel Dunbar285108f2009-05-12 06:35:50 +00001294BC_DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.bc.d.tmp" \
1295 -MT "$(ObjDir)/$*.ll" -MT "$(ObjDir)/$*.bc.d"
1296
1297# If the build succeeded, move the dependency file over, otherwise
1298# remove it.
1299BC_DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.bc.d.tmp" "$(ObjDir)/$*.bc.d"; \
1300 else $(RM) "$(ObjDir)/$*.bc.d.tmp"; exit 1; fi
1301
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1303 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Daniel Dunbar285108f2009-05-12 06:35:50 +00001304 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1305 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1306 $(BC_DEPEND_MOVEFILE)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307
1308$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1309 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Daniel Dunbar285108f2009-05-12 06:35:50 +00001310 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1311 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1312 $(BC_DEPEND_MOVEFILE)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001313
1314$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1315 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Daniel Dunbar285108f2009-05-12 06:35:50 +00001316 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1317 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1318 $(BC_DEPEND_MOVEFILE)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001319
1320# Provide alternate rule sets if dependencies are disabled
1321else
1322
Nick Lewycky8d91e192009-02-26 07:44:16 +00001323$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001324 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001325 $(Compile.CXX) $< -o $@
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001326
Nick Lewycky8d91e192009-02-26 07:44:16 +00001327$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001328 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001329 $(Compile.CXX) $< -o $@
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330
Nick Lewycky8d91e192009-02-26 07:44:16 +00001331$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001332 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001333 $(Compile.C) $< -o $@
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001334
1335$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1336 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
1337 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001338
1339$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
1340 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1341 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001342
1343$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
1344 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
1345 $(BCCompile.C) $< -o $@ -S -emit-llvm
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001346
1347endif
1348
1349
1350## Rules for building preprocessed (.i/.ii) outputs.
1351$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1352 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1353 $(Verb) $(Preprocess.CXX) $< -o $@
1354
1355$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1356 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1357 $(Verb) $(Preprocess.CXX) $< -o $@
1358
1359$(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1360 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1361 $(Verb) $(Preprocess.C) $< -o $@
1362
1363
1364$(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1365 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001366 $(Compile.CXX) $< -o $@ -S
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001367
1368$(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1369 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001370 $(Compile.CXX) $< -o $@ -S
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001371
1372$(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1373 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky8d91e192009-02-26 07:44:16 +00001374 $(Compile.C) $< -o $@ -S
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001375
1376
1377# make the C and C++ compilers strip debug info out of bytecode libraries.
1378ifdef DEBUG_RUNTIME
Dan Gohman25de0de2009-09-08 15:52:56 +00001379$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001380 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Dan Gohman25de0de2009-09-08 15:52:56 +00001381 $(Verb) $(LOPT) $< -std-compile-opts -o $@
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001382else
Dan Gohman25de0de2009-09-08 15:52:56 +00001383$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001384 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Dan Gohman25de0de2009-09-08 15:52:56 +00001385 $(Verb) $(LOPT) $< -std-compile-opts -strip-debug -o $@
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001386endif
1387
1388
1389#---------------------------------------------------------
1390# Provide rule to build .bc files from .ll sources,
1391# regardless of dependencies
1392#---------------------------------------------------------
1393$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
1394 $(Echo) "Compiling $*.ll for $(BuildMode) build"
1395 $(Verb) $(LLVMAS) $< -f -o $@
1396
1397###############################################################################
1398# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1399###############################################################################
1400
1401ifdef TARGET
Mikhail Glushenkov72145e32009-03-02 09:42:59 +00001402TABLEGEN_INC_FILES_COMMON = 1
1403endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001404
Mikhail Glushenkov72145e32009-03-02 09:42:59 +00001405ifdef LLVMC_BUILD_AUTOGENERATED_INC
1406TABLEGEN_INC_FILES_COMMON = 1
1407endif
1408
1409ifdef TABLEGEN_INC_FILES_COMMON
1410
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001411INCFiles := $(filter %.inc,$(BUILT_SOURCES))
1412INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1413.PRECIOUS: $(INCTMPFiles) $(INCFiles)
1414
Misha Brukman89fe5162009-01-08 02:11:55 +00001415# INCFiles rule: All of the tblgen generated files are emitted to
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001416# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1417# us to only "touch" the real file if the contents of it change. IOW, if
Daniel Dunbar90f3e7f2008-11-03 17:33:36 +00001418# tblgen is modified, all of the .inc.tmp files are regenerated, but no
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001419# dependencies of the .inc files are, unless the contents of the .inc file
1420# changes.
1421$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
1422 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
1423
Mikhail Glushenkov72145e32009-03-02 09:42:59 +00001424endif # TABLEGEN_INC_FILES_COMMON
1425
1426ifdef TARGET
1427
1428TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1429 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1430 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1431 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1432 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1433 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1434 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1435
Rafael Espindola4d8cd532009-03-10 17:58:54 +00001436# All of these files depend on tblgen and the .td files.
1437$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1438
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001439$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1440$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
1441 $(Echo) "Building $(<F) register names with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001442 $(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001443
1444$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1445$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
1446 $(Echo) "Building $(<F) register information header with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001447 $(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001448
1449$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1450$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
1451 $(Echo) "Building $(<F) register info implementation with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001452 $(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001453
1454$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1455$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
1456 $(Echo) "Building $(<F) instruction names with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001457 $(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001458
1459$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1460$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
1461 $(Echo) "Building $(<F) instruction information with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001462 $(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001463
1464$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1465$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
1466 $(Echo) "Building $(<F) assembly writer with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001467 $(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001468
1469$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1470$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1471 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Misha Brukman89fe5162009-01-08 02:11:55 +00001472 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473
Daniel Dunbara9b43082009-07-13 18:35:35 +00001474$(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1475$(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir
1476 $(Echo) "Building $(<F) assembly matcher with tblgen"
1477 $(Verb) $(TableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1478
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001479$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1480$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1481 $(Echo) "Building $(<F) code emitter with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001482 $(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001483
1484$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1485$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
Dan Gohmanb75dead2008-08-13 20:19:35 +00001486 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001487 $(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001488
Dan Gohmanb75dead2008-08-13 20:19:35 +00001489$(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1490$(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
1491 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1492 $(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1493
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001494$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1495$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1496 $(Echo) "Building $(<F) subtarget information with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001497 $(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001498
1499$(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1500$(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1501 $(Echo) "Building $(<F) calling convention information with tblgen"
Chris Lattner1b0a3a12008-01-15 23:27:40 +00001502 $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001503
Dale Johannesenfe5921a2009-02-05 01:49:45 +00001504$(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
1505$(ObjDir)/%GenIntrinsics.inc.tmp : Intrinsics%.td $(ObjDir)/.dir
1506 $(Echo) "Building $(<F) calling convention information with tblgen"
1507 $(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1508
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001509clean-local::
1510 -$(Verb) $(RM) -f $(INCFiles)
1511
Mikhail Glushenkov72145e32009-03-02 09:42:59 +00001512endif # TARGET
1513
1514ifdef LLVMC_BUILD_AUTOGENERATED_INC
1515
Mikhail Glushenkov3b335a42009-04-21 19:46:10 +00001516LLVMCPluginSrc := $(sort $(strip $(wildcard $(PROJ_SRC_DIR)/*.td)) \
1517 $(strip $(wildcard $(PROJ_OBJ_DIR)/*.td)))
Mikhail Glushenkov72145e32009-03-02 09:42:59 +00001518
1519TDFiles := $(LLVMCPluginSrc) \
1520 $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
1521
1522$(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
1523 $(TBLGEN) $(TD_COMMON)
1524 $(Echo) "Building LLVMC configuration library with tblgen"
1525 $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
1526
1527endif # LLVMC_BUILD_AUTOGENERATED_INC
1528
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001529###############################################################################
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001530# OTHER RULES: Other rules needed
1531###############################################################################
1532
1533# To create postscript files from dot files...
1534ifneq ($(DOT),false)
1535%.ps: %.dot
1536 $(DOT) -Tps < $< > $@
1537else
1538%.ps: %.dot
1539 $(Echo) "Cannot build $@: The program dot is not installed"
1540endif
1541
1542# This rules ensures that header files that are removed still have a rule for
1543# which they can be "generated." This allows make to ignore them and
1544# reproduce the dependency lists.
1545%.h:: ;
1546%.hpp:: ;
1547
1548# Define clean-local to clean the current directory. Note that this uses a
Misha Brukman89fe5162009-01-08 02:11:55 +00001549# very conservative approach ensuring that empty variables do not cause
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001550# errors or disastrous removal.
1551clean-local::
Jim Grosbache4c032e2008-10-02 22:56:44 +00001552ifneq ($(strip $(ObjRootDir)),)
1553 -$(Verb) $(RM) -rf $(ObjRootDir)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001554endif
1555 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
1556ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
1557 -$(Verb) $(RM) -f *$(SHLIBEXT)
1558endif
1559
1560clean-all-local::
1561 -$(Verb) $(RM) -rf Debug Release Profile
1562
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001563
1564###############################################################################
1565# DEPENDENCIES: Include the dependency files if we should
1566###############################################################################
1567ifndef DISABLE_AUTO_DEPENDENCIES
1568
1569# If its not one of the cleaning targets
Daniel Dunbara89194e2008-10-03 19:11:19 +00001570ifndef IS_CLEANING_TARGET
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001571
1572# Get the list of dependency files
Daniel Dunbar285108f2009-05-12 06:35:50 +00001573DependSourceFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1574DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1575
1576# Include bitcode dependency files if using bitcode libraries
1577ifdef BYTECODE_LIBRARY
1578DependFiles += $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
1579endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001580
Reid Spencerdfb3d5b2007-07-23 08:20:46 +00001581-include $(DependFiles) ""
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001582
1583endif
1584
Misha Brukman89fe5162009-01-08 02:11:55 +00001585endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001586
1587###############################################################################
1588# CHECK: Running the test suite
1589###############################################################################
1590
Bill Wendlingea4af672009-04-09 18:26:57 +00001591check::
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001592 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1593 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1594 $(EchoCmd) Running test suite ; \
1595 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
1596 TESTSUITE=$(TESTSUITE) ; \
1597 else \
1598 $(EchoCmd) No Makefile in test directory ; \
1599 fi ; \
1600 else \
1601 $(EchoCmd) No test directory ; \
1602 fi
1603
Daniel Dunbar12ffa4d2009-09-08 05:31:44 +00001604check-lit::
1605 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1606 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1607 $(EchoCmd) Running test suite ; \
1608 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-lit ; \
1609 else \
1610 $(EchoCmd) No Makefile in test directory ; \
1611 fi ; \
1612 else \
1613 $(EchoCmd) No test directory ; \
1614 fi
1615
Daniel Dunbar5b6816d2009-09-20 06:17:21 +00001616check-all::
1617 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1618 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1619 $(EchoCmd) Running test suite ; \
1620 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1621 else \
1622 $(EchoCmd) No Makefile in test directory ; \
1623 fi ; \
1624 else \
1625 $(EchoCmd) No test directory ; \
1626 fi
1627
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001628###############################################################################
Bill Wendling2e3646a2009-01-04 23:12:21 +00001629# UNITTESTS: Running the unittests test suite
1630###############################################################################
1631
Bill Wendlingea4af672009-04-09 18:26:57 +00001632unittests::
Bill Wendling2e3646a2009-01-04 23:12:21 +00001633 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1634 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1635 $(EchoCmd) Running unittests test suite ; \
Daniel Dunbar4f1c6552009-09-13 22:39:27 +00001636 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
Bill Wendling2e3646a2009-01-04 23:12:21 +00001637 else \
1638 $(EchoCmd) No Makefile in unittests directory ; \
1639 fi ; \
1640 else \
1641 $(EchoCmd) No unittests directory ; \
1642 fi
1643
1644###############################################################################
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001645# DISTRIBUTION: Handle construction of a distribution tarball
1646###############################################################################
1647
1648#------------------------------------------------------------------------
1649# Define distribution related variables
1650#------------------------------------------------------------------------
1651DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1652DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1653TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1654DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1655DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1656DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
1657DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1658 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
1659 Makefile.config.in configure autoconf
1660DistOther := $(notdir $(wildcard \
1661 $(PROJ_SRC_DIR)/*.h \
1662 $(PROJ_SRC_DIR)/*.td \
1663 $(PROJ_SRC_DIR)/*.def \
1664 $(PROJ_SRC_DIR)/*.ll \
1665 $(PROJ_SRC_DIR)/*.in))
1666DistSubDirs := $(SubDirs)
1667DistSources = $(Sources) $(EXTRA_DIST)
1668DistFiles = $(DistAlways) $(DistSources) $(DistOther)
1669
1670#------------------------------------------------------------------------
1671# We MUST build distribution with OBJ_DIR != SRC_DIR
1672#------------------------------------------------------------------------
1673ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
1674dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1675 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
1676
1677else
1678
1679#------------------------------------------------------------------------
1680# Prevent attempt to run dist targets from anywhere but the top level
1681#------------------------------------------------------------------------
1682ifneq ($(LEVEL),.)
1683dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
1684 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
1685else
1686
1687#------------------------------------------------------------------------
1688# Provide the top level targets
1689#------------------------------------------------------------------------
1690
1691dist-gzip:: $(DistTarGZip)
1692
1693$(DistTarGZip) : $(TopDistDir)/.makedistdir
1694 $(Echo) Packing gzipped distribution tar file.
1695 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1696 $(GZIP) -c > "$(DistTarGZip)"
1697
1698dist-bzip2:: $(DistTarBZ2)
1699
1700$(DistTarBZ2) : $(TopDistDir)/.makedistdir
1701 $(Echo) Packing bzipped distribution tar file.
1702 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1703 $(BZIP2) -c >$(DistTarBZ2)
1704
1705dist-zip:: $(DistZip)
1706
1707$(DistZip) : $(TopDistDir)/.makedistdir
1708 $(Echo) Packing zipped distribution file.
1709 $(Verb) rm -f $(DistZip)
1710 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
1711
Misha Brukman89fe5162009-01-08 02:11:55 +00001712dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001713 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
1714
1715DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
1716
1717dist-check:: $(DistTarGZip)
1718 $(Echo) Checking distribution tar file.
1719 $(Verb) if test -d $(DistCheckDir) ; then \
1720 $(RM) -rf $(DistCheckDir) ; \
1721 fi
1722 $(Verb) $(MKDIR) $(DistCheckDir)
1723 $(Verb) cd $(DistCheckDir) && \
1724 $(MKDIR) $(DistCheckDir)/build && \
1725 $(MKDIR) $(DistCheckDir)/install && \
1726 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1727 cd build && \
1728 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1729 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
1730 $(MAKE) all && \
1731 $(MAKE) check && \
Bill Wendling2e3646a2009-01-04 23:12:21 +00001732 $(MAKE) unittests && \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001733 $(MAKE) install && \
1734 $(MAKE) uninstall && \
1735 $(MAKE) dist-clean && \
1736 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
1737
1738dist-clean::
1739 $(Echo) Cleaning distribution files
1740 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1741 $(DistCheckDir)
1742
1743endif
1744
1745#------------------------------------------------------------------------
1746# Provide the recursive distdir target for building the distribution directory
1747#------------------------------------------------------------------------
1748distdir: $(DistDir)/.makedistdir
1749$(DistDir)/.makedistdir: $(DistSources)
1750 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1751 if test -d "$(DistDir)" ; then \
1752 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1753 exit 1 ; \
1754 fi ; \
1755 $(EchoCmd) Removing old $(DistDir) ; \
1756 $(RM) -rf $(DistDir); \
1757 $(EchoCmd) Making 'all' to verify build ; \
1758 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
1759 fi
1760 $(Echo) Building Distribution Directory $(DistDir)
Misha Brukman89fe5162009-01-08 02:11:55 +00001761 $(Verb) $(MKDIR) $(DistDir)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1763 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
1764 for file in $(DistFiles) ; do \
1765 case "$$file" in \
1766 $(PROJ_SRC_DIR)/*) \
1767 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1768 ;; \
1769 $(PROJ_SRC_ROOT)/*) \
1770 file=`echo "$$file" | \
1771 sed "s#^$$srcrootstrip/##"` \
1772 ;; \
1773 esac; \
1774 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1775 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1776 from_dir="$(PROJ_SRC_DIR)" ; \
1777 elif test -f "$$file" || test -d "$$file" ; then \
1778 from_dir=. ; \
1779 fi ; \
1780 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
1781 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1782 to_dir="$(DistDir)/$$dir"; \
1783 $(MKDIR) "$$to_dir" ; \
1784 else \
1785 to_dir="$(DistDir)"; \
1786 fi; \
1787 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1788 if test -n "$$mid_dir" ; then \
1789 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
1790 fi ; \
1791 if test -d "$$from_dir/$$file"; then \
1792 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1793 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
1794 cd $(PROJ_SRC_DIR) ; \
1795 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1796 ( cd $$to_dir ; $(TAR) xf - ) ; \
1797 cd $(PROJ_OBJ_DIR) ; \
1798 else \
1799 cd $$from_dir ; \
1800 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1801 ( cd $$to_dir ; $(TAR) xf - ) ; \
1802 cd $(PROJ_OBJ_DIR) ; \
1803 fi; \
1804 elif test -f "$$from_dir/$$file" ; then \
1805 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1806 elif test -L "$$from_dir/$$file" ; then \
1807 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1808 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1809 $(EchoCmd) "===== WARNING: Distribution Source " \
1810 "$$from_dir/$$file Not Found!" ; \
1811 elif test "$(Verb)" != '@' ; then \
1812 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
1813 fi; \
1814 done
1815 $(Verb) for subdir in $(DistSubDirs) ; do \
1816 if test "$$subdir" \!= "." ; then \
1817 new_distdir="$(DistDir)/$$subdir" ; \
1818 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1819 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
1820 DistDir="$$new_distdir" distdir ) || exit 1; \
1821 fi; \
1822 done
1823 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1824 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1825 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1826 -name .svn \) -print` ;\
1827 $(MAKE) dist-hook ; \
1828 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1829 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1830 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1831 -o ! -type d ! -perm -444 -exec \
1832 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1833 || chmod -R a+r $(DistDir) ; \
1834 fi
1835
1836# This is invoked by distdir target, define it as a no-op to avoid errors if not
1837# defined by user.
1838dist-hook::
1839
1840endif
1841
1842###############################################################################
1843# TOP LEVEL - targets only to apply at the top level directory
1844###############################################################################
1845
1846ifeq ($(LEVEL),.)
1847
1848#------------------------------------------------------------------------
1849# Install support for the project's include files:
1850#------------------------------------------------------------------------
1851ifdef NO_INSTALL
1852install-local::
1853 $(Echo) Install circumvented with NO_INSTALL
1854uninstall-local::
1855 $(Echo) Uninstall circumvented with NO_INSTALL
1856else
1857install-local::
1858 $(Echo) Installing include files
1859 $(Verb) $(MKDIR) $(PROJ_includedir)
1860 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
1861 cd $(PROJ_SRC_ROOT)/include && \
Chris Lattnerbfaed4c2009-01-02 07:16:45 +00001862 for hdr in `find . -type f '!' '(' -name '*~' \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001863 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
1864 grep -v .svn` ; do \
1865 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1866 if test \! -d "$$instdir" ; then \
1867 $(EchoCmd) Making install directory $$instdir ; \
1868 $(MKDIR) $$instdir ;\
1869 fi ; \
1870 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1871 done ; \
1872 fi
1873ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
1874 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
1875 cd $(PROJ_OBJ_ROOT)/include && \
1876 for hdr in `find . -type f -print | grep -v CVS` ; do \
1877 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
1878 done ; \
1879 fi
1880endif
1881
1882uninstall-local::
1883 $(Echo) Uninstalling include files
1884 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1885 cd $(PROJ_SRC_ROOT)/include && \
1886 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
Chris Lattnerbfaed4c2009-01-02 07:16:45 +00001887 '!' '(' -name '*~' -o -name '.#*' \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001888 -o -name '*.in' ')' -print ')' | \
1889 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
1890 cd $(PROJ_SRC_ROOT)/include && \
1891 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1892 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1893 fi
1894endif
1895endif
1896
1897check-line-length:
Gabor Greifb91ea9d2008-05-15 10:04:30 +00001898 @echo searching for overlength lines in files: $(Sources)
1899 @echo
1900 @echo
Gabor Greif3033d032008-08-28 22:32:39 +00001901 egrep -n '.{81}' $(Sources) /dev/null
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001902
1903check-for-tabs:
Gabor Greifb91ea9d2008-05-15 10:04:30 +00001904 @echo searching for tabs in files: $(Sources)
1905 @echo
1906 @echo
Gabor Greif3033d032008-08-28 22:32:39 +00001907 egrep -n ' ' $(Sources) /dev/null
Gabor Greifb91ea9d2008-05-15 10:04:30 +00001908
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001909check-footprint:
1910 @ls -l $(LibDir) | awk '\
1911 BEGIN { sum = 0; } \
1912 { sum += $$5; } \
1913 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1914 @ls -l $(ToolDir) | awk '\
1915 BEGIN { sum = 0; } \
1916 { sum += $$5; } \
1917 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1918#------------------------------------------------------------------------
1919# Print out the directories used for building
1920#------------------------------------------------------------------------
1921printvars::
1922 $(Echo) "BuildMode : " '$(BuildMode)'
1923 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1924 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1925 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1926 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1927 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1928 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1929 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1930 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1931 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1932 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
1933 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
1934 $(Echo) "UserTargets : " '$(UserTargets)'
1935 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1936 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1937 $(Echo) "ObjDir : " '$(ObjDir)'
1938 $(Echo) "LibDir : " '$(LibDir)'
1939 $(Echo) "ToolDir : " '$(ToolDir)'
1940 $(Echo) "ExmplDir : " '$(ExmplDir)'
1941 $(Echo) "Sources : " '$(Sources)'
1942 $(Echo) "TDFiles : " '$(TDFiles)'
1943 $(Echo) "INCFiles : " '$(INCFiles)'
1944 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
1945 $(Echo) "PreConditions: " '$(PreConditions)'
1946 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1947 $(Echo) "Compile.C : " '$(Compile.C)'
1948 $(Echo) "Archive : " '$(Archive)'
1949 $(Echo) "YaccFiles : " '$(YaccFiles)'
1950 $(Echo) "LexFiles : " '$(LexFiles)'
1951 $(Echo) "Module : " '$(Module)'
1952 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
1953 $(Echo) "SubDirs : " '$(SubDirs)'
1954 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
1955 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
Daniel Dunbar190b3d52009-02-21 20:42:39 +00001956
1957###
1958# Debugging
1959
Daniel Dunbara6b02752009-03-06 22:23:25 +00001960# General debugging rule, use 'make dbg-print-XXX' to print the
Daniel Dunbar190b3d52009-02-21 20:42:39 +00001961# definition, value and origin of XXX.
Daniel Dunbara6b02752009-03-06 22:23:25 +00001962make-print-%:
Daniel Dunbar190b3d52009-02-21 20:42:39 +00001963 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))