blob: 4cf51835d59688dcbd10c66c243f6b11e1a54f37 [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
88clean-local::
89ifneq ($(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
216 ifdef ENABLE_OPTIMIZED
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 Spencer15b85092006-04-10 16:46:04 +0000247# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
248# then disable assertions by defining the appropriate preprocessor symbols.
Reid Spencerece13582006-04-09 23:41:14 +0000249ifdef DISABLE_ASSERTIONS
Reid Spencer056f0222006-04-07 16:06:18 +0000250 BuildMode := $(BuildMode)-Asserts
Chris Lattner98c79c32006-03-21 01:06:41 +0000251 CXX.Flags += -DNDEBUG
252 C.Flags += -DNDEBUG
Reid Spencerece13582006-04-09 23:41:14 +0000253else
254 CXX.Flags += -D_DEBUG
255 C.Flags += -D_DEBUG
Chris Lattner98c79c32006-03-21 01:06:41 +0000256endif
257
Reid Spencere7141c82006-08-28 01:02:49 +0000258CXX.Flags += $(CXXFLAGS) -Woverloaded-virtual
Reid Spencer6f682b72006-03-22 15:59:55 +0000259C.Flags += $(CFLAGS)
260CPP.BaseFlags += $(CPPFLAGS)
261LD.Flags += $(LDFLAGS)
262AR.Flags := cru
Reid Spencerf88808a2004-10-30 09:19:36 +0000263LibTool.Flags := --tag=CXX
Reid Spencer81cd0492004-10-23 20:04:14 +0000264
Chris Lattnerdc5a8962006-07-27 18:19:51 +0000265# Make Floating point IEEE compliant on Alpha.
Andrew Lenharth9a98def2005-02-13 03:41:10 +0000266ifeq ($(ARCH),Alpha)
Andrew Lenharth2b0badd2006-07-20 17:27:58 +0000267 CXX.Flags += -mieee -fPIC
268 CPP.BaseFlags += -mieee -fPIC
Andrew Lenharth9a98def2005-02-13 03:41:10 +0000269endif
270
Reid Spencer81cd0492004-10-23 20:04:14 +0000271#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000272# Directory locations
Reid Spencer81cd0492004-10-23 20:04:14 +0000273#--------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +0000274ObjDir := $(PROJ_OBJ_DIR)/$(BuildMode)
275LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
276ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
277ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000278LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer0dbf1012004-11-18 20:04:39 +0000279LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencerb9f8de62004-12-28 07:59:22 +0000280LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer2bba41c2004-12-22 05:57:21 +0000281CFERuntimeLibDir := $(LLVMGCCDIR)/lib
John Criswell3ef61af2003-06-30 21:59:07 +0000282
Reid Spencer81cd0492004-10-23 20:04:14 +0000283#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000284# Full Paths To Compiled Tools and Utilities
Reid Spencer81cd0492004-10-23 20:04:14 +0000285#--------------------------------------------------------------------
Reid Spencerb12e2902005-01-14 16:33:36 +0000286EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
287Echo = @$(EchoCmd)
Reid Spencerf88808a2004-10-30 09:19:36 +0000288ifndef LIBTOOL
Reid Spencerf206bd72004-10-22 21:01:56 +0000289LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencerf88808a2004-10-30 09:19:36 +0000290endif
291ifndef LLVMAS
292LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
293endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000294ifndef TBLGEN
Reid Spencer0aa9d002006-07-26 21:14:56 +0000295 ifeq ($(LLVM_CROSS_COMPILING),1)
296 TBLGEN := $(LLVMToolDir)/tblgen$(BUILD_EXEEXT)
297 else
298 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
299 endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000300endif
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000301LLVM_CONFIG := $(LLVMToolDir)/llvm-config
Chris Lattner0ea40c92004-11-29 19:47:58 +0000302ifndef GCCAS
303GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
304endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000305ifndef GCCLD
306GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
307endif
Chris Lattner68c97542006-09-04 05:23:20 +0000308ifndef LLVMDIS
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000309LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
310endif
311ifndef LLI
312LLI := $(LLVMToolDir)/lli$(EXEEXT)
313endif
Alkis Evlogimenos24340582005-02-27 10:21:37 +0000314ifndef LLC
315LLC := $(LLVMToolDir)/llc$(EXEEXT)
316endif
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000317ifndef LOPT
Alkis Evlogimenos7c7705d2004-12-13 18:08:29 +0000318LOPT := $(LLVMToolDir)/opt$(EXEEXT)
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000319endif
Alkis Evlogimenos7c04a3d2005-02-02 00:40:15 +0000320ifndef LBUGPOINT
321LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
322endif
323
John Criswelldc665012005-01-03 17:42:57 +0000324LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
325LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000326
Reid Spencer81cd0492004-10-23 20:04:14 +0000327#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000328# Adjust to user's request
Reid Spencer81cd0492004-10-23 20:04:14 +0000329#--------------------------------------------------------------------
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000330
Reid Spencer87e645c2005-01-11 04:31:07 +0000331# Adjust LD.Flags and Libtool.Flags depending on the kind of library that is
332# to be built. Note that if LOADABLE_MODULE is specified then the resulting
Reid Spencere6458c32006-08-07 23:12:15 +0000333# shared library can be opened with dlopen. Also, LOADABLE_MODULE implies
334# several other things so we force them to be defined/on.
335ifdef LOADABLE_MODULE
336 SHARED_LIBRARY := 1
337 DONT_BUILD_RELINKED := 1
338 LINK_LIBS_IN_SHARED := 1
339 LD.Flags += -module
340endif
341
Reid Spencer87e645c2005-01-11 04:31:07 +0000342ifdef SHARED_LIBRARY
Reid Spencerf88808a2004-10-30 09:19:36 +0000343 LD.Flags += -rpath $(LibDir)
Reid Spencer87e645c2005-01-11 04:31:07 +0000344else
345 LibTool.Flags += --tag=disable-shared
John Criswell3601f372003-07-31 20:58:51 +0000346endif
347
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000348ifdef TOOL_VERBOSE
349 C.Flags += -v
350 CXX.Flags += -v
351 LD.Flags += -v
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000352 VERBOSE := 1
353endif
354
Reid Spencer81cd0492004-10-23 20:04:14 +0000355# Adjust settings for verbose mode
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000356ifndef VERBOSE
Reid Spencerf88808a2004-10-30 09:19:36 +0000357 Verb := @
358 LibTool.Flags += --silent
359 AR.Flags += >/dev/null 2>/dev/null
Reid Spencerba6a3db2005-01-16 02:20:54 +0000360 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
Reid Spencer100080c2004-10-25 08:27:37 +0000361else
Reid Spencerf88808a2004-10-30 09:19:36 +0000362 ConfigureScriptFLAGS :=
Misha Brukman1326a7c2002-09-12 16:05:39 +0000363endif
364
Vikram S. Adved141c282002-09-18 11:55:13 +0000365# By default, strip symbol information from executable
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000366ifndef KEEP_SYMBOLS
Reid Spencerf88808a2004-10-30 09:19:36 +0000367 Strip := $(PLATFORMSTRIPOPTS)
368 StripWarnMsg := "(without symbols)"
Reid Spencer247a10e2005-02-24 07:12:43 +0000369 Install.StripFlag += -s
Vikram S. Adved141c282002-09-18 11:55:13 +0000370endif
371
Reid Spencer81cd0492004-10-23 20:04:14 +0000372# Adjust linker flags for building an executable
Reid Spencerf206bd72004-10-22 21:01:56 +0000373ifdef TOOLNAME
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000374ifdef EXAMPLE_TOOL
375 LD.Flags += -rpath $(ExmplDir) -export-dynamic
376else
Reid Spencerf88808a2004-10-30 09:19:36 +0000377 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000378endif
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000379endif
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000380
Reid Spencer81cd0492004-10-23 20:04:14 +0000381#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000382# Options To Invoke Tools
Reid Spencer81cd0492004-10-23 20:04:14 +0000383#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000384
Reid Spencera62f0972006-06-01 01:55:21 +0000385CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused -Wno-long-long \
Evan Cheng9e7e4b52006-06-20 18:50:48 +0000386 -pedantic $(EXTRA_OPTIONS)
Reid Spencerf206bd72004-10-22 21:01:56 +0000387
Duraid Madina60c9a3c2005-05-16 06:38:09 +0000388ifeq ($(OS),HP-UX)
Duraid Madina1f898af2006-02-15 03:20:16 +0000389 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
Duraid Madina60c9a3c2005-05-16 06:38:09 +0000390endif
391
Chris Lattner11c25cf2006-05-30 16:38:06 +0000392# If we are building a universal binary on Mac OS/X, pass extra options. This
393# is useful to people that want to link the LLVM libraries into their universal
Chris Lattner65e28b32006-06-29 19:38:04 +0000394# apps.
395#
396# The following can be optionally specified:
397# UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
398# For Mac OS/X 10.4 Intel machines, the traditional one is:
399# UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
400# UNIVERSAL_ARCH can be optionally specified to be a list of architectures
401# to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
402# i386/ppc only.
Chris Lattnerd81eba52006-04-06 06:30:15 +0000403ifdef UNIVERSAL
Chris Lattner65e28b32006-06-29 19:38:04 +0000404 ifndef UNIVERSAL_ARCH
405 UNIVERSAL_ARCH := i386 ppc
406 endif
407 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
408 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
409 Relink.Flags := $(UNIVERSAL_ARCH_OPTIONS:%=-XCClinker %)
Chris Lattner64e85f32006-06-16 21:47:59 +0000410 ifdef UNIVERSAL_SDK_PATH
411 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
412 Relink.Flags += -XCClinker -isysroot -XCClinker $(UNIVERSAL_SDK_PATH)
413 endif
414
415 # Building universal cannot compute dependencies automatically.
Chris Lattnerd81eba52006-04-06 06:30:15 +0000416 DISABLE_AUTO_DEPENDENCIES=1
417endif
418
Reid Spencer6f682b72006-03-22 15:59:55 +0000419LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
420CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
421# All -I flags should go here, so that they don't confuse llvm-config.
422CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
423 -I$(PROJ_OBJ_ROOT)/include \
424 -I$(PROJ_SRC_ROOT)/include \
425 -I$(LLVM_OBJ_ROOT)/include \
426 -I$(LLVM_SRC_ROOT)/include \
427 $(CPP.BaseFlags)
Reid Spencerf206bd72004-10-22 21:01:56 +0000428
Reid Spencerf88808a2004-10-30 09:19:36 +0000429Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
430LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
Reid Spencer2bba41c2004-12-22 05:57:21 +0000431BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000432 $(C.Flags)
Chris Lattnerbb087952005-10-05 00:28:41 +0000433Preprocess.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -E $(C.Flags)
434
Reid Spencerf88808a2004-10-30 09:19:36 +0000435Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
436LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
Reid Spencerc005fba2004-12-24 14:47:34 +0000437BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000438 $(CXX.Flags)
Chris Lattnerbb087952005-10-05 00:28:41 +0000439Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
Reid Spencere6458c32006-08-07 23:12:15 +0000440Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
441 $(LD.Flags) $(Strip)
442LTLink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(Link)
443Relink = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
444 $(Relink.Flags)
445LTRelink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(Relink)
Reid Spencerfe0a01e2005-02-16 16:13:02 +0000446LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
447 $(Install.Flags)
Reid Spencer247a10e2005-02-24 07:12:43 +0000448ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
Reid Spencer6f682b72006-03-22 15:59:55 +0000449ScriptInstall = $(INSTALL) -m 0755
Reid Spencer247a10e2005-02-24 07:12:43 +0000450DataInstall = $(INSTALL) -m 0644
Vladimir Prus788db2c2006-05-16 06:39:36 +0000451TableGen = $(TBLGEN) -I $(PROJ_SRC_DIR) -I$(PROJ_SRC_ROOT)/include \
452 -I $(PROJ_SRC_ROOT)/lib/Target
Reid Spencerf88808a2004-10-30 09:19:36 +0000453Archive = $(AR) $(AR.Flags)
Reid Spencer32f7e422004-12-02 09:28:21 +0000454LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencerf206bd72004-10-22 21:01:56 +0000455ifdef RANLIB
Reid Spencer81cd0492004-10-23 20:04:14 +0000456Ranlib = $(RANLIB)
Reid Spencerf206bd72004-10-22 21:01:56 +0000457else
Reid Spencer81cd0492004-10-23 20:04:14 +0000458Ranlib = ranlib
John Criswell3ef61af2003-06-30 21:59:07 +0000459endif
460
Chris Lattner2f7c9632001-06-06 20:29:01 +0000461#----------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +0000462# Get the list of source files and compute object file
463# names from them.
Reid Spencer81cd0492004-10-23 20:04:14 +0000464#----------------------------------------------------------
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000465
466ifndef SOURCES
467 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
468 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
469 $(PROJ_SRC_DIR)/*.l))
Reid Spencerf88808a2004-10-30 09:19:36 +0000470else
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000471 Sources := $(SOURCES)
472endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000473
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000474ifdef BUILT_SOURCES
475Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Reid Spencer81546582004-12-04 22:34:09 +0000476endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000477
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000478BaseNameSources := $(sort $(basename $(Sources)))
479
480ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
481ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
482ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
483
Reid Spencer81cd0492004-10-23 20:04:14 +0000484###############################################################################
485# DIRECTORIES: Handle recursive descent of directory structure
486###############################################################################
John Criswell3601f372003-07-31 20:58:51 +0000487
Chris Lattner2f7c9632001-06-06 20:29:01 +0000488#---------------------------------------------------------
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000489# Provide rules to make install dirs. This must be early
490# in the file so they get built before dependencies
491#---------------------------------------------------------
492
Reid Spencer90b689d2005-05-19 20:26:14 +0000493$(PROJ_bindir): $(PROJ_bindir)/.dir
494$(PROJ_libdir): $(PROJ_libdir)/.dir
495$(PROJ_includedir): $(PROJ_includedir)/.dir
496$(PROJ_etcdir): $(PROJ_etcdir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000497
Reid Spencerf88808a2004-10-30 09:19:36 +0000498# To create other directories, as needed, and timestamp their creation
499%/.dir:
500 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfc66af42004-11-29 05:00:33 +0000501 $(Verb) $(DATE) > $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000502
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000503.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
504.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000505
506#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000507# Handle the DIRS options for sequential construction
Chris Lattner2f7c9632001-06-06 20:29:01 +0000508#---------------------------------------------------------
509
Reid Spencerf88808a2004-10-30 09:19:36 +0000510SubDirs :=
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000511ifdef DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000512SubDirs += $(DIRS)
Chris Lattnerb9259612006-07-26 20:22:26 +0000513
514ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencerf88808a2004-10-30 09:19:36 +0000515$(RecursiveTargets)::
516 $(Verb) for dir in $(DIRS); do \
Reid Spencerf206bd72004-10-22 21:01:56 +0000517 if [ ! -f $$dir/Makefile ]; then \
518 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000519 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000520 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000521 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattner539a23c2002-09-17 23:35:02 +0000522 done
Chris Lattnerb9259612006-07-26 20:22:26 +0000523else
524$(RecursiveTargets)::
525 $(Verb) for dir in $(DIRS); do \
526 ($(MAKE) -C $$dir $@ ) || exit 1; \
527 done
528endif
529
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000530endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000531
Reid Spencer81cd0492004-10-23 20:04:14 +0000532#---------------------------------------------------------
533# Handle the EXPERIMENTAL_DIRS options ensuring success
534# after each directory is built.
535#---------------------------------------------------------
536ifdef EXPERIMENTAL_DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000537$(RecursiveTargets)::
538 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer81cd0492004-10-23 20:04:14 +0000539 if [ ! -f $$dir/Makefile ]; then \
540 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000541 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000542 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000543 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000544 done
545endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000546
Reid Spencerc49a8632005-12-21 23:17:06 +0000547#-----------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000548# Handle the PARALLEL_DIRS options for parallel construction
Reid Spencerc49a8632005-12-21 23:17:06 +0000549#-----------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000550ifdef PARALLEL_DIRS
551
Reid Spencerf88808a2004-10-30 09:19:36 +0000552SubDirs += $(PARALLEL_DIRS)
553
Reid Spencerd4bd3752004-12-03 20:08:48 +0000554# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencerf88808a2004-10-30 09:19:36 +0000555all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
556clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000557clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencerf88808a2004-10-30 09:19:36 +0000558install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000559uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencerd4bd3752004-12-03 20:08:48 +0000560install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000561
Reid Spencer81546582004-12-04 22:34:09 +0000562ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer81cd0492004-10-23 20:04:14 +0000563
Reid Spencer81546582004-12-04 22:34:09 +0000564$(ParallelTargets) :
Reid Spencerf88808a2004-10-30 09:19:36 +0000565 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencerf206bd72004-10-22 21:01:56 +0000566 $(MKDIR) $(@D); \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000567 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswell6df35dd2003-11-25 19:32:22 +0000568 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000569 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ;
Chris Lattner2f7c9632001-06-06 20:29:01 +0000570endif
571
Reid Spencer81cd0492004-10-23 20:04:14 +0000572#---------------------------------------------------------
573# Handle the OPTIONAL_DIRS options for directores that may
574# or may not exist.
575#---------------------------------------------------------
John Criswell8224df92003-06-27 16:58:44 +0000576ifdef OPTIONAL_DIRS
Reid Spencer100080c2004-10-25 08:27:37 +0000577
Reid Spencerf88808a2004-10-30 09:19:36 +0000578SubDirs += $(OPTIONAL_DIRS)
Reid Spencer100080c2004-10-25 08:27:37 +0000579
Chris Lattnerb9259612006-07-26 20:22:26 +0000580ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencerf88808a2004-10-30 09:19:36 +0000581$(RecursiveTargets)::
582 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000583 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
Reid Spencerf206bd72004-10-22 21:01:56 +0000584 if [ ! -f $$dir/Makefile ]; then \
585 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000586 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000587 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000588 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000589 fi \
John Criswell8224df92003-06-27 16:58:44 +0000590 done
Chris Lattnerb9259612006-07-26 20:22:26 +0000591else
592$(RecursiveTargets)::
593 $(Verb) for dir in $(OPTIONAL_DIRS); do \
594 ($(MAKE) -C$$dir $@ ) || exit 1; \
595 done
596endif
John Criswell8224df92003-06-27 16:58:44 +0000597endif
598
Reid Spencercc51e7b2004-08-20 09:20:05 +0000599#---------------------------------------------------------
600# Handle the CONFIG_FILES options
601#---------------------------------------------------------
602ifdef CONFIG_FILES
Reid Spencercc51e7b2004-08-20 09:20:05 +0000603
Reid Spencerba6a3db2005-01-16 02:20:54 +0000604install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
605 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000606 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000607 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
Reid Spencerc43b1d42005-02-24 03:56:32 +0000608 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000609 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
Reid Spencerc43b1d42005-02-24 03:56:32 +0000610 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer39d6a612004-11-23 05:59:53 +0000611 else \
612 $(ECHO) Error: cannot find config file $${file}. ; \
613 fi \
Reid Spencercc51e7b2004-08-20 09:20:05 +0000614 done
Reid Spencer81cd0492004-10-23 20:04:14 +0000615
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000616uninstall-local::
Reid Spencerba6a3db2005-01-16 02:20:54 +0000617 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000618 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000619 $(RM) -f $(PROJ_etcdir)/$${file} ; \
Reid Spencer12a3a052004-10-24 07:53:21 +0000620 done
621
Reid Spencercc51e7b2004-08-20 09:20:05 +0000622endif
623
Reid Spencer81cd0492004-10-23 20:04:14 +0000624###############################################################################
Reid Spencera80f1672005-05-19 00:37:31 +0000625# Set up variables for building libararies
626###############################################################################
627
628#---------------------------------------------------------
Reid Spencera80f1672005-05-19 00:37:31 +0000629# Define various command line options pertaining to the
630# libraries needed when linking. There are "Proj" libs
631# (defined by the user's project) and "LLVM" libs (defined
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000632# by the LLVM project).
Reid Spencera80f1672005-05-19 00:37:31 +0000633#---------------------------------------------------------
Andrew Lenharth6b62b472005-08-13 05:09:50 +0000634
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000635ifdef USEDLIBS
Reid Spencera80f1672005-05-19 00:37:31 +0000636ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
637ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000638ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
639ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
640endif
641
642ifdef LLVMLIBS
Reid Spencera80f1672005-05-19 00:37:31 +0000643LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
644LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
Reid Spencera80f1672005-05-19 00:37:31 +0000645LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
Reid Spencera80f1672005-05-19 00:37:31 +0000646LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000647endif
648
Chris Lattner68c97542006-09-04 05:23:20 +0000649ifeq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000650ifdef LINK_COMPONENTS
Chris Lattner68c97542006-09-04 05:23:20 +0000651
652# If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
653# clean in tools, then do a make in tools (instead of at the top level).
654$(LLVM_CONFIG):
655 @echo "*** llvm-config doesn't exist - rebuilding it."
656 @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
657
658$(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
659
660ProjLibsOptions = $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
661ProjLibsPaths = $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
Chris Lattnerf9ac33d2006-09-04 04:47:21 +0000662endif
Chris Lattner9a4a92e2006-09-04 04:50:10 +0000663endif
Reid Spencera80f1672005-05-19 00:37:31 +0000664
665###############################################################################
Reid Spencer81cd0492004-10-23 20:04:14 +0000666# Library Build Rules: Four ways to build a library
667###############################################################################
Chris Lattner2f7c9632001-06-06 20:29:01 +0000668
Reid Spencerd78077d2004-12-05 05:17:22 +0000669#---------------------------------------------------------
670# Bytecode Module Targets:
671# If the user set MODULE_NAME then they want to build a
672# bytecode module from the sources. We compile all the
673# sources and link it together into a single bytecode
674# module.
675#---------------------------------------------------------
676
677ifdef MODULE_NAME
Reid Spencere9fa5442005-02-14 21:54:08 +0000678ifeq ($(strip $(LLVMGCC)),)
Reid Spencer83745dd2005-05-13 18:32:54 +0000679$(warning Modules require llvm-gcc but no llvm-gcc is available ****)
Reid Spencere9fa5442005-02-14 21:54:08 +0000680else
Reid Spencerd78077d2004-12-05 05:17:22 +0000681
682Module := $(LibDir)/$(MODULE_NAME).bc
Reid Spencer78ede562006-04-12 18:21:35 +0000683LinkModule := $(GCCLD) -L$(CFERuntimeLibDir)
684
Reid Spencerd78077d2004-12-05 05:17:22 +0000685
686ifdef EXPORTED_SYMBOL_FILE
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000687LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencerd78077d2004-12-05 05:17:22 +0000688endif
689
690$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
Reid Spencer83745dd2005-05-13 18:32:54 +0000691 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
Reid Spencerd78077d2004-12-05 05:17:22 +0000692 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
693
694all-local:: $(Module)
695
696clean-local::
697ifneq ($(strip $(Module)),)
698 -$(Verb) $(RM) -f $(Module)
699endif
700
Reid Spencerefe3a822004-12-13 07:38:07 +0000701ifdef BYTECODE_DESTINATION
702ModuleDestDir := $(BYTECODE_DESTINATION)
703else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000704ModuleDestDir := $(PROJ_libdir)
Reid Spencerefe3a822004-12-13 07:38:07 +0000705endif
Reid Spencerd78077d2004-12-05 05:17:22 +0000706
Reid Spencerefe3a822004-12-13 07:38:07 +0000707DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
708
709install-module:: $(DestModule)
Reid Spencerd78077d2004-12-05 05:17:22 +0000710install-local:: $(DestModule)
711
Reid Spencerefe3a822004-12-13 07:38:07 +0000712$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencerd78077d2004-12-05 05:17:22 +0000713 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
Reid Spencerd77a4c02005-02-24 21:30:37 +0000714 $(Verb) $(DataInstall) $(Module) $(DestModule)
Reid Spencerd78077d2004-12-05 05:17:22 +0000715
716uninstall-local::
717 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
718 -$(Verb) $(RM) -f $(DestModule)
719
720endif
Reid Spencere9fa5442005-02-14 21:54:08 +0000721endif
Brian Gaekeecc92bf2004-01-22 22:53:48 +0000722
Reid Spencer81cd0492004-10-23 20:04:14 +0000723# if we're building a library ...
Chris Lattner2f7c9632001-06-06 20:29:01 +0000724ifdef LIBRARYNAME
Vikram S. Advefe346892001-07-15 13:16:47 +0000725
Chris Lattner0100eab2002-09-16 22:36:42 +0000726# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000727LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencer87e645c2005-01-11 04:31:07 +0000728ifdef LOADABLE_MODULE
729LibName.LA := $(LibDir)/$(LIBRARYNAME).la
730else
Reid Spencerf88808a2004-10-30 09:19:36 +0000731LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
Reid Spencer87e645c2005-01-11 04:31:07 +0000732endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000733LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
734LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer32f7e422004-12-02 09:28:21 +0000735LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000736
Reid Spencer81cd0492004-10-23 20:04:14 +0000737#---------------------------------------------------------
738# Shared Library Targets:
739# If the user asked for a shared library to be built
740# with the SHARED_LIBRARY variable, then we provide
741# targets for building them.
742#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000743ifdef SHARED_LIBRARY
744
Reid Spencerf88808a2004-10-30 09:19:36 +0000745all-local:: $(LibName.LA)
Reid Spencerf206bd72004-10-22 21:01:56 +0000746
Reid Spencera80f1672005-05-19 00:37:31 +0000747ifdef LINK_LIBS_IN_SHARED
Reid Spencere6458c32006-08-07 23:12:15 +0000748ifdef LOADABLE_MODULE
749SharedLibKindMessage := "Lodable Module"
750else
751SharedLibKindMessage := "Shared Library"
752endif
Reid Spencera80f1672005-05-19 00:37:31 +0000753$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
Reid Spencere6458c32006-08-07 23:12:15 +0000754 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
755 $(LIBRARYNAME)$(SHLIBEXT)
756 $(Verb) $(LTLink) -o $@ $(ObjectsLO) $(ProjLibsOptions) \
757 $(LLVMLibsOptions)
Reid Spencera80f1672005-05-19 00:37:31 +0000758 $(Verb) $(LTInstall) $@ $(LibDir)
759else
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000760$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000761 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencere6458c32006-08-07 23:12:15 +0000762 $(Verb) $(LTLink) -o $@ $(ObjectsLO)
Reid Spencerf88808a2004-10-30 09:19:36 +0000763 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencera80f1672005-05-19 00:37:31 +0000764endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000765
766clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000767ifneq ($(strip $(LibName.LA)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000768 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000769endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000770
Reid Spencerba6a3db2005-01-16 02:20:54 +0000771DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf206bd72004-10-22 21:01:56 +0000772
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000773install-local:: $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000774
Reid Spencerba6a3db2005-01-16 02:20:54 +0000775$(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000776 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000777 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000778 $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
Reid Spencer12a3a052004-10-24 07:53:21 +0000779
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000780uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000781 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000782 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
Reid Spencer12a3a052004-10-24 07:53:21 +0000783
Reid Spencerf206bd72004-10-22 21:01:56 +0000784endif
785
Reid Spencer81cd0492004-10-23 20:04:14 +0000786#---------------------------------------------------------
787# Bytecode Library Targets:
788# If the user asked for a bytecode library to be built
789# with the BYTECODE_LIBRARY variable, then we provide
790# targets for building them.
791#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000792ifdef BYTECODE_LIBRARY
Reid Spencere9fa5442005-02-14 21:54:08 +0000793ifeq ($(strip $(LLVMGCC)),)
Reid Spencer83745dd2005-05-13 18:32:54 +0000794$(warning Bytecode libraries require llvm-gcc which could not be found ****)
Reid Spencere9fa5442005-02-14 21:54:08 +0000795else
Reid Spencerf206bd72004-10-22 21:01:56 +0000796
Reid Spencer32f7e422004-12-02 09:28:21 +0000797all-local:: $(LibName.BCA)
798
799ifdef EXPORTED_SYMBOL_FILE
Chris Lattner11c25cf2006-05-30 16:38:06 +0000800BCLinkLib = $(GCCLD) -L$(CFERuntimeLibDir) \
801 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer32f7e422004-12-02 09:28:21 +0000802
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000803$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +0000804 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +0000805 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
806 "(internalize)"
Chris Lattnere3d98f12004-12-02 21:23:43 +0000807 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencer85d55ad2004-12-13 03:59:35 +0000808 $(Verb) $(RM) -f $@
Reid Spencer32f7e422004-12-02 09:28:21 +0000809 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencerf206bd72004-10-22 21:01:56 +0000810else
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000811$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +0000812 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +0000813 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencer85d55ad2004-12-13 03:59:35 +0000814 $(Verb) $(RM) -f $@
Reid Spencer32f7e422004-12-02 09:28:21 +0000815 $(Verb) $(LArchive) $@ $(ObjectsBC)
816
Reid Spencerf206bd72004-10-22 21:01:56 +0000817endif
818
Reid Spencer81cd0492004-10-23 20:04:14 +0000819clean-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000820ifneq ($(strip $(LibName.BCA)),)
821 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000822endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000823
Reid Spencer65086be2004-12-13 07:28:21 +0000824ifdef BYTECODE_DESTINATION
825BytecodeDestDir := $(BYTECODE_DESTINATION)
826else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000827BytecodeDestDir := $(PROJ_libdir)
Reid Spencer65086be2004-12-13 07:28:21 +0000828endif
829
830DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
Reid Spencer32f7e422004-12-02 09:28:21 +0000831
Reid Spencerd4bd3752004-12-03 20:08:48 +0000832install-bytecode-local:: $(DestBytecodeLib)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000833
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000834install-local:: $(DestBytecodeLib)
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000835
Reid Spencer65086be2004-12-13 07:28:21 +0000836$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
Reid Spencer32f7e422004-12-02 09:28:21 +0000837 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerdcc53752005-02-24 21:36:32 +0000838 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000839
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000840uninstall-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000841 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000842 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000843
844endif
Reid Spencere9fa5442005-02-14 21:54:08 +0000845endif
Vikram S. Adve15bd3ad2002-08-02 18:34:12 +0000846
Reid Spencerf88808a2004-10-30 09:19:36 +0000847#---------------------------------------------------------
848# ReLinked Library Targets:
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000849# If the user explicitly requests a relinked library with
850# BUILD_RELINKED, provide it. Otherwise, if they specify
851# neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
852# them one.
Reid Spencerf88808a2004-10-30 09:19:36 +0000853#---------------------------------------------------------
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000854ifndef BUILD_ARCHIVE
Chris Lattner76d98ba2002-07-23 17:56:16 +0000855ifndef DONT_BUILD_RELINKED
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000856BUILD_RELINKED = 1
857endif
858endif
859
860ifdef BUILD_RELINKED
Reid Spencerf206bd72004-10-22 21:01:56 +0000861
Reid Spencerf88808a2004-10-30 09:19:36 +0000862all-local:: $(LibName.O)
863
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000864$(LibName.O): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000865 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencere6458c32006-08-07 23:12:15 +0000866 $(Verb) $(LTRelink) -o $@ $(ObjectsO)
Reid Spencerf206bd72004-10-22 21:01:56 +0000867
Reid Spencer81cd0492004-10-23 20:04:14 +0000868clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000869ifneq ($(strip $(LibName.O)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000870 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencer12a3a052004-10-24 07:53:21 +0000871endif
872
Reid Spencerba6a3db2005-01-16 02:20:54 +0000873DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
Reid Spencer12a3a052004-10-24 07:53:21 +0000874
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000875install-local:: $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000876
Reid Spencerba6a3db2005-01-16 02:20:54 +0000877$(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000878 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000879 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000880
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000881uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000882 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000883 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000884
Chris Lattner76d98ba2002-07-23 17:56:16 +0000885endif
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000886
Reid Spencerf88808a2004-10-30 09:19:36 +0000887#---------------------------------------------------------
888# Archive Library Targets:
889# If the user wanted a regular archive library built,
890# then we provide targets for building them.
891#---------------------------------------------------------
Chris Lattner76d98ba2002-07-23 17:56:16 +0000892ifdef BUILD_ARCHIVE
Chris Lattner76d98ba2002-07-23 17:56:16 +0000893
Reid Spencerf88808a2004-10-30 09:19:36 +0000894all-local:: $(LibName.A)
895
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000896$(LibName.A): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000897 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000898 -$(Verb) $(RM) -f $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000899 $(Verb) $(Archive) $@ $(ObjectsO)
900 $(Verb) $(Ranlib) $@
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000901
Reid Spencer81cd0492004-10-23 20:04:14 +0000902clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000903ifneq ($(strip $(LibName.A)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000904 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000905endif
906
Reid Spencerba6a3db2005-01-16 02:20:54 +0000907DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
Reid Spencer12a3a052004-10-24 07:53:21 +0000908
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000909install-local:: $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000910
Reid Spencerba6a3db2005-01-16 02:20:54 +0000911$(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000912 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000913 $(Verb) $(MKDIR) $(PROJ_libdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000914 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000915
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000916uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000917 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000918 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000919
920endif
921
922# endif LIBRARYNAME
Reid Spencerf206bd72004-10-22 21:01:56 +0000923endif
924
Reid Spencerdcba7782004-10-24 08:21:04 +0000925###############################################################################
926# Tool Build Rules: Build executable tool based on TOOLNAME option
927###############################################################################
928
Chris Lattner07c7c192001-09-07 22:57:58 +0000929ifdef TOOLNAME
930
Reid Spencerf88808a2004-10-30 09:19:36 +0000931#---------------------------------------------------------
932# Set up variables for building a tool.
933#---------------------------------------------------------
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000934ifdef EXAMPLE_TOOL
Reid Spencer98a2d982005-05-19 21:03:11 +0000935ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000936else
Reid Spencer98a2d982005-05-19 21:03:11 +0000937ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000938endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000939
Reid Spencerf88808a2004-10-30 09:19:36 +0000940#---------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000941# Provide targets for building the tools
942#---------------------------------------------------------
943all-local:: $(ToolBuildPath)
John Criswell8224df92003-06-27 16:58:44 +0000944
Reid Spencer81cd0492004-10-23 20:04:14 +0000945clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000946ifneq ($(strip $(ToolBuildPath)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000947 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencer12a3a052004-10-24 07:53:21 +0000948endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000949
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000950ifdef EXAMPLE_TOOL
951$(ToolBuildPath): $(ExmplDir)/.dir
952else
953$(ToolBuildPath): $(ToolDir)/.dir
954endif
955
Chris Lattner68c97542006-09-04 05:23:20 +0000956$(ToolBuildPath): $(ObjectsO) $(LLVM_CONFIG) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000957 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencere6458c32006-08-07 23:12:15 +0000958 $(Verb) $(LTLink) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
Reid Spencer10536582006-05-16 06:25:14 +0000959 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
Chris Lattnere2dcbe02006-02-14 04:25:54 +0000960 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
961 $(StripWarnMsg)
Reid Spencer12a3a052004-10-24 07:53:21 +0000962
Reid Spencerba6a3db2005-01-16 02:20:54 +0000963DestTool = $(PROJ_bindir)/$(TOOLNAME)
Reid Spencer12a3a052004-10-24 07:53:21 +0000964
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000965install-local:: $(DestTool)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000966
Reid Spencerba6a3db2005-01-16 02:20:54 +0000967$(DestTool): $(PROJ_bindir) $(ToolBuildPath)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000968 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencerc43b1d42005-02-24 03:56:32 +0000969 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000970
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000971uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000972 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000973 -$(Verb) $(RM) -f $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000974
Reid Spencerf206bd72004-10-22 21:01:56 +0000975endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000976
Reid Spencerf88808a2004-10-30 09:19:36 +0000977###############################################################################
978# Object Build Rules: Build object files based on sources
979###############################################################################
980
Duraid Madinacbbc1842006-02-15 03:23:26 +0000981# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
982ifeq ($(OS),HP-UX)
983 DISABLE_AUTO_DEPENDENCIES=1
984endif
985
Chris Lattner085c7152006-06-21 20:58:03 +0000986ifdef SHARED_LIBRARY
987PIC_FLAG = "(PIC)"
988MAYBE_PIC_Compile.CXX = $(LTCompile.CXX)
989MAYBE_PIC_Compile.C = $(LTCompile.C)
990else
991MAYBE_PIC_Compile.CXX = $(Compile.CXX)
992MAYBE_PIC_Compile.C = $(Compile.C)
993endif
994
Reid Spencerf88808a2004-10-30 09:19:36 +0000995# Provide rule sets for when dependency generation is enabled
Reid Spencerf206bd72004-10-22 21:01:56 +0000996ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000997
Reid Spencerf88808a2004-10-30 09:19:36 +0000998#---------------------------------------------------------
999# Create .lo files in the ObjDir directory from the .cpp and .c files...
1000#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001001
Chris Lattner2a023902004-12-16 17:28:50 +00001002$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001003 $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
1004 $(Verb) if $(MAYBE_PIC_Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
1005 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
1006 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +00001007
Chris Lattnerf60c1702005-02-04 21:28:50 +00001008$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001009 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1010 $(Verb) if $(MAYBE_PIC_Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
Chris Lattnerf60c1702005-02-04 21:28:50 +00001011 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
1012 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
1013
Chris Lattner2a023902004-12-16 17:28:50 +00001014$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001015 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1016 $(Verb) if $(MAYBE_PIC_Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001017 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
1018 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +00001019
Reid Spencerf88808a2004-10-30 09:19:36 +00001020#---------------------------------------------------------
Chris Lattnerf60c1702005-02-04 21:28:50 +00001021# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
Reid Spencerf88808a2004-10-30 09:19:36 +00001022#---------------------------------------------------------
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001023
1024$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001025 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001026 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1027 $< -o $@ -S -emit-llvm ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001028 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1029 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +00001030
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001031$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001032 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001033 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1034 $< -o $@ -S -emit-llvm ; \
Chris Lattnerf60c1702005-02-04 21:28:50 +00001035 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1036 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1037
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001038$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001039 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001040 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" \
1041 $< -o $@ -S -emit-llvm ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001042 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1043 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +00001044
Reid Spencerf88808a2004-10-30 09:19:36 +00001045# Provide alternate rule sets if dependencies are disabled
Reid Spencerf206bd72004-10-22 21:01:56 +00001046else
1047
Chris Lattner2a023902004-12-16 17:28:50 +00001048$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001049 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1050 $(MAYBE_PIC_Compile.CXX) $< -o $@
Reid Spencer81cd0492004-10-23 20:04:14 +00001051
Chris Lattnerf60c1702005-02-04 21:28:50 +00001052$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001053 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1054 $(MAYBE_PIC_Compile.CXX) $< -o $@
Chris Lattnerf60c1702005-02-04 21:28:50 +00001055
Chris Lattner2a023902004-12-16 17:28:50 +00001056$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001057 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1058 $(MAYBE_PIC_Compile.C) $< -o $@
Reid Spencerf206bd72004-10-22 21:01:56 +00001059
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001060$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001061 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001062 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Reid Spencerf206bd72004-10-22 21:01:56 +00001063
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001064$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001065 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001066 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Chris Lattnerf60c1702005-02-04 21:28:50 +00001067
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001068$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001069 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001070 $(BCCompile.C) $< -o $@ -S -emit-llvm
Brian Gaeke0f148bc2003-12-10 00:26:28 +00001071
Chris Lattner07c7c192001-09-07 22:57:58 +00001072endif
1073
Chris Lattner161a84e2006-06-21 21:01:20 +00001074
1075## Rules for building preprocessed (.i/.ii) outputs.
1076$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1077 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1078 $(Verb) $(Preprocess.CXX) $< -o $@
1079
1080$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1081 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1082 $(Verb) $(Preprocess.CXX) $< -o $@
1083
1084 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1085 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1086 $(Verb) $(Preprocess.C) $< -o $@
1087
1088
1089$(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1090 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1091 $(MAYBE_PIC_Compile.CXX) $< -o $@ -S
1092
1093$(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1094 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1095 $(MAYBE_PIC_Compile.CXX) $< -o $@ -S
1096
1097$(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1098 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1099 $(MAYBE_PIC_Compile.C) $< -o $@ -S
1100
1101
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001102# make the C and C++ compilers strip debug info out of bytecode libraries.
1103ifdef DEBUG_RUNTIME
1104$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1105 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Chris Lattner5b59d7c2006-03-09 06:00:05 +00001106 $(Verb) $(GCCAS) $< -o $@
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001107else
1108$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1109 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Chris Lattner5b59d7c2006-03-09 06:00:05 +00001110 $(Verb) $(GCCAS) -strip-debug $< -o $@
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001111endif
1112
1113
Reid Spencerf88808a2004-10-30 09:19:36 +00001114#---------------------------------------------------------
1115# Provide rule to build .bc files from .ll sources,
1116# regardless of dependencies
1117#---------------------------------------------------------
1118$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001119 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +00001120 $(Verb) $(LLVMAS) $< -f -o $@
1121
1122###############################################################################
1123# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1124###############################################################################
Chris Lattner0c4f4fe2003-08-15 02:18:35 +00001125
Reid Spencerf206bd72004-10-22 21:01:56 +00001126ifdef TARGET
1127
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001128TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1129 $(LLVM_SRC_ROOT)/lib/Target/Target.td \
Chris Lattner8a87f5f2006-03-03 01:54:54 +00001130 $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td \
1131 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td)
Reid Spencerf88808a2004-10-30 09:19:36 +00001132INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Chris Lattner2a023902004-12-16 17:28:50 +00001133INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1134.PRECIOUS: $(INCTMPFiles) $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001135
Chris Lattner2a023902004-12-16 17:28:50 +00001136# All of these files depend on tblgen and the .td files.
1137$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001138
Chris Lattnerf86914d2004-12-16 17:38:56 +00001139# INCFiles rule: All of the tblgen generated files are emitted to
1140# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1141# us to only "touch" the real file if the contents of it change. IOW, if
1142# tblgen is modified, all of the .inc.tmp files are regereated, but no
1143# dependencies of the .inc files are, unless the contents of the .inc file
1144# changes.
1145$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
Reid Spencerafdc82c2004-12-16 18:26:53 +00001146 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
Chris Lattner2a023902004-12-16 17:28:50 +00001147
1148$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1149$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001150 $(Echo) "Building $(<F) register names with tblgen"
1151 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001152
Chris Lattner2a023902004-12-16 17:28:50 +00001153$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1154$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001155 $(Echo) "Building $(<F) register information header with tblgen"
1156 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001157
Chris Lattner2a023902004-12-16 17:28:50 +00001158$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1159$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001160 $(Echo) "Building $(<F) register info implementation with tblgen"
1161 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001162
Chris Lattner2a023902004-12-16 17:28:50 +00001163$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1164$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001165 $(Echo) "Building $(<F) instruction names with tblgen"
1166 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001167
Chris Lattner2a023902004-12-16 17:28:50 +00001168$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1169$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001170 $(Echo) "Building $(<F) instruction information with tblgen"
1171 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001172
Chris Lattner2a023902004-12-16 17:28:50 +00001173$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1174$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001175 $(Echo) "Building $(<F) assembly writer with tblgen"
1176 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001177
Chris Lattner22f937a2004-12-16 17:34:04 +00001178$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1179$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1180 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Reid Spencerf88808a2004-10-30 09:19:36 +00001181 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001182
Chris Lattner2a023902004-12-16 17:28:50 +00001183$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1184$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001185 $(Echo) "Building $(<F) code emitter with tblgen"
1186 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001187
Chris Lattner33f98bd2005-09-03 01:15:25 +00001188$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1189$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1190 $(Echo) "Building $(<F) instruction selector implementation with tblgen"
1191 $(Verb) $(TableGen) -gen-dag-isel -o $@ $<
1192
Jim Laskey9ed90322005-10-21 19:05:19 +00001193$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1194$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1195 $(Echo) "Building $(<F) subtarget information with tblgen"
1196 $(Verb) $(TableGen) -gen-subtarget -o $@ $<
Chris Lattner33f98bd2005-09-03 01:15:25 +00001197
Reid Spencer81cd0492004-10-23 20:04:14 +00001198clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001199 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001200
1201endif
Chris Lattner0c4f4fe2003-08-15 02:18:35 +00001202
Reid Spencerf88808a2004-10-30 09:19:36 +00001203###############################################################################
1204# LEX AND YACC: Provide rules for generating sources with lex and yacc
1205###############################################################################
Chris Lattnerdb644dd2003-01-16 22:44:19 +00001206
Reid Spencerf88808a2004-10-30 09:19:36 +00001207#---------------------------------------------------------
1208# Provide rules for generating a .cpp source file from
1209# (f)lex input sources.
1210#---------------------------------------------------------
1211
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001212LexFiles := $(filter %.l,$(Sources))
Reid Spencerf88808a2004-10-30 09:19:36 +00001213
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001214ifneq ($(LexFiles),)
1215
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001216# Cancel built-in rules for lex
1217%.c: %.l
1218%.cpp: %.l
Reid Spencerf88808a2004-10-30 09:19:36 +00001219
Chris Lattner8104b4c2006-02-14 05:12:00 +00001220all:: $(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs)
1221
Reid Spencerf88808a2004-10-30 09:19:36 +00001222# Note the extra sed filtering here, used to cut down on the warnings emited
1223# by GCC. The last line is a gross hack to work around flex aparently not
1224# being able to resize the buffer on a large token input. Currently, for
1225# uninitialized string buffers in LLVM we can generate very long tokens, so
1226# this is a hack around it.
Chris Lattner92fc9b02003-08-15 20:00:47 +00001227# FIXME. (f.e. char Buffer[10000] )
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001228$(PROJ_SRC_DIR)/%.cpp: $(PROJ_SRC_DIR)/%.l
Reid Spencer993b95e2004-12-10 19:44:16 +00001229 $(Echo) Flexing $*.l
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001230 $(Verb) $(FLEX) -t $(PROJ_SRC_DIR)/$*.l | \
Reid Spencerf206bd72004-10-22 21:01:56 +00001231 $(SED) 's/void yyunput/inline void yyunput/' | \
1232 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1233 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001234 > $(PROJ_SRC_DIR)/$*.cpp
Chris Lattner8104b4c2006-02-14 05:12:00 +00001235
1236# IFF the .l file has changed since it was last checked into CVS, copy the .l
1237# file to .l.cvs and the generated .cpp file to .cpp.cvs. We use this mechanism
1238# so that people without flex can build LLVM by copying the .cvs files to the
1239# source location and building them.
1240$(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1241$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattner1e612822006-02-16 05:10:48 +00001242 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs || \
Chris Lattner8104b4c2006-02-14 05:12:00 +00001243 ($(CP) $< $@; $(CP) $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001244
Chris Lattner8104b4c2006-02-14 05:12:00 +00001245$(LexFiles:%.l=$(ObjDir)/%.o) : \
1246$(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
Chris Lattner2f7c9632001-06-06 20:29:01 +00001247
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001248clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001249 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001250
Reid Spencerf88808a2004-10-30 09:19:36 +00001251endif
1252
1253#---------------------------------------------------------
1254# Provide rules for generating a .cpp and .h source files
1255# from yacc (bison) input sources.
1256#---------------------------------------------------------
1257
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001258YaccFiles := $(filter %.y,$(Sources))
1259ifneq ($(YaccFiles),)
Reid Spencerf88808a2004-10-30 09:19:36 +00001260
1261.PRECIOUS: $(YaccOutput)
1262
Chris Lattnerb0240b22006-02-15 07:23:05 +00001263all:: $(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs)
Chris Lattnerc38a9752006-02-15 07:16:57 +00001264
Reid Spencerf88808a2004-10-30 09:19:36 +00001265# Cancel built-in rules for yacc
1266%.c: %.y
1267%.cpp: %.y
1268%.h: %.y
1269
Reid Spencerc49a8632005-12-21 23:17:06 +00001270# Rule for building the bison based parsers...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001271$(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
Reid Spencer917cf122006-08-24 22:41:20 +00001272ifneq ($(BISON),)
Reid Spencerf88808a2004-10-30 09:19:36 +00001273 $(Echo) "Bisoning $*.y"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001274 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1275 $(Verb) $(MV) -f $*.tab.c $(PROJ_SRC_DIR)/$*.cpp
1276 $(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
Reid Spencer917cf122006-08-24 22:41:20 +00001277else
1278 $(Echo) "Bison of $*.y SKIPPED -- bison not found"
1279endif
Chris Lattner2f7c9632001-06-06 20:29:01 +00001280
Chris Lattnerc38a9752006-02-15 07:16:57 +00001281# IFF the .y file has changed since it was last checked into CVS, copy the .y
1282# file to .y.cvs and the generated .cpp/.h file to .cpp.cvs/.h.cvs. We use this
1283# mechanism so that people without flex can build LLVM by copying the .cvs files
1284# to the source location and building them.
1285$(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1286$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattner1e612822006-02-16 05:10:48 +00001287 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs || \
Chris Lattnerc38a9752006-02-15 07:16:57 +00001288 ($(CP) $< $@; \
Chris Lattnerb0240b22006-02-15 07:23:05 +00001289 $(CP) $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs; \
Chris Lattnerc38a9752006-02-15 07:16:57 +00001290 $(CP) $(PROJ_SRC_DIR)/$*.h $(PROJ_SRC_DIR)/$*.h.cvs)
Reid Spencerc49a8632005-12-21 23:17:06 +00001291
Chris Lattnerc38a9752006-02-15 07:16:57 +00001292
1293$(YaccFiles:%.y=$(ObjDir)/%.o): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
1294
1295YaccOutput := $(YaccFiles:%.y=%.output)
Reid Spencerc49a8632005-12-21 23:17:06 +00001296
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001297clean-local::
Reid Spencerc49a8632005-12-21 23:17:06 +00001298 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencerf88808a2004-10-30 09:19:36 +00001299endif
Chris Lattner2f7c9632001-06-06 20:29:01 +00001300
Reid Spencerf88808a2004-10-30 09:19:36 +00001301###############################################################################
1302# OTHER RULES: Other rules needed
1303###############################################################################
Reid Spencerf206bd72004-10-22 21:01:56 +00001304
Chris Lattner23d47392003-01-16 21:06:18 +00001305# To create postscript files from dot files...
John Criswell4ffb8442003-10-02 19:02:02 +00001306ifneq ($(DOT),false)
Chris Lattner23d47392003-01-16 21:06:18 +00001307%.ps: %.dot
Reid Spencerf206bd72004-10-22 21:01:56 +00001308 $(DOT) -Tps < $< > $@
John Criswell3ef61af2003-06-30 21:59:07 +00001309else
1310%.ps: %.dot
Reid Spencerf88808a2004-10-30 09:19:36 +00001311 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell3ef61af2003-06-30 21:59:07 +00001312endif
Chris Lattner23d47392003-01-16 21:06:18 +00001313
John Criswell0a6e6aa2003-09-06 14:44:17 +00001314# This rules ensures that header files that are removed still have a rule for
1315# which they can be "generated." This allows make to ignore them and
1316# reproduce the dependency lists.
John Criswella8391af2003-09-18 18:37:08 +00001317%.h:: ;
Chris Lattnerf60c1702005-02-04 21:28:50 +00001318%.hpp:: ;
John Criswell0a6e6aa2003-09-06 14:44:17 +00001319
Reid Spencerf88808a2004-10-30 09:19:36 +00001320# Define clean-local to clean the current directory. Note that this uses a
1321# very conservative approach ensuring that empty variables do not cause
1322# errors or disastrous removal.
Reid Spencer81cd0492004-10-23 20:04:14 +00001323clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001324ifneq ($(strip $(ObjDir)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001325 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencer12a3a052004-10-24 07:53:21 +00001326endif
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001327 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke8625f682004-01-21 19:53:11 +00001328ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001329 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke8625f682004-01-21 19:53:11 +00001330endif
John Criswell3ef61af2003-06-30 21:59:07 +00001331
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001332clean-all-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001333 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001334
Reid Spencerf88808a2004-10-30 09:19:36 +00001335# Build tags database for Emacs/Xemacs:
Reid Spenceraee67e62004-11-12 02:27:36 +00001336tags:: TAGS CTAGS
1337
Reid Spencerf88808a2004-10-30 09:19:36 +00001338TAGS:
Reid Spencerba6a3db2005-01-16 02:20:54 +00001339 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1340 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1341 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1342 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spenceraee67e62004-11-12 02:27:36 +00001343 -name '*.cpp' -o -name '*.h' | \
Reid Spencerf88808a2004-10-30 09:19:36 +00001344 $(ETAGS) $(ETAGSFLAGS) -
1345
Reid Spenceraee67e62004-11-12 02:27:36 +00001346CTAGS:
Reid Spencerba6a3db2005-01-16 02:20:54 +00001347 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1348 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1349 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1350 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spenceraee67e62004-11-12 02:27:36 +00001351 \( -name '*.cpp' -o -name '*.h' \) -print | \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001352 ctags -ImtT -o $(PROJ_OBJ_ROOT)/CTAGS -L -
Reid Spenceraee67e62004-11-12 02:27:36 +00001353
1354
Reid Spencer81cd0492004-10-23 20:04:14 +00001355###############################################################################
1356# DEPENDENCIES: Include the dependency files if we should
1357###############################################################################
Chris Lattnere9d7d702003-08-22 14:10:16 +00001358ifndef DISABLE_AUTO_DEPENDENCIES
1359
Reid Spencer81cd0492004-10-23 20:04:14 +00001360# If its not one of the cleaning targets
Chris Lattner68c97542006-09-04 05:23:20 +00001361ifneq ($(strip $(filter-out clean clean-local dist-clean,$(MAKECMDGOALS)))),)
Reid Spencerf206bd72004-10-22 21:01:56 +00001362
Reid Spencer81cd0492004-10-23 20:04:14 +00001363# Get the list of dependency files
Reid Spencerf88808a2004-10-30 09:19:36 +00001364DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Chris Lattner8104b4c2006-02-14 05:12:00 +00001365DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
Misha Brukmanb891ffb2003-11-09 21:36:19 +00001366
Reid Spencer81cd0492004-10-23 20:04:14 +00001367-include /dev/null $(DependFiles)
1368
John Criswell48ecca62003-08-12 18:51:51 +00001369endif
Chris Lattner598222b2003-08-18 17:27:40 +00001370
Reid Spencerf88808a2004-10-30 09:19:36 +00001371endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001372
Reid Spencer100080c2004-10-25 08:27:37 +00001373###############################################################################
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001374# CHECK: Running the test suite
1375###############################################################################
1376
1377check::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001378 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1379 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001380 $(EchoCmd) Running test suite ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001381 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001382 TESTSUITE=$(TESTSUITE) ; \
1383 else \
1384 $(EchoCmd) No Makefile in test directory ; \
1385 fi ; \
1386 else \
1387 $(EchoCmd) No test directory ; \
1388 fi
1389
1390###############################################################################
Reid Spencerf88808a2004-10-30 09:19:36 +00001391# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer100080c2004-10-25 08:27:37 +00001392###############################################################################
1393
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001394#------------------------------------------------------------------------
1395# Define distribution related variables
1396#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +00001397DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1398DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1399TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1400DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1401DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1402DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
Reid Spencer100080c2004-10-25 08:27:37 +00001403DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1404 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001405 Makefile.config.in configure autoconf
1406DistOther := $(notdir $(wildcard \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001407 $(PROJ_SRC_DIR)/*.h \
1408 $(PROJ_SRC_DIR)/*.td \
1409 $(PROJ_SRC_DIR)/*.def \
1410 $(PROJ_SRC_DIR)/*.ll \
1411 $(PROJ_SRC_DIR)/*.in))
Reid Spencerf88808a2004-10-30 09:19:36 +00001412DistSubDirs := $(SubDirs)
Reid Spencerfc66af42004-11-29 05:00:33 +00001413DistSources = $(Sources) $(EXTRA_DIST)
1414DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer100080c2004-10-25 08:27:37 +00001415
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001416#------------------------------------------------------------------------
1417# We MUST build distribution with OBJ_DIR != SRC_DIR
1418#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +00001419ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001420dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerf88808a2004-10-30 09:19:36 +00001421 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001422
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001423else
1424
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001425#------------------------------------------------------------------------
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001426# Prevent attempt to run dist targets from anywhere but the top level
1427#------------------------------------------------------------------------
1428ifneq ($(LEVEL),.)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001429dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001430 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001431else
1432
1433#------------------------------------------------------------------------
1434# Provide the top level targets
1435#------------------------------------------------------------------------
1436
Reid Spencerf88808a2004-10-30 09:19:36 +00001437dist-gzip:: $(DistTarGZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001438
Reid Spencer81546582004-12-04 22:34:09 +00001439$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001440 $(Echo) Packing gzipped distribution tar file.
Reid Spencerba6a3db2005-01-16 02:20:54 +00001441 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
Reid Spencerfc66af42004-11-29 05:00:33 +00001442 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001443
Reid Spencerf88808a2004-10-30 09:19:36 +00001444dist-bzip2:: $(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001445
Reid Spencer81546582004-12-04 22:34:09 +00001446$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001447 $(Echo) Packing bzipped distribution tar file.
Reid Spencerba6a3db2005-01-16 02:20:54 +00001448 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
Reid Spencerfc66af42004-11-29 05:00:33 +00001449 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001450
Reid Spencerf88808a2004-10-30 09:19:36 +00001451dist-zip:: $(DistZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001452
Reid Spencer81546582004-12-04 22:34:09 +00001453$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001454 $(Echo) Packing zipped distribution file.
1455 $(Verb) rm -f $(DistZip)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001456 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001457
1458dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001459 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001460
Reid Spencer3a468752005-01-28 19:52:32 +00001461DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001462
Reid Spencer81546582004-12-04 22:34:09 +00001463dist-check:: $(DistTarGZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001464 $(Echo) Checking distribution tar file.
1465 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001466 $(RM) -rf $(DistCheckDir) ; \
1467 fi
Reid Spencerf88808a2004-10-30 09:19:36 +00001468 $(Verb) $(MKDIR) $(DistCheckDir)
1469 $(Verb) cd $(DistCheckDir) && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001470 $(MKDIR) $(DistCheckDir)/build && \
1471 $(MKDIR) $(DistCheckDir)/install && \
1472 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1473 cd build && \
1474 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
Reid Spencer13f51932005-05-24 02:33:20 +00001475 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
Reid Spencer81546582004-12-04 22:34:09 +00001476 $(MAKE) all && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001477 $(MAKE) check && \
1478 $(MAKE) install && \
1479 $(MAKE) uninstall && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001480 $(MAKE) dist-clean && \
Reid Spencerf88808a2004-10-30 09:19:36 +00001481 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001482
1483dist-clean::
Reid Spencerf88808a2004-10-30 09:19:36 +00001484 $(Echo) Cleaning distribution files
Reid Spencer81546582004-12-04 22:34:09 +00001485 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1486 $(DistCheckDir)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001487
1488endif
1489
1490#------------------------------------------------------------------------
1491# Provide the recursive distdir target for building the distribution directory
1492#------------------------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +00001493distdir: $(DistDir)/.makedistdir
1494$(DistDir)/.makedistdir: $(DistSources)
Reid Spencerf88808a2004-10-30 09:19:36 +00001495 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001496 if test -d "$(DistDir)" ; then \
1497 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1498 exit 1 ; \
1499 fi ; \
Reid Spencer81546582004-12-04 22:34:09 +00001500 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001501 $(RM) -rf $(DistDir); \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001502 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer15b85092006-04-10 16:46:04 +00001503 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001504 fi
Reid Spencerfc66af42004-11-29 05:00:33 +00001505 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencerf88808a2004-10-30 09:19:36 +00001506 $(Verb) $(MKDIR) $(DistDir)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001507 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1508 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
Reid Spencer100080c2004-10-25 08:27:37 +00001509 for file in $(DistFiles) ; do \
1510 case "$$file" in \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001511 $(PROJ_SRC_DIR)/*) \
Reid Spencer81546582004-12-04 22:34:09 +00001512 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1513 ;; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001514 $(PROJ_SRC_ROOT)/*) \
Reid Spencer81546582004-12-04 22:34:09 +00001515 file=`echo "$$file" | \
1516 sed "s#^$$srcrootstrip/##"` \
1517 ;; \
Reid Spencer100080c2004-10-25 08:27:37 +00001518 esac; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001519 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1520 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1521 from_dir="$(PROJ_SRC_DIR)" ; \
Reid Spencer81546582004-12-04 22:34:09 +00001522 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001523 from_dir=. ; \
Reid Spencer81546582004-12-04 22:34:09 +00001524 fi ; \
1525 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001526 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1527 to_dir="$(DistDir)/$$dir"; \
1528 $(MKDIR) "$$to_dir" ; \
1529 else \
1530 to_dir="$(DistDir)"; \
1531 fi; \
1532 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1533 if test -n "$$mid_dir" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001534 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001535 fi ; \
1536 if test -d "$$from_dir/$$file"; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001537 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1538 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
Reid Spencer13f51932005-05-24 02:33:20 +00001539 cd $(PROJ_SRC_DIR) ; \
1540 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1541 ( cd $$to_dir ; $(TAR) xf - ) ; \
1542 cd $(PROJ_OBJ_DIR) ; \
1543 else \
1544 cd $$from_dir ; \
1545 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1546 ( cd $$to_dir ; $(TAR) xf - ) ; \
1547 cd $(PROJ_OBJ_DIR) ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001548 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +00001549 elif test -f "$$from_dir/$$file" ; then \
Reid Spencerafdc82c2004-12-16 18:26:53 +00001550 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001551 elif test -L "$$from_dir/$$file" ; then \
Reid Spencerafdc82c2004-12-16 18:26:53 +00001552 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001553 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer81546582004-12-04 22:34:09 +00001554 $(EchoCmd) "===== WARNING: Distribution Source " \
1555 "$$from_dir/$$file Not Found!" ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001556 elif test "$(Verb)" != '@' ; then \
1557 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001558 fi; \
1559 done
Reid Spencerf88808a2004-10-30 09:19:36 +00001560 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer100080c2004-10-25 08:27:37 +00001561 if test "$$subdir" \!= "." ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001562 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001563 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer15b85092006-04-10 16:46:04 +00001564 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
Reid Spencer056f0222006-04-07 16:06:18 +00001565 DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001566 fi; \
1567 done
Reid Spencer81546582004-12-04 22:34:09 +00001568 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer13f51932005-05-24 02:33:20 +00001569 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
Chris Lattnerb8e7aa02006-02-14 04:27:15 +00001570 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1571 -name .svn \) -print` ;\
Reid Spencer81546582004-12-04 22:34:09 +00001572 $(MAKE) dist-hook ; \
1573 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1574 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1575 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1576 -o ! -type d ! -perm -444 -exec \
1577 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1578 || chmod -R a+r $(DistDir) ; \
1579 fi
Reid Spencer100080c2004-10-25 08:27:37 +00001580
Reid Spencerf88808a2004-10-30 09:19:36 +00001581# This is invoked by distdir target, define it as a no-op to avoid errors if not
1582# defined by user.
Reid Spencer100080c2004-10-25 08:27:37 +00001583dist-hook::
1584
Reid Spencer23a70372004-10-22 23:06:30 +00001585endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001586
1587###############################################################################
Reid Spencer12a3a052004-10-24 07:53:21 +00001588# TOP LEVEL - targets only to apply at the top level directory
1589###############################################################################
1590
1591ifeq ($(LEVEL),.)
1592
1593#------------------------------------------------------------------------
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001594# Install support for the project's include files:
Reid Spencer12a3a052004-10-24 07:53:21 +00001595#------------------------------------------------------------------------
1596install-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001597 $(Echo) Installing include files
Reid Spencerba6a3db2005-01-16 02:20:54 +00001598 $(Verb) $(MKDIR) $(PROJ_includedir)
Reid Spencerc43b1d42005-02-24 03:56:32 +00001599 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001600 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer48a82f42005-02-16 15:54:03 +00001601 for hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
1602 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS ` ; do \
Reid Spencerc43b1d42005-02-24 03:56:32 +00001603 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1604 if test \! -d "$$instdir" ; then \
1605 $(EchoCmd) Making install directory $$instdir ; \
1606 $(MKDIR) $$instdir ;\
1607 fi ; \
1608 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer48a82f42005-02-16 15:54:03 +00001609 done ; \
Reid Spencer12a3a052004-10-24 07:53:21 +00001610 fi
Reid Spencer528c9802005-12-23 22:27:56 +00001611ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencerc43b1d42005-02-24 03:56:32 +00001612 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
Reid Spencer48a82f42005-02-16 15:54:03 +00001613 cd $(PROJ_OBJ_ROOT)/include && \
Reid Spencer528c9802005-12-23 22:27:56 +00001614 for hdr in `find . -type f -print | grep -v CVS` ; do \
Reid Spencerc43b1d42005-02-24 03:56:32 +00001615 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer48a82f42005-02-16 15:54:03 +00001616 done ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001617 fi
Reid Spencer528c9802005-12-23 22:27:56 +00001618endif
Reid Spencer12a3a052004-10-24 07:53:21 +00001619
1620uninstall-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001621 $(Echo) Uninstalling include files
Reid Spencerba6a3db2005-01-16 02:20:54 +00001622 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1623 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer12a3a052004-10-24 07:53:21 +00001624 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001625 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' \
1626 -o -name '*.in' ')' -print ')' | \
1627 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001628 cd $(PROJ_SRC_ROOT)/include && \
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001629 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1630 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001631 fi
Reid Spencer12a3a052004-10-24 07:53:21 +00001632
Reid Spencer12a3a052004-10-24 07:53:21 +00001633endif
1634
Reid Spencerf206bd72004-10-22 21:01:56 +00001635#------------------------------------------------------------------------
1636# Print out the directories used for building
Reid Spencerf88808a2004-10-30 09:19:36 +00001637#------------------------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001638printvars::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001639 $(Echo) "BuildMode : " '$(BuildMode)'
1640 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1641 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1642 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1643 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1644 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1645 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1646 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1647 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1648 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1649 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
Reid Spencerfe0a01e2005-02-16 16:13:02 +00001650 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
Reid Spencerba6a3db2005-01-16 02:20:54 +00001651 $(Echo) "UserTargets : " '$(UserTargets)'
1652 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1653 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1654 $(Echo) "ObjDir : " '$(ObjDir)'
1655 $(Echo) "LibDir : " '$(LibDir)'
1656 $(Echo) "ToolDir : " '$(ToolDir)'
1657 $(Echo) "ExmplDir : " '$(ExmplDir)'
1658 $(Echo) "Sources : " '$(Sources)'
1659 $(Echo) "TDFiles : " '$(TDFiles)'
1660 $(Echo) "INCFiles : " '$(INCFiles)'
1661 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
Reid Spencerfefb9ea2005-03-01 16:27:06 +00001662 $(Echo) "PreConditions: " '$(PreConditions)'
Reid Spencerba6a3db2005-01-16 02:20:54 +00001663 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1664 $(Echo) "Compile.C : " '$(Compile.C)'
1665 $(Echo) "Archive : " '$(Archive)'
1666 $(Echo) "YaccFiles : " '$(YaccFiles)'
1667 $(Echo) "LexFiles : " '$(LexFiles)'
1668 $(Echo) "Module : " '$(Module)'
Reid Spencerb48e3f82005-08-24 10:43:10 +00001669 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
Reid Spencerece13582006-04-09 23:41:14 +00001670 $(Echo) "SubDirs : " '$(SubDirs)'