blob: eab886190cce6deb3a9cf9fe571fb7ea4dd37037 [file] [log] [blame]
Misha Brukman6d5ab862004-04-24 00:10:56 +00001#===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
2#
John Criswelld8846c12003-10-21 14:33:46 +00003# The LLVM Compiler Infrastructure
4#
Chris Lattner57360d12007-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 Brukmanef5dc702009-01-08 02:11:55 +00007#
Misha Brukman6d5ab862004-04-24 00:10:56 +00008#===------------------------------------------------------------------------===#
Chris Lattner00950542001-06-06 20:29:01 +00009#
Reid Spencer3a561f52004-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 Lattneraf06a082003-08-15 03:02:52 +000012#
Chris Lattner77efe272006-02-14 04:27:15 +000013#===-----------------------------------------------------------------------====#
Chris Lattner00950542001-06-06 20:29:01 +000014
Reid Spencercc2d1e22004-10-30 09:19:36 +000015################################################################################
Reid Spencer3a561f52004-10-23 20:04:14 +000016# TARGETS: Define standard targets that can be invoked
Reid Spencercc2d1e22004-10-30 09:19:36 +000017################################################################################
John Criswell7a73b802003-06-30 21:59:07 +000018
Chris Lattner00950542001-06-06 20:29:01 +000019#--------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +000020# Define the various target sets
21#--------------------------------------------------------------------
Daniel Dunbar7f068f42009-09-13 22:39:27 +000022RecursiveTargets := all clean clean-all install uninstall install-bytecode \
23 unitcheck
Reid Spencer9e8d54a2004-12-06 05:35:13 +000024LocalTargets := all-local clean-local clean-all-local check-local \
Reid Spencer44cb1b32004-12-03 20:08:48 +000025 install-local printvars uninstall-local \
Daniel Dunbar7f068f42009-09-13 22:39:27 +000026 install-bytecode-local
Chris Lattner72e46332007-09-26 06:10:47 +000027TopLevelTargets := check dist dist-check dist-clean dist-gzip dist-bzip2 \
Bill Wendling4113bd12009-01-04 23:12:21 +000028 dist-zip unittests
Reid Spencercc2d1e22004-10-30 09:19:36 +000029UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
30InternalTargets := preconditions distdir dist-hook
Reid Spencer3a561f52004-10-23 20:04:14 +000031
Reid Spencercc2d1e22004-10-30 09:19:36 +000032################################################################################
Reid Spencer9411c642004-10-26 22:26:33 +000033# INITIALIZATION: Basic things the makefile needs
Reid Spencercc2d1e22004-10-30 09:19:36 +000034################################################################################
35
36#--------------------------------------------------------------------
37# Set the VPATH so that we can find source files.
38#--------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +000039VPATH=$(PROJ_SRC_DIR)
Reid Spencer9411c642004-10-26 22:26:33 +000040
41#--------------------------------------------------------------------
Reid Spencer1abd46d2007-06-29 14:02:07 +000042# Reset the list of suffixes we know how to build.
Reid Spencer9411c642004-10-26 22:26:33 +000043#--------------------------------------------------------------------
44.SUFFIXES:
Greg Clayton43bc79a2010-07-13 18:47:09 +000045.SUFFIXES: .c .cpp .cc .h .hpp .o .a .bc .td .ps .dot .ll .m .mm
Reid Spencercc2d1e22004-10-30 09:19:36 +000046.SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
Reid Spencer9411c642004-10-26 22:26:33 +000047
Reid Spencer3a561f52004-10-23 20:04:14 +000048#--------------------------------------------------------------------
49# Mark all of these targets as phony to avoid implicit rule search
50#--------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000051.PHONY: $(UserTargets) $(InternalTargets)
Reid Spencer3a561f52004-10-23 20:04:14 +000052
53#--------------------------------------------------------------------
Misha Brukmanef5dc702009-01-08 02:11:55 +000054# Make sure all the user-target rules are double colon rules and
Reid Spencer9411c642004-10-26 22:26:33 +000055# they are defined first.
Reid Spencer3a561f52004-10-23 20:04:14 +000056#--------------------------------------------------------------------
57
Reid Spencercc2d1e22004-10-30 09:19:36 +000058$(UserTargets)::
Reid Spencer151f8ba2004-10-25 08:27:37 +000059
Reid Spencer9411c642004-10-26 22:26:33 +000060################################################################################
61# PRECONDITIONS: that which must be built/checked first
62################################################################################
63
Reid Spencer44cb1b32004-12-03 20:08:48 +000064SrcMakefiles := $(filter %Makefile %Makefile.tests,\
Reid Spencer11fde542005-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 Lattner0a1db822006-09-04 05:23:20 +000077
Reid Spencer11fde542005-01-16 02:20:54 +000078ifneq ($(MakefileConfigIn),)
79PreConditions += $(MakefileConfig)
80endif
Reid Spencer9411c642004-10-26 22:26:33 +000081
Reid Spencerca739c62005-08-25 04:59:49 +000082preconditions: $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +000083
84#------------------------------------------------------------------------
85# Make sure the BUILT_SOURCES are built first
86#------------------------------------------------------------------------
Reid Spencer07a549a2004-12-16 07:15:16 +000087$(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000088
Reid Spencer9bb399c2007-02-07 19:13:19 +000089clean-all-local::
Reid Spencer9411c642004-10-26 22:26:33 +000090ifneq ($(strip $(BUILT_SOURCES)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +000091 -$(Verb) $(RM) -f $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000092endif
93
Reid Spencer11fde542005-01-16 02:20:54 +000094ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
Reid Spencer31f95242004-12-16 08:00:46 +000095spotless:
Reid Spencer31f95242004-12-16 08:00:46 +000096 $(Verb) if test -x config.status ; then \
Reid Spencer11fde542005-01-16 02:20:54 +000097 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
Reid Spencer39b73632004-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 Spencer31f95242004-12-16 08:00:46 +0000102 $(RM) -rf * ; \
Reid Spencer39b73632004-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 Spencer11fde542005-01-16 02:20:54 +0000107 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
Reid Spencer39b73632004-12-17 07:45:03 +0000108 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
109 $(ConfigStatusScript) ; \
Reid Spencer31f95242004-12-16 08:00:46 +0000110 else \
Reid Spencer11fde542005-01-16 02:20:54 +0000111 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
Reid Spencer31f95242004-12-16 08:00:46 +0000112 fi
Reid Spencer25e8a702005-12-21 23:17:06 +0000113else
114spotless:
115 $(EchoCmd) "spotless target not supported for objdir == srcdir"
Reid Spencer31f95242004-12-16 08:00:46 +0000116endif
117
Reid Spencercc2d1e22004-10-30 09:19:36 +0000118$(BUILT_SOURCES) : $(ObjMakefiles)
Reid Spencer80f0ef72004-10-28 00:41:43 +0000119
Reid Spencer9411c642004-10-26 22:26:33 +0000120#------------------------------------------------------------------------
121# Make sure we're not using a stale configuration
122#------------------------------------------------------------------------
Reid Spencerc3719842004-12-16 18:26:53 +0000123reconfigure:
Reid Spencer11fde542005-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 Spencer32924e02004-12-24 03:36:31 +0000128 fi ; \
Reid Spencerc3719842004-12-16 18:26:53 +0000129 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
130 $(ConfigStatusScript)
131
Reid Spencercc2d1e22004-10-30 09:19:36 +0000132.PRECIOUS: $(ConfigStatusScript)
Jim Grosbache5e2c412010-10-01 22:32:12 +0000133$(ConfigStatusScript): $(ConfigureScript)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000134 $(Echo) Reconfiguring with $<
Reid Spencer11fde542005-01-16 02:20:54 +0000135 $(Verb) cd $(PROJ_OBJ_ROOT) && \
136 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
137 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
Reid Spencer32924e02004-12-24 03:36:31 +0000138 fi ; \
Reid Spencer7d277002004-11-29 12:37:44 +0000139 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
140 $(ConfigStatusScript)
Reid Spencer9411c642004-10-26 22:26:33 +0000141
Reid Spencer6f5f8b32005-08-25 04:44:18 +0000142#------------------------------------------------------------------------
Reid Spencer9411c642004-10-26 22:26:33 +0000143# Make sure the configuration makefile is up to date
144#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +0000145ifneq ($(MakefileConfigIn),)
146$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000147 $(Echo) Regenerating $@
Reid Spencer11fde542005-01-16 02:20:54 +0000148 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
149endif
150
151ifneq ($(MakefileCommonIn),)
152$(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
153 $(Echo) Regenerating $@
154 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
155endif
Reid Spencer9411c642004-10-26 22:26:33 +0000156
157#------------------------------------------------------------------------
158# If the Makefile in the source tree has been updated, copy it over into the
159# build tree. But, only do this if the source and object makefiles differ
160#------------------------------------------------------------------------
Daniel Dunbar9ae4ca62010-09-09 17:38:11 +0000161ifndef PROJ_MAKEFILE
162PROJ_MAKEFILE := $(PROJ_SRC_DIR)/Makefile
163endif
164
Reid Spencer11fde542005-01-16 02:20:54 +0000165ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
Reid Spencer9411c642004-10-26 22:26:33 +0000166
Daniel Dunbar9ae4ca62010-09-09 17:38:11 +0000167Makefile: $(PROJ_MAKEFILE) $(ExtraMakefiles)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000168 $(Echo) "Updating Makefile"
169 $(Verb) $(MKDIR) $(@D)
Reid Spencerc3719842004-12-16 18:26:53 +0000170 $(Verb) $(CP) -f $< $@
Reid Spencer9411c642004-10-26 22:26:33 +0000171
172# Copy the Makefile.* files unless we're in the root directory which avoids
173# the copying of Makefile.config.in or other things that should be explicitly
174# taken care of.
Daniel Dunbar9ae4ca62010-09-09 17:38:11 +0000175$(PROJ_OBJ_DIR)/Makefile% : $(PROJ_MAKEFILE)%
Reid Spencer86606782004-10-26 23:10:00 +0000176 @case '$?' in \
177 *Makefile.rules) ;; \
178 *.in) ;; \
Gordon Henriksen7252dc02008-03-10 15:58:40 +0000179 *) $(EchoCmd) "Updating $(@F)" ; \
Reid Spencer86606782004-10-26 23:10:00 +0000180 $(MKDIR) $(@D) ; \
Reid Spencerc3719842004-12-16 18:26:53 +0000181 $(CP) -f $< $@ ;; \
Reid Spencer86606782004-10-26 23:10:00 +0000182 esac
Gabor Greif0a4c3782008-02-27 13:34:15 +0000183
Reid Spencer9411c642004-10-26 22:26:33 +0000184endif
185
186#------------------------------------------------------------------------
187# Set up the basic dependencies
188#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000189$(UserTargets):: $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +0000190
191all:: all-local
Anton Korobeynikov569c45c2008-11-10 07:33:13 +0000192clean:: clean-local
Reid Spencer3d659492004-11-02 16:36:03 +0000193clean-all:: clean-local clean-all-local
Reid Spencer9411c642004-10-26 22:26:33 +0000194install:: install-local
195uninstall:: uninstall-local
Misha Brukmanef5dc702009-01-08 02:11:55 +0000196install-local:: all-local
Reid Spencer44cb1b32004-12-03 20:08:48 +0000197install-bytecode:: install-bytecode-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000198
199###############################################################################
Mikhail Glushenkovb3d36292010-08-15 07:07:12 +0000200# LLVMC: Provide rules for compiling llvmc-based driver
Mikhail Glushenkov540d73f2009-03-02 09:04:13 +0000201###############################################################################
202
Mikhail Glushenkov0a1cb1e2009-06-25 01:07:00 +0000203ifdef LLVMC_BASED_DRIVER
204
205TOOLNAME = $(LLVMC_BASED_DRIVER)
Mikhail Glushenkov2373c992009-07-03 03:52:47 +0000206
Mikhail Glushenkovb3d36292010-08-15 07:07:12 +0000207LLVMLIBS = CompilerDriver.a
Charles Davis53ca1f32010-11-29 19:44:50 +0000208LINK_COMPONENTS = support
Mikhail Glushenkov0a1cb1e2009-06-25 01:07:00 +0000209
210endif # LLVMC_BASED_DRIVER
211
Mikhail Glushenkov540d73f2009-03-02 09:04:13 +0000212###############################################################################
Reid Spencer3a561f52004-10-23 20:04:14 +0000213# VARIABLES: Set up various variables based on configuration data
214###############################################################################
215
Daniel Dunbar94e98af2008-10-03 19:11:19 +0000216# Variable for if this make is for a "cleaning" target
217ifneq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
218 IS_CLEANING_TARGET=1
219endif
220
Reid Spencer3a561f52004-10-23 20:04:14 +0000221#--------------------------------------------------------------------
222# Variables derived from configuration we are building
Chris Lattner00950542001-06-06 20:29:01 +0000223#--------------------------------------------------------------------
224
Reid Spencer0a522b12007-07-10 07:19:53 +0000225CPP.Defines :=
David Greenedbefd0c2009-04-17 14:49:22 +0000226ifeq ($(ENABLE_OPTIMIZED),1)
227 BuildMode := Release
228 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
Anton Korobeynikove55db742009-08-18 00:40:33 +0000229 ifneq ($(HOST_OS),FreeBSD)
230 ifneq ($(HOST_OS),Darwin)
David Greenedbefd0c2009-04-17 14:49:22 +0000231 OmitFramePointer := -fomit-frame-pointer
Chris Lattner760da062003-03-14 20:25:22 +0000232 endif
David Greenedbefd0c2009-04-17 14:49:22 +0000233 endif
234
235 # Darwin requires -fstrict-aliasing to be explicitly enabled.
Evan Chengea84e932009-04-20 22:49:59 +0000236 # Avoid -fstrict-aliasing on Darwin for now, there are unresolved issues
237 # with -fstrict-aliasing and ipa-type-escape radr://6756684
Anton Korobeynikove55db742009-08-18 00:40:33 +0000238 #ifeq ($(HOST_OS),Darwin)
Evan Chengb306e382009-04-20 22:16:40 +0000239 # EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
240 #endif
David Greenedbefd0c2009-04-17 14:49:22 +0000241 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
242 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
243 LD.Flags += $(OPTIMIZE_OPTION)
Jeffrey Yasskin7fd82e52009-09-27 17:47:29 +0000244 ifdef DEBUG_SYMBOLS
Jeffrey Yasskind4482922009-09-25 16:46:09 +0000245 BuildMode := $(BuildMode)+Debug
246 CXX.Flags += -g
247 C.Flags += -g
248 LD.Flags += -g
249 KEEP_SYMBOLS := 1
250 endif
David Greenedbefd0c2009-04-17 14:49:22 +0000251else
Daniel Dunbardee8dbe2009-11-16 22:37:52 +0000252 ifdef NO_DEBUG_SYMBOLS
253 BuildMode := Unoptimized
254 CXX.Flags +=
255 C.Flags +=
256 LD.Flags +=
257 KEEP_SYMBOLS := 1
258 else
259 BuildMode := Debug
260 CXX.Flags += -g
261 C.Flags += -g
262 LD.Flags += -g
263 KEEP_SYMBOLS := 1
264 endif
David Greenedbefd0c2009-04-17 14:49:22 +0000265endif
266
267ifeq ($(ENABLE_PROFILING),1)
268 BuildMode := $(BuildMode)+Profile
269 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags)) -pg -g
270 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags)) -pg -g
271 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags)) -pg -g
272 KEEP_SYMBOLS := 1
Chris Lattner760da062003-03-14 20:25:22 +0000273endif
274
Daniel Dunbarecfe67c2008-09-02 17:35:16 +0000275#ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
276# CXX.Flags += -fvisibility-inlines-hidden
277#endif
278
Chris Lattnerc96d5082010-01-24 20:20:40 +0000279ifdef ENABLE_EXPENSIVE_CHECKS
280 # GNU libstdc++ uses RTTI if you define _GLIBCXX_DEBUG, which we did above.
281 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160
282 REQUIRES_RTTI := 1
283endif
284
Reid Spencer99655e12006-08-25 19:54:53 +0000285# IF REQUIRES_EH=1 is specified then don't disable exceptions
Reid Spencerdcea1402006-08-25 20:56:59 +0000286ifndef REQUIRES_EH
287 CXX.Flags += -fno-exceptions
Chris Lattnerc6150382010-01-24 20:21:50 +0000288else
289 # If the library requires EH, it also requires RTTI.
290 REQUIRES_RTTI := 1
Reid Spencerdcea1402006-08-25 20:56:59 +0000291endif
Reid Spencer99655e12006-08-25 19:54:53 +0000292
Nicolas Geoffray8ed81412009-08-19 22:04:44 +0000293ifdef REQUIRES_FRAME_POINTER
294 CXX.Flags := $(filter-out -fomit-frame-pointer,$(CXX.Flags))
295 C.Flags := $(filter-out -fomit-frame-pointer,$(C.Flags))
296 LD.Flags := $(filter-out -fomit-frame-pointer,$(LD.Flags))
297endif
298
Daniel Dunbarccb75c22009-09-11 15:47:24 +0000299# If REQUIRES_RTTI=1 is specified then don't disable run-time type id.
Chris Lattner43b5f932010-01-24 20:43:08 +0000300ifneq ($(REQUIRES_RTTI), 1)
301 CXX.Flags += -fno-rtti
Reid Spencer6548bf12007-05-02 21:29:39 +0000302endif
303
Peter Collingbourneed50d382010-10-22 12:54:34 +0000304ifeq ($(ENABLE_COVERAGE),1)
Daniel Dunbar55a07b22009-03-13 20:59:41 +0000305 BuildMode := $(BuildMode)+Coverage
Chris Lattner6be92662009-06-16 23:00:42 +0000306 CXX.Flags += -ftest-coverage -fprofile-arcs
307 C.Flags += -ftest-coverage -fprofile-arcs
Daniel Dunbar55a07b22009-03-13 20:59:41 +0000308endif
309
Reid Spencer854071c2006-04-10 16:46:04 +0000310# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
311# then disable assertions by defining the appropriate preprocessor symbols.
Peter Collingbourneed50d382010-10-22 12:54:34 +0000312ifeq ($(DISABLE_ASSERTIONS),1)
313 CPP.Defines += -DNDEBUG
314else
Duncan Sands8246adc2010-07-07 07:48:00 +0000315 BuildMode := $(BuildMode)+Asserts
Reid Spencer0a522b12007-07-10 07:19:53 +0000316 CPP.Defines += -D_DEBUG
Chris Lattner71927862006-03-21 01:06:41 +0000317endif
318
Misha Brukmanef5dc702009-01-08 02:11:55 +0000319# If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
320# configured), then enable expensive checks by defining the
David Greenecba29182007-06-29 03:36:21 +0000321# appropriate preprocessor symbols.
Peter Collingbourneed50d382010-10-22 12:54:34 +0000322ifeq ($(ENABLE_EXPENSIVE_CHECKS),1)
David Greenea696d242007-06-28 19:36:08 +0000323 BuildMode := $(BuildMode)+Checks
Duncan Sands47d9dcc2008-12-09 21:33:20 +0000324 CPP.Defines += -D_GLIBCXX_DEBUG -DXDEBUG
David Greenea696d242007-06-28 19:36:08 +0000325endif
326
Nick Lewyckya15dc032009-02-26 07:44:16 +0000327# LOADABLE_MODULE implies several other things so we force them to be
328# defined/on.
329ifdef LOADABLE_MODULE
330 SHARED_LIBRARY := 1
Nick Lewyckya15dc032009-02-26 07:44:16 +0000331 LINK_LIBS_IN_SHARED := 1
332endif
333
334ifdef SHARED_LIBRARY
335 ENABLE_PIC := 1
336 PIC_FLAG = "(PIC)"
337endif
338
Reid Spencer89b0d992006-12-16 22:07:52 +0000339ifeq ($(ENABLE_PIC),1)
Anton Korobeynikove55db742009-08-18 00:40:33 +0000340 ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
Nick Lewycky8e87e652009-02-21 08:41:09 +0000341 # Nothing. Win32 defaults to PIC and warns when given -fPIC
342 else
Anton Korobeynikove55db742009-08-18 00:40:33 +0000343 ifeq ($(HOST_OS),Darwin)
Nick Lewyckya15dc032009-02-26 07:44:16 +0000344 # Common symbols not allowed in dylib files
Nick Lewycky8e87e652009-02-21 08:41:09 +0000345 CXX.Flags += -fno-common
346 C.Flags += -fno-common
347 else
348 # Linux and others; pass -fPIC
349 CXX.Flags += -fPIC
350 C.Flags += -fPIC
351 endif
352 endif
Mike Stump3fbdbd92009-05-08 23:08:58 +0000353else
Anton Korobeynikove55db742009-08-18 00:40:33 +0000354 ifeq ($(HOST_OS),Darwin)
Mike Stump3fbdbd92009-05-08 23:08:58 +0000355 CXX.Flags += -mdynamic-no-pic
356 C.Flags += -mdynamic-no-pic
357 endif
Reid Spencer89b0d992006-12-16 22:07:52 +0000358endif
359
Daniel Dunbardd464df2010-05-10 20:11:56 +0000360# Support makefile variable to disable any kind of timestamp/non-deterministic
361# info from being used in the build.
362ifeq ($(ENABLE_TIMESTAMPS),1)
363 DOTDIR_TIMESTAMP_COMMAND := $(DATE)
364else
365 DOTDIR_TIMESTAMP_COMMAND := echo 'Created.'
366endif
367
Anton Korobeynikov2b02b432010-01-16 14:06:58 +0000368ifeq ($(HOST_OS),MingW)
369 # Work around PR4957
370 CPP.Defines += -D__NO_CTYPE_INLINE
371 ifeq ($(LLVM_CROSS_COMPILING),1)
372 # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
373 ifdef TOOLNAME
374 LD.Flags += -Wl,--allow-multiple-definition
375 endif
376 endif
377endif
378
Eric Christopher2bd4bb02009-08-18 03:23:40 +0000379CXX.Flags += -Woverloaded-virtual
David Greenea696d242007-06-28 19:36:08 +0000380CPP.BaseFlags += $(CPP.Defines)
Reid Spencerf2722ca2006-03-22 15:59:55 +0000381AR.Flags := cru
Reid Spencer3a561f52004-10-23 20:04:14 +0000382
Chris Lattner16620fc2006-07-27 18:19:51 +0000383# Make Floating point IEEE compliant on Alpha.
Andrew Lenharth39bcf5b2005-02-13 03:41:10 +0000384ifeq ($(ARCH),Alpha)
Reid Spencer89b0d992006-12-16 22:07:52 +0000385 CXX.Flags += -mieee
386 CPP.BaseFlags += -mieee
387ifeq ($(ENABLE_PIC),0)
388 CXX.Flags += -fPIC
389 CPP.BaseFlags += -fPIC
390endif
Andrew Lenharth39bcf5b2005-02-13 03:41:10 +0000391
Andrew Lenharthc5e455d2007-01-26 13:34:50 +0000392 LD.Flags += -Wl,--no-relax
393endif
394
NAKAMURA Takumib9dec1f2010-11-26 09:32:02 +0000395# GNU ld/PECOFF accepts but ignores them below;
396# --version-script
397# --export-dynamic
398# --rpath
399# FIXME: autoconf should be aware of them.
400ifneq (,$(filter $(HOST_OS),Cygwin MingW))
401 HAVE_LINK_VERSION_SCRIPT := 0
402 RPATH :=
403 RDYNAMIC := -Wl,--export-all-symbols
404endif
405
Reid Spencer3a561f52004-10-23 20:04:14 +0000406#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000407# Directory locations
Reid Spencer3a561f52004-10-23 20:04:14 +0000408#--------------------------------------------------------------------
Jim Grosbach673612e2008-10-02 22:56:44 +0000409TargetMode :=
410ifeq ($(LLVM_CROSS_COMPILING),1)
Anton Korobeynikov569c45c2008-11-10 07:33:13 +0000411 BuildLLVMToolDir := $(LLVM_OBJ_ROOT)/BuildTools/$(BuildMode)/bin
Jim Grosbach673612e2008-10-02 22:56:44 +0000412endif
413
414ObjRootDir := $(PROJ_OBJ_DIR)/$(BuildMode)
Anton Korobeynikov569c45c2008-11-10 07:33:13 +0000415ObjDir := $(ObjRootDir)
416LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
417ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
418ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
419LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
420LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
421LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
John Criswell7a73b802003-06-30 21:59:07 +0000422
Reid Spencer3a561f52004-10-23 20:04:14 +0000423#--------------------------------------------------------------------
Anton Korobeynikov59a430f2010-08-17 19:03:03 +0000424# Locations of shared libraries
425#--------------------------------------------------------------------
426
427SharedPrefix := lib
428SharedLibDir := $(LibDir)
429LLVMSharedLibDir := $(LLVMLibDir)
430
431# Win32.DLL prefers to be located on the "PATH" of binaries.
432ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
433 SharedLibDir := $(ToolDir)
434 LLVMSharedLibDir := $(LLVMToolDir)
435
436 ifeq ($(HOST_OS),Cygwin)
437 SharedPrefix := cyg
438 else
439 SharedPrefix :=
440 endif
441endif
442
443#--------------------------------------------------------------------
Daniel Dunbar797faed2010-02-23 10:00:53 +0000444# LLVM Capable Compiler
445#--------------------------------------------------------------------
446
447ifeq ($(LLVMCC_OPTION),llvm-gcc)
448 LLVMCC := $(LLVMGCC)
449 LLVMCXX := $(LLVMGXX)
450else
451 ifeq ($(LLVMCC_OPTION),clang)
452 ifneq ($(CLANGPATH),)
453 LLVMCC := $(CLANGPATH)
454 LLVMCXX := $(CLANGXXPATH)
455 else
456 ifeq ($(ENABLE_BUILT_CLANG),1)
457 LLVMCC := $(LLVMToolDir)/clang
458 LLVMCXX := $(LLVMToolDir)/clang++
459 endif
460 endif
461 endif
462endif
463
464#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000465# Full Paths To Compiled Tools and Utilities
Reid Spencer3a561f52004-10-23 20:04:14 +0000466#--------------------------------------------------------------------
Reid Spencer3ca6d8b2005-01-14 16:33:36 +0000467EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
468Echo = @$(EchoCmd)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000469ifndef LLVMAS
470LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
471endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000472ifndef TBLGEN
Reid Spencere2cfe5d2006-07-26 21:14:56 +0000473 ifeq ($(LLVM_CROSS_COMPILING),1)
Anton Korobeynikov569c45c2008-11-10 07:33:13 +0000474 TBLGEN := $(BuildLLVMToolDir)/tblgen$(BUILD_EXEEXT)
Reid Spencere2cfe5d2006-07-26 21:14:56 +0000475 else
476 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
477 endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000478endif
Misha Brukmanef5dc702009-01-08 02:11:55 +0000479LLVM_CONFIG := $(LLVMToolDir)/llvm-config
Reid Spencer43eb96c2007-02-09 15:52:07 +0000480ifndef LLVMLD
Reid Spencer18464122007-02-09 17:09:14 +0000481LLVMLD := $(LLVMToolDir)/llvm-ld$(EXEEXT)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000482endif
Chris Lattner0a1db822006-09-04 05:23:20 +0000483ifndef LLVMDIS
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000484LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
485endif
486ifndef LLI
487LLI := $(LLVMToolDir)/lli$(EXEEXT)
488endif
Alkis Evlogimenoseebaf332005-02-27 10:21:37 +0000489ifndef LLC
490LLC := $(LLVMToolDir)/llc$(EXEEXT)
491endif
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000492ifndef LOPT
Alkis Evlogimenos20d793a2004-12-13 18:08:29 +0000493LOPT := $(LLVMToolDir)/opt$(EXEEXT)
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000494endif
Alkis Evlogimenos270e8512005-02-02 00:40:15 +0000495ifndef LBUGPOINT
496LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
497endif
Reid Spencere46687c2006-12-03 21:01:45 +0000498
Reid Spencer3a561f52004-10-23 20:04:14 +0000499#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000500# Adjust to user's request
Reid Spencer3a561f52004-10-23 20:04:14 +0000501#--------------------------------------------------------------------
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000502
Anton Korobeynikove55db742009-08-18 00:40:33 +0000503ifeq ($(HOST_OS),Darwin)
Scott Michel87af5f02009-03-12 21:03:53 +0000504 DARWIN_VERSION := `sw_vers -productVersion`
505 # Strip a number like 10.4.7 to 10.4
506 DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
507 # Get "4" out of 10.4 for later pieces in the makefile.
508 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
Bill Wendlingaca56952009-03-22 08:28:45 +0000509
Daniel Dunbar7bc0f272010-12-08 01:48:05 +0000510 LoadableModuleOptions := -Wl,-flat_namespace -Wl,-undefined,suppress
511 SharedLinkOptions := -dynamiclib
Evan Chenga5e225e2009-09-08 18:52:20 +0000512 ifneq ($(ARCH),ARM)
513 SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
514 endif
Scott Michel87af5f02009-03-12 21:03:53 +0000515else
Anton Korobeynikov59a430f2010-08-17 19:03:03 +0000516 SharedLinkOptions=-shared
Scott Michel87af5f02009-03-12 21:03:53 +0000517endif
518
Anton Korobeynikove55db742009-08-18 00:40:33 +0000519ifeq ($(TARGET_OS),Darwin)
Evan Chenga5e225e2009-09-08 18:52:20 +0000520 ifneq ($(ARCH),ARM)
521 TargetCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
522 endif
Anton Korobeynikove55db742009-08-18 00:40:33 +0000523endif
524
Reid Spencer492c2932005-01-11 04:31:07 +0000525ifdef SHARED_LIBRARY
Anton Korobeynikov59a430f2010-08-17 19:03:03 +0000526ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
Rafael Espindolaa89efd52010-05-16 03:05:14 +0000527ifneq ($(HOST_OS),Darwin)
528 LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
John Criswell82f4a5a2003-07-31 20:58:51 +0000529endif
Scott Michel87af5f02009-03-12 21:03:53 +0000530endif
Rafael Espindolaa89efd52010-05-16 03:05:14 +0000531endif
John Criswell82f4a5a2003-07-31 20:58:51 +0000532
Reid Spencercceed9f2004-11-08 17:32:12 +0000533ifdef TOOL_VERBOSE
534 C.Flags += -v
535 CXX.Flags += -v
536 LD.Flags += -v
Reid Spencercceed9f2004-11-08 17:32:12 +0000537 VERBOSE := 1
538endif
539
Reid Spencer3a561f52004-10-23 20:04:14 +0000540# Adjust settings for verbose mode
Chris Lattner760da062003-03-14 20:25:22 +0000541ifndef VERBOSE
Reid Spencercc2d1e22004-10-30 09:19:36 +0000542 Verb := @
Reid Spencer491a6cd2007-07-23 08:20:46 +0000543 AR.Flags += >/dev/null 2>/dev/null
Reid Spencer11fde542005-01-16 02:20:54 +0000544 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
Reid Spencer151f8ba2004-10-25 08:27:37 +0000545else
Misha Brukmanef5dc702009-01-08 02:11:55 +0000546 ConfigureScriptFLAGS :=
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000547endif
548
Vikram S. Advefeeae582002-09-18 11:55:13 +0000549# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000550ifndef KEEP_SYMBOLS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000551 Strip := $(PLATFORMSTRIPOPTS)
552 StripWarnMsg := "(without symbols)"
Reid Spencer860598a2005-02-24 07:12:43 +0000553 Install.StripFlag += -s
Vikram S. Advefeeae582002-09-18 11:55:13 +0000554endif
555
Rafael Espindola31552a92010-10-15 00:58:12 +0000556ifdef TOOL_NO_EXPORTS
557 DynamicFlags :=
558else
559 DynamicFlag := $(RDYNAMIC)
560endif
561
Reid Spencer3a561f52004-10-23 20:04:14 +0000562# Adjust linker flags for building an executable
Nick Lewyckye28015c2010-08-02 03:16:19 +0000563ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
564ifneq ($(HOST_OS), Darwin)
Reid Spencer4d71b662004-10-22 21:01:56 +0000565ifdef TOOLNAME
Jeffrey Yasskinc9017192010-02-25 06:34:33 +0000566 LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
567 ifdef EXAMPLE_TOOL
Rafael Espindola31552a92010-10-15 00:58:12 +0000568 LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(DynamicFlag)
Jeffrey Yasskinc9017192010-02-25 06:34:33 +0000569 else
Rafael Espindola31552a92010-10-15 00:58:12 +0000570 LD.Flags += $(RPATH) -Wl,$(ToolDir) $(DynamicFlag)
Jeffrey Yasskinc9017192010-02-25 06:34:33 +0000571 endif
Reid Spencer815cbcf2004-11-18 10:03:46 +0000572endif
Ted Kremenekd634bcb2010-07-15 06:36:57 +0000573else
574ifneq ($(DARWIN_MAJVERS),4)
575 LD.Flags += $(RPATH) -Wl,@executable_path/../lib
Nick Lewyckya15dc032009-02-26 07:44:16 +0000576endif
Ted Kremenekd634bcb2010-07-15 06:36:57 +0000577endif
Nick Lewyckye28015c2010-08-02 03:16:19 +0000578endif
Ted Kremenekd634bcb2010-07-15 06:36:57 +0000579
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000580
Reid Spencer3a561f52004-10-23 20:04:14 +0000581#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000582# Options To Invoke Tools
Reid Spencer3a561f52004-10-23 20:04:14 +0000583#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000584
Daniel Dunbare36b6d42009-05-12 07:26:49 +0000585ifndef NO_PEDANTIC
Duncan Sands9ff4c132009-06-19 12:40:30 +0000586CompileCommonOpts += -pedantic -Wno-long-long
Daniel Dunbare36b6d42009-05-12 07:26:49 +0000587endif
Duncan Sands9ff4c132009-06-19 12:40:30 +0000588CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
589 $(EXTRA_OPTIONS)
Dan Gohman3072b8a2010-04-19 18:33:28 +0000590# Enable cast-qual for C++; the workaround is to use const_cast.
591CXX.Flags += -Wcast-qual
Reid Spencer4d71b662004-10-22 21:01:56 +0000592
Anton Korobeynikove55db742009-08-18 00:40:33 +0000593ifeq ($(HOST_OS),HP-UX)
Duraid Madinaeb713402006-02-15 03:20:16 +0000594 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
Duraid Madina0ad8fcf2005-05-16 06:38:09 +0000595endif
596
Chris Lattner73faa392006-05-30 16:38:06 +0000597# If we are building a universal binary on Mac OS/X, pass extra options. This
598# is useful to people that want to link the LLVM libraries into their universal
Chris Lattner7dabf392006-06-29 19:38:04 +0000599# apps.
600#
601# The following can be optionally specified:
602# UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
603# For Mac OS/X 10.4 Intel machines, the traditional one is:
604# UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
605# UNIVERSAL_ARCH can be optionally specified to be a list of architectures
606# to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
607# i386/ppc only.
Chris Lattnerba466652006-04-06 06:30:15 +0000608ifdef UNIVERSAL
Chris Lattner7dabf392006-06-29 19:38:04 +0000609 ifndef UNIVERSAL_ARCH
610 UNIVERSAL_ARCH := i386 ppc
611 endif
612 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
613 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
Chris Lattnerf988e532006-06-16 21:47:59 +0000614 ifdef UNIVERSAL_SDK_PATH
615 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
Chris Lattnerf988e532006-06-16 21:47:59 +0000616 endif
617
618 # Building universal cannot compute dependencies automatically.
Chris Lattnerba466652006-04-06 06:30:15 +0000619 DISABLE_AUTO_DEPENDENCIES=1
Evan Chengc785b4f2009-03-09 18:28:37 +0000620else
Anton Korobeynikove55db742009-08-18 00:40:33 +0000621 ifeq ($(TARGET_OS),Darwin)
Bill Wendlinga0833352009-03-12 04:10:09 +0000622 ifeq ($(ARCH),x86_64)
Evan Chenga38ff642009-03-23 03:45:56 +0000623 TargetCommonOpts = -m64
Bill Wendlinga0833352009-03-12 04:10:09 +0000624 else
625 ifeq ($(ARCH),x86)
Evan Chenga38ff642009-03-23 03:45:56 +0000626 TargetCommonOpts = -m32
Bill Wendlinga0833352009-03-12 04:10:09 +0000627 endif
Evan Chengc785b4f2009-03-09 18:28:37 +0000628 endif
629 endif
Chris Lattnerba466652006-04-06 06:30:15 +0000630endif
631
Anton Korobeynikove55db742009-08-18 00:40:33 +0000632ifeq ($(HOST_OS),SunOS)
Michael J. Spencer1f6efa32010-11-29 18:16:10 +0000633CPP.BaseFlags += -include llvm/Support/Solaris.h
Chris Lattner58a4c5e2008-06-24 17:44:42 +0000634endif
635
Edward O'Callaghandf199f12009-10-14 05:55:03 +0000636ifeq ($(HOST_OS),AuroraUX)
Michael J. Spencer1f6efa32010-11-29 18:16:10 +0000637CPP.BaseFlags += -include llvm/Support/Solaris.h
Edward O'Callaghandf199f12009-10-14 05:55:03 +0000638endif # !HOST_OS - AuroraUX.
639
Misha Brukmanef5dc702009-01-08 02:11:55 +0000640LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
Dan Gohman63f97202008-10-17 01:33:43 +0000641CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
Reid Spencerf2722ca2006-03-22 15:59:55 +0000642# All -I flags should go here, so that they don't confuse llvm-config.
Duncan Sands095765e2008-01-28 17:38:30 +0000643CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
644 $(patsubst %,-I%/include,\
Chris Lattner2671fc32008-01-28 04:18:41 +0000645 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
646 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
647 $(CPP.BaseFlags)
Reid Spencer4d71b662004-10-22 21:01:56 +0000648
Daniel Dunbar55a07b22009-03-13 20:59:41 +0000649ifeq ($(BUILD_COMPONENT), 1)
Eric Christopher2bd4bb02009-08-18 03:23:40 +0000650 Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
Evan Chenga38ff642009-03-23 03:45:56 +0000651 $(TargetCommonOpts) $(CompileCommonOpts) -c
Eric Christopher2bd4bb02009-08-18 03:23:40 +0000652 Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
653 $(CPPFLAGS) \
Evan Chenga38ff642009-03-23 03:45:56 +0000654 $(TargetCommonOpts) $(CompileCommonOpts) -c
Eric Christopher2bd4bb02009-08-18 03:23:40 +0000655 Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CPPFLAGS) $(TargetCommonOpts) \
Chris Lattner6be92662009-06-16 23:00:42 +0000656 $(CompileCommonOpts) $(CXX.Flags) -E
Eric Christopher2a80dc72009-08-18 18:07:35 +0000657 Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) \
658 $(LDFLAGS) \
Evan Chenga38ff642009-03-23 03:45:56 +0000659 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
Jim Grosbach673612e2008-10-02 22:56:44 +0000660else
Eric Christopher2bd4bb02009-08-18 03:23:40 +0000661 Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
Evan Chenga38ff642009-03-23 03:45:56 +0000662 $(TargetCommonOpts) $(CompileCommonOpts) -c
Eric Christopher2bd4bb02009-08-18 03:23:40 +0000663 Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
Evan Chenga38ff642009-03-23 03:45:56 +0000664 $(TargetCommonOpts) $(CompileCommonOpts) -c
Eric Christopher2bd4bb02009-08-18 03:23:40 +0000665 Preprocess.CXX= $(CXX) $(CPP.Flags) $(TargetCommonOpts) $(CPPFLAGS) \
Chris Lattner6be92662009-06-16 23:00:42 +0000666 $(CompileCommonOpts) $(CXX.Flags) -E
Eric Christopher2a80dc72009-08-18 18:07:35 +0000667 Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(LDFLAGS) \
Evan Chenga38ff642009-03-23 03:45:56 +0000668 $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip)
Jim Grosbach673612e2008-10-02 22:56:44 +0000669endif
670
Daniel Dunbar7cfbe252010-02-23 10:28:06 +0000671BCCompile.C = $(LLVMCC) $(CPP.Flags) $(C.Flags) $(CFLAGS) $(CPPFLAGS) \
Evan Chenga38ff642009-03-23 03:45:56 +0000672 $(TargetCommonOpts) $(CompileCommonOpts)
Eric Christopher2bd4bb02009-08-18 03:23:40 +0000673Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CPPFLAGS) \
Evan Chenga38ff642009-03-23 03:45:56 +0000674 $(TargetCommonOpts) $(CompileCommonOpts) -E
Chris Lattner0cb09f12005-10-05 00:28:41 +0000675
Daniel Dunbar7cfbe252010-02-23 10:28:06 +0000676BCCompile.CXX = $(LLVMCXX) $(CPP.Flags) $(CXX.Flags) $(CXXFLAGS) $(CPPFLAGS) \
Evan Chenga38ff642009-03-23 03:45:56 +0000677 $(TargetCommonOpts) $(CompileCommonOpts)
Chris Lattnerd95e3f22006-09-29 18:47:13 +0000678
Misha Brukmanef5dc702009-01-08 02:11:55 +0000679ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
680ScriptInstall = $(INSTALL) -m 0755
Reid Spencer860598a2005-02-24 07:12:43 +0000681DataInstall = $(INSTALL) -m 0644
Chris Lattner6e0a5292008-01-15 23:27:40 +0000682
683# When compiling under Mingw/Cygwin, the tblgen tool expects Windows
684# paths. In this case, the SYSPATH function (defined in
685# Makefile.config) transforms Unix paths into Windows paths.
686TableGen = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
Mikhail Glushenkovafa22592009-01-09 16:31:01 +0000687 -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \
Chris Lattner6e0a5292008-01-15 23:27:40 +0000688 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
689 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
690
Reid Spencercc2d1e22004-10-30 09:19:36 +0000691Archive = $(AR) $(AR.Flags)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000692LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencer4d71b662004-10-22 21:01:56 +0000693ifdef RANLIB
Reid Spencer3a561f52004-10-23 20:04:14 +0000694Ranlib = $(RANLIB)
Reid Spencer4d71b662004-10-22 21:01:56 +0000695else
Reid Spencer3a561f52004-10-23 20:04:14 +0000696Ranlib = ranlib
John Criswell7a73b802003-06-30 21:59:07 +0000697endif
698
Daniel Dunbarfd96b132009-11-19 00:14:53 +0000699AliasTool = ln -s
700
Chris Lattner00950542001-06-06 20:29:01 +0000701#----------------------------------------------------------
Misha Brukmanef5dc702009-01-08 02:11:55 +0000702# Get the list of source files and compute object file
703# names from them.
Reid Spencer3a561f52004-10-23 20:04:14 +0000704#----------------------------------------------------------
Chris Lattner89681112006-01-27 22:13:12 +0000705
706ifndef SOURCES
707 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
Chris Lattnerc9480642009-01-02 07:16:45 +0000708 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000709else
Chris Lattner89681112006-01-27 22:13:12 +0000710 Sources := $(SOURCES)
Misha Brukmanef5dc702009-01-08 02:11:55 +0000711endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000712
Chris Lattner89681112006-01-27 22:13:12 +0000713ifdef BUILT_SOURCES
Chris Lattnerc9480642009-01-02 07:16:45 +0000714Sources += $(filter %.cpp %.c %.cc,$(BUILT_SOURCES))
Reid Spencer345235ca2004-12-04 22:34:09 +0000715endif
Reid Spencer3a561f52004-10-23 20:04:14 +0000716
Chris Lattner89681112006-01-27 22:13:12 +0000717BaseNameSources := $(sort $(basename $(Sources)))
718
719ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
Chris Lattner89681112006-01-27 22:13:12 +0000720ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
721
Reid Spencer3a561f52004-10-23 20:04:14 +0000722###############################################################################
723# DIRECTORIES: Handle recursive descent of directory structure
724###############################################################################
John Criswell82f4a5a2003-07-31 20:58:51 +0000725
Chris Lattner00950542001-06-06 20:29:01 +0000726#---------------------------------------------------------
Reid Spencera69b1ea2004-10-28 09:15:28 +0000727# Provide rules to make install dirs. This must be early
728# in the file so they get built before dependencies
729#---------------------------------------------------------
730
Erick Tryzelaard4076cf2010-03-04 20:56:19 +0000731$(DESTDIR)$(PROJ_bindir) $(DESTDIR)$(PROJ_libdir) $(DESTDIR)$(PROJ_includedir) $(DESTDIR)$(PROJ_etcdir)::
Mike Stumpe50f34a2009-01-22 03:24:22 +0000732 $(Verb) $(MKDIR) $@
Reid Spencera69b1ea2004-10-28 09:15:28 +0000733
Reid Spencercc2d1e22004-10-30 09:19:36 +0000734# To create other directories, as needed, and timestamp their creation
735%/.dir:
736 $(Verb) $(MKDIR) $* > /dev/null
Daniel Dunbardd464df2010-05-10 20:11:56 +0000737 $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000738
Reid Spencer815cbcf2004-11-18 10:03:46 +0000739.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
740.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000741
742#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000743# Handle the DIRS options for sequential construction
Chris Lattner00950542001-06-06 20:29:01 +0000744#---------------------------------------------------------
745
Misha Brukmanef5dc702009-01-08 02:11:55 +0000746SubDirs :=
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000747ifdef DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000748SubDirs += $(DIRS)
Chris Lattner82033602006-07-26 20:22:26 +0000749
750ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000751$(RecursiveTargets)::
752 $(Verb) for dir in $(DIRS); do \
Daniel Dunbar546023f2010-06-08 20:10:13 +0000753 if ([ ! -f $$dir/Makefile ] || \
Chris Lattnerf2a12242010-06-18 00:35:32 +0000754 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
Reid Spencer4d71b662004-10-22 21:01:56 +0000755 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000756 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000757 fi; \
Reid Spencerdd1aac32006-05-17 22:55:35 +0000758 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000759 done
Chris Lattner82033602006-07-26 20:22:26 +0000760else
761$(RecursiveTargets)::
762 $(Verb) for dir in $(DIRS); do \
763 ($(MAKE) -C $$dir $@ ) || exit 1; \
764 done
765endif
766
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000767endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000768
Reid Spencer3a561f52004-10-23 20:04:14 +0000769#---------------------------------------------------------
770# Handle the EXPERIMENTAL_DIRS options ensuring success
771# after each directory is built.
772#---------------------------------------------------------
773ifdef EXPERIMENTAL_DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000774$(RecursiveTargets)::
775 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Daniel Dunbar546023f2010-06-08 20:10:13 +0000776 if ([ ! -f $$dir/Makefile ] || \
Chris Lattnerf2a12242010-06-18 00:35:32 +0000777 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
Reid Spencer3a561f52004-10-23 20:04:14 +0000778 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000779 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000780 fi; \
Reid Spencerdd1aac32006-05-17 22:55:35 +0000781 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000782 done
783endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000784
Reid Spencer25e8a702005-12-21 23:17:06 +0000785#-----------------------------------------------------------
Mike Stump0a268912009-01-24 00:00:41 +0000786# Handle the OPTIONAL_PARALLEL_DIRS options for optional parallel construction
787#-----------------------------------------------------------
788ifdef OPTIONAL_PARALLEL_DIRS
789 PARALLEL_DIRS += $(foreach T,$(OPTIONAL_PARALLEL_DIRS),$(shell test -d $(PROJ_SRC_DIR)/$(T) && echo "$(T)"))
790endif
791
792#-----------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000793# Handle the PARALLEL_DIRS options for parallel construction
Reid Spencer25e8a702005-12-21 23:17:06 +0000794#-----------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000795ifdef PARALLEL_DIRS
796
Reid Spencercc2d1e22004-10-30 09:19:36 +0000797SubDirs += $(PARALLEL_DIRS)
798
Reid Spencer44cb1b32004-12-03 20:08:48 +0000799# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencercc2d1e22004-10-30 09:19:36 +0000800all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
801clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000802clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000803install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000804uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencer44cb1b32004-12-03 20:08:48 +0000805install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Daniel Dunbar7f068f42009-09-13 22:39:27 +0000806unitcheck:: $(addsuffix /.makeunitcheck,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000807
Reid Spencer345235ca2004-12-04 22:34:09 +0000808ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer3a561f52004-10-23 20:04:14 +0000809
Reid Spencer345235ca2004-12-04 22:34:09 +0000810$(ParallelTargets) :
Daniel Dunbar546023f2010-06-08 20:10:13 +0000811 $(Verb) if ([ ! -f $(@D)/Makefile ] || \
Chris Lattnerf2a12242010-06-18 00:35:32 +0000812 command test $(@D)/Makefile -ot \
Chris Lattner381cd022010-06-15 21:35:22 +0000813 $(PROJ_SRC_DIR)/$(@D)/Makefile ); then \
Reid Spencer4d71b662004-10-22 21:01:56 +0000814 $(MKDIR) $(@D); \
Reid Spencer11fde542005-01-16 02:20:54 +0000815 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswellb3866b62003-11-25 19:32:22 +0000816 fi; \
Reid Spencer91140e92007-02-07 03:29:29 +0000817 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
Chris Lattner00950542001-06-06 20:29:01 +0000818endif
819
Reid Spencer3a561f52004-10-23 20:04:14 +0000820#---------------------------------------------------------
821# Handle the OPTIONAL_DIRS options for directores that may
822# or may not exist.
823#---------------------------------------------------------
John Criswell2a6530f2003-06-27 16:58:44 +0000824ifdef OPTIONAL_DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000825
Reid Spencercc2d1e22004-10-30 09:19:36 +0000826SubDirs += $(OPTIONAL_DIRS)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000827
Chris Lattner82033602006-07-26 20:22:26 +0000828ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000829$(RecursiveTargets)::
830 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000831 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
Daniel Dunbar546023f2010-06-08 20:10:13 +0000832 if ([ ! -f $$dir/Makefile ] || \
Chris Lattnerf2a12242010-06-18 00:35:32 +0000833 command test $$dir/Makefile -ot $(PROJ_SRC_DIR)/$$dir/Makefile ); then \
Reid Spencer4d71b662004-10-22 21:01:56 +0000834 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000835 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000836 fi; \
Reid Spencerdd1aac32006-05-17 22:55:35 +0000837 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000838 fi \
John Criswell2a6530f2003-06-27 16:58:44 +0000839 done
Chris Lattner82033602006-07-26 20:22:26 +0000840else
841$(RecursiveTargets)::
842 $(Verb) for dir in $(OPTIONAL_DIRS); do \
843 ($(MAKE) -C$$dir $@ ) || exit 1; \
844 done
845endif
John Criswell2a6530f2003-06-27 16:58:44 +0000846endif
847
Reid Spencerfc945082004-08-20 09:20:05 +0000848#---------------------------------------------------------
849# Handle the CONFIG_FILES options
850#---------------------------------------------------------
851ifdef CONFIG_FILES
Reid Spencerfc945082004-08-20 09:20:05 +0000852
Reid Spencera2a31bf2007-02-06 18:53:14 +0000853ifdef NO_INSTALL
854install-local::
855 $(Echo) Install circumvented with NO_INSTALL
856uninstall-local::
857 $(Echo) UnInstall circumvented with NO_INSTALL
858else
Erick Tryzelaard4076cf2010-03-04 20:56:19 +0000859install-local:: $(DESTDIR)$(PROJ_etcdir) $(CONFIG_FILES)
860 $(Echo) Installing Configuration Files To $(DESTDIR)$(PROJ_etcdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000861 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000862 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
Erick Tryzelaard4076cf2010-03-04 20:56:19 +0000863 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
Reid Spencer11fde542005-01-16 02:20:54 +0000864 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
Erick Tryzelaard4076cf2010-03-04 20:56:19 +0000865 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(DESTDIR)$(PROJ_etcdir) ; \
Reid Spencer1b426ab2004-11-23 05:59:53 +0000866 else \
867 $(ECHO) Error: cannot find config file $${file}. ; \
868 fi \
Reid Spencerfc945082004-08-20 09:20:05 +0000869 done
Reid Spencer3a561f52004-10-23 20:04:14 +0000870
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000871uninstall-local::
Erick Tryzelaard4076cf2010-03-04 20:56:19 +0000872 $(Echo) Uninstalling Configuration Files From $(DESTDIR)$(PROJ_etcdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000873 $(Verb)for file in $(CONFIG_FILES); do \
Erick Tryzelaard4076cf2010-03-04 20:56:19 +0000874 $(RM) -f $(DESTDIR)$(PROJ_etcdir)/$${file} ; \
Reid Spencere5487ba2004-10-24 07:53:21 +0000875 done
Reid Spencera2a31bf2007-02-06 18:53:14 +0000876endif
Reid Spencere5487ba2004-10-24 07:53:21 +0000877
Reid Spencerfc945082004-08-20 09:20:05 +0000878endif
879
Reid Spencer3a561f52004-10-23 20:04:14 +0000880###############################################################################
Eric Christopherdf7d4192010-06-21 23:49:08 +0000881# Set up variables for building libraries
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000882###############################################################################
883
884#---------------------------------------------------------
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000885# Define various command line options pertaining to the
Misha Brukmanef5dc702009-01-08 02:11:55 +0000886# libraries needed when linking. There are "Proj" libs
887# (defined by the user's project) and "LLVM" libs (defined
Chris Lattneref0d0f12006-09-04 04:47:21 +0000888# by the LLVM project).
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000889#---------------------------------------------------------
Andrew Lenharth7ac17522005-08-13 05:09:50 +0000890
Chris Lattneref0d0f12006-09-04 04:47:21 +0000891ifdef USEDLIBS
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000892ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
893ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
Chris Lattneref0d0f12006-09-04 04:47:21 +0000894ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
895ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
896endif
897
898ifdef LLVMLIBS
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000899LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
900LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000901LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000902LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
Chris Lattneref0d0f12006-09-04 04:47:21 +0000903endif
904
NAKAMURA Takumia64eb832010-09-10 06:27:02 +0000905# Loadable module for Win32 requires all symbols resolved for linking.
906# Then all symbols in LLVM.dll will be available.
907ifeq ($(ENABLE_SHARED),1)
Anton Korobeynikov59a430f2010-08-17 19:03:03 +0000908 ifdef LOADABLE_MODULE
NAKAMURA Takumia64eb832010-09-10 06:27:02 +0000909 ifneq (,$(filter $(HOST_OS),Cygwin MingW))
910 LINK_COMPONENTS += all
911 endif
Anton Korobeynikov59a430f2010-08-17 19:03:03 +0000912 endif
913endif
914
Daniel Dunbar94e98af2008-10-03 19:11:19 +0000915ifndef IS_CLEANING_TARGET
Chris Lattneref0d0f12006-09-04 04:47:21 +0000916ifdef LINK_COMPONENTS
Chris Lattner0a1db822006-09-04 05:23:20 +0000917
918# If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
919# clean in tools, then do a make in tools (instead of at the top level).
920$(LLVM_CONFIG):
921 @echo "*** llvm-config doesn't exist - rebuilding it."
922 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
Gabor Greif0a4c3782008-02-27 13:34:15 +0000923
Chris Lattner0a1db822006-09-04 05:23:20 +0000924$(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
925
Jeffrey Yasskinc9017192010-02-25 06:34:33 +0000926ifeq ($(ENABLE_SHARED), 1)
Anton Korobeynikov59a430f2010-08-17 19:03:03 +0000927# We can take the "auto-import" feature to get rid of using dllimport.
928ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
929LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \
930 -L $(SharedLibDir)
931endif
Jeffrey Yasskinc9017192010-02-25 06:34:33 +0000932LLVMLibsOptions += -lLLVM-$(LLVMVersion)
Anton Korobeynikov59a430f2010-08-17 19:03:03 +0000933LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)LLVM-$(LLVMVersion)$(SHLIBEXT)
Jeffrey Yasskinc9017192010-02-25 06:34:33 +0000934else
Chris Lattnerf636aa92010-09-01 16:11:17 +0000935
936ifndef NO_LLVM_CONFIG
937LLVMConfigLibs := $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)
938ifeq ($(LLVMConfigLibs),Error)
939$(error llvm-config --libs failed)
940endif
941LLVMLibsOptions += $(LLVMConfigLibs)
942LLVMConfigLibfiles := $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS) || echo Error)
943ifeq ($(LLVMConfigLibfiles),Error)
944$(error llvm-config --libfiles failed)
945endif
946LLVMLibsPaths += $(LLVM_CONFIG) $(LLVMConfigLibfiles)
947endif
948
Chris Lattneref0d0f12006-09-04 04:47:21 +0000949endif
Chris Lattner55e6c4a2006-09-04 04:50:10 +0000950endif
Jeffrey Yasskinc9017192010-02-25 06:34:33 +0000951endif
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000952
Dan Gohmanb16b53b2010-04-15 20:54:25 +0000953# Set up the library exports file.
954ifdef EXPORTED_SYMBOL_FILE
955
956# First, set up the native export file, which may differ from the source
957# export file.
958
959ifeq ($(HOST_OS),Darwin)
960# Darwin convention prefixes symbols with underscores.
Dan Gohman7c52f2e2010-04-15 23:08:00 +0000961NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).sed
Dan Gohman2d675f12010-04-15 22:46:27 +0000962$(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
Dan Gohmanf4ef72e2010-06-01 17:08:56 +0000963 $(Verb) sed -e 's/^/_/' < $< > $@
Dan Gohmanb16b53b2010-04-15 20:54:25 +0000964clean-local::
965 -$(Verb) $(RM) -f $(NativeExportsFile)
966else
Dan Gohmanda612d62010-06-01 14:56:56 +0000967ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
968# Gold and BFD ld require a version script rather than a plain list.
969NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).map
970$(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
971 $(Verb) echo "{" > $@
972 $(Verb) grep -q "\<" $< && echo " global:" >> $@ || :
Dan Gohmanf4ef72e2010-06-01 17:08:56 +0000973 $(Verb) sed -e 's/$$/;/' -e 's/^/ /' < $< >> $@
Dan Gohmanda612d62010-06-01 14:56:56 +0000974 $(Verb) echo " local: *;" >> $@
975 $(Verb) echo "};" >> $@
976clean-local::
977 -$(Verb) $(RM) -f $(NativeExportsFile)
978else
Anton Korobeynikov59a430f2010-08-17 19:03:03 +0000979ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
Dan Gohman9a7570c2010-09-03 17:29:33 +0000980# GNU ld Win32 accepts .DEF files that contain "DATA" entries.
Anton Korobeynikov59a430f2010-08-17 19:03:03 +0000981NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE:.exports=.def))
Anton Korobeynikov59a430f2010-08-17 19:03:03 +0000982$(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir
983 $(Echo) Generating $(notdir $@)
984 $(Verb) $(ECHO) "EXPORTS" > $@
985 $(Verb) $(CAT) $< >> $@
986clean-local::
987 -$(Verb) $(RM) -f $(NativeExportsFile)
988else
Dan Gohman9a7570c2010-09-03 17:29:33 +0000989# Default behavior: just use the exports file verbatim.
990NativeExportsFile := $(EXPORTED_SYMBOL_FILE)
991endif
992endif
993endif
994
995# Now add the linker command-line options to use the native export file.
996
997# Darwin
998ifeq ($(HOST_OS),Darwin)
999LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
1000endif
Anton Korobeynikov59a430f2010-08-17 19:03:03 +00001001
Dan Gohmane05f6092010-04-16 22:58:15 +00001002# gold, bfd ld, etc.
Dan Gohmanda612d62010-06-01 14:56:56 +00001003ifeq ($(HAVE_LINK_VERSION_SCRIPT),1)
1004LLVMLibsOptions += -Wl,--version-script,$(NativeExportsFile)
Dan Gohmanb16b53b2010-04-15 20:54:25 +00001005endif
1006
Dan Gohman9a7570c2010-09-03 17:29:33 +00001007# Windows
1008ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1009# LLVMLibsOptions is invalidated at processing tools/llvm-shlib.
1010SharedLinkOptions += $(NativeExportsFile)
Dan Gohmanb16b53b2010-04-15 20:54:25 +00001011endif
1012
Anton Korobeynikov59a430f2010-08-17 19:03:03 +00001013endif
1014
Reid Spencer8f9e21e2005-05-19 00:37:31 +00001015###############################################################################
Reid Spencer3a561f52004-10-23 20:04:14 +00001016# Library Build Rules: Four ways to build a library
1017###############################################################################
Chris Lattner00950542001-06-06 20:29:01 +00001018
Reid Spencer7980ea42004-12-05 05:17:22 +00001019#---------------------------------------------------------
1020# Bytecode Module Targets:
1021# If the user set MODULE_NAME then they want to build a
1022# bytecode module from the sources. We compile all the
1023# sources and link it together into a single bytecode
1024# module.
1025#---------------------------------------------------------
1026
1027ifdef MODULE_NAME
Daniel Dunbar7cfbe252010-02-23 10:28:06 +00001028ifeq ($(strip $(LLVMCC)),)
1029$(warning Modules require LLVM capable compiler but none is available ****)
Reid Spencer9a8398e2005-02-14 21:54:08 +00001030else
Reid Spencer7980ea42004-12-05 05:17:22 +00001031
1032Module := $(LibDir)/$(MODULE_NAME).bc
Daniel Dunbar112257d2010-02-23 09:28:50 +00001033LinkModule := $(LLVMLD) -r
Reid Spencerbbd5e432006-04-12 18:21:35 +00001034
Reid Spencer7980ea42004-12-05 05:17:22 +00001035
1036ifdef EXPORTED_SYMBOL_FILE
Chris Lattner89681112006-01-27 22:13:12 +00001037LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer7980ea42004-12-05 05:17:22 +00001038endif
1039
Reid Spencer43eb96c2007-02-09 15:52:07 +00001040$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
Reid Spencer0d255bd2005-05-13 18:32:54 +00001041 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
Reid Spencer7980ea42004-12-05 05:17:22 +00001042 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
1043
1044all-local:: $(Module)
1045
1046clean-local::
1047ifneq ($(strip $(Module)),)
1048 -$(Verb) $(RM) -f $(Module)
1049endif
1050
Reid Spencerab3690b2004-12-13 07:38:07 +00001051ifdef BYTECODE_DESTINATION
1052ModuleDestDir := $(BYTECODE_DESTINATION)
1053else
Erick Tryzelaard4076cf2010-03-04 20:56:19 +00001054ModuleDestDir := $(DESTDIR)$(PROJ_libdir)
Reid Spencerab3690b2004-12-13 07:38:07 +00001055endif
Reid Spencer7980ea42004-12-05 05:17:22 +00001056
Reid Spencera2a31bf2007-02-06 18:53:14 +00001057ifdef NO_INSTALL
1058install-local::
1059 $(Echo) Install circumvented with NO_INSTALL
1060uninstall-local::
1061 $(Echo) Uninstall circumvented with NO_INSTALL
1062else
Reid Spencerab3690b2004-12-13 07:38:07 +00001063DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
1064
1065install-module:: $(DestModule)
Reid Spencer7980ea42004-12-05 05:17:22 +00001066install-local:: $(DestModule)
1067
Misha Brukmanef5dc702009-01-08 02:11:55 +00001068$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencer7980ea42004-12-05 05:17:22 +00001069 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
Reid Spencer151bbe42005-02-24 21:30:37 +00001070 $(Verb) $(DataInstall) $(Module) $(DestModule)
Reid Spencer7980ea42004-12-05 05:17:22 +00001071
1072uninstall-local::
1073 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
1074 -$(Verb) $(RM) -f $(DestModule)
Reid Spencera2a31bf2007-02-06 18:53:14 +00001075endif
Reid Spencer7980ea42004-12-05 05:17:22 +00001076
1077endif
Reid Spencer9a8398e2005-02-14 21:54:08 +00001078endif
Brian Gaeke8abff792004-01-22 22:53:48 +00001079
Reid Spencer3a561f52004-10-23 20:04:14 +00001080# if we're building a library ...
Chris Lattner00950542001-06-06 20:29:01 +00001081ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +00001082
Misha Brukmanf547a122009-08-17 15:31:24 +00001083# Make sure there isn't any extraneous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +00001084LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencer492c2932005-01-11 04:31:07 +00001085ifdef LOADABLE_MODULE
Rafael Espindola0ecd2962011-02-03 22:01:15 +00001086BaseLibName.A := $(LIBRARYNAME).a
1087BaseLibName.SO := $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencer492c2932005-01-11 04:31:07 +00001088else
Rafael Espindola0ecd2962011-02-03 22:01:15 +00001089BaseLibName.A := lib$(LIBRARYNAME).a
1090BaseLibName.SO := $(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)
Nick Lewyckya15dc032009-02-26 07:44:16 +00001091endif
Rafael Espindola0ecd2962011-02-03 22:01:15 +00001092LibName.A := $(LibDir)/$(BaseLibName.A)
1093LibName.SO := $(SharedLibDir)/$(BaseLibName.SO)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001094LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer9a2f1372004-12-02 09:28:21 +00001095LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnerccb4ebd2002-09-16 22:34:56 +00001096
Reid Spencer3a561f52004-10-23 20:04:14 +00001097#---------------------------------------------------------
1098# Shared Library Targets:
1099# If the user asked for a shared library to be built
1100# with the SHARED_LIBRARY variable, then we provide
1101# targets for building them.
1102#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +00001103ifdef SHARED_LIBRARY
1104
Nick Lewyckya15dc032009-02-26 07:44:16 +00001105all-local:: $(LibName.SO)
Reid Spencer4d71b662004-10-22 21:01:56 +00001106
Dan Gohmanb16b53b2010-04-15 20:54:25 +00001107ifdef EXPORTED_SYMBOL_FILE
1108$(LibName.SO): $(NativeExportsFile)
1109endif
1110
Reid Spencer8f9e21e2005-05-19 00:37:31 +00001111ifdef LINK_LIBS_IN_SHARED
Reid Spencer42fe4552006-08-07 23:12:15 +00001112ifdef LOADABLE_MODULE
Chris Lattner166f45e2006-11-15 21:04:15 +00001113SharedLibKindMessage := "Loadable Module"
Daniel Dunbar7bc0f272010-12-08 01:48:05 +00001114SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions)
Reid Spencer42fe4552006-08-07 23:12:15 +00001115else
1116SharedLibKindMessage := "Shared Library"
1117endif
Anton Korobeynikov59a430f2010-08-17 19:03:03 +00001118$(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
Reid Spencer42fe4552006-08-07 23:12:15 +00001119 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
Dan Gohman6b156a32010-07-26 20:15:47 +00001120 $(notdir $@)
Nick Lewyckya15dc032009-02-26 07:44:16 +00001121 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
Torok Edwin2efc73d2009-05-26 19:11:47 +00001122 $(ProjLibsOptions) $(LLVMLibsOptions) $(LIBS)
Reid Spencer8f9e21e2005-05-19 00:37:31 +00001123else
Anton Korobeynikov59a430f2010-08-17 19:03:03 +00001124$(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
Dan Gohman6b156a32010-07-26 20:15:47 +00001125 $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
Nick Lewyckya15dc032009-02-26 07:44:16 +00001126 $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
Reid Spencer8f9e21e2005-05-19 00:37:31 +00001127endif
Reid Spencer3a561f52004-10-23 20:04:14 +00001128
1129clean-local::
Nick Lewyckya15dc032009-02-26 07:44:16 +00001130ifneq ($(strip $(LibName.SO)),)
1131 -$(Verb) $(RM) -f $(LibName.SO)
Reid Spencere5487ba2004-10-24 07:53:21 +00001132endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001133
Reid Spencera2a31bf2007-02-06 18:53:14 +00001134ifdef NO_INSTALL
1135install-local::
1136 $(Echo) Install circumvented with NO_INSTALL
1137uninstall-local::
1138 $(Echo) Uninstall circumvented with NO_INSTALL
1139else
Rafael Espindolabbe03f82010-05-16 03:13:23 +00001140
Anton Korobeynikov59a430f2010-08-17 19:03:03 +00001141# Win32.DLL prefers to be located on the "PATH" of binaries.
1142ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
1143DestSharedLibDir := $(DESTDIR)$(PROJ_bindir)
Rafael Espindolabbe03f82010-05-16 03:13:23 +00001144else
Anton Korobeynikov59a430f2010-08-17 19:03:03 +00001145DestSharedLibDir := $(DESTDIR)$(PROJ_libdir)
Rafael Espindolabbe03f82010-05-16 03:13:23 +00001146endif
Rafael Espindola0ecd2962011-02-03 22:01:15 +00001147DestSharedLib := $(DestSharedLibDir)/$(BaseLibName.SO)
Reid Spencer4d71b662004-10-22 21:01:56 +00001148
Reid Spencerc6dcc6a2004-10-28 07:57:28 +00001149install-local:: $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +00001150
Anton Korobeynikov59a430f2010-08-17 19:03:03 +00001151$(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
Reid Spencer9af3b292004-11-01 07:50:27 +00001152 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Nick Lewyckya15dc032009-02-26 07:44:16 +00001153 $(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +00001154
Misha Brukmanef5dc702009-01-08 02:11:55 +00001155uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +00001156 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Anton Korobeynikov59a430f2010-08-17 19:03:03 +00001157 -$(Verb) $(RM) -f $(DestSharedLibDir)/$(SharedPrefix)$(LIBRARYNAME).*
Reid Spencera2a31bf2007-02-06 18:53:14 +00001158endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001159endif
1160
Reid Spencer3a561f52004-10-23 20:04:14 +00001161#---------------------------------------------------------
1162# Bytecode Library Targets:
1163# If the user asked for a bytecode library to be built
Misha Brukmanef5dc702009-01-08 02:11:55 +00001164# with the BYTECODE_LIBRARY variable, then we provide
Reid Spencer3a561f52004-10-23 20:04:14 +00001165# targets for building them.
1166#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +00001167ifdef BYTECODE_LIBRARY
Daniel Dunbar7cfbe252010-02-23 10:28:06 +00001168ifeq ($(strip $(LLVMCC)),)
1169$(warning Bytecode libraries require LLVM capable compiler but none is available ****)
Reid Spencer9a8398e2005-02-14 21:54:08 +00001170else
Reid Spencer4d71b662004-10-22 21:01:56 +00001171
Reid Spencer9a2f1372004-12-02 09:28:21 +00001172all-local:: $(LibName.BCA)
1173
1174ifdef EXPORTED_SYMBOL_FILE
Daniel Dunbar112257d2010-02-23 09:28:50 +00001175BCLinkLib = $(LLVMLD) -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer9a2f1372004-12-02 09:28:21 +00001176
Reid Spencer43eb96c2007-02-09 15:52:07 +00001177$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
Chris Lattner264ccbe2004-12-15 17:14:06 +00001178 $(LLVMToolDir)/llvm-ar
Reid Spencer9a2f1372004-12-02 09:28:21 +00001179 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
1180 "(internalize)"
Daniel Dunbare5f1b2f2009-08-28 16:14:46 +00001181 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).internalize $(ObjectsBC)
Reid Spencerefd6bb32004-12-13 03:59:35 +00001182 $(Verb) $(RM) -f $@
Daniel Dunbare5f1b2f2009-08-28 16:14:46 +00001183 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).internalize.bc
Reid Spencer4d71b662004-10-22 21:01:56 +00001184else
Reid Spencerf2ac1892004-12-16 07:36:08 +00001185$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
Chris Lattner264ccbe2004-12-15 17:14:06 +00001186 $(LLVMToolDir)/llvm-ar
Reid Spencer9a2f1372004-12-02 09:28:21 +00001187 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencerefd6bb32004-12-13 03:59:35 +00001188 $(Verb) $(RM) -f $@
Reid Spencer9a2f1372004-12-02 09:28:21 +00001189 $(Verb) $(LArchive) $@ $(ObjectsBC)
1190
Reid Spencer4d71b662004-10-22 21:01:56 +00001191endif
1192
Reid Spencer3a561f52004-10-23 20:04:14 +00001193clean-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +00001194ifneq ($(strip $(LibName.BCA)),)
1195 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencere5487ba2004-10-24 07:53:21 +00001196endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001197
Reid Spencer8f094f32004-12-13 07:28:21 +00001198ifdef BYTECODE_DESTINATION
1199BytecodeDestDir := $(BYTECODE_DESTINATION)
1200else
Erick Tryzelaard4076cf2010-03-04 20:56:19 +00001201BytecodeDestDir := $(DESTDIR)$(PROJ_libdir)
Reid Spencer8f094f32004-12-13 07:28:21 +00001202endif
1203
Daniel Dunbard62031e2009-05-12 05:35:40 +00001204DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).bca
Reid Spencer9a2f1372004-12-02 09:28:21 +00001205
Reid Spencer44cb1b32004-12-03 20:08:48 +00001206install-bytecode-local:: $(DestBytecodeLib)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001207
Reid Spencera2a31bf2007-02-06 18:53:14 +00001208ifdef NO_INSTALL
1209install-local::
1210 $(Echo) Install circumvented with NO_INSTALL
1211uninstall-local::
1212 $(Echo) Uninstall circumvented with NO_INSTALL
1213else
Reid Spencerc6dcc6a2004-10-28 07:57:28 +00001214install-local:: $(DestBytecodeLib)
Chris Lattner481cc7c2003-08-15 02:18:35 +00001215
Mike Stumpb445d742009-02-12 23:45:11 +00001216$(DestBytecodeLib): $(LibName.BCA) $(BytecodeDestDir)
Reid Spencer9a2f1372004-12-02 09:28:21 +00001217 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerb80621f2005-02-24 21:36:32 +00001218 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
Reid Spencere5487ba2004-10-24 07:53:21 +00001219
Reid Spencerc6dcc6a2004-10-28 07:57:28 +00001220uninstall-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +00001221 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001222 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencera2a31bf2007-02-06 18:53:14 +00001223endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001224endif
Reid Spencer9a8398e2005-02-14 21:54:08 +00001225endif
Vikram S. Adve60f56062002-08-02 18:34:12 +00001226
Reid Spencercc2d1e22004-10-30 09:19:36 +00001227#---------------------------------------------------------
Chris Lattner6be92662009-06-16 23:00:42 +00001228# Library Targets:
1229# If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to
1230# building an archive.
Reid Spencercc2d1e22004-10-30 09:19:36 +00001231#---------------------------------------------------------
Jeffrey Yasskinc9017192010-02-25 06:34:33 +00001232ifndef NO_BUILD_ARCHIVE
Chris Lattner89938082005-10-24 02:21:45 +00001233ifndef BUILD_ARCHIVE
Chris Lattner6be92662009-06-16 23:00:42 +00001234ifndef LOADABLE_MODULE
1235BUILD_ARCHIVE = 1
Reid Spencera2a31bf2007-02-06 18:53:14 +00001236endif
Chris Lattnere62dbe92002-07-23 17:56:16 +00001237endif
Jeffrey Yasskinc9017192010-02-25 06:34:33 +00001238endif
Chris Lattner760da062003-03-14 20:25:22 +00001239
Reid Spencercc2d1e22004-10-30 09:19:36 +00001240#---------------------------------------------------------
1241# Archive Library Targets:
Misha Brukmanef5dc702009-01-08 02:11:55 +00001242# If the user wanted a regular archive library built,
Reid Spencercc2d1e22004-10-30 09:19:36 +00001243# then we provide targets for building them.
1244#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +00001245ifdef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +00001246
Reid Spencercc2d1e22004-10-30 09:19:36 +00001247all-local:: $(LibName.A)
1248
Reid Spencerf2ac1892004-12-16 07:36:08 +00001249$(LibName.A): $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +00001250 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001251 -$(Verb) $(RM) -f $@
Bill Wendlingdfaf4f92009-01-03 22:46:50 +00001252 $(Verb) $(Archive) $@ $(ObjectsO)
1253 $(Verb) $(Ranlib) $@
Vikram S. Adve41e78912002-09-20 14:03:13 +00001254
Reid Spencer3a561f52004-10-23 20:04:14 +00001255clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001256ifneq ($(strip $(LibName.A)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001257 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner00950542001-06-06 20:29:01 +00001258endif
1259
Reid Spencera2a31bf2007-02-06 18:53:14 +00001260ifdef NO_INSTALL
1261install-local::
1262 $(Echo) Install circumvented with NO_INSTALL
1263uninstall-local::
1264 $(Echo) Uninstall circumvented with NO_INSTALL
Daniel Dunbaree40a162010-04-30 22:00:17 +00001265else
1266ifdef NO_INSTALL_ARCHIVES
Daniel Dunbar24d9d972010-04-30 20:04:53 +00001267install-local::
1268 $(Echo) Install circumvented with NO_INSTALL
1269uninstall-local::
1270 $(Echo) Uninstall circumvented with NO_INSTALL
Reid Spencera2a31bf2007-02-06 18:53:14 +00001271else
Erick Tryzelaard4076cf2010-03-04 20:56:19 +00001272DestArchiveLib := $(DESTDIR)$(PROJ_libdir)/lib$(LIBRARYNAME).a
Reid Spencere5487ba2004-10-24 07:53:21 +00001273
Reid Spencerc6dcc6a2004-10-28 07:57:28 +00001274install-local:: $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +00001275
Erick Tryzelaard4076cf2010-03-04 20:56:19 +00001276$(DestArchiveLib): $(LibName.A) $(DESTDIR)$(PROJ_libdir)
Reid Spencer9af3b292004-11-01 07:50:27 +00001277 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Erick Tryzelaard4076cf2010-03-04 20:56:19 +00001278 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_libdir)
Nick Lewyckya15dc032009-02-26 07:44:16 +00001279 $(Verb) $(INSTALL) $(LibName.A) $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +00001280
Reid Spencerc6dcc6a2004-10-28 07:57:28 +00001281uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +00001282 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001283 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencera2a31bf2007-02-06 18:53:14 +00001284endif
Reid Spencere5487ba2004-10-24 07:53:21 +00001285endif
Daniel Dunbaree40a162010-04-30 22:00:17 +00001286endif
Reid Spencere5487ba2004-10-24 07:53:21 +00001287
1288# endif LIBRARYNAME
Misha Brukmanef5dc702009-01-08 02:11:55 +00001289endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001290
Reid Spencerb1dd3dd2004-10-24 08:21:04 +00001291###############################################################################
1292# Tool Build Rules: Build executable tool based on TOOLNAME option
1293###############################################################################
1294
Chris Lattner1cbc29f2001-09-07 22:57:58 +00001295ifdef TOOLNAME
1296
Reid Spencercc2d1e22004-10-30 09:19:36 +00001297#---------------------------------------------------------
1298# Set up variables for building a tool.
1299#---------------------------------------------------------
Daniel Dunbarfd96b132009-11-19 00:14:53 +00001300TOOLEXENAME := $(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer815cbcf2004-11-18 10:03:46 +00001301ifdef EXAMPLE_TOOL
Daniel Dunbarfd96b132009-11-19 00:14:53 +00001302ToolBuildPath := $(ExmplDir)/$(TOOLEXENAME)
Reid Spencer815cbcf2004-11-18 10:03:46 +00001303else
Daniel Dunbarfd96b132009-11-19 00:14:53 +00001304ToolBuildPath := $(ToolDir)/$(TOOLEXENAME)
1305endif
1306
1307# TOOLALIAS is a name to symlink (or copy) the tool to.
1308ifdef TOOLALIAS
1309ifdef EXAMPLE_TOOL
1310ToolAliasBuildPath := $(ExmplDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1311else
1312ToolAliasBuildPath := $(ToolDir)/$(strip $(TOOLALIAS))$(EXEEXT)
1313endif
Reid Spencer815cbcf2004-11-18 10:03:46 +00001314endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +00001315
Reid Spencercc2d1e22004-10-30 09:19:36 +00001316#---------------------------------------------------------
Chris Lattner61863a32009-02-26 17:47:49 +00001317# Prune Exports
1318#---------------------------------------------------------
1319
1320# If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
1321# not exporting all of the weak symbols from the binary. This reduces dyld
1322# startup time by 4x on darwin in some cases.
1323ifdef TOOL_NO_EXPORTS
Anton Korobeynikove55db742009-08-18 00:40:33 +00001324ifeq ($(HOST_OS),Darwin)
Chris Lattner1b030a12009-03-10 17:15:56 +00001325
1326# Tiger tools don't support this.
1327ifneq ($(DARWIN_MAJVERS),4)
Dan Gohmane05f6092010-04-16 22:58:15 +00001328LD.Flags += -Wl,-exported_symbol,_main
Chris Lattner61863a32009-02-26 17:47:49 +00001329endif
Chris Lattner1b030a12009-03-10 17:15:56 +00001330endif
Chris Lattner61863a32009-02-26 17:47:49 +00001331
Anton Korobeynikove55db742009-08-18 00:40:33 +00001332ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD))
Bruno Cardoso Lopes6651b3f2010-07-20 08:44:20 +00001333ifneq ($(ARCH), Mips)
Nick Lewycky0d203662009-10-25 03:22:00 +00001334 LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
Chris Lattner61863a32009-02-26 17:47:49 +00001335endif
1336endif
Bruno Cardoso Lopes6651b3f2010-07-20 08:44:20 +00001337endif
Chris Lattner61863a32009-02-26 17:47:49 +00001338
Devang Patel83be4512010-07-15 20:57:09 +00001339#---------------------------------------------------------
Daniel Dunbarccfaa4b2010-09-16 00:42:32 +00001340# Tool Order File Support
1341#---------------------------------------------------------
1342
1343ifeq ($(HOST_OS),Darwin)
1344ifdef TOOL_ORDER_FINE
1345
1346LD.Flags += -Wl,-order_file,$(TOOL_ORDER_FILE)
1347
1348endif
1349endif
1350
1351#---------------------------------------------------------
Devang Patel83be4512010-07-15 20:57:09 +00001352# Tool Version Info Support
1353#---------------------------------------------------------
1354
1355ifeq ($(HOST_OS),Darwin)
1356ifdef TOOL_INFO_PLIST
1357
1358LD.Flags += -Wl,-sectcreate,__TEXT,__info_plist,$(ObjDir)/$(TOOL_INFO_PLIST)
1359
1360$(ToolBuildPath): $(ObjDir)/$(TOOL_INFO_PLIST)
1361
Daniel Dunbar14ceb872010-07-15 21:51:52 +00001362$(ObjDir)/$(TOOL_INFO_PLIST): $(PROJ_SRC_DIR)/$(TOOL_INFO_PLIST).in $(ObjDir)/.dir
Devang Patel83be4512010-07-15 20:57:09 +00001363 $(Echo) "Creating $(TOOLNAME) '$(TOOL_INFO_PLIST)' file..."
1364 $(Verb)sed -e "s#@TOOL_INFO_UTI@#$(TOOL_INFO_UTI)#g" \
1365 -e "s#@TOOL_INFO_NAME@#$(TOOL_INFO_NAME)#g" \
1366 -e "s#@TOOL_INFO_VERSION@#$(TOOL_INFO_VERSION)#g" \
1367 -e "s#@TOOL_INFO_BUILD_VERSION@#$(TOOL_INFO_BUILD_VERSION)#g" \
1368 $< > $@
1369
1370endif
1371endif
Chris Lattner61863a32009-02-26 17:47:49 +00001372
1373#---------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +00001374# Provide targets for building the tools
1375#---------------------------------------------------------
Daniel Dunbarfd96b132009-11-19 00:14:53 +00001376all-local:: $(ToolBuildPath) $(ToolAliasBuildPath)
John Criswell2a6530f2003-06-27 16:58:44 +00001377
Reid Spencer3a561f52004-10-23 20:04:14 +00001378clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001379ifneq ($(strip $(ToolBuildPath)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001380 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencere5487ba2004-10-24 07:53:21 +00001381endif
Daniel Dunbarfd96b132009-11-19 00:14:53 +00001382ifneq ($(strip $(ToolAliasBuildPath)),)
1383 -$(Verb) $(RM) -f $(ToolAliasBuildPath)
1384endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +00001385
Reid Spencer815cbcf2004-11-18 10:03:46 +00001386ifdef EXAMPLE_TOOL
1387$(ToolBuildPath): $(ExmplDir)/.dir
1388else
1389$(ToolBuildPath): $(ToolDir)/.dir
1390endif
1391
Chris Lattnera7868af2006-09-04 06:39:52 +00001392$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencer9af3b292004-11-01 07:50:27 +00001393 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Nick Lewyckya15dc032009-02-26 07:44:16 +00001394 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
Reid Spencerab519972006-05-16 06:25:14 +00001395 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
Chris Lattnerd25ad612006-02-14 04:25:54 +00001396 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
Misha Brukmanef5dc702009-01-08 02:11:55 +00001397 $(StripWarnMsg)
Reid Spencere5487ba2004-10-24 07:53:21 +00001398
Daniel Dunbarfd96b132009-11-19 00:14:53 +00001399ifneq ($(strip $(ToolAliasBuildPath)),)
1400$(ToolAliasBuildPath): $(ToolBuildPath)
1401 $(Echo) Creating $(BuildMode) Alias $(TOOLALIAS) $(StripWarnMsg)
1402 $(Verb) $(RM) -f $(ToolAliasBuildPath)
1403 $(Verb) $(AliasTool) $(TOOLEXENAME) $(ToolAliasBuildPath)
Dan Gohmanf9d11632010-08-18 01:35:53 +00001404 $(Echo) ======= Finished Creating $(BuildMode) Alias $(TOOLALIAS) \
Daniel Dunbarfd96b132009-11-19 00:14:53 +00001405 $(StripWarnMsg)
1406endif
1407
Reid Spencera2a31bf2007-02-06 18:53:14 +00001408ifdef NO_INSTALL
1409install-local::
1410 $(Echo) Install circumvented with NO_INSTALL
1411uninstall-local::
1412 $(Echo) Uninstall circumvented with NO_INSTALL
1413else
Erick Tryzelaard4076cf2010-03-04 20:56:19 +00001414DestTool = $(DESTDIR)$(PROJ_bindir)/$(TOOLEXENAME)
Reid Spencere5487ba2004-10-24 07:53:21 +00001415
Reid Spencerc6dcc6a2004-10-28 07:57:28 +00001416install-local:: $(DestTool)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001417
Erick Tryzelaard4076cf2010-03-04 20:56:19 +00001418$(DestTool): $(ToolBuildPath) $(DESTDIR)$(PROJ_bindir)
Reid Spencer9af3b292004-11-01 07:50:27 +00001419 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001420 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +00001421
Reid Spencerc6dcc6a2004-10-28 07:57:28 +00001422uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +00001423 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001424 -$(Verb) $(RM) -f $(DestTool)
Daniel Dunbarfd96b132009-11-19 00:14:53 +00001425
1426# TOOLALIAS install.
1427ifdef TOOLALIAS
Chris Lattner97d7b102010-03-10 21:27:53 +00001428DestToolAlias = $(DESTDIR)$(PROJ_bindir)/$(TOOLALIAS)$(EXEEXT)
Daniel Dunbarfd96b132009-11-19 00:14:53 +00001429
1430install-local:: $(DestToolAlias)
1431
Daniel Dunbar8fcd4182010-04-30 20:47:09 +00001432$(DestToolAlias): $(DestTool)
Daniel Dunbarfd96b132009-11-19 00:14:53 +00001433 $(Echo) Installing $(BuildMode) $(DestToolAlias)
1434 $(Verb) $(RM) -f $(DestToolAlias)
1435 $(Verb) $(AliasTool) $(TOOLEXENAME) $(DestToolAlias)
1436
1437uninstall-local::
1438 $(Echo) Uninstalling $(BuildMode) $(DestToolAlias)
1439 -$(Verb) $(RM) -f $(DestToolAlias)
1440endif
1441
Reid Spencera2a31bf2007-02-06 18:53:14 +00001442endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001443endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +00001444
Reid Spencercc2d1e22004-10-30 09:19:36 +00001445###############################################################################
Misha Brukmanef5dc702009-01-08 02:11:55 +00001446# Object Build Rules: Build object files based on sources
Reid Spencercc2d1e22004-10-30 09:19:36 +00001447###############################################################################
1448
Duraid Madina197ab872006-02-15 03:23:26 +00001449# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
Anton Korobeynikove55db742009-08-18 00:40:33 +00001450ifeq ($(HOST_OS),HP-UX)
Duraid Madina197ab872006-02-15 03:23:26 +00001451 DISABLE_AUTO_DEPENDENCIES=1
1452endif
1453
Reid Spencercc2d1e22004-10-30 09:19:36 +00001454# Provide rule sets for when dependency generation is enabled
Reid Spencer4d71b662004-10-22 21:01:56 +00001455ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve41e78912002-09-20 14:03:13 +00001456
Reid Spencercc2d1e22004-10-30 09:19:36 +00001457#---------------------------------------------------------
Nick Lewyckya15dc032009-02-26 07:44:16 +00001458# Create .o files in the ObjDir directory from the .cpp and .c files...
Reid Spencercc2d1e22004-10-30 09:19:36 +00001459#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001460
Chris Lattnere43ba3d2007-12-31 23:58:31 +00001461DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
Nick Lewyckya15dc032009-02-26 07:44:16 +00001462 -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
Gabor Greif0a4c3782008-02-27 13:34:15 +00001463
Daniel Dunbarfab3d682009-05-12 06:35:50 +00001464# If the build succeeded, move the dependency file over, otherwise
1465# remove it.
Chris Lattnere43ba3d2007-12-31 23:58:31 +00001466DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1467 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1468
Daniel Dunbar9ae4ca62010-09-09 17:38:11 +00001469$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
Jakob Stoklund Olesen52020782009-10-04 17:54:36 +00001470 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
Nick Lewyckya15dc032009-02-26 07:44:16 +00001471 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
Chris Lattnere43ba3d2007-12-31 23:58:31 +00001472 $(DEPEND_MOVEFILE)
Reid Spencer3a561f52004-10-23 20:04:14 +00001473
Daniel Dunbar9ae4ca62010-09-09 17:38:11 +00001474$(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
Greg Clayton43bc79a2010-07-13 18:47:09 +00001475 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1476 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1477 $(DEPEND_MOVEFILE)
1478
Daniel Dunbar9ae4ca62010-09-09 17:38:11 +00001479$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
Chris Lattnerd92490f2006-06-21 20:58:03 +00001480 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
Nick Lewyckya15dc032009-02-26 07:44:16 +00001481 $(Verb) if $(Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
Chris Lattnere43ba3d2007-12-31 23:58:31 +00001482 $(DEPEND_MOVEFILE)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001483
Daniel Dunbar9ae4ca62010-09-09 17:38:11 +00001484$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
Chris Lattnerd92490f2006-06-21 20:58:03 +00001485 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
Nick Lewyckya15dc032009-02-26 07:44:16 +00001486 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
Chris Lattnere43ba3d2007-12-31 23:58:31 +00001487 $(DEPEND_MOVEFILE)
Reid Spencer3a561f52004-10-23 20:04:14 +00001488
Daniel Dunbar9ae4ca62010-09-09 17:38:11 +00001489$(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(PROJ_MAKEFILE)
Greg Clayton43bc79a2010-07-13 18:47:09 +00001490 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1491 $(Verb) if $(Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1492 $(DEPEND_MOVEFILE)
1493
Reid Spencercc2d1e22004-10-30 09:19:36 +00001494#---------------------------------------------------------
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001495# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
Reid Spencercc2d1e22004-10-30 09:19:36 +00001496#---------------------------------------------------------
Chris Lattner89681112006-01-27 22:13:12 +00001497
Daniel Dunbarfab3d682009-05-12 06:35:50 +00001498BC_DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.bc.d.tmp" \
1499 -MT "$(ObjDir)/$*.ll" -MT "$(ObjDir)/$*.bc.d"
1500
1501# If the build succeeded, move the dependency file over, otherwise
1502# remove it.
1503BC_DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.bc.d.tmp" "$(ObjDir)/$*.bc.d"; \
1504 else $(RM) "$(ObjDir)/$*.bc.d.tmp"; exit 1; fi
1505
Daniel Dunbar7cfbe252010-02-23 10:28:06 +00001506$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
Reid Spencer9af3b292004-11-01 07:50:27 +00001507 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Daniel Dunbarfab3d682009-05-12 06:35:50 +00001508 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
Duncan Sands8ed69262010-11-25 21:14:55 +00001509 $< -o $(ObjDir)/$*.ll -S -$(LLVMCC_EMITIR_FLAG) ; \
Daniel Dunbarfab3d682009-05-12 06:35:50 +00001510 $(BC_DEPEND_MOVEFILE)
Reid Spencer4d71b662004-10-22 21:01:56 +00001511
Greg Clayton43bc79a2010-07-13 18:47:09 +00001512$(ObjDir)/%.ll: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1513 $(Echo) "Compiling $*.mm for $(BuildMode) build (bytecode)"
1514 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
Duncan Sands8ed69262010-11-25 21:14:55 +00001515 $< -o $(ObjDir)/$*.ll -S -$(LLVMCC_EMITIR_FLAG) ; \
Greg Clayton43bc79a2010-07-13 18:47:09 +00001516 $(BC_DEPEND_MOVEFILE)
1517
Daniel Dunbar7cfbe252010-02-23 10:28:06 +00001518$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001519 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Daniel Dunbarfab3d682009-05-12 06:35:50 +00001520 $(Verb) if $(BCCompile.CXX) $(BC_DEPEND_OPTIONS) \
Duncan Sands8ed69262010-11-25 21:14:55 +00001521 $< -o $(ObjDir)/$*.ll -S -$(LLVMCC_EMITIR_FLAG) ; \
Daniel Dunbarfab3d682009-05-12 06:35:50 +00001522 $(BC_DEPEND_MOVEFILE)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001523
Daniel Dunbar7cfbe252010-02-23 10:28:06 +00001524$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
Reid Spencer9af3b292004-11-01 07:50:27 +00001525 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Daniel Dunbarfab3d682009-05-12 06:35:50 +00001526 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
Duncan Sands8ed69262010-11-25 21:14:55 +00001527 $< -o $(ObjDir)/$*.ll -S -$(LLVMCC_EMITIR_FLAG) ; \
Daniel Dunbarfab3d682009-05-12 06:35:50 +00001528 $(BC_DEPEND_MOVEFILE)
Reid Spencer4d71b662004-10-22 21:01:56 +00001529
Greg Clayton43bc79a2010-07-13 18:47:09 +00001530$(ObjDir)/%.ll: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1531 $(Echo) "Compiling $*.m for $(BuildMode) build (bytecode)"
1532 $(Verb) if $(BCCompile.C) $(BC_DEPEND_OPTIONS) \
Duncan Sands8ed69262010-11-25 21:14:55 +00001533 $< -o $(ObjDir)/$*.ll -S -$(LLVMCC_EMITIR_FLAG) ; \
Greg Clayton43bc79a2010-07-13 18:47:09 +00001534 $(BC_DEPEND_MOVEFILE)
1535
Reid Spencercc2d1e22004-10-30 09:19:36 +00001536# Provide alternate rule sets if dependencies are disabled
Reid Spencer4d71b662004-10-22 21:01:56 +00001537else
1538
Nick Lewyckya15dc032009-02-26 07:44:16 +00001539$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerd92490f2006-06-21 20:58:03 +00001540 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
Nick Lewyckya15dc032009-02-26 07:44:16 +00001541 $(Compile.CXX) $< -o $@
Reid Spencer3a561f52004-10-23 20:04:14 +00001542
Greg Clayton43bc79a2010-07-13 18:47:09 +00001543$(ObjDir)/%.o: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1544 $(Echo) "Compiling $*.mm for $(BuildMode) build" $(PIC_FLAG)
1545 $(Compile.CXX) $< -o $@
1546
Nick Lewyckya15dc032009-02-26 07:44:16 +00001547$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerd92490f2006-06-21 20:58:03 +00001548 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
Nick Lewyckya15dc032009-02-26 07:44:16 +00001549 $(Compile.CXX) $< -o $@
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001550
Nick Lewyckya15dc032009-02-26 07:44:16 +00001551$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerd92490f2006-06-21 20:58:03 +00001552 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
Nick Lewyckya15dc032009-02-26 07:44:16 +00001553 $(Compile.C) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +00001554
Greg Clayton43bc79a2010-07-13 18:47:09 +00001555$(ObjDir)/%.o: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1556 $(Echo) "Compiling $*.m for $(BuildMode) build" $(PIC_FLAG)
1557 $(Compile.C) $< -o $@
1558
Daniel Dunbar7cfbe252010-02-23 10:28:06 +00001559$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
Reid Spencer9af3b292004-11-01 07:50:27 +00001560 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Duncan Sands8ed69262010-11-25 21:14:55 +00001561 $(BCCompile.CXX) $< -o $@ -S -$(LLVMCC_EMITIR_FLAG)
Reid Spencer4d71b662004-10-22 21:01:56 +00001562
Greg Clayton43bc79a2010-07-13 18:47:09 +00001563$(ObjDir)/%.ll: %.mm $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
1564 $(Echo) "Compiling $*.mm for $(BuildMode) build (bytecode)"
Duncan Sands8ed69262010-11-25 21:14:55 +00001565 $(BCCompile.CXX) $< -o $@ -S -$(LLVMCC_EMITIR_FLAG)
Greg Clayton43bc79a2010-07-13 18:47:09 +00001566
Daniel Dunbar7cfbe252010-02-23 10:28:06 +00001567$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCXX)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001568 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Duncan Sands8ed69262010-11-25 21:14:55 +00001569 $(BCCompile.CXX) $< -o $@ -S -$(LLVMCC_EMITIR_FLAG)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001570
Daniel Dunbar7cfbe252010-02-23 10:28:06 +00001571$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
Reid Spencer9af3b292004-11-01 07:50:27 +00001572 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Duncan Sands8ed69262010-11-25 21:14:55 +00001573 $(BCCompile.C) $< -o $@ -S -$(LLVMCC_EMITIR_FLAG)
Brian Gaeke44909cf2003-12-10 00:26:28 +00001574
Greg Clayton43bc79a2010-07-13 18:47:09 +00001575$(ObjDir)/%.ll: %.m $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMCC)
1576 $(Echo) "Compiling $*.m for $(BuildMode) build (bytecode)"
Duncan Sands8ed69262010-11-25 21:14:55 +00001577 $(BCCompile.C) $< -o $@ -S -$(LLVMCC_EMITIR_FLAG)
Greg Clayton43bc79a2010-07-13 18:47:09 +00001578
Chris Lattner1cbc29f2001-09-07 22:57:58 +00001579endif
1580
Chris Lattner8eb12de2006-06-21 21:01:20 +00001581
1582## Rules for building preprocessed (.i/.ii) outputs.
1583$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1584 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1585 $(Verb) $(Preprocess.CXX) $< -o $@
1586
Greg Clayton43bc79a2010-07-13 18:47:09 +00001587$(BuildMode)/%.ii: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1588 $(Echo) "Compiling $*.mm for $(BuildMode) build to .ii file"
1589 $(Verb) $(Preprocess.CXX) $< -o $@
1590
Chris Lattner8eb12de2006-06-21 21:01:20 +00001591$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1592 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1593 $(Verb) $(Preprocess.CXX) $< -o $@
1594
Reid Spencer44136722006-12-10 04:56:38 +00001595$(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner8eb12de2006-06-21 21:01:20 +00001596 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1597 $(Verb) $(Preprocess.C) $< -o $@
1598
Greg Clayton43bc79a2010-07-13 18:47:09 +00001599$(BuildMode)/%.i: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1600 $(Echo) "Compiling $*.m for $(BuildMode) build to .i file"
1601 $(Verb) $(Preprocess.C) $< -o $@
1602
Chris Lattner8eb12de2006-06-21 21:01:20 +00001603
1604$(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1605 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
Nick Lewyckya15dc032009-02-26 07:44:16 +00001606 $(Compile.CXX) $< -o $@ -S
Chris Lattner8eb12de2006-06-21 21:01:20 +00001607
Greg Clayton43bc79a2010-07-13 18:47:09 +00001608$(ObjDir)/%.s: %.mm $(ObjDir)/.dir $(BUILT_SOURCES)
1609 $(Echo) "Compiling $*.mm to asm for $(BuildMode) build" $(PIC_FLAG)
1610 $(Compile.CXX) $< -o $@ -S
1611
Chris Lattner8eb12de2006-06-21 21:01:20 +00001612$(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1613 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
Nick Lewyckya15dc032009-02-26 07:44:16 +00001614 $(Compile.CXX) $< -o $@ -S
Chris Lattner8eb12de2006-06-21 21:01:20 +00001615
1616$(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1617 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
Nick Lewyckya15dc032009-02-26 07:44:16 +00001618 $(Compile.C) $< -o $@ -S
Chris Lattner8eb12de2006-06-21 21:01:20 +00001619
Greg Clayton43bc79a2010-07-13 18:47:09 +00001620$(ObjDir)/%.s: %.m $(ObjDir)/.dir $(BUILT_SOURCES)
1621 $(Echo) "Compiling $*.m to asm for $(BuildMode) build" $(PIC_FLAG)
1622 $(Compile.C) $< -o $@ -S
1623
Reid Spencer8b2e1412006-11-17 03:32:33 +00001624
Chris Lattner89681112006-01-27 22:13:12 +00001625# make the C and C++ compilers strip debug info out of bytecode libraries.
Reid Spencer8b2e1412006-11-17 03:32:33 +00001626ifdef DEBUG_RUNTIME
Dan Gohman0e6a4da2009-09-08 15:52:56 +00001627$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
Reid Spencer8b2e1412006-11-17 03:32:33 +00001628 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Dan Gohman0e6a4da2009-09-08 15:52:56 +00001629 $(Verb) $(LOPT) $< -std-compile-opts -o $@
Reid Spencer8b2e1412006-11-17 03:32:33 +00001630else
Dan Gohman0e6a4da2009-09-08 15:52:56 +00001631$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LOPT)
Chris Lattner89681112006-01-27 22:13:12 +00001632 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Dan Gohman0e6a4da2009-09-08 15:52:56 +00001633 $(Verb) $(LOPT) $< -std-compile-opts -strip-debug -o $@
Reid Spencer8b2e1412006-11-17 03:32:33 +00001634endif
1635
Chris Lattner89681112006-01-27 22:13:12 +00001636
Reid Spencercc2d1e22004-10-30 09:19:36 +00001637#---------------------------------------------------------
1638# Provide rule to build .bc files from .ll sources,
1639# regardless of dependencies
1640#---------------------------------------------------------
1641$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencer9af3b292004-11-01 07:50:27 +00001642 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001643 $(Verb) $(LLVMAS) $< -f -o $@
1644
1645###############################################################################
1646# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1647###############################################################################
Chris Lattner481cc7c2003-08-15 02:18:35 +00001648
Reid Spencer4d71b662004-10-22 21:01:56 +00001649ifdef TARGET
Mikhail Glushenkov1386ae42009-03-02 09:42:59 +00001650TABLEGEN_INC_FILES_COMMON = 1
1651endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001652
Mikhail Glushenkovb3d36292010-08-15 07:07:12 +00001653ifdef LLVMC_BASED_DRIVER
Mikhail Glushenkov1386ae42009-03-02 09:42:59 +00001654TABLEGEN_INC_FILES_COMMON = 1
1655endif
1656
1657ifdef TABLEGEN_INC_FILES_COMMON
1658
Reid Spencercc2d1e22004-10-30 09:19:36 +00001659INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Chris Lattner3c473472004-12-16 17:28:50 +00001660INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1661.PRECIOUS: $(INCTMPFiles) $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001662
Misha Brukmanef5dc702009-01-08 02:11:55 +00001663# INCFiles rule: All of the tblgen generated files are emitted to
Chris Lattner23ee7952004-12-16 17:38:56 +00001664# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1665# us to only "touch" the real file if the contents of it change. IOW, if
Daniel Dunbareb909ca2008-11-03 17:33:36 +00001666# tblgen is modified, all of the .inc.tmp files are regenerated, but no
Chris Lattner23ee7952004-12-16 17:38:56 +00001667# dependencies of the .inc files are, unless the contents of the .inc file
1668# changes.
1669$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
Reid Spencerc3719842004-12-16 18:26:53 +00001670 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
Chris Lattner3c473472004-12-16 17:28:50 +00001671
Mikhail Glushenkov1386ae42009-03-02 09:42:59 +00001672endif # TABLEGEN_INC_FILES_COMMON
1673
1674ifdef TARGET
1675
1676TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1677 $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
1678 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
1679 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
1680 $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
1681 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1682 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
1683
Rafael Espindola075630a2009-03-10 17:58:54 +00001684# All of these files depend on tblgen and the .td files.
1685$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1686
Chris Lattner3c473472004-12-16 17:28:50 +00001687$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1688$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001689 $(Echo) "Building $(<F) register names with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001690 $(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001691
Chris Lattner3c473472004-12-16 17:28:50 +00001692$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1693$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001694 $(Echo) "Building $(<F) register information header with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001695 $(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001696
Chris Lattner3c473472004-12-16 17:28:50 +00001697$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1698$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001699 $(Echo) "Building $(<F) register info implementation with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001700 $(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001701
Chris Lattner3c473472004-12-16 17:28:50 +00001702$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1703$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001704 $(Echo) "Building $(<F) instruction names with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001705 $(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001706
Chris Lattner3c473472004-12-16 17:28:50 +00001707$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1708$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001709 $(Echo) "Building $(<F) instruction information with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001710 $(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001711
Chris Lattner3c473472004-12-16 17:28:50 +00001712$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1713$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001714 $(Echo) "Building $(<F) assembly writer with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001715 $(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001716
Chris Lattner02a4f902004-12-16 17:34:04 +00001717$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1718$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1719 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Misha Brukmanef5dc702009-01-08 02:11:55 +00001720 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001721
Daniel Dunbarc464e512009-07-13 18:35:35 +00001722$(TARGET:%=$(ObjDir)/%GenAsmMatcher.inc.tmp): \
1723$(ObjDir)/%GenAsmMatcher.inc.tmp : %.td $(ObjDir)/.dir
1724 $(Echo) "Building $(<F) assembly matcher with tblgen"
1725 $(Verb) $(TableGen) -gen-asm-matcher -o $(call SYSPATH, $@) $<
1726
Jim Grosbachbd29a362010-11-03 23:46:01 +00001727$(TARGET:%=$(ObjDir)/%GenMCCodeEmitter.inc.tmp): \
1728$(ObjDir)/%GenMCCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
1729 $(Echo) "Building $(<F) MC code emitter with tblgen"
1730 $(Verb) $(TableGen) -gen-emitter -mc-emitter -o $(call SYSPATH, $@) $<
1731
Chris Lattner3c473472004-12-16 17:28:50 +00001732$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1733$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001734 $(Echo) "Building $(<F) code emitter with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001735 $(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001736
Chris Lattnerf31f09e2005-09-03 01:15:25 +00001737$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1738$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
Dan Gohmanb0cf29c2008-08-13 20:19:35 +00001739 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001740 $(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
Chris Lattnerf31f09e2005-09-03 01:15:25 +00001741
Daniel Dunbarf87ea4d2009-11-25 04:46:58 +00001742$(TARGET:%=$(ObjDir)/%GenDisassemblerTables.inc.tmp): \
1743$(ObjDir)/%GenDisassemblerTables.inc.tmp : %.td $(ObjDir)/.dir
1744 $(Echo) "Building $(<F) disassembly tables with tblgen"
1745 $(Verb) $(TableGen) -gen-disassembler -o $(call SYSPATH, $@) $<
1746
Sean Callanan95fcebd2010-01-29 00:21:04 +00001747$(TARGET:%=$(ObjDir)/%GenEDInfo.inc.tmp): \
1748$(ObjDir)/%GenEDInfo.inc.tmp : %.td $(ObjDir)/.dir
1749 $(Echo) "Building $(<F) enhanced disassembly information with tblgen"
1750 $(Verb) $(TableGen) -gen-enhanced-disassembly-info -o $(call SYSPATH, $@) $<
1751
Dan Gohmanb0cf29c2008-08-13 20:19:35 +00001752$(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1753$(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
1754 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1755 $(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1756
Jim Laskeyf5fc2cb2005-10-21 19:05:19 +00001757$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1758$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1759 $(Echo) "Building $(<F) subtarget information with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001760 $(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
Chris Lattnerf31f09e2005-09-03 01:15:25 +00001761
Chris Lattnerbcc3c192007-02-27 20:44:12 +00001762$(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1763$(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1764 $(Echo) "Building $(<F) calling convention information with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001765 $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
Chris Lattnerbcc3c192007-02-27 20:44:12 +00001766
Dale Johannesen49de9822009-02-05 01:49:45 +00001767$(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \
Jakob Stoklund Olesen7b68ffc2009-10-15 18:48:47 +00001768$(ObjDir)/%GenIntrinsics.inc.tmp : %.td $(ObjDir)/.dir
1769 $(Echo) "Building $(<F) intrinsics information with tblgen"
Dale Johannesen49de9822009-02-05 01:49:45 +00001770 $(Verb) $(TableGen) -gen-tgt-intrinsic -o $(call SYSPATH, $@) $<
1771
Johnny Chenb68a3ee2010-04-02 22:27:38 +00001772$(ObjDir)/ARMGenDecoderTables.inc.tmp : ARM.td $(ObjDir)/.dir
1773 $(Echo) "Building $(<F) decoder tables with tblgen"
1774 $(Verb) $(TableGen) -gen-arm-decoder -o $(call SYSPATH, $@) $<
1775
1776
Reid Spencer3a561f52004-10-23 20:04:14 +00001777clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001778 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001779
Mikhail Glushenkov1386ae42009-03-02 09:42:59 +00001780endif # TARGET
1781
Mikhail Glushenkovb3d36292010-08-15 07:07:12 +00001782ifdef LLVMC_BASED_DRIVER
Mikhail Glushenkov1386ae42009-03-02 09:42:59 +00001783
Mikhail Glushenkovb3d36292010-08-15 07:07:12 +00001784TDSrc := $(sort $(strip $(wildcard $(PROJ_SRC_DIR)/*.td)) \
1785 $(strip $(wildcard $(PROJ_OBJ_DIR)/*.td)))
Mikhail Glushenkov1386ae42009-03-02 09:42:59 +00001786
Mikhail Glushenkovb3d36292010-08-15 07:07:12 +00001787TDCommon := $(strip $(wildcard \
1788 $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
Mikhail Glushenkov1386ae42009-03-02 09:42:59 +00001789
Mikhail Glushenkovb3d36292010-08-15 07:07:12 +00001790TDFiles := $(TDSrc) $(TDCommon)
1791
1792$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
1793
1794$(ObjDir)/%.inc.tmp: %.td $(ObjDir)/.dir
1795 $(Echo) "Building LLVMC compilation graph description with tblgen"
Mikhail Glushenkova73e5862010-10-23 07:32:53 +00001796 $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
Mikhail Glushenkov1386ae42009-03-02 09:42:59 +00001797
Mikhail Glushenkovb3d36292010-08-15 07:07:12 +00001798clean-local::
1799 -$(Verb) $(RM) -f $(INCFiles)
1800
1801endif # LLVMC_BASED_DRIVER
Mikhail Glushenkov1386ae42009-03-02 09:42:59 +00001802
Reid Spencercc2d1e22004-10-30 09:19:36 +00001803###############################################################################
Reid Spencercc2d1e22004-10-30 09:19:36 +00001804# OTHER RULES: Other rules needed
1805###############################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +00001806
Chris Lattner30440c62003-01-16 21:06:18 +00001807# To create postscript files from dot files...
John Criswelle0f9ac62003-10-02 19:02:02 +00001808ifneq ($(DOT),false)
Chris Lattner30440c62003-01-16 21:06:18 +00001809%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +00001810 $(DOT) -Tps < $< > $@
John Criswell7a73b802003-06-30 21:59:07 +00001811else
1812%.ps: %.dot
Reid Spencercc2d1e22004-10-30 09:19:36 +00001813 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell7a73b802003-06-30 21:59:07 +00001814endif
Chris Lattner30440c62003-01-16 21:06:18 +00001815
John Criswell7f336952003-09-06 14:44:17 +00001816# This rules ensures that header files that are removed still have a rule for
1817# which they can be "generated." This allows make to ignore them and
1818# reproduce the dependency lists.
John Criswell4b6e5d12003-09-18 18:37:08 +00001819%.h:: ;
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001820%.hpp:: ;
John Criswell7f336952003-09-06 14:44:17 +00001821
Reid Spencercc2d1e22004-10-30 09:19:36 +00001822# Define clean-local to clean the current directory. Note that this uses a
Misha Brukmanef5dc702009-01-08 02:11:55 +00001823# very conservative approach ensuring that empty variables do not cause
Reid Spencercc2d1e22004-10-30 09:19:36 +00001824# errors or disastrous removal.
Reid Spencer3a561f52004-10-23 20:04:14 +00001825clean-local::
Jim Grosbach673612e2008-10-02 22:56:44 +00001826ifneq ($(strip $(ObjRootDir)),)
1827 -$(Verb) $(RM) -rf $(ObjRootDir)
Reid Spencere5487ba2004-10-24 07:53:21 +00001828endif
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001829 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001830ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001831 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001832endif
John Criswell7a73b802003-06-30 21:59:07 +00001833
Reid Spencer3d659492004-11-02 16:36:03 +00001834clean-all-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001835 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer3d659492004-11-02 16:36:03 +00001836
Reid Spencer12d79512004-11-12 02:27:36 +00001837
Reid Spencer3a561f52004-10-23 20:04:14 +00001838###############################################################################
1839# DEPENDENCIES: Include the dependency files if we should
1840###############################################################################
Chris Lattner33ad24a2003-08-22 14:10:16 +00001841ifndef DISABLE_AUTO_DEPENDENCIES
1842
Reid Spencer3a561f52004-10-23 20:04:14 +00001843# If its not one of the cleaning targets
Daniel Dunbar94e98af2008-10-03 19:11:19 +00001844ifndef IS_CLEANING_TARGET
Reid Spencer4d71b662004-10-22 21:01:56 +00001845
Reid Spencer3a561f52004-10-23 20:04:14 +00001846# Get the list of dependency files
Greg Clayton43bc79a2010-07-13 18:47:09 +00001847DependSourceFiles := $(basename $(filter %.cpp %.c %.cc %.m %.mm, $(Sources)))
Daniel Dunbarfab3d682009-05-12 06:35:50 +00001848DependFiles := $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
1849
1850# Include bitcode dependency files if using bitcode libraries
1851ifdef BYTECODE_LIBRARY
1852DependFiles += $(DependSourceFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.bc.d)
1853endif
Misha Brukman4f7a8cf2003-11-09 21:36:19 +00001854
Reid Spencer491a6cd2007-07-23 08:20:46 +00001855-include $(DependFiles) ""
Reid Spencer3a561f52004-10-23 20:04:14 +00001856
John Criswelld741bcf2003-08-12 18:51:51 +00001857endif
Chris Lattner1ddb6b62003-08-18 17:27:40 +00001858
Misha Brukmanef5dc702009-01-08 02:11:55 +00001859endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001860
Reid Spencer151f8ba2004-10-25 08:27:37 +00001861###############################################################################
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001862# CHECK: Running the test suite
1863###############################################################################
1864
Bill Wendling29c0e3d2009-04-09 18:26:57 +00001865check::
Reid Spencer11fde542005-01-16 02:20:54 +00001866 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1867 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001868 $(EchoCmd) Running test suite ; \
Reid Spencer11fde542005-01-16 02:20:54 +00001869 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001870 TESTSUITE=$(TESTSUITE) ; \
1871 else \
1872 $(EchoCmd) No Makefile in test directory ; \
1873 fi ; \
1874 else \
1875 $(EchoCmd) No test directory ; \
1876 fi
1877
Daniel Dunbar666b4022010-08-02 00:05:18 +00001878check-lit:: check
1879
1880check-dg::
Daniel Dunbar70a3b772009-09-08 05:31:44 +00001881 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1882 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1883 $(EchoCmd) Running test suite ; \
Daniel Dunbar666b4022010-08-02 00:05:18 +00001884 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-dg ; \
Daniel Dunbar70a3b772009-09-08 05:31:44 +00001885 else \
1886 $(EchoCmd) No Makefile in test directory ; \
1887 fi ; \
1888 else \
1889 $(EchoCmd) No test directory ; \
1890 fi
1891
Daniel Dunbar34185792009-09-20 06:17:21 +00001892check-all::
1893 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1894 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
1895 $(EchoCmd) Running test suite ; \
1896 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local-all ; \
1897 else \
1898 $(EchoCmd) No Makefile in test directory ; \
1899 fi ; \
1900 else \
1901 $(EchoCmd) No test directory ; \
1902 fi
1903
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001904###############################################################################
Bill Wendling4113bd12009-01-04 23:12:21 +00001905# UNITTESTS: Running the unittests test suite
1906###############################################################################
1907
Bill Wendling29c0e3d2009-04-09 18:26:57 +00001908unittests::
Bill Wendling4113bd12009-01-04 23:12:21 +00001909 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/unittests" ; then \
1910 if test -f "$(PROJ_OBJ_ROOT)/unittests/Makefile" ; then \
1911 $(EchoCmd) Running unittests test suite ; \
Daniel Dunbar7f068f42009-09-13 22:39:27 +00001912 $(MAKE) -C $(PROJ_OBJ_ROOT)/unittests unitcheck; \
Bill Wendling4113bd12009-01-04 23:12:21 +00001913 else \
1914 $(EchoCmd) No Makefile in unittests directory ; \
1915 fi ; \
1916 else \
1917 $(EchoCmd) No unittests directory ; \
1918 fi
1919
1920###############################################################################
Reid Spencercc2d1e22004-10-30 09:19:36 +00001921# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer151f8ba2004-10-25 08:27:37 +00001922###############################################################################
1923
Reid Spencere45ebfa2004-10-26 07:09:33 +00001924#------------------------------------------------------------------------
1925# Define distribution related variables
1926#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +00001927DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1928DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1929TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1930DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1931DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1932DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
Reid Spencer151f8ba2004-10-25 08:27:37 +00001933DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1934 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001935 Makefile.config.in configure autoconf
1936DistOther := $(notdir $(wildcard \
Reid Spencer11fde542005-01-16 02:20:54 +00001937 $(PROJ_SRC_DIR)/*.h \
1938 $(PROJ_SRC_DIR)/*.td \
1939 $(PROJ_SRC_DIR)/*.def \
1940 $(PROJ_SRC_DIR)/*.ll \
1941 $(PROJ_SRC_DIR)/*.in))
Reid Spencercc2d1e22004-10-30 09:19:36 +00001942DistSubDirs := $(SubDirs)
Reid Spencerfbbf3072004-11-29 05:00:33 +00001943DistSources = $(Sources) $(EXTRA_DIST)
1944DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer151f8ba2004-10-25 08:27:37 +00001945
Reid Spencere45ebfa2004-10-26 07:09:33 +00001946#------------------------------------------------------------------------
1947# We MUST build distribution with OBJ_DIR != SRC_DIR
1948#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +00001949ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
Reid Spencere45ebfa2004-10-26 07:09:33 +00001950dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001951 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencere45ebfa2004-10-26 07:09:33 +00001952
Reid Spencere45ebfa2004-10-26 07:09:33 +00001953else
1954
Reid Spencere45ebfa2004-10-26 07:09:33 +00001955#------------------------------------------------------------------------
Reid Spencere45ebfa2004-10-26 07:09:33 +00001956# Prevent attempt to run dist targets from anywhere but the top level
1957#------------------------------------------------------------------------
1958ifneq ($(LEVEL),.)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001959dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencer11fde542005-01-16 02:20:54 +00001960 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001961else
1962
1963#------------------------------------------------------------------------
1964# Provide the top level targets
1965#------------------------------------------------------------------------
1966
Reid Spencercc2d1e22004-10-30 09:19:36 +00001967dist-gzip:: $(DistTarGZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001968
Reid Spencer345235ca2004-12-04 22:34:09 +00001969$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001970 $(Echo) Packing gzipped distribution tar file.
Reid Spencer11fde542005-01-16 02:20:54 +00001971 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
Reid Spencerfbbf3072004-11-29 05:00:33 +00001972 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencere45ebfa2004-10-26 07:09:33 +00001973
Reid Spencercc2d1e22004-10-30 09:19:36 +00001974dist-bzip2:: $(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001975
Reid Spencer345235ca2004-12-04 22:34:09 +00001976$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001977 $(Echo) Packing bzipped distribution tar file.
Reid Spencer11fde542005-01-16 02:20:54 +00001978 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
Reid Spencerfbbf3072004-11-29 05:00:33 +00001979 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001980
Reid Spencercc2d1e22004-10-30 09:19:36 +00001981dist-zip:: $(DistZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001982
Reid Spencer345235ca2004-12-04 22:34:09 +00001983$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001984 $(Echo) Packing zipped distribution file.
1985 $(Verb) rm -f $(DistZip)
Reid Spencer11fde542005-01-16 02:20:54 +00001986 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001987
Misha Brukmanef5dc702009-01-08 02:11:55 +00001988dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001989 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001990
Reid Spencerf8f57402005-01-28 19:52:32 +00001991DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
Reid Spencere45ebfa2004-10-26 07:09:33 +00001992
Reid Spencer345235ca2004-12-04 22:34:09 +00001993dist-check:: $(DistTarGZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001994 $(Echo) Checking distribution tar file.
1995 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001996 $(RM) -rf $(DistCheckDir) ; \
1997 fi
Reid Spencercc2d1e22004-10-30 09:19:36 +00001998 $(Verb) $(MKDIR) $(DistCheckDir)
1999 $(Verb) cd $(DistCheckDir) && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00002000 $(MKDIR) $(DistCheckDir)/build && \
2001 $(MKDIR) $(DistCheckDir)/install && \
2002 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
2003 cd build && \
2004 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
Reid Spencer45eeed92005-05-24 02:33:20 +00002005 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
Reid Spencer345235ca2004-12-04 22:34:09 +00002006 $(MAKE) all && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00002007 $(MAKE) check && \
Bill Wendling4113bd12009-01-04 23:12:21 +00002008 $(MAKE) unittests && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00002009 $(MAKE) install && \
2010 $(MAKE) uninstall && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00002011 $(MAKE) dist-clean && \
Reid Spencercc2d1e22004-10-30 09:19:36 +00002012 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00002013
2014dist-clean::
Reid Spencercc2d1e22004-10-30 09:19:36 +00002015 $(Echo) Cleaning distribution files
Reid Spencer345235ca2004-12-04 22:34:09 +00002016 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
2017 $(DistCheckDir)
Reid Spencere45ebfa2004-10-26 07:09:33 +00002018
2019endif
2020
2021#------------------------------------------------------------------------
2022# Provide the recursive distdir target for building the distribution directory
2023#------------------------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +00002024distdir: $(DistDir)/.makedistdir
2025$(DistDir)/.makedistdir: $(DistSources)
Reid Spencercc2d1e22004-10-30 09:19:36 +00002026 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00002027 if test -d "$(DistDir)" ; then \
2028 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
2029 exit 1 ; \
2030 fi ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00002031 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00002032 $(RM) -rf $(DistDir); \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00002033 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer854071c2006-04-10 16:46:04 +00002034 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00002035 fi
Reid Spencerfbbf3072004-11-29 05:00:33 +00002036 $(Echo) Building Distribution Directory $(DistDir)
Misha Brukmanef5dc702009-01-08 02:11:55 +00002037 $(Verb) $(MKDIR) $(DistDir)
Reid Spencer11fde542005-01-16 02:20:54 +00002038 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
2039 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00002040 for file in $(DistFiles) ; do \
2041 case "$$file" in \
Reid Spencer11fde542005-01-16 02:20:54 +00002042 $(PROJ_SRC_DIR)/*) \
Reid Spencer345235ca2004-12-04 22:34:09 +00002043 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
2044 ;; \
Reid Spencer11fde542005-01-16 02:20:54 +00002045 $(PROJ_SRC_ROOT)/*) \
Reid Spencer345235ca2004-12-04 22:34:09 +00002046 file=`echo "$$file" | \
2047 sed "s#^$$srcrootstrip/##"` \
2048 ;; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00002049 esac; \
Reid Spencer11fde542005-01-16 02:20:54 +00002050 if test -f "$(PROJ_SRC_DIR)/$$file" || \
2051 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
2052 from_dir="$(PROJ_SRC_DIR)" ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00002053 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00002054 from_dir=. ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00002055 fi ; \
2056 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00002057 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
2058 to_dir="$(DistDir)/$$dir"; \
2059 $(MKDIR) "$$to_dir" ; \
2060 else \
2061 to_dir="$(DistDir)"; \
2062 fi; \
2063 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
2064 if test -n "$$mid_dir" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00002065 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00002066 fi ; \
2067 if test -d "$$from_dir/$$file"; then \
Reid Spencer11fde542005-01-16 02:20:54 +00002068 if test -d "$(PROJ_SRC_DIR)/$$file" && \
2069 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
Reid Spencer45eeed92005-05-24 02:33:20 +00002070 cd $(PROJ_SRC_DIR) ; \
2071 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
2072 ( cd $$to_dir ; $(TAR) xf - ) ; \
2073 cd $(PROJ_OBJ_DIR) ; \
2074 else \
2075 cd $$from_dir ; \
2076 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
2077 ( cd $$to_dir ; $(TAR) xf - ) ; \
2078 cd $(PROJ_OBJ_DIR) ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00002079 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00002080 elif test -f "$$from_dir/$$file" ; then \
Reid Spencerc3719842004-12-16 18:26:53 +00002081 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00002082 elif test -L "$$from_dir/$$file" ; then \
Reid Spencerc3719842004-12-16 18:26:53 +00002083 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00002084 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer345235ca2004-12-04 22:34:09 +00002085 $(EchoCmd) "===== WARNING: Distribution Source " \
2086 "$$from_dir/$$file Not Found!" ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00002087 elif test "$(Verb)" != '@' ; then \
2088 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00002089 fi; \
2090 done
Reid Spencercc2d1e22004-10-30 09:19:36 +00002091 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer151f8ba2004-10-25 08:27:37 +00002092 if test "$$subdir" \!= "." ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00002093 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00002094 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer854071c2006-04-10 16:46:04 +00002095 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
Reid Spencerbac3ca22006-04-07 16:06:18 +00002096 DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00002097 fi; \
2098 done
Reid Spencer345235ca2004-12-04 22:34:09 +00002099 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer45eeed92005-05-24 02:33:20 +00002100 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
Chris Lattner77efe272006-02-14 04:27:15 +00002101 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
2102 -name .svn \) -print` ;\
Reid Spencer345235ca2004-12-04 22:34:09 +00002103 $(MAKE) dist-hook ; \
2104 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
2105 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
2106 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
2107 -o ! -type d ! -perm -444 -exec \
2108 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
2109 || chmod -R a+r $(DistDir) ; \
2110 fi
Reid Spencer151f8ba2004-10-25 08:27:37 +00002111
Reid Spencercc2d1e22004-10-30 09:19:36 +00002112# This is invoked by distdir target, define it as a no-op to avoid errors if not
2113# defined by user.
Reid Spencer151f8ba2004-10-25 08:27:37 +00002114dist-hook::
2115
Reid Spencere53e3972004-10-22 23:06:30 +00002116endif
Reid Spencer4d71b662004-10-22 21:01:56 +00002117
2118###############################################################################
Reid Spencere5487ba2004-10-24 07:53:21 +00002119# TOP LEVEL - targets only to apply at the top level directory
2120###############################################################################
2121
2122ifeq ($(LEVEL),.)
2123
2124#------------------------------------------------------------------------
Reid Spencer9e8d54a2004-12-06 05:35:13 +00002125# Install support for the project's include files:
Reid Spencere5487ba2004-10-24 07:53:21 +00002126#------------------------------------------------------------------------
Reid Spencera2a31bf2007-02-06 18:53:14 +00002127ifdef NO_INSTALL
2128install-local::
2129 $(Echo) Install circumvented with NO_INSTALL
2130uninstall-local::
2131 $(Echo) Uninstall circumvented with NO_INSTALL
2132else
Reid Spencere5487ba2004-10-24 07:53:21 +00002133install-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00002134 $(Echo) Installing include files
Erick Tryzelaard4076cf2010-03-04 20:56:19 +00002135 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_includedir)
Reid Spencer4a0aaea2005-02-24 03:56:32 +00002136 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
Reid Spencer11fde542005-01-16 02:20:54 +00002137 cd $(PROJ_SRC_ROOT)/include && \
Chris Lattnerc9480642009-01-02 07:16:45 +00002138 for hdr in `find . -type f '!' '(' -name '*~' \
Reid Spencer0522d8b2007-04-09 19:08:58 +00002139 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
2140 grep -v .svn` ; do \
Erick Tryzelaard4076cf2010-03-04 20:56:19 +00002141 instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$hdr"` ; \
Reid Spencer4a0aaea2005-02-24 03:56:32 +00002142 if test \! -d "$$instdir" ; then \
2143 $(EchoCmd) Making install directory $$instdir ; \
2144 $(MKDIR) $$instdir ;\
2145 fi ; \
Erick Tryzelaard4076cf2010-03-04 20:56:19 +00002146 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
Reid Spencer2edabc02005-02-16 15:54:03 +00002147 done ; \
Reid Spencere5487ba2004-10-24 07:53:21 +00002148 fi
Reid Spencer443045a2005-12-23 22:27:56 +00002149ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencer4a0aaea2005-02-24 03:56:32 +00002150 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
Reid Spencer2edabc02005-02-16 15:54:03 +00002151 cd $(PROJ_OBJ_ROOT)/include && \
Reid Spencer443045a2005-12-23 22:27:56 +00002152 for hdr in `find . -type f -print | grep -v CVS` ; do \
Erick Tryzelaard4076cf2010-03-04 20:56:19 +00002153 $(DataInstall) $$hdr $(DESTDIR)$(PROJ_includedir)/$$hdr ; \
Reid Spencer2edabc02005-02-16 15:54:03 +00002154 done ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00002155 fi
Reid Spencer443045a2005-12-23 22:27:56 +00002156endif
Reid Spencere5487ba2004-10-24 07:53:21 +00002157
2158uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00002159 $(Echo) Uninstalling include files
Reid Spencer11fde542005-01-16 02:20:54 +00002160 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
2161 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencere5487ba2004-10-24 07:53:21 +00002162 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
Chris Lattnerc9480642009-01-02 07:16:45 +00002163 '!' '(' -name '*~' -o -name '.#*' \
Chris Lattnerd25ad612006-02-14 04:25:54 +00002164 -o -name '*.in' ')' -print ')' | \
Erick Tryzelaard4076cf2010-03-04 20:56:19 +00002165 grep -v CVS | sed 's#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00002166 cd $(PROJ_SRC_ROOT)/include && \
Chris Lattnerd25ad612006-02-14 04:25:54 +00002167 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
Erick Tryzelaard4076cf2010-03-04 20:56:19 +00002168 -print ')' | sed 's#\.in$$##;s#^#$(DESTDIR)$(PROJ_includedir)/#'` ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00002169 fi
Reid Spencera2a31bf2007-02-06 18:53:14 +00002170endif
Reid Spencere5487ba2004-10-24 07:53:21 +00002171endif
2172
Chris Lattner03840ac2007-04-14 23:35:45 +00002173check-line-length:
Gabor Greifb1dbcd82008-05-15 10:04:30 +00002174 @echo searching for overlength lines in files: $(Sources)
2175 @echo
2176 @echo
Gabor Greif5039a6f2008-08-28 22:32:39 +00002177 egrep -n '.{81}' $(Sources) /dev/null
Chris Lattner03840ac2007-04-14 23:35:45 +00002178
Anton Korobeynikovbed29462007-04-16 18:10:23 +00002179check-for-tabs:
Gabor Greifb1dbcd82008-05-15 10:04:30 +00002180 @echo searching for tabs in files: $(Sources)
2181 @echo
2182 @echo
Gabor Greif5039a6f2008-08-28 22:32:39 +00002183 egrep -n ' ' $(Sources) /dev/null
Gabor Greifb1dbcd82008-05-15 10:04:30 +00002184
Reid Spencer6548bf12007-05-02 21:29:39 +00002185check-footprint:
2186 @ls -l $(LibDir) | awk '\
2187 BEGIN { sum = 0; } \
2188 { sum += $$5; } \
2189 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
2190 @ls -l $(ToolDir) | awk '\
2191 BEGIN { sum = 0; } \
2192 { sum += $$5; } \
2193 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
Reid Spencer4d71b662004-10-22 21:01:56 +00002194#------------------------------------------------------------------------
2195# Print out the directories used for building
Reid Spencercc2d1e22004-10-30 09:19:36 +00002196#------------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00002197printvars::
Reid Spencer11fde542005-01-16 02:20:54 +00002198 $(Echo) "BuildMode : " '$(BuildMode)'
2199 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
2200 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
2201 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
2202 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
2203 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
2204 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
2205 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
2206 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
2207 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
2208 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
Reid Spencer1a9a69c2005-02-16 16:13:02 +00002209 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
Reid Spencer11fde542005-01-16 02:20:54 +00002210 $(Echo) "UserTargets : " '$(UserTargets)'
2211 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
2212 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
2213 $(Echo) "ObjDir : " '$(ObjDir)'
2214 $(Echo) "LibDir : " '$(LibDir)'
2215 $(Echo) "ToolDir : " '$(ToolDir)'
2216 $(Echo) "ExmplDir : " '$(ExmplDir)'
2217 $(Echo) "Sources : " '$(Sources)'
2218 $(Echo) "TDFiles : " '$(TDFiles)'
2219 $(Echo) "INCFiles : " '$(INCFiles)'
2220 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
Reid Spencere0acb762005-03-01 16:27:06 +00002221 $(Echo) "PreConditions: " '$(PreConditions)'
Reid Spencer11fde542005-01-16 02:20:54 +00002222 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
2223 $(Echo) "Compile.C : " '$(Compile.C)'
2224 $(Echo) "Archive : " '$(Archive)'
2225 $(Echo) "YaccFiles : " '$(YaccFiles)'
2226 $(Echo) "LexFiles : " '$(LexFiles)'
2227 $(Echo) "Module : " '$(Module)'
Reid Spencer755bcf02005-08-24 10:43:10 +00002228 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
Reid Spencerf9f431c2006-04-09 23:41:14 +00002229 $(Echo) "SubDirs : " '$(SubDirs)'
Reid Spencer8475ec02007-03-29 19:05:44 +00002230 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
2231 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'
Daniel Dunbar92acef02009-02-21 20:42:39 +00002232
2233###
2234# Debugging
2235
Daniel Dunbar3c898122009-03-06 22:23:25 +00002236# General debugging rule, use 'make dbg-print-XXX' to print the
Daniel Dunbar92acef02009-02-21 20:42:39 +00002237# definition, value and origin of XXX.
Daniel Dunbar3c898122009-03-06 22:23:25 +00002238make-print-%:
Daniel Dunbar92acef02009-02-21 20:42:39 +00002239 $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))