blob: d35447d912977b5d1e5dcf8bff259417f9225a91 [file] [log] [blame]
Misha Brukman7426c892004-04-24 00:10:56 +00001#===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
2#
John Criswell23e43fb2003-10-21 14:33:46 +00003# The LLVM Compiler Infrastructure
4#
5# This file was developed by the LLVM research group and is distributed under
6# the University of Illinois Open Source License. See LICENSE.TXT for details.
7#
Misha Brukman7426c892004-04-24 00:10:56 +00008#===------------------------------------------------------------------------===#
Chris Lattner2f7c9632001-06-06 20:29:01 +00009#
Reid Spencer81cd0492004-10-23 20:04:14 +000010# This file is included by all of the LLVM makefiles. For details on how to use
11# it properly, please see the document MakefileGuide.html in the docs directory.
Chris Lattner2e9fc94a2003-08-15 03:02:52 +000012#
Chris Lattnerb8e7aa02006-02-14 04:27:15 +000013#===-----------------------------------------------------------------------====#
Chris Lattner2f7c9632001-06-06 20:29:01 +000014
Reid Spencerf88808a2004-10-30 09:19:36 +000015################################################################################
Reid Spencer81cd0492004-10-23 20:04:14 +000016# TARGETS: Define standard targets that can be invoked
Reid Spencerf88808a2004-10-30 09:19:36 +000017################################################################################
John Criswell3ef61af2003-06-30 21:59:07 +000018
Chris Lattner2f7c9632001-06-06 20:29:01 +000019#--------------------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +000020# Define the various target sets
21#--------------------------------------------------------------------
Chris Lattner661a7142004-12-03 21:05:57 +000022RecursiveTargets := all clean clean-all install uninstall install-bytecode
Reid Spencer8b5ebe52004-12-06 05:35:13 +000023LocalTargets := all-local clean-local clean-all-local check-local \
Reid Spencerd4bd3752004-12-03 20:08:48 +000024 install-local printvars uninstall-local \
25 install-bytecode-local
Reid Spencer8b5ebe52004-12-06 05:35:13 +000026TopLevelTargets := check dist dist-check dist-clean tags dist-gzip dist-bzip2 \
Reid Spencerf88808a2004-10-30 09:19:36 +000027 dist-zip
28UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
29InternalTargets := preconditions distdir dist-hook
Reid Spencer81cd0492004-10-23 20:04:14 +000030
Reid Spencerf88808a2004-10-30 09:19:36 +000031################################################################################
Reid Spencer77a46d22004-10-26 22:26:33 +000032# INITIALIZATION: Basic things the makefile needs
Reid Spencerf88808a2004-10-30 09:19:36 +000033################################################################################
34
35#--------------------------------------------------------------------
36# Set the VPATH so that we can find source files.
37#--------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +000038VPATH=$(PROJ_SRC_DIR)
Reid Spencer77a46d22004-10-26 22:26:33 +000039
40#--------------------------------------------------------------------
41# Reset the list of suffixes we know how to build
42#--------------------------------------------------------------------
43.SUFFIXES:
Chris Lattnerb3eb31f2006-01-27 22:13:12 +000044.SUFFIXES: .c .cpp .cc .h .hpp .y .l .lo .o .a .bc .td .ps .dot .ll
Reid Spencerf88808a2004-10-30 09:19:36 +000045.SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
Reid Spencer77a46d22004-10-26 22:26:33 +000046
Reid Spencer81cd0492004-10-23 20:04:14 +000047#--------------------------------------------------------------------
48# Mark all of these targets as phony to avoid implicit rule search
49#--------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +000050.PHONY: $(UserTargets) $(InternalTargets)
Reid Spencer81cd0492004-10-23 20:04:14 +000051
52#--------------------------------------------------------------------
Reid Spencer77a46d22004-10-26 22:26:33 +000053# Make sure all the user-target rules are double colon rules and
54# they are defined first.
Reid Spencer81cd0492004-10-23 20:04:14 +000055#--------------------------------------------------------------------
56
Reid Spencerf88808a2004-10-30 09:19:36 +000057$(UserTargets)::
Reid Spencer100080c2004-10-25 08:27:37 +000058
Reid Spencer77a46d22004-10-26 22:26:33 +000059################################################################################
60# PRECONDITIONS: that which must be built/checked first
61################################################################################
62
Reid Spencerd4bd3752004-12-03 20:08:48 +000063SrcMakefiles := $(filter %Makefile %Makefile.tests,\
Reid Spencerba6a3db2005-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 Lattner68c97542006-09-04 05:23:20 +000076
Reid Spencerba6a3db2005-01-16 02:20:54 +000077ifneq ($(MakefileConfigIn),)
78PreConditions += $(MakefileConfig)
79endif
Reid Spencer77a46d22004-10-26 22:26:33 +000080
Reid Spencer53846bc2005-08-25 04:59:49 +000081preconditions: $(PreConditions)
Reid Spencer77a46d22004-10-26 22:26:33 +000082
83#------------------------------------------------------------------------
84# Make sure the BUILT_SOURCES are built first
85#------------------------------------------------------------------------
Reid Spencer97e40f12004-12-16 07:15:16 +000086$(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
Reid Spencer77a46d22004-10-26 22:26:33 +000087
Reid Spencer48c74392007-02-07 19:13:19 +000088clean-all-local::
Reid Spencer77a46d22004-10-26 22:26:33 +000089ifneq ($(strip $(BUILT_SOURCES)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +000090 -$(Verb) $(RM) -f $(BUILT_SOURCES)
Reid Spencer77a46d22004-10-26 22:26:33 +000091endif
92
Reid Spencerba6a3db2005-01-16 02:20:54 +000093ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
Reid Spencer55814372004-12-16 08:00:46 +000094spotless:
Reid Spencer55814372004-12-16 08:00:46 +000095 $(Verb) if test -x config.status ; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +000096 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
Reid Spencer7ef8e662004-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 Spencer55814372004-12-16 08:00:46 +0000101 $(RM) -rf * ; \
Reid Spencer7ef8e662004-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 Spencerba6a3db2005-01-16 02:20:54 +0000106 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
Reid Spencer7ef8e662004-12-17 07:45:03 +0000107 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
108 $(ConfigStatusScript) ; \
Reid Spencer55814372004-12-16 08:00:46 +0000109 else \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000110 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
Reid Spencer55814372004-12-16 08:00:46 +0000111 fi
Reid Spencerc49a8632005-12-21 23:17:06 +0000112else
113spotless:
114 $(EchoCmd) "spotless target not supported for objdir == srcdir"
Reid Spencer55814372004-12-16 08:00:46 +0000115endif
116
Reid Spencerf88808a2004-10-30 09:19:36 +0000117$(BUILT_SOURCES) : $(ObjMakefiles)
Reid Spencerb7f710a2004-10-28 00:41:43 +0000118
Reid Spencer77a46d22004-10-26 22:26:33 +0000119#------------------------------------------------------------------------
120# Make sure we're not using a stale configuration
121#------------------------------------------------------------------------
Reid Spencerafdc82c2004-12-16 18:26:53 +0000122reconfigure:
Reid Spencerba6a3db2005-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 Spencer35655d62004-12-24 03:36:31 +0000127 fi ; \
Reid Spencerafdc82c2004-12-16 18:26:53 +0000128 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
129 $(ConfigStatusScript)
130
Reid Spencerf88808a2004-10-30 09:19:36 +0000131.PRECIOUS: $(ConfigStatusScript)
132$(ConfigStatusScript): $(ConfigureScript)
133 $(Echo) Reconfiguring with $<
Reid Spencerba6a3db2005-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 Spencer35655d62004-12-24 03:36:31 +0000137 fi ; \
Reid Spencer50f34872004-11-29 12:37:44 +0000138 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
139 $(ConfigStatusScript)
Reid Spencer77a46d22004-10-26 22:26:33 +0000140
Reid Spencer83bde552005-08-25 04:44:18 +0000141#------------------------------------------------------------------------
Reid Spencer77a46d22004-10-26 22:26:33 +0000142# Make sure the configuration makefile is up to date
143#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +0000144ifneq ($(MakefileConfigIn),)
145$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
Reid Spencerf88808a2004-10-30 09:19:36 +0000146 $(Echo) Regenerating $@
Reid Spencerba6a3db2005-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 Spencer77a46d22004-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 Spencerba6a3db2005-01-16 02:20:54 +0000160ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
Reid Spencer77a46d22004-10-26 22:26:33 +0000161
Reid Spencerba6a3db2005-01-16 02:20:54 +0000162Makefile: $(PROJ_SRC_DIR)/Makefile
Reid Spencerf88808a2004-10-30 09:19:36 +0000163 $(Echo) "Updating Makefile"
164 $(Verb) $(MKDIR) $(@D)
Reid Spencerafdc82c2004-12-16 18:26:53 +0000165 $(Verb) $(CP) -f $< $@
Reid Spencer77a46d22004-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 Spencerba6a3db2005-01-16 02:20:54 +0000170$(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
Reid Spencerd94bb332004-10-26 23:10:00 +0000171 @case '$?' in \
172 *Makefile.rules) ;; \
173 *.in) ;; \
Reid Spencerf88808a2004-10-30 09:19:36 +0000174 *) $(Echo) "Updating $(@F)" ; \
Reid Spencerd94bb332004-10-26 23:10:00 +0000175 $(MKDIR) $(@D) ; \
Reid Spencerafdc82c2004-12-16 18:26:53 +0000176 $(CP) -f $< $@ ;; \
Reid Spencerd94bb332004-10-26 23:10:00 +0000177 esac
178
Reid Spencer77a46d22004-10-26 22:26:33 +0000179endif
180
181#------------------------------------------------------------------------
182# Set up the basic dependencies
183#------------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000184$(UserTargets):: $(PreConditions)
Reid Spencer77a46d22004-10-26 22:26:33 +0000185
186all:: all-local
Reid Spencer81cd0492004-10-23 20:04:14 +0000187clean:: clean-local
Reid Spencer9d0c1e02004-11-02 16:36:03 +0000188clean-all:: clean-local clean-all-local
Reid Spencer77a46d22004-10-26 22:26:33 +0000189install:: install-local
190uninstall:: uninstall-local
Reid Spencer77a46d22004-10-26 22:26:33 +0000191install-local:: all-local
Reid Spencerd4bd3752004-12-03 20:08:48 +0000192install-bytecode:: install-bytecode-local
Reid Spencer81cd0492004-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 Lattner2f7c9632001-06-06 20:29:01 +0000200#--------------------------------------------------------------------
201
Chris Lattner213a85b2006-05-24 23:02:40 +0000202# OPTIMIZE_OPTION - The optimization level option we want to build LLVM with
203# this can be overridden on the make command line.
Reid Spencer187b4ad2006-06-01 19:03:21 +0000204ifneq ($(OS),MingW)
205 OPTIMIZE_OPTION := -O3
206else
207 OPTIMIZE_OPTION := -O2
208endif
Chris Lattner213a85b2006-05-24 23:02:40 +0000209
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000210ifdef ENABLE_PROFILING
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000211 BuildMode := Profile
Chris Lattner4a482452006-07-11 18:33:50 +0000212 CXX.Flags := $(OPTIMIZE_OPTION) -pg -g
213 C.Flags := $(OPTIMIZE_OPTION) -pg -g
214 LD.Flags := $(OPTIMIZE_OPTION) -pg -g
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000215else
Reid Spencerd185c022006-11-11 00:00:31 +0000216 ifeq ($(ENABLE_OPTIMIZED),1)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000217 BuildMode := Release
Chris Lattnerdc5a8962006-07-27 18:19:51 +0000218 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
Reid Spencer34982d82005-01-02 17:43:20 +0000219 ifneq ($(OS),FreeBSD)
Chris Lattner040c1102006-05-24 18:34:08 +0000220 ifneq ($(OS),Darwin)
Reid Spencer34982d82005-01-02 17:43:20 +0000221 OmitFramePointer := -fomit-frame-pointer
222 endif
Chris Lattner040c1102006-05-24 18:34:08 +0000223 endif
Chris Lattnerdc5a8962006-07-27 18:19:51 +0000224
225 # Darwin requires -fstrict-aliasing to be explicitly enabled.
226 ifeq ($(OS),Darwin)
227 EXTRA_OPTIONS += -fstrict-aliasing
228 endif
229
Chris Lattner213a85b2006-05-24 23:02:40 +0000230 CXX.Flags := $(OPTIMIZE_OPTION) $(OmitFramePointer)
231 C.Flags := $(OPTIMIZE_OPTION) $(OmitFramePointer)
232 LD.Flags := $(OPTIMIZE_OPTION)
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000233 else
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000234 BuildMode := Debug
Chris Lattner98c79c32006-03-21 01:06:41 +0000235 CXX.Flags := -g
236 C.Flags := -g
Evan Cheng83c56aa2006-07-21 23:06:51 +0000237 LD.Flags := -g
Reid Spencerf206bd72004-10-22 21:01:56 +0000238 KEEP_SYMBOLS := 1
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000239 endif
240endif
241
Reid Spencer51e6f682006-08-25 19:54:53 +0000242# IF REQUIRES_EH=1 is specified then don't disable exceptions
Reid Spencer0b6396c2006-08-25 20:56:59 +0000243ifndef REQUIRES_EH
244 CXX.Flags += -fno-exceptions
245endif
Reid Spencer51e6f682006-08-25 19:54:53 +0000246
Reid Spencere6bc2062007-05-02 21:29:39 +0000247# IF REQUIRES_RTTI=1 is specified then don't disable run-time type id
248ifndef REQUIRES_RTTI
Reid Spencer700a0382007-05-02 21:31:09 +0000249# CXX.Flags += -fno-rtti
Reid Spencere6bc2062007-05-02 21:29:39 +0000250endif
251
Reid Spencer15b85092006-04-10 16:46:04 +0000252# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
253# then disable assertions by defining the appropriate preprocessor symbols.
Reid Spencerece13582006-04-09 23:41:14 +0000254ifdef DISABLE_ASSERTIONS
Reid Spencer056f0222006-04-07 16:06:18 +0000255 BuildMode := $(BuildMode)-Asserts
Chris Lattner98c79c32006-03-21 01:06:41 +0000256 CXX.Flags += -DNDEBUG
257 C.Flags += -DNDEBUG
Reid Spencerece13582006-04-09 23:41:14 +0000258else
259 CXX.Flags += -D_DEBUG
260 C.Flags += -D_DEBUG
Chris Lattner98c79c32006-03-21 01:06:41 +0000261endif
262
David Greene869e4b52007-06-29 03:36:21 +0000263# If ENABLE_EXPENSIVE_CHECKS=1 is specified (make command line or
264# configured), then enable expensive checks by defining the
265# appropriate preprocessor symbols.
David Greenecbc8ddf2007-06-28 19:36:08 +0000266ifdef ENABLE_EXPENSIVE_CHECKS
267 BuildMode := $(BuildMode)+Checks
268 CXX.Flags += -D_GLIBCXX_DEBUG
269endif
270
Reid Spencer05a1fe52006-12-16 22:07:52 +0000271ifeq ($(ENABLE_PIC),1)
272 CXX.Flags += -fPIC
273 C.Flags += -fPIC
274endif
275
Reid Spencere7141c82006-08-28 01:02:49 +0000276CXX.Flags += $(CXXFLAGS) -Woverloaded-virtual
Reid Spencer6f682b72006-03-22 15:59:55 +0000277C.Flags += $(CFLAGS)
David Greenecbc8ddf2007-06-28 19:36:08 +0000278CPP.Defines += $(CPPFLAGS)
279CPP.BaseFlags += $(CPP.Defines)
Reid Spencer6f682b72006-03-22 15:59:55 +0000280LD.Flags += $(LDFLAGS)
281AR.Flags := cru
Reid Spencerf88808a2004-10-30 09:19:36 +0000282LibTool.Flags := --tag=CXX
Reid Spencer81cd0492004-10-23 20:04:14 +0000283
Chris Lattnerdc5a8962006-07-27 18:19:51 +0000284# Make Floating point IEEE compliant on Alpha.
Andrew Lenharth9a98def2005-02-13 03:41:10 +0000285ifeq ($(ARCH),Alpha)
Reid Spencer05a1fe52006-12-16 22:07:52 +0000286 CXX.Flags += -mieee
287 CPP.BaseFlags += -mieee
288ifeq ($(ENABLE_PIC),0)
289 CXX.Flags += -fPIC
290 CPP.BaseFlags += -fPIC
291endif
Andrew Lenharth9a98def2005-02-13 03:41:10 +0000292endif
293
Andrew Lenharth0ad67b02007-01-26 13:34:50 +0000294ifeq ($(ARCH),Alpha)
295 LD.Flags += -Wl,--no-relax
296endif
297
Reid Spencer81cd0492004-10-23 20:04:14 +0000298#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000299# Directory locations
Reid Spencer81cd0492004-10-23 20:04:14 +0000300#--------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +0000301ObjDir := $(PROJ_OBJ_DIR)/$(BuildMode)
302LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
303ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
304ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000305LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer0dbf1012004-11-18 20:04:39 +0000306LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencerb9f8de62004-12-28 07:59:22 +0000307LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer2bba41c2004-12-22 05:57:21 +0000308CFERuntimeLibDir := $(LLVMGCCDIR)/lib
John Criswell3ef61af2003-06-30 21:59:07 +0000309
Reid Spencer81cd0492004-10-23 20:04:14 +0000310#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000311# Full Paths To Compiled Tools and Utilities
Reid Spencer81cd0492004-10-23 20:04:14 +0000312#--------------------------------------------------------------------
Reid Spencerb12e2902005-01-14 16:33:36 +0000313EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
314Echo = @$(EchoCmd)
Reid Spencerf88808a2004-10-30 09:19:36 +0000315ifndef LIBTOOL
Reid Spencerf206bd72004-10-22 21:01:56 +0000316LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencerf88808a2004-10-30 09:19:36 +0000317endif
318ifndef LLVMAS
319LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
320endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000321ifndef TBLGEN
Reid Spencer0aa9d002006-07-26 21:14:56 +0000322 ifeq ($(LLVM_CROSS_COMPILING),1)
323 TBLGEN := $(LLVMToolDir)/tblgen$(BUILD_EXEEXT)
324 else
325 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
326 endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000327endif
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000328LLVM_CONFIG := $(LLVMToolDir)/llvm-config
Reid Spencerb63d0c42007-02-09 15:52:07 +0000329ifndef LLVMLD
Reid Spencer7cec4f22007-02-09 17:09:14 +0000330LLVMLD := $(LLVMToolDir)/llvm-ld$(EXEEXT)
Reid Spencerf88808a2004-10-30 09:19:36 +0000331endif
Chris Lattner68c97542006-09-04 05:23:20 +0000332ifndef LLVMDIS
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000333LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
334endif
335ifndef LLI
336LLI := $(LLVMToolDir)/lli$(EXEEXT)
337endif
Alkis Evlogimenos24340582005-02-27 10:21:37 +0000338ifndef LLC
339LLC := $(LLVMToolDir)/llc$(EXEEXT)
340endif
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000341ifndef LOPT
Alkis Evlogimenos7c7705d2004-12-13 18:08:29 +0000342LOPT := $(LLVMToolDir)/opt$(EXEEXT)
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000343endif
Alkis Evlogimenos7c04a3d2005-02-02 00:40:15 +0000344ifndef LBUGPOINT
345LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
346endif
Reid Spencer9a6fc822006-12-03 21:01:45 +0000347ifndef LUPGRADE
348LUPGRADE := $(LLVMToolDir)/llvm-upgrade$(EXEEXT)
349endif
350ifeq ($(LLVMGCC_MAJVERS),3)
351UPGRADE_MSG = $(Echo) "Upgrading $(1) assembly to latest."
352UPGRADE_LL = $(Verb)$(LUPGRADE) $(1) -o $(1).up.tmp -f ; $(MV) $(1).up.tmp $(1)
Reid Spencerbef61c52006-12-10 04:56:38 +0000353LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
354LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
Reid Spencer9a6fc822006-12-03 21:01:45 +0000355else
356UPGRADE_MSG =
357UPGRADE_LL =
Reid Spencerbef61c52006-12-10 04:56:38 +0000358LLVMGCCWITHPATH := $(LLVMGCC)
359LLVMGXXWITHPATH := $(LLVMGXX)
Reid Spencer9a6fc822006-12-03 21:01:45 +0000360endif
361
Reid Spencer81cd0492004-10-23 20:04:14 +0000362#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000363# Adjust to user's request
Reid Spencer81cd0492004-10-23 20:04:14 +0000364#--------------------------------------------------------------------
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000365
Reid Spencer87e645c2005-01-11 04:31:07 +0000366# Adjust LD.Flags and Libtool.Flags depending on the kind of library that is
367# to be built. Note that if LOADABLE_MODULE is specified then the resulting
Reid Spencere6458c32006-08-07 23:12:15 +0000368# shared library can be opened with dlopen. Also, LOADABLE_MODULE implies
369# several other things so we force them to be defined/on.
370ifdef LOADABLE_MODULE
371 SHARED_LIBRARY := 1
372 DONT_BUILD_RELINKED := 1
373 LINK_LIBS_IN_SHARED := 1
374 LD.Flags += -module
375endif
376
Reid Spencer87e645c2005-01-11 04:31:07 +0000377ifdef SHARED_LIBRARY
Reid Spencerf88808a2004-10-30 09:19:36 +0000378 LD.Flags += -rpath $(LibDir)
Reid Spencer87e645c2005-01-11 04:31:07 +0000379else
380 LibTool.Flags += --tag=disable-shared
John Criswell3601f372003-07-31 20:58:51 +0000381endif
382
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000383ifdef TOOL_VERBOSE
384 C.Flags += -v
385 CXX.Flags += -v
386 LD.Flags += -v
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000387 VERBOSE := 1
388endif
389
Reid Spencer81cd0492004-10-23 20:04:14 +0000390# Adjust settings for verbose mode
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000391ifndef VERBOSE
Reid Spencerf88808a2004-10-30 09:19:36 +0000392 Verb := @
393 LibTool.Flags += --silent
394 AR.Flags += >/dev/null 2>/dev/null
Reid Spencerba6a3db2005-01-16 02:20:54 +0000395 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
Reid Spencer100080c2004-10-25 08:27:37 +0000396else
Reid Spencerf88808a2004-10-30 09:19:36 +0000397 ConfigureScriptFLAGS :=
Misha Brukman1326a7c2002-09-12 16:05:39 +0000398endif
399
Vikram S. Adved141c282002-09-18 11:55:13 +0000400# By default, strip symbol information from executable
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000401ifndef KEEP_SYMBOLS
Reid Spencerf88808a2004-10-30 09:19:36 +0000402 Strip := $(PLATFORMSTRIPOPTS)
403 StripWarnMsg := "(without symbols)"
Reid Spencer247a10e2005-02-24 07:12:43 +0000404 Install.StripFlag += -s
Vikram S. Adved141c282002-09-18 11:55:13 +0000405endif
406
Reid Spencer81cd0492004-10-23 20:04:14 +0000407# Adjust linker flags for building an executable
Reid Spencerf206bd72004-10-22 21:01:56 +0000408ifdef TOOLNAME
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000409ifdef EXAMPLE_TOOL
410 LD.Flags += -rpath $(ExmplDir) -export-dynamic
411else
Reid Spencerf88808a2004-10-30 09:19:36 +0000412 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000413endif
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000414endif
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000415
Reid Spencer81cd0492004-10-23 20:04:14 +0000416#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000417# Options To Invoke Tools
Reid Spencer81cd0492004-10-23 20:04:14 +0000418#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000419
Reid Spencerde46e482006-11-02 20:25:50 +0000420CompileCommonOpts := -pedantic -Wall -W -Wwrite-strings -Wno-long-long \
421 -Wunused -Wno-unused-parameter $(EXTRA_OPTIONS)
Reid Spencerf206bd72004-10-22 21:01:56 +0000422
Duraid Madina60c9a3c2005-05-16 06:38:09 +0000423ifeq ($(OS),HP-UX)
Duraid Madina1f898af2006-02-15 03:20:16 +0000424 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
Duraid Madina60c9a3c2005-05-16 06:38:09 +0000425endif
426
Chris Lattner11c25cf2006-05-30 16:38:06 +0000427# If we are building a universal binary on Mac OS/X, pass extra options. This
428# is useful to people that want to link the LLVM libraries into their universal
Chris Lattner65e28b32006-06-29 19:38:04 +0000429# apps.
430#
431# The following can be optionally specified:
432# UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
433# For Mac OS/X 10.4 Intel machines, the traditional one is:
434# UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
435# UNIVERSAL_ARCH can be optionally specified to be a list of architectures
436# to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
437# i386/ppc only.
Chris Lattnerd81eba52006-04-06 06:30:15 +0000438ifdef UNIVERSAL
Chris Lattner65e28b32006-06-29 19:38:04 +0000439 ifndef UNIVERSAL_ARCH
440 UNIVERSAL_ARCH := i386 ppc
441 endif
442 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
443 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
444 Relink.Flags := $(UNIVERSAL_ARCH_OPTIONS:%=-XCClinker %)
Chris Lattner64e85f32006-06-16 21:47:59 +0000445 ifdef UNIVERSAL_SDK_PATH
446 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
447 Relink.Flags += -XCClinker -isysroot -XCClinker $(UNIVERSAL_SDK_PATH)
448 endif
449
450 # Building universal cannot compute dependencies automatically.
Chris Lattnerd81eba52006-04-06 06:30:15 +0000451 DISABLE_AUTO_DEPENDENCIES=1
452endif
453
Reid Spencer6f682b72006-03-22 15:59:55 +0000454LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
455CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
456# All -I flags should go here, so that they don't confuse llvm-config.
457CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
458 -I$(PROJ_OBJ_ROOT)/include \
459 -I$(PROJ_SRC_ROOT)/include \
460 -I$(LLVM_OBJ_ROOT)/include \
461 -I$(LLVM_SRC_ROOT)/include \
462 $(CPP.BaseFlags)
Reid Spencerf206bd72004-10-22 21:01:56 +0000463
Chris Lattner008b2de2006-09-29 18:47:13 +0000464Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -c
Reid Spencerf88808a2004-10-30 09:19:36 +0000465LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
Chris Lattner008b2de2006-09-29 18:47:13 +0000466BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts)
467Preprocess.C = $(CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -E
Chris Lattnerbb087952005-10-05 00:28:41 +0000468
Chris Lattner008b2de2006-09-29 18:47:13 +0000469Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) -c
Reid Spencerf88808a2004-10-30 09:19:36 +0000470LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
Chris Lattner008b2de2006-09-29 18:47:13 +0000471BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CXX.Flags) \
472 $(CompileCommonOpts)
473
Chris Lattnerbb087952005-10-05 00:28:41 +0000474Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
Reid Spencere6458c32006-08-07 23:12:15 +0000475Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
476 $(LD.Flags) $(Strip)
477LTLink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(Link)
478Relink = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
479 $(Relink.Flags)
480LTRelink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(Relink)
Reid Spencerfe0a01e2005-02-16 16:13:02 +0000481LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
482 $(Install.Flags)
Reid Spencer247a10e2005-02-24 07:12:43 +0000483ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
Reid Spencer6f682b72006-03-22 15:59:55 +0000484ScriptInstall = $(INSTALL) -m 0755
Reid Spencer247a10e2005-02-24 07:12:43 +0000485DataInstall = $(INSTALL) -m 0644
Vladimir Prus788db2c2006-05-16 06:39:36 +0000486TableGen = $(TBLGEN) -I $(PROJ_SRC_DIR) -I$(PROJ_SRC_ROOT)/include \
487 -I $(PROJ_SRC_ROOT)/lib/Target
Reid Spencerf88808a2004-10-30 09:19:36 +0000488Archive = $(AR) $(AR.Flags)
Reid Spencer32f7e422004-12-02 09:28:21 +0000489LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencerf206bd72004-10-22 21:01:56 +0000490ifdef RANLIB
Reid Spencer81cd0492004-10-23 20:04:14 +0000491Ranlib = $(RANLIB)
Reid Spencerf206bd72004-10-22 21:01:56 +0000492else
Reid Spencer81cd0492004-10-23 20:04:14 +0000493Ranlib = ranlib
John Criswell3ef61af2003-06-30 21:59:07 +0000494endif
495
Chris Lattner2f7c9632001-06-06 20:29:01 +0000496#----------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +0000497# Get the list of source files and compute object file
498# names from them.
Reid Spencer81cd0492004-10-23 20:04:14 +0000499#----------------------------------------------------------
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000500
501ifndef SOURCES
502 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
503 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
504 $(PROJ_SRC_DIR)/*.l))
Reid Spencerf88808a2004-10-30 09:19:36 +0000505else
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000506 Sources := $(SOURCES)
507endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000508
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000509ifdef BUILT_SOURCES
510Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Reid Spencer81546582004-12-04 22:34:09 +0000511endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000512
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000513BaseNameSources := $(sort $(basename $(Sources)))
514
515ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
516ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
517ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
518
Reid Spencer81cd0492004-10-23 20:04:14 +0000519###############################################################################
520# DIRECTORIES: Handle recursive descent of directory structure
521###############################################################################
John Criswell3601f372003-07-31 20:58:51 +0000522
Chris Lattner2f7c9632001-06-06 20:29:01 +0000523#---------------------------------------------------------
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000524# Provide rules to make install dirs. This must be early
525# in the file so they get built before dependencies
526#---------------------------------------------------------
527
Reid Spencer90b689d2005-05-19 20:26:14 +0000528$(PROJ_bindir): $(PROJ_bindir)/.dir
529$(PROJ_libdir): $(PROJ_libdir)/.dir
530$(PROJ_includedir): $(PROJ_includedir)/.dir
531$(PROJ_etcdir): $(PROJ_etcdir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000532
Reid Spencerf88808a2004-10-30 09:19:36 +0000533# To create other directories, as needed, and timestamp their creation
534%/.dir:
535 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfc66af42004-11-29 05:00:33 +0000536 $(Verb) $(DATE) > $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000537
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000538.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
539.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000540
541#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000542# Handle the DIRS options for sequential construction
Chris Lattner2f7c9632001-06-06 20:29:01 +0000543#---------------------------------------------------------
544
Reid Spencerf88808a2004-10-30 09:19:36 +0000545SubDirs :=
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000546ifdef DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000547SubDirs += $(DIRS)
Chris Lattnerb9259612006-07-26 20:22:26 +0000548
549ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencerf88808a2004-10-30 09:19:36 +0000550$(RecursiveTargets)::
551 $(Verb) for dir in $(DIRS); do \
Reid Spencerf206bd72004-10-22 21:01:56 +0000552 if [ ! -f $$dir/Makefile ]; then \
553 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000554 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000555 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000556 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattner539a23c2002-09-17 23:35:02 +0000557 done
Chris Lattnerb9259612006-07-26 20:22:26 +0000558else
559$(RecursiveTargets)::
560 $(Verb) for dir in $(DIRS); do \
561 ($(MAKE) -C $$dir $@ ) || exit 1; \
562 done
563endif
564
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000565endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000566
Reid Spencer81cd0492004-10-23 20:04:14 +0000567#---------------------------------------------------------
568# Handle the EXPERIMENTAL_DIRS options ensuring success
569# after each directory is built.
570#---------------------------------------------------------
571ifdef EXPERIMENTAL_DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000572$(RecursiveTargets)::
573 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer81cd0492004-10-23 20:04:14 +0000574 if [ ! -f $$dir/Makefile ]; then \
575 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000576 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000577 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000578 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000579 done
580endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000581
Reid Spencerc49a8632005-12-21 23:17:06 +0000582#-----------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000583# Handle the PARALLEL_DIRS options for parallel construction
Reid Spencerc49a8632005-12-21 23:17:06 +0000584#-----------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000585ifdef PARALLEL_DIRS
586
Reid Spencerf88808a2004-10-30 09:19:36 +0000587SubDirs += $(PARALLEL_DIRS)
588
Reid Spencerd4bd3752004-12-03 20:08:48 +0000589# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencerf88808a2004-10-30 09:19:36 +0000590all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
591clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000592clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencerf88808a2004-10-30 09:19:36 +0000593install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000594uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencerd4bd3752004-12-03 20:08:48 +0000595install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000596
Reid Spencer81546582004-12-04 22:34:09 +0000597ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer81cd0492004-10-23 20:04:14 +0000598
Reid Spencer81546582004-12-04 22:34:09 +0000599$(ParallelTargets) :
Reid Spencerf88808a2004-10-30 09:19:36 +0000600 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencerf206bd72004-10-22 21:01:56 +0000601 $(MKDIR) $(@D); \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000602 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswell6df35dd2003-11-25 19:32:22 +0000603 fi; \
Reid Spencer960cf7c2007-02-07 03:29:29 +0000604 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000605endif
606
Reid Spencer81cd0492004-10-23 20:04:14 +0000607#---------------------------------------------------------
608# Handle the OPTIONAL_DIRS options for directores that may
609# or may not exist.
610#---------------------------------------------------------
John Criswell8224df92003-06-27 16:58:44 +0000611ifdef OPTIONAL_DIRS
Reid Spencer100080c2004-10-25 08:27:37 +0000612
Reid Spencerf88808a2004-10-30 09:19:36 +0000613SubDirs += $(OPTIONAL_DIRS)
Reid Spencer100080c2004-10-25 08:27:37 +0000614
Chris Lattnerb9259612006-07-26 20:22:26 +0000615ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencerf88808a2004-10-30 09:19:36 +0000616$(RecursiveTargets)::
617 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000618 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
Reid Spencerf206bd72004-10-22 21:01:56 +0000619 if [ ! -f $$dir/Makefile ]; then \
620 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000621 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000622 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000623 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000624 fi \
John Criswell8224df92003-06-27 16:58:44 +0000625 done
Chris Lattnerb9259612006-07-26 20:22:26 +0000626else
627$(RecursiveTargets)::
628 $(Verb) for dir in $(OPTIONAL_DIRS); do \
629 ($(MAKE) -C$$dir $@ ) || exit 1; \
630 done
631endif
John Criswell8224df92003-06-27 16:58:44 +0000632endif
633
Reid Spencercc51e7b2004-08-20 09:20:05 +0000634#---------------------------------------------------------
635# Handle the CONFIG_FILES options
636#---------------------------------------------------------
637ifdef CONFIG_FILES
Reid Spencercc51e7b2004-08-20 09:20:05 +0000638
Reid Spencera79819d2007-02-06 18:53:14 +0000639ifdef NO_INSTALL
640install-local::
641 $(Echo) Install circumvented with NO_INSTALL
642uninstall-local::
643 $(Echo) UnInstall circumvented with NO_INSTALL
644else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000645install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
646 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000647 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000648 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
Reid Spencerc43b1d42005-02-24 03:56:32 +0000649 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000650 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
Reid Spencerc43b1d42005-02-24 03:56:32 +0000651 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer39d6a612004-11-23 05:59:53 +0000652 else \
653 $(ECHO) Error: cannot find config file $${file}. ; \
654 fi \
Reid Spencercc51e7b2004-08-20 09:20:05 +0000655 done
Reid Spencer81cd0492004-10-23 20:04:14 +0000656
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000657uninstall-local::
Reid Spencerba6a3db2005-01-16 02:20:54 +0000658 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000659 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000660 $(RM) -f $(PROJ_etcdir)/$${file} ; \
Reid Spencer12a3a052004-10-24 07:53:21 +0000661 done
Reid Spencera79819d2007-02-06 18:53:14 +0000662endif
Reid Spencer12a3a052004-10-24 07:53:21 +0000663
Reid Spencercc51e7b2004-08-20 09:20:05 +0000664endif
665
Reid Spencer81cd0492004-10-23 20:04:14 +0000666###############################################################################
Reid Spencera80f1672005-05-19 00:37:31 +0000667# Set up variables for building libararies
668###############################################################################
669
670#---------------------------------------------------------
Reid Spencera80f1672005-05-19 00:37:31 +0000671# Define various command line options pertaining to the
672# libraries needed when linking. There are "Proj" libs
673# (defined by the user's project) and "LLVM" libs (defined
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000674# by the LLVM project).
Reid Spencera80f1672005-05-19 00:37:31 +0000675#---------------------------------------------------------
Andrew Lenharth6b62b472005-08-13 05:09:50 +0000676
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000677ifdef USEDLIBS
Reid Spencera80f1672005-05-19 00:37:31 +0000678ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
679ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000680ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
681ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
682endif
683
684ifdef LLVMLIBS
Reid Spencera80f1672005-05-19 00:37:31 +0000685LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
686LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
Reid Spencera80f1672005-05-19 00:37:31 +0000687LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
Reid Spencera80f1672005-05-19 00:37:31 +0000688LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000689endif
690
Chris Lattner68c97542006-09-04 05:23:20 +0000691ifeq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000692ifdef LINK_COMPONENTS
Chris Lattner68c97542006-09-04 05:23:20 +0000693
694# If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
695# clean in tools, then do a make in tools (instead of at the top level).
696$(LLVM_CONFIG):
697 @echo "*** llvm-config doesn't exist - rebuilding it."
698 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
699
700$(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
701
Reid Spencer1e86e652007-02-04 22:12:25 +0000702ProjLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
703ProjLibsPaths += $(LLVM_CONFIG) \
Chris Lattnera5d27b12006-09-04 06:39:52 +0000704 $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000705endif
Chris Lattner9a4a92e2006-09-04 04:50:10 +0000706endif
Reid Spencera80f1672005-05-19 00:37:31 +0000707
708###############################################################################
Reid Spencer81cd0492004-10-23 20:04:14 +0000709# Library Build Rules: Four ways to build a library
710###############################################################################
Chris Lattner2f7c9632001-06-06 20:29:01 +0000711
Reid Spencerd78077d2004-12-05 05:17:22 +0000712#---------------------------------------------------------
713# Bytecode Module Targets:
714# If the user set MODULE_NAME then they want to build a
715# bytecode module from the sources. We compile all the
716# sources and link it together into a single bytecode
717# module.
718#---------------------------------------------------------
719
720ifdef MODULE_NAME
Reid Spencere9fa5442005-02-14 21:54:08 +0000721ifeq ($(strip $(LLVMGCC)),)
Reid Spencer83745dd2005-05-13 18:32:54 +0000722$(warning Modules require llvm-gcc but no llvm-gcc is available ****)
Reid Spencere9fa5442005-02-14 21:54:08 +0000723else
Reid Spencerd78077d2004-12-05 05:17:22 +0000724
725Module := $(LibDir)/$(MODULE_NAME).bc
Reid Spencerb63d0c42007-02-09 15:52:07 +0000726LinkModule := $(LLVMLD) -L$(CFERuntimeLibDir)
Reid Spencer78ede562006-04-12 18:21:35 +0000727
Reid Spencerd78077d2004-12-05 05:17:22 +0000728
729ifdef EXPORTED_SYMBOL_FILE
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000730LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencerd78077d2004-12-05 05:17:22 +0000731endif
732
Reid Spencerb63d0c42007-02-09 15:52:07 +0000733$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(LLVMLD)
Reid Spencer83745dd2005-05-13 18:32:54 +0000734 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
Reid Spencerd78077d2004-12-05 05:17:22 +0000735 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
736
737all-local:: $(Module)
738
739clean-local::
740ifneq ($(strip $(Module)),)
741 -$(Verb) $(RM) -f $(Module)
742endif
743
Reid Spencerefe3a822004-12-13 07:38:07 +0000744ifdef BYTECODE_DESTINATION
745ModuleDestDir := $(BYTECODE_DESTINATION)
746else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000747ModuleDestDir := $(PROJ_libdir)
Reid Spencerefe3a822004-12-13 07:38:07 +0000748endif
Reid Spencerd78077d2004-12-05 05:17:22 +0000749
Reid Spencera79819d2007-02-06 18:53:14 +0000750ifdef NO_INSTALL
751install-local::
752 $(Echo) Install circumvented with NO_INSTALL
753uninstall-local::
754 $(Echo) Uninstall circumvented with NO_INSTALL
755else
Reid Spencerefe3a822004-12-13 07:38:07 +0000756DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
757
758install-module:: $(DestModule)
Reid Spencerd78077d2004-12-05 05:17:22 +0000759install-local:: $(DestModule)
760
Reid Spencerefe3a822004-12-13 07:38:07 +0000761$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencerd78077d2004-12-05 05:17:22 +0000762 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
Reid Spencerd77a4c02005-02-24 21:30:37 +0000763 $(Verb) $(DataInstall) $(Module) $(DestModule)
Reid Spencerd78077d2004-12-05 05:17:22 +0000764
765uninstall-local::
766 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
767 -$(Verb) $(RM) -f $(DestModule)
Reid Spencera79819d2007-02-06 18:53:14 +0000768endif
Reid Spencerd78077d2004-12-05 05:17:22 +0000769
770endif
Reid Spencere9fa5442005-02-14 21:54:08 +0000771endif
Brian Gaekeecc92bf2004-01-22 22:53:48 +0000772
Reid Spencer81cd0492004-10-23 20:04:14 +0000773# if we're building a library ...
Chris Lattner2f7c9632001-06-06 20:29:01 +0000774ifdef LIBRARYNAME
Vikram S. Advefe346892001-07-15 13:16:47 +0000775
Chris Lattner0100eab2002-09-16 22:36:42 +0000776# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000777LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencer87e645c2005-01-11 04:31:07 +0000778ifdef LOADABLE_MODULE
779LibName.LA := $(LibDir)/$(LIBRARYNAME).la
780else
Reid Spencerf88808a2004-10-30 09:19:36 +0000781LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
Reid Spencer87e645c2005-01-11 04:31:07 +0000782endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000783LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
784LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer32f7e422004-12-02 09:28:21 +0000785LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000786
Reid Spencer81cd0492004-10-23 20:04:14 +0000787#---------------------------------------------------------
788# Shared Library Targets:
789# If the user asked for a shared library to be built
790# with the SHARED_LIBRARY variable, then we provide
791# targets for building them.
792#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000793ifdef SHARED_LIBRARY
794
Reid Spencerf88808a2004-10-30 09:19:36 +0000795all-local:: $(LibName.LA)
Reid Spencerf206bd72004-10-22 21:01:56 +0000796
Reid Spencera80f1672005-05-19 00:37:31 +0000797ifdef LINK_LIBS_IN_SHARED
Reid Spencere6458c32006-08-07 23:12:15 +0000798ifdef LOADABLE_MODULE
Chris Lattner7cab3de2006-11-15 21:04:15 +0000799SharedLibKindMessage := "Loadable Module"
Reid Spencere6458c32006-08-07 23:12:15 +0000800else
801SharedLibKindMessage := "Shared Library"
802endif
Reid Spencera80f1672005-05-19 00:37:31 +0000803$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
Reid Spencere6458c32006-08-07 23:12:15 +0000804 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
805 $(LIBRARYNAME)$(SHLIBEXT)
806 $(Verb) $(LTLink) -o $@ $(ObjectsLO) $(ProjLibsOptions) \
807 $(LLVMLibsOptions)
Reid Spencera80f1672005-05-19 00:37:31 +0000808 $(Verb) $(LTInstall) $@ $(LibDir)
809else
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000810$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000811 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencere6458c32006-08-07 23:12:15 +0000812 $(Verb) $(LTLink) -o $@ $(ObjectsLO)
Reid Spencerf88808a2004-10-30 09:19:36 +0000813 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencera80f1672005-05-19 00:37:31 +0000814endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000815
816clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000817ifneq ($(strip $(LibName.LA)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000818 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000819endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000820
Reid Spencera79819d2007-02-06 18:53:14 +0000821ifdef NO_INSTALL
822install-local::
823 $(Echo) Install circumvented with NO_INSTALL
824uninstall-local::
825 $(Echo) Uninstall circumvented with NO_INSTALL
826else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000827DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf206bd72004-10-22 21:01:56 +0000828
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000829install-local:: $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000830
Reid Spencerba6a3db2005-01-16 02:20:54 +0000831$(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000832 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000833 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000834 $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
Reid Spencer12a3a052004-10-24 07:53:21 +0000835
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000836uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000837 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000838 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
Reid Spencera79819d2007-02-06 18:53:14 +0000839endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000840endif
841
Reid Spencer81cd0492004-10-23 20:04:14 +0000842#---------------------------------------------------------
843# Bytecode Library Targets:
844# If the user asked for a bytecode library to be built
845# with the BYTECODE_LIBRARY variable, then we provide
846# targets for building them.
847#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000848ifdef BYTECODE_LIBRARY
Reid Spencere9fa5442005-02-14 21:54:08 +0000849ifeq ($(strip $(LLVMGCC)),)
Reid Spencer83745dd2005-05-13 18:32:54 +0000850$(warning Bytecode libraries require llvm-gcc which could not be found ****)
Reid Spencere9fa5442005-02-14 21:54:08 +0000851else
Reid Spencerf206bd72004-10-22 21:01:56 +0000852
Reid Spencer32f7e422004-12-02 09:28:21 +0000853all-local:: $(LibName.BCA)
854
855ifdef EXPORTED_SYMBOL_FILE
Reid Spencerb63d0c42007-02-09 15:52:07 +0000856BCLinkLib = $(LLVMLD) -L$(CFERuntimeLibDir) \
Chris Lattner11c25cf2006-05-30 16:38:06 +0000857 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer32f7e422004-12-02 09:28:21 +0000858
Reid Spencerb63d0c42007-02-09 15:52:07 +0000859$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(LLVMLD) \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +0000860 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +0000861 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
862 "(internalize)"
Chris Lattnere3d98f12004-12-02 21:23:43 +0000863 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencer85d55ad2004-12-13 03:59:35 +0000864 $(Verb) $(RM) -f $@
Reid Spencer32f7e422004-12-02 09:28:21 +0000865 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencerf206bd72004-10-22 21:01:56 +0000866else
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000867$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +0000868 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +0000869 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencer85d55ad2004-12-13 03:59:35 +0000870 $(Verb) $(RM) -f $@
Reid Spencer32f7e422004-12-02 09:28:21 +0000871 $(Verb) $(LArchive) $@ $(ObjectsBC)
872
Reid Spencerf206bd72004-10-22 21:01:56 +0000873endif
874
Reid Spencer81cd0492004-10-23 20:04:14 +0000875clean-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000876ifneq ($(strip $(LibName.BCA)),)
877 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000878endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000879
Reid Spencer65086be2004-12-13 07:28:21 +0000880ifdef BYTECODE_DESTINATION
881BytecodeDestDir := $(BYTECODE_DESTINATION)
882else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000883BytecodeDestDir := $(PROJ_libdir)
Reid Spencer65086be2004-12-13 07:28:21 +0000884endif
885
886DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
Reid Spencer32f7e422004-12-02 09:28:21 +0000887
Reid Spencerd4bd3752004-12-03 20:08:48 +0000888install-bytecode-local:: $(DestBytecodeLib)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000889
Reid Spencera79819d2007-02-06 18:53:14 +0000890ifdef NO_INSTALL
891install-local::
892 $(Echo) Install circumvented with NO_INSTALL
893uninstall-local::
894 $(Echo) Uninstall circumvented with NO_INSTALL
895else
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000896install-local:: $(DestBytecodeLib)
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000897
Reid Spencer65086be2004-12-13 07:28:21 +0000898$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
Reid Spencer32f7e422004-12-02 09:28:21 +0000899 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerdcc53752005-02-24 21:36:32 +0000900 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000901
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000902uninstall-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000903 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000904 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencera79819d2007-02-06 18:53:14 +0000905endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000906endif
Reid Spencere9fa5442005-02-14 21:54:08 +0000907endif
Vikram S. Adve15bd3ad2002-08-02 18:34:12 +0000908
Reid Spencerf88808a2004-10-30 09:19:36 +0000909#---------------------------------------------------------
910# ReLinked Library Targets:
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000911# If the user explicitly requests a relinked library with
912# BUILD_RELINKED, provide it. Otherwise, if they specify
913# neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
914# them one.
Reid Spencerf88808a2004-10-30 09:19:36 +0000915#---------------------------------------------------------
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000916ifndef BUILD_ARCHIVE
Chris Lattner76d98ba2002-07-23 17:56:16 +0000917ifndef DONT_BUILD_RELINKED
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000918BUILD_RELINKED = 1
919endif
920endif
921
922ifdef BUILD_RELINKED
Reid Spencerf206bd72004-10-22 21:01:56 +0000923
Reid Spencerf88808a2004-10-30 09:19:36 +0000924all-local:: $(LibName.O)
925
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000926$(LibName.O): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000927 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencere6458c32006-08-07 23:12:15 +0000928 $(Verb) $(LTRelink) -o $@ $(ObjectsO)
Reid Spencerf206bd72004-10-22 21:01:56 +0000929
Reid Spencer81cd0492004-10-23 20:04:14 +0000930clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000931ifneq ($(strip $(LibName.O)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000932 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencer12a3a052004-10-24 07:53:21 +0000933endif
934
Reid Spencera79819d2007-02-06 18:53:14 +0000935ifdef NO_INSTALL
936install-local::
937 $(Echo) Install circumvented with NO_INSTALL
938uninstall-local::
939 $(Echo) Uninstall circumvented with NO_INSTALL
940else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000941DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
Reid Spencer12a3a052004-10-24 07:53:21 +0000942
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000943install-local:: $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000944
Reid Spencerba6a3db2005-01-16 02:20:54 +0000945$(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000946 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000947 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000948
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000949uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000950 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000951 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencera79819d2007-02-06 18:53:14 +0000952endif
Chris Lattner76d98ba2002-07-23 17:56:16 +0000953endif
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000954
Reid Spencerf88808a2004-10-30 09:19:36 +0000955#---------------------------------------------------------
956# Archive Library Targets:
957# If the user wanted a regular archive library built,
958# then we provide targets for building them.
959#---------------------------------------------------------
Chris Lattner76d98ba2002-07-23 17:56:16 +0000960ifdef BUILD_ARCHIVE
Chris Lattner76d98ba2002-07-23 17:56:16 +0000961
Reid Spencerf88808a2004-10-30 09:19:36 +0000962all-local:: $(LibName.A)
963
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000964$(LibName.A): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000965 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000966 -$(Verb) $(RM) -f $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000967 $(Verb) $(Archive) $@ $(ObjectsO)
968 $(Verb) $(Ranlib) $@
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000969
Reid Spencer81cd0492004-10-23 20:04:14 +0000970clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000971ifneq ($(strip $(LibName.A)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000972 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000973endif
974
Reid Spencera79819d2007-02-06 18:53:14 +0000975ifdef NO_INSTALL
976install-local::
977 $(Echo) Install circumvented with NO_INSTALL
978uninstall-local::
979 $(Echo) Uninstall circumvented with NO_INSTALL
980else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000981DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
Reid Spencer12a3a052004-10-24 07:53:21 +0000982
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000983install-local:: $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000984
Reid Spencerba6a3db2005-01-16 02:20:54 +0000985$(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000986 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000987 $(Verb) $(MKDIR) $(PROJ_libdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000988 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000989
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000990uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000991 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000992 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencera79819d2007-02-06 18:53:14 +0000993endif
Reid Spencer12a3a052004-10-24 07:53:21 +0000994endif
995
996# endif LIBRARYNAME
Reid Spencerf206bd72004-10-22 21:01:56 +0000997endif
998
Reid Spencerdcba7782004-10-24 08:21:04 +0000999###############################################################################
1000# Tool Build Rules: Build executable tool based on TOOLNAME option
1001###############################################################################
1002
Chris Lattner07c7c192001-09-07 22:57:58 +00001003ifdef TOOLNAME
1004
Reid Spencerf88808a2004-10-30 09:19:36 +00001005#---------------------------------------------------------
1006# Set up variables for building a tool.
1007#---------------------------------------------------------
Reid Spencer7e9e0b02004-11-18 10:03:46 +00001008ifdef EXAMPLE_TOOL
Reid Spencer98a2d982005-05-19 21:03:11 +00001009ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +00001010else
Reid Spencer98a2d982005-05-19 21:03:11 +00001011ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +00001012endif
Chris Lattner07c7c192001-09-07 22:57:58 +00001013
Reid Spencerf88808a2004-10-30 09:19:36 +00001014#---------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +00001015# Provide targets for building the tools
1016#---------------------------------------------------------
1017all-local:: $(ToolBuildPath)
John Criswell8224df92003-06-27 16:58:44 +00001018
Reid Spencer81cd0492004-10-23 20:04:14 +00001019clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001020ifneq ($(strip $(ToolBuildPath)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001021 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencer12a3a052004-10-24 07:53:21 +00001022endif
Chris Lattner07c7c192001-09-07 22:57:58 +00001023
Reid Spencer7e9e0b02004-11-18 10:03:46 +00001024ifdef EXAMPLE_TOOL
1025$(ToolBuildPath): $(ExmplDir)/.dir
1026else
1027$(ToolBuildPath): $(ToolDir)/.dir
1028endif
1029
Chris Lattnera5d27b12006-09-04 06:39:52 +00001030$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001031 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencere6458c32006-08-07 23:12:15 +00001032 $(Verb) $(LTLink) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
Reid Spencer10536582006-05-16 06:25:14 +00001033 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001034 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1035 $(StripWarnMsg)
Reid Spencer12a3a052004-10-24 07:53:21 +00001036
Reid Spencera79819d2007-02-06 18:53:14 +00001037ifdef NO_INSTALL
1038install-local::
1039 $(Echo) Install circumvented with NO_INSTALL
1040uninstall-local::
1041 $(Echo) Uninstall circumvented with NO_INSTALL
1042else
Reid Spencerba6a3db2005-01-16 02:20:54 +00001043DestTool = $(PROJ_bindir)/$(TOOLNAME)
Reid Spencer12a3a052004-10-24 07:53:21 +00001044
Reid Spencerbe6a4e92004-10-28 07:57:28 +00001045install-local:: $(DestTool)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001046
Reid Spencerba6a3db2005-01-16 02:20:54 +00001047$(DestTool): $(PROJ_bindir) $(ToolBuildPath)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001048 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencerc43b1d42005-02-24 03:56:32 +00001049 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +00001050
Reid Spencerbe6a4e92004-10-28 07:57:28 +00001051uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001052 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001053 -$(Verb) $(RM) -f $(DestTool)
Reid Spencera79819d2007-02-06 18:53:14 +00001054endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001055endif
Chris Lattner07c7c192001-09-07 22:57:58 +00001056
Reid Spencerf88808a2004-10-30 09:19:36 +00001057###############################################################################
1058# Object Build Rules: Build object files based on sources
1059###############################################################################
1060
Duraid Madinacbbc1842006-02-15 03:23:26 +00001061# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1062ifeq ($(OS),HP-UX)
1063 DISABLE_AUTO_DEPENDENCIES=1
1064endif
1065
Chris Lattner085c7152006-06-21 20:58:03 +00001066ifdef SHARED_LIBRARY
1067PIC_FLAG = "(PIC)"
1068MAYBE_PIC_Compile.CXX = $(LTCompile.CXX)
1069MAYBE_PIC_Compile.C = $(LTCompile.C)
1070else
1071MAYBE_PIC_Compile.CXX = $(Compile.CXX)
1072MAYBE_PIC_Compile.C = $(Compile.C)
1073endif
1074
Reid Spencerf88808a2004-10-30 09:19:36 +00001075# Provide rule sets for when dependency generation is enabled
Reid Spencerf206bd72004-10-22 21:01:56 +00001076ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve20aa62f2002-09-20 14:03:13 +00001077
Reid Spencerf88808a2004-10-30 09:19:36 +00001078#---------------------------------------------------------
1079# Create .lo files in the ObjDir directory from the .cpp and .c files...
1080#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001081
Chris Lattner2a023902004-12-16 17:28:50 +00001082$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001083 $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
1084 $(Verb) if $(MAYBE_PIC_Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
1085 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
1086 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +00001087
Chris Lattnerf60c1702005-02-04 21:28:50 +00001088$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001089 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1090 $(Verb) if $(MAYBE_PIC_Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
Chris Lattnerf60c1702005-02-04 21:28:50 +00001091 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
1092 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
1093
Chris Lattner2a023902004-12-16 17:28:50 +00001094$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001095 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1096 $(Verb) if $(MAYBE_PIC_Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001097 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
1098 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +00001099
Reid Spencerf88808a2004-10-30 09:19:36 +00001100#---------------------------------------------------------
Chris Lattnerf60c1702005-02-04 21:28:50 +00001101# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
Reid Spencerf88808a2004-10-30 09:19:36 +00001102#---------------------------------------------------------
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001103
Reid Spencer96edbd52006-12-30 16:31:02 +00001104$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001105 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001106 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1107 $< -o $@ -S -emit-llvm ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001108 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1109 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencer9a6fc822006-12-03 21:01:45 +00001110 $(call UPGRADE_MSG,$@)
1111 $(call UPGRADE_LL,$@)
Reid Spencerf206bd72004-10-22 21:01:56 +00001112
Reid Spencer96edbd52006-12-30 16:31:02 +00001113$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001114 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001115 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1116 $< -o $@ -S -emit-llvm ; \
Chris Lattnerf60c1702005-02-04 21:28:50 +00001117 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1118 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencer9a6fc822006-12-03 21:01:45 +00001119 $(call UPGRADE_MSG,$@)
1120 $(call UPGRADE_LL,$@)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001121
Reid Spencer96edbd52006-12-30 16:31:02 +00001122$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001123 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001124 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" \
1125 $< -o $@ -S -emit-llvm ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001126 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1127 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencer9a6fc822006-12-03 21:01:45 +00001128 $(call UPGRADE_MSG,$@)
1129 $(call UPGRADE_LL,$@)
Reid Spencerf206bd72004-10-22 21:01:56 +00001130
Reid Spencerf88808a2004-10-30 09:19:36 +00001131# Provide alternate rule sets if dependencies are disabled
Reid Spencerf206bd72004-10-22 21:01:56 +00001132else
1133
Chris Lattner2a023902004-12-16 17:28:50 +00001134$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001135 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1136 $(MAYBE_PIC_Compile.CXX) $< -o $@
Reid Spencer81cd0492004-10-23 20:04:14 +00001137
Chris Lattnerf60c1702005-02-04 21:28:50 +00001138$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001139 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1140 $(MAYBE_PIC_Compile.CXX) $< -o $@
Chris Lattnerf60c1702005-02-04 21:28:50 +00001141
Chris Lattner2a023902004-12-16 17:28:50 +00001142$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001143 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1144 $(MAYBE_PIC_Compile.C) $< -o $@
Reid Spencerf206bd72004-10-22 21:01:56 +00001145
Reid Spencer96edbd52006-12-30 16:31:02 +00001146$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001147 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001148 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Reid Spencer9a6fc822006-12-03 21:01:45 +00001149 $(call UPGRADE_MSG,$@)
1150 $(call UPGRADE_LL,$@)
Reid Spencerf206bd72004-10-22 21:01:56 +00001151
Reid Spencer96edbd52006-12-30 16:31:02 +00001152$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGXX)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001153 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001154 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Reid Spencer9a6fc822006-12-03 21:01:45 +00001155 $(call UPGRADE_MSG,$@)
1156 $(call UPGRADE_LL,$@)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001157
Reid Spencer96edbd52006-12-30 16:31:02 +00001158$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(LLVMGCC)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001159 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001160 $(BCCompile.C) $< -o $@ -S -emit-llvm
Reid Spencer9a6fc822006-12-03 21:01:45 +00001161 $(call UPGRADE_MSG,@)
1162 $(call UPGRADE_LL,@)
Brian Gaeke0f148bc2003-12-10 00:26:28 +00001163
Chris Lattner07c7c192001-09-07 22:57:58 +00001164endif
1165
Chris Lattner161a84e2006-06-21 21:01:20 +00001166
1167## Rules for building preprocessed (.i/.ii) outputs.
1168$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1169 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1170 $(Verb) $(Preprocess.CXX) $< -o $@
1171
1172$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1173 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1174 $(Verb) $(Preprocess.CXX) $< -o $@
1175
Reid Spencerbef61c52006-12-10 04:56:38 +00001176$(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner161a84e2006-06-21 21:01:20 +00001177 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1178 $(Verb) $(Preprocess.C) $< -o $@
1179
1180
1181$(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1182 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1183 $(MAYBE_PIC_Compile.CXX) $< -o $@ -S
1184
1185$(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1186 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1187 $(MAYBE_PIC_Compile.CXX) $< -o $@ -S
1188
1189$(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1190 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1191 $(MAYBE_PIC_Compile.C) $< -o $@ -S
1192
Reid Spencer4b8067f2006-11-17 03:32:33 +00001193
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001194# make the C and C++ compilers strip debug info out of bytecode libraries.
Reid Spencer4b8067f2006-11-17 03:32:33 +00001195ifdef DEBUG_RUNTIME
Reid Spencerb63d0c42007-02-09 15:52:07 +00001196$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
Reid Spencer4b8067f2006-11-17 03:32:33 +00001197 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Reid Spencer7cec4f22007-02-09 17:09:14 +00001198 $(Verb) $(LLVMAS) $< -o - | $(LOPT) -std-compile-opts -o $@ -f
Reid Spencer4b8067f2006-11-17 03:32:33 +00001199else
Reid Spencerb63d0c42007-02-09 15:52:07 +00001200$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(LLVMAS) $(LOPT)
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001201 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Reid Spencerb63d0c42007-02-09 15:52:07 +00001202 $(Verb) $(LLVMAS) $< -o - | \
Reid Spencer7cec4f22007-02-09 17:09:14 +00001203 $(LOPT) -std-compile-opts -strip-debug -o $@ -f
Reid Spencer4b8067f2006-11-17 03:32:33 +00001204endif
1205
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001206
Reid Spencerf88808a2004-10-30 09:19:36 +00001207#---------------------------------------------------------
1208# Provide rule to build .bc files from .ll sources,
1209# regardless of dependencies
1210#---------------------------------------------------------
1211$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001212 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +00001213 $(Verb) $(LLVMAS) $< -f -o $@
1214
1215###############################################################################
1216# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1217###############################################################################
Chris Lattner0c4f4fe2003-08-15 02:18:35 +00001218
Reid Spencerf206bd72004-10-22 21:01:56 +00001219ifdef TARGET
1220
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001221TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1222 $(LLVM_SRC_ROOT)/lib/Target/Target.td \
Chris Lattner0706d8492007-02-28 05:10:40 +00001223 $(LLVM_SRC_ROOT)/lib/Target/TargetCallingConv.td \
Chris Lattner8a87f5f2006-03-03 01:54:54 +00001224 $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td \
Chris Lattner3becc6b2006-10-24 20:32:44 +00001225 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
1226 $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
Reid Spencerf88808a2004-10-30 09:19:36 +00001227INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Chris Lattner2a023902004-12-16 17:28:50 +00001228INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1229.PRECIOUS: $(INCTMPFiles) $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001230
Chris Lattner2a023902004-12-16 17:28:50 +00001231# All of these files depend on tblgen and the .td files.
1232$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001233
Chris Lattnerf86914d2004-12-16 17:38:56 +00001234# INCFiles rule: All of the tblgen generated files are emitted to
1235# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1236# us to only "touch" the real file if the contents of it change. IOW, if
1237# tblgen is modified, all of the .inc.tmp files are regereated, but no
1238# dependencies of the .inc files are, unless the contents of the .inc file
1239# changes.
1240$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
Reid Spencerafdc82c2004-12-16 18:26:53 +00001241 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
Chris Lattner2a023902004-12-16 17:28:50 +00001242
1243$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1244$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001245 $(Echo) "Building $(<F) register names with tblgen"
1246 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001247
Chris Lattner2a023902004-12-16 17:28:50 +00001248$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1249$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001250 $(Echo) "Building $(<F) register information header with tblgen"
1251 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001252
Chris Lattner2a023902004-12-16 17:28:50 +00001253$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1254$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001255 $(Echo) "Building $(<F) register info implementation with tblgen"
1256 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001257
Chris Lattner2a023902004-12-16 17:28:50 +00001258$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1259$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001260 $(Echo) "Building $(<F) instruction names with tblgen"
1261 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001262
Chris Lattner2a023902004-12-16 17:28:50 +00001263$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1264$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001265 $(Echo) "Building $(<F) instruction information with tblgen"
1266 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001267
Chris Lattner2a023902004-12-16 17:28:50 +00001268$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1269$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001270 $(Echo) "Building $(<F) assembly writer with tblgen"
1271 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001272
Chris Lattner22f937a2004-12-16 17:34:04 +00001273$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1274$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1275 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Reid Spencerf88808a2004-10-30 09:19:36 +00001276 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001277
Chris Lattner2a023902004-12-16 17:28:50 +00001278$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1279$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001280 $(Echo) "Building $(<F) code emitter with tblgen"
1281 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001282
Chris Lattner33f98bd2005-09-03 01:15:25 +00001283$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1284$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1285 $(Echo) "Building $(<F) instruction selector implementation with tblgen"
1286 $(Verb) $(TableGen) -gen-dag-isel -o $@ $<
1287
Jim Laskey9ed90322005-10-21 19:05:19 +00001288$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1289$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1290 $(Echo) "Building $(<F) subtarget information with tblgen"
1291 $(Verb) $(TableGen) -gen-subtarget -o $@ $<
Chris Lattner33f98bd2005-09-03 01:15:25 +00001292
Chris Lattneree0fe3b2007-02-27 20:44:12 +00001293$(TARGET:%=$(ObjDir)/%GenCallingConv.inc.tmp): \
1294$(ObjDir)/%GenCallingConv.inc.tmp : %.td $(ObjDir)/.dir
1295 $(Echo) "Building $(<F) calling convention information with tblgen"
1296 $(Verb) $(TableGen) -gen-callingconv -o $@ $<
1297
Reid Spencer81cd0492004-10-23 20:04:14 +00001298clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001299 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001300
1301endif
Chris Lattner0c4f4fe2003-08-15 02:18:35 +00001302
Reid Spencerf88808a2004-10-30 09:19:36 +00001303###############################################################################
1304# LEX AND YACC: Provide rules for generating sources with lex and yacc
1305###############################################################################
Chris Lattnerdb644dd2003-01-16 22:44:19 +00001306
Reid Spencerf88808a2004-10-30 09:19:36 +00001307#---------------------------------------------------------
1308# Provide rules for generating a .cpp source file from
1309# (f)lex input sources.
1310#---------------------------------------------------------
1311
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001312LexFiles := $(filter %.l,$(Sources))
Reid Spencerf88808a2004-10-30 09:19:36 +00001313
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001314ifneq ($(LexFiles),)
1315
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001316# Cancel built-in rules for lex
1317%.c: %.l
1318%.cpp: %.l
Reid Spencerf88808a2004-10-30 09:19:36 +00001319
Chris Lattner8104b4c2006-02-14 05:12:00 +00001320all:: $(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs)
1321
Reid Spencerf88808a2004-10-30 09:19:36 +00001322# Note the extra sed filtering here, used to cut down on the warnings emited
1323# by GCC. The last line is a gross hack to work around flex aparently not
1324# being able to resize the buffer on a large token input. Currently, for
1325# uninitialized string buffers in LLVM we can generate very long tokens, so
1326# this is a hack around it.
Chris Lattner92fc9b02003-08-15 20:00:47 +00001327# FIXME. (f.e. char Buffer[10000] )
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001328$(PROJ_SRC_DIR)/%.cpp: $(PROJ_SRC_DIR)/%.l
Reid Spencer993b95e2004-12-10 19:44:16 +00001329 $(Echo) Flexing $*.l
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001330 $(Verb) $(FLEX) -t $(PROJ_SRC_DIR)/$*.l | \
Reid Spencerf206bd72004-10-22 21:01:56 +00001331 $(SED) 's/void yyunput/inline void yyunput/' | \
1332 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1333 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001334 > $(PROJ_SRC_DIR)/$*.cpp
Chris Lattner8104b4c2006-02-14 05:12:00 +00001335
1336# IFF the .l file has changed since it was last checked into CVS, copy the .l
1337# file to .l.cvs and the generated .cpp file to .cpp.cvs. We use this mechanism
1338# so that people without flex can build LLVM by copying the .cvs files to the
1339# source location and building them.
1340$(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1341$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattner1e612822006-02-16 05:10:48 +00001342 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs || \
Chris Lattner8104b4c2006-02-14 05:12:00 +00001343 ($(CP) $< $@; $(CP) $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001344
Chris Lattner8104b4c2006-02-14 05:12:00 +00001345$(LexFiles:%.l=$(ObjDir)/%.o) : \
1346$(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
Chris Lattner2f7c9632001-06-06 20:29:01 +00001347
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001348clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001349 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001350
Reid Spencerf88808a2004-10-30 09:19:36 +00001351endif
1352
1353#---------------------------------------------------------
1354# Provide rules for generating a .cpp and .h source files
1355# from yacc (bison) input sources.
1356#---------------------------------------------------------
1357
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001358YaccFiles := $(filter %.y,$(Sources))
1359ifneq ($(YaccFiles),)
Reid Spencerf88808a2004-10-30 09:19:36 +00001360
1361.PRECIOUS: $(YaccOutput)
1362
Chris Lattnerb0240b22006-02-15 07:23:05 +00001363all:: $(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs)
Chris Lattnerc38a9752006-02-15 07:16:57 +00001364
Reid Spencerf88808a2004-10-30 09:19:36 +00001365# Cancel built-in rules for yacc
1366%.c: %.y
1367%.cpp: %.y
1368%.h: %.y
1369
Reid Spencerc49a8632005-12-21 23:17:06 +00001370# Rule for building the bison based parsers...
Reid Spencer917cf122006-08-24 22:41:20 +00001371ifneq ($(BISON),)
Reid Spencer07aa6682007-05-17 22:51:35 +00001372$(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
Reid Spencerf88808a2004-10-30 09:19:36 +00001373 $(Echo) "Bisoning $*.y"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001374 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1375 $(Verb) $(MV) -f $*.tab.c $(PROJ_SRC_DIR)/$*.cpp
1376 $(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
Chris Lattner2f7c9632001-06-06 20:29:01 +00001377
Chris Lattnerc38a9752006-02-15 07:16:57 +00001378# IFF the .y file has changed since it was last checked into CVS, copy the .y
1379# file to .y.cvs and the generated .cpp/.h file to .cpp.cvs/.h.cvs. We use this
1380# mechanism so that people without flex can build LLVM by copying the .cvs files
1381# to the source location and building them.
1382$(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1383$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattner1e612822006-02-16 05:10:48 +00001384 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs || \
Chris Lattnerc38a9752006-02-15 07:16:57 +00001385 ($(CP) $< $@; \
Chris Lattnerb0240b22006-02-15 07:23:05 +00001386 $(CP) $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs; \
Chris Lattnerc38a9752006-02-15 07:16:57 +00001387 $(CP) $(PROJ_SRC_DIR)/$*.h $(PROJ_SRC_DIR)/$*.h.cvs)
Reid Spencerc49a8632005-12-21 23:17:06 +00001388
Reid Spencer07aa6682007-05-17 22:51:35 +00001389else
1390$(PROJ_SRC_DIR)/%.cpp : $(PROJ_SRC_DIR)/%.cpp.cvs
1391 $(Echo) "Bison of $*.y SKIPPED, bison not found -- copying .cpp.cvs"
1392 $(Verb)$(CP) $(PROJ_SRC_DIR)/$*.cpp.cvs $(PROJ_SRC_DIR)/$*.cpp
1393
1394$(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.h.cvs
1395 $(Echo) "Bison of $*.y SKIPPED, bison not found -- copying .h.cvs"
1396 $(Verb)$(CP) $(PROJ_SRC_DIR)/$*.h.cvs $(PROJ_SRC_DIR)/$*.h
1397endif
1398
Chris Lattnerc38a9752006-02-15 07:16:57 +00001399
1400$(YaccFiles:%.y=$(ObjDir)/%.o): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
1401
1402YaccOutput := $(YaccFiles:%.y=%.output)
Reid Spencerc49a8632005-12-21 23:17:06 +00001403
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001404clean-local::
Reid Spencerc49a8632005-12-21 23:17:06 +00001405 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencerf88808a2004-10-30 09:19:36 +00001406endif
Chris Lattner2f7c9632001-06-06 20:29:01 +00001407
Reid Spencerf88808a2004-10-30 09:19:36 +00001408###############################################################################
1409# OTHER RULES: Other rules needed
1410###############################################################################
Reid Spencerf206bd72004-10-22 21:01:56 +00001411
Chris Lattner23d47392003-01-16 21:06:18 +00001412# To create postscript files from dot files...
John Criswell4ffb8442003-10-02 19:02:02 +00001413ifneq ($(DOT),false)
Chris Lattner23d47392003-01-16 21:06:18 +00001414%.ps: %.dot
Reid Spencerf206bd72004-10-22 21:01:56 +00001415 $(DOT) -Tps < $< > $@
John Criswell3ef61af2003-06-30 21:59:07 +00001416else
1417%.ps: %.dot
Reid Spencerf88808a2004-10-30 09:19:36 +00001418 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell3ef61af2003-06-30 21:59:07 +00001419endif
Chris Lattner23d47392003-01-16 21:06:18 +00001420
John Criswell0a6e6aa2003-09-06 14:44:17 +00001421# This rules ensures that header files that are removed still have a rule for
1422# which they can be "generated." This allows make to ignore them and
1423# reproduce the dependency lists.
John Criswella8391af2003-09-18 18:37:08 +00001424%.h:: ;
Chris Lattnerf60c1702005-02-04 21:28:50 +00001425%.hpp:: ;
John Criswell0a6e6aa2003-09-06 14:44:17 +00001426
Reid Spencerf88808a2004-10-30 09:19:36 +00001427# Define clean-local to clean the current directory. Note that this uses a
1428# very conservative approach ensuring that empty variables do not cause
1429# errors or disastrous removal.
Reid Spencer81cd0492004-10-23 20:04:14 +00001430clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001431ifneq ($(strip $(ObjDir)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001432 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencer12a3a052004-10-24 07:53:21 +00001433endif
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001434 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke8625f682004-01-21 19:53:11 +00001435ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001436 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke8625f682004-01-21 19:53:11 +00001437endif
John Criswell3ef61af2003-06-30 21:59:07 +00001438
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001439clean-all-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001440 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001441
Reid Spencerf88808a2004-10-30 09:19:36 +00001442# Build tags database for Emacs/Xemacs:
Reid Spenceraee67e62004-11-12 02:27:36 +00001443tags:: TAGS CTAGS
1444
Reid Spencerf88808a2004-10-30 09:19:36 +00001445TAGS:
Reid Spencerba6a3db2005-01-16 02:20:54 +00001446 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1447 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1448 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1449 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spenceraee67e62004-11-12 02:27:36 +00001450 -name '*.cpp' -o -name '*.h' | \
Reid Spencerf88808a2004-10-30 09:19:36 +00001451 $(ETAGS) $(ETAGSFLAGS) -
1452
Reid Spenceraee67e62004-11-12 02:27:36 +00001453CTAGS:
Reid Spencerba6a3db2005-01-16 02:20:54 +00001454 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1455 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1456 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1457 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spenceraee67e62004-11-12 02:27:36 +00001458 \( -name '*.cpp' -o -name '*.h' \) -print | \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001459 ctags -ImtT -o $(PROJ_OBJ_ROOT)/CTAGS -L -
Reid Spenceraee67e62004-11-12 02:27:36 +00001460
1461
Reid Spencer81cd0492004-10-23 20:04:14 +00001462###############################################################################
1463# DEPENDENCIES: Include the dependency files if we should
1464###############################################################################
Chris Lattnere9d7d702003-08-22 14:10:16 +00001465ifndef DISABLE_AUTO_DEPENDENCIES
1466
Reid Spencer81cd0492004-10-23 20:04:14 +00001467# If its not one of the cleaning targets
Chris Lattner68c97542006-09-04 05:23:20 +00001468ifneq ($(strip $(filter-out clean clean-local dist-clean,$(MAKECMDGOALS)))),)
Reid Spencerf206bd72004-10-22 21:01:56 +00001469
Reid Spencer81cd0492004-10-23 20:04:14 +00001470# Get the list of dependency files
Reid Spencerf88808a2004-10-30 09:19:36 +00001471DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Chris Lattner8104b4c2006-02-14 05:12:00 +00001472DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
Misha Brukmanb891ffb2003-11-09 21:36:19 +00001473
Reid Spencer81cd0492004-10-23 20:04:14 +00001474-include /dev/null $(DependFiles)
1475
John Criswell48ecca62003-08-12 18:51:51 +00001476endif
Chris Lattner598222b2003-08-18 17:27:40 +00001477
Reid Spencerf88808a2004-10-30 09:19:36 +00001478endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001479
Reid Spencer100080c2004-10-25 08:27:37 +00001480###############################################################################
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001481# CHECK: Running the test suite
1482###############################################################################
1483
1484check::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001485 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1486 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001487 $(EchoCmd) Running test suite ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001488 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001489 TESTSUITE=$(TESTSUITE) ; \
1490 else \
1491 $(EchoCmd) No Makefile in test directory ; \
1492 fi ; \
1493 else \
1494 $(EchoCmd) No test directory ; \
1495 fi
1496
1497###############################################################################
Reid Spencerf88808a2004-10-30 09:19:36 +00001498# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer100080c2004-10-25 08:27:37 +00001499###############################################################################
1500
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001501#------------------------------------------------------------------------
1502# Define distribution related variables
1503#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +00001504DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1505DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1506TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1507DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1508DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1509DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
Reid Spencer100080c2004-10-25 08:27:37 +00001510DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1511 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001512 Makefile.config.in configure autoconf
1513DistOther := $(notdir $(wildcard \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001514 $(PROJ_SRC_DIR)/*.h \
1515 $(PROJ_SRC_DIR)/*.td \
1516 $(PROJ_SRC_DIR)/*.def \
1517 $(PROJ_SRC_DIR)/*.ll \
1518 $(PROJ_SRC_DIR)/*.in))
Reid Spencerf88808a2004-10-30 09:19:36 +00001519DistSubDirs := $(SubDirs)
Reid Spencerfc66af42004-11-29 05:00:33 +00001520DistSources = $(Sources) $(EXTRA_DIST)
1521DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer100080c2004-10-25 08:27:37 +00001522
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001523#------------------------------------------------------------------------
1524# We MUST build distribution with OBJ_DIR != SRC_DIR
1525#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +00001526ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001527dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerf88808a2004-10-30 09:19:36 +00001528 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001529
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001530else
1531
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001532#------------------------------------------------------------------------
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001533# Prevent attempt to run dist targets from anywhere but the top level
1534#------------------------------------------------------------------------
1535ifneq ($(LEVEL),.)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001536dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001537 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001538else
1539
1540#------------------------------------------------------------------------
1541# Provide the top level targets
1542#------------------------------------------------------------------------
1543
Reid Spencerf88808a2004-10-30 09:19:36 +00001544dist-gzip:: $(DistTarGZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001545
Reid Spencer81546582004-12-04 22:34:09 +00001546$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001547 $(Echo) Packing gzipped distribution tar file.
Reid Spencerba6a3db2005-01-16 02:20:54 +00001548 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
Reid Spencerfc66af42004-11-29 05:00:33 +00001549 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001550
Reid Spencerf88808a2004-10-30 09:19:36 +00001551dist-bzip2:: $(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001552
Reid Spencer81546582004-12-04 22:34:09 +00001553$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001554 $(Echo) Packing bzipped distribution tar file.
Reid Spencerba6a3db2005-01-16 02:20:54 +00001555 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
Reid Spencerfc66af42004-11-29 05:00:33 +00001556 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001557
Reid Spencerf88808a2004-10-30 09:19:36 +00001558dist-zip:: $(DistZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001559
Reid Spencer81546582004-12-04 22:34:09 +00001560$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001561 $(Echo) Packing zipped distribution file.
1562 $(Verb) rm -f $(DistZip)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001563 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001564
1565dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001566 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001567
Reid Spencer3a468752005-01-28 19:52:32 +00001568DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001569
Reid Spencer81546582004-12-04 22:34:09 +00001570dist-check:: $(DistTarGZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001571 $(Echo) Checking distribution tar file.
1572 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001573 $(RM) -rf $(DistCheckDir) ; \
1574 fi
Reid Spencerf88808a2004-10-30 09:19:36 +00001575 $(Verb) $(MKDIR) $(DistCheckDir)
1576 $(Verb) cd $(DistCheckDir) && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001577 $(MKDIR) $(DistCheckDir)/build && \
1578 $(MKDIR) $(DistCheckDir)/install && \
1579 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1580 cd build && \
1581 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
Reid Spencer13f51932005-05-24 02:33:20 +00001582 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
Reid Spencer81546582004-12-04 22:34:09 +00001583 $(MAKE) all && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001584 $(MAKE) check && \
1585 $(MAKE) install && \
1586 $(MAKE) uninstall && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001587 $(MAKE) dist-clean && \
Reid Spencerf88808a2004-10-30 09:19:36 +00001588 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001589
1590dist-clean::
Reid Spencerf88808a2004-10-30 09:19:36 +00001591 $(Echo) Cleaning distribution files
Reid Spencer81546582004-12-04 22:34:09 +00001592 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1593 $(DistCheckDir)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001594
1595endif
1596
1597#------------------------------------------------------------------------
1598# Provide the recursive distdir target for building the distribution directory
1599#------------------------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +00001600distdir: $(DistDir)/.makedistdir
1601$(DistDir)/.makedistdir: $(DistSources)
Reid Spencerf88808a2004-10-30 09:19:36 +00001602 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001603 if test -d "$(DistDir)" ; then \
1604 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1605 exit 1 ; \
1606 fi ; \
Reid Spencer81546582004-12-04 22:34:09 +00001607 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001608 $(RM) -rf $(DistDir); \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001609 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer15b85092006-04-10 16:46:04 +00001610 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001611 fi
Reid Spencerfc66af42004-11-29 05:00:33 +00001612 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencerf88808a2004-10-30 09:19:36 +00001613 $(Verb) $(MKDIR) $(DistDir)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001614 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1615 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
Reid Spencer100080c2004-10-25 08:27:37 +00001616 for file in $(DistFiles) ; do \
1617 case "$$file" in \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001618 $(PROJ_SRC_DIR)/*) \
Reid Spencer81546582004-12-04 22:34:09 +00001619 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1620 ;; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001621 $(PROJ_SRC_ROOT)/*) \
Reid Spencer81546582004-12-04 22:34:09 +00001622 file=`echo "$$file" | \
1623 sed "s#^$$srcrootstrip/##"` \
1624 ;; \
Reid Spencer100080c2004-10-25 08:27:37 +00001625 esac; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001626 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1627 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1628 from_dir="$(PROJ_SRC_DIR)" ; \
Reid Spencer81546582004-12-04 22:34:09 +00001629 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001630 from_dir=. ; \
Reid Spencer81546582004-12-04 22:34:09 +00001631 fi ; \
1632 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001633 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1634 to_dir="$(DistDir)/$$dir"; \
1635 $(MKDIR) "$$to_dir" ; \
1636 else \
1637 to_dir="$(DistDir)"; \
1638 fi; \
1639 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1640 if test -n "$$mid_dir" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001641 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001642 fi ; \
1643 if test -d "$$from_dir/$$file"; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001644 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1645 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
Reid Spencer13f51932005-05-24 02:33:20 +00001646 cd $(PROJ_SRC_DIR) ; \
1647 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1648 ( cd $$to_dir ; $(TAR) xf - ) ; \
1649 cd $(PROJ_OBJ_DIR) ; \
1650 else \
1651 cd $$from_dir ; \
1652 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1653 ( cd $$to_dir ; $(TAR) xf - ) ; \
1654 cd $(PROJ_OBJ_DIR) ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001655 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +00001656 elif test -f "$$from_dir/$$file" ; then \
Reid Spencerafdc82c2004-12-16 18:26:53 +00001657 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001658 elif test -L "$$from_dir/$$file" ; then \
Reid Spencerafdc82c2004-12-16 18:26:53 +00001659 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001660 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer81546582004-12-04 22:34:09 +00001661 $(EchoCmd) "===== WARNING: Distribution Source " \
1662 "$$from_dir/$$file Not Found!" ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001663 elif test "$(Verb)" != '@' ; then \
1664 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001665 fi; \
1666 done
Reid Spencerf88808a2004-10-30 09:19:36 +00001667 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer100080c2004-10-25 08:27:37 +00001668 if test "$$subdir" \!= "." ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001669 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001670 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer15b85092006-04-10 16:46:04 +00001671 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
Reid Spencer056f0222006-04-07 16:06:18 +00001672 DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001673 fi; \
1674 done
Reid Spencer81546582004-12-04 22:34:09 +00001675 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer13f51932005-05-24 02:33:20 +00001676 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
Chris Lattnerb8e7aa02006-02-14 04:27:15 +00001677 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1678 -name .svn \) -print` ;\
Reid Spencer81546582004-12-04 22:34:09 +00001679 $(MAKE) dist-hook ; \
1680 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1681 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1682 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1683 -o ! -type d ! -perm -444 -exec \
1684 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1685 || chmod -R a+r $(DistDir) ; \
1686 fi
Reid Spencer100080c2004-10-25 08:27:37 +00001687
Reid Spencerf88808a2004-10-30 09:19:36 +00001688# This is invoked by distdir target, define it as a no-op to avoid errors if not
1689# defined by user.
Reid Spencer100080c2004-10-25 08:27:37 +00001690dist-hook::
1691
Reid Spencer23a70372004-10-22 23:06:30 +00001692endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001693
1694###############################################################################
Reid Spencer12a3a052004-10-24 07:53:21 +00001695# TOP LEVEL - targets only to apply at the top level directory
1696###############################################################################
1697
1698ifeq ($(LEVEL),.)
1699
1700#------------------------------------------------------------------------
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001701# Install support for the project's include files:
Reid Spencer12a3a052004-10-24 07:53:21 +00001702#------------------------------------------------------------------------
Reid Spencera79819d2007-02-06 18:53:14 +00001703ifdef NO_INSTALL
1704install-local::
1705 $(Echo) Install circumvented with NO_INSTALL
1706uninstall-local::
1707 $(Echo) Uninstall circumvented with NO_INSTALL
1708else
Reid Spencer12a3a052004-10-24 07:53:21 +00001709install-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001710 $(Echo) Installing include files
Reid Spencerba6a3db2005-01-16 02:20:54 +00001711 $(Verb) $(MKDIR) $(PROJ_includedir)
Reid Spencerc43b1d42005-02-24 03:56:32 +00001712 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001713 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer48a82f42005-02-16 15:54:03 +00001714 for hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
Reid Spencerc82c2cf2007-04-09 19:08:58 +00001715 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS | \
1716 grep -v .svn` ; do \
Reid Spencerc43b1d42005-02-24 03:56:32 +00001717 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1718 if test \! -d "$$instdir" ; then \
1719 $(EchoCmd) Making install directory $$instdir ; \
1720 $(MKDIR) $$instdir ;\
1721 fi ; \
1722 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer48a82f42005-02-16 15:54:03 +00001723 done ; \
Reid Spencer12a3a052004-10-24 07:53:21 +00001724 fi
Reid Spencer528c9802005-12-23 22:27:56 +00001725ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencerc43b1d42005-02-24 03:56:32 +00001726 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
Reid Spencer48a82f42005-02-16 15:54:03 +00001727 cd $(PROJ_OBJ_ROOT)/include && \
Reid Spencer528c9802005-12-23 22:27:56 +00001728 for hdr in `find . -type f -print | grep -v CVS` ; do \
Reid Spencerc43b1d42005-02-24 03:56:32 +00001729 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer48a82f42005-02-16 15:54:03 +00001730 done ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001731 fi
Reid Spencer528c9802005-12-23 22:27:56 +00001732endif
Reid Spencer12a3a052004-10-24 07:53:21 +00001733
1734uninstall-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001735 $(Echo) Uninstalling include files
Reid Spencerba6a3db2005-01-16 02:20:54 +00001736 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1737 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer12a3a052004-10-24 07:53:21 +00001738 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001739 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' \
1740 -o -name '*.in' ')' -print ')' | \
1741 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001742 cd $(PROJ_SRC_ROOT)/include && \
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001743 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1744 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001745 fi
Reid Spencera79819d2007-02-06 18:53:14 +00001746endif
Reid Spencer12a3a052004-10-24 07:53:21 +00001747endif
1748
Chris Lattnerf8adf7a2007-04-14 23:35:45 +00001749check-line-length:
Anton Korobeynikovfb801512007-04-16 18:10:23 +00001750 @egrep -n '.{81}' $(Sources)
Chris Lattnerf8adf7a2007-04-14 23:35:45 +00001751
Anton Korobeynikovfb801512007-04-16 18:10:23 +00001752check-for-tabs:
1753 @egrep -n ' ' $(Sources)
Reid Spencere6bc2062007-05-02 21:29:39 +00001754check-footprint:
1755 @ls -l $(LibDir) | awk '\
1756 BEGIN { sum = 0; } \
1757 { sum += $$5; } \
1758 END { printf("Libraries: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
1759 @ls -l $(ToolDir) | awk '\
1760 BEGIN { sum = 0; } \
1761 { sum += $$5; } \
1762 END { printf("Programs: %6.3f MBytes\n", sum/(1024.0*1024.0)); }'
Reid Spencerf206bd72004-10-22 21:01:56 +00001763#------------------------------------------------------------------------
1764# Print out the directories used for building
Reid Spencerf88808a2004-10-30 09:19:36 +00001765#------------------------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001766printvars::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001767 $(Echo) "BuildMode : " '$(BuildMode)'
1768 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1769 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1770 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1771 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1772 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1773 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1774 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1775 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1776 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1777 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
Reid Spencerfe0a01e2005-02-16 16:13:02 +00001778 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
Reid Spencerba6a3db2005-01-16 02:20:54 +00001779 $(Echo) "UserTargets : " '$(UserTargets)'
1780 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1781 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1782 $(Echo) "ObjDir : " '$(ObjDir)'
1783 $(Echo) "LibDir : " '$(LibDir)'
1784 $(Echo) "ToolDir : " '$(ToolDir)'
1785 $(Echo) "ExmplDir : " '$(ExmplDir)'
1786 $(Echo) "Sources : " '$(Sources)'
1787 $(Echo) "TDFiles : " '$(TDFiles)'
1788 $(Echo) "INCFiles : " '$(INCFiles)'
1789 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
Reid Spencerfefb9ea2005-03-01 16:27:06 +00001790 $(Echo) "PreConditions: " '$(PreConditions)'
Reid Spencerba6a3db2005-01-16 02:20:54 +00001791 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1792 $(Echo) "Compile.C : " '$(Compile.C)'
1793 $(Echo) "Archive : " '$(Archive)'
1794 $(Echo) "YaccFiles : " '$(YaccFiles)'
1795 $(Echo) "LexFiles : " '$(LexFiles)'
1796 $(Echo) "Module : " '$(Module)'
Reid Spencerb48e3f82005-08-24 10:43:10 +00001797 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
Reid Spencerece13582006-04-09 23:41:14 +00001798 $(Echo) "SubDirs : " '$(SubDirs)'
Reid Spencer200c6f92007-03-29 19:05:44 +00001799 $(Echo) "ProjLibsPaths: " '$(ProjLibsPaths)'
1800 $(Echo) "ProjLibsOptions: " '$(ProjLibsOptions)'