blob: b719e8c130360aecc23056b94a201d081ccc1b66 [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
76ifneq ($(MakefileConfigIn),)
77PreConditions += $(MakefileConfig)
78endif
Reid Spencer77a46d22004-10-26 22:26:33 +000079
Reid Spencer53846bc2005-08-25 04:59:49 +000080preconditions: $(PreConditions)
Reid Spencer77a46d22004-10-26 22:26:33 +000081
82#------------------------------------------------------------------------
83# Make sure the BUILT_SOURCES are built first
84#------------------------------------------------------------------------
Reid Spencer97e40f12004-12-16 07:15:16 +000085$(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
Reid Spencer77a46d22004-10-26 22:26:33 +000086
87clean-local::
88ifneq ($(strip $(BUILT_SOURCES)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +000089 -$(Verb) $(RM) -f $(BUILT_SOURCES)
Reid Spencer77a46d22004-10-26 22:26:33 +000090endif
91
Reid Spencerba6a3db2005-01-16 02:20:54 +000092ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
Reid Spencer55814372004-12-16 08:00:46 +000093spotless:
Reid Spencer55814372004-12-16 08:00:46 +000094 $(Verb) if test -x config.status ; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +000095 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
Reid Spencer7ef8e662004-12-17 07:45:03 +000096 $(MKDIR) .spotless.save ; \
97 $(MV) config.status .spotless.save ; \
98 $(MV) mklib .spotless.save ; \
99 $(MV) projects .spotless.save ; \
Reid Spencer55814372004-12-16 08:00:46 +0000100 $(RM) -rf * ; \
Reid Spencer7ef8e662004-12-17 07:45:03 +0000101 $(MV) .spotless.save/config.status . ; \
102 $(MV) .spotless.save/mklib . ; \
103 $(MV) .spotless.save/projects . ; \
104 $(RM) -rf .spotless.save ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000105 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
Reid Spencer7ef8e662004-12-17 07:45:03 +0000106 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
107 $(ConfigStatusScript) ; \
Reid Spencer55814372004-12-16 08:00:46 +0000108 else \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000109 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
Reid Spencer55814372004-12-16 08:00:46 +0000110 fi
Reid Spencerc49a8632005-12-21 23:17:06 +0000111else
112spotless:
113 $(EchoCmd) "spotless target not supported for objdir == srcdir"
Reid Spencer55814372004-12-16 08:00:46 +0000114endif
115
Reid Spencerf88808a2004-10-30 09:19:36 +0000116$(BUILT_SOURCES) : $(ObjMakefiles)
Reid Spencerb7f710a2004-10-28 00:41:43 +0000117
Reid Spencer77a46d22004-10-26 22:26:33 +0000118#------------------------------------------------------------------------
119# Make sure we're not using a stale configuration
120#------------------------------------------------------------------------
Reid Spencerafdc82c2004-12-16 18:26:53 +0000121reconfigure:
Reid Spencerba6a3db2005-01-16 02:20:54 +0000122 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
123 $(Verb) cd $(PROJ_OBJ_ROOT) && \
124 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
125 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
Reid Spencer35655d62004-12-24 03:36:31 +0000126 fi ; \
Reid Spencerafdc82c2004-12-16 18:26:53 +0000127 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
128 $(ConfigStatusScript)
129
Reid Spencerf88808a2004-10-30 09:19:36 +0000130.PRECIOUS: $(ConfigStatusScript)
131$(ConfigStatusScript): $(ConfigureScript)
132 $(Echo) Reconfiguring with $<
Reid Spencerba6a3db2005-01-16 02:20:54 +0000133 $(Verb) cd $(PROJ_OBJ_ROOT) && \
134 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
135 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
Reid Spencer35655d62004-12-24 03:36:31 +0000136 fi ; \
Reid Spencer50f34872004-11-29 12:37:44 +0000137 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
138 $(ConfigStatusScript)
Reid Spencer77a46d22004-10-26 22:26:33 +0000139
Reid Spencer83bde552005-08-25 04:44:18 +0000140#------------------------------------------------------------------------
Reid Spencer77a46d22004-10-26 22:26:33 +0000141# Make sure the configuration makefile is up to date
142#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +0000143ifneq ($(MakefileConfigIn),)
144$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
Reid Spencerf88808a2004-10-30 09:19:36 +0000145 $(Echo) Regenerating $@
Reid Spencerba6a3db2005-01-16 02:20:54 +0000146 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
147endif
148
149ifneq ($(MakefileCommonIn),)
150$(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
151 $(Echo) Regenerating $@
152 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
153endif
Reid Spencer77a46d22004-10-26 22:26:33 +0000154
155#------------------------------------------------------------------------
156# If the Makefile in the source tree has been updated, copy it over into the
157# build tree. But, only do this if the source and object makefiles differ
158#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +0000159ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
Reid Spencer77a46d22004-10-26 22:26:33 +0000160
Reid Spencerba6a3db2005-01-16 02:20:54 +0000161Makefile: $(PROJ_SRC_DIR)/Makefile
Reid Spencerf88808a2004-10-30 09:19:36 +0000162 $(Echo) "Updating Makefile"
163 $(Verb) $(MKDIR) $(@D)
Reid Spencerafdc82c2004-12-16 18:26:53 +0000164 $(Verb) $(CP) -f $< $@
Reid Spencer77a46d22004-10-26 22:26:33 +0000165
166# Copy the Makefile.* files unless we're in the root directory which avoids
167# the copying of Makefile.config.in or other things that should be explicitly
168# taken care of.
Reid Spencerba6a3db2005-01-16 02:20:54 +0000169$(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
Reid Spencerd94bb332004-10-26 23:10:00 +0000170 @case '$?' in \
171 *Makefile.rules) ;; \
172 *.in) ;; \
Reid Spencerf88808a2004-10-30 09:19:36 +0000173 *) $(Echo) "Updating $(@F)" ; \
Reid Spencerd94bb332004-10-26 23:10:00 +0000174 $(MKDIR) $(@D) ; \
Reid Spencerafdc82c2004-12-16 18:26:53 +0000175 $(CP) -f $< $@ ;; \
Reid Spencerd94bb332004-10-26 23:10:00 +0000176 esac
177
Reid Spencer77a46d22004-10-26 22:26:33 +0000178endif
179
180#------------------------------------------------------------------------
181# Set up the basic dependencies
182#------------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000183$(UserTargets):: $(PreConditions)
Reid Spencer77a46d22004-10-26 22:26:33 +0000184
185all:: all-local
Reid Spencer81cd0492004-10-23 20:04:14 +0000186clean:: clean-local
Reid Spencer9d0c1e02004-11-02 16:36:03 +0000187clean-all:: clean-local clean-all-local
Reid Spencer77a46d22004-10-26 22:26:33 +0000188install:: install-local
189uninstall:: uninstall-local
Reid Spencer77a46d22004-10-26 22:26:33 +0000190install-local:: all-local
Reid Spencerd4bd3752004-12-03 20:08:48 +0000191install-bytecode:: install-bytecode-local
Reid Spencer81cd0492004-10-23 20:04:14 +0000192
193###############################################################################
194# VARIABLES: Set up various variables based on configuration data
195###############################################################################
196
197#--------------------------------------------------------------------
198# Variables derived from configuration we are building
Chris Lattner2f7c9632001-06-06 20:29:01 +0000199#--------------------------------------------------------------------
200
Chris Lattner213a85b2006-05-24 23:02:40 +0000201# OPTIMIZE_OPTION - The optimization level option we want to build LLVM with
202# this can be overridden on the make command line.
203OPTIMIZE_OPTION := -O3
204
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000205ifdef ENABLE_PROFILING
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000206 BuildMode := Profile
Chris Lattner213a85b2006-05-24 23:02:40 +0000207 CXX.Flags := $(OPTIMIZE_OPTION) -pg
208 C.Flags := $(OPTIMIZE_OPTION) -pg
209 LD.Flags := $(OPTIMIZE_OPTION) -pg
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000210else
211 ifdef ENABLE_OPTIMIZED
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000212 BuildMode := Release
Reid Spencer34982d82005-01-02 17:43:20 +0000213 # Don't use -fomit-frame-pointer on FreeBSD
214 ifneq ($(OS),FreeBSD)
Chris Lattner040c1102006-05-24 18:34:08 +0000215 # Don't use -fomit-frame-pointer on Darwin, it breaks backtraces.
216 ifneq ($(OS),Darwin)
Reid Spencer34982d82005-01-02 17:43:20 +0000217 OmitFramePointer := -fomit-frame-pointer
218 endif
Chris Lattner040c1102006-05-24 18:34:08 +0000219 endif
Chris Lattner213a85b2006-05-24 23:02:40 +0000220 CXX.Flags := $(OPTIMIZE_OPTION) $(OmitFramePointer)
221 C.Flags := $(OPTIMIZE_OPTION) $(OmitFramePointer)
222 LD.Flags := $(OPTIMIZE_OPTION)
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000223 else
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000224 BuildMode := Debug
Chris Lattner98c79c32006-03-21 01:06:41 +0000225 CXX.Flags := -g
226 C.Flags := -g
227 LD.Flags := -g
Reid Spencerf206bd72004-10-22 21:01:56 +0000228 KEEP_SYMBOLS := 1
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000229 endif
230endif
231
Reid Spencer15b85092006-04-10 16:46:04 +0000232# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
233# then disable assertions by defining the appropriate preprocessor symbols.
Reid Spencerece13582006-04-09 23:41:14 +0000234ifdef DISABLE_ASSERTIONS
Reid Spencer056f0222006-04-07 16:06:18 +0000235 BuildMode := $(BuildMode)-Asserts
Chris Lattner98c79c32006-03-21 01:06:41 +0000236 CXX.Flags += -DNDEBUG
237 C.Flags += -DNDEBUG
Reid Spencerece13582006-04-09 23:41:14 +0000238else
239 CXX.Flags += -D_DEBUG
240 C.Flags += -D_DEBUG
Chris Lattner98c79c32006-03-21 01:06:41 +0000241endif
242
Reid Spencer6f682b72006-03-22 15:59:55 +0000243CXX.Flags += $(CXXFLAGS)
244C.Flags += $(CFLAGS)
245CPP.BaseFlags += $(CPPFLAGS)
246LD.Flags += $(LDFLAGS)
247AR.Flags := cru
Reid Spencerf88808a2004-10-30 09:19:36 +0000248LibTool.Flags := --tag=CXX
Reid Spencer81cd0492004-10-23 20:04:14 +0000249
Andrew Lenharth9a98def2005-02-13 03:41:10 +0000250#Make Floating point ieee complient on alpha
251ifeq ($(ARCH),Alpha)
Reid Spencer6f682b72006-03-22 15:59:55 +0000252 CXX.Flags += -mieee
253 CPP.BaseFlags += -mieee
Andrew Lenharth9a98def2005-02-13 03:41:10 +0000254endif
255
Reid Spencer81cd0492004-10-23 20:04:14 +0000256#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000257# Directory locations
Reid Spencer81cd0492004-10-23 20:04:14 +0000258#--------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +0000259ObjDir := $(PROJ_OBJ_DIR)/$(BuildMode)
260LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
261ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
262ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000263LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer0dbf1012004-11-18 20:04:39 +0000264LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencerb9f8de62004-12-28 07:59:22 +0000265LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer2bba41c2004-12-22 05:57:21 +0000266CFERuntimeLibDir := $(LLVMGCCDIR)/lib
John Criswell3ef61af2003-06-30 21:59:07 +0000267
Reid Spencer81cd0492004-10-23 20:04:14 +0000268#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000269# Full Paths To Compiled Tools and Utilities
Reid Spencer81cd0492004-10-23 20:04:14 +0000270#--------------------------------------------------------------------
Reid Spencerb12e2902005-01-14 16:33:36 +0000271EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
272Echo = @$(EchoCmd)
Reid Spencerf88808a2004-10-30 09:19:36 +0000273ifndef LIBTOOL
Reid Spencerf206bd72004-10-22 21:01:56 +0000274LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencerf88808a2004-10-30 09:19:36 +0000275endif
276ifndef LLVMAS
277LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
278endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000279ifndef TBLGEN
280TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
281endif
Chris Lattner0ea40c92004-11-29 19:47:58 +0000282ifndef GCCAS
283GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
284endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000285ifndef GCCLD
286GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
287endif
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000288ifndef LDIS
289LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
290endif
291ifndef LLI
292LLI := $(LLVMToolDir)/lli$(EXEEXT)
293endif
Alkis Evlogimenos24340582005-02-27 10:21:37 +0000294ifndef LLC
295LLC := $(LLVMToolDir)/llc$(EXEEXT)
296endif
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000297ifndef LOPT
Alkis Evlogimenos7c7705d2004-12-13 18:08:29 +0000298LOPT := $(LLVMToolDir)/opt$(EXEEXT)
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000299endif
Alkis Evlogimenos7c04a3d2005-02-02 00:40:15 +0000300ifndef LBUGPOINT
301LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
302endif
303
John Criswelldc665012005-01-03 17:42:57 +0000304LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
305LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000306
Reid Spencer81cd0492004-10-23 20:04:14 +0000307#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000308# Adjust to user's request
Reid Spencer81cd0492004-10-23 20:04:14 +0000309#--------------------------------------------------------------------
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000310
Reid Spencer87e645c2005-01-11 04:31:07 +0000311# Adjust LD.Flags and Libtool.Flags depending on the kind of library that is
312# to be built. Note that if LOADABLE_MODULE is specified then the resulting
313# shared library can be opened with dlopen
314ifdef SHARED_LIBRARY
Reid Spencerf88808a2004-10-30 09:19:36 +0000315 LD.Flags += -rpath $(LibDir)
Reid Spencer87e645c2005-01-11 04:31:07 +0000316 ifdef LOADABLE_MODULE
317 LD.Flags += -module
318 endif
319else
320 LibTool.Flags += --tag=disable-shared
John Criswell3601f372003-07-31 20:58:51 +0000321endif
322
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000323ifdef TOOL_VERBOSE
324 C.Flags += -v
325 CXX.Flags += -v
326 LD.Flags += -v
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000327 VERBOSE := 1
328endif
329
Reid Spencer81cd0492004-10-23 20:04:14 +0000330# Adjust settings for verbose mode
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000331ifndef VERBOSE
Reid Spencerf88808a2004-10-30 09:19:36 +0000332 Verb := @
333 LibTool.Flags += --silent
334 AR.Flags += >/dev/null 2>/dev/null
Reid Spencerba6a3db2005-01-16 02:20:54 +0000335 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
Reid Spencer100080c2004-10-25 08:27:37 +0000336else
Reid Spencerf88808a2004-10-30 09:19:36 +0000337 ConfigureScriptFLAGS :=
Misha Brukman1326a7c2002-09-12 16:05:39 +0000338endif
339
Vikram S. Adved141c282002-09-18 11:55:13 +0000340# By default, strip symbol information from executable
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000341ifndef KEEP_SYMBOLS
Reid Spencerf88808a2004-10-30 09:19:36 +0000342 Strip := $(PLATFORMSTRIPOPTS)
343 StripWarnMsg := "(without symbols)"
Reid Spencer247a10e2005-02-24 07:12:43 +0000344 Install.StripFlag += -s
Vikram S. Adved141c282002-09-18 11:55:13 +0000345endif
346
Reid Spencer81cd0492004-10-23 20:04:14 +0000347# Adjust linker flags for building an executable
Reid Spencerf206bd72004-10-22 21:01:56 +0000348ifdef TOOLNAME
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000349ifdef EXAMPLE_TOOL
350 LD.Flags += -rpath $(ExmplDir) -export-dynamic
351else
Reid Spencerf88808a2004-10-30 09:19:36 +0000352 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000353endif
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000354endif
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000355
Reid Spencer81cd0492004-10-23 20:04:14 +0000356#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000357# Options To Invoke Tools
Reid Spencer81cd0492004-10-23 20:04:14 +0000358#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000359
360CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
361
Duraid Madina60c9a3c2005-05-16 06:38:09 +0000362ifeq ($(OS),HP-UX)
Duraid Madina1f898af2006-02-15 03:20:16 +0000363 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
Duraid Madina60c9a3c2005-05-16 06:38:09 +0000364endif
365
Chris Lattner11c25cf2006-05-30 16:38:06 +0000366# If we are building a universal binary on Mac OS/X, pass extra options. This
367# is useful to people that want to link the LLVM libraries into their universal
368# apps.
Chris Lattnerd81eba52006-04-06 06:30:15 +0000369ifdef UNIVERSAL
Chris Lattnerf2f4aed2006-04-19 18:45:29 +0000370 CompileCommonOpts += \
371 -arch i386 -arch ppc -isysroot /Developer/SDKs/MACOSX10.4u.sdk/
372 Relink.Flags := -XCClinker -arch -XCClinker i386 -XCClinker -arch \
373 -XCClinker ppc -XCClinker \
374 -isysroot -XCClinker /Developer/SDKs/MACOSX10.4u.sdk/
Chris Lattnerd81eba52006-04-06 06:30:15 +0000375 DISABLE_AUTO_DEPENDENCIES=1
376endif
377
Chris Lattner11c25cf2006-05-30 16:38:06 +0000378# Temporary workaround for a Mac OSX compatibility issue.
Evan Chengbb66ec22006-04-07 08:31:56 +0000379ifeq ($(OS),Darwin)
Evan Chengbb66ec22006-04-07 08:31:56 +0000380 CXX.Flags += -fno-use-cxa-atexit
381endif
Evan Cheng1e86e672006-04-07 08:10:09 +0000382
Reid Spencer6f682b72006-03-22 15:59:55 +0000383LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
384CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
385# All -I flags should go here, so that they don't confuse llvm-config.
386CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
387 -I$(PROJ_OBJ_ROOT)/include \
388 -I$(PROJ_SRC_ROOT)/include \
389 -I$(LLVM_OBJ_ROOT)/include \
390 -I$(LLVM_SRC_ROOT)/include \
391 $(CPP.BaseFlags)
Reid Spencerf206bd72004-10-22 21:01:56 +0000392
Reid Spencerf88808a2004-10-30 09:19:36 +0000393Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
394LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
Reid Spencer2bba41c2004-12-22 05:57:21 +0000395BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000396 $(C.Flags)
Chris Lattnerbb087952005-10-05 00:28:41 +0000397Preprocess.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -E $(C.Flags)
398
Reid Spencerf88808a2004-10-30 09:19:36 +0000399Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
400LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
Reid Spencerc005fba2004-12-24 14:47:34 +0000401BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000402 $(CXX.Flags)
Chris Lattnerbb087952005-10-05 00:28:41 +0000403Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
Reid Spencerf88808a2004-10-30 09:19:36 +0000404Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencer540c1b92006-05-16 06:51:02 +0000405 $(CXX.Flags) $(CompileCommonOpts) $(LD.Flags) $(Strip)
Reid Spencerf88808a2004-10-30 09:19:36 +0000406Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencer540c1b92006-05-16 06:51:02 +0000407 $(CXX.Flags) $(CompileCommonOpts) $(Relink.Flags)
Reid Spencerfe0a01e2005-02-16 16:13:02 +0000408LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
409 $(Install.Flags)
Reid Spencer247a10e2005-02-24 07:12:43 +0000410ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
Reid Spencer6f682b72006-03-22 15:59:55 +0000411ScriptInstall = $(INSTALL) -m 0755
Reid Spencer247a10e2005-02-24 07:12:43 +0000412DataInstall = $(INSTALL) -m 0644
Vladimir Prus788db2c2006-05-16 06:39:36 +0000413TableGen = $(TBLGEN) -I $(PROJ_SRC_DIR) -I$(PROJ_SRC_ROOT)/include \
414 -I $(PROJ_SRC_ROOT)/lib/Target
Reid Spencerf88808a2004-10-30 09:19:36 +0000415Archive = $(AR) $(AR.Flags)
Reid Spencer32f7e422004-12-02 09:28:21 +0000416LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencerf206bd72004-10-22 21:01:56 +0000417ifdef RANLIB
Reid Spencer81cd0492004-10-23 20:04:14 +0000418Ranlib = $(RANLIB)
Reid Spencerf206bd72004-10-22 21:01:56 +0000419else
Reid Spencer81cd0492004-10-23 20:04:14 +0000420Ranlib = ranlib
John Criswell3ef61af2003-06-30 21:59:07 +0000421endif
422
Chris Lattner2f7c9632001-06-06 20:29:01 +0000423#----------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +0000424# Get the list of source files and compute object file
425# names from them.
Reid Spencer81cd0492004-10-23 20:04:14 +0000426#----------------------------------------------------------
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000427
428ifndef SOURCES
429 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
430 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
431 $(PROJ_SRC_DIR)/*.l))
Reid Spencerf88808a2004-10-30 09:19:36 +0000432else
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000433 Sources := $(SOURCES)
434endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000435
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000436ifdef BUILT_SOURCES
437Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Reid Spencer81546582004-12-04 22:34:09 +0000438endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000439
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000440BaseNameSources := $(sort $(basename $(Sources)))
441
442ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
443ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
444ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
445
Reid Spencer81cd0492004-10-23 20:04:14 +0000446###############################################################################
447# DIRECTORIES: Handle recursive descent of directory structure
448###############################################################################
John Criswell3601f372003-07-31 20:58:51 +0000449
Chris Lattner2f7c9632001-06-06 20:29:01 +0000450#---------------------------------------------------------
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000451# Provide rules to make install dirs. This must be early
452# in the file so they get built before dependencies
453#---------------------------------------------------------
454
Reid Spencer90b689d2005-05-19 20:26:14 +0000455$(PROJ_bindir): $(PROJ_bindir)/.dir
456$(PROJ_libdir): $(PROJ_libdir)/.dir
457$(PROJ_includedir): $(PROJ_includedir)/.dir
458$(PROJ_etcdir): $(PROJ_etcdir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000459
Reid Spencerf88808a2004-10-30 09:19:36 +0000460# To create other directories, as needed, and timestamp their creation
461%/.dir:
462 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfc66af42004-11-29 05:00:33 +0000463 $(Verb) $(DATE) > $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000464
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000465.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
466.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000467
468#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000469# Handle the DIRS options for sequential construction
Chris Lattner2f7c9632001-06-06 20:29:01 +0000470#---------------------------------------------------------
471
Reid Spencerf88808a2004-10-30 09:19:36 +0000472SubDirs :=
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000473ifdef DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000474SubDirs += $(DIRS)
475$(RecursiveTargets)::
476 $(Verb) for dir in $(DIRS); do \
Reid Spencerf206bd72004-10-22 21:01:56 +0000477 if [ ! -f $$dir/Makefile ]; then \
478 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000479 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000480 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000481 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattner539a23c2002-09-17 23:35:02 +0000482 done
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000483endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000484
Reid Spencer81cd0492004-10-23 20:04:14 +0000485#---------------------------------------------------------
486# Handle the EXPERIMENTAL_DIRS options ensuring success
487# after each directory is built.
488#---------------------------------------------------------
489ifdef EXPERIMENTAL_DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000490$(RecursiveTargets)::
491 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer81cd0492004-10-23 20:04:14 +0000492 if [ ! -f $$dir/Makefile ]; then \
493 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000494 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000495 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000496 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000497 done
498endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000499
Reid Spencerc49a8632005-12-21 23:17:06 +0000500#-----------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000501# Handle the PARALLEL_DIRS options for parallel construction
Reid Spencerc49a8632005-12-21 23:17:06 +0000502#-----------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000503ifdef PARALLEL_DIRS
504
Reid Spencerf88808a2004-10-30 09:19:36 +0000505SubDirs += $(PARALLEL_DIRS)
506
Reid Spencerd4bd3752004-12-03 20:08:48 +0000507# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencerf88808a2004-10-30 09:19:36 +0000508all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
509clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000510clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencerf88808a2004-10-30 09:19:36 +0000511install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000512uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencerd4bd3752004-12-03 20:08:48 +0000513install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000514
Reid Spencer81546582004-12-04 22:34:09 +0000515ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer81cd0492004-10-23 20:04:14 +0000516
Reid Spencer81546582004-12-04 22:34:09 +0000517$(ParallelTargets) :
Reid Spencerf88808a2004-10-30 09:19:36 +0000518 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencerf206bd72004-10-22 21:01:56 +0000519 $(MKDIR) $(@D); \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000520 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswell6df35dd2003-11-25 19:32:22 +0000521 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000522 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ;
Chris Lattner2f7c9632001-06-06 20:29:01 +0000523endif
524
Reid Spencer81cd0492004-10-23 20:04:14 +0000525#---------------------------------------------------------
526# Handle the OPTIONAL_DIRS options for directores that may
527# or may not exist.
528#---------------------------------------------------------
John Criswell8224df92003-06-27 16:58:44 +0000529ifdef OPTIONAL_DIRS
Reid Spencer100080c2004-10-25 08:27:37 +0000530
Reid Spencerf88808a2004-10-30 09:19:36 +0000531SubDirs += $(OPTIONAL_DIRS)
Reid Spencer100080c2004-10-25 08:27:37 +0000532
Reid Spencerf88808a2004-10-30 09:19:36 +0000533$(RecursiveTargets)::
534 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000535 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
Reid Spencerf206bd72004-10-22 21:01:56 +0000536 if [ ! -f $$dir/Makefile ]; then \
537 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000538 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000539 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000540 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000541 fi \
John Criswell8224df92003-06-27 16:58:44 +0000542 done
543endif
544
Reid Spencercc51e7b2004-08-20 09:20:05 +0000545#---------------------------------------------------------
546# Handle the CONFIG_FILES options
547#---------------------------------------------------------
548ifdef CONFIG_FILES
Reid Spencercc51e7b2004-08-20 09:20:05 +0000549
Reid Spencerba6a3db2005-01-16 02:20:54 +0000550install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
551 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000552 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000553 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
Reid Spencerc43b1d42005-02-24 03:56:32 +0000554 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000555 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
Reid Spencerc43b1d42005-02-24 03:56:32 +0000556 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer39d6a612004-11-23 05:59:53 +0000557 else \
558 $(ECHO) Error: cannot find config file $${file}. ; \
559 fi \
Reid Spencercc51e7b2004-08-20 09:20:05 +0000560 done
Reid Spencer81cd0492004-10-23 20:04:14 +0000561
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000562uninstall-local::
Reid Spencerba6a3db2005-01-16 02:20:54 +0000563 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000564 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000565 $(RM) -f $(PROJ_etcdir)/$${file} ; \
Reid Spencer12a3a052004-10-24 07:53:21 +0000566 done
567
Reid Spencercc51e7b2004-08-20 09:20:05 +0000568endif
569
Reid Spencer81cd0492004-10-23 20:04:14 +0000570###############################################################################
Reid Spencera80f1672005-05-19 00:37:31 +0000571# Set up variables for building libararies
572###############################################################################
573
574#---------------------------------------------------------
575# Handle the special "JIT" value for LLVM_LIBS which is a
576# shorthand for a bunch of libraries that get the correct
577# JIT support for a library or a tool that runs JIT.
578#---------------------------------------------------------
Reid Spencerd813b952006-03-24 07:36:57 +0000579ifeq ($(firstword $(LLVMLIBS)),config)
580LLVM_CONFIG := $(LLVM_SRC_ROOT)/utils/llvm-config/llvm-config
Reid Spencer056f0222006-04-07 16:06:18 +0000581LLVMLIBS := $(shell $(LLVM_CONFIG) --libnames $(wordlist 2,9999,$(LLVMLIBS)))
582LLVMLIBS := $(patsubst lib%.a,%.a,$(LLVMLIBS))
Reid Spencerd813b952006-03-24 07:36:57 +0000583LLVMLIBS := $(patsubst %.o,%,$(LLVMLIBS))
Reid Spencerd813b952006-03-24 07:36:57 +0000584endif
585
Reid Spencera80f1672005-05-19 00:37:31 +0000586ifeq ($(LLVMLIBS),JIT)
587
588# Make sure we can get our own symbols in the tool
589Link += -dlopen self
590
591# Generic JIT libraries
592JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
593
594# You can enable the X86 JIT on a non-X86 host by setting the flag
595# ENABLE_X86_JIT on the make command line. If not, it will still be
596# enabled automagically on an X86 host.
597ifeq ($(ARCH), x86)
598 ENABLE_X86_JIT = 1
599endif
600
601# What the X86 JIT requires
602ifdef ENABLE_X86_JIT
603 JIT_LIBS += LLVMX86 LLVMSelectionDAG
604endif
605
Reid Spencera80f1672005-05-19 00:37:31 +0000606# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
607# ENABLE_PPC_JIT on the make command line. If not, it will still be
608# enabled automagically on an PowerPC host.
609ifeq ($(ARCH), PowerPC)
610 ENABLE_PPC_JIT = 1
611endif
612
613# What the PowerPC JIT requires
614ifdef ENABLE_PPC_JIT
615 JIT_LIBS += LLVMPowerPC LLVMSelectionDAG
616endif
617
Andrew Lenharthc7fe0f52005-07-22 20:54:01 +0000618# You can enable the Alpha JIT on a non-Alpha host by setting the flag
619# ENABLE_ALPHA_JIT on the make command line. If not, it will still be
Misha Brukman08c36452005-07-22 22:43:40 +0000620# enabled automagically on an Alpha host.
Andrew Lenharthc7fe0f52005-07-22 20:54:01 +0000621ifeq ($(ARCH), Alpha)
622 ENABLE_ALPHA_JIT = 1
623endif
624
Andrew Lenharth99007012005-07-22 22:00:24 +0000625# What the Alpha JIT requires
Andrew Lenharthc7fe0f52005-07-22 20:54:01 +0000626ifdef ENABLE_ALPHA_JIT
627 JIT_LIBS += LLVMAlpha LLVMSelectionDAG
628endif
629
John Criswellfe5f33b2005-10-27 15:54:34 +0000630LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts.a LLVMTransformUtils.a LLVMAnalysis.a \
Owen Anderson68afff22006-05-11 03:10:15 +0000631 LLVMBCReader LLVMTarget.a LLVMCore LLVMSupport.a LLVMbzip2 \
Reid Spencera80f1672005-05-19 00:37:31 +0000632 LLVMSystem.a $(PLATFORMLIBDL)
633endif
634
635#---------------------------------------------------------
636# Define various command line options pertaining to the
637# libraries needed when linking. There are "Proj" libs
638# (defined by the user's project) and "LLVM" libs (defined
639# by the # LLVM project).
640#---------------------------------------------------------
Misha Brukman5fbf58a2005-08-17 02:38:56 +0000641# Some versions of gcc on Alpha produce too many symbols, so use a .a file
Andrew Lenharth6b62b472005-08-13 05:09:50 +0000642ifeq ($(ARCH),Alpha)
Reid Spencer10536582006-05-16 06:25:14 +0000643USEDLIBS := $(subst LLVMCore, LLVMCore.a, $(USEDLIBS))
Andrew Lenharth6b62b472005-08-13 05:09:50 +0000644LLVMLIBS := $(subst LLVMCore, LLVMCore.a, $(LLVMLIBS))
Reid Spencer6f682b72006-03-22 15:59:55 +0000645CORE_IS_ARCHIVE := 1
646else
647CORE_IS_ARCHIVE := 0
Andrew Lenharth6b62b472005-08-13 05:09:50 +0000648endif
649
Reid Spencera80f1672005-05-19 00:37:31 +0000650ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
651ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
652LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
653LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
654ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
655LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
656ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
657LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
658
659###############################################################################
Reid Spencer81cd0492004-10-23 20:04:14 +0000660# Library Build Rules: Four ways to build a library
661###############################################################################
Chris Lattner2f7c9632001-06-06 20:29:01 +0000662
Reid Spencerd78077d2004-12-05 05:17:22 +0000663#---------------------------------------------------------
664# Bytecode Module Targets:
665# If the user set MODULE_NAME then they want to build a
666# bytecode module from the sources. We compile all the
667# sources and link it together into a single bytecode
668# module.
669#---------------------------------------------------------
670
671ifdef MODULE_NAME
Reid Spencere9fa5442005-02-14 21:54:08 +0000672ifeq ($(strip $(LLVMGCC)),)
Reid Spencer83745dd2005-05-13 18:32:54 +0000673$(warning Modules require llvm-gcc but no llvm-gcc is available ****)
Reid Spencere9fa5442005-02-14 21:54:08 +0000674else
Reid Spencerd78077d2004-12-05 05:17:22 +0000675
676Module := $(LibDir)/$(MODULE_NAME).bc
Reid Spencer78ede562006-04-12 18:21:35 +0000677LinkModule := $(GCCLD) -L$(CFERuntimeLibDir)
678
Reid Spencerd78077d2004-12-05 05:17:22 +0000679
680ifdef EXPORTED_SYMBOL_FILE
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000681LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencerd78077d2004-12-05 05:17:22 +0000682endif
683
684$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
Reid Spencer83745dd2005-05-13 18:32:54 +0000685 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
Reid Spencerd78077d2004-12-05 05:17:22 +0000686 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
687
688all-local:: $(Module)
689
690clean-local::
691ifneq ($(strip $(Module)),)
692 -$(Verb) $(RM) -f $(Module)
693endif
694
Reid Spencerefe3a822004-12-13 07:38:07 +0000695ifdef BYTECODE_DESTINATION
696ModuleDestDir := $(BYTECODE_DESTINATION)
697else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000698ModuleDestDir := $(PROJ_libdir)
Reid Spencerefe3a822004-12-13 07:38:07 +0000699endif
Reid Spencerd78077d2004-12-05 05:17:22 +0000700
Reid Spencerefe3a822004-12-13 07:38:07 +0000701DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
702
703install-module:: $(DestModule)
Reid Spencerd78077d2004-12-05 05:17:22 +0000704install-local:: $(DestModule)
705
Reid Spencerefe3a822004-12-13 07:38:07 +0000706$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencerd78077d2004-12-05 05:17:22 +0000707 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
Reid Spencerd77a4c02005-02-24 21:30:37 +0000708 $(Verb) $(DataInstall) $(Module) $(DestModule)
Reid Spencerd78077d2004-12-05 05:17:22 +0000709
710uninstall-local::
711 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
712 -$(Verb) $(RM) -f $(DestModule)
713
714endif
Reid Spencere9fa5442005-02-14 21:54:08 +0000715endif
Brian Gaekeecc92bf2004-01-22 22:53:48 +0000716
Reid Spencer81cd0492004-10-23 20:04:14 +0000717# if we're building a library ...
Chris Lattner2f7c9632001-06-06 20:29:01 +0000718ifdef LIBRARYNAME
Vikram S. Advefe346892001-07-15 13:16:47 +0000719
Chris Lattner0100eab2002-09-16 22:36:42 +0000720# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000721LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencer87e645c2005-01-11 04:31:07 +0000722ifdef LOADABLE_MODULE
723LibName.LA := $(LibDir)/$(LIBRARYNAME).la
724else
Reid Spencerf88808a2004-10-30 09:19:36 +0000725LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
Reid Spencer87e645c2005-01-11 04:31:07 +0000726endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000727LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
728LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer32f7e422004-12-02 09:28:21 +0000729LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000730
Reid Spencer81cd0492004-10-23 20:04:14 +0000731#---------------------------------------------------------
732# Shared Library Targets:
733# If the user asked for a shared library to be built
734# with the SHARED_LIBRARY variable, then we provide
735# targets for building them.
736#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000737ifdef SHARED_LIBRARY
738
Reid Spencerf88808a2004-10-30 09:19:36 +0000739all-local:: $(LibName.LA)
Reid Spencerf206bd72004-10-22 21:01:56 +0000740
Reid Spencera80f1672005-05-19 00:37:31 +0000741ifdef LINK_LIBS_IN_SHARED
742$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
743 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
744 $(Verb) $(Link) -o $@ $(ObjectsLO) \
745 $(ProjLibsOptions) $(LLVMLibsOptions)
746 $(Verb) $(LTInstall) $@ $(LibDir)
747else
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000748$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000749 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf88808a2004-10-30 09:19:36 +0000750 $(Verb) $(Link) -o $@ $(ObjectsLO)
751 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencera80f1672005-05-19 00:37:31 +0000752endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000753
754clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000755ifneq ($(strip $(LibName.LA)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000756 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000757endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000758
Reid Spencerba6a3db2005-01-16 02:20:54 +0000759DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf206bd72004-10-22 21:01:56 +0000760
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000761install-local:: $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000762
Reid Spencerba6a3db2005-01-16 02:20:54 +0000763$(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000764 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000765 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000766 $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
Reid Spencer12a3a052004-10-24 07:53:21 +0000767
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000768uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000769 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000770 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
Reid Spencer12a3a052004-10-24 07:53:21 +0000771
Reid Spencerf206bd72004-10-22 21:01:56 +0000772endif
773
Reid Spencer81cd0492004-10-23 20:04:14 +0000774#---------------------------------------------------------
775# Bytecode Library Targets:
776# If the user asked for a bytecode library to be built
777# with the BYTECODE_LIBRARY variable, then we provide
778# targets for building them.
779#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000780ifdef BYTECODE_LIBRARY
Reid Spencere9fa5442005-02-14 21:54:08 +0000781ifeq ($(strip $(LLVMGCC)),)
Reid Spencer83745dd2005-05-13 18:32:54 +0000782$(warning Bytecode libraries require llvm-gcc which could not be found ****)
Reid Spencere9fa5442005-02-14 21:54:08 +0000783else
Reid Spencerf206bd72004-10-22 21:01:56 +0000784
Reid Spencer32f7e422004-12-02 09:28:21 +0000785all-local:: $(LibName.BCA)
786
787ifdef EXPORTED_SYMBOL_FILE
Chris Lattner11c25cf2006-05-30 16:38:06 +0000788BCLinkLib = $(GCCLD) -L$(CFERuntimeLibDir) \
789 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer32f7e422004-12-02 09:28:21 +0000790
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000791$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +0000792 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +0000793 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
794 "(internalize)"
Chris Lattnere3d98f12004-12-02 21:23:43 +0000795 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencer85d55ad2004-12-13 03:59:35 +0000796 $(Verb) $(RM) -f $@
Reid Spencer32f7e422004-12-02 09:28:21 +0000797 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencerf206bd72004-10-22 21:01:56 +0000798else
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000799$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +0000800 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +0000801 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencer85d55ad2004-12-13 03:59:35 +0000802 $(Verb) $(RM) -f $@
Reid Spencer32f7e422004-12-02 09:28:21 +0000803 $(Verb) $(LArchive) $@ $(ObjectsBC)
804
Reid Spencerf206bd72004-10-22 21:01:56 +0000805endif
806
Reid Spencer81cd0492004-10-23 20:04:14 +0000807clean-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000808ifneq ($(strip $(LibName.BCA)),)
809 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000810endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000811
Reid Spencer65086be2004-12-13 07:28:21 +0000812ifdef BYTECODE_DESTINATION
813BytecodeDestDir := $(BYTECODE_DESTINATION)
814else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000815BytecodeDestDir := $(PROJ_libdir)
Reid Spencer65086be2004-12-13 07:28:21 +0000816endif
817
818DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
Reid Spencer32f7e422004-12-02 09:28:21 +0000819
Reid Spencerd4bd3752004-12-03 20:08:48 +0000820install-bytecode-local:: $(DestBytecodeLib)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000821
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000822install-local:: $(DestBytecodeLib)
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000823
Reid Spencer65086be2004-12-13 07:28:21 +0000824$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
Reid Spencer32f7e422004-12-02 09:28:21 +0000825 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerdcc53752005-02-24 21:36:32 +0000826 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000827
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000828uninstall-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000829 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000830 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000831
832endif
Reid Spencere9fa5442005-02-14 21:54:08 +0000833endif
Vikram S. Adve15bd3ad2002-08-02 18:34:12 +0000834
Reid Spencerf88808a2004-10-30 09:19:36 +0000835#---------------------------------------------------------
836# ReLinked Library Targets:
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000837# If the user explicitly requests a relinked library with
838# BUILD_RELINKED, provide it. Otherwise, if they specify
839# neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
840# them one.
Reid Spencerf88808a2004-10-30 09:19:36 +0000841#---------------------------------------------------------
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000842ifndef BUILD_ARCHIVE
Chris Lattner76d98ba2002-07-23 17:56:16 +0000843ifndef DONT_BUILD_RELINKED
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000844BUILD_RELINKED = 1
845endif
846endif
847
848ifdef BUILD_RELINKED
Reid Spencerf206bd72004-10-22 21:01:56 +0000849
Reid Spencerf88808a2004-10-30 09:19:36 +0000850all-local:: $(LibName.O)
851
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000852$(LibName.O): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000853 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencerf88808a2004-10-30 09:19:36 +0000854 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencerf206bd72004-10-22 21:01:56 +0000855
Reid Spencer81cd0492004-10-23 20:04:14 +0000856clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000857ifneq ($(strip $(LibName.O)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000858 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencer12a3a052004-10-24 07:53:21 +0000859endif
860
Reid Spencerba6a3db2005-01-16 02:20:54 +0000861DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
Reid Spencer12a3a052004-10-24 07:53:21 +0000862
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000863install-local:: $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000864
Reid Spencerba6a3db2005-01-16 02:20:54 +0000865$(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000866 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000867 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000868
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000869uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000870 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000871 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000872
Chris Lattner76d98ba2002-07-23 17:56:16 +0000873endif
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000874
Reid Spencerf88808a2004-10-30 09:19:36 +0000875#---------------------------------------------------------
876# Archive Library Targets:
877# If the user wanted a regular archive library built,
878# then we provide targets for building them.
879#---------------------------------------------------------
Chris Lattner76d98ba2002-07-23 17:56:16 +0000880ifdef BUILD_ARCHIVE
Chris Lattner76d98ba2002-07-23 17:56:16 +0000881
Reid Spencerf88808a2004-10-30 09:19:36 +0000882all-local:: $(LibName.A)
883
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000884$(LibName.A): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000885 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000886 -$(Verb) $(RM) -f $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000887 $(Verb) $(Archive) $@ $(ObjectsO)
888 $(Verb) $(Ranlib) $@
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000889
Reid Spencer81cd0492004-10-23 20:04:14 +0000890clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000891ifneq ($(strip $(LibName.A)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000892 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000893endif
894
Reid Spencerba6a3db2005-01-16 02:20:54 +0000895DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
Reid Spencer12a3a052004-10-24 07:53:21 +0000896
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000897install-local:: $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000898
Reid Spencerba6a3db2005-01-16 02:20:54 +0000899$(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000900 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000901 $(Verb) $(MKDIR) $(PROJ_libdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000902 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000903
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000904uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000905 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000906 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000907
908endif
909
910# endif LIBRARYNAME
Reid Spencerf206bd72004-10-22 21:01:56 +0000911endif
912
Reid Spencerdcba7782004-10-24 08:21:04 +0000913###############################################################################
914# Tool Build Rules: Build executable tool based on TOOLNAME option
915###############################################################################
916
Chris Lattner07c7c192001-09-07 22:57:58 +0000917ifdef TOOLNAME
918
Reid Spencerf88808a2004-10-30 09:19:36 +0000919#---------------------------------------------------------
920# Set up variables for building a tool.
921#---------------------------------------------------------
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000922ifdef EXAMPLE_TOOL
Reid Spencer98a2d982005-05-19 21:03:11 +0000923ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000924else
Reid Spencer98a2d982005-05-19 21:03:11 +0000925ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000926endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000927
Reid Spencerf88808a2004-10-30 09:19:36 +0000928#---------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000929# Tell make that we need to rebuild subdirectories before
930# we can link the tool. This affects things like LLI which
931# has library subdirectories.
932#---------------------------------------------------------
933$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner3ecb7762003-01-22 16:13:31 +0000934
Reid Spencerf88808a2004-10-30 09:19:36 +0000935#---------------------------------------------------------
936# Provide targets for building the tools
937#---------------------------------------------------------
938all-local:: $(ToolBuildPath)
John Criswell8224df92003-06-27 16:58:44 +0000939
Reid Spencer81cd0492004-10-23 20:04:14 +0000940clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000941ifneq ($(strip $(ToolBuildPath)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000942 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencer12a3a052004-10-24 07:53:21 +0000943endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000944
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000945ifdef EXAMPLE_TOOL
946$(ToolBuildPath): $(ExmplDir)/.dir
947else
948$(ToolBuildPath): $(ToolDir)/.dir
949endif
950
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000951$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000952 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencer10536582006-05-16 06:25:14 +0000953 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
954 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
Chris Lattnere2dcbe02006-02-14 04:25:54 +0000955 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
956 $(StripWarnMsg)
Reid Spencer12a3a052004-10-24 07:53:21 +0000957
Reid Spencerba6a3db2005-01-16 02:20:54 +0000958DestTool = $(PROJ_bindir)/$(TOOLNAME)
Reid Spencer12a3a052004-10-24 07:53:21 +0000959
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000960install-local:: $(DestTool)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000961
Reid Spencerba6a3db2005-01-16 02:20:54 +0000962$(DestTool): $(PROJ_bindir) $(ToolBuildPath)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000963 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencerc43b1d42005-02-24 03:56:32 +0000964 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000965
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000966uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000967 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000968 -$(Verb) $(RM) -f $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000969
Reid Spencerf206bd72004-10-22 21:01:56 +0000970endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000971
Reid Spencerf88808a2004-10-30 09:19:36 +0000972###############################################################################
973# Object Build Rules: Build object files based on sources
974###############################################################################
975
Duraid Madinacbbc1842006-02-15 03:23:26 +0000976# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
977ifeq ($(OS),HP-UX)
978 DISABLE_AUTO_DEPENDENCIES=1
979endif
980
Reid Spencerf88808a2004-10-30 09:19:36 +0000981# Provide rule sets for when dependency generation is enabled
Reid Spencerf206bd72004-10-22 21:01:56 +0000982ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000983
Reid Spencerf88808a2004-10-30 09:19:36 +0000984#---------------------------------------------------------
985# Create .lo files in the ObjDir directory from the .cpp and .c files...
986#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000987ifdef SHARED_LIBRARY
988
Chris Lattner2a023902004-12-16 17:28:50 +0000989$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000990 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Chris Lattnerb8e7aa02006-02-14 04:27:15 +0000991 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
Reid Spencerf88808a2004-10-30 09:19:36 +0000992 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
993 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000994
Chris Lattnerf60c1702005-02-04 21:28:50 +0000995$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
996 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
Chris Lattnerb8e7aa02006-02-14 04:27:15 +0000997 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
Chris Lattnerf60c1702005-02-04 21:28:50 +0000998 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
999 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
1000
Chris Lattner2a023902004-12-16 17:28:50 +00001001$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001002 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencerf88808a2004-10-30 09:19:36 +00001003 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
1004 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
1005 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +00001006
Reid Spencerf88808a2004-10-30 09:19:36 +00001007#---------------------------------------------------------
1008# Create .o files in the ObjDir directory from the .cpp and .c files...
1009#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001010else
Reid Spencerf206bd72004-10-22 21:01:56 +00001011
Chris Lattner2a023902004-12-16 17:28:50 +00001012$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001013 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +00001014 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
1015 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
1016 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +00001017
Chris Lattnerf60c1702005-02-04 21:28:50 +00001018$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1019 $(Echo) "Compiling $*.cc for $(BuildMode) build"
1020 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
1021 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
1022 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
1023
Chris Lattner2a023902004-12-16 17:28:50 +00001024$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001025 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +00001026 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
1027 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
1028 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +00001029
1030endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001031
Chris Lattnerbb087952005-10-05 00:28:41 +00001032## Rules for building preprocessed (.i/.ii) outputs.
1033$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1034 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1035 $(Verb) $(Preprocess.CXX) $< -o $@
1036
1037$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1038 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1039 $(Verb) $(Preprocess.CXX) $< -o $@
1040
1041 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1042 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1043 $(Verb) $(Preprocess.C) $< -o $@
1044
1045
Reid Spencerf88808a2004-10-30 09:19:36 +00001046#---------------------------------------------------------
Chris Lattnerf60c1702005-02-04 21:28:50 +00001047# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
Reid Spencerf88808a2004-10-30 09:19:36 +00001048#---------------------------------------------------------
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001049
1050$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001051 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001052 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1053 $< -o $@ -S -emit-llvm ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001054 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1055 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +00001056
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001057$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001058 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001059 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1060 $< -o $@ -S -emit-llvm ; \
Chris Lattnerf60c1702005-02-04 21:28:50 +00001061 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1062 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1063
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001064$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001065 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001066 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" \
1067 $< -o $@ -S -emit-llvm ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001068 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1069 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +00001070
Reid Spencerf88808a2004-10-30 09:19:36 +00001071# Provide alternate rule sets if dependencies are disabled
Reid Spencerf206bd72004-10-22 21:01:56 +00001072else
1073
Reid Spencer81cd0492004-10-23 20:04:14 +00001074ifdef SHARED_LIBRARY
1075
Chris Lattner2a023902004-12-16 17:28:50 +00001076$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001077 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +00001078 $(LTCompile.CXX) $< -o $@
1079
Chris Lattnerf60c1702005-02-04 21:28:50 +00001080$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1081 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
1082 $(LTCompile.CXX) $< -o $@
1083
Chris Lattner2a023902004-12-16 17:28:50 +00001084$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerafdc82c2004-12-16 18:26:53 +00001085 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +00001086 $(LTCompile.C) $< -o $@
1087
1088else
Reid Spencerf206bd72004-10-22 21:01:56 +00001089
Chris Lattner2a023902004-12-16 17:28:50 +00001090$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001091 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer81cd0492004-10-23 20:04:14 +00001092 $(Compile.CXX) $< -o $@
Reid Spencerf206bd72004-10-22 21:01:56 +00001093
Chris Lattnerf60c1702005-02-04 21:28:50 +00001094$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1095 $(Echo) "Compiling $*.cc for $(BuildMode) build"
1096 $(Compile.CXX) $< -o $@
1097
Chris Lattner2a023902004-12-16 17:28:50 +00001098$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerafdc82c2004-12-16 18:26:53 +00001099 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencer81cd0492004-10-23 20:04:14 +00001100 $(Compile.C) $< -o $@
1101endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001102
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001103$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001104 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001105 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Reid Spencerf206bd72004-10-22 21:01:56 +00001106
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001107$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001108 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001109 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Chris Lattnerf60c1702005-02-04 21:28:50 +00001110
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001111$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001112 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001113 $(BCCompile.C) $< -o $@ -S -emit-llvm
Brian Gaeke0f148bc2003-12-10 00:26:28 +00001114
Chris Lattner07c7c192001-09-07 22:57:58 +00001115endif
1116
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001117# make the C and C++ compilers strip debug info out of bytecode libraries.
1118ifdef DEBUG_RUNTIME
1119$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1120 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Chris Lattner5b59d7c2006-03-09 06:00:05 +00001121 $(Verb) $(GCCAS) $< -o $@
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001122else
1123$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1124 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Chris Lattner5b59d7c2006-03-09 06:00:05 +00001125 $(Verb) $(GCCAS) -strip-debug $< -o $@
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001126endif
1127
1128
Reid Spencerf88808a2004-10-30 09:19:36 +00001129#---------------------------------------------------------
1130# Provide rule to build .bc files from .ll sources,
1131# regardless of dependencies
1132#---------------------------------------------------------
1133$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001134 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +00001135 $(Verb) $(LLVMAS) $< -f -o $@
1136
1137###############################################################################
1138# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1139###############################################################################
Chris Lattner0c4f4fe2003-08-15 02:18:35 +00001140
Reid Spencerf206bd72004-10-22 21:01:56 +00001141ifdef TARGET
1142
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001143TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1144 $(LLVM_SRC_ROOT)/lib/Target/Target.td \
Chris Lattner8a87f5f2006-03-03 01:54:54 +00001145 $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td \
1146 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td)
Reid Spencerf88808a2004-10-30 09:19:36 +00001147INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Chris Lattner2a023902004-12-16 17:28:50 +00001148INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1149.PRECIOUS: $(INCTMPFiles) $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001150
Chris Lattner2a023902004-12-16 17:28:50 +00001151# All of these files depend on tblgen and the .td files.
1152$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001153
Chris Lattnerf86914d2004-12-16 17:38:56 +00001154# INCFiles rule: All of the tblgen generated files are emitted to
1155# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1156# us to only "touch" the real file if the contents of it change. IOW, if
1157# tblgen is modified, all of the .inc.tmp files are regereated, but no
1158# dependencies of the .inc files are, unless the contents of the .inc file
1159# changes.
1160$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
Reid Spencerafdc82c2004-12-16 18:26:53 +00001161 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
Chris Lattner2a023902004-12-16 17:28:50 +00001162
1163$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1164$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001165 $(Echo) "Building $(<F) register names with tblgen"
1166 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001167
Chris Lattner2a023902004-12-16 17:28:50 +00001168$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1169$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001170 $(Echo) "Building $(<F) register information header with tblgen"
1171 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001172
Chris Lattner2a023902004-12-16 17:28:50 +00001173$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1174$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001175 $(Echo) "Building $(<F) register info implementation with tblgen"
1176 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001177
Chris Lattner2a023902004-12-16 17:28:50 +00001178$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1179$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001180 $(Echo) "Building $(<F) instruction names with tblgen"
1181 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001182
Chris Lattner2a023902004-12-16 17:28:50 +00001183$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1184$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001185 $(Echo) "Building $(<F) instruction information with tblgen"
1186 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001187
Chris Lattner2a023902004-12-16 17:28:50 +00001188$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1189$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001190 $(Echo) "Building $(<F) assembly writer with tblgen"
1191 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001192
Chris Lattner22f937a2004-12-16 17:34:04 +00001193$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1194$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1195 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Reid Spencerf88808a2004-10-30 09:19:36 +00001196 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001197
Chris Lattner2a023902004-12-16 17:28:50 +00001198$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1199$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001200 $(Echo) "Building $(<F) code emitter with tblgen"
1201 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001202
Chris Lattner33f98bd2005-09-03 01:15:25 +00001203$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1204$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1205 $(Echo) "Building $(<F) instruction selector implementation with tblgen"
1206 $(Verb) $(TableGen) -gen-dag-isel -o $@ $<
1207
Jim Laskey9ed90322005-10-21 19:05:19 +00001208$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1209$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1210 $(Echo) "Building $(<F) subtarget information with tblgen"
1211 $(Verb) $(TableGen) -gen-subtarget -o $@ $<
Chris Lattner33f98bd2005-09-03 01:15:25 +00001212
Reid Spencer81cd0492004-10-23 20:04:14 +00001213clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001214 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001215
1216endif
Chris Lattner0c4f4fe2003-08-15 02:18:35 +00001217
Reid Spencerf88808a2004-10-30 09:19:36 +00001218###############################################################################
1219# LEX AND YACC: Provide rules for generating sources with lex and yacc
1220###############################################################################
Chris Lattnerdb644dd2003-01-16 22:44:19 +00001221
Reid Spencerf88808a2004-10-30 09:19:36 +00001222#---------------------------------------------------------
1223# Provide rules for generating a .cpp source file from
1224# (f)lex input sources.
1225#---------------------------------------------------------
1226
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001227LexFiles := $(filter %.l,$(Sources))
Reid Spencerf88808a2004-10-30 09:19:36 +00001228
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001229ifneq ($(LexFiles),)
1230
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001231# Cancel built-in rules for lex
1232%.c: %.l
1233%.cpp: %.l
Reid Spencerf88808a2004-10-30 09:19:36 +00001234
Chris Lattner8104b4c2006-02-14 05:12:00 +00001235all:: $(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs)
1236
Reid Spencerf88808a2004-10-30 09:19:36 +00001237# Note the extra sed filtering here, used to cut down on the warnings emited
1238# by GCC. The last line is a gross hack to work around flex aparently not
1239# being able to resize the buffer on a large token input. Currently, for
1240# uninitialized string buffers in LLVM we can generate very long tokens, so
1241# this is a hack around it.
Chris Lattner92fc9b02003-08-15 20:00:47 +00001242# FIXME. (f.e. char Buffer[10000] )
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001243$(PROJ_SRC_DIR)/%.cpp: $(PROJ_SRC_DIR)/%.l
Reid Spencer993b95e2004-12-10 19:44:16 +00001244 $(Echo) Flexing $*.l
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001245 $(Verb) $(FLEX) -t $(PROJ_SRC_DIR)/$*.l | \
Reid Spencerf206bd72004-10-22 21:01:56 +00001246 $(SED) 's/void yyunput/inline void yyunput/' | \
1247 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1248 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001249 > $(PROJ_SRC_DIR)/$*.cpp
Chris Lattner8104b4c2006-02-14 05:12:00 +00001250
1251# IFF the .l file has changed since it was last checked into CVS, copy the .l
1252# file to .l.cvs and the generated .cpp file to .cpp.cvs. We use this mechanism
1253# so that people without flex can build LLVM by copying the .cvs files to the
1254# source location and building them.
1255$(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1256$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattner1e612822006-02-16 05:10:48 +00001257 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs || \
Chris Lattner8104b4c2006-02-14 05:12:00 +00001258 ($(CP) $< $@; $(CP) $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001259
Chris Lattner8104b4c2006-02-14 05:12:00 +00001260$(LexFiles:%.l=$(ObjDir)/%.o) : \
1261$(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
Chris Lattner2f7c9632001-06-06 20:29:01 +00001262
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001263clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001264 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001265
Reid Spencerf88808a2004-10-30 09:19:36 +00001266endif
1267
1268#---------------------------------------------------------
1269# Provide rules for generating a .cpp and .h source files
1270# from yacc (bison) input sources.
1271#---------------------------------------------------------
1272
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001273YaccFiles := $(filter %.y,$(Sources))
1274ifneq ($(YaccFiles),)
Reid Spencerf88808a2004-10-30 09:19:36 +00001275
1276.PRECIOUS: $(YaccOutput)
1277
Chris Lattnerb0240b22006-02-15 07:23:05 +00001278all:: $(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs)
Chris Lattnerc38a9752006-02-15 07:16:57 +00001279
Reid Spencerf88808a2004-10-30 09:19:36 +00001280# Cancel built-in rules for yacc
1281%.c: %.y
1282%.cpp: %.y
1283%.h: %.y
1284
Reid Spencerc49a8632005-12-21 23:17:06 +00001285# Rule for building the bison based parsers...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001286$(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
Reid Spencerf88808a2004-10-30 09:19:36 +00001287 $(Echo) "Bisoning $*.y"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001288 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1289 $(Verb) $(MV) -f $*.tab.c $(PROJ_SRC_DIR)/$*.cpp
1290 $(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
Chris Lattner2f7c9632001-06-06 20:29:01 +00001291
Chris Lattnerc38a9752006-02-15 07:16:57 +00001292# IFF the .y file has changed since it was last checked into CVS, copy the .y
1293# file to .y.cvs and the generated .cpp/.h file to .cpp.cvs/.h.cvs. We use this
1294# mechanism so that people without flex can build LLVM by copying the .cvs files
1295# to the source location and building them.
1296$(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1297$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattner1e612822006-02-16 05:10:48 +00001298 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs || \
Chris Lattnerc38a9752006-02-15 07:16:57 +00001299 ($(CP) $< $@; \
Chris Lattnerb0240b22006-02-15 07:23:05 +00001300 $(CP) $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs; \
Chris Lattnerc38a9752006-02-15 07:16:57 +00001301 $(CP) $(PROJ_SRC_DIR)/$*.h $(PROJ_SRC_DIR)/$*.h.cvs)
Reid Spencerc49a8632005-12-21 23:17:06 +00001302
Chris Lattnerc38a9752006-02-15 07:16:57 +00001303
1304$(YaccFiles:%.y=$(ObjDir)/%.o): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
1305
1306YaccOutput := $(YaccFiles:%.y=%.output)
Reid Spencerc49a8632005-12-21 23:17:06 +00001307
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001308clean-local::
Reid Spencerc49a8632005-12-21 23:17:06 +00001309 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencerf88808a2004-10-30 09:19:36 +00001310endif
Chris Lattner2f7c9632001-06-06 20:29:01 +00001311
Reid Spencerf88808a2004-10-30 09:19:36 +00001312###############################################################################
1313# OTHER RULES: Other rules needed
1314###############################################################################
Reid Spencerf206bd72004-10-22 21:01:56 +00001315
Chris Lattner23d47392003-01-16 21:06:18 +00001316# To create postscript files from dot files...
John Criswell4ffb8442003-10-02 19:02:02 +00001317ifneq ($(DOT),false)
Chris Lattner23d47392003-01-16 21:06:18 +00001318%.ps: %.dot
Reid Spencerf206bd72004-10-22 21:01:56 +00001319 $(DOT) -Tps < $< > $@
John Criswell3ef61af2003-06-30 21:59:07 +00001320else
1321%.ps: %.dot
Reid Spencerf88808a2004-10-30 09:19:36 +00001322 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell3ef61af2003-06-30 21:59:07 +00001323endif
Chris Lattner23d47392003-01-16 21:06:18 +00001324
John Criswell0a6e6aa2003-09-06 14:44:17 +00001325# This rules ensures that header files that are removed still have a rule for
1326# which they can be "generated." This allows make to ignore them and
1327# reproduce the dependency lists.
John Criswella8391af2003-09-18 18:37:08 +00001328%.h:: ;
Chris Lattnerf60c1702005-02-04 21:28:50 +00001329%.hpp:: ;
John Criswell0a6e6aa2003-09-06 14:44:17 +00001330
Reid Spencerf88808a2004-10-30 09:19:36 +00001331# Define clean-local to clean the current directory. Note that this uses a
1332# very conservative approach ensuring that empty variables do not cause
1333# errors or disastrous removal.
Reid Spencer81cd0492004-10-23 20:04:14 +00001334clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001335ifneq ($(strip $(ObjDir)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001336 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencer12a3a052004-10-24 07:53:21 +00001337endif
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001338 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke8625f682004-01-21 19:53:11 +00001339ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001340 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke8625f682004-01-21 19:53:11 +00001341endif
John Criswell3ef61af2003-06-30 21:59:07 +00001342
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001343clean-all-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001344 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001345
Reid Spencerf88808a2004-10-30 09:19:36 +00001346# Build tags database for Emacs/Xemacs:
Reid Spenceraee67e62004-11-12 02:27:36 +00001347tags:: TAGS CTAGS
1348
Reid Spencerf88808a2004-10-30 09:19:36 +00001349TAGS:
Reid Spencerba6a3db2005-01-16 02:20:54 +00001350 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1351 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1352 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1353 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spenceraee67e62004-11-12 02:27:36 +00001354 -name '*.cpp' -o -name '*.h' | \
Reid Spencerf88808a2004-10-30 09:19:36 +00001355 $(ETAGS) $(ETAGSFLAGS) -
1356
Reid Spenceraee67e62004-11-12 02:27:36 +00001357CTAGS:
Reid Spencerba6a3db2005-01-16 02:20:54 +00001358 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1359 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1360 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1361 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spenceraee67e62004-11-12 02:27:36 +00001362 \( -name '*.cpp' -o -name '*.h' \) -print | \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001363 ctags -ImtT -o $(PROJ_OBJ_ROOT)/CTAGS -L -
Reid Spenceraee67e62004-11-12 02:27:36 +00001364
1365
Reid Spencer81cd0492004-10-23 20:04:14 +00001366###############################################################################
1367# DEPENDENCIES: Include the dependency files if we should
1368###############################################################################
Chris Lattnere9d7d702003-08-22 14:10:16 +00001369ifndef DISABLE_AUTO_DEPENDENCIES
1370
Reid Spencer81cd0492004-10-23 20:04:14 +00001371# If its not one of the cleaning targets
Reid Spencerf88808a2004-10-30 09:19:36 +00001372ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencerf206bd72004-10-22 21:01:56 +00001373
Reid Spencer81cd0492004-10-23 20:04:14 +00001374# Get the list of dependency files
Reid Spencerf88808a2004-10-30 09:19:36 +00001375DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Chris Lattner8104b4c2006-02-14 05:12:00 +00001376DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
Misha Brukmanb891ffb2003-11-09 21:36:19 +00001377
Reid Spencer81cd0492004-10-23 20:04:14 +00001378-include /dev/null $(DependFiles)
1379
John Criswell48ecca62003-08-12 18:51:51 +00001380endif
Chris Lattner598222b2003-08-18 17:27:40 +00001381
Reid Spencerf88808a2004-10-30 09:19:36 +00001382endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001383
Reid Spencer100080c2004-10-25 08:27:37 +00001384###############################################################################
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001385# CHECK: Running the test suite
1386###############################################################################
1387
1388check::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001389 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1390 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001391 $(EchoCmd) Running test suite ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001392 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001393 TESTSUITE=$(TESTSUITE) ; \
1394 else \
1395 $(EchoCmd) No Makefile in test directory ; \
1396 fi ; \
1397 else \
1398 $(EchoCmd) No test directory ; \
1399 fi
1400
1401###############################################################################
Reid Spencerf88808a2004-10-30 09:19:36 +00001402# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer100080c2004-10-25 08:27:37 +00001403###############################################################################
1404
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001405#------------------------------------------------------------------------
1406# Define distribution related variables
1407#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +00001408DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1409DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1410TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1411DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1412DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1413DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
Reid Spencer100080c2004-10-25 08:27:37 +00001414DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1415 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001416 Makefile.config.in configure autoconf
1417DistOther := $(notdir $(wildcard \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001418 $(PROJ_SRC_DIR)/*.h \
1419 $(PROJ_SRC_DIR)/*.td \
1420 $(PROJ_SRC_DIR)/*.def \
1421 $(PROJ_SRC_DIR)/*.ll \
1422 $(PROJ_SRC_DIR)/*.in))
Reid Spencerf88808a2004-10-30 09:19:36 +00001423DistSubDirs := $(SubDirs)
Reid Spencerfc66af42004-11-29 05:00:33 +00001424DistSources = $(Sources) $(EXTRA_DIST)
1425DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer100080c2004-10-25 08:27:37 +00001426
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001427#------------------------------------------------------------------------
1428# We MUST build distribution with OBJ_DIR != SRC_DIR
1429#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +00001430ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001431dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerf88808a2004-10-30 09:19:36 +00001432 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001433
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001434else
1435
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001436#------------------------------------------------------------------------
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001437# Prevent attempt to run dist targets from anywhere but the top level
1438#------------------------------------------------------------------------
1439ifneq ($(LEVEL),.)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001440dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001441 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001442else
1443
1444#------------------------------------------------------------------------
1445# Provide the top level targets
1446#------------------------------------------------------------------------
1447
Reid Spencerf88808a2004-10-30 09:19:36 +00001448dist-gzip:: $(DistTarGZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001449
Reid Spencer81546582004-12-04 22:34:09 +00001450$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001451 $(Echo) Packing gzipped distribution tar file.
Reid Spencerba6a3db2005-01-16 02:20:54 +00001452 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
Reid Spencerfc66af42004-11-29 05:00:33 +00001453 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001454
Reid Spencerf88808a2004-10-30 09:19:36 +00001455dist-bzip2:: $(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001456
Reid Spencer81546582004-12-04 22:34:09 +00001457$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001458 $(Echo) Packing bzipped distribution tar file.
Reid Spencerba6a3db2005-01-16 02:20:54 +00001459 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
Reid Spencerfc66af42004-11-29 05:00:33 +00001460 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001461
Reid Spencerf88808a2004-10-30 09:19:36 +00001462dist-zip:: $(DistZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001463
Reid Spencer81546582004-12-04 22:34:09 +00001464$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001465 $(Echo) Packing zipped distribution file.
1466 $(Verb) rm -f $(DistZip)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001467 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001468
1469dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001470 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001471
Reid Spencer3a468752005-01-28 19:52:32 +00001472DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001473
Reid Spencer81546582004-12-04 22:34:09 +00001474dist-check:: $(DistTarGZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001475 $(Echo) Checking distribution tar file.
1476 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001477 $(RM) -rf $(DistCheckDir) ; \
1478 fi
Reid Spencerf88808a2004-10-30 09:19:36 +00001479 $(Verb) $(MKDIR) $(DistCheckDir)
1480 $(Verb) cd $(DistCheckDir) && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001481 $(MKDIR) $(DistCheckDir)/build && \
1482 $(MKDIR) $(DistCheckDir)/install && \
1483 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1484 cd build && \
1485 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
Reid Spencer13f51932005-05-24 02:33:20 +00001486 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
Reid Spencer81546582004-12-04 22:34:09 +00001487 $(MAKE) all && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001488 $(MAKE) check && \
1489 $(MAKE) install && \
1490 $(MAKE) uninstall && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001491 $(MAKE) dist-clean && \
Reid Spencerf88808a2004-10-30 09:19:36 +00001492 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001493
1494dist-clean::
Reid Spencerf88808a2004-10-30 09:19:36 +00001495 $(Echo) Cleaning distribution files
Reid Spencer81546582004-12-04 22:34:09 +00001496 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1497 $(DistCheckDir)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001498
1499endif
1500
1501#------------------------------------------------------------------------
1502# Provide the recursive distdir target for building the distribution directory
1503#------------------------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +00001504distdir: $(DistDir)/.makedistdir
1505$(DistDir)/.makedistdir: $(DistSources)
Reid Spencerf88808a2004-10-30 09:19:36 +00001506 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001507 if test -d "$(DistDir)" ; then \
1508 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1509 exit 1 ; \
1510 fi ; \
Reid Spencer81546582004-12-04 22:34:09 +00001511 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001512 $(RM) -rf $(DistDir); \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001513 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer15b85092006-04-10 16:46:04 +00001514 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001515 fi
Reid Spencerfc66af42004-11-29 05:00:33 +00001516 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencerf88808a2004-10-30 09:19:36 +00001517 $(Verb) $(MKDIR) $(DistDir)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001518 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1519 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
Reid Spencer100080c2004-10-25 08:27:37 +00001520 for file in $(DistFiles) ; do \
1521 case "$$file" in \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001522 $(PROJ_SRC_DIR)/*) \
Reid Spencer81546582004-12-04 22:34:09 +00001523 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1524 ;; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001525 $(PROJ_SRC_ROOT)/*) \
Reid Spencer81546582004-12-04 22:34:09 +00001526 file=`echo "$$file" | \
1527 sed "s#^$$srcrootstrip/##"` \
1528 ;; \
Reid Spencer100080c2004-10-25 08:27:37 +00001529 esac; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001530 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1531 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1532 from_dir="$(PROJ_SRC_DIR)" ; \
Reid Spencer81546582004-12-04 22:34:09 +00001533 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001534 from_dir=. ; \
Reid Spencer81546582004-12-04 22:34:09 +00001535 fi ; \
1536 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001537 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1538 to_dir="$(DistDir)/$$dir"; \
1539 $(MKDIR) "$$to_dir" ; \
1540 else \
1541 to_dir="$(DistDir)"; \
1542 fi; \
1543 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1544 if test -n "$$mid_dir" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001545 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001546 fi ; \
1547 if test -d "$$from_dir/$$file"; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001548 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1549 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
Reid Spencer13f51932005-05-24 02:33:20 +00001550 cd $(PROJ_SRC_DIR) ; \
1551 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1552 ( cd $$to_dir ; $(TAR) xf - ) ; \
1553 cd $(PROJ_OBJ_DIR) ; \
1554 else \
1555 cd $$from_dir ; \
1556 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1557 ( cd $$to_dir ; $(TAR) xf - ) ; \
1558 cd $(PROJ_OBJ_DIR) ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001559 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +00001560 elif test -f "$$from_dir/$$file" ; then \
Reid Spencerafdc82c2004-12-16 18:26:53 +00001561 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001562 elif test -L "$$from_dir/$$file" ; then \
Reid Spencerafdc82c2004-12-16 18:26:53 +00001563 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001564 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer81546582004-12-04 22:34:09 +00001565 $(EchoCmd) "===== WARNING: Distribution Source " \
1566 "$$from_dir/$$file Not Found!" ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001567 elif test "$(Verb)" != '@' ; then \
1568 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001569 fi; \
1570 done
Reid Spencerf88808a2004-10-30 09:19:36 +00001571 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer100080c2004-10-25 08:27:37 +00001572 if test "$$subdir" \!= "." ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001573 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001574 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer15b85092006-04-10 16:46:04 +00001575 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
Reid Spencer056f0222006-04-07 16:06:18 +00001576 DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001577 fi; \
1578 done
Reid Spencer81546582004-12-04 22:34:09 +00001579 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer13f51932005-05-24 02:33:20 +00001580 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
Chris Lattnerb8e7aa02006-02-14 04:27:15 +00001581 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1582 -name .svn \) -print` ;\
Reid Spencer81546582004-12-04 22:34:09 +00001583 $(MAKE) dist-hook ; \
1584 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1585 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1586 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1587 -o ! -type d ! -perm -444 -exec \
1588 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1589 || chmod -R a+r $(DistDir) ; \
1590 fi
Reid Spencer100080c2004-10-25 08:27:37 +00001591
Reid Spencerf88808a2004-10-30 09:19:36 +00001592# This is invoked by distdir target, define it as a no-op to avoid errors if not
1593# defined by user.
Reid Spencer100080c2004-10-25 08:27:37 +00001594dist-hook::
1595
Reid Spencer23a70372004-10-22 23:06:30 +00001596endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001597
1598###############################################################################
Reid Spencer12a3a052004-10-24 07:53:21 +00001599# TOP LEVEL - targets only to apply at the top level directory
1600###############################################################################
1601
1602ifeq ($(LEVEL),.)
1603
1604#------------------------------------------------------------------------
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001605# Install support for the project's include files:
Reid Spencer12a3a052004-10-24 07:53:21 +00001606#------------------------------------------------------------------------
1607install-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001608 $(Echo) Installing include files
Reid Spencerba6a3db2005-01-16 02:20:54 +00001609 $(Verb) $(MKDIR) $(PROJ_includedir)
Reid Spencerc43b1d42005-02-24 03:56:32 +00001610 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001611 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer48a82f42005-02-16 15:54:03 +00001612 for hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
1613 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS ` ; do \
Reid Spencerc43b1d42005-02-24 03:56:32 +00001614 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1615 if test \! -d "$$instdir" ; then \
1616 $(EchoCmd) Making install directory $$instdir ; \
1617 $(MKDIR) $$instdir ;\
1618 fi ; \
1619 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer48a82f42005-02-16 15:54:03 +00001620 done ; \
Reid Spencer12a3a052004-10-24 07:53:21 +00001621 fi
Reid Spencer528c9802005-12-23 22:27:56 +00001622ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencerc43b1d42005-02-24 03:56:32 +00001623 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
Reid Spencer48a82f42005-02-16 15:54:03 +00001624 cd $(PROJ_OBJ_ROOT)/include && \
Reid Spencer528c9802005-12-23 22:27:56 +00001625 for hdr in `find . -type f -print | grep -v CVS` ; do \
Reid Spencerc43b1d42005-02-24 03:56:32 +00001626 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer48a82f42005-02-16 15:54:03 +00001627 done ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001628 fi
Reid Spencer528c9802005-12-23 22:27:56 +00001629endif
Reid Spencer12a3a052004-10-24 07:53:21 +00001630
1631uninstall-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001632 $(Echo) Uninstalling include files
Reid Spencerba6a3db2005-01-16 02:20:54 +00001633 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1634 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer12a3a052004-10-24 07:53:21 +00001635 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001636 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' \
1637 -o -name '*.in' ')' -print ')' | \
1638 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001639 cd $(PROJ_SRC_ROOT)/include && \
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001640 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1641 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001642 fi
Reid Spencer12a3a052004-10-24 07:53:21 +00001643
Reid Spencer12a3a052004-10-24 07:53:21 +00001644endif
1645
Reid Spencerf206bd72004-10-22 21:01:56 +00001646#------------------------------------------------------------------------
1647# Print out the directories used for building
Reid Spencerf88808a2004-10-30 09:19:36 +00001648#------------------------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001649printvars::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001650 $(Echo) "BuildMode : " '$(BuildMode)'
1651 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1652 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1653 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1654 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1655 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1656 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1657 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1658 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1659 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1660 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
Reid Spencerfe0a01e2005-02-16 16:13:02 +00001661 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
Reid Spencerba6a3db2005-01-16 02:20:54 +00001662 $(Echo) "UserTargets : " '$(UserTargets)'
1663 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1664 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1665 $(Echo) "ObjDir : " '$(ObjDir)'
1666 $(Echo) "LibDir : " '$(LibDir)'
1667 $(Echo) "ToolDir : " '$(ToolDir)'
1668 $(Echo) "ExmplDir : " '$(ExmplDir)'
1669 $(Echo) "Sources : " '$(Sources)'
1670 $(Echo) "TDFiles : " '$(TDFiles)'
1671 $(Echo) "INCFiles : " '$(INCFiles)'
1672 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
Reid Spencerfefb9ea2005-03-01 16:27:06 +00001673 $(Echo) "PreConditions: " '$(PreConditions)'
Reid Spencerba6a3db2005-01-16 02:20:54 +00001674 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1675 $(Echo) "Compile.C : " '$(Compile.C)'
1676 $(Echo) "Archive : " '$(Archive)'
1677 $(Echo) "YaccFiles : " '$(YaccFiles)'
1678 $(Echo) "LexFiles : " '$(LexFiles)'
1679 $(Echo) "Module : " '$(Module)'
Reid Spencerb48e3f82005-08-24 10:43:10 +00001680 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
Reid Spencerece13582006-04-09 23:41:14 +00001681 $(Echo) "SubDirs : " '$(SubDirs)'