blob: 8cabd0b02cb00b37ecbe4da679387d6546e9c621 [file] [log] [blame]
Misha Brukman7426c892004-04-24 00:10:56 +00001#===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
2#
John Criswell23e43fb2003-10-21 14:33:46 +00003# The LLVM Compiler Infrastructure
4#
Chris Lattner11cc8b32007-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 Brukman2879c292009-01-08 02:11:55 +00007#
Misha Brukman7426c892004-04-24 00:10:56 +00008#===------------------------------------------------------------------------===#
Chris Lattner2f7c9632001-06-06 20:29:01 +00009#
Reid Spencer81cd0492004-10-23 20:04:14 +000010# 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.
Chris Lattner2e9fc94a2003-08-15 03:02:52 +000012#
Chris Lattnerb8e7aa02006-02-14 04:27:15 +000013#===-----------------------------------------------------------------------====#
Chris Lattner2f7c9632001-06-06 20:29:01 +000014
Reid Spencerf88808a2004-10-30 09:19:36 +000015################################################################################
Reid Spencer81cd0492004-10-23 20:04:14 +000016# TARGETS: Define standard targets that can be invoked
Reid Spencerf88808a2004-10-30 09:19:36 +000017################################################################################
John Criswell3ef61af2003-06-30 21:59:07 +000018
Chris Lattner2f7c9632001-06-06 20:29:01 +000019#--------------------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +000020# Define the various target sets
21#--------------------------------------------------------------------
Daniel Dunbar96ccc472009-09-13 22:39:27 +000022RecursiveTargets := all clean clean-all install uninstall install-bytecode \
23 unitcheck
Reid Spencer8b5ebe52004-12-06 05:35:13 +000024LocalTargets := all-local clean-local clean-all-local check-local \
Reid Spencerd4bd3752004-12-03 20:08:48 +000025 install-local printvars uninstall-local \
Daniel Dunbar96ccc472009-09-13 22:39:27 +000026 install-bytecode-local
Chris Lattnerd0382a82007-09-26 06:10:47 +000027TopLevelTargets := check dist dist-check dist-clean dist-gzip dist-bzip2 \
Bill Wendling8790e322009-01-04 23:12:21 +000028 dist-zip unittests
Reid Spencerf88808a2004-10-30 09:19:36 +000029UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
30InternalTargets := preconditions distdir dist-hook
Reid Spencer81cd0492004-10-23 20:04:14 +000031
Reid Spencerf88808a2004-10-30 09:19:36 +000032################################################################################
Reid Spencer77a46d22004-10-26 22:26:33 +000033# INITIALIZATION: Basic things the makefile needs
Reid Spencerf88808a2004-10-30 09:19:36 +000034################################################################################
35
36#--------------------------------------------------------------------
37# Set the VPATH so that we can find source files.
38#--------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +000039VPATH=$(PROJ_SRC_DIR)
Reid Spencer77a46d22004-10-26 22:26:33 +000040
41#--------------------------------------------------------------------
Reid Spencer7214cfd2007-06-29 14:02:07 +000042# Reset the list of suffixes we know how to build.
Reid Spencer77a46d22004-10-26 22:26:33 +000043#--------------------------------------------------------------------
44.SUFFIXES:
Nick Lewycky28c62d22009-02-26 07:44:16 +000045.SUFFIXES: .c .cpp .cc .h .hpp .o .a .bc .td .ps .dot .ll
Reid Spencerf88808a2004-10-30 09:19:36 +000046.SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
Reid Spencer77a46d22004-10-26 22:26:33 +000047
Reid Spencer81cd0492004-10-23 20:04:14 +000048#--------------------------------------------------------------------
49# Mark all of these targets as phony to avoid implicit rule search
50#--------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +000051.PHONY: $(UserTargets) $(InternalTargets)
Reid Spencer81cd0492004-10-23 20:04:14 +000052
53#--------------------------------------------------------------------
Misha Brukman2879c292009-01-08 02:11:55 +000054# Make sure all the user-target rules are double colon rules and
Reid Spencer77a46d22004-10-26 22:26:33 +000055# they are defined first.
Reid Spencer81cd0492004-10-23 20:04:14 +000056#--------------------------------------------------------------------
57
Reid Spencerf88808a2004-10-30 09:19:36 +000058$(UserTargets)::
Reid Spencer100080c2004-10-25 08:27:37 +000059
Reid Spencer77a46d22004-10-26 22:26:33 +000060################################################################################
61# PRECONDITIONS: that which must be built/checked first
62################################################################################
63
Reid Spencerd4bd3752004-12-03 20:08:48 +000064SrcMakefiles := $(filter %Makefile %Makefile.tests,\
Reid Spencerba6a3db2005-01-16 02:20:54 +000065 $(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
Chris Lattner68c97542006-09-04 05:23:20 +000077
Reid Spencerba6a3db2005-01-16 02:20:54 +000078ifneq ($(MakefileConfigIn),)
79PreConditions += $(MakefileConfig)
80endif
Reid Spencer77a46d22004-10-26 22:26:33 +000081
Reid Spencer53846bc2005-08-25 04:59:49 +000082preconditions: $(PreConditions)
Reid Spencer77a46d22004-10-26 22:26:33 +000083
84#------------------------------------------------------------------------
85# Make sure the BUILT_SOURCES are built first
86#------------------------------------------------------------------------
Reid Spencer97e40f12004-12-16 07:15:16 +000087$(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
Reid Spencer77a46d22004-10-26 22:26:33 +000088
Reid Spencer48c74392007-02-07 19:13:19 +000089clean-all-local::
Reid Spencer77a46d22004-10-26 22:26:33 +000090ifneq ($(strip $(BUILT_SOURCES)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +000091 -$(Verb) $(RM) -f $(BUILT_SOURCES)
Reid Spencer77a46d22004-10-26 22:26:33 +000092endif
93
Reid Spencerba6a3db2005-01-16 02:20:54 +000094ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
Reid Spencer55814372004-12-16 08:00:46 +000095spotless:
Reid Spencer55814372004-12-16 08:00:46 +000096 $(Verb) if test -x config.status ; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +000097 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
Reid Spencer7ef8e662004-12-17 07:45:03 +000098 $(MKDIR) .spotless.save ; \
99 $(MV) config.status .spotless.save ; \
100 $(MV) mklib .spotless.save ; \
101 $(MV) projects .spotless.save ; \
Reid Spencer55814372004-12-16 08:00:46 +0000102 $(RM) -rf * ; \
Reid Spencer7ef8e662004-12-17 07:45:03 +0000103 $(MV) .spotless.save/config.status . ; \
104 $(MV) .spotless.save/mklib . ; \
105 $(MV) .spotless.save/projects . ; \
106 $(RM) -rf .spotless.save ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000107 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
Reid Spencer7ef8e662004-12-17 07:45:03 +0000108 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
109 $(ConfigStatusScript) ; \
Reid Spencer55814372004-12-16 08:00:46 +0000110 else \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000111 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
Reid Spencer55814372004-12-16 08:00:46 +0000112 fi
Reid Spencerc49a8632005-12-21 23:17:06 +0000113else
114spotless:
115 $(EchoCmd) "spotless target not supported for objdir == srcdir"
Reid Spencer55814372004-12-16 08:00:46 +0000116endif
117
Reid Spencerf88808a2004-10-30 09:19:36 +0000118$(BUILT_SOURCES) : $(ObjMakefiles)
Reid Spencerb7f710a2004-10-28 00:41:43 +0000119
Reid Spencer77a46d22004-10-26 22:26:33 +0000120#------------------------------------------------------------------------
121# Make sure we're not using a stale configuration
122#------------------------------------------------------------------------
Reid Spencerafdc82c2004-12-16 18:26:53 +0000123reconfigure:
Reid Spencerba6a3db2005-01-16 02:20:54 +0000124 $(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 ; \
Reid Spencer35655d62004-12-24 03:36:31 +0000128 fi ; \
Reid Spencerafdc82c2004-12-16 18:26:53 +0000129 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
130 $(ConfigStatusScript)
131
Anton Korobeynikov28381c02009-08-14 18:53:19 +0000132# FIXME: The {PIC16,MSP430}/AsmPrinter line here is a hack to force a reconfigure to pick
Daniel Dunbard8186682009-08-13 17:22:49 +0000133# up AsmPrinter changes. Remove it after a reasonable delay from 2009-08-13.
134
Reid Spencerf88808a2004-10-30 09:19:36 +0000135.PRECIOUS: $(ConfigStatusScript)
Anton Korobeynikov28381c02009-08-14 18:53:19 +0000136$(ConfigStatusScript): $(ConfigureScript) $(LLVM_SRC_ROOT)/lib/Target/PIC16/AsmPrinter/Makefile $(LLVM_SRC_ROOT)/lib/Target/MSP430/AsmPrinter/Makefile
Reid Spencerf88808a2004-10-30 09:19:36 +0000137 $(Echo) Reconfiguring with $<
Reid Spencerba6a3db2005-01-16 02:20:54 +0000138 $(Verb) cd $(PROJ_OBJ_ROOT) && \
139 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
140 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
Reid Spencer35655d62004-12-24 03:36:31 +0000141 fi ; \
Reid Spencer50f34872004-11-29 12:37:44 +0000142 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
143 $(ConfigStatusScript)
Reid Spencer77a46d22004-10-26 22:26:33 +0000144
Reid Spencer83bde552005-08-25 04:44:18 +0000145#------------------------------------------------------------------------
Reid Spencer77a46d22004-10-26 22:26:33 +0000146# Make sure the configuration makefile is up to date
147#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +0000148ifneq ($(MakefileConfigIn),)
149$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
Reid Spencerf88808a2004-10-30 09:19:36 +0000150 $(Echo) Regenerating $@
Reid Spencerba6a3db2005-01-16 02:20:54 +0000151 $(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
Reid Spencer77a46d22004-10-26 22:26:33 +0000159
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#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +0000164ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
Reid Spencer77a46d22004-10-26 22:26:33 +0000165
Gordon Henriksen04e38cf2008-03-10 15:58:40 +0000166Makefile: $(PROJ_SRC_DIR)/Makefile $(ExtraMakefiles)
Reid Spencerf88808a2004-10-30 09:19:36 +0000167 $(Echo) "Updating Makefile"
168 $(Verb) $(MKDIR) $(@D)
Reid Spencerafdc82c2004-12-16 18:26:53 +0000169 $(Verb) $(CP) -f $< $@
Reid Spencer77a46d22004-10-26 22:26:33 +0000170
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.
Reid Spencerba6a3db2005-01-16 02:20:54 +0000174$(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
Reid Spencerd94bb332004-10-26 23:10:00 +0000175 @case '$?' in \
176 *Makefile.rules) ;; \
177 *.in) ;; \
Gordon Henriksen04e38cf2008-03-10 15:58:40 +0000178 *) $(EchoCmd) "Updating $(@F)" ; \
Reid Spencerd94bb332004-10-26 23:10:00 +0000179 $(MKDIR) $(@D) ; \
Reid Spencerafdc82c2004-12-16 18:26:53 +0000180 $(CP) -f $< $@ ;; \
Reid Spencerd94bb332004-10-26 23:10:00 +0000181 esac
Gabor Greifc848f9e2008-02-27 13:34:15 +0000182
Reid Spencer77a46d22004-10-26 22:26:33 +0000183endif
184
185#------------------------------------------------------------------------
186# Set up the basic dependencies
187#------------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000188$(UserTargets):: $(PreConditions)
Reid Spencer77a46d22004-10-26 22:26:33 +0000189
190all:: all-local
Anton Korobeynikov8e58c522008-11-10 07:33:13 +0000191clean:: clean-local
Reid Spencer9d0c1e02004-11-02 16:36:03 +0000192clean-all:: clean-local clean-all-local
Reid Spencer77a46d22004-10-26 22:26:33 +0000193install:: install-local
194uninstall:: uninstall-local
Misha Brukman2879c292009-01-08 02:11:55 +0000195install-local:: all-local
Reid Spencerd4bd3752004-12-03 20:08:48 +0000196install-bytecode:: install-bytecode-local
Reid Spencer81cd0492004-10-23 20:04:14 +0000197
198###############################################################################
Mikhail Glushenkov7cff8182009-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 Glushenkov248c4142009-06-23 20:46:48 +0000205CPP.Flags += -DLLVMC_PLUGIN_NAME=$(LLVMC_PLUGIN)
Mikhail Glushenkov7cff8182009-03-02 09:04:13 +0000206REQUIRES_EH := 1
Mikhail Glushenkovd6c39ae2009-07-03 03:52:47 +0000207
208ifeq ($(ENABLE_LLVMC_DYNAMIC),1)
209 LD.Flags += -lCompilerDriver
210endif
Mikhail Glushenkov7cff8182009-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 Glushenkovd6c39ae2009-07-03 03:52:47 +0000215 LOADABLE_MODULE = 1
Mikhail Glushenkov7cff8182009-03-02 09:04:13 +0000216endif
217
218# TableGen stuff...
219ifneq ($(BUILT_SOURCES),)
Mikhail Glushenkovd6c39ae2009-07-03 03:52:47 +0000220 LLVMC_BUILD_AUTOGENERATED_INC=1
Mikhail Glushenkov7cff8182009-03-02 09:04:13 +0000221endif
222
223endif # LLVMC_PLUGIN
224
Mikhail Glushenkov73da6262009-06-25 01:07:00 +0000225ifdef LLVMC_BASED_DRIVER
226
227TOOLNAME = $(LLVMC_BASED_DRIVER)
Mikhail Glushenkovd6c39ae2009-07-03 03:52:47 +0000228
Mikhail Glushenkov73da6262009-06-25 01:07:00 +0000229REQUIRES_EH := 1
Mikhail Glushenkovd6c39ae2009-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 Glushenkov73da6262009-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))
Mikhail Glushenkovfc8809d2009-10-09 04:15:52 +0000249LLVMC_BUILTIN_PLUGIN_6 = $(word 6, $(LLVMC_BUILTIN_PLUGINS))
250LLVMC_BUILTIN_PLUGIN_7 = $(word 7, $(LLVMC_BUILTIN_PLUGINS))
251LLVMC_BUILTIN_PLUGIN_8 = $(word 8, $(LLVMC_BUILTIN_PLUGINS))
252LLVMC_BUILTIN_PLUGIN_9 = $(word 9, $(LLVMC_BUILTIN_PLUGINS))
253LLVMC_BUILTIN_PLUGIN_10 = $(word 10, $(LLVMC_BUILTIN_PLUGINS))
254
Mikhail Glushenkov73da6262009-06-25 01:07:00 +0000255
256ifneq ($(LLVMC_BUILTIN_PLUGIN_1),)
257CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_1=$(LLVMC_BUILTIN_PLUGIN_1)
258endif
259
260ifneq ($(LLVMC_BUILTIN_PLUGIN_2),)
261CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_2=$(LLVMC_BUILTIN_PLUGIN_2)
262endif
263
264ifneq ($(LLVMC_BUILTIN_PLUGIN_3),)
265CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_3=$(LLVMC_BUILTIN_PLUGIN_3)
266endif
267
268ifneq ($(LLVMC_BUILTIN_PLUGIN_4),)
269CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_4=$(LLVMC_BUILTIN_PLUGIN_4)
270endif
271
272ifneq ($(LLVMC_BUILTIN_PLUGIN_5),)
273CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_5)
274endif
275
Mikhail Glushenkovfc8809d2009-10-09 04:15:52 +0000276ifneq ($(LLVMC_BUILTIN_PLUGIN_6),)
277CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_6)
278endif
279
280ifneq ($(LLVMC_BUILTIN_PLUGIN_7),)
281CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_7)
282endif
283
284ifneq ($(LLVMC_BUILTIN_PLUGIN_8),)
285CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_8)
286endif
287
288ifneq ($(LLVMC_BUILTIN_PLUGIN_9),)
289CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_9)
290endif
291
292ifneq ($(LLVMC_BUILTIN_PLUGIN_10),)
293CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_10)
294endif
295
296
Mikhail Glushenkov73da6262009-06-25 01:07:00 +0000297endif
298
299endif # LLVMC_BASED_DRIVER
300
Mikhail Glushenkov7cff8182009-03-02 09:04:13 +0000301###############################################################################
Reid Spencer81cd0492004-10-23 20:04:14 +0000302# VARIABLES: Set up various variables based on configuration data
303###############################################################################
304
Daniel Dunbar78caa022008-10-03 19:11:19 +0000305# Variable for if this make is for a "cleaning" target
306ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
307 IS_CLEANING_TARGET=1
308endif
309
Reid Spencer81cd0492004-10-23 20:04:14 +0000310#--------------------------------------------------------------------
311# Variables derived from configuration we are building
Chris Lattner2f7c9632001-06-06 20:29:01 +0000312#--------------------------------------------------------------------
313
Reid Spencerfd8e6412007-07-10 07:19:53 +0000314CPP.Defines :=
David Greene80f48bd2009-04-17 14:49:22 +0000315ifeq ($(ENABLE_OPTIMIZED),1)
316 BuildMode := Release
317 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000318 ifneq ($(HOST_OS),FreeBSD)
319 ifneq ($(HOST_OS),Darwin)
David Greene80f48bd2009-04-17 14:49:22 +0000320 OmitFramePointer := -fomit-frame-pointer
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000321 endif
David Greene80f48bd2009-04-17 14:49:22 +0000322 endif
323
324 # Darwin requires -fstrict-aliasing to be explicitly enabled.
Evan Cheng57709502009-04-20 22:49:59 +0000325 # Avoid -fstrict-aliasing on Darwin for now, there are unresolved issues
326 # with -fstrict-aliasing and ipa-type-escape radr://6756684
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000327 #ifeq ($(HOST_OS),Darwin)
Evan Cheng40c52322009-04-20 22:16:40 +0000328 # EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
329 #endif
David Greene80f48bd2009-04-17 14:49:22 +0000330 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
331 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
332 LD.Flags += $(OPTIMIZE_OPTION)
Jeffrey Yasskinc3273dc2009-09-27 17:47:29 +0000333 ifdef DEBUG_SYMBOLS
Jeffrey Yasskindb281082009-09-25 16:46:09 +0000334 BuildMode := $(BuildMode)+Debug
335 CXX.Flags += -g
336 C.Flags += -g
337 LD.Flags += -g
338 KEEP_SYMBOLS := 1
339 endif
David Greene80f48bd2009-04-17 14:49:22 +0000340else
Daniel Dunbar08d4ab92009-11-16 22:37:52 +0000341 ifdef NO_DEBUG_SYMBOLS
342 BuildMode := Unoptimized
343 CXX.Flags +=
344 C.Flags +=
345 LD.Flags +=
346 KEEP_SYMBOLS := 1
347 else
348 BuildMode := Debug
349 CXX.Flags += -g
350 C.Flags += -g
351 LD.Flags += -g
352 KEEP_SYMBOLS := 1
353 endif
David Greene80f48bd2009-04-17 14:49:22 +0000354endif
355
356ifeq ($(ENABLE_PROFILING),1)
357 BuildMode := $(BuildMode)+Profile
358 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
359 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
360 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg -g
361 KEEP_SYMBOLS := 1
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000362endif
363
Daniel Dunbar61e0a822008-09-02 17:35:16 +0000364#ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
365# CXX.Flags += -fvisibility-inlines-hidden
366#endif
367
Chris Lattnerab8a7c42010-01-24 20:20:40 +0000368ifdef ENABLE_EXPENSIVE_CHECKS
369 # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above.
370 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160
371 REQUIRES_RTTI := 1
372endif
373
Reid Spencer51e6f682006-08-25 19:54:53 +0000374# IF REQUIRES_EH=1 is specified then don't disable exceptions
Reid Spencer0b6396c2006-08-25 20:56:59 +0000375ifndef REQUIRES_EH
376 CXX.Flags += -fno-exceptions
Chris Lattnerdb308fd2010-01-24 20:21:50 +0000377else
378 # If the library requires EH, it also requires RTTI.
379 REQUIRES_RTTI := 1
Reid Spencer0b6396c2006-08-25 20:56:59 +0000380endif
Reid Spencer51e6f682006-08-25 19:54:53 +0000381
Nicolas Geoffray43cce222009-08-19 22:04:44 +0000382ifdef REQUIRES_FRAME_POINTER
383 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags))
384 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags))
385 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags))
386endif
387
Daniel Dunbar24c00472009-09-11 15:47:24 +0000388# If REQUIRES_RTTI=1 is specified then don't disable run-time type id.
Chris Lattner823aed12010-01-24 20:43:08 +0000389ifneq ($(REQUIRES_RTTI), 1)
390 CXX.Flags += -fno-rtti
391 CXXFLAGS += -fno-rtti
Reid Spencere6bc2062007-05-02 21:29:39 +0000392endif
393
Daniel Dunbar5b86bf52009-03-13 20:59:41 +0000394ifdef ENABLE_COVERAGE
395 BuildMode := $(BuildMode)+Coverage
Chris Lattnereaae8d02009-06-16 23:00:42 +0000396 CXX.Flags += -ftest-coverage -fprofile-arcs
397 C.Flags += -ftest-coverage -fprofile-arcs
Daniel Dunbar5b86bf52009-03-13 20:59:41 +0000398endif
399
Reid Spencer15b85092006-04-10 16:46:04 +0000400# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
401# then disable assertions by defining the appropriate preprocessor symbols.
Reid Spencerece13582006-04-09 23:41:14 +0000402ifdef DISABLE_ASSERTIONS
Duncan Sands99d0b232009-03-27 11:35:00 +0000403 # Indicate that assertions are turned off using a minus sign
404 BuildMode := $(BuildMode)-Asserts
Reid Spencerfd8e6412007-07-10 07:19:53 +0000405 CPP.Defines += -DNDEBUG
Reid Spencerece13582006-04-09 23:41:14 +0000406else
Reid Spencerfd8e6412007-07-10 07:19:53 +0000407 CPP.Defines += -D_DEBUG
Chris Lattner98c79c32006-03-21 01:06:41 +0000408endif
409
Misha Brukman2879c292009-01-08 02:11:55 +0000410# If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
411# configured), then enable expensive checks by defining the
David Greene869e4b52007-06-29 03:36:21 +0000412# appropriate preprocessor symbols.
David Greenecbc8ddf2007-06-28 19:36:08 +0000413ifdef ENABLE_EXPENSIVE_CHECKS
414 BuildMode := $(BuildMode)+Checks
Duncan Sands445071c2008-12-09 21:33:20 +0000415 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
David Greenecbc8ddf2007-06-28 19:36:08 +0000416endif
417
Nick Lewycky28c62d22009-02-26 07:44:16 +0000418# LOADABLE_MODULE implies several other things so we force them to be
419# defined/on.
420ifdef LOADABLE_MODULE
421 SHARED_LIBRARY := 1
Nick Lewycky28c62d22009-02-26 07:44:16 +0000422 LINK_LIBS_IN_SHARED := 1
423endif
424
425ifdef SHARED_LIBRARY
426 ENABLE_PIC := 1
427 PIC_FLAG = "(PIC)"
428endif
429
Reid Spencer05a1fe52006-12-16 22:07:52 +0000430ifeq ($(ENABLE_PIC),1)
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000431 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
Nick Lewycky9e5ed6d2009-02-21 08:41:09 +0000432 # Nothing. Win32 defaults to PIC and warns when given -fPIC
433 else
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000434 ifeq ($(HOST_OS),Darwin)
Nick Lewycky28c62d22009-02-26 07:44:16 +0000435 # Common symbols not allowed in dylib files
Nick Lewycky9e5ed6d2009-02-21 08:41:09 +0000436 CXX.Flags += -fno-common
437 C.Flags += -fno-common
438 else
439 # Linux and others; pass -fPIC
440 CXX.Flags += -fPIC
441 C.Flags += -fPIC
442 endif
443 endif
Mike Stumpd1b46362009-05-08 23:08:58 +0000444else
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000445 ifeq ($(HOST_OS),Darwin)
Mike Stumpd1b46362009-05-08 23:08:58 +0000446 CXX.Flags += -mdynamic-no-pic
447 C.Flags += -mdynamic-no-pic
448 endif
Reid Spencer05a1fe52006-12-16 22:07:52 +0000449endif
450
Anton Korobeynikov803c60c2010-01-16 14:06:58 +0000451ifeq ($(HOST_OS),MingW)
452 # Work around PR4957
453 CPP.Defines += -D__NO_CTYPE_INLINE
454 ifeq ($(LLVM_CROSS_COMPILING),1)
455 # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
456 ifdef TOOLNAME
457 LD.Flags += -Wl,--allow-multiple-definition
458 endif
459 endif
460endif
461
Eric Christopher3fe69672009-08-18 03:23:40 +0000462CXX.Flags += -Woverloaded-virtual
David Greenecbc8ddf2007-06-28 19:36:08 +0000463CPP.BaseFlags += $(CPP.Defines)
Reid Spencer6f682b72006-03-22 15:59:55 +0000464AR.Flags := cru
Reid Spencer81cd0492004-10-23 20:04:14 +0000465
Chris Lattnerdc5a8962006-07-27 18:19:51 +0000466# Make Floating point IEEE compliant on Alpha.
Andrew Lenharth9a98def2005-02-13 03:41:10 +0000467ifeq ($(ARCH),Alpha)
Reid Spencer05a1fe52006-12-16 22:07:52 +0000468 CXX.Flags += -mieee
469 CPP.BaseFlags += -mieee
470ifeq ($(ENABLE_PIC),0)
471 CXX.Flags += -fPIC
472 CPP.BaseFlags += -fPIC
473endif
Andrew Lenharth9a98def2005-02-13 03:41:10 +0000474endif
475
Andrew Lenharth0ad67b02007-01-26 13:34:50 +0000476ifeq ($(ARCH),Alpha)
477 LD.Flags += -Wl,--no-relax
478endif
479
Reid Spencer81cd0492004-10-23 20:04:14 +0000480#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000481# Directory locations
Reid Spencer81cd0492004-10-23 20:04:14 +0000482#--------------------------------------------------------------------
Jim Grosbach009db892008-10-02 22:56:44 +0000483TargetMode :=
484ifeq ($(LLVM_CROSS_COMPILING),1)
Anton Korobeynikov8e58c522008-11-10 07:33:13 +0000485 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
Jim Grosbach009db892008-10-02 22:56:44 +0000486endif
487
488ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
Anton Korobeynikov8e58c522008-11-10 07:33:13 +0000489ObjDir := $(ObjRootDir)
490LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
491ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
492ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
493LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
494LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
495LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer2bba41c2004-12-22 05:57:21 +0000496CFERuntimeLibDir := $(LLVMGCCDIR)/lib
John Criswell3ef61af2003-06-30 21:59:07 +0000497
Reid Spencer81cd0492004-10-23 20:04:14 +0000498#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000499# Full Paths To Compiled Tools and Utilities
Reid Spencer81cd0492004-10-23 20:04:14 +0000500#--------------------------------------------------------------------
Reid Spencerb12e2902005-01-14 16:33:36 +0000501EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
502Echo = @$(EchoCmd)
Reid Spencerf88808a2004-10-30 09:19:36 +0000503ifndef LLVMAS
504LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
505endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000506ifndef TBLGEN
Reid Spencer0aa9d002006-07-26 21:14:56 +0000507 ifeq ($(LLVM_CROSS_COMPILING),1)
Anton Korobeynikov8e58c522008-11-10 07:33:13 +0000508 TBLGEN := $(BuildLLVMToolDir)/tblgen$(BUILD_EXEEXT)
Reid Spencer0aa9d002006-07-26 21:14:56 +0000509 else
510 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
511 endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000512endif
Misha Brukman2879c292009-01-08 02:11:55 +0000513LLVM_CONFIG := $(LLVMToolDir)/llvm-config
Reid Spencerb63d0c42007-02-09 15:52:07 +0000514ifndef LLVMLD
Reid Spencer7cec4f22007-02-09 17:09:14 +0000515LLVMLD := $(LLVMToolDir)/llvm-ld$(EXEEXT)
Reid Spencerf88808a2004-10-30 09:19:36 +0000516endif
Chris Lattner68c97542006-09-04 05:23:20 +0000517ifndef LLVMDIS
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000518LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
519endif
520ifndef LLI
521LLI := $(LLVMToolDir)/lli$(EXEEXT)
522endif
Alkis Evlogimenos24340582005-02-27 10:21:37 +0000523ifndef LLC
524LLC := $(LLVMToolDir)/llc$(EXEEXT)
525endif
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000526ifndef LOPT
Alkis Evlogimenos7c7705d2004-12-13 18:08:29 +0000527LOPT := $(LLVMToolDir)/opt$(EXEEXT)
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000528endif
Alkis Evlogimenos7c04a3d2005-02-02 00:40:15 +0000529ifndef LBUGPOINT
530LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
531endif
Reid Spencer9a6fc822006-12-03 21:01:45 +0000532ifndef LUPGRADE
533LUPGRADE := $(LLVMToolDir)/llvm-upgrade$(EXEEXT)
534endif
535ifeq ($(LLVMGCC_MAJVERS),3)
Reid Spencerbef61c52006-12-10 04:56:38 +0000536LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
537LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
Reid Spencer9a6fc822006-12-03 21:01:45 +0000538else
Reid Spencerbef61c52006-12-10 04:56:38 +0000539LLVMGCCWITHPATH := $(LLVMGCC)
540LLVMGXXWITHPATH := $(LLVMGXX)
Reid Spencer9a6fc822006-12-03 21:01:45 +0000541endif
542
Reid Spencer81cd0492004-10-23 20:04:14 +0000543#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000544# Adjust to user's request
Reid Spencer81cd0492004-10-23 20:04:14 +0000545#--------------------------------------------------------------------
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000546
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000547ifeq ($(HOST_OS),Darwin)
Scott Michelb1a830a2009-03-12 21:03:53 +0000548 DARWIN_VERSION := `sw_vers -productVersion`
549 # Strip a number like 10.4.7 to 10.4
550 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
551 # Get "4" out of 10.4 for later pieces in the makefile.
552 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
Bill Wendlingf3ef2c72009-03-22 08:28:45 +0000553
Julien Lerouge15833b92009-03-27 18:18:00 +0000554 SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress \
Evan Cheng57b14192009-09-08 18:52:20 +0000555 -dynamiclib
556 ifneq ($(ARCH),ARM)
557 SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
558 endif
Scott Michelb1a830a2009-03-12 21:03:53 +0000559else
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000560 ifeq ($(HOST_OS),Cygwin)
Scott Michelb1a830a2009-03-12 21:03:53 +0000561 SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
Mikhail Glushenkovd6c39ae2009-07-03 03:52:47 +0000562 -Wl,--enable-auto-import -Wl,--enable-auto-image-base
Scott Michelb1a830a2009-03-12 21:03:53 +0000563 else
564 SharedLinkOptions=-shared
565 endif
566endif
567
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000568ifeq ($(TARGET_OS),Darwin)
Evan Cheng57b14192009-09-08 18:52:20 +0000569 ifneq ($(ARCH),ARM)
570 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
Jim Grosbach95e6e932009-10-30 21:33:05 +0000571 else
572 TargetCommonOpts += -marm
Evan Cheng57b14192009-09-08 18:52:20 +0000573 endif
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000574endif
575
Nick Lewycky28c62d22009-02-26 07:44:16 +0000576# Adjust LD.Flags depending on the kind of library that is to be built. Note
577# that if LOADABLE_MODULE is specified then the resulting shared library can
578# be opened with dlopen.
Reid Spencere6458c32006-08-07 23:12:15 +0000579ifdef LOADABLE_MODULE
Reid Spencere6458c32006-08-07 23:12:15 +0000580 LD.Flags += -module
581endif
582
Reid Spencer87e645c2005-01-11 04:31:07 +0000583ifdef SHARED_LIBRARY
Scott Michelb1a830a2009-03-12 21:03:53 +0000584ifneq ($(DARWIN_MAJVERS),4)
Nick Lewycky7d01e392009-03-03 04:55:15 +0000585 LD.Flags += $(RPATH) -Wl,$(LibDir)
John Criswell3601f372003-07-31 20:58:51 +0000586endif
Scott Michelb1a830a2009-03-12 21:03:53 +0000587endif
John Criswell3601f372003-07-31 20:58:51 +0000588
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000589ifdef TOOL_VERBOSE
590 C.Flags += -v
591 CXX.Flags += -v
592 LD.Flags += -v
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000593 VERBOSE := 1
594endif
595
Reid Spencer81cd0492004-10-23 20:04:14 +0000596# Adjust settings for verbose mode
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000597ifndef VERBOSE
Reid Spencerf88808a2004-10-30 09:19:36 +0000598 Verb := @
Reid Spencerfcd78152007-07-23 08:20:46 +0000599 AR.Flags += >/dev/null 2>/dev/null
Reid Spencerba6a3db2005-01-16 02:20:54 +0000600 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
Reid Spencer100080c2004-10-25 08:27:37 +0000601else
Misha Brukman2879c292009-01-08 02:11:55 +0000602 ConfigureScriptFLAGS :=
Misha Brukman1326a7c2002-09-12 16:05:39 +0000603endif
604
Vikram S. Adved141c282002-09-18 11:55:13 +0000605# By default, strip symbol information from executable
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000606ifndef KEEP_SYMBOLS
Reid Spencerf88808a2004-10-30 09:19:36 +0000607 Strip := $(PLATFORMSTRIPOPTS)
608 StripWarnMsg := "(without symbols)"
Reid Spencer247a10e2005-02-24 07:12:43 +0000609 Install.StripFlag += -s
Vikram S. Adved141c282002-09-18 11:55:13 +0000610endif
611
Reid Spencer81cd0492004-10-23 20:04:14 +0000612# Adjust linker flags for building an executable
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000613ifneq ($(HOST_OS),Darwin)
Scott Michelb1a830a2009-03-12 21:03:53 +0000614ifneq ($(DARWIN_MAJVERS),4)
Reid Spencerf206bd72004-10-22 21:01:56 +0000615ifdef TOOLNAME
Jeffrey Yasskinf750fef2010-02-18 02:36:02 +0000616 LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
617 ifdef EXAMPLE_TOOL
618 LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
619 else
620 LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC)
621 endif
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000622endif
Nick Lewycky28c62d22009-02-26 07:44:16 +0000623endif
Nick Lewycky28c62d22009-02-26 07:44:16 +0000624endif
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000625
Reid Spencer81cd0492004-10-23 20:04:14 +0000626#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000627# Options To Invoke Tools
Reid Spencer81cd0492004-10-23 20:04:14 +0000628#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000629
Daniel Dunbar310511d2009-05-12 07:26:49 +0000630ifndef NO_PEDANTIC
Duncan Sandse532b552009-06-19 12:40:30 +0000631CompileCommonOpts += -pedantic -Wno-long-long
Daniel Dunbar310511d2009-05-12 07:26:49 +0000632endif
Duncan Sandse532b552009-06-19 12:40:30 +0000633CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
634 $(EXTRA_OPTIONS)
Reid Spencerf206bd72004-10-22 21:01:56 +0000635
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000636ifeq ($(HOST_OS),HP-UX)
Duraid Madina1f898af2006-02-15 03:20:16 +0000637 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
Duraid Madina60c9a3c2005-05-16 06:38:09 +0000638endif
639
Chris Lattner11c25cf2006-05-30 16:38:06 +0000640# If we are building a universal binary on Mac OS/X, pass extra options. This
641# is useful to people that want to link the LLVM libraries into their universal
Chris Lattner65e28b32006-06-29 19:38:04 +0000642# apps.
643#
644# The following can be optionally specified:
645# UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
646# For Mac OS/X 10.4 Intel machines, the traditional one is:
647# UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
648# UNIVERSAL_ARCH can be optionally specified to be a list of architectures
649# to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
650# i386/ppc only.
Chris Lattnerd81eba52006-04-06 06:30:15 +0000651ifdef UNIVERSAL
Chris Lattner65e28b32006-06-29 19:38:04 +0000652 ifndef UNIVERSAL_ARCH
653 UNIVERSAL_ARCH := i386 ppc
654 endif
655 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
656 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
Chris Lattner64e85f32006-06-16 21:47:59 +0000657 ifdef UNIVERSAL_SDK_PATH
658 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
Chris Lattner64e85f32006-06-16 21:47:59 +0000659 endif
660
661 # Building universal cannot compute dependencies automatically.
Chris Lattnerd81eba52006-04-06 06:30:15 +0000662 DISABLE_AUTO_DEPENDENCIES=1
Evan Cheng3807bb72009-03-09 18:28:37 +0000663else
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000664 ifeq ($(TARGET_OS),Darwin)
Bill Wendling207495d2009-03-12 04:10:09 +0000665 ifeq ($(ARCH),x86_64)
Evan Cheng3138f7a2009-03-23 03:45:56 +0000666 TargetCommonOpts = -m64
Bill Wendling207495d2009-03-12 04:10:09 +0000667 else
668 ifeq ($(ARCH),x86)
Evan Cheng3138f7a2009-03-23 03:45:56 +0000669 TargetCommonOpts = -m32
Bill Wendling207495d2009-03-12 04:10:09 +0000670 endif
Evan Cheng3807bb72009-03-09 18:28:37 +0000671 endif
672 endif
Chris Lattnerd81eba52006-04-06 06:30:15 +0000673endif
674
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000675ifeq ($(HOST_OS),SunOS)
Chris Lattner01602a12008-06-24 17:44:42 +0000676CPP.BaseFlags += -include llvm/System/Solaris.h
677endif
678
Edward O'Callaghan4ae411e2009-10-14 05:55:03 +0000679ifeq ($(HOST_OS),AuroraUX)
680CPP.BaseFlags += -include llvm/System/Solaris.h
681endif # !HOST_OS - AuroraUX.
682
Misha Brukman2879c292009-01-08 02:11:55 +0000683LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
Dan Gohmanca0546f2008-10-17 01:33:43 +0000684CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
Reid Spencer6f682b72006-03-22 15:59:55 +0000685# All -I flags should go here, so that they don't confuse llvm-config.
Duncan Sands9f6f4d32008-01-28 17:38:30 +0000686CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
687 $(patsubst %,-I%/include,\
Chris Lattner6379fc62008-01-28 04:18:41 +0000688 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
689 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
690 $(CPP.BaseFlags)
Reid Spencerf206bd72004-10-22 21:01:56 +0000691
Daniel Dunbar5b86bf52009-03-13 20:59:41 +0000692ifeq ($(BUILD_COMPONENT), 1)
Eric Christopher3fe69672009-08-18 03:23:40 +0000693 Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
Evan Cheng3138f7a2009-03-23 03:45:56 +0000694 $(TargetCommonOpts) $(CompileCommonOpts) -c
Eric Christopher3fe69672009-08-18 03:23:40 +0000695 Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
696 $(CPPFLAGS) \
Evan Cheng3138f7a2009-03-23 03:45:56 +0000697 $(TargetCommonOpts) $(CompileCommonOpts) -c
Eric Christopher3fe69672009-08-18 03:23:40 +0000698 Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CPPFLAGS) $(TargetCommonOpts) \
Chris Lattnereaae8d02009-06-16 23:00:42 +0000699 $(CompileCommonOpts) $(CXX.Flags) -E
Eric Christopherd604b252009-08-18 18:07:35 +0000700 Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
701 $(LDFLAGS) \
Evan Cheng3138f7a2009-03-23 03:45:56 +0000702 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
Jim Grosbach009db892008-10-02 22:56:44 +0000703else
Eric Christopher3fe69672009-08-18 03:23:40 +0000704 Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
Evan Cheng3138f7a2009-03-23 03:45:56 +0000705 $(TargetCommonOpts) $(CompileCommonOpts) -c
Eric Christopher3fe69672009-08-18 03:23:40 +0000706 Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
Evan Cheng3138f7a2009-03-23 03:45:56 +0000707 $(TargetCommonOpts) $(CompileCommonOpts) -c
Eric Christopher3fe69672009-08-18 03:23:40 +0000708 Preprocess.CXX= $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
Chris Lattnereaae8d02009-06-16 23:00:42 +0000709 $(CompileCommonOpts) $(CXX.Flags) -E
Eric Christopherd604b252009-08-18 18:07:35 +0000710 Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(LDFLAGS) \
Evan Cheng3138f7a2009-03-23 03:45:56 +0000711 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
Jim Grosbach009db892008-10-02 22:56:44 +0000712endif
713
Eric Christopher3fe69672009-08-18 03:23:40 +0000714BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) $(CFLAGS) \
715 $(CPPFLAGS) \
Evan Cheng3138f7a2009-03-23 03:45:56 +0000716 $(TargetCommonOpts) $(CompileCommonOpts)
Eric Christopher3fe69672009-08-18 03:23:40 +0000717Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
Evan Cheng3138f7a2009-03-23 03:45:56 +0000718 $(TargetCommonOpts) $(CompileCommonOpts) -E
Chris Lattnerbb087952005-10-05 00:28:41 +0000719
Eric Christopher3fe69672009-08-18 03:23:40 +0000720BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
721 $(CPPFLAGS) \
Evan Cheng3138f7a2009-03-23 03:45:56 +0000722 $(TargetCommonOpts) $(CompileCommonOpts)
Chris Lattner008b2de2006-09-29 18:47:13 +0000723
Misha Brukman2879c292009-01-08 02:11:55 +0000724ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
725ScriptInstall = $(INSTALL) -m 0755
Reid Spencer247a10e2005-02-24 07:12:43 +0000726DataInstall = $(INSTALL) -m 0644
Chris Lattner50475362008-01-15 23:27:40 +0000727
728# When compiling under Mingw/Cygwin, the tblgen tool expects Windows
729# paths. In this case, the SYSPATH function (defined in
730# Makefile.config) transforms Unix paths into Windows paths.
731TableGen = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
Mikhail Glushenkov726440d2009-01-09 16:31:01 +0000732 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
Chris Lattner50475362008-01-15 23:27:40 +0000733 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
734 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
735
Reid Spencerf88808a2004-10-30 09:19:36 +0000736Archive = $(AR) $(AR.Flags)
Reid Spencer32f7e422004-12-02 09:28:21 +0000737LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencerf206bd72004-10-22 21:01:56 +0000738ifdef RANLIB
Reid Spencer81cd0492004-10-23 20:04:14 +0000739Ranlib = $(RANLIB)
Reid Spencerf206bd72004-10-22 21:01:56 +0000740else
Reid Spencer81cd0492004-10-23 20:04:14 +0000741Ranlib = ranlib
John Criswell3ef61af2003-06-30 21:59:07 +0000742endif
743
Daniel Dunbar0dd2b812009-11-19 00:14:53 +0000744AliasTool = ln -s
745
Chris Lattner2f7c9632001-06-06 20:29:01 +0000746#----------------------------------------------------------
Misha Brukman2879c292009-01-08 02:11:55 +0000747# Get the list of source files and compute object file
748# names from them.
Reid Spencer81cd0492004-10-23 20:04:14 +0000749#----------------------------------------------------------
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000750
751ifndef SOURCES
752 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
Chris Lattner814d9ee2009-01-02 07:16:45 +0000753 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
Reid Spencerf88808a2004-10-30 09:19:36 +0000754else
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000755 Sources := $(SOURCES)
Misha Brukman2879c292009-01-08 02:11:55 +0000756endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000757
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000758ifdef BUILT_SOURCES
Chris Lattner814d9ee2009-01-02 07:16:45 +0000759Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
Reid Spencer81546582004-12-04 22:34:09 +0000760endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000761
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000762BaseNameSources := $(sort $(basename $(Sources)))
763
764ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000765ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
766
Reid Spencer81cd0492004-10-23 20:04:14 +0000767###############################################################################
768# DIRECTORIES: Handle recursive descent of directory structure
769###############################################################################
John Criswell3601f372003-07-31 20:58:51 +0000770
Chris Lattner2f7c9632001-06-06 20:29:01 +0000771#---------------------------------------------------------
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000772# Provide rules to make install dirs. This must be early
773# in the file so they get built before dependencies
774#---------------------------------------------------------
775
Mike Stump35f423e2009-02-12 23:45:11 +0000776$(PROJ_bindir) $(PROJ_libdir) $(PROJ_includedir) $(PROJ_etcdir)::
Mike Stumpf7a16e92009-01-22 03:24:22 +0000777 $(Verb) $(MKDIR) $@
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000778
Reid Spencerf88808a2004-10-30 09:19:36 +0000779# To create other directories, as needed, and timestamp their creation
780%/.dir:
781 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfc66af42004-11-29 05:00:33 +0000782 $(Verb) $(DATE) > $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000783
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000784.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
785.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000786
787#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000788# Handle the DIRS options for sequential construction
Chris Lattner2f7c9632001-06-06 20:29:01 +0000789#---------------------------------------------------------
790
Misha Brukman2879c292009-01-08 02:11:55 +0000791SubDirs :=
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000792ifdef DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000793SubDirs += $(DIRS)
Chris Lattnerb9259612006-07-26 20:22:26 +0000794
795ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencerf88808a2004-10-30 09:19:36 +0000796$(RecursiveTargets)::
797 $(Verb) for dir in $(DIRS); do \
Reid Spencerf206bd72004-10-22 21:01:56 +0000798 if [ ! -f $$dir/Makefile ]; then \
799 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000800 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000801 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000802 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattner539a23c2002-09-17 23:35:02 +0000803 done
Chris Lattnerb9259612006-07-26 20:22:26 +0000804else
805$(RecursiveTargets)::
806 $(Verb) for dir in $(DIRS); do \
807 ($(MAKE) -C $$dir $@ ) || exit 1; \
808 done
809endif
810
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000811endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000812
Reid Spencer81cd0492004-10-23 20:04:14 +0000813#---------------------------------------------------------
814# Handle the EXPERIMENTAL_DIRS options ensuring success
815# after each directory is built.
816#---------------------------------------------------------
817ifdef EXPERIMENTAL_DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000818$(RecursiveTargets)::
819 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer81cd0492004-10-23 20:04:14 +0000820 if [ ! -f $$dir/Makefile ]; then \
821 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000822 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000823 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000824 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000825 done
826endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000827
Reid Spencerc49a8632005-12-21 23:17:06 +0000828#-----------------------------------------------------------
Mike Stump82221d62009-01-24 00:00:41 +0000829# Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
830#-----------------------------------------------------------
831ifdef OPTIONAL_PARALLEL_DIRS
832 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
833endif
834
835#-----------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000836# Handle the PARALLEL_DIRS options for parallel construction
Reid Spencerc49a8632005-12-21 23:17:06 +0000837#-----------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000838ifdef PARALLEL_DIRS
839
Reid Spencerf88808a2004-10-30 09:19:36 +0000840SubDirs += $(PARALLEL_DIRS)
841
Reid Spencerd4bd3752004-12-03 20:08:48 +0000842# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencerf88808a2004-10-30 09:19:36 +0000843all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
844clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000845clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencerf88808a2004-10-30 09:19:36 +0000846install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000847uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencerd4bd3752004-12-03 20:08:48 +0000848install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Daniel Dunbar96ccc472009-09-13 22:39:27 +0000849unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000850
Reid Spencer81546582004-12-04 22:34:09 +0000851ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer81cd0492004-10-23 20:04:14 +0000852
Reid Spencer81546582004-12-04 22:34:09 +0000853$(ParallelTargets) :
Reid Spencerf88808a2004-10-30 09:19:36 +0000854 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencerf206bd72004-10-22 21:01:56 +0000855 $(MKDIR) $(@D); \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000856 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswell6df35dd2003-11-25 19:32:22 +0000857 fi; \
Reid Spencer960cf7c2007-02-07 03:29:29 +0000858 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000859endif
860
Reid Spencer81cd0492004-10-23 20:04:14 +0000861#---------------------------------------------------------
862# Handle the OPTIONAL_DIRS options for directores that may
863# or may not exist.
864#---------------------------------------------------------
John Criswell8224df92003-06-27 16:58:44 +0000865ifdef OPTIONAL_DIRS
Reid Spencer100080c2004-10-25 08:27:37 +0000866
Reid Spencerf88808a2004-10-30 09:19:36 +0000867SubDirs += $(OPTIONAL_DIRS)
Reid Spencer100080c2004-10-25 08:27:37 +0000868
Chris Lattnerb9259612006-07-26 20:22:26 +0000869ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencerf88808a2004-10-30 09:19:36 +0000870$(RecursiveTargets)::
871 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000872 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
Reid Spencerf206bd72004-10-22 21:01:56 +0000873 if [ ! -f $$dir/Makefile ]; then \
874 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000875 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000876 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000877 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000878 fi \
John Criswell8224df92003-06-27 16:58:44 +0000879 done
Chris Lattnerb9259612006-07-26 20:22:26 +0000880else
881$(RecursiveTargets)::
882 $(Verb) for dir in $(OPTIONAL_DIRS); do \
883 ($(MAKE) -C$$dir $@ ) || exit 1; \
884 done
885endif
John Criswell8224df92003-06-27 16:58:44 +0000886endif
887
Reid Spencercc51e7b2004-08-20 09:20:05 +0000888#---------------------------------------------------------
889# Handle the CONFIG_FILES options
890#---------------------------------------------------------
891ifdef CONFIG_FILES
Reid Spencercc51e7b2004-08-20 09:20:05 +0000892
Reid Spencera79819d2007-02-06 18:53:14 +0000893ifdef NO_INSTALL
894install-local::
895 $(Echo) Install circumvented with NO_INSTALL
896uninstall-local::
897 $(Echo) UnInstall circumvented with NO_INSTALL
898else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000899install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
900 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000901 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000902 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
Reid Spencerc43b1d42005-02-24 03:56:32 +0000903 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000904 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
Reid Spencerc43b1d42005-02-24 03:56:32 +0000905 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer39d6a612004-11-23 05:59:53 +0000906 else \
907 $(ECHO) Error: cannot find config file $${file}. ; \
908 fi \
Reid Spencercc51e7b2004-08-20 09:20:05 +0000909 done
Reid Spencer81cd0492004-10-23 20:04:14 +0000910
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000911uninstall-local::
Reid Spencerba6a3db2005-01-16 02:20:54 +0000912 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000913 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000914 $(RM) -f $(PROJ_etcdir)/$${file} ; \
Reid Spencer12a3a052004-10-24 07:53:21 +0000915 done
Reid Spencera79819d2007-02-06 18:53:14 +0000916endif
Reid Spencer12a3a052004-10-24 07:53:21 +0000917
Reid Spencercc51e7b2004-08-20 09:20:05 +0000918endif
919
Reid Spencer81cd0492004-10-23 20:04:14 +0000920###############################################################################
Reid Spencera80f1672005-05-19 00:37:31 +0000921# Set up variables for building libararies
922###############################################################################
923
924#---------------------------------------------------------
Reid Spencera80f1672005-05-19 00:37:31 +0000925# Define various command line options pertaining to the
Misha Brukman2879c292009-01-08 02:11:55 +0000926# libraries needed when linking. There are "Proj" libs
927# (defined by the user's project) and "LLVM" libs (defined
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000928# by the LLVM project).
Reid Spencera80f1672005-05-19 00:37:31 +0000929#---------------------------------------------------------
Andrew Lenharth6b62b472005-08-13 05:09:50 +0000930
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000931ifdef USEDLIBS
Reid Spencera80f1672005-05-19 00:37:31 +0000932ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
933ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000934ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
935ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
936endif
937
938ifdef LLVMLIBS
Reid Spencera80f1672005-05-19 00:37:31 +0000939LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
940LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
Reid Spencera80f1672005-05-19 00:37:31 +0000941LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
Reid Spencera80f1672005-05-19 00:37:31 +0000942LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000943endif
944
Daniel Dunbar78caa022008-10-03 19:11:19 +0000945ifndef IS_CLEANING_TARGET
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000946ifdef LINK_COMPONENTS
Chris Lattner68c97542006-09-04 05:23:20 +0000947
948# If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
949# clean in tools, then do a make in tools (instead of at the top level).
950$(LLVM_CONFIG):
951 @echo "*** llvm-config doesn't exist - rebuilding it."
952 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
Gabor Greifc848f9e2008-02-27 13:34:15 +0000953
Chris Lattner68c97542006-09-04 05:23:20 +0000954$(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
955
Jeffrey Yasskinf750fef2010-02-18 02:36:02 +0000956ifeq ($(ENABLE_SHARED), 1)
957LLVMLibsOptions += -lLLVM$(LLVMVersion)
958LLVMLibsPaths += $(LibDir)/libLLVM$(LLVMVersion)$(SHLIBEXT)
959else
960ifeq ($(EXAMPLE_TOOL), 1)
961LLVMLibsOptions += -lLLVM$(LLVMVersion)
962LLVMLibsPaths += $(LibDir)/libLLVM$(LLVMVersion)$(SHLIBEXT)
963else
Mikhail Glushenkovab6f8de2009-03-03 10:03:27 +0000964LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
965LLVMLibsPaths += $(LLVM_CONFIG) \
Misha Brukman5906bc12009-08-17 15:31:24 +0000966 $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000967endif
Chris Lattner9a4a92e2006-09-04 04:50:10 +0000968endif
Jeffrey Yasskinf750fef2010-02-18 02:36:02 +0000969endif
970endif
Reid Spencera80f1672005-05-19 00:37:31 +0000971
972###############################################################################
Reid Spencer81cd0492004-10-23 20:04:14 +0000973# Library Build Rules: Four ways to build a library
974###############################################################################
Chris Lattner2f7c9632001-06-06 20:29:01 +0000975
Reid Spencerd78077d2004-12-05 05:17:22 +0000976#---------------------------------------------------------
977# Bytecode Module Targets:
978# If the user set MODULE_NAME then they want to build a
979# bytecode module from the sources. We compile all the
980# sources and link it together into a single bytecode
981# module.
982#---------------------------------------------------------
983
984ifdef MODULE_NAME
Reid Spencere9fa5442005-02-14 21:54:08 +0000985ifeq ($(strip $(LLVMGCC)),)
Reid Spencer83745dd2005-05-13 18:32:54 +0000986$(warning Modules require llvm-gcc but no llvm-gcc is available ****)
Reid Spencere9fa5442005-02-14 21:54:08 +0000987else
Reid Spencerd78077d2004-12-05 05:17:22 +0000988
989Module := $(LibDir)/$(MODULE_NAME).bc
Andrew Lenharthdddb68c2008-02-25 22:41:55 +0000990LinkModule := $(LLVMLD) -L$(CFERuntimeLibDir) -r
Reid Spencer78ede562006-04-12 18:21:35 +0000991
Reid Spencerd78077d2004-12-05 05:17:22 +0000992
993ifdef EXPORTED_SYMBOL_FILE
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000994LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencerd78077d2004-12-05 05:17:22 +0000995endif
996
Reid Spencerb63d0c42007-02-09 15:52:07 +0000997$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
Reid Spencer83745dd2005-05-13 18:32:54 +0000998 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
Reid Spencerd78077d2004-12-05 05:17:22 +0000999 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
1000
1001all-local:: $(Module)
1002
1003clean-local::
1004ifneq ($(strip $(Module)),)
1005 -$(Verb) $(RM) -f $(Module)
1006endif
1007
Reid Spencerefe3a822004-12-13 07:38:07 +00001008ifdef BYTECODE_DESTINATION
1009ModuleDestDir := $(BYTECODE_DESTINATION)
1010else
Reid Spencerba6a3db2005-01-16 02:20:54 +00001011ModuleDestDir := $(PROJ_libdir)
Reid Spencerefe3a822004-12-13 07:38:07 +00001012endif
Reid Spencerd78077d2004-12-05 05:17:22 +00001013
Reid Spencera79819d2007-02-06 18:53:14 +00001014ifdef NO_INSTALL
1015install-local::
1016 $(Echo) Install circumvented with NO_INSTALL
1017uninstall-local::
1018 $(Echo) Uninstall circumvented with NO_INSTALL
1019else
Reid Spencerefe3a822004-12-13 07:38:07 +00001020DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
1021
1022install-module:: $(DestModule)
Reid Spencerd78077d2004-12-05 05:17:22 +00001023install-local:: $(DestModule)
1024
Misha Brukman2879c292009-01-08 02:11:55 +00001025$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencerd78077d2004-12-05 05:17:22 +00001026 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
Reid Spencerd77a4c02005-02-24 21:30:37 +00001027 $(Verb) $(DataInstall) $(Module) $(DestModule)
Reid Spencerd78077d2004-12-05 05:17:22 +00001028
1029uninstall-local::
1030 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
1031 -$(Verb) $(RM) -f $(DestModule)
Reid Spencera79819d2007-02-06 18:53:14 +00001032endif
Reid Spencerd78077d2004-12-05 05:17:22 +00001033
1034endif
Reid Spencere9fa5442005-02-14 21:54:08 +00001035endif
Brian Gaekeecc92bf2004-01-22 22:53:48 +00001036
Reid Spencer81cd0492004-10-23 20:04:14 +00001037# if we're building a library ...
Chris Lattner2f7c9632001-06-06 20:29:01 +00001038ifdef LIBRARYNAME
Vikram S. Advefe346892001-07-15 13:16:47 +00001039
Misha Brukman5906bc12009-08-17 15:31:24 +00001040# Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
Chris Lattnere6e193ca2002-09-16 22:34:56 +00001041LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencer87e645c2005-01-11 04:31:07 +00001042ifdef LOADABLE_MODULE
Nick Lewycky28c62d22009-02-26 07:44:16 +00001043LibName.A := $(LibDir)/$(LIBRARYNAME).a
1044LibName.SO := $(LibDir)/$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencer87e645c2005-01-11 04:31:07 +00001045else
Reid Spencerf88808a2004-10-30 09:19:36 +00001046LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
Nick Lewycky28c62d22009-02-26 07:44:16 +00001047LibName.SO := $(LibDir)/lib$(LIBRARYNAME)$(SHLIBEXT)
1048endif
Reid Spencerf88808a2004-10-30 09:19:36 +00001049LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer32f7e422004-12-02 09:28:21 +00001050LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnere6e193ca2002-09-16 22:34:56 +00001051
Reid Spencer81cd0492004-10-23 20:04:14 +00001052#---------------------------------------------------------
1053# Shared Library Targets:
1054# If the user asked for a shared library to be built
1055# with the SHARED_LIBRARY variable, then we provide
1056# targets for building them.
1057#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +00001058ifdef SHARED_LIBRARY
1059
Nick Lewycky28c62d22009-02-26 07:44:16 +00001060all-local:: $(LibName.SO)
Reid Spencerf206bd72004-10-22 21:01:56 +00001061
Reid Spencera80f1672005-05-19 00:37:31 +00001062ifdef LINK_LIBS_IN_SHARED
Reid Spencere6458c32006-08-07 23:12:15 +00001063ifdef LOADABLE_MODULE
Chris Lattner7cab3de2006-11-15 21:04:15 +00001064SharedLibKindMessage := "Loadable Module"
Reid Spencere6458c32006-08-07 23:12:15 +00001065else
1066SharedLibKindMessage := "Shared Library"
1067endif
Nick Lewycky28c62d22009-02-26 07:44:16 +00001068$(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(LibDir)/.dir
Reid Spencere6458c32006-08-07 23:12:15 +00001069 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
1070 $(LIBRARYNAME)$(SHLIBEXT)
Nick Lewycky28c62d22009-02-26 07:44:16 +00001071 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
Torok Edwin49db7382009-05-26 19:11:47 +00001072 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
Reid Spencera80f1672005-05-19 00:37:31 +00001073else
Nick Lewycky28c62d22009-02-26 07:44:16 +00001074$(LibName.SO): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001075 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Nick Lewycky28c62d22009-02-26 07:44:16 +00001076 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
Reid Spencera80f1672005-05-19 00:37:31 +00001077endif
Reid Spencer81cd0492004-10-23 20:04:14 +00001078
1079clean-local::
Nick Lewycky28c62d22009-02-26 07:44:16 +00001080ifneq ($(strip $(LibName.SO)),)
1081 -$(Verb) $(RM) -f $(LibName.SO)
Reid Spencer12a3a052004-10-24 07:53:21 +00001082endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001083
Reid Spencera79819d2007-02-06 18:53:14 +00001084ifdef NO_INSTALL
1085install-local::
1086 $(Echo) Install circumvented with NO_INSTALL
1087uninstall-local::
1088 $(Echo) Uninstall circumvented with NO_INSTALL
1089else
Reid Spencerba6a3db2005-01-16 02:20:54 +00001090DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf206bd72004-10-22 21:01:56 +00001091
Reid Spencerbe6a4e92004-10-28 07:57:28 +00001092install-local:: $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +00001093
Nick Lewycky28c62d22009-02-26 07:44:16 +00001094$(DestSharedLib): $(LibName.SO) $(PROJ_libdir)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001095 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Nick Lewycky28c62d22009-02-26 07:44:16 +00001096 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +00001097
Misha Brukman2879c292009-01-08 02:11:55 +00001098uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001099 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001100 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
Reid Spencera79819d2007-02-06 18:53:14 +00001101endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001102endif
1103
Reid Spencer81cd0492004-10-23 20:04:14 +00001104#---------------------------------------------------------
1105# Bytecode Library Targets:
1106# If the user asked for a bytecode library to be built
Misha Brukman2879c292009-01-08 02:11:55 +00001107# with the BYTECODE_LIBRARY variable, then we provide
Reid Spencer81cd0492004-10-23 20:04:14 +00001108# targets for building them.
1109#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +00001110ifdef BYTECODE_LIBRARY
Reid Spencere9fa5442005-02-14 21:54:08 +00001111ifeq ($(strip $(LLVMGCC)),)
Reid Spencer83745dd2005-05-13 18:32:54 +00001112$(warning Bytecode libraries require llvm-gcc which could not be found ****)
Reid Spencere9fa5442005-02-14 21:54:08 +00001113else
Reid Spencerf206bd72004-10-22 21:01:56 +00001114
Reid Spencer32f7e422004-12-02 09:28:21 +00001115all-local:: $(LibName.BCA)
1116
1117ifdef EXPORTED_SYMBOL_FILE
Reid Spencerb63d0c42007-02-09 15:52:07 +00001118BCLinkLib = $(LLVMLD) -L$(CFERuntimeLibDir) \
Chris Lattner11c25cf2006-05-30 16:38:06 +00001119 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer32f7e422004-12-02 09:28:21 +00001120
Reid Spencerb63d0c42007-02-09 15:52:07 +00001121$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +00001122 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +00001123 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
1124 "(internalize)"
Daniel Dunbar8d799c52009-08-28 16:14:46 +00001125 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).internalize $(ObjectsBC)
Reid Spencer85d55ad2004-12-13 03:59:35 +00001126 $(Verb) $(RM) -f $@
Daniel Dunbar8d799c52009-08-28 16:14:46 +00001127 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).internalize.bc
Reid Spencerf206bd72004-10-22 21:01:56 +00001128else
Reid Spenceraeea3cf2004-12-16 07:36:08 +00001129$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +00001130 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +00001131 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencer85d55ad2004-12-13 03:59:35 +00001132 $(Verb) $(RM) -f $@
Reid Spencer32f7e422004-12-02 09:28:21 +00001133 $(Verb) $(LArchive) $@ $(ObjectsBC)
1134
Reid Spencerf206bd72004-10-22 21:01:56 +00001135endif
1136
Reid Spencer81cd0492004-10-23 20:04:14 +00001137clean-local::
Reid Spencer32f7e422004-12-02 09:28:21 +00001138ifneq ($(strip $(LibName.BCA)),)
1139 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencer12a3a052004-10-24 07:53:21 +00001140endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001141
Reid Spencer65086be2004-12-13 07:28:21 +00001142ifdef BYTECODE_DESTINATION
1143BytecodeDestDir := $(BYTECODE_DESTINATION)
1144else
Reid Spencerba6a3db2005-01-16 02:20:54 +00001145BytecodeDestDir := $(PROJ_libdir)
Reid Spencer65086be2004-12-13 07:28:21 +00001146endif
1147
Daniel Dunbarc25ba422009-05-12 05:35:40 +00001148DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).bca
Reid Spencer32f7e422004-12-02 09:28:21 +00001149
Reid Spencerd4bd3752004-12-03 20:08:48 +00001150install-bytecode-local:: $(DestBytecodeLib)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001151
Reid Spencera79819d2007-02-06 18:53:14 +00001152ifdef NO_INSTALL
1153install-local::
1154 $(Echo) Install circumvented with NO_INSTALL
1155uninstall-local::
1156 $(Echo) Uninstall circumvented with NO_INSTALL
1157else
Reid Spencerbe6a4e92004-10-28 07:57:28 +00001158install-local:: $(DestBytecodeLib)
Chris Lattner0c4f4fe2003-08-15 02:18:35 +00001159
Mike Stump35f423e2009-02-12 23:45:11 +00001160$(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
Reid Spencer32f7e422004-12-02 09:28:21 +00001161 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerdcc53752005-02-24 21:36:32 +00001162 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
Reid Spencer12a3a052004-10-24 07:53:21 +00001163
Reid Spencerbe6a4e92004-10-28 07:57:28 +00001164uninstall-local::
Reid Spencer32f7e422004-12-02 09:28:21 +00001165 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001166 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencera79819d2007-02-06 18:53:14 +00001167endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001168endif
Reid Spencere9fa5442005-02-14 21:54:08 +00001169endif
Vikram S. Adve15bd3ad2002-08-02 18:34:12 +00001170
Reid Spencerf88808a2004-10-30 09:19:36 +00001171#---------------------------------------------------------
Chris Lattnereaae8d02009-06-16 23:00:42 +00001172# Library Targets:
1173# If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1174# building an archive.
Reid Spencerf88808a2004-10-30 09:19:36 +00001175#---------------------------------------------------------
Jeffrey Yasskinf750fef2010-02-18 02:36:02 +00001176ifndef NO_BUILD_ARCHIVE
Chris Lattner1b91cbd2005-10-24 02:21:45 +00001177ifndef BUILD_ARCHIVE
Chris Lattnereaae8d02009-06-16 23:00:42 +00001178ifndef LOADABLE_MODULE
1179BUILD_ARCHIVE = 1
Reid Spencera79819d2007-02-06 18:53:14 +00001180endif
Chris Lattner76d98ba2002-07-23 17:56:16 +00001181endif
Jeffrey Yasskinf750fef2010-02-18 02:36:02 +00001182endif
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +00001183
Reid Spencerf88808a2004-10-30 09:19:36 +00001184#---------------------------------------------------------
1185# Archive Library Targets:
Misha Brukman2879c292009-01-08 02:11:55 +00001186# If the user wanted a regular archive library built,
Reid Spencerf88808a2004-10-30 09:19:36 +00001187# then we provide targets for building them.
1188#---------------------------------------------------------
Chris Lattner76d98ba2002-07-23 17:56:16 +00001189ifdef BUILD_ARCHIVE
Chris Lattner76d98ba2002-07-23 17:56:16 +00001190
Reid Spencerf88808a2004-10-30 09:19:36 +00001191all-local:: $(LibName.A)
1192
Reid Spenceraeea3cf2004-12-16 07:36:08 +00001193$(LibName.A): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001194 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001195 -$(Verb) $(RM) -f $@
Bill Wendlingb2f724e2009-01-03 22:46:50 +00001196 $(Verb) $(Archive) $@ $(ObjectsO)
1197 $(Verb) $(Ranlib) $@
Vikram S. Adve20aa62f2002-09-20 14:03:13 +00001198
Reid Spencer81cd0492004-10-23 20:04:14 +00001199clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001200ifneq ($(strip $(LibName.A)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001201 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner2f7c9632001-06-06 20:29:01 +00001202endif
1203
Reid Spencera79819d2007-02-06 18:53:14 +00001204ifdef NO_INSTALL
1205install-local::
1206 $(Echo) Install circumvented with NO_INSTALL
1207uninstall-local::
1208 $(Echo) Uninstall circumvented with NO_INSTALL
1209else
Reid Spencerba6a3db2005-01-16 02:20:54 +00001210DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
Reid Spencer12a3a052004-10-24 07:53:21 +00001211
Reid Spencerbe6a4e92004-10-28 07:57:28 +00001212install-local:: $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +00001213
Mike Stump35f423e2009-02-12 23:45:11 +00001214$(DestArchiveLib): $(LibName.A) $(PROJ_libdir)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001215 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001216 $(Verb) $(MKDIR) $(PROJ_libdir)
Nick Lewycky28c62d22009-02-26 07:44:16 +00001217 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +00001218
Reid Spencerbe6a4e92004-10-28 07:57:28 +00001219uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001220 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001221 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencera79819d2007-02-06 18:53:14 +00001222endif
Reid Spencer12a3a052004-10-24 07:53:21 +00001223endif
1224
1225# endif LIBRARYNAME
Misha Brukman2879c292009-01-08 02:11:55 +00001226endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001227
Reid Spencerdcba7782004-10-24 08:21:04 +00001228###############################################################################
1229# Tool Build Rules: Build executable tool based on TOOLNAME option
1230###############################################################################
1231
Chris Lattner07c7c192001-09-07 22:57:58 +00001232ifdef TOOLNAME
1233
Reid Spencerf88808a2004-10-30 09:19:36 +00001234#---------------------------------------------------------
1235# Set up variables for building a tool.
1236#---------------------------------------------------------
Daniel Dunbar0dd2b812009-11-19 00:14:53 +00001237TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +00001238ifdef EXAMPLE_TOOL
Daniel Dunbar0dd2b812009-11-19 00:14:53 +00001239ToolBuildPath := $(ExmplDir)/$(TOOLEXENAME)
Reid Spencer7e9e0b02004-11-18 10:03:46 +00001240else
Daniel Dunbar0dd2b812009-11-19 00:14:53 +00001241ToolBuildPath := $(ToolDir)/$(TOOLEXENAME)
1242endif
1243
1244# TOOLALIAS is a name to symlink (or copy) the tool to.
1245ifdef TOOLALIAS
1246ifdef EXAMPLE_TOOL
1247ToolAliasBuildPath := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1248else
1249ToolAliasBuildPath := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1250endif
Reid Spencer7e9e0b02004-11-18 10:03:46 +00001251endif
Chris Lattner07c7c192001-09-07 22:57:58 +00001252
Reid Spencerf88808a2004-10-30 09:19:36 +00001253#---------------------------------------------------------
Chris Lattner0f1958092009-02-26 17:47:49 +00001254# Prune Exports
1255#---------------------------------------------------------
1256
1257# If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1258# not exporting all of the weak symbols from the binary. This reduces dyld
1259# startup time by 4x on darwin in some cases.
1260ifdef TOOL_NO_EXPORTS
Anton Korobeynikov90e17e72009-08-18 00:40:33 +00001261ifeq ($(HOST_OS),Darwin)
Chris Lattner869b6bf2009-03-10 17:15:56 +00001262
1263# Tiger tools don't support this.
1264ifneq ($(DARWIN_MAJVERS),4)
Chris Lattner0f1958092009-02-26 17:47:49 +00001265LD.Flags += -Wl,-exported_symbol -Wl,_main
1266endif
Chris Lattner869b6bf2009-03-10 17:15:56 +00001267endif
Chris Lattner0f1958092009-02-26 17:47:49 +00001268
Anton Korobeynikov90e17e72009-08-18 00:40:33 +00001269ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD))
Nick Lewyckyefd3e902009-10-25 03:22:00 +00001270 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
Chris Lattner0f1958092009-02-26 17:47:49 +00001271endif
1272endif
1273
1274
1275#---------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +00001276# Provide targets for building the tools
1277#---------------------------------------------------------
Daniel Dunbar0dd2b812009-11-19 00:14:53 +00001278all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
John Criswell8224df92003-06-27 16:58:44 +00001279
Reid Spencer81cd0492004-10-23 20:04:14 +00001280clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001281ifneq ($(strip $(ToolBuildPath)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001282 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencer12a3a052004-10-24 07:53:21 +00001283endif
Daniel Dunbar0dd2b812009-11-19 00:14:53 +00001284ifneq ($(strip $(ToolAliasBuildPath)),)
1285 -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1286endif
Chris Lattner07c7c192001-09-07 22:57:58 +00001287
Reid Spencer7e9e0b02004-11-18 10:03:46 +00001288ifdef EXAMPLE_TOOL
1289$(ToolBuildPath): $(ExmplDir)/.dir
1290else
1291$(ToolBuildPath): $(ToolDir)/.dir
1292endif
1293
Chris Lattnera5d27b12006-09-04 06:39:52 +00001294$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001295 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Nick Lewycky28c62d22009-02-26 07:44:16 +00001296 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
Reid Spencer10536582006-05-16 06:25:14 +00001297 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001298 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
Misha Brukman2879c292009-01-08 02:11:55 +00001299 $(StripWarnMsg)
Reid Spencer12a3a052004-10-24 07:53:21 +00001300
Daniel Dunbar0dd2b812009-11-19 00:14:53 +00001301ifneq ($(strip $(ToolAliasBuildPath)),)
1302$(ToolAliasBuildPath): $(ToolBuildPath)
1303 $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1304 $(Verb) $(RM) -f $(ToolAliasBuildPath)
1305 $(Verb) $(AliasTool) $(TOOLEXENAME) $(ToolAliasBuildPath)
1306 $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLNAME) \
1307 $(StripWarnMsg)
1308endif
1309
Reid Spencera79819d2007-02-06 18:53:14 +00001310ifdef NO_INSTALL
1311install-local::
1312 $(Echo) Install circumvented with NO_INSTALL
1313uninstall-local::
1314 $(Echo) Uninstall circumvented with NO_INSTALL
1315else
Daniel Dunbar0dd2b812009-11-19 00:14:53 +00001316DestTool = $(PROJ_bindir)/$(TOOLEXENAME)
Reid Spencer12a3a052004-10-24 07:53:21 +00001317
Reid Spencerbe6a4e92004-10-28 07:57:28 +00001318install-local:: $(DestTool)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001319
Mike Stump35f423e2009-02-12 23:45:11 +00001320$(DestTool): $(ToolBuildPath) $(PROJ_bindir)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001321 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencerc43b1d42005-02-24 03:56:32 +00001322 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +00001323
Reid Spencerbe6a4e92004-10-28 07:57:28 +00001324uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001325 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001326 -$(Verb) $(RM) -f $(DestTool)
Daniel Dunbar0dd2b812009-11-19 00:14:53 +00001327
1328# TOOLALIAS install.
1329ifdef TOOLALIAS
1330DestToolAlias = $(PROJ_bindir)/$(TOOLALIAS)$(EXEEXT)
1331
1332install-local:: $(DestToolAlias)
1333
1334$(DestToolAlias): $(DestTool) $(PROJ_bindir)
1335 $(Echo) Installing $(BuildMode) $(DestToolAlias)
1336 $(Verb) $(RM) -f $(DestToolAlias)
1337 $(Verb) $(AliasTool) $(TOOLEXENAME) $(DestToolAlias)
1338
1339uninstall-local::
1340 $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1341 -$(Verb) $(RM) -f $(DestToolAlias)
1342endif
1343
Reid Spencera79819d2007-02-06 18:53:14 +00001344endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001345endif
Chris Lattner07c7c192001-09-07 22:57:58 +00001346
Reid Spencerf88808a2004-10-30 09:19:36 +00001347###############################################################################
Misha Brukman2879c292009-01-08 02:11:55 +00001348# Object Build Rules: Build object files based on sources
Reid Spencerf88808a2004-10-30 09:19:36 +00001349###############################################################################
1350
Duraid Madinacbbc1842006-02-15 03:23:26 +00001351# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
Anton Korobeynikov90e17e72009-08-18 00:40:33 +00001352ifeq ($(HOST_OS),HP-UX)
Duraid Madinacbbc1842006-02-15 03:23:26 +00001353 DISABLE_AUTO_DEPENDENCIES=1
1354endif
1355
Reid Spencerf88808a2004-10-30 09:19:36 +00001356# Provide rule sets for when dependency generation is enabled
Reid Spencerf206bd72004-10-22 21:01:56 +00001357ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve20aa62f2002-09-20 14:03:13 +00001358
Reid Spencerf88808a2004-10-30 09:19:36 +00001359#---------------------------------------------------------
Nick Lewycky28c62d22009-02-26 07:44:16 +00001360# Create .o files in the ObjDir directory from the .cpp and .c files...
Reid Spencerf88808a2004-10-30 09:19:36 +00001361#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001362
Chris Lattnerc23e6352007-12-31 23:58:31 +00001363DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
Nick Lewycky28c62d22009-02-26 07:44:16 +00001364 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
Gabor Greifc848f9e2008-02-27 13:34:15 +00001365
Daniel Dunbar8a28e012009-05-12 06:35:50 +00001366# If the build succeeded, move the dependency file over, otherwise
1367# remove it.
Chris Lattnerc23e6352007-12-31 23:58:31 +00001368DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1369 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1370
Daniel Dunbar99ab0e02010-01-22 18:10:54 +00001371$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
Jakob Stoklund Olesenbefc8532009-10-04 17:54:36 +00001372 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky28c62d22009-02-26 07:44:16 +00001373 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
Chris Lattnerc23e6352007-12-31 23:58:31 +00001374 $(DEPEND_MOVEFILE)
Reid Spencer81cd0492004-10-23 20:04:14 +00001375
Daniel Dunbar99ab0e02010-01-22 18:10:54 +00001376$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
Chris Lattner085c7152006-06-21 20:58:03 +00001377 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky28c62d22009-02-26 07:44:16 +00001378 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
Chris Lattnerc23e6352007-12-31 23:58:31 +00001379 $(DEPEND_MOVEFILE)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001380
Daniel Dunbar99ab0e02010-01-22 18:10:54 +00001381$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_SRC_DIR)/Makefile
Chris Lattner085c7152006-06-21 20:58:03 +00001382 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky28c62d22009-02-26 07:44:16 +00001383 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
Chris Lattnerc23e6352007-12-31 23:58:31 +00001384 $(DEPEND_MOVEFILE)
Reid Spencer81cd0492004-10-23 20:04:14 +00001385
Reid Spencerf88808a2004-10-30 09:19:36 +00001386#---------------------------------------------------------
Chris Lattnerf60c1702005-02-04 21:28:50 +00001387# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
Reid Spencerf88808a2004-10-30 09:19:36 +00001388#---------------------------------------------------------
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001389
Daniel Dunbar8a28e012009-05-12 06:35:50 +00001390BC_DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.bc.d.tmp" \
1391 -MT "$(ObjDir)/$*.ll" -MT "$(ObjDir)/$*.bc.d"
1392
1393# If the build succeeded, move the dependency file over, otherwise
1394# remove it.
1395BC_DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.bc.d.tmp" "$(ObjDir)/$*.bc.d"; \
1396 else $(RM) "$(ObjDir)/$*.bc.d.tmp"; exit 1; fi
1397
Reid Spencer96edbd52006-12-30 16:31:02 +00001398$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001399 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Daniel Dunbar8a28e012009-05-12 06:35:50 +00001400 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1401 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1402 $(BC_DEPEND_MOVEFILE)
Reid Spencerf206bd72004-10-22 21:01:56 +00001403
Reid Spencer96edbd52006-12-30 16:31:02 +00001404$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001405 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Daniel Dunbar8a28e012009-05-12 06:35:50 +00001406 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
1407 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1408 $(BC_DEPEND_MOVEFILE)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001409
Reid Spencer96edbd52006-12-30 16:31:02 +00001410$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001411 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Daniel Dunbar8a28e012009-05-12 06:35:50 +00001412 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
1413 $< -o $(ObjDir)/$*.ll -S -emit-llvm ; \
1414 $(BC_DEPEND_MOVEFILE)
Reid Spencerf206bd72004-10-22 21:01:56 +00001415
Reid Spencerf88808a2004-10-30 09:19:36 +00001416# Provide alternate rule sets if dependencies are disabled
Reid Spencerf206bd72004-10-22 21:01:56 +00001417else
1418
Nick Lewycky28c62d22009-02-26 07:44:16 +00001419$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001420 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky28c62d22009-02-26 07:44:16 +00001421 $(Compile.CXX) $< -o $@
Reid Spencer81cd0492004-10-23 20:04:14 +00001422
Nick Lewycky28c62d22009-02-26 07:44:16 +00001423$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001424 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky28c62d22009-02-26 07:44:16 +00001425 $(Compile.CXX) $< -o $@
Chris Lattnerf60c1702005-02-04 21:28:50 +00001426
Nick Lewycky28c62d22009-02-26 07:44:16 +00001427$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001428 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky28c62d22009-02-26 07:44:16 +00001429 $(Compile.C) $< -o $@
Reid Spencerf206bd72004-10-22 21:01:56 +00001430
Reid Spencer96edbd52006-12-30 16:31:02 +00001431$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001432 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001433 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Reid Spencerf206bd72004-10-22 21:01:56 +00001434
Reid Spencer96edbd52006-12-30 16:31:02 +00001435$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001436 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001437 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Chris Lattnerf60c1702005-02-04 21:28:50 +00001438
Reid Spencer96edbd52006-12-30 16:31:02 +00001439$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001440 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001441 $(BCCompile.C) $< -o $@ -S -emit-llvm
Brian Gaeke0f148bc2003-12-10 00:26:28 +00001442
Chris Lattner07c7c192001-09-07 22:57:58 +00001443endif
1444
Chris Lattner161a84e2006-06-21 21:01:20 +00001445
1446## Rules for building preprocessed (.i/.ii) outputs.
1447$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1448 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1449 $(Verb) $(Preprocess.CXX) $< -o $@
1450
1451$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1452 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1453 $(Verb) $(Preprocess.CXX) $< -o $@
1454
Reid Spencerbef61c52006-12-10 04:56:38 +00001455$(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner161a84e2006-06-21 21:01:20 +00001456 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1457 $(Verb) $(Preprocess.C) $< -o $@
1458
1459
1460$(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1461 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky28c62d22009-02-26 07:44:16 +00001462 $(Compile.CXX) $< -o $@ -S
Chris Lattner161a84e2006-06-21 21:01:20 +00001463
1464$(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1465 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky28c62d22009-02-26 07:44:16 +00001466 $(Compile.CXX) $< -o $@ -S
Chris Lattner161a84e2006-06-21 21:01:20 +00001467
1468$(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1469 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
Nick Lewycky28c62d22009-02-26 07:44:16 +00001470 $(Compile.C) $< -o $@ -S
Chris Lattner161a84e2006-06-21 21:01:20 +00001471
Reid Spencer4b8067f2006-11-17 03:32:33 +00001472
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001473# make the C and C++ compilers strip debug info out of bytecode libraries.
Reid Spencer4b8067f2006-11-17 03:32:33 +00001474ifdef DEBUG_RUNTIME
Dan Gohman40d204f2009-09-08 15:52:56 +00001475$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
Reid Spencer4b8067f2006-11-17 03:32:33 +00001476 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Dan Gohman40d204f2009-09-08 15:52:56 +00001477 $(Verb) $(LOPT) $< -std-compile-opts -o $@
Reid Spencer4b8067f2006-11-17 03:32:33 +00001478else
Dan Gohman40d204f2009-09-08 15:52:56 +00001479$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001480 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Dan Gohman40d204f2009-09-08 15:52:56 +00001481 $(Verb) $(LOPT) $< -std-compile-opts -strip-debug -o $@
Reid Spencer4b8067f2006-11-17 03:32:33 +00001482endif
1483
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001484
Reid Spencerf88808a2004-10-30 09:19:36 +00001485#---------------------------------------------------------
1486# Provide rule to build .bc files from .ll sources,
1487# regardless of dependencies
1488#---------------------------------------------------------
1489$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001490 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +00001491 $(Verb) $(LLVMAS) $< -f -o $@
1492
1493###############################################################################
1494# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1495###############################################################################
Chris Lattner0c4f4fe2003-08-15 02:18:35 +00001496
Reid Spencerf206bd72004-10-22 21:01:56 +00001497ifdef TARGET
Mikhail Glushenkovc6333bd2009-03-02 09:42:59 +00001498TABLEGEN_INC_FILES_COMMON = 1
1499endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001500
Mikhail Glushenkovc6333bd2009-03-02 09:42:59 +00001501ifdef LLVMC_BUILD_AUTOGENERATED_INC
1502TABLEGEN_INC_FILES_COMMON = 1
1503endif
1504
1505ifdef TABLEGEN_INC_FILES_COMMON
1506
Reid Spencerf88808a2004-10-30 09:19:36 +00001507INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Chris Lattner2a023902004-12-16 17:28:50 +00001508INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1509.PRECIOUS: $(INCTMPFiles) $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001510
Misha Brukman2879c292009-01-08 02:11:55 +00001511# INCFiles rule: All of the tblgen generated files are emitted to
Chris Lattnerf86914d2004-12-16 17:38:56 +00001512# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1513# us to only "touch" the real file if the contents of it change. IOW, if
Daniel Dunbard395a172008-11-03 17:33:36 +00001514# tblgen is modified, all of the .inc.tmp files are regenerated, but no
Chris Lattnerf86914d2004-12-16 17:38:56 +00001515# dependencies of the .inc files are, unless the contents of the .inc file
1516# changes.
1517$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
Reid Spencerafdc82c2004-12-16 18:26:53 +00001518 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
Chris Lattner2a023902004-12-16 17:28:50 +00001519
Mikhail Glushenkovc6333bd2009-03-02 09:42:59 +00001520endif # TABLEGEN_INC_FILES_COMMON
1521
1522ifdef TARGET
1523
1524TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1525 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1526 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1527 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1528 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1529 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1530 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1531
Rafael Espindola59e371a2009-03-10 17:58:54 +00001532# All of these files depend on tblgen and the .td files.
1533$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1534
Chris Lattner2a023902004-12-16 17:28:50 +00001535$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1536$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001537 $(Echo) "Building $(<F) register names with tblgen"
Chris Lattner50475362008-01-15 23:27:40 +00001538 $(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001539
Chris Lattner2a023902004-12-16 17:28:50 +00001540$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1541$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001542 $(Echo) "Building $(<F) register information header with tblgen"
Chris Lattner50475362008-01-15 23:27:40 +00001543 $(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001544
Chris Lattner2a023902004-12-16 17:28:50 +00001545$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1546$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001547 $(Echo) "Building $(<F) register info implementation with tblgen"
Chris Lattner50475362008-01-15 23:27:40 +00001548 $(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001549
Chris Lattner2a023902004-12-16 17:28:50 +00001550$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1551$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001552 $(Echo) "Building $(<F) instruction names with tblgen"
Chris Lattner50475362008-01-15 23:27:40 +00001553 $(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001554
Chris Lattner2a023902004-12-16 17:28:50 +00001555$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1556$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001557 $(Echo) "Building $(<F) instruction information with tblgen"
Chris Lattner50475362008-01-15 23:27:40 +00001558 $(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001559
Chris Lattner2a023902004-12-16 17:28:50 +00001560$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1561$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001562 $(Echo) "Building $(<F) assembly writer with tblgen"
Chris Lattner50475362008-01-15 23:27:40 +00001563 $(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001564
Chris Lattner22f937a2004-12-16 17:34:04 +00001565$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1566$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1567 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Misha Brukman2879c292009-01-08 02:11:55 +00001568 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001569
Daniel Dunbar2841ea42009-07-13 18:35:35 +00001570$(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1571$(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir
1572 $(Echo) "Building $(<F) assembly matcher with tblgen"
1573 $(Verb) $(TableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1574
Chris Lattner2a023902004-12-16 17:28:50 +00001575$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1576$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001577 $(Echo) "Building $(<F) code emitter with tblgen"
Chris Lattner50475362008-01-15 23:27:40 +00001578 $(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001579
Chris Lattner33f98bd2005-09-03 01:15:25 +00001580$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1581$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
Dan Gohmanb2226e22008-08-13 20:19:35 +00001582 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
Chris Lattner50475362008-01-15 23:27:40 +00001583 $(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
Chris Lattner33f98bd2005-09-03 01:15:25 +00001584
Daniel Dunbare8b8cce2009-11-25 04:46:58 +00001585$(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1586$(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir
1587 $(Echo) "Building $(<F) disassembly tables with tblgen"
1588 $(Verb) $(TableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1589
Sean Callanan82436d12010-01-29 00:21:04 +00001590$(TARGET:%=$(ObjDir)/%GenEDInfo.inc.tmp): \
1591$(ObjDir)/%GenEDInfo.inc.tmp : %.td $(ObjDir)/.dir
1592 $(Echo) "Building $(<F) enhanced disassembly information with tblgen"
1593 $(Verb) $(TableGen) -gen-enhanced-disassembly-info -o $(call SYSPATH, $@) $<
1594
Dan Gohmanb2226e22008-08-13 20:19:35 +00001595$(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1596$(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
1597 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1598 $(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1599
Jim Laskey9ed90322005-10-21 19:05:19 +00001600$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1601$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1602 $(Echo) "Building $(<F) subtarget information with tblgen"
Chris Lattner50475362008-01-15 23:27:40 +00001603 $(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
Chris Lattner33f98bd2005-09-03 01:15:25 +00001604
Chris Lattneree0fe3b2007-02-27 20:44:12 +00001605$(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1606$(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1607 $(Echo) "Building $(<F) calling convention information with tblgen"
Chris Lattner50475362008-01-15 23:27:40 +00001608 $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
Chris Lattneree0fe3b2007-02-27 20:44:12 +00001609
Dale Johannesenb842d522009-02-05 01:49:45 +00001610$(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
Jakob Stoklund Olesen79843052009-10-15 18:48:47 +00001611$(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir
1612 $(Echo) "Building $(<F) intrinsics information with tblgen"
Dale Johannesenb842d522009-02-05 01:49:45 +00001613 $(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1614
Reid Spencer81cd0492004-10-23 20:04:14 +00001615clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001616 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001617
Mikhail Glushenkovc6333bd2009-03-02 09:42:59 +00001618endif # TARGET
1619
1620ifdef LLVMC_BUILD_AUTOGENERATED_INC
1621
Mikhail Glushenkov2c332fe2009-04-21 19:46:10 +00001622LLVMCPluginSrc := $(sort $(strip $(wildcard $(PROJ_SRC_DIR)/*.td)) \
1623 $(strip $(wildcard $(PROJ_OBJ_DIR)/*.td)))
Mikhail Glushenkovc6333bd2009-03-02 09:42:59 +00001624
1625TDFiles := $(LLVMCPluginSrc) \
1626 $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
1627
1628$(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
1629 $(TBLGEN) $(TD_COMMON)
1630 $(Echo) "Building LLVMC configuration library with tblgen"
1631 $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
1632
1633endif # LLVMC_BUILD_AUTOGENERATED_INC
1634
Reid Spencerf88808a2004-10-30 09:19:36 +00001635###############################################################################
Reid Spencerf88808a2004-10-30 09:19:36 +00001636# OTHER RULES: Other rules needed
1637###############################################################################
Reid Spencerf206bd72004-10-22 21:01:56 +00001638
Chris Lattner23d47392003-01-16 21:06:18 +00001639# To create postscript files from dot files...
John Criswell4ffb8442003-10-02 19:02:02 +00001640ifneq ($(DOT),false)
Chris Lattner23d47392003-01-16 21:06:18 +00001641%.ps: %.dot
Reid Spencerf206bd72004-10-22 21:01:56 +00001642 $(DOT) -Tps < $< > $@
John Criswell3ef61af2003-06-30 21:59:07 +00001643else
1644%.ps: %.dot
Reid Spencerf88808a2004-10-30 09:19:36 +00001645 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell3ef61af2003-06-30 21:59:07 +00001646endif
Chris Lattner23d47392003-01-16 21:06:18 +00001647
John Criswell0a6e6aa2003-09-06 14:44:17 +00001648# This rules ensures that header files that are removed still have a rule for
1649# which they can be "generated." This allows make to ignore them and
1650# reproduce the dependency lists.
John Criswella8391af2003-09-18 18:37:08 +00001651%.h:: ;
Chris Lattnerf60c1702005-02-04 21:28:50 +00001652%.hpp:: ;
John Criswell0a6e6aa2003-09-06 14:44:17 +00001653
Reid Spencerf88808a2004-10-30 09:19:36 +00001654# Define clean-local to clean the current directory. Note that this uses a
Misha Brukman2879c292009-01-08 02:11:55 +00001655# very conservative approach ensuring that empty variables do not cause
Reid Spencerf88808a2004-10-30 09:19:36 +00001656# errors or disastrous removal.
Reid Spencer81cd0492004-10-23 20:04:14 +00001657clean-local::
Jim Grosbach009db892008-10-02 22:56:44 +00001658ifneq ($(strip $(ObjRootDir)),)
1659 -$(Verb) $(RM) -rf $(ObjRootDir)
Reid Spencer12a3a052004-10-24 07:53:21 +00001660endif
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001661 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke8625f682004-01-21 19:53:11 +00001662ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001663 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke8625f682004-01-21 19:53:11 +00001664endif
John Criswell3ef61af2003-06-30 21:59:07 +00001665
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001666clean-all-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001667 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001668
Reid Spenceraee67e62004-11-12 02:27:36 +00001669
Reid Spencer81cd0492004-10-23 20:04:14 +00001670###############################################################################
1671# DEPENDENCIES: Include the dependency files if we should
1672###############################################################################
Chris Lattnere9d7d702003-08-22 14:10:16 +00001673ifndef DISABLE_AUTO_DEPENDENCIES
1674
Reid Spencer81cd0492004-10-23 20:04:14 +00001675# If its not one of the cleaning targets
Daniel Dunbar78caa022008-10-03 19:11:19 +00001676ifndef IS_CLEANING_TARGET
Reid Spencerf206bd72004-10-22 21:01:56 +00001677
Reid Spencer81cd0492004-10-23 20:04:14 +00001678# Get the list of dependency files
Daniel Dunbar8a28e012009-05-12 06:35:50 +00001679DependSourceFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
1680DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1681
1682# Include bitcode dependency files if using bitcode libraries
1683ifdef BYTECODE_LIBRARY
1684DependFiles += $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
1685endif
Misha Brukmanb891ffb2003-11-09 21:36:19 +00001686
Reid Spencerfcd78152007-07-23 08:20:46 +00001687-include $(DependFiles) ""
Reid Spencer81cd0492004-10-23 20:04:14 +00001688
John Criswell48ecca62003-08-12 18:51:51 +00001689endif
Chris Lattner598222b2003-08-18 17:27:40 +00001690
Misha Brukman2879c292009-01-08 02:11:55 +00001691endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001692
Reid Spencer100080c2004-10-25 08:27:37 +00001693###############################################################################
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001694# CHECK: Running the test suite
1695###############################################################################
1696
Bill Wendlingf704f902009-04-09 18:26:57 +00001697check::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001698 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1699 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001700 $(EchoCmd) Running test suite ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001701 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001702 TESTSUITE=$(TESTSUITE) ; \
1703 else \
1704 $(EchoCmd) No Makefile in test directory ; \
1705 fi ; \
1706 else \
1707 $(EchoCmd) No test directory ; \
1708 fi
1709
Daniel Dunbar3eeddd22009-09-08 05:31:44 +00001710check-lit::
1711 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1712 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1713 $(EchoCmd) Running test suite ; \
1714 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-lit ; \
1715 else \
1716 $(EchoCmd) No Makefile in test directory ; \
1717 fi ; \
1718 else \
1719 $(EchoCmd) No test directory ; \
1720 fi
1721
Daniel Dunbarf2719e62009-09-20 06:17:21 +00001722check-all::
1723 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1724 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1725 $(EchoCmd) Running test suite ; \
1726 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1727 else \
1728 $(EchoCmd) No Makefile in test directory ; \
1729 fi ; \
1730 else \
1731 $(EchoCmd) No test directory ; \
1732 fi
1733
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001734###############################################################################
Bill Wendling8790e322009-01-04 23:12:21 +00001735# UNITTESTS: Running the unittests test suite
1736###############################################################################
1737
Bill Wendlingf704f902009-04-09 18:26:57 +00001738unittests::
Bill Wendling8790e322009-01-04 23:12:21 +00001739 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1740 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1741 $(EchoCmd) Running unittests test suite ; \
Daniel Dunbar96ccc472009-09-13 22:39:27 +00001742 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
Bill Wendling8790e322009-01-04 23:12:21 +00001743 else \
1744 $(EchoCmd) No Makefile in unittests directory ; \
1745 fi ; \
1746 else \
1747 $(EchoCmd) No unittests directory ; \
1748 fi
1749
1750###############################################################################
Reid Spencerf88808a2004-10-30 09:19:36 +00001751# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer100080c2004-10-25 08:27:37 +00001752###############################################################################
1753
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001754#------------------------------------------------------------------------
1755# Define distribution related variables
1756#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +00001757DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1758DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1759TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1760DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1761DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1762DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
Reid Spencer100080c2004-10-25 08:27:37 +00001763DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1764 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001765 Makefile.config.in configure autoconf
1766DistOther := $(notdir $(wildcard \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001767 $(PROJ_SRC_DIR)/*.h \
1768 $(PROJ_SRC_DIR)/*.td \
1769 $(PROJ_SRC_DIR)/*.def \
1770 $(PROJ_SRC_DIR)/*.ll \
1771 $(PROJ_SRC_DIR)/*.in))
Reid Spencerf88808a2004-10-30 09:19:36 +00001772DistSubDirs := $(SubDirs)
Reid Spencerfc66af42004-11-29 05:00:33 +00001773DistSources = $(Sources) $(EXTRA_DIST)
1774DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer100080c2004-10-25 08:27:37 +00001775
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001776#------------------------------------------------------------------------
1777# We MUST build distribution with OBJ_DIR != SRC_DIR
1778#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +00001779ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001780dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerf88808a2004-10-30 09:19:36 +00001781 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001782
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001783else
1784
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001785#------------------------------------------------------------------------
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001786# Prevent attempt to run dist targets from anywhere but the top level
1787#------------------------------------------------------------------------
1788ifneq ($(LEVEL),.)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001789dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001790 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001791else
1792
1793#------------------------------------------------------------------------
1794# Provide the top level targets
1795#------------------------------------------------------------------------
1796
Reid Spencerf88808a2004-10-30 09:19:36 +00001797dist-gzip:: $(DistTarGZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001798
Reid Spencer81546582004-12-04 22:34:09 +00001799$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001800 $(Echo) Packing gzipped distribution tar file.
Reid Spencerba6a3db2005-01-16 02:20:54 +00001801 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
Reid Spencerfc66af42004-11-29 05:00:33 +00001802 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001803
Reid Spencerf88808a2004-10-30 09:19:36 +00001804dist-bzip2:: $(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001805
Reid Spencer81546582004-12-04 22:34:09 +00001806$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001807 $(Echo) Packing bzipped distribution tar file.
Reid Spencerba6a3db2005-01-16 02:20:54 +00001808 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
Reid Spencerfc66af42004-11-29 05:00:33 +00001809 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001810
Reid Spencerf88808a2004-10-30 09:19:36 +00001811dist-zip:: $(DistZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001812
Reid Spencer81546582004-12-04 22:34:09 +00001813$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001814 $(Echo) Packing zipped distribution file.
1815 $(Verb) rm -f $(DistZip)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001816 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001817
Misha Brukman2879c292009-01-08 02:11:55 +00001818dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001819 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001820
Reid Spencer3a468752005-01-28 19:52:32 +00001821DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001822
Reid Spencer81546582004-12-04 22:34:09 +00001823dist-check:: $(DistTarGZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001824 $(Echo) Checking distribution tar file.
1825 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001826 $(RM) -rf $(DistCheckDir) ; \
1827 fi
Reid Spencerf88808a2004-10-30 09:19:36 +00001828 $(Verb) $(MKDIR) $(DistCheckDir)
1829 $(Verb) cd $(DistCheckDir) && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001830 $(MKDIR) $(DistCheckDir)/build && \
1831 $(MKDIR) $(DistCheckDir)/install && \
1832 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1833 cd build && \
1834 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
Reid Spencer13f51932005-05-24 02:33:20 +00001835 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
Reid Spencer81546582004-12-04 22:34:09 +00001836 $(MAKE) all && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001837 $(MAKE) check && \
Bill Wendling8790e322009-01-04 23:12:21 +00001838 $(MAKE) unittests && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001839 $(MAKE) install && \
1840 $(MAKE) uninstall && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001841 $(MAKE) dist-clean && \
Reid Spencerf88808a2004-10-30 09:19:36 +00001842 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001843
1844dist-clean::
Reid Spencerf88808a2004-10-30 09:19:36 +00001845 $(Echo) Cleaning distribution files
Reid Spencer81546582004-12-04 22:34:09 +00001846 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1847 $(DistCheckDir)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001848
1849endif
1850
1851#------------------------------------------------------------------------
1852# Provide the recursive distdir target for building the distribution directory
1853#------------------------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +00001854distdir: $(DistDir)/.makedistdir
1855$(DistDir)/.makedistdir: $(DistSources)
Reid Spencerf88808a2004-10-30 09:19:36 +00001856 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001857 if test -d "$(DistDir)" ; then \
1858 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1859 exit 1 ; \
1860 fi ; \
Reid Spencer81546582004-12-04 22:34:09 +00001861 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001862 $(RM) -rf $(DistDir); \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001863 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer15b85092006-04-10 16:46:04 +00001864 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001865 fi
Reid Spencerfc66af42004-11-29 05:00:33 +00001866 $(Echo) Building Distribution Directory $(DistDir)
Misha Brukman2879c292009-01-08 02:11:55 +00001867 $(Verb) $(MKDIR) $(DistDir)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001868 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1869 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
Reid Spencer100080c2004-10-25 08:27:37 +00001870 for file in $(DistFiles) ; do \
1871 case "$$file" in \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001872 $(PROJ_SRC_DIR)/*) \
Reid Spencer81546582004-12-04 22:34:09 +00001873 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1874 ;; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001875 $(PROJ_SRC_ROOT)/*) \
Reid Spencer81546582004-12-04 22:34:09 +00001876 file=`echo "$$file" | \
1877 sed "s#^$$srcrootstrip/##"` \
1878 ;; \
Reid Spencer100080c2004-10-25 08:27:37 +00001879 esac; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001880 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1881 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1882 from_dir="$(PROJ_SRC_DIR)" ; \
Reid Spencer81546582004-12-04 22:34:09 +00001883 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001884 from_dir=. ; \
Reid Spencer81546582004-12-04 22:34:09 +00001885 fi ; \
1886 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001887 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1888 to_dir="$(DistDir)/$$dir"; \
1889 $(MKDIR) "$$to_dir" ; \
1890 else \
1891 to_dir="$(DistDir)"; \
1892 fi; \
1893 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1894 if test -n "$$mid_dir" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001895 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001896 fi ; \
1897 if test -d "$$from_dir/$$file"; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001898 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1899 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
Reid Spencer13f51932005-05-24 02:33:20 +00001900 cd $(PROJ_SRC_DIR) ; \
1901 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1902 ( cd $$to_dir ; $(TAR) xf - ) ; \
1903 cd $(PROJ_OBJ_DIR) ; \
1904 else \
1905 cd $$from_dir ; \
1906 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1907 ( cd $$to_dir ; $(TAR) xf - ) ; \
1908 cd $(PROJ_OBJ_DIR) ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001909 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +00001910 elif test -f "$$from_dir/$$file" ; then \
Reid Spencerafdc82c2004-12-16 18:26:53 +00001911 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001912 elif test -L "$$from_dir/$$file" ; then \
Reid Spencerafdc82c2004-12-16 18:26:53 +00001913 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001914 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer81546582004-12-04 22:34:09 +00001915 $(EchoCmd) "===== WARNING: Distribution Source " \
1916 "$$from_dir/$$file Not Found!" ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001917 elif test "$(Verb)" != '@' ; then \
1918 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001919 fi; \
1920 done
Reid Spencerf88808a2004-10-30 09:19:36 +00001921 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer100080c2004-10-25 08:27:37 +00001922 if test "$$subdir" \!= "." ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001923 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001924 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer15b85092006-04-10 16:46:04 +00001925 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
Reid Spencer056f0222006-04-07 16:06:18 +00001926 DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001927 fi; \
1928 done
Reid Spencer81546582004-12-04 22:34:09 +00001929 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer13f51932005-05-24 02:33:20 +00001930 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
Chris Lattnerb8e7aa02006-02-14 04:27:15 +00001931 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1932 -name .svn \) -print` ;\
Reid Spencer81546582004-12-04 22:34:09 +00001933 $(MAKE) dist-hook ; \
1934 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1935 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1936 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1937 -o ! -type d ! -perm -444 -exec \
1938 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1939 || chmod -R a+r $(DistDir) ; \
1940 fi
Reid Spencer100080c2004-10-25 08:27:37 +00001941
Reid Spencerf88808a2004-10-30 09:19:36 +00001942# This is invoked by distdir target, define it as a no-op to avoid errors if not
1943# defined by user.
Reid Spencer100080c2004-10-25 08:27:37 +00001944dist-hook::
1945
Reid Spencer23a70372004-10-22 23:06:30 +00001946endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001947
1948###############################################################################
Reid Spencer12a3a052004-10-24 07:53:21 +00001949# TOP LEVEL - targets only to apply at the top level directory
1950###############################################################################
1951
1952ifeq ($(LEVEL),.)
1953
1954#------------------------------------------------------------------------
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001955# Install support for the project's include files:
Reid Spencer12a3a052004-10-24 07:53:21 +00001956#------------------------------------------------------------------------
Reid Spencera79819d2007-02-06 18:53:14 +00001957ifdef NO_INSTALL
1958install-local::
1959 $(Echo) Install circumvented with NO_INSTALL
1960uninstall-local::
1961 $(Echo) Uninstall circumvented with NO_INSTALL
1962else
Reid Spencer12a3a052004-10-24 07:53:21 +00001963install-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001964 $(Echo) Installing include files
Reid Spencerba6a3db2005-01-16 02:20:54 +00001965 $(Verb) $(MKDIR) $(PROJ_includedir)
Reid Spencerc43b1d42005-02-24 03:56:32 +00001966 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001967 cd $(PROJ_SRC_ROOT)/include && \
Chris Lattner814d9ee2009-01-02 07:16:45 +00001968 for hdr in `find . -type f '!' '(' -name '*~' \
Reid Spencerc82c2cf2007-04-09 19:08:58 +00001969 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
1970 grep -v .svn` ; do \
Reid Spencerc43b1d42005-02-24 03:56:32 +00001971 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1972 if test \! -d "$$instdir" ; then \
1973 $(EchoCmd) Making install directory $$instdir ; \
1974 $(MKDIR) $$instdir ;\
1975 fi ; \
1976 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer48a82f42005-02-16 15:54:03 +00001977 done ; \
Reid Spencer12a3a052004-10-24 07:53:21 +00001978 fi
Reid Spencer528c9802005-12-23 22:27:56 +00001979ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencerc43b1d42005-02-24 03:56:32 +00001980 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
Reid Spencer48a82f42005-02-16 15:54:03 +00001981 cd $(PROJ_OBJ_ROOT)/include && \
Reid Spencer528c9802005-12-23 22:27:56 +00001982 for hdr in `find . -type f -print | grep -v CVS` ; do \
Reid Spencerc43b1d42005-02-24 03:56:32 +00001983 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer48a82f42005-02-16 15:54:03 +00001984 done ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001985 fi
Reid Spencer528c9802005-12-23 22:27:56 +00001986endif
Reid Spencer12a3a052004-10-24 07:53:21 +00001987
1988uninstall-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001989 $(Echo) Uninstalling include files
Reid Spencerba6a3db2005-01-16 02:20:54 +00001990 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1991 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer12a3a052004-10-24 07:53:21 +00001992 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
Chris Lattner814d9ee2009-01-02 07:16:45 +00001993 '!' '(' -name '*~' -o -name '.#*' \
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001994 -o -name '*.in' ')' -print ')' | \
1995 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001996 cd $(PROJ_SRC_ROOT)/include && \
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001997 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1998 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001999 fi
Reid Spencera79819d2007-02-06 18:53:14 +00002000endif
Reid Spencer12a3a052004-10-24 07:53:21 +00002001endif
2002
Chris Lattnerf8adf7a2007-04-14 23:35:45 +00002003check-line-length:
Gabor Greif697e94c2008-05-15 10:04:30 +00002004 @echo searching for overlength lines in files: $(Sources)
2005 @echo
2006 @echo
Gabor Greif2dd54ed2008-08-28 22:32:39 +00002007 egrep -n '.{81}' $(Sources) /dev/null
Chris Lattnerf8adf7a2007-04-14 23:35:45 +00002008
Anton Korobeynikovfb801512007-04-16 18:10:23 +00002009check-for-tabs:
Gabor Greif697e94c2008-05-15 10:04:30 +00002010 @echo searching for tabs in files: $(Sources)
2011 @echo
2012 @echo
Gabor Greif2dd54ed2008-08-28 22:32:39 +00002013 egrep -n ' ' $(Sources) /dev/null
Gabor Greif697e94c2008-05-15 10:04:30 +00002014
Reid Spencere6bc2062007-05-02 21:29:39 +00002015check-footprint:
2016 @ls -l $(LibDir) | awk '\
2017 BEGIN { sum = 0; } \
2018 { sum += $$5; } \
2019 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2020 @ls -l $(ToolDir) | awk '\
2021 BEGIN { sum = 0; } \
2022 { sum += $$5; } \
2023 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
Reid Spencerf206bd72004-10-22 21:01:56 +00002024#------------------------------------------------------------------------
2025# Print out the directories used for building
Reid Spencerf88808a2004-10-30 09:19:36 +00002026#------------------------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00002027printvars::
Reid Spencerba6a3db2005-01-16 02:20:54 +00002028 $(Echo) "BuildMode : " '$(BuildMode)'
2029 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
2030 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
2031 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
2032 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
2033 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
2034 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
2035 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
2036 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
2037 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
2038 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
Reid Spencerfe0a01e2005-02-16 16:13:02 +00002039 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
Reid Spencerba6a3db2005-01-16 02:20:54 +00002040 $(Echo) "UserTargets : " '$(UserTargets)'
2041 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
2042 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
2043 $(Echo) "ObjDir : " '$(ObjDir)'
2044 $(Echo) "LibDir : " '$(LibDir)'
2045 $(Echo) "ToolDir : " '$(ToolDir)'
2046 $(Echo) "ExmplDir : " '$(ExmplDir)'
2047 $(Echo) "Sources : " '$(Sources)'
2048 $(Echo) "TDFiles : " '$(TDFiles)'
2049 $(Echo) "INCFiles : " '$(INCFiles)'
2050 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
Reid Spencerfefb9ea2005-03-01 16:27:06 +00002051 $(Echo) "PreConditions: " '$(PreConditions)'
Reid Spencerba6a3db2005-01-16 02:20:54 +00002052 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
2053 $(Echo) "Compile.C : " '$(Compile.C)'
2054 $(Echo) "Archive : " '$(Archive)'
2055 $(Echo) "YaccFiles : " '$(YaccFiles)'
2056 $(Echo) "LexFiles : " '$(LexFiles)'
2057 $(Echo) "Module : " '$(Module)'
Reid Spencerb48e3f82005-08-24 10:43:10 +00002058 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
Reid Spencerece13582006-04-09 23:41:14 +00002059 $(Echo) "SubDirs : " '$(SubDirs)'
Reid Spencer200c6f92007-03-29 19:05:44 +00002060 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
2061 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
Daniel Dunbar0094e342009-02-21 20:42:39 +00002062
2063###
2064# Debugging
2065
Daniel Dunbar3b3c3f02009-03-06 22:23:25 +00002066# General debugging rule, use 'make dbg-print-XXX' to print the
Daniel Dunbar0094e342009-02-21 20:42:39 +00002067# definition, value and origin of XXX.
Daniel Dunbar3b3c3f02009-03-06 22:23:25 +00002068make-print-%:
Daniel Dunbar0094e342009-02-21 20:42:39 +00002069 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))