blob: d0d83c038be1308a06fca124ab5b8ae6628db37e [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.
John Criswelld8846c12003-10-21 14:33:46 +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#--------------------------------------------------------------------
Chris Lattner7dc02822004-12-03 21:05:57 +000022RecursiveTargets := all clean clean-all install uninstall install-bytecode
Reid Spencer9e8d54a2004-12-06 05:35:13 +000023LocalTargets := all-local clean-local clean-all-local check-local \
Reid Spencer44cb1b32004-12-03 20:08:48 +000024 install-local printvars uninstall-local \
25 install-bytecode-local
Chris Lattner72e46332007-09-26 06:10:47 +000026TopLevelTargets := check dist dist-check dist-clean dist-gzip dist-bzip2 \
Reid Spencercc2d1e22004-10-30 09:19:36 +000027 dist-zip
28UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
29InternalTargets := preconditions distdir dist-hook
Reid Spencer3a561f52004-10-23 20:04:14 +000030
Reid Spencercc2d1e22004-10-30 09:19:36 +000031################################################################################
Reid Spencer9411c642004-10-26 22:26:33 +000032# INITIALIZATION: Basic things the makefile needs
Reid Spencercc2d1e22004-10-30 09:19:36 +000033################################################################################
34
35#--------------------------------------------------------------------
36# Set the VPATH so that we can find source files.
37#--------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +000038VPATH=$(PROJ_SRC_DIR)
Reid Spencer9411c642004-10-26 22:26:33 +000039
40#--------------------------------------------------------------------
Reid Spencer1abd46d2007-06-29 14:02:07 +000041# Reset the list of suffixes we know how to build.
Reid Spencer9411c642004-10-26 22:26:33 +000042#--------------------------------------------------------------------
43.SUFFIXES:
Chris Lattner89681112006-01-27 22:13:12 +000044.SUFFIXES: .c .cpp .cc .h .hpp .y .l .lo .o .a .bc .td .ps .dot .ll
Reid Spencercc2d1e22004-10-30 09:19:36 +000045.SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
Reid Spencer9411c642004-10-26 22:26:33 +000046
Reid Spencer3a561f52004-10-23 20:04:14 +000047#--------------------------------------------------------------------
48# Mark all of these targets as phony to avoid implicit rule search
49#--------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000050.PHONY: $(UserTargets) $(InternalTargets)
Reid Spencer3a561f52004-10-23 20:04:14 +000051
52#--------------------------------------------------------------------
Reid Spencer9411c642004-10-26 22:26:33 +000053# Make sure all the user-target rules are double colon rules and
54# they are defined first.
Reid Spencer3a561f52004-10-23 20:04:14 +000055#--------------------------------------------------------------------
56
Reid Spencercc2d1e22004-10-30 09:19:36 +000057$(UserTargets)::
Reid Spencer151f8ba2004-10-25 08:27:37 +000058
Reid Spencer9411c642004-10-26 22:26:33 +000059################################################################################
60# PRECONDITIONS: that which must be built/checked first
61################################################################################
62
Reid Spencer44cb1b32004-12-03 20:08:48 +000063SrcMakefiles := $(filter %Makefile %Makefile.tests,\
Reid Spencer11fde542005-01-16 02:20:54 +000064 $(wildcard $(PROJ_SRC_DIR)/Makefile*))
65ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
66ConfigureScript := $(PROJ_SRC_ROOT)/configure
67ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
68MakefileConfigIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
69MakefileCommonIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
70MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
71MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
72PreConditions := $(ConfigStatusScript) $(ObjMakefiles)
73ifneq ($(MakefileCommonIn),)
74PreConditions += $(MakefileCommon)
75endif
Chris Lattner0a1db822006-09-04 05:23:20 +000076
Reid Spencer11fde542005-01-16 02:20:54 +000077ifneq ($(MakefileConfigIn),)
78PreConditions += $(MakefileConfig)
79endif
Reid Spencer9411c642004-10-26 22:26:33 +000080
Reid Spencerca739c62005-08-25 04:59:49 +000081preconditions: $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +000082
83#------------------------------------------------------------------------
84# Make sure the BUILT_SOURCES are built first
85#------------------------------------------------------------------------
Reid Spencer07a549a2004-12-16 07:15:16 +000086$(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000087
Reid Spencer9bb399c2007-02-07 19:13:19 +000088clean-all-local::
Reid Spencer9411c642004-10-26 22:26:33 +000089ifneq ($(strip $(BUILT_SOURCES)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +000090 -$(Verb) $(RM) -f $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000091endif
92
Reid Spencer11fde542005-01-16 02:20:54 +000093ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
Reid Spencer31f95242004-12-16 08:00:46 +000094spotless:
Reid Spencer31f95242004-12-16 08:00:46 +000095 $(Verb) if test -x config.status ; then \
Reid Spencer11fde542005-01-16 02:20:54 +000096 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
Reid Spencer39b73632004-12-17 07:45:03 +000097 $(MKDIR) .spotless.save ; \
98 $(MV) config.status .spotless.save ; \
99 $(MV) mklib .spotless.save ; \
100 $(MV) projects .spotless.save ; \
Reid Spencer31f95242004-12-16 08:00:46 +0000101 $(RM) -rf * ; \
Reid Spencer39b73632004-12-17 07:45:03 +0000102 $(MV) .spotless.save/config.status . ; \
103 $(MV) .spotless.save/mklib . ; \
104 $(MV) .spotless.save/projects . ; \
105 $(RM) -rf .spotless.save ; \
Reid Spencer11fde542005-01-16 02:20:54 +0000106 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
Reid Spencer39b73632004-12-17 07:45:03 +0000107 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
108 $(ConfigStatusScript) ; \
Reid Spencer31f95242004-12-16 08:00:46 +0000109 else \
Reid Spencer11fde542005-01-16 02:20:54 +0000110 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
Reid Spencer31f95242004-12-16 08:00:46 +0000111 fi
Reid Spencer25e8a702005-12-21 23:17:06 +0000112else
113spotless:
114 $(EchoCmd) "spotless target not supported for objdir == srcdir"
Reid Spencer31f95242004-12-16 08:00:46 +0000115endif
116
Reid Spencercc2d1e22004-10-30 09:19:36 +0000117$(BUILT_SOURCES) : $(ObjMakefiles)
Reid Spencer80f0ef72004-10-28 00:41:43 +0000118
Reid Spencer9411c642004-10-26 22:26:33 +0000119#------------------------------------------------------------------------
120# Make sure we're not using a stale configuration
121#------------------------------------------------------------------------
Reid Spencerc3719842004-12-16 18:26:53 +0000122reconfigure:
Reid Spencer11fde542005-01-16 02:20:54 +0000123 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
124 $(Verb) cd $(PROJ_OBJ_ROOT) && \
125 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
126 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
Reid Spencer32924e02004-12-24 03:36:31 +0000127 fi ; \
Reid Spencerc3719842004-12-16 18:26:53 +0000128 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
129 $(ConfigStatusScript)
130
Reid Spencercc2d1e22004-10-30 09:19:36 +0000131.PRECIOUS: $(ConfigStatusScript)
132$(ConfigStatusScript): $(ConfigureScript)
133 $(Echo) Reconfiguring with $<
Reid Spencer11fde542005-01-16 02:20:54 +0000134 $(Verb) cd $(PROJ_OBJ_ROOT) && \
135 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
136 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
Reid Spencer32924e02004-12-24 03:36:31 +0000137 fi ; \
Reid Spencer7d277002004-11-29 12:37:44 +0000138 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
139 $(ConfigStatusScript)
Reid Spencer9411c642004-10-26 22:26:33 +0000140
Reid Spencer6f5f8b32005-08-25 04:44:18 +0000141#------------------------------------------------------------------------
Reid Spencer9411c642004-10-26 22:26:33 +0000142# Make sure the configuration makefile is up to date
143#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +0000144ifneq ($(MakefileConfigIn),)
145$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000146 $(Echo) Regenerating $@
Reid Spencer11fde542005-01-16 02:20:54 +0000147 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
148endif
149
150ifneq ($(MakefileCommonIn),)
151$(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
152 $(Echo) Regenerating $@
153 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
154endif
Reid Spencer9411c642004-10-26 22:26:33 +0000155
156#------------------------------------------------------------------------
157# If the Makefile in the source tree has been updated, copy it over into the
158# build tree. But, only do this if the source and object makefiles differ
159#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +0000160ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
Reid Spencer9411c642004-10-26 22:26:33 +0000161
Gordon Henriksen7252dc02008-03-10 15:58:40 +0000162Makefile: $(PROJ_SRC_DIR)/Makefile $(ExtraMakefiles)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000163 $(Echo) "Updating Makefile"
164 $(Verb) $(MKDIR) $(@D)
Reid Spencerc3719842004-12-16 18:26:53 +0000165 $(Verb) $(CP) -f $< $@
Reid Spencer9411c642004-10-26 22:26:33 +0000166
167# Copy the Makefile.* files unless we're in the root directory which avoids
168# the copying of Makefile.config.in or other things that should be explicitly
169# taken care of.
Reid Spencer11fde542005-01-16 02:20:54 +0000170$(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
Reid Spencer86606782004-10-26 23:10:00 +0000171 @case '$?' in \
172 *Makefile.rules) ;; \
173 *.in) ;; \
Gordon Henriksen7252dc02008-03-10 15:58:40 +0000174 *) $(EchoCmd) "Updating $(@F)" ; \
Reid Spencer86606782004-10-26 23:10:00 +0000175 $(MKDIR) $(@D) ; \
Reid Spencerc3719842004-12-16 18:26:53 +0000176 $(CP) -f $< $@ ;; \
Reid Spencer86606782004-10-26 23:10:00 +0000177 esac
Gabor Greif0a4c3782008-02-27 13:34:15 +0000178
Reid Spencer9411c642004-10-26 22:26:33 +0000179endif
180
181#------------------------------------------------------------------------
182# Set up the basic dependencies
183#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000184$(UserTargets):: $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +0000185
186all:: all-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000187clean:: clean-local
Reid Spencer3d659492004-11-02 16:36:03 +0000188clean-all:: clean-local clean-all-local
Reid Spencer9411c642004-10-26 22:26:33 +0000189install:: install-local
190uninstall:: uninstall-local
Reid Spencer9411c642004-10-26 22:26:33 +0000191install-local:: all-local
Reid Spencer44cb1b32004-12-03 20:08:48 +0000192install-bytecode:: install-bytecode-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000193
194###############################################################################
195# VARIABLES: Set up various variables based on configuration data
196###############################################################################
197
198#--------------------------------------------------------------------
199# Variables derived from configuration we are building
Chris Lattner00950542001-06-06 20:29:01 +0000200#--------------------------------------------------------------------
201
Reid Spencer0a522b12007-07-10 07:19:53 +0000202CPP.Defines :=
Chris Lattnerd63b9642006-05-24 23:02:40 +0000203# OPTIMIZE_OPTION - The optimization level option we want to build LLVM with
204# this can be overridden on the make command line.
Reid Spencer48fdf912006-06-01 19:03:21 +0000205ifneq ($(OS),MingW)
206 OPTIMIZE_OPTION := -O3
207else
208 OPTIMIZE_OPTION := -O2
209endif
Chris Lattnerd63b9642006-05-24 23:02:40 +0000210
Chris Lattner760da062003-03-14 20:25:22 +0000211ifdef ENABLE_PROFILING
Reid Spencer9af3b292004-11-01 07:50:27 +0000212 BuildMode := Profile
Gordon Henriksen9e7aba22008-01-06 21:54:35 +0000213 CXX.Flags += $(OPTIMIZE_OPTION) -pg -g
214 C.Flags += $(OPTIMIZE_OPTION) -pg -g
215 LD.Flags += $(OPTIMIZE_OPTION) -pg -g
Reid Spencereff15532007-07-10 14:52:01 +0000216 KEEP_SYMBOLS := 1
Chris Lattner760da062003-03-14 20:25:22 +0000217else
Reid Spencer7f5f75d2006-11-11 00:00:31 +0000218 ifeq ($(ENABLE_OPTIMIZED),1)
Reid Spencer9af3b292004-11-01 07:50:27 +0000219 BuildMode := Release
Chris Lattner16620fc2006-07-27 18:19:51 +0000220 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
Reid Spencer325a87e2005-01-02 17:43:20 +0000221 ifneq ($(OS),FreeBSD)
Chris Lattnere5aa8f32006-05-24 18:34:08 +0000222 ifneq ($(OS),Darwin)
Reid Spencer325a87e2005-01-02 17:43:20 +0000223 OmitFramePointer := -fomit-frame-pointer
224 endif
Chris Lattnere5aa8f32006-05-24 18:34:08 +0000225 endif
Chris Lattner16620fc2006-07-27 18:19:51 +0000226
227 # Darwin requires -fstrict-aliasing to be explicitly enabled.
228 ifeq ($(OS),Darwin)
Evan Cheng6fc5b482008-06-05 23:00:08 +0000229 EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
Chris Lattner16620fc2006-07-27 18:19:51 +0000230 endif
231
Gordon Henriksen9e7aba22008-01-06 21:54:35 +0000232 CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
233 C.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
234 LD.Flags += $(OPTIMIZE_OPTION)
Chris Lattner760da062003-03-14 20:25:22 +0000235 else
Reid Spencer9af3b292004-11-01 07:50:27 +0000236 BuildMode := Debug
Gordon Henriksen9e7aba22008-01-06 21:54:35 +0000237 CXX.Flags += -g
238 C.Flags += -g
239 LD.Flags += -g
Reid Spencer4d71b662004-10-22 21:01:56 +0000240 KEEP_SYMBOLS := 1
Chris Lattner760da062003-03-14 20:25:22 +0000241 endif
242endif
243
Daniel Dunbarecfe67c2008-09-02 17:35:16 +0000244#ifeq ($(ENABLE_VISIBILITY_INLINES_HIDDEN),1)
245# CXX.Flags += -fvisibility-inlines-hidden
246#endif
247
Reid Spencer99655e12006-08-25 19:54:53 +0000248# IF REQUIRES_EH=1 is specified then don't disable exceptions
Reid Spencerdcea1402006-08-25 20:56:59 +0000249ifndef REQUIRES_EH
250 CXX.Flags += -fno-exceptions
251endif
Reid Spencer99655e12006-08-25 19:54:53 +0000252
Reid Spencer6548bf12007-05-02 21:29:39 +0000253# IF REQUIRES_RTTI=1 is specified then don't disable run-time type id
254ifndef REQUIRES_RTTI
Reid Spencer749a89b2007-05-02 21:31:09 +0000255# CXX.Flags += -fno-rtti
Reid Spencer6548bf12007-05-02 21:29:39 +0000256endif
257
Reid Spencer854071c2006-04-10 16:46:04 +0000258# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
259# then disable assertions by defining the appropriate preprocessor symbols.
Reid Spencerf9f431c2006-04-09 23:41:14 +0000260ifdef DISABLE_ASSERTIONS
Reid Spencerbac3ca22006-04-07 16:06:18 +0000261 BuildMode := $(BuildMode)-Asserts
Reid Spencer0a522b12007-07-10 07:19:53 +0000262 CPP.Defines += -DNDEBUG
Reid Spencerf9f431c2006-04-09 23:41:14 +0000263else
Reid Spencer0a522b12007-07-10 07:19:53 +0000264 CPP.Defines += -D_DEBUG
Chris Lattner71927862006-03-21 01:06:41 +0000265endif
266
David Greenecba29182007-06-29 03:36:21 +0000267# If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
268# configured), then enable expensive checks by defining the
269# appropriate preprocessor symbols.
David Greenea696d242007-06-28 19:36:08 +0000270ifdef ENABLE_EXPENSIVE_CHECKS
271 BuildMode := $(BuildMode)+Checks
Reid Spencer0a522b12007-07-10 07:19:53 +0000272 CPP.Defines += -D_GLIBCXX_DEBUG
David Greenea696d242007-06-28 19:36:08 +0000273endif
274
Reid Spencer89b0d992006-12-16 22:07:52 +0000275ifeq ($(ENABLE_PIC),1)
276 CXX.Flags += -fPIC
277 C.Flags += -fPIC
278endif
279
Reid Spencer3a9ec242006-08-28 01:02:49 +0000280CXX.Flags += $(CXXFLAGS) -Woverloaded-virtual
Reid Spencerf2722ca2006-03-22 15:59:55 +0000281C.Flags += $(CFLAGS)
David Greenea696d242007-06-28 19:36:08 +0000282CPP.Defines += $(CPPFLAGS)
283CPP.BaseFlags += $(CPP.Defines)
Reid Spencerf2722ca2006-03-22 15:59:55 +0000284LD.Flags += $(LDFLAGS)
285AR.Flags := cru
Reid Spencercc2d1e22004-10-30 09:19:36 +0000286LibTool.Flags := --tag=CXX
Reid Spencer3a561f52004-10-23 20:04:14 +0000287
Chris Lattner16620fc2006-07-27 18:19:51 +0000288# Make Floating point IEEE compliant on Alpha.
Andrew Lenharth39bcf5b2005-02-13 03:41:10 +0000289ifeq ($(ARCH),Alpha)
Reid Spencer89b0d992006-12-16 22:07:52 +0000290 CXX.Flags += -mieee
291 CPP.BaseFlags += -mieee
292ifeq ($(ENABLE_PIC),0)
293 CXX.Flags += -fPIC
294 CPP.BaseFlags += -fPIC
295endif
Andrew Lenharth39bcf5b2005-02-13 03:41:10 +0000296endif
297
Andrew Lenharthc5e455d2007-01-26 13:34:50 +0000298ifeq ($(ARCH),Alpha)
299 LD.Flags += -Wl,--no-relax
300endif
301
Reid Spencer3a561f52004-10-23 20:04:14 +0000302#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000303# Directory locations
Reid Spencer3a561f52004-10-23 20:04:14 +0000304#--------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +0000305ObjDir := $(PROJ_OBJ_DIR)/$(BuildMode)
306LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
307ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
308ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer815cbcf2004-11-18 10:03:46 +0000309LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer9a5acaf2004-11-18 20:04:39 +0000310LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer775bf892004-12-28 07:59:22 +0000311LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer2f138e72004-12-22 05:57:21 +0000312CFERuntimeLibDir := $(LLVMGCCDIR)/lib
John Criswell7a73b802003-06-30 21:59:07 +0000313
Reid Spencer3a561f52004-10-23 20:04:14 +0000314#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000315# Full Paths To Compiled Tools and Utilities
Reid Spencer3a561f52004-10-23 20:04:14 +0000316#--------------------------------------------------------------------
Reid Spencer3ca6d8b2005-01-14 16:33:36 +0000317EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
318Echo = @$(EchoCmd)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000319ifndef LIBTOOL
Reid Spencer4d71b662004-10-22 21:01:56 +0000320LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencercc2d1e22004-10-30 09:19:36 +0000321endif
322ifndef LLVMAS
323LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
324endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000325ifndef TBLGEN
Reid Spencere2cfe5d2006-07-26 21:14:56 +0000326 ifeq ($(LLVM_CROSS_COMPILING),1)
327 TBLGEN := $(LLVMToolDir)/tblgen$(BUILD_EXEEXT)
328 else
329 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
330 endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000331endif
Chris Lattneref0d0f12006-09-04 04:47:21 +0000332LLVM_CONFIG := $(LLVMToolDir)/llvm-config
Reid Spencer43eb96c2007-02-09 15:52:07 +0000333ifndef LLVMLD
Reid Spencer18464122007-02-09 17:09:14 +0000334LLVMLD := $(LLVMToolDir)/llvm-ld$(EXEEXT)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000335endif
Chris Lattner0a1db822006-09-04 05:23:20 +0000336ifndef LLVMDIS
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000337LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
338endif
339ifndef LLI
340LLI := $(LLVMToolDir)/lli$(EXEEXT)
341endif
Alkis Evlogimenoseebaf332005-02-27 10:21:37 +0000342ifndef LLC
343LLC := $(LLVMToolDir)/llc$(EXEEXT)
344endif
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000345ifndef LOPT
Alkis Evlogimenos20d793a2004-12-13 18:08:29 +0000346LOPT := $(LLVMToolDir)/opt$(EXEEXT)
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000347endif
Alkis Evlogimenos270e8512005-02-02 00:40:15 +0000348ifndef LBUGPOINT
349LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
350endif
Reid Spencere46687c2006-12-03 21:01:45 +0000351ifndef LUPGRADE
352LUPGRADE := $(LLVMToolDir)/llvm-upgrade$(EXEEXT)
353endif
354ifeq ($(LLVMGCC_MAJVERS),3)
355UPGRADE_MSG = $(Echo) "Upgrading $(1) assembly to latest."
356UPGRADE_LL = $(Verb)$(LUPGRADE) $(1) -o $(1).up.tmp -f ; $(MV) $(1).up.tmp $(1)
Reid Spencer44136722006-12-10 04:56:38 +0000357LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
358LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
Reid Spencere46687c2006-12-03 21:01:45 +0000359else
360UPGRADE_MSG =
361UPGRADE_LL =
Reid Spencer44136722006-12-10 04:56:38 +0000362LLVMGCCWITHPATH := $(LLVMGCC)
363LLVMGXXWITHPATH := $(LLVMGXX)
Reid Spencere46687c2006-12-03 21:01:45 +0000364endif
365
Reid Spencer3a561f52004-10-23 20:04:14 +0000366#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000367# Adjust to user's request
Reid Spencer3a561f52004-10-23 20:04:14 +0000368#--------------------------------------------------------------------
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000369
Reid Spencer492c2932005-01-11 04:31:07 +0000370# Adjust LD.Flags and Libtool.Flags depending on the kind of library that is
371# to be built. Note that if LOADABLE_MODULE is specified then the resulting
Reid Spencer42fe4552006-08-07 23:12:15 +0000372# shared library can be opened with dlopen. Also, LOADABLE_MODULE implies
373# several other things so we force them to be defined/on.
374ifdef LOADABLE_MODULE
375 SHARED_LIBRARY := 1
376 DONT_BUILD_RELINKED := 1
377 LINK_LIBS_IN_SHARED := 1
378 LD.Flags += -module
379endif
380
Reid Spencer492c2932005-01-11 04:31:07 +0000381ifdef SHARED_LIBRARY
Reid Spencercc2d1e22004-10-30 09:19:36 +0000382 LD.Flags += -rpath $(LibDir)
Reid Spencer492c2932005-01-11 04:31:07 +0000383else
384 LibTool.Flags += --tag=disable-shared
John Criswell82f4a5a2003-07-31 20:58:51 +0000385endif
386
Reid Spencercceed9f2004-11-08 17:32:12 +0000387ifdef TOOL_VERBOSE
388 C.Flags += -v
389 CXX.Flags += -v
390 LD.Flags += -v
Reid Spencercceed9f2004-11-08 17:32:12 +0000391 VERBOSE := 1
392endif
393
Reid Spencer3a561f52004-10-23 20:04:14 +0000394# Adjust settings for verbose mode
Chris Lattner760da062003-03-14 20:25:22 +0000395ifndef VERBOSE
Reid Spencercc2d1e22004-10-30 09:19:36 +0000396 Verb := @
397 LibTool.Flags += --silent
Reid Spencer491a6cd2007-07-23 08:20:46 +0000398 AR.Flags += >/dev/null 2>/dev/null
Reid Spencer11fde542005-01-16 02:20:54 +0000399 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
Reid Spencer151f8ba2004-10-25 08:27:37 +0000400else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000401 ConfigureScriptFLAGS :=
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000402endif
403
Vikram S. Advefeeae582002-09-18 11:55:13 +0000404# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000405ifndef KEEP_SYMBOLS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000406 Strip := $(PLATFORMSTRIPOPTS)
407 StripWarnMsg := "(without symbols)"
Reid Spencer860598a2005-02-24 07:12:43 +0000408 Install.StripFlag += -s
Vikram S. Advefeeae582002-09-18 11:55:13 +0000409endif
410
Reid Spencer3a561f52004-10-23 20:04:14 +0000411# Adjust linker flags for building an executable
Reid Spencer4d71b662004-10-22 21:01:56 +0000412ifdef TOOLNAME
Reid Spencer815cbcf2004-11-18 10:03:46 +0000413ifdef EXAMPLE_TOOL
414 LD.Flags += -rpath $(ExmplDir) -export-dynamic
415else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000416 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000417endif
Reid Spencer815cbcf2004-11-18 10:03:46 +0000418endif
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000419
Reid Spencer3a561f52004-10-23 20:04:14 +0000420#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000421# Options To Invoke Tools
Reid Spencer3a561f52004-10-23 20:04:14 +0000422#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000423
Reid Spencer3ed469c2006-11-02 20:25:50 +0000424CompileCommonOpts := -pedantic -Wall -W -Wwrite-strings -Wno-long-long \
425 -Wunused -Wno-unused-parameter $(EXTRA_OPTIONS)
Reid Spencer4d71b662004-10-22 21:01:56 +0000426
Duraid Madina0ad8fcf2005-05-16 06:38:09 +0000427ifeq ($(OS),HP-UX)
Duraid Madinaeb713402006-02-15 03:20:16 +0000428 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
Duraid Madina0ad8fcf2005-05-16 06:38:09 +0000429endif
430
Chris Lattner73faa392006-05-30 16:38:06 +0000431# If we are building a universal binary on Mac OS/X, pass extra options. This
432# is useful to people that want to link the LLVM libraries into their universal
Chris Lattner7dabf392006-06-29 19:38:04 +0000433# apps.
434#
435# The following can be optionally specified:
436# UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
437# For Mac OS/X 10.4 Intel machines, the traditional one is:
438# UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
439# UNIVERSAL_ARCH can be optionally specified to be a list of architectures
440# to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
441# i386/ppc only.
Chris Lattnerba466652006-04-06 06:30:15 +0000442ifdef UNIVERSAL
Chris Lattner7dabf392006-06-29 19:38:04 +0000443 ifndef UNIVERSAL_ARCH
444 UNIVERSAL_ARCH := i386 ppc
445 endif
446 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
447 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
448 Relink.Flags := $(UNIVERSAL_ARCH_OPTIONS:%=-XCClinker %)
Chris Lattnerf988e532006-06-16 21:47:59 +0000449 ifdef UNIVERSAL_SDK_PATH
450 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
451 Relink.Flags += -XCClinker -isysroot -XCClinker $(UNIVERSAL_SDK_PATH)
452 endif
453
454 # Building universal cannot compute dependencies automatically.
Chris Lattnerba466652006-04-06 06:30:15 +0000455 DISABLE_AUTO_DEPENDENCIES=1
456endif
457
Chris Lattner58a4c5e2008-06-24 17:44:42 +0000458ifeq ($(OS),SunOS)
459CPP.BaseFlags += -include llvm/System/Solaris.h
460endif
461
Reid Spencerf2722ca2006-03-22 15:59:55 +0000462LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
463CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
464# All -I flags should go here, so that they don't confuse llvm-config.
Duncan Sands095765e2008-01-28 17:38:30 +0000465CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
466 $(patsubst %,-I%/include,\
Chris Lattner2671fc32008-01-28 04:18:41 +0000467 $(PROJ_OBJ_ROOT) $(PROJ_SRC_ROOT) \
468 $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
469 $(CPP.BaseFlags)
Reid Spencer4d71b662004-10-22 21:01:56 +0000470
Chris Lattnerd95e3f22006-09-29 18:47:13 +0000471Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -c
Reid Spencercc2d1e22004-10-30 09:19:36 +0000472LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
Chris Lattnerd95e3f22006-09-29 18:47:13 +0000473BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts)
474Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -E
Chris Lattner0cb09f12005-10-05 00:28:41 +0000475
Chris Lattnerd95e3f22006-09-29 18:47:13 +0000476Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) -c
Reid Spencercc2d1e22004-10-30 09:19:36 +0000477LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
Chris Lattnerd95e3f22006-09-29 18:47:13 +0000478BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CXX.Flags) \
479 $(CompileCommonOpts)
480
Chris Lattner0cb09f12005-10-05 00:28:41 +0000481Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
Reid Spencer42fe4552006-08-07 23:12:15 +0000482Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
483 $(LD.Flags) $(Strip)
484LTLink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(Link)
485Relink = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
486 $(Relink.Flags)
487LTRelink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(Relink)
Reid Spencer1a9a69c2005-02-16 16:13:02 +0000488LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
489 $(Install.Flags)
Reid Spencer860598a2005-02-24 07:12:43 +0000490ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
Reid Spencerf2722ca2006-03-22 15:59:55 +0000491ScriptInstall = $(INSTALL) -m 0755
Reid Spencer860598a2005-02-24 07:12:43 +0000492DataInstall = $(INSTALL) -m 0644
Chris Lattner6e0a5292008-01-15 23:27:40 +0000493
494# When compiling under Mingw/Cygwin, the tblgen tool expects Windows
495# paths. In this case, the SYSPATH function (defined in
496# Makefile.config) transforms Unix paths into Windows paths.
497TableGen = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \
498 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \
499 -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target)
500
Reid Spencercc2d1e22004-10-30 09:19:36 +0000501Archive = $(AR) $(AR.Flags)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000502LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencer4d71b662004-10-22 21:01:56 +0000503ifdef RANLIB
Reid Spencer3a561f52004-10-23 20:04:14 +0000504Ranlib = $(RANLIB)
Reid Spencer4d71b662004-10-22 21:01:56 +0000505else
Reid Spencer3a561f52004-10-23 20:04:14 +0000506Ranlib = ranlib
John Criswell7a73b802003-06-30 21:59:07 +0000507endif
508
Chris Lattner00950542001-06-06 20:29:01 +0000509#----------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +0000510# Get the list of source files and compute object file
511# names from them.
Reid Spencer3a561f52004-10-23 20:04:14 +0000512#----------------------------------------------------------
Chris Lattner89681112006-01-27 22:13:12 +0000513
514ifndef SOURCES
515 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
516 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
517 $(PROJ_SRC_DIR)/*.l))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000518else
Chris Lattner89681112006-01-27 22:13:12 +0000519 Sources := $(SOURCES)
520endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000521
Chris Lattner89681112006-01-27 22:13:12 +0000522ifdef BUILT_SOURCES
523Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Reid Spencer345235ca2004-12-04 22:34:09 +0000524endif
Reid Spencer3a561f52004-10-23 20:04:14 +0000525
Chris Lattner89681112006-01-27 22:13:12 +0000526BaseNameSources := $(sort $(basename $(Sources)))
527
528ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
529ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
530ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
531
Reid Spencer3a561f52004-10-23 20:04:14 +0000532###############################################################################
533# DIRECTORIES: Handle recursive descent of directory structure
534###############################################################################
John Criswell82f4a5a2003-07-31 20:58:51 +0000535
Chris Lattner00950542001-06-06 20:29:01 +0000536#---------------------------------------------------------
Reid Spencera69b1ea2004-10-28 09:15:28 +0000537# Provide rules to make install dirs. This must be early
538# in the file so they get built before dependencies
539#---------------------------------------------------------
540
Reid Spenceraa8bc432005-05-19 20:26:14 +0000541$(PROJ_bindir): $(PROJ_bindir)/.dir
542$(PROJ_libdir): $(PROJ_libdir)/.dir
543$(PROJ_includedir): $(PROJ_includedir)/.dir
544$(PROJ_etcdir): $(PROJ_etcdir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000545
Reid Spencercc2d1e22004-10-30 09:19:36 +0000546# To create other directories, as needed, and timestamp their creation
547%/.dir:
548 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfbbf3072004-11-29 05:00:33 +0000549 $(Verb) $(DATE) > $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000550
Reid Spencer815cbcf2004-11-18 10:03:46 +0000551.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
552.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000553
554#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000555# Handle the DIRS options for sequential construction
Chris Lattner00950542001-06-06 20:29:01 +0000556#---------------------------------------------------------
557
Reid Spencercc2d1e22004-10-30 09:19:36 +0000558SubDirs :=
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000559ifdef DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000560SubDirs += $(DIRS)
Chris Lattner82033602006-07-26 20:22:26 +0000561
562ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000563$(RecursiveTargets)::
564 $(Verb) for dir in $(DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000565 if [ ! -f $$dir/Makefile ]; then \
566 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000567 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000568 fi; \
Reid Spencerdd1aac32006-05-17 22:55:35 +0000569 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000570 done
Chris Lattner82033602006-07-26 20:22:26 +0000571else
572$(RecursiveTargets)::
573 $(Verb) for dir in $(DIRS); do \
574 ($(MAKE) -C $$dir $@ ) || exit 1; \
575 done
576endif
577
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000578endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000579
Reid Spencer3a561f52004-10-23 20:04:14 +0000580#---------------------------------------------------------
581# Handle the EXPERIMENTAL_DIRS options ensuring success
582# after each directory is built.
583#---------------------------------------------------------
584ifdef EXPERIMENTAL_DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000585$(RecursiveTargets)::
586 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer3a561f52004-10-23 20:04:14 +0000587 if [ ! -f $$dir/Makefile ]; then \
588 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000589 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000590 fi; \
Reid Spencerdd1aac32006-05-17 22:55:35 +0000591 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000592 done
593endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000594
Reid Spencer25e8a702005-12-21 23:17:06 +0000595#-----------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000596# Handle the PARALLEL_DIRS options for parallel construction
Reid Spencer25e8a702005-12-21 23:17:06 +0000597#-----------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000598ifdef PARALLEL_DIRS
599
Reid Spencercc2d1e22004-10-30 09:19:36 +0000600SubDirs += $(PARALLEL_DIRS)
601
Reid Spencer44cb1b32004-12-03 20:08:48 +0000602# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencercc2d1e22004-10-30 09:19:36 +0000603all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
604clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000605clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000606install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000607uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencer44cb1b32004-12-03 20:08:48 +0000608install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000609
Reid Spencer345235ca2004-12-04 22:34:09 +0000610ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer3a561f52004-10-23 20:04:14 +0000611
Reid Spencer345235ca2004-12-04 22:34:09 +0000612$(ParallelTargets) :
Reid Spencercc2d1e22004-10-30 09:19:36 +0000613 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencer4d71b662004-10-22 21:01:56 +0000614 $(MKDIR) $(@D); \
Reid Spencer11fde542005-01-16 02:20:54 +0000615 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswellb3866b62003-11-25 19:32:22 +0000616 fi; \
Reid Spencer91140e92007-02-07 03:29:29 +0000617 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
Chris Lattner00950542001-06-06 20:29:01 +0000618endif
619
Reid Spencer3a561f52004-10-23 20:04:14 +0000620#---------------------------------------------------------
621# Handle the OPTIONAL_DIRS options for directores that may
622# or may not exist.
623#---------------------------------------------------------
John Criswell2a6530f2003-06-27 16:58:44 +0000624ifdef OPTIONAL_DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000625
Reid Spencercc2d1e22004-10-30 09:19:36 +0000626SubDirs += $(OPTIONAL_DIRS)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000627
Chris Lattner82033602006-07-26 20:22:26 +0000628ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000629$(RecursiveTargets)::
630 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000631 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
Reid Spencer4d71b662004-10-22 21:01:56 +0000632 if [ ! -f $$dir/Makefile ]; then \
633 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000634 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000635 fi; \
Reid Spencerdd1aac32006-05-17 22:55:35 +0000636 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000637 fi \
John Criswell2a6530f2003-06-27 16:58:44 +0000638 done
Chris Lattner82033602006-07-26 20:22:26 +0000639else
640$(RecursiveTargets)::
641 $(Verb) for dir in $(OPTIONAL_DIRS); do \
642 ($(MAKE) -C$$dir $@ ) || exit 1; \
643 done
644endif
John Criswell2a6530f2003-06-27 16:58:44 +0000645endif
646
Reid Spencerfc945082004-08-20 09:20:05 +0000647#---------------------------------------------------------
648# Handle the CONFIG_FILES options
649#---------------------------------------------------------
650ifdef CONFIG_FILES
Reid Spencerfc945082004-08-20 09:20:05 +0000651
Reid Spencera2a31bf2007-02-06 18:53:14 +0000652ifdef NO_INSTALL
653install-local::
654 $(Echo) Install circumvented with NO_INSTALL
655uninstall-local::
656 $(Echo) UnInstall circumvented with NO_INSTALL
657else
Reid Spencer11fde542005-01-16 02:20:54 +0000658install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
659 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000660 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000661 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
Reid Spencer4a0aaea2005-02-24 03:56:32 +0000662 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer11fde542005-01-16 02:20:54 +0000663 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
Reid Spencer4a0aaea2005-02-24 03:56:32 +0000664 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer1b426ab2004-11-23 05:59:53 +0000665 else \
666 $(ECHO) Error: cannot find config file $${file}. ; \
667 fi \
Reid Spencerfc945082004-08-20 09:20:05 +0000668 done
Reid Spencer3a561f52004-10-23 20:04:14 +0000669
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000670uninstall-local::
Reid Spencer11fde542005-01-16 02:20:54 +0000671 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000672 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000673 $(RM) -f $(PROJ_etcdir)/$${file} ; \
Reid Spencere5487ba2004-10-24 07:53:21 +0000674 done
Reid Spencera2a31bf2007-02-06 18:53:14 +0000675endif
Reid Spencere5487ba2004-10-24 07:53:21 +0000676
Reid Spencerfc945082004-08-20 09:20:05 +0000677endif
678
Reid Spencer3a561f52004-10-23 20:04:14 +0000679###############################################################################
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000680# Set up variables for building libararies
681###############################################################################
682
683#---------------------------------------------------------
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000684# Define various command line options pertaining to the
685# libraries needed when linking. There are "Proj" libs
686# (defined by the user's project) and "LLVM" libs (defined
Chris Lattneref0d0f12006-09-04 04:47:21 +0000687# by the LLVM project).
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000688#---------------------------------------------------------
Andrew Lenharth7ac17522005-08-13 05:09:50 +0000689
Chris Lattneref0d0f12006-09-04 04:47:21 +0000690ifdef USEDLIBS
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000691ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
692ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
Chris Lattneref0d0f12006-09-04 04:47:21 +0000693ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
694ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
695endif
696
697ifdef LLVMLIBS
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000698LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
699LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000700LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000701LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
Chris Lattneref0d0f12006-09-04 04:47:21 +0000702endif
703
Chris Lattner0a1db822006-09-04 05:23:20 +0000704ifeq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
Chris Lattneref0d0f12006-09-04 04:47:21 +0000705ifdef LINK_COMPONENTS
Chris Lattner0a1db822006-09-04 05:23:20 +0000706
707# If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
708# clean in tools, then do a make in tools (instead of at the top level).
709$(LLVM_CONFIG):
710 @echo "*** llvm-config doesn't exist - rebuilding it."
711 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
Gabor Greif0a4c3782008-02-27 13:34:15 +0000712
Chris Lattner0a1db822006-09-04 05:23:20 +0000713$(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
714
Reid Spencer54100d72007-02-04 22:12:25 +0000715ProjLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
716ProjLibsPaths += $(LLVM_CONFIG) \
Chris Lattnera7868af2006-09-04 06:39:52 +0000717 $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
Chris Lattneref0d0f12006-09-04 04:47:21 +0000718endif
Chris Lattner55e6c4a2006-09-04 04:50:10 +0000719endif
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000720
721###############################################################################
Reid Spencer3a561f52004-10-23 20:04:14 +0000722# Library Build Rules: Four ways to build a library
723###############################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000724
Reid Spencer7980ea42004-12-05 05:17:22 +0000725#---------------------------------------------------------
726# Bytecode Module Targets:
727# If the user set MODULE_NAME then they want to build a
728# bytecode module from the sources. We compile all the
729# sources and link it together into a single bytecode
730# module.
731#---------------------------------------------------------
732
733ifdef MODULE_NAME
Reid Spencer9a8398e2005-02-14 21:54:08 +0000734ifeq ($(strip $(LLVMGCC)),)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000735$(warning Modules require llvm-gcc but no llvm-gcc is available ****)
Reid Spencer9a8398e2005-02-14 21:54:08 +0000736else
Reid Spencer7980ea42004-12-05 05:17:22 +0000737
738Module := $(LibDir)/$(MODULE_NAME).bc
Andrew Lenhartha7b33db2008-02-25 22:41:55 +0000739LinkModule := $(LLVMLD) -L$(CFERuntimeLibDir) -r
Reid Spencerbbd5e432006-04-12 18:21:35 +0000740
Reid Spencer7980ea42004-12-05 05:17:22 +0000741
742ifdef EXPORTED_SYMBOL_FILE
Chris Lattner89681112006-01-27 22:13:12 +0000743LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer7980ea42004-12-05 05:17:22 +0000744endif
745
Reid Spencer43eb96c2007-02-09 15:52:07 +0000746$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000747 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
Reid Spencer7980ea42004-12-05 05:17:22 +0000748 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
749
750all-local:: $(Module)
751
752clean-local::
753ifneq ($(strip $(Module)),)
754 -$(Verb) $(RM) -f $(Module)
755endif
756
Reid Spencerab3690b2004-12-13 07:38:07 +0000757ifdef BYTECODE_DESTINATION
758ModuleDestDir := $(BYTECODE_DESTINATION)
759else
Reid Spencer11fde542005-01-16 02:20:54 +0000760ModuleDestDir := $(PROJ_libdir)
Reid Spencerab3690b2004-12-13 07:38:07 +0000761endif
Reid Spencer7980ea42004-12-05 05:17:22 +0000762
Reid Spencera2a31bf2007-02-06 18:53:14 +0000763ifdef NO_INSTALL
764install-local::
765 $(Echo) Install circumvented with NO_INSTALL
766uninstall-local::
767 $(Echo) Uninstall circumvented with NO_INSTALL
768else
Reid Spencerab3690b2004-12-13 07:38:07 +0000769DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
770
771install-module:: $(DestModule)
Reid Spencer7980ea42004-12-05 05:17:22 +0000772install-local:: $(DestModule)
773
Reid Spencerab3690b2004-12-13 07:38:07 +0000774$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencer7980ea42004-12-05 05:17:22 +0000775 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
Reid Spencer151bbe42005-02-24 21:30:37 +0000776 $(Verb) $(DataInstall) $(Module) $(DestModule)
Reid Spencer7980ea42004-12-05 05:17:22 +0000777
778uninstall-local::
779 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
780 -$(Verb) $(RM) -f $(DestModule)
Reid Spencera2a31bf2007-02-06 18:53:14 +0000781endif
Reid Spencer7980ea42004-12-05 05:17:22 +0000782
783endif
Reid Spencer9a8398e2005-02-14 21:54:08 +0000784endif
Brian Gaeke8abff792004-01-22 22:53:48 +0000785
Reid Spencer3a561f52004-10-23 20:04:14 +0000786# if we're building a library ...
Chris Lattner00950542001-06-06 20:29:01 +0000787ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000788
Chris Lattner2a548c52002-09-16 22:36:42 +0000789# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000790LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencer492c2932005-01-11 04:31:07 +0000791ifdef LOADABLE_MODULE
792LibName.LA := $(LibDir)/$(LIBRARYNAME).la
793else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000794LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
Reid Spencer492c2932005-01-11 04:31:07 +0000795endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000796LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
797LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer9a2f1372004-12-02 09:28:21 +0000798LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000799
Reid Spencer3a561f52004-10-23 20:04:14 +0000800#---------------------------------------------------------
801# Shared Library Targets:
802# If the user asked for a shared library to be built
803# with the SHARED_LIBRARY variable, then we provide
804# targets for building them.
805#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000806ifdef SHARED_LIBRARY
807
Reid Spencercc2d1e22004-10-30 09:19:36 +0000808all-local:: $(LibName.LA)
Reid Spencer4d71b662004-10-22 21:01:56 +0000809
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000810ifdef LINK_LIBS_IN_SHARED
Reid Spencer42fe4552006-08-07 23:12:15 +0000811ifdef LOADABLE_MODULE
Chris Lattner166f45e2006-11-15 21:04:15 +0000812SharedLibKindMessage := "Loadable Module"
Reid Spencer42fe4552006-08-07 23:12:15 +0000813else
814SharedLibKindMessage := "Shared Library"
815endif
Chris Lattnerf5c94672008-02-05 19:43:40 +0000816$(LibName.LA): $(ObjectsLO) $(ProjLibsPaths) $(LLVMLibsPaths) $(LibDir)/.dir
Reid Spencer42fe4552006-08-07 23:12:15 +0000817 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
818 $(LIBRARYNAME)$(SHLIBEXT)
819 $(Verb) $(LTLink) -o $@ $(ObjectsLO) $(ProjLibsOptions) \
820 $(LLVMLibsOptions)
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000821 $(Verb) $(LTInstall) $@ $(LibDir)
822else
Reid Spencerf2ac1892004-12-16 07:36:08 +0000823$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000824 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencer42fe4552006-08-07 23:12:15 +0000825 $(Verb) $(LTLink) -o $@ $(ObjectsLO)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000826 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000827endif
Reid Spencer3a561f52004-10-23 20:04:14 +0000828
829clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000830ifneq ($(strip $(LibName.LA)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000831 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000832endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000833
Reid Spencera2a31bf2007-02-06 18:53:14 +0000834ifdef NO_INSTALL
835install-local::
836 $(Echo) Install circumvented with NO_INSTALL
837uninstall-local::
838 $(Echo) Uninstall circumvented with NO_INSTALL
839else
Reid Spencer11fde542005-01-16 02:20:54 +0000840DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencer4d71b662004-10-22 21:01:56 +0000841
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000842install-local:: $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000843
Reid Spencer11fde542005-01-16 02:20:54 +0000844$(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
Reid Spencer9af3b292004-11-01 07:50:27 +0000845 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000846 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
Reid Spencer11fde542005-01-16 02:20:54 +0000847 $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
Reid Spencere5487ba2004-10-24 07:53:21 +0000848
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000849uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000850 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencer11fde542005-01-16 02:20:54 +0000851 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
Reid Spencera2a31bf2007-02-06 18:53:14 +0000852endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000853endif
854
Reid Spencer3a561f52004-10-23 20:04:14 +0000855#---------------------------------------------------------
856# Bytecode Library Targets:
857# If the user asked for a bytecode library to be built
858# with the BYTECODE_LIBRARY variable, then we provide
859# targets for building them.
860#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000861ifdef BYTECODE_LIBRARY
Reid Spencer9a8398e2005-02-14 21:54:08 +0000862ifeq ($(strip $(LLVMGCC)),)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000863$(warning Bytecode libraries require llvm-gcc which could not be found ****)
Reid Spencer9a8398e2005-02-14 21:54:08 +0000864else
Reid Spencer4d71b662004-10-22 21:01:56 +0000865
Reid Spencer9a2f1372004-12-02 09:28:21 +0000866all-local:: $(LibName.BCA)
867
868ifdef EXPORTED_SYMBOL_FILE
Reid Spencer43eb96c2007-02-09 15:52:07 +0000869BCLinkLib = $(LLVMLD) -L$(CFERuntimeLibDir) \
Chris Lattner73faa392006-05-30 16:38:06 +0000870 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000871
Reid Spencer43eb96c2007-02-09 15:52:07 +0000872$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
Chris Lattner264ccbe2004-12-15 17:14:06 +0000873 $(LLVMToolDir)/llvm-ar
Reid Spencer9a2f1372004-12-02 09:28:21 +0000874 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
875 "(internalize)"
Chris Lattnerb0ea8642004-12-02 21:23:43 +0000876 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencerefd6bb32004-12-13 03:59:35 +0000877 $(Verb) $(RM) -f $@
Reid Spencer9a2f1372004-12-02 09:28:21 +0000878 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencer4d71b662004-10-22 21:01:56 +0000879else
Reid Spencerf2ac1892004-12-16 07:36:08 +0000880$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
Chris Lattner264ccbe2004-12-15 17:14:06 +0000881 $(LLVMToolDir)/llvm-ar
Reid Spencer9a2f1372004-12-02 09:28:21 +0000882 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencerefd6bb32004-12-13 03:59:35 +0000883 $(Verb) $(RM) -f $@
Reid Spencer9a2f1372004-12-02 09:28:21 +0000884 $(Verb) $(LArchive) $@ $(ObjectsBC)
885
Reid Spencer4d71b662004-10-22 21:01:56 +0000886endif
887
Reid Spencer3a561f52004-10-23 20:04:14 +0000888clean-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000889ifneq ($(strip $(LibName.BCA)),)
890 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000891endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000892
Reid Spencer8f094f32004-12-13 07:28:21 +0000893ifdef BYTECODE_DESTINATION
894BytecodeDestDir := $(BYTECODE_DESTINATION)
895else
Reid Spencer11fde542005-01-16 02:20:54 +0000896BytecodeDestDir := $(PROJ_libdir)
Reid Spencer8f094f32004-12-13 07:28:21 +0000897endif
898
899DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
Reid Spencer9a2f1372004-12-02 09:28:21 +0000900
Reid Spencer44cb1b32004-12-03 20:08:48 +0000901install-bytecode-local:: $(DestBytecodeLib)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000902
Reid Spencera2a31bf2007-02-06 18:53:14 +0000903ifdef NO_INSTALL
904install-local::
905 $(Echo) Install circumvented with NO_INSTALL
906uninstall-local::
907 $(Echo) Uninstall circumvented with NO_INSTALL
908else
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000909install-local:: $(DestBytecodeLib)
Chris Lattner481cc7c2003-08-15 02:18:35 +0000910
Reid Spencer8f094f32004-12-13 07:28:21 +0000911$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000912 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerb80621f2005-02-24 21:36:32 +0000913 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000914
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000915uninstall-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000916 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000917 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencera2a31bf2007-02-06 18:53:14 +0000918endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000919endif
Reid Spencer9a8398e2005-02-14 21:54:08 +0000920endif
Vikram S. Adve60f56062002-08-02 18:34:12 +0000921
Reid Spencercc2d1e22004-10-30 09:19:36 +0000922#---------------------------------------------------------
923# ReLinked Library Targets:
Chris Lattner89938082005-10-24 02:21:45 +0000924# If the user explicitly requests a relinked library with
925# BUILD_RELINKED, provide it. Otherwise, if they specify
926# neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
927# them one.
Reid Spencercc2d1e22004-10-30 09:19:36 +0000928#---------------------------------------------------------
Chris Lattner89938082005-10-24 02:21:45 +0000929ifndef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000930ifndef DONT_BUILD_RELINKED
Chris Lattner89938082005-10-24 02:21:45 +0000931BUILD_RELINKED = 1
932endif
933endif
934
935ifdef BUILD_RELINKED
Reid Spencer4d71b662004-10-22 21:01:56 +0000936
Reid Spencercc2d1e22004-10-30 09:19:36 +0000937all-local:: $(LibName.O)
938
Reid Spencerf2ac1892004-12-16 07:36:08 +0000939$(LibName.O): $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000940 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencer42fe4552006-08-07 23:12:15 +0000941 $(Verb) $(LTRelink) -o $@ $(ObjectsO)
Reid Spencer4d71b662004-10-22 21:01:56 +0000942
Reid Spencer3a561f52004-10-23 20:04:14 +0000943clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000944ifneq ($(strip $(LibName.O)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000945 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencere5487ba2004-10-24 07:53:21 +0000946endif
947
Reid Spencera2a31bf2007-02-06 18:53:14 +0000948ifdef NO_INSTALL
949install-local::
950 $(Echo) Install circumvented with NO_INSTALL
951uninstall-local::
952 $(Echo) Uninstall circumvented with NO_INSTALL
953else
Reid Spencer11fde542005-01-16 02:20:54 +0000954DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
Reid Spencere5487ba2004-10-24 07:53:21 +0000955
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000956install-local:: $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000957
Reid Spencer11fde542005-01-16 02:20:54 +0000958$(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
Reid Spencer9af3b292004-11-01 07:50:27 +0000959 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000960 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000961
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000962uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000963 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000964 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencera2a31bf2007-02-06 18:53:14 +0000965endif
Chris Lattnere62dbe92002-07-23 17:56:16 +0000966endif
Chris Lattner760da062003-03-14 20:25:22 +0000967
Reid Spencercc2d1e22004-10-30 09:19:36 +0000968#---------------------------------------------------------
969# Archive Library Targets:
970# If the user wanted a regular archive library built,
971# then we provide targets for building them.
972#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000973ifdef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000974
Reid Spencercc2d1e22004-10-30 09:19:36 +0000975all-local:: $(LibName.A)
976
Reid Spencerf2ac1892004-12-16 07:36:08 +0000977$(LibName.A): $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000978 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000979 -$(Verb) $(RM) -f $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000980 $(Verb) $(Archive) $@ $(ObjectsO)
981 $(Verb) $(Ranlib) $@
Vikram S. Adve41e78912002-09-20 14:03:13 +0000982
Reid Spencer3a561f52004-10-23 20:04:14 +0000983clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000984ifneq ($(strip $(LibName.A)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000985 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner00950542001-06-06 20:29:01 +0000986endif
987
Reid Spencera2a31bf2007-02-06 18:53:14 +0000988ifdef NO_INSTALL
989install-local::
990 $(Echo) Install circumvented with NO_INSTALL
991uninstall-local::
992 $(Echo) Uninstall circumvented with NO_INSTALL
993else
Reid Spencer11fde542005-01-16 02:20:54 +0000994DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
Reid Spencere5487ba2004-10-24 07:53:21 +0000995
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000996install-local:: $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000997
Reid Spencer11fde542005-01-16 02:20:54 +0000998$(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
Reid Spencer9af3b292004-11-01 07:50:27 +0000999 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencer11fde542005-01-16 02:20:54 +00001000 $(Verb) $(MKDIR) $(PROJ_libdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001001 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +00001002
Reid Spencerc6dcc6a2004-10-28 07:57:28 +00001003uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +00001004 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001005 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencera2a31bf2007-02-06 18:53:14 +00001006endif
Reid Spencere5487ba2004-10-24 07:53:21 +00001007endif
1008
1009# endif LIBRARYNAME
Reid Spencer4d71b662004-10-22 21:01:56 +00001010endif
1011
Reid Spencerb1dd3dd2004-10-24 08:21:04 +00001012###############################################################################
1013# Tool Build Rules: Build executable tool based on TOOLNAME option
1014###############################################################################
1015
Chris Lattner1cbc29f2001-09-07 22:57:58 +00001016ifdef TOOLNAME
1017
Reid Spencercc2d1e22004-10-30 09:19:36 +00001018#---------------------------------------------------------
1019# Set up variables for building a tool.
1020#---------------------------------------------------------
Reid Spencer815cbcf2004-11-18 10:03:46 +00001021ifdef EXAMPLE_TOOL
Reid Spencer5da2d082005-05-19 21:03:11 +00001022ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer815cbcf2004-11-18 10:03:46 +00001023else
Reid Spencer5da2d082005-05-19 21:03:11 +00001024ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer815cbcf2004-11-18 10:03:46 +00001025endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +00001026
Reid Spencercc2d1e22004-10-30 09:19:36 +00001027#---------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +00001028# Provide targets for building the tools
1029#---------------------------------------------------------
1030all-local:: $(ToolBuildPath)
John Criswell2a6530f2003-06-27 16:58:44 +00001031
Reid Spencer3a561f52004-10-23 20:04:14 +00001032clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001033ifneq ($(strip $(ToolBuildPath)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001034 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencere5487ba2004-10-24 07:53:21 +00001035endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +00001036
Reid Spencer815cbcf2004-11-18 10:03:46 +00001037ifdef EXAMPLE_TOOL
1038$(ToolBuildPath): $(ExmplDir)/.dir
1039else
1040$(ToolBuildPath): $(ToolDir)/.dir
1041endif
1042
Chris Lattnera7868af2006-09-04 06:39:52 +00001043$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencer9af3b292004-11-01 07:50:27 +00001044 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencer42fe4552006-08-07 23:12:15 +00001045 $(Verb) $(LTLink) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
Reid Spencerab519972006-05-16 06:25:14 +00001046 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
Chris Lattnerd25ad612006-02-14 04:25:54 +00001047 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1048 $(StripWarnMsg)
Reid Spencere5487ba2004-10-24 07:53:21 +00001049
Reid Spencera2a31bf2007-02-06 18:53:14 +00001050ifdef NO_INSTALL
1051install-local::
1052 $(Echo) Install circumvented with NO_INSTALL
1053uninstall-local::
1054 $(Echo) Uninstall circumvented with NO_INSTALL
1055else
Reid Spencer11fde542005-01-16 02:20:54 +00001056DestTool = $(PROJ_bindir)/$(TOOLNAME)
Reid Spencere5487ba2004-10-24 07:53:21 +00001057
Reid Spencerc6dcc6a2004-10-28 07:57:28 +00001058install-local:: $(DestTool)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001059
Reid Spencer11fde542005-01-16 02:20:54 +00001060$(DestTool): $(PROJ_bindir) $(ToolBuildPath)
Reid Spencer9af3b292004-11-01 07:50:27 +00001061 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001062 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +00001063
Reid Spencerc6dcc6a2004-10-28 07:57:28 +00001064uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +00001065 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001066 -$(Verb) $(RM) -f $(DestTool)
Reid Spencera2a31bf2007-02-06 18:53:14 +00001067endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001068endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +00001069
Reid Spencercc2d1e22004-10-30 09:19:36 +00001070###############################################################################
1071# Object Build Rules: Build object files based on sources
1072###############################################################################
1073
Duraid Madina197ab872006-02-15 03:23:26 +00001074# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1075ifeq ($(OS),HP-UX)
1076 DISABLE_AUTO_DEPENDENCIES=1
1077endif
1078
Chris Lattnerd92490f2006-06-21 20:58:03 +00001079ifdef SHARED_LIBRARY
1080PIC_FLAG = "(PIC)"
1081MAYBE_PIC_Compile.CXX = $(LTCompile.CXX)
1082MAYBE_PIC_Compile.C = $(LTCompile.C)
1083else
1084MAYBE_PIC_Compile.CXX = $(Compile.CXX)
1085MAYBE_PIC_Compile.C = $(Compile.C)
1086endif
1087
Reid Spencercc2d1e22004-10-30 09:19:36 +00001088# Provide rule sets for when dependency generation is enabled
Reid Spencer4d71b662004-10-22 21:01:56 +00001089ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve41e78912002-09-20 14:03:13 +00001090
Reid Spencercc2d1e22004-10-30 09:19:36 +00001091#---------------------------------------------------------
1092# Create .lo files in the ObjDir directory from the .cpp and .c files...
1093#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001094
Chris Lattnere43ba3d2007-12-31 23:58:31 +00001095DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
1096 -MT "$(ObjDir)/$*.lo" -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
Gabor Greif0a4c3782008-02-27 13:34:15 +00001097
Chris Lattnere43ba3d2007-12-31 23:58:31 +00001098# If the build succeeded, move the dependency file over. If it failed, put an
1099# empty file there.
1100DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
1101 else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
1102
Chris Lattner3c473472004-12-16 17:28:50 +00001103$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerd92490f2006-06-21 20:58:03 +00001104 $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
Chris Lattnere43ba3d2007-12-31 23:58:31 +00001105 $(Verb) if $(MAYBE_PIC_Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1106 $(DEPEND_MOVEFILE)
Reid Spencer3a561f52004-10-23 20:04:14 +00001107
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001108$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerd92490f2006-06-21 20:58:03 +00001109 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
Chris Lattnere43ba3d2007-12-31 23:58:31 +00001110 $(Verb) if $(MAYBE_PIC_Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1111 $(DEPEND_MOVEFILE)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001112
Chris Lattner3c473472004-12-16 17:28:50 +00001113$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerd92490f2006-06-21 20:58:03 +00001114 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
Chris Lattnere43ba3d2007-12-31 23:58:31 +00001115 $(Verb) if $(MAYBE_PIC_Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
1116 $(DEPEND_MOVEFILE)
Reid Spencer3a561f52004-10-23 20:04:14 +00001117
Reid Spencercc2d1e22004-10-30 09:19:36 +00001118#---------------------------------------------------------
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001119# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
Reid Spencercc2d1e22004-10-30 09:19:36 +00001120#---------------------------------------------------------
Chris Lattner89681112006-01-27 22:13:12 +00001121
Reid Spencer129f0042006-12-30 16:31:02 +00001122$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
Reid Spencer9af3b292004-11-01 07:50:27 +00001123 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattnerd25ad612006-02-14 04:25:54 +00001124 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1125 $< -o $@ -S -emit-llvm ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001126 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1127 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencere46687c2006-12-03 21:01:45 +00001128 $(call UPGRADE_MSG,$@)
1129 $(call UPGRADE_LL,$@)
Reid Spencer4d71b662004-10-22 21:01:56 +00001130
Reid Spencer129f0042006-12-30 16:31:02 +00001131$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001132 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattnerd25ad612006-02-14 04:25:54 +00001133 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1134 $< -o $@ -S -emit-llvm ; \
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001135 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1136 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencere46687c2006-12-03 21:01:45 +00001137 $(call UPGRADE_MSG,$@)
1138 $(call UPGRADE_LL,$@)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001139
Reid Spencer129f0042006-12-30 16:31:02 +00001140$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
Reid Spencer9af3b292004-11-01 07:50:27 +00001141 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattnerd25ad612006-02-14 04:25:54 +00001142 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" \
1143 $< -o $@ -S -emit-llvm ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001144 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1145 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencere46687c2006-12-03 21:01:45 +00001146 $(call UPGRADE_MSG,$@)
1147 $(call UPGRADE_LL,$@)
Reid Spencer4d71b662004-10-22 21:01:56 +00001148
Reid Spencercc2d1e22004-10-30 09:19:36 +00001149# Provide alternate rule sets if dependencies are disabled
Reid Spencer4d71b662004-10-22 21:01:56 +00001150else
1151
Chris Lattner3c473472004-12-16 17:28:50 +00001152$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerd92490f2006-06-21 20:58:03 +00001153 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1154 $(MAYBE_PIC_Compile.CXX) $< -o $@
Reid Spencer3a561f52004-10-23 20:04:14 +00001155
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001156$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerd92490f2006-06-21 20:58:03 +00001157 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1158 $(MAYBE_PIC_Compile.CXX) $< -o $@
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001159
Chris Lattner3c473472004-12-16 17:28:50 +00001160$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerd92490f2006-06-21 20:58:03 +00001161 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1162 $(MAYBE_PIC_Compile.C) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +00001163
Reid Spencer129f0042006-12-30 16:31:02 +00001164$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
Reid Spencer9af3b292004-11-01 07:50:27 +00001165 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001166 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Reid Spencere46687c2006-12-03 21:01:45 +00001167 $(call UPGRADE_MSG,$@)
1168 $(call UPGRADE_LL,$@)
Reid Spencer4d71b662004-10-22 21:01:56 +00001169
Reid Spencer129f0042006-12-30 16:31:02 +00001170$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001171 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001172 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Reid Spencere46687c2006-12-03 21:01:45 +00001173 $(call UPGRADE_MSG,$@)
1174 $(call UPGRADE_LL,$@)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001175
Reid Spencer129f0042006-12-30 16:31:02 +00001176$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
Reid Spencer9af3b292004-11-01 07:50:27 +00001177 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001178 $(BCCompile.C) $< -o $@ -S -emit-llvm
Reid Spencere46687c2006-12-03 21:01:45 +00001179 $(call UPGRADE_MSG,@)
1180 $(call UPGRADE_LL,@)
Brian Gaeke44909cf2003-12-10 00:26:28 +00001181
Chris Lattner1cbc29f2001-09-07 22:57:58 +00001182endif
1183
Chris Lattner8eb12de2006-06-21 21:01:20 +00001184
1185## Rules for building preprocessed (.i/.ii) outputs.
1186$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1187 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1188 $(Verb) $(Preprocess.CXX) $< -o $@
1189
1190$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1191 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1192 $(Verb) $(Preprocess.CXX) $< -o $@
1193
Reid Spencer44136722006-12-10 04:56:38 +00001194$(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner8eb12de2006-06-21 21:01:20 +00001195 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1196 $(Verb) $(Preprocess.C) $< -o $@
1197
1198
1199$(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1200 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1201 $(MAYBE_PIC_Compile.CXX) $< -o $@ -S
1202
1203$(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1204 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1205 $(MAYBE_PIC_Compile.CXX) $< -o $@ -S
1206
1207$(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1208 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1209 $(MAYBE_PIC_Compile.C) $< -o $@ -S
1210
Reid Spencer8b2e1412006-11-17 03:32:33 +00001211
Chris Lattner89681112006-01-27 22:13:12 +00001212# make the C and C++ compilers strip debug info out of bytecode libraries.
Reid Spencer8b2e1412006-11-17 03:32:33 +00001213ifdef DEBUG_RUNTIME
Reid Spencer43eb96c2007-02-09 15:52:07 +00001214$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
Reid Spencer8b2e1412006-11-17 03:32:33 +00001215 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Reid Spencer18464122007-02-09 17:09:14 +00001216 $(Verb) $(LLVMAS) $< -o - | $(LOPT) -std-compile-opts -o $@ -f
Reid Spencer8b2e1412006-11-17 03:32:33 +00001217else
Reid Spencer43eb96c2007-02-09 15:52:07 +00001218$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
Chris Lattner89681112006-01-27 22:13:12 +00001219 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Reid Spencer43eb96c2007-02-09 15:52:07 +00001220 $(Verb) $(LLVMAS) $< -o - | \
Reid Spencer18464122007-02-09 17:09:14 +00001221 $(LOPT) -std-compile-opts -strip-debug -o $@ -f
Reid Spencer8b2e1412006-11-17 03:32:33 +00001222endif
1223
Chris Lattner89681112006-01-27 22:13:12 +00001224
Reid Spencercc2d1e22004-10-30 09:19:36 +00001225#---------------------------------------------------------
1226# Provide rule to build .bc files from .ll sources,
1227# regardless of dependencies
1228#---------------------------------------------------------
1229$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencer9af3b292004-11-01 07:50:27 +00001230 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001231 $(Verb) $(LLVMAS) $< -f -o $@
1232
1233###############################################################################
1234# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1235###############################################################################
Chris Lattner481cc7c2003-08-15 02:18:35 +00001236
Reid Spencer4d71b662004-10-22 21:01:56 +00001237ifdef TARGET
1238
Chris Lattnerd25ad612006-02-14 04:25:54 +00001239TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1240 $(LLVM_SRC_ROOT)/lib/Target/Target.td \
Chris Lattnerfd3542f2007-02-28 05:10:40 +00001241 $(LLVM_SRC_ROOT)/lib/Target/TargetCallingConv.td \
Chris Lattnercb3fc532006-03-03 01:54:54 +00001242 $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td \
Chris Lattner93858f62006-10-24 20:32:44 +00001243 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1244 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001245INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Chris Lattner3c473472004-12-16 17:28:50 +00001246INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1247.PRECIOUS: $(INCTMPFiles) $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001248
Chris Lattner3c473472004-12-16 17:28:50 +00001249# All of these files depend on tblgen and the .td files.
1250$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001251
Chris Lattner23ee7952004-12-16 17:38:56 +00001252# INCFiles rule: All of the tblgen generated files are emitted to
1253# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1254# us to only "touch" the real file if the contents of it change. IOW, if
1255# tblgen is modified, all of the .inc.tmp files are regereated, but no
1256# dependencies of the .inc files are, unless the contents of the .inc file
1257# changes.
1258$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
Reid Spencerc3719842004-12-16 18:26:53 +00001259 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
Chris Lattner3c473472004-12-16 17:28:50 +00001260
1261$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1262$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001263 $(Echo) "Building $(<F) register names with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001264 $(Verb) $(TableGen) -gen-register-enums -o $(call SYSPATH, $@) $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001265
Chris Lattner3c473472004-12-16 17:28:50 +00001266$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1267$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001268 $(Echo) "Building $(<F) register information header with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001269 $(Verb) $(TableGen) -gen-register-desc-header -o $(call SYSPATH, $@) $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001270
Chris Lattner3c473472004-12-16 17:28:50 +00001271$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1272$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001273 $(Echo) "Building $(<F) register info implementation with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001274 $(Verb) $(TableGen) -gen-register-desc -o $(call SYSPATH, $@) $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001275
Chris Lattner3c473472004-12-16 17:28:50 +00001276$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1277$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001278 $(Echo) "Building $(<F) instruction names with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001279 $(Verb) $(TableGen) -gen-instr-enums -o $(call SYSPATH, $@) $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001280
Chris Lattner3c473472004-12-16 17:28:50 +00001281$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1282$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001283 $(Echo) "Building $(<F) instruction information with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001284 $(Verb) $(TableGen) -gen-instr-desc -o $(call SYSPATH, $@) $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001285
Chris Lattner3c473472004-12-16 17:28:50 +00001286$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1287$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001288 $(Echo) "Building $(<F) assembly writer with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001289 $(Verb) $(TableGen) -gen-asm-writer -o $(call SYSPATH, $@) $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001290
Chris Lattner02a4f902004-12-16 17:34:04 +00001291$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1292$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1293 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001294 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $(call SYSPATH, $@) $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001295
Chris Lattner3c473472004-12-16 17:28:50 +00001296$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1297$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001298 $(Echo) "Building $(<F) code emitter with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001299 $(Verb) $(TableGen) -gen-emitter -o $(call SYSPATH, $@) $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001300
Chris Lattnerf31f09e2005-09-03 01:15:25 +00001301$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1302$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
Dan Gohmanb0cf29c2008-08-13 20:19:35 +00001303 $(Echo) "Building $(<F) DAG instruction selector implementation with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001304 $(Verb) $(TableGen) -gen-dag-isel -o $(call SYSPATH, $@) $<
Chris Lattnerf31f09e2005-09-03 01:15:25 +00001305
Dan Gohmanb0cf29c2008-08-13 20:19:35 +00001306$(TARGET:%=$(ObjDir)/%GenFastISel.inc.tmp): \
1307$(ObjDir)/%GenFastISel.inc.tmp : %.td $(ObjDir)/.dir
1308 $(Echo) "Building $(<F) \"fast\" instruction selector implementation with tblgen"
1309 $(Verb) $(TableGen) -gen-fast-isel -o $(call SYSPATH, $@) $<
1310
Jim Laskeyf5fc2cb2005-10-21 19:05:19 +00001311$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1312$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1313 $(Echo) "Building $(<F) subtarget information with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001314 $(Verb) $(TableGen) -gen-subtarget -o $(call SYSPATH, $@) $<
Chris Lattnerf31f09e2005-09-03 01:15:25 +00001315
Chris Lattnerbcc3c192007-02-27 20:44:12 +00001316$(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1317$(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1318 $(Echo) "Building $(<F) calling convention information with tblgen"
Chris Lattner6e0a5292008-01-15 23:27:40 +00001319 $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $<
Chris Lattnerbcc3c192007-02-27 20:44:12 +00001320
Reid Spencer3a561f52004-10-23 20:04:14 +00001321clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001322 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001323
1324endif
Chris Lattner481cc7c2003-08-15 02:18:35 +00001325
Reid Spencercc2d1e22004-10-30 09:19:36 +00001326###############################################################################
1327# LEX AND YACC: Provide rules for generating sources with lex and yacc
1328###############################################################################
Chris Lattnere8996782003-01-16 22:44:19 +00001329
Reid Spencercc2d1e22004-10-30 09:19:36 +00001330#---------------------------------------------------------
1331# Provide rules for generating a .cpp source file from
1332# (f)lex input sources.
1333#---------------------------------------------------------
1334
Reid Spencer3d659492004-11-02 16:36:03 +00001335LexFiles := $(filter %.l,$(Sources))
Reid Spencercc2d1e22004-10-30 09:19:36 +00001336
Reid Spencer3d659492004-11-02 16:36:03 +00001337ifneq ($(LexFiles),)
1338
Reid Spencer68a24bd2005-08-27 18:50:39 +00001339# Cancel built-in rules for lex
1340%.c: %.l
1341%.cpp: %.l
Reid Spencercc2d1e22004-10-30 09:19:36 +00001342
Chris Lattner342567c2006-02-14 05:12:00 +00001343all:: $(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs)
1344
Reid Spencercc2d1e22004-10-30 09:19:36 +00001345# Note the extra sed filtering here, used to cut down on the warnings emited
1346# by GCC. The last line is a gross hack to work around flex aparently not
1347# being able to resize the buffer on a large token input. Currently, for
1348# uninitialized string buffers in LLVM we can generate very long tokens, so
1349# this is a hack around it.
Chris Lattnerb7dc2b92003-08-15 20:00:47 +00001350# FIXME. (f.e. char Buffer[10000] )
Reid Spencer68a24bd2005-08-27 18:50:39 +00001351$(PROJ_SRC_DIR)/%.cpp: $(PROJ_SRC_DIR)/%.l
Reid Spencerc2ef8cd2004-12-10 19:44:16 +00001352 $(Echo) Flexing $*.l
Reid Spencer68a24bd2005-08-27 18:50:39 +00001353 $(Verb) $(FLEX) -t $(PROJ_SRC_DIR)/$*.l | \
Reid Spencer4d71b662004-10-22 21:01:56 +00001354 $(SED) 's/void yyunput/inline void yyunput/' | \
1355 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1356 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001357 > $(PROJ_SRC_DIR)/$*.cpp
Gabor Greif0a4c3782008-02-27 13:34:15 +00001358
1359# IFF the .l file has changed since it was last checked into SVN, copy the .l
Chris Lattner342567c2006-02-14 05:12:00 +00001360# file to .l.cvs and the generated .cpp file to .cpp.cvs. We use this mechanism
1361# so that people without flex can build LLVM by copying the .cvs files to the
1362# source location and building them.
1363$(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1364$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattneraf2f3512006-02-16 05:10:48 +00001365 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs || \
Chris Lattner342567c2006-02-14 05:12:00 +00001366 ($(CP) $< $@; $(CP) $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001367
Chris Lattner342567c2006-02-14 05:12:00 +00001368$(LexFiles:%.l=$(ObjDir)/%.o) : \
1369$(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
Chris Lattner00950542001-06-06 20:29:01 +00001370
Reid Spencer9af3b292004-11-01 07:50:27 +00001371clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001372 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencer9af3b292004-11-01 07:50:27 +00001373
Reid Spencercc2d1e22004-10-30 09:19:36 +00001374endif
1375
1376#---------------------------------------------------------
1377# Provide rules for generating a .cpp and .h source files
1378# from yacc (bison) input sources.
1379#---------------------------------------------------------
1380
Reid Spencer3d659492004-11-02 16:36:03 +00001381YaccFiles := $(filter %.y,$(Sources))
1382ifneq ($(YaccFiles),)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001383
1384.PRECIOUS: $(YaccOutput)
1385
Chris Lattner1f1edce2006-02-15 07:23:05 +00001386all:: $(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs)
Chris Lattner6599c752006-02-15 07:16:57 +00001387
Reid Spencercc2d1e22004-10-30 09:19:36 +00001388# Cancel built-in rules for yacc
1389%.c: %.y
1390%.cpp: %.y
1391%.h: %.y
1392
Reid Spencer25e8a702005-12-21 23:17:06 +00001393# Rule for building the bison based parsers...
Reid Spencer4869d7f2006-08-24 22:41:20 +00001394ifneq ($(BISON),)
Reid Spencer413f2f92007-05-17 22:51:35 +00001395$(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
Reid Spencercc2d1e22004-10-30 09:19:36 +00001396 $(Echo) "Bisoning $*.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001397 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1398 $(Verb) $(MV) -f $*.tab.c $(PROJ_SRC_DIR)/$*.cpp
1399 $(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
Chris Lattner00950542001-06-06 20:29:01 +00001400
Gabor Greif0a4c3782008-02-27 13:34:15 +00001401# IFF the .y file has changed since it was last checked into SVN, copy the .y
Chris Lattner6599c752006-02-15 07:16:57 +00001402# file to .y.cvs and the generated .cpp/.h file to .cpp.cvs/.h.cvs. We use this
1403# mechanism so that people without flex can build LLVM by copying the .cvs files
1404# to the source location and building them.
1405$(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1406$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattneraf2f3512006-02-16 05:10:48 +00001407 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs || \
Chris Lattner6599c752006-02-15 07:16:57 +00001408 ($(CP) $< $@; \
Chris Lattner1f1edce2006-02-15 07:23:05 +00001409 $(CP) $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs; \
Chris Lattner6599c752006-02-15 07:16:57 +00001410 $(CP) $(PROJ_SRC_DIR)/$*.h $(PROJ_SRC_DIR)/$*.h.cvs)
Reid Spencer25e8a702005-12-21 23:17:06 +00001411
Reid Spencer413f2f92007-05-17 22:51:35 +00001412else
1413$(PROJ_SRC_DIR)/%.cpp : $(PROJ_SRC_DIR)/%.cpp.cvs
1414 $(Echo) "Bison of $*.y SKIPPED, bison not found -- copying .cpp.cvs"
1415 $(Verb)$(CP) $(PROJ_SRC_DIR)/$*.cpp.cvs $(PROJ_SRC_DIR)/$*.cpp
1416
1417$(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.h.cvs
1418 $(Echo) "Bison of $*.y SKIPPED, bison not found -- copying .h.cvs"
1419 $(Verb)$(CP) $(PROJ_SRC_DIR)/$*.h.cvs $(PROJ_SRC_DIR)/$*.h
1420endif
1421
Chris Lattner6599c752006-02-15 07:16:57 +00001422
1423$(YaccFiles:%.y=$(ObjDir)/%.o): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
1424
1425YaccOutput := $(YaccFiles:%.y=%.output)
Reid Spencer25e8a702005-12-21 23:17:06 +00001426
Reid Spencer9af3b292004-11-01 07:50:27 +00001427clean-local::
Reid Spencer25e8a702005-12-21 23:17:06 +00001428 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001429endif
Chris Lattner00950542001-06-06 20:29:01 +00001430
Reid Spencercc2d1e22004-10-30 09:19:36 +00001431###############################################################################
1432# OTHER RULES: Other rules needed
1433###############################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +00001434
Chris Lattner30440c62003-01-16 21:06:18 +00001435# To create postscript files from dot files...
John Criswelle0f9ac62003-10-02 19:02:02 +00001436ifneq ($(DOT),false)
Chris Lattner30440c62003-01-16 21:06:18 +00001437%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +00001438 $(DOT) -Tps < $< > $@
John Criswell7a73b802003-06-30 21:59:07 +00001439else
1440%.ps: %.dot
Reid Spencercc2d1e22004-10-30 09:19:36 +00001441 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell7a73b802003-06-30 21:59:07 +00001442endif
Chris Lattner30440c62003-01-16 21:06:18 +00001443
John Criswell7f336952003-09-06 14:44:17 +00001444# This rules ensures that header files that are removed still have a rule for
1445# which they can be "generated." This allows make to ignore them and
1446# reproduce the dependency lists.
John Criswell4b6e5d12003-09-18 18:37:08 +00001447%.h:: ;
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001448%.hpp:: ;
John Criswell7f336952003-09-06 14:44:17 +00001449
Reid Spencercc2d1e22004-10-30 09:19:36 +00001450# Define clean-local to clean the current directory. Note that this uses a
1451# very conservative approach ensuring that empty variables do not cause
1452# errors or disastrous removal.
Reid Spencer3a561f52004-10-23 20:04:14 +00001453clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001454ifneq ($(strip $(ObjDir)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001455 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencere5487ba2004-10-24 07:53:21 +00001456endif
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001457 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001458ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001459 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001460endif
John Criswell7a73b802003-06-30 21:59:07 +00001461
Reid Spencer3d659492004-11-02 16:36:03 +00001462clean-all-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001463 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer3d659492004-11-02 16:36:03 +00001464
Reid Spencer12d79512004-11-12 02:27:36 +00001465
Reid Spencer3a561f52004-10-23 20:04:14 +00001466###############################################################################
1467# DEPENDENCIES: Include the dependency files if we should
1468###############################################################################
Chris Lattner33ad24a2003-08-22 14:10:16 +00001469ifndef DISABLE_AUTO_DEPENDENCIES
1470
Reid Spencer3a561f52004-10-23 20:04:14 +00001471# If its not one of the cleaning targets
Chris Lattner05a3e8a2008-01-22 05:19:26 +00001472ifneq ($(strip $(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencer4d71b662004-10-22 21:01:56 +00001473
Reid Spencer3a561f52004-10-23 20:04:14 +00001474# Get the list of dependency files
Reid Spencercc2d1e22004-10-30 09:19:36 +00001475DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Chris Lattner342567c2006-02-14 05:12:00 +00001476DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
Misha Brukman4f7a8cf2003-11-09 21:36:19 +00001477
Reid Spencer491a6cd2007-07-23 08:20:46 +00001478-include $(DependFiles) ""
Reid Spencer3a561f52004-10-23 20:04:14 +00001479
John Criswelld741bcf2003-08-12 18:51:51 +00001480endif
Chris Lattner1ddb6b62003-08-18 17:27:40 +00001481
Reid Spencercc2d1e22004-10-30 09:19:36 +00001482endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001483
Reid Spencer151f8ba2004-10-25 08:27:37 +00001484###############################################################################
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001485# CHECK: Running the test suite
1486###############################################################################
1487
1488check::
Reid Spencer11fde542005-01-16 02:20:54 +00001489 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1490 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001491 $(EchoCmd) Running test suite ; \
Reid Spencer11fde542005-01-16 02:20:54 +00001492 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001493 TESTSUITE=$(TESTSUITE) ; \
1494 else \
1495 $(EchoCmd) No Makefile in test directory ; \
1496 fi ; \
1497 else \
1498 $(EchoCmd) No test directory ; \
1499 fi
1500
1501###############################################################################
Reid Spencercc2d1e22004-10-30 09:19:36 +00001502# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer151f8ba2004-10-25 08:27:37 +00001503###############################################################################
1504
Reid Spencere45ebfa2004-10-26 07:09:33 +00001505#------------------------------------------------------------------------
1506# Define distribution related variables
1507#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +00001508DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1509DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1510TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1511DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1512DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1513DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
Reid Spencer151f8ba2004-10-25 08:27:37 +00001514DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1515 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001516 Makefile.config.in configure autoconf
1517DistOther := $(notdir $(wildcard \
Reid Spencer11fde542005-01-16 02:20:54 +00001518 $(PROJ_SRC_DIR)/*.h \
1519 $(PROJ_SRC_DIR)/*.td \
1520 $(PROJ_SRC_DIR)/*.def \
1521 $(PROJ_SRC_DIR)/*.ll \
1522 $(PROJ_SRC_DIR)/*.in))
Reid Spencercc2d1e22004-10-30 09:19:36 +00001523DistSubDirs := $(SubDirs)
Reid Spencerfbbf3072004-11-29 05:00:33 +00001524DistSources = $(Sources) $(EXTRA_DIST)
1525DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer151f8ba2004-10-25 08:27:37 +00001526
Reid Spencere45ebfa2004-10-26 07:09:33 +00001527#------------------------------------------------------------------------
1528# We MUST build distribution with OBJ_DIR != SRC_DIR
1529#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +00001530ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
Reid Spencere45ebfa2004-10-26 07:09:33 +00001531dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001532 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencere45ebfa2004-10-26 07:09:33 +00001533
Reid Spencere45ebfa2004-10-26 07:09:33 +00001534else
1535
Reid Spencere45ebfa2004-10-26 07:09:33 +00001536#------------------------------------------------------------------------
Reid Spencere45ebfa2004-10-26 07:09:33 +00001537# Prevent attempt to run dist targets from anywhere but the top level
1538#------------------------------------------------------------------------
1539ifneq ($(LEVEL),.)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001540dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencer11fde542005-01-16 02:20:54 +00001541 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001542else
1543
1544#------------------------------------------------------------------------
1545# Provide the top level targets
1546#------------------------------------------------------------------------
1547
Reid Spencercc2d1e22004-10-30 09:19:36 +00001548dist-gzip:: $(DistTarGZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001549
Reid Spencer345235ca2004-12-04 22:34:09 +00001550$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001551 $(Echo) Packing gzipped distribution tar file.
Reid Spencer11fde542005-01-16 02:20:54 +00001552 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
Reid Spencerfbbf3072004-11-29 05:00:33 +00001553 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencere45ebfa2004-10-26 07:09:33 +00001554
Reid Spencercc2d1e22004-10-30 09:19:36 +00001555dist-bzip2:: $(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001556
Reid Spencer345235ca2004-12-04 22:34:09 +00001557$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001558 $(Echo) Packing bzipped distribution tar file.
Reid Spencer11fde542005-01-16 02:20:54 +00001559 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
Reid Spencerfbbf3072004-11-29 05:00:33 +00001560 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001561
Reid Spencercc2d1e22004-10-30 09:19:36 +00001562dist-zip:: $(DistZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001563
Reid Spencer345235ca2004-12-04 22:34:09 +00001564$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001565 $(Echo) Packing zipped distribution file.
1566 $(Verb) rm -f $(DistZip)
Reid Spencer11fde542005-01-16 02:20:54 +00001567 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001568
1569dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001570 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001571
Reid Spencerf8f57402005-01-28 19:52:32 +00001572DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
Reid Spencere45ebfa2004-10-26 07:09:33 +00001573
Reid Spencer345235ca2004-12-04 22:34:09 +00001574dist-check:: $(DistTarGZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001575 $(Echo) Checking distribution tar file.
1576 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001577 $(RM) -rf $(DistCheckDir) ; \
1578 fi
Reid Spencercc2d1e22004-10-30 09:19:36 +00001579 $(Verb) $(MKDIR) $(DistCheckDir)
1580 $(Verb) cd $(DistCheckDir) && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001581 $(MKDIR) $(DistCheckDir)/build && \
1582 $(MKDIR) $(DistCheckDir)/install && \
1583 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1584 cd build && \
1585 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
Reid Spencer45eeed92005-05-24 02:33:20 +00001586 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
Reid Spencer345235ca2004-12-04 22:34:09 +00001587 $(MAKE) all && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001588 $(MAKE) check && \
1589 $(MAKE) install && \
1590 $(MAKE) uninstall && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001591 $(MAKE) dist-clean && \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001592 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001593
1594dist-clean::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001595 $(Echo) Cleaning distribution files
Reid Spencer345235ca2004-12-04 22:34:09 +00001596 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1597 $(DistCheckDir)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001598
1599endif
1600
1601#------------------------------------------------------------------------
1602# Provide the recursive distdir target for building the distribution directory
1603#------------------------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +00001604distdir: $(DistDir)/.makedistdir
1605$(DistDir)/.makedistdir: $(DistSources)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001606 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001607 if test -d "$(DistDir)" ; then \
1608 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1609 exit 1 ; \
1610 fi ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001611 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001612 $(RM) -rf $(DistDir); \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001613 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer854071c2006-04-10 16:46:04 +00001614 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001615 fi
Reid Spencerfbbf3072004-11-29 05:00:33 +00001616 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001617 $(Verb) $(MKDIR) $(DistDir)
Reid Spencer11fde542005-01-16 02:20:54 +00001618 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1619 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001620 for file in $(DistFiles) ; do \
1621 case "$$file" in \
Reid Spencer11fde542005-01-16 02:20:54 +00001622 $(PROJ_SRC_DIR)/*) \
Reid Spencer345235ca2004-12-04 22:34:09 +00001623 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1624 ;; \
Reid Spencer11fde542005-01-16 02:20:54 +00001625 $(PROJ_SRC_ROOT)/*) \
Reid Spencer345235ca2004-12-04 22:34:09 +00001626 file=`echo "$$file" | \
1627 sed "s#^$$srcrootstrip/##"` \
1628 ;; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001629 esac; \
Reid Spencer11fde542005-01-16 02:20:54 +00001630 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1631 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1632 from_dir="$(PROJ_SRC_DIR)" ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001633 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001634 from_dir=. ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001635 fi ; \
1636 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001637 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1638 to_dir="$(DistDir)/$$dir"; \
1639 $(MKDIR) "$$to_dir" ; \
1640 else \
1641 to_dir="$(DistDir)"; \
1642 fi; \
1643 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1644 if test -n "$$mid_dir" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001645 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001646 fi ; \
1647 if test -d "$$from_dir/$$file"; then \
Reid Spencer11fde542005-01-16 02:20:54 +00001648 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1649 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
Reid Spencer45eeed92005-05-24 02:33:20 +00001650 cd $(PROJ_SRC_DIR) ; \
1651 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1652 ( cd $$to_dir ; $(TAR) xf - ) ; \
1653 cd $(PROJ_OBJ_DIR) ; \
1654 else \
1655 cd $$from_dir ; \
1656 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1657 ( cd $$to_dir ; $(TAR) xf - ) ; \
1658 cd $(PROJ_OBJ_DIR) ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001659 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001660 elif test -f "$$from_dir/$$file" ; then \
Reid Spencerc3719842004-12-16 18:26:53 +00001661 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001662 elif test -L "$$from_dir/$$file" ; then \
Reid Spencerc3719842004-12-16 18:26:53 +00001663 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001664 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer345235ca2004-12-04 22:34:09 +00001665 $(EchoCmd) "===== WARNING: Distribution Source " \
1666 "$$from_dir/$$file Not Found!" ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001667 elif test "$(Verb)" != '@' ; then \
1668 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001669 fi; \
1670 done
Reid Spencercc2d1e22004-10-30 09:19:36 +00001671 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001672 if test "$$subdir" \!= "." ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001673 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001674 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer854071c2006-04-10 16:46:04 +00001675 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
Reid Spencerbac3ca22006-04-07 16:06:18 +00001676 DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001677 fi; \
1678 done
Reid Spencer345235ca2004-12-04 22:34:09 +00001679 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer45eeed92005-05-24 02:33:20 +00001680 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
Chris Lattner77efe272006-02-14 04:27:15 +00001681 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1682 -name .svn \) -print` ;\
Reid Spencer345235ca2004-12-04 22:34:09 +00001683 $(MAKE) dist-hook ; \
1684 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1685 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1686 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1687 -o ! -type d ! -perm -444 -exec \
1688 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1689 || chmod -R a+r $(DistDir) ; \
1690 fi
Reid Spencer151f8ba2004-10-25 08:27:37 +00001691
Reid Spencercc2d1e22004-10-30 09:19:36 +00001692# This is invoked by distdir target, define it as a no-op to avoid errors if not
1693# defined by user.
Reid Spencer151f8ba2004-10-25 08:27:37 +00001694dist-hook::
1695
Reid Spencere53e3972004-10-22 23:06:30 +00001696endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001697
1698###############################################################################
Reid Spencere5487ba2004-10-24 07:53:21 +00001699# TOP LEVEL - targets only to apply at the top level directory
1700###############################################################################
1701
1702ifeq ($(LEVEL),.)
1703
1704#------------------------------------------------------------------------
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001705# Install support for the project's include files:
Reid Spencere5487ba2004-10-24 07:53:21 +00001706#------------------------------------------------------------------------
Reid Spencera2a31bf2007-02-06 18:53:14 +00001707ifdef NO_INSTALL
1708install-local::
1709 $(Echo) Install circumvented with NO_INSTALL
1710uninstall-local::
1711 $(Echo) Uninstall circumvented with NO_INSTALL
1712else
Reid Spencere5487ba2004-10-24 07:53:21 +00001713install-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001714 $(Echo) Installing include files
Reid Spencer11fde542005-01-16 02:20:54 +00001715 $(Verb) $(MKDIR) $(PROJ_includedir)
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001716 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
Reid Spencer11fde542005-01-16 02:20:54 +00001717 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer2edabc02005-02-16 15:54:03 +00001718 for hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
Reid Spencer0522d8b2007-04-09 19:08:58 +00001719 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
1720 grep -v .svn` ; do \
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001721 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1722 if test \! -d "$$instdir" ; then \
1723 $(EchoCmd) Making install directory $$instdir ; \
1724 $(MKDIR) $$instdir ;\
1725 fi ; \
1726 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer2edabc02005-02-16 15:54:03 +00001727 done ; \
Reid Spencere5487ba2004-10-24 07:53:21 +00001728 fi
Reid Spencer443045a2005-12-23 22:27:56 +00001729ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001730 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
Reid Spencer2edabc02005-02-16 15:54:03 +00001731 cd $(PROJ_OBJ_ROOT)/include && \
Reid Spencer443045a2005-12-23 22:27:56 +00001732 for hdr in `find . -type f -print | grep -v CVS` ; do \
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001733 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer2edabc02005-02-16 15:54:03 +00001734 done ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001735 fi
Reid Spencer443045a2005-12-23 22:27:56 +00001736endif
Reid Spencere5487ba2004-10-24 07:53:21 +00001737
1738uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001739 $(Echo) Uninstalling include files
Reid Spencer11fde542005-01-16 02:20:54 +00001740 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1741 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencere5487ba2004-10-24 07:53:21 +00001742 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
Chris Lattnerd25ad612006-02-14 04:25:54 +00001743 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' \
1744 -o -name '*.in' ')' -print ')' | \
1745 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001746 cd $(PROJ_SRC_ROOT)/include && \
Chris Lattnerd25ad612006-02-14 04:25:54 +00001747 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1748 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001749 fi
Reid Spencera2a31bf2007-02-06 18:53:14 +00001750endif
Reid Spencere5487ba2004-10-24 07:53:21 +00001751endif
1752
Chris Lattner03840ac2007-04-14 23:35:45 +00001753check-line-length:
Gabor Greifb1dbcd82008-05-15 10:04:30 +00001754 @echo searching for overlength lines in files: $(Sources)
1755 @echo
1756 @echo
Gabor Greif5039a6f2008-08-28 22:32:39 +00001757 egrep -n '.{81}' $(Sources) /dev/null
Chris Lattner03840ac2007-04-14 23:35:45 +00001758
Anton Korobeynikovbed29462007-04-16 18:10:23 +00001759check-for-tabs:
Gabor Greifb1dbcd82008-05-15 10:04:30 +00001760 @echo searching for tabs in files: $(Sources)
1761 @echo
1762 @echo
Gabor Greif5039a6f2008-08-28 22:32:39 +00001763 egrep -n ' ' $(Sources) /dev/null
Gabor Greifb1dbcd82008-05-15 10:04:30 +00001764
Reid Spencer6548bf12007-05-02 21:29:39 +00001765check-footprint:
1766 @ls -l $(LibDir) | awk '\
1767 BEGIN { sum = 0; } \
1768 { sum += $$5; } \
1769 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1770 @ls -l $(ToolDir) | awk '\
1771 BEGIN { sum = 0; } \
1772 { sum += $$5; } \
1773 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
Reid Spencer4d71b662004-10-22 21:01:56 +00001774#------------------------------------------------------------------------
1775# Print out the directories used for building
Reid Spencercc2d1e22004-10-30 09:19:36 +00001776#------------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001777printvars::
Reid Spencer11fde542005-01-16 02:20:54 +00001778 $(Echo) "BuildMode : " '$(BuildMode)'
1779 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1780 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1781 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1782 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1783 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1784 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1785 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1786 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1787 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1788 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
Reid Spencer1a9a69c2005-02-16 16:13:02 +00001789 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
Reid Spencer11fde542005-01-16 02:20:54 +00001790 $(Echo) "UserTargets : " '$(UserTargets)'
1791 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1792 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1793 $(Echo) "ObjDir : " '$(ObjDir)'
1794 $(Echo) "LibDir : " '$(LibDir)'
1795 $(Echo) "ToolDir : " '$(ToolDir)'
1796 $(Echo) "ExmplDir : " '$(ExmplDir)'
1797 $(Echo) "Sources : " '$(Sources)'
1798 $(Echo) "TDFiles : " '$(TDFiles)'
1799 $(Echo) "INCFiles : " '$(INCFiles)'
1800 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
Reid Spencere0acb762005-03-01 16:27:06 +00001801 $(Echo) "PreConditions: " '$(PreConditions)'
Reid Spencer11fde542005-01-16 02:20:54 +00001802 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1803 $(Echo) "Compile.C : " '$(Compile.C)'
1804 $(Echo) "Archive : " '$(Archive)'
1805 $(Echo) "YaccFiles : " '$(YaccFiles)'
1806 $(Echo) "LexFiles : " '$(LexFiles)'
1807 $(Echo) "Module : " '$(Module)'
Reid Spencer755bcf02005-08-24 10:43:10 +00001808 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
Reid Spencerf9f431c2006-04-09 23:41:14 +00001809 $(Echo) "SubDirs : " '$(SubDirs)'
Reid Spencer8475ec02007-03-29 19:05:44 +00001810 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
1811 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'