blob: c9795ec6969d8bb8e20670bf21e3d72c2fe43437 [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.
Reid Spencer187b4ad2006-06-01 19:03:21 +0000203ifneq ($(OS),MingW)
204 OPTIMIZE_OPTION := -O3
205else
206 OPTIMIZE_OPTION := -O2
207endif
Chris Lattner213a85b2006-05-24 23:02:40 +0000208
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000209ifdef ENABLE_PROFILING
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000210 BuildMode := Profile
Chris Lattner4a482452006-07-11 18:33:50 +0000211 CXX.Flags := $(OPTIMIZE_OPTION) -pg -g
212 C.Flags := $(OPTIMIZE_OPTION) -pg -g
213 LD.Flags := $(OPTIMIZE_OPTION) -pg -g
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000214else
215 ifdef ENABLE_OPTIMIZED
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000216 BuildMode := Release
Chris Lattnerdc5a8962006-07-27 18:19:51 +0000217 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
Reid Spencer34982d82005-01-02 17:43:20 +0000218 ifneq ($(OS),FreeBSD)
Chris Lattner040c1102006-05-24 18:34:08 +0000219 ifneq ($(OS),Darwin)
Reid Spencer34982d82005-01-02 17:43:20 +0000220 OmitFramePointer := -fomit-frame-pointer
221 endif
Chris Lattner040c1102006-05-24 18:34:08 +0000222 endif
Chris Lattnerdc5a8962006-07-27 18:19:51 +0000223
224 # Darwin requires -fstrict-aliasing to be explicitly enabled.
225 ifeq ($(OS),Darwin)
226 EXTRA_OPTIONS += -fstrict-aliasing
227 endif
228
Chris Lattner213a85b2006-05-24 23:02:40 +0000229 CXX.Flags := $(OPTIMIZE_OPTION) $(OmitFramePointer)
230 C.Flags := $(OPTIMIZE_OPTION) $(OmitFramePointer)
231 LD.Flags := $(OPTIMIZE_OPTION)
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000232 else
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000233 BuildMode := Debug
Chris Lattner98c79c32006-03-21 01:06:41 +0000234 CXX.Flags := -g
235 C.Flags := -g
Evan Cheng83c56aa2006-07-21 23:06:51 +0000236 LD.Flags := -g
Reid Spencerf206bd72004-10-22 21:01:56 +0000237 KEEP_SYMBOLS := 1
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000238 endif
239endif
240
Reid Spencer15b85092006-04-10 16:46:04 +0000241# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
242# then disable assertions by defining the appropriate preprocessor symbols.
Reid Spencerece13582006-04-09 23:41:14 +0000243ifdef DISABLE_ASSERTIONS
Reid Spencer056f0222006-04-07 16:06:18 +0000244 BuildMode := $(BuildMode)-Asserts
Chris Lattner98c79c32006-03-21 01:06:41 +0000245 CXX.Flags += -DNDEBUG
246 C.Flags += -DNDEBUG
Reid Spencerece13582006-04-09 23:41:14 +0000247else
248 CXX.Flags += -D_DEBUG
249 C.Flags += -D_DEBUG
Chris Lattner98c79c32006-03-21 01:06:41 +0000250endif
251
Reid Spencer6f682b72006-03-22 15:59:55 +0000252CXX.Flags += $(CXXFLAGS)
253C.Flags += $(CFLAGS)
254CPP.BaseFlags += $(CPPFLAGS)
255LD.Flags += $(LDFLAGS)
256AR.Flags := cru
Reid Spencerf88808a2004-10-30 09:19:36 +0000257LibTool.Flags := --tag=CXX
Reid Spencer81cd0492004-10-23 20:04:14 +0000258
Chris Lattnerdc5a8962006-07-27 18:19:51 +0000259# Make Floating point IEEE compliant on Alpha.
Andrew Lenharth9a98def2005-02-13 03:41:10 +0000260ifeq ($(ARCH),Alpha)
Andrew Lenharth2b0badd2006-07-20 17:27:58 +0000261 CXX.Flags += -mieee -fPIC
262 CPP.BaseFlags += -mieee -fPIC
Andrew Lenharth9a98def2005-02-13 03:41:10 +0000263endif
264
Reid Spencer81cd0492004-10-23 20:04:14 +0000265#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000266# Directory locations
Reid Spencer81cd0492004-10-23 20:04:14 +0000267#--------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +0000268ObjDir := $(PROJ_OBJ_DIR)/$(BuildMode)
269LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
270ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
271ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000272LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer0dbf1012004-11-18 20:04:39 +0000273LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencerb9f8de62004-12-28 07:59:22 +0000274LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer2bba41c2004-12-22 05:57:21 +0000275CFERuntimeLibDir := $(LLVMGCCDIR)/lib
John Criswell3ef61af2003-06-30 21:59:07 +0000276
Reid Spencer81cd0492004-10-23 20:04:14 +0000277#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000278# Full Paths To Compiled Tools and Utilities
Reid Spencer81cd0492004-10-23 20:04:14 +0000279#--------------------------------------------------------------------
Reid Spencerb12e2902005-01-14 16:33:36 +0000280EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
281Echo = @$(EchoCmd)
Reid Spencerf88808a2004-10-30 09:19:36 +0000282ifndef LIBTOOL
Reid Spencerf206bd72004-10-22 21:01:56 +0000283LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencerf88808a2004-10-30 09:19:36 +0000284endif
285ifndef LLVMAS
286LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
287endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000288ifndef TBLGEN
Reid Spencer0aa9d002006-07-26 21:14:56 +0000289 ifeq ($(LLVM_CROSS_COMPILING),1)
290 TBLGEN := $(LLVMToolDir)/tblgen$(BUILD_EXEEXT)
291 else
292 TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
293 endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000294endif
Chris Lattner0ea40c92004-11-29 19:47:58 +0000295ifndef GCCAS
296GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
297endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000298ifndef GCCLD
299GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
300endif
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000301ifndef LDIS
302LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
303endif
304ifndef LLI
305LLI := $(LLVMToolDir)/lli$(EXEEXT)
306endif
Alkis Evlogimenos24340582005-02-27 10:21:37 +0000307ifndef LLC
308LLC := $(LLVMToolDir)/llc$(EXEEXT)
309endif
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000310ifndef LOPT
Alkis Evlogimenos7c7705d2004-12-13 18:08:29 +0000311LOPT := $(LLVMToolDir)/opt$(EXEEXT)
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000312endif
Alkis Evlogimenos7c04a3d2005-02-02 00:40:15 +0000313ifndef LBUGPOINT
314LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
315endif
316
John Criswelldc665012005-01-03 17:42:57 +0000317LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
318LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000319
Reid Spencer81cd0492004-10-23 20:04:14 +0000320#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000321# Adjust to user's request
Reid Spencer81cd0492004-10-23 20:04:14 +0000322#--------------------------------------------------------------------
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000323
Reid Spencer87e645c2005-01-11 04:31:07 +0000324# Adjust LD.Flags and Libtool.Flags depending on the kind of library that is
325# to be built. Note that if LOADABLE_MODULE is specified then the resulting
Reid Spencere6458c32006-08-07 23:12:15 +0000326# shared library can be opened with dlopen. Also, LOADABLE_MODULE implies
327# several other things so we force them to be defined/on.
328ifdef LOADABLE_MODULE
329 SHARED_LIBRARY := 1
330 DONT_BUILD_RELINKED := 1
331 LINK_LIBS_IN_SHARED := 1
332 LD.Flags += -module
333endif
334
Reid Spencer87e645c2005-01-11 04:31:07 +0000335ifdef SHARED_LIBRARY
Reid Spencerf88808a2004-10-30 09:19:36 +0000336 LD.Flags += -rpath $(LibDir)
Reid Spencer87e645c2005-01-11 04:31:07 +0000337else
338 LibTool.Flags += --tag=disable-shared
John Criswell3601f372003-07-31 20:58:51 +0000339endif
340
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000341ifdef TOOL_VERBOSE
342 C.Flags += -v
343 CXX.Flags += -v
344 LD.Flags += -v
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000345 VERBOSE := 1
346endif
347
Reid Spencer81cd0492004-10-23 20:04:14 +0000348# Adjust settings for verbose mode
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000349ifndef VERBOSE
Reid Spencerf88808a2004-10-30 09:19:36 +0000350 Verb := @
351 LibTool.Flags += --silent
352 AR.Flags += >/dev/null 2>/dev/null
Reid Spencerba6a3db2005-01-16 02:20:54 +0000353 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
Reid Spencer100080c2004-10-25 08:27:37 +0000354else
Reid Spencerf88808a2004-10-30 09:19:36 +0000355 ConfigureScriptFLAGS :=
Misha Brukman1326a7c2002-09-12 16:05:39 +0000356endif
357
Vikram S. Adved141c282002-09-18 11:55:13 +0000358# By default, strip symbol information from executable
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000359ifndef KEEP_SYMBOLS
Reid Spencerf88808a2004-10-30 09:19:36 +0000360 Strip := $(PLATFORMSTRIPOPTS)
361 StripWarnMsg := "(without symbols)"
Reid Spencer247a10e2005-02-24 07:12:43 +0000362 Install.StripFlag += -s
Vikram S. Adved141c282002-09-18 11:55:13 +0000363endif
364
Reid Spencer81cd0492004-10-23 20:04:14 +0000365# Adjust linker flags for building an executable
Reid Spencerf206bd72004-10-22 21:01:56 +0000366ifdef TOOLNAME
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000367ifdef EXAMPLE_TOOL
368 LD.Flags += -rpath $(ExmplDir) -export-dynamic
369else
Reid Spencerf88808a2004-10-30 09:19:36 +0000370 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000371endif
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000372endif
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000373
Reid Spencer81cd0492004-10-23 20:04:14 +0000374#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000375# Options To Invoke Tools
Reid Spencer81cd0492004-10-23 20:04:14 +0000376#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000377
Reid Spencera62f0972006-06-01 01:55:21 +0000378CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused -Wno-long-long \
Evan Cheng9e7e4b52006-06-20 18:50:48 +0000379 -pedantic $(EXTRA_OPTIONS)
Reid Spencerf206bd72004-10-22 21:01:56 +0000380
Duraid Madina60c9a3c2005-05-16 06:38:09 +0000381ifeq ($(OS),HP-UX)
Duraid Madina1f898af2006-02-15 03:20:16 +0000382 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
Duraid Madina60c9a3c2005-05-16 06:38:09 +0000383endif
384
Chris Lattner11c25cf2006-05-30 16:38:06 +0000385# If we are building a universal binary on Mac OS/X, pass extra options. This
386# is useful to people that want to link the LLVM libraries into their universal
Chris Lattner65e28b32006-06-29 19:38:04 +0000387# apps.
388#
389# The following can be optionally specified:
390# UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
391# For Mac OS/X 10.4 Intel machines, the traditional one is:
392# UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
393# UNIVERSAL_ARCH can be optionally specified to be a list of architectures
394# to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
395# i386/ppc only.
Chris Lattnerd81eba52006-04-06 06:30:15 +0000396ifdef UNIVERSAL
Chris Lattner65e28b32006-06-29 19:38:04 +0000397 ifndef UNIVERSAL_ARCH
398 UNIVERSAL_ARCH := i386 ppc
399 endif
400 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
401 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
402 Relink.Flags := $(UNIVERSAL_ARCH_OPTIONS:%=-XCClinker %)
Chris Lattner64e85f32006-06-16 21:47:59 +0000403 ifdef UNIVERSAL_SDK_PATH
404 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
405 Relink.Flags += -XCClinker -isysroot -XCClinker $(UNIVERSAL_SDK_PATH)
406 endif
407
408 # Building universal cannot compute dependencies automatically.
Chris Lattnerd81eba52006-04-06 06:30:15 +0000409 DISABLE_AUTO_DEPENDENCIES=1
410endif
411
Reid Spencer6f682b72006-03-22 15:59:55 +0000412LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
413CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
414# All -I flags should go here, so that they don't confuse llvm-config.
415CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
416 -I$(PROJ_OBJ_ROOT)/include \
417 -I$(PROJ_SRC_ROOT)/include \
418 -I$(LLVM_OBJ_ROOT)/include \
419 -I$(LLVM_SRC_ROOT)/include \
420 $(CPP.BaseFlags)
Reid Spencerf206bd72004-10-22 21:01:56 +0000421
Reid Spencerf88808a2004-10-30 09:19:36 +0000422Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
423LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
Reid Spencer2bba41c2004-12-22 05:57:21 +0000424BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000425 $(C.Flags)
Chris Lattnerbb087952005-10-05 00:28:41 +0000426Preprocess.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -E $(C.Flags)
427
Reid Spencerf88808a2004-10-30 09:19:36 +0000428Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
429LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
Reid Spencerc005fba2004-12-24 14:47:34 +0000430BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000431 $(CXX.Flags)
Chris Lattnerbb087952005-10-05 00:28:41 +0000432Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
Reid Spencere6458c32006-08-07 23:12:15 +0000433Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
434 $(LD.Flags) $(Strip)
435LTLink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(Link)
436Relink = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
437 $(Relink.Flags)
438LTRelink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(Relink)
Reid Spencerfe0a01e2005-02-16 16:13:02 +0000439LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
440 $(Install.Flags)
Reid Spencer247a10e2005-02-24 07:12:43 +0000441ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
Reid Spencer6f682b72006-03-22 15:59:55 +0000442ScriptInstall = $(INSTALL) -m 0755
Reid Spencer247a10e2005-02-24 07:12:43 +0000443DataInstall = $(INSTALL) -m 0644
Vladimir Prus788db2c2006-05-16 06:39:36 +0000444TableGen = $(TBLGEN) -I $(PROJ_SRC_DIR) -I$(PROJ_SRC_ROOT)/include \
445 -I $(PROJ_SRC_ROOT)/lib/Target
Reid Spencerf88808a2004-10-30 09:19:36 +0000446Archive = $(AR) $(AR.Flags)
Reid Spencer32f7e422004-12-02 09:28:21 +0000447LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencerf206bd72004-10-22 21:01:56 +0000448ifdef RANLIB
Reid Spencer81cd0492004-10-23 20:04:14 +0000449Ranlib = $(RANLIB)
Reid Spencerf206bd72004-10-22 21:01:56 +0000450else
Reid Spencer81cd0492004-10-23 20:04:14 +0000451Ranlib = ranlib
John Criswell3ef61af2003-06-30 21:59:07 +0000452endif
453
Chris Lattner2f7c9632001-06-06 20:29:01 +0000454#----------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +0000455# Get the list of source files and compute object file
456# names from them.
Reid Spencer81cd0492004-10-23 20:04:14 +0000457#----------------------------------------------------------
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000458
459ifndef SOURCES
460 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
461 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
462 $(PROJ_SRC_DIR)/*.l))
Reid Spencerf88808a2004-10-30 09:19:36 +0000463else
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000464 Sources := $(SOURCES)
465endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000466
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000467ifdef BUILT_SOURCES
468Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Reid Spencer81546582004-12-04 22:34:09 +0000469endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000470
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000471BaseNameSources := $(sort $(basename $(Sources)))
472
473ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
474ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
475ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
476
Reid Spencer81cd0492004-10-23 20:04:14 +0000477###############################################################################
478# DIRECTORIES: Handle recursive descent of directory structure
479###############################################################################
John Criswell3601f372003-07-31 20:58:51 +0000480
Chris Lattner2f7c9632001-06-06 20:29:01 +0000481#---------------------------------------------------------
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000482# Provide rules to make install dirs. This must be early
483# in the file so they get built before dependencies
484#---------------------------------------------------------
485
Reid Spencer90b689d2005-05-19 20:26:14 +0000486$(PROJ_bindir): $(PROJ_bindir)/.dir
487$(PROJ_libdir): $(PROJ_libdir)/.dir
488$(PROJ_includedir): $(PROJ_includedir)/.dir
489$(PROJ_etcdir): $(PROJ_etcdir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000490
Reid Spencerf88808a2004-10-30 09:19:36 +0000491# To create other directories, as needed, and timestamp their creation
492%/.dir:
493 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfc66af42004-11-29 05:00:33 +0000494 $(Verb) $(DATE) > $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000495
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000496.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
497.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000498
499#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000500# Handle the DIRS options for sequential construction
Chris Lattner2f7c9632001-06-06 20:29:01 +0000501#---------------------------------------------------------
502
Reid Spencerf88808a2004-10-30 09:19:36 +0000503SubDirs :=
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000504ifdef DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000505SubDirs += $(DIRS)
Chris Lattnerb9259612006-07-26 20:22:26 +0000506
507ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencerf88808a2004-10-30 09:19:36 +0000508$(RecursiveTargets)::
509 $(Verb) for dir in $(DIRS); do \
Reid Spencerf206bd72004-10-22 21:01:56 +0000510 if [ ! -f $$dir/Makefile ]; then \
511 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000512 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000513 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000514 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattner539a23c2002-09-17 23:35:02 +0000515 done
Chris Lattnerb9259612006-07-26 20:22:26 +0000516else
517$(RecursiveTargets)::
518 $(Verb) for dir in $(DIRS); do \
519 ($(MAKE) -C $$dir $@ ) || exit 1; \
520 done
521endif
522
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000523endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000524
Reid Spencer81cd0492004-10-23 20:04:14 +0000525#---------------------------------------------------------
526# Handle the EXPERIMENTAL_DIRS options ensuring success
527# after each directory is built.
528#---------------------------------------------------------
529ifdef EXPERIMENTAL_DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000530$(RecursiveTargets)::
531 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer81cd0492004-10-23 20:04:14 +0000532 if [ ! -f $$dir/Makefile ]; then \
533 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000534 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000535 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000536 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000537 done
538endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000539
Reid Spencerc49a8632005-12-21 23:17:06 +0000540#-----------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000541# Handle the PARALLEL_DIRS options for parallel construction
Reid Spencerc49a8632005-12-21 23:17:06 +0000542#-----------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000543ifdef PARALLEL_DIRS
544
Reid Spencerf88808a2004-10-30 09:19:36 +0000545SubDirs += $(PARALLEL_DIRS)
546
Reid Spencerd4bd3752004-12-03 20:08:48 +0000547# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencerf88808a2004-10-30 09:19:36 +0000548all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
549clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000550clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencerf88808a2004-10-30 09:19:36 +0000551install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000552uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencerd4bd3752004-12-03 20:08:48 +0000553install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000554
Reid Spencer81546582004-12-04 22:34:09 +0000555ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer81cd0492004-10-23 20:04:14 +0000556
Reid Spencer81546582004-12-04 22:34:09 +0000557$(ParallelTargets) :
Reid Spencerf88808a2004-10-30 09:19:36 +0000558 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencerf206bd72004-10-22 21:01:56 +0000559 $(MKDIR) $(@D); \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000560 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswell6df35dd2003-11-25 19:32:22 +0000561 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000562 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ;
Chris Lattner2f7c9632001-06-06 20:29:01 +0000563endif
564
Reid Spencer81cd0492004-10-23 20:04:14 +0000565#---------------------------------------------------------
566# Handle the OPTIONAL_DIRS options for directores that may
567# or may not exist.
568#---------------------------------------------------------
John Criswell8224df92003-06-27 16:58:44 +0000569ifdef OPTIONAL_DIRS
Reid Spencer100080c2004-10-25 08:27:37 +0000570
Reid Spencerf88808a2004-10-30 09:19:36 +0000571SubDirs += $(OPTIONAL_DIRS)
Reid Spencer100080c2004-10-25 08:27:37 +0000572
Chris Lattnerb9259612006-07-26 20:22:26 +0000573ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencerf88808a2004-10-30 09:19:36 +0000574$(RecursiveTargets)::
575 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000576 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
Reid Spencerf206bd72004-10-22 21:01:56 +0000577 if [ ! -f $$dir/Makefile ]; then \
578 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000579 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000580 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000581 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000582 fi \
John Criswell8224df92003-06-27 16:58:44 +0000583 done
Chris Lattnerb9259612006-07-26 20:22:26 +0000584else
585$(RecursiveTargets)::
586 $(Verb) for dir in $(OPTIONAL_DIRS); do \
587 ($(MAKE) -C$$dir $@ ) || exit 1; \
588 done
589endif
John Criswell8224df92003-06-27 16:58:44 +0000590endif
591
Reid Spencercc51e7b2004-08-20 09:20:05 +0000592#---------------------------------------------------------
593# Handle the CONFIG_FILES options
594#---------------------------------------------------------
595ifdef CONFIG_FILES
Reid Spencercc51e7b2004-08-20 09:20:05 +0000596
Reid Spencerba6a3db2005-01-16 02:20:54 +0000597install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
598 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000599 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000600 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
Reid Spencerc43b1d42005-02-24 03:56:32 +0000601 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000602 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
Reid Spencerc43b1d42005-02-24 03:56:32 +0000603 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer39d6a612004-11-23 05:59:53 +0000604 else \
605 $(ECHO) Error: cannot find config file $${file}. ; \
606 fi \
Reid Spencercc51e7b2004-08-20 09:20:05 +0000607 done
Reid Spencer81cd0492004-10-23 20:04:14 +0000608
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000609uninstall-local::
Reid Spencerba6a3db2005-01-16 02:20:54 +0000610 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000611 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000612 $(RM) -f $(PROJ_etcdir)/$${file} ; \
Reid Spencer12a3a052004-10-24 07:53:21 +0000613 done
614
Reid Spencercc51e7b2004-08-20 09:20:05 +0000615endif
616
Reid Spencer81cd0492004-10-23 20:04:14 +0000617###############################################################################
Reid Spencera80f1672005-05-19 00:37:31 +0000618# Set up variables for building libararies
619###############################################################################
620
621#---------------------------------------------------------
622# Handle the special "JIT" value for LLVM_LIBS which is a
623# shorthand for a bunch of libraries that get the correct
624# JIT support for a library or a tool that runs JIT.
625#---------------------------------------------------------
Reid Spencerd813b952006-03-24 07:36:57 +0000626ifeq ($(firstword $(LLVMLIBS)),config)
627LLVM_CONFIG := $(LLVM_SRC_ROOT)/utils/llvm-config/llvm-config
Reid Spencer056f0222006-04-07 16:06:18 +0000628LLVMLIBS := $(shell $(LLVM_CONFIG) --libnames $(wordlist 2,9999,$(LLVMLIBS)))
629LLVMLIBS := $(patsubst lib%.a,%.a,$(LLVMLIBS))
Reid Spencerd813b952006-03-24 07:36:57 +0000630LLVMLIBS := $(patsubst %.o,%,$(LLVMLIBS))
Reid Spencerd813b952006-03-24 07:36:57 +0000631endif
632
Reid Spencera80f1672005-05-19 00:37:31 +0000633ifeq ($(LLVMLIBS),JIT)
634
635# Make sure we can get our own symbols in the tool
636Link += -dlopen self
637
638# Generic JIT libraries
Devang Patel2c15c012006-07-21 19:44:55 +0000639JIT_LIBS := LLVMInterpreter LLVMJIT LLVMSelectionDAG.a LLVMCodeGen.a \
640 LLVMExecutionEngine
Reid Spencera80f1672005-05-19 00:37:31 +0000641
642# You can enable the X86 JIT on a non-X86 host by setting the flag
643# ENABLE_X86_JIT on the make command line. If not, it will still be
644# enabled automagically on an X86 host.
645ifeq ($(ARCH), x86)
646 ENABLE_X86_JIT = 1
647endif
648
649# What the X86 JIT requires
650ifdef ENABLE_X86_JIT
Devang Patel2c15c012006-07-21 19:44:55 +0000651 JIT_LIBS += LLVMX86
Reid Spencera80f1672005-05-19 00:37:31 +0000652endif
653
Reid Spencera80f1672005-05-19 00:37:31 +0000654# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
655# ENABLE_PPC_JIT on the make command line. If not, it will still be
656# enabled automagically on an PowerPC host.
657ifeq ($(ARCH), PowerPC)
658 ENABLE_PPC_JIT = 1
659endif
660
661# What the PowerPC JIT requires
662ifdef ENABLE_PPC_JIT
Devang Patel2c15c012006-07-21 19:44:55 +0000663 JIT_LIBS += LLVMPowerPC
Reid Spencera80f1672005-05-19 00:37:31 +0000664endif
665
Andrew Lenharthc7fe0f52005-07-22 20:54:01 +0000666# You can enable the Alpha JIT on a non-Alpha host by setting the flag
667# ENABLE_ALPHA_JIT on the make command line. If not, it will still be
Misha Brukman08c36452005-07-22 22:43:40 +0000668# enabled automagically on an Alpha host.
Andrew Lenharthc7fe0f52005-07-22 20:54:01 +0000669ifeq ($(ARCH), Alpha)
670 ENABLE_ALPHA_JIT = 1
671endif
672
Andrew Lenharth99007012005-07-22 22:00:24 +0000673# What the Alpha JIT requires
Andrew Lenharthc7fe0f52005-07-22 20:54:01 +0000674ifdef ENABLE_ALPHA_JIT
Devang Patel2c15c012006-07-21 19:44:55 +0000675 JIT_LIBS += LLVMAlpha
Andrew Lenharthc7fe0f52005-07-22 20:54:01 +0000676endif
677
John Criswellfe5f33b2005-10-27 15:54:34 +0000678LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts.a LLVMTransformUtils.a LLVMAnalysis.a \
Reid Spencera647c7f2006-06-01 01:30:27 +0000679 LLVMBCReader.a LLVMTarget.a LLVMCore.a LLVMSupport.a LLVMbzip2.a \
Reid Spencera80f1672005-05-19 00:37:31 +0000680 LLVMSystem.a $(PLATFORMLIBDL)
681endif
682
683#---------------------------------------------------------
684# Define various command line options pertaining to the
685# libraries needed when linking. There are "Proj" libs
686# (defined by the user's project) and "LLVM" libs (defined
687# by the # LLVM project).
688#---------------------------------------------------------
Andrew Lenharth6b62b472005-08-13 05:09:50 +0000689
Reid Spencera80f1672005-05-19 00:37:31 +0000690ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
691ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
692LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
693LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
694ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
695LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
696ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
697LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
698
699###############################################################################
Reid Spencer81cd0492004-10-23 20:04:14 +0000700# Library Build Rules: Four ways to build a library
701###############################################################################
Chris Lattner2f7c9632001-06-06 20:29:01 +0000702
Reid Spencerd78077d2004-12-05 05:17:22 +0000703#---------------------------------------------------------
704# Bytecode Module Targets:
705# If the user set MODULE_NAME then they want to build a
706# bytecode module from the sources. We compile all the
707# sources and link it together into a single bytecode
708# module.
709#---------------------------------------------------------
710
711ifdef MODULE_NAME
Reid Spencere9fa5442005-02-14 21:54:08 +0000712ifeq ($(strip $(LLVMGCC)),)
Reid Spencer83745dd2005-05-13 18:32:54 +0000713$(warning Modules require llvm-gcc but no llvm-gcc is available ****)
Reid Spencere9fa5442005-02-14 21:54:08 +0000714else
Reid Spencerd78077d2004-12-05 05:17:22 +0000715
716Module := $(LibDir)/$(MODULE_NAME).bc
Reid Spencer78ede562006-04-12 18:21:35 +0000717LinkModule := $(GCCLD) -L$(CFERuntimeLibDir)
718
Reid Spencerd78077d2004-12-05 05:17:22 +0000719
720ifdef EXPORTED_SYMBOL_FILE
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000721LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencerd78077d2004-12-05 05:17:22 +0000722endif
723
724$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
Reid Spencer83745dd2005-05-13 18:32:54 +0000725 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
Reid Spencerd78077d2004-12-05 05:17:22 +0000726 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
727
728all-local:: $(Module)
729
730clean-local::
731ifneq ($(strip $(Module)),)
732 -$(Verb) $(RM) -f $(Module)
733endif
734
Reid Spencerefe3a822004-12-13 07:38:07 +0000735ifdef BYTECODE_DESTINATION
736ModuleDestDir := $(BYTECODE_DESTINATION)
737else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000738ModuleDestDir := $(PROJ_libdir)
Reid Spencerefe3a822004-12-13 07:38:07 +0000739endif
Reid Spencerd78077d2004-12-05 05:17:22 +0000740
Reid Spencerefe3a822004-12-13 07:38:07 +0000741DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
742
743install-module:: $(DestModule)
Reid Spencerd78077d2004-12-05 05:17:22 +0000744install-local:: $(DestModule)
745
Reid Spencerefe3a822004-12-13 07:38:07 +0000746$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencerd78077d2004-12-05 05:17:22 +0000747 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
Reid Spencerd77a4c02005-02-24 21:30:37 +0000748 $(Verb) $(DataInstall) $(Module) $(DestModule)
Reid Spencerd78077d2004-12-05 05:17:22 +0000749
750uninstall-local::
751 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
752 -$(Verb) $(RM) -f $(DestModule)
753
754endif
Reid Spencere9fa5442005-02-14 21:54:08 +0000755endif
Brian Gaekeecc92bf2004-01-22 22:53:48 +0000756
Reid Spencer81cd0492004-10-23 20:04:14 +0000757# if we're building a library ...
Chris Lattner2f7c9632001-06-06 20:29:01 +0000758ifdef LIBRARYNAME
Vikram S. Advefe346892001-07-15 13:16:47 +0000759
Chris Lattner0100eab2002-09-16 22:36:42 +0000760# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000761LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencer87e645c2005-01-11 04:31:07 +0000762ifdef LOADABLE_MODULE
763LibName.LA := $(LibDir)/$(LIBRARYNAME).la
764else
Reid Spencerf88808a2004-10-30 09:19:36 +0000765LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
Reid Spencer87e645c2005-01-11 04:31:07 +0000766endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000767LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
768LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer32f7e422004-12-02 09:28:21 +0000769LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000770
Reid Spencer81cd0492004-10-23 20:04:14 +0000771#---------------------------------------------------------
772# Shared Library Targets:
773# If the user asked for a shared library to be built
774# with the SHARED_LIBRARY variable, then we provide
775# targets for building them.
776#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000777ifdef SHARED_LIBRARY
778
Reid Spencerf88808a2004-10-30 09:19:36 +0000779all-local:: $(LibName.LA)
Reid Spencerf206bd72004-10-22 21:01:56 +0000780
Reid Spencera80f1672005-05-19 00:37:31 +0000781ifdef LINK_LIBS_IN_SHARED
Reid Spencere6458c32006-08-07 23:12:15 +0000782ifdef LOADABLE_MODULE
783SharedLibKindMessage := "Lodable Module"
784else
785SharedLibKindMessage := "Shared Library"
786endif
Reid Spencera80f1672005-05-19 00:37:31 +0000787$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
Reid Spencere6458c32006-08-07 23:12:15 +0000788 $(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
789 $(LIBRARYNAME)$(SHLIBEXT)
790 $(Verb) $(LTLink) -o $@ $(ObjectsLO) $(ProjLibsOptions) \
791 $(LLVMLibsOptions)
Reid Spencera80f1672005-05-19 00:37:31 +0000792 $(Verb) $(LTInstall) $@ $(LibDir)
793else
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000794$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000795 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencere6458c32006-08-07 23:12:15 +0000796 $(Verb) $(LTLink) -o $@ $(ObjectsLO)
Reid Spencerf88808a2004-10-30 09:19:36 +0000797 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencera80f1672005-05-19 00:37:31 +0000798endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000799
800clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000801ifneq ($(strip $(LibName.LA)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000802 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000803endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000804
Reid Spencerba6a3db2005-01-16 02:20:54 +0000805DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf206bd72004-10-22 21:01:56 +0000806
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000807install-local:: $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000808
Reid Spencerba6a3db2005-01-16 02:20:54 +0000809$(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000810 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000811 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000812 $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
Reid Spencer12a3a052004-10-24 07:53:21 +0000813
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000814uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000815 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000816 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
Reid Spencer12a3a052004-10-24 07:53:21 +0000817
Reid Spencerf206bd72004-10-22 21:01:56 +0000818endif
819
Reid Spencer81cd0492004-10-23 20:04:14 +0000820#---------------------------------------------------------
821# Bytecode Library Targets:
822# If the user asked for a bytecode library to be built
823# with the BYTECODE_LIBRARY variable, then we provide
824# targets for building them.
825#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000826ifdef BYTECODE_LIBRARY
Reid Spencere9fa5442005-02-14 21:54:08 +0000827ifeq ($(strip $(LLVMGCC)),)
Reid Spencer83745dd2005-05-13 18:32:54 +0000828$(warning Bytecode libraries require llvm-gcc which could not be found ****)
Reid Spencere9fa5442005-02-14 21:54:08 +0000829else
Reid Spencerf206bd72004-10-22 21:01:56 +0000830
Reid Spencer32f7e422004-12-02 09:28:21 +0000831all-local:: $(LibName.BCA)
832
833ifdef EXPORTED_SYMBOL_FILE
Chris Lattner11c25cf2006-05-30 16:38:06 +0000834BCLinkLib = $(GCCLD) -L$(CFERuntimeLibDir) \
835 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer32f7e422004-12-02 09:28:21 +0000836
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000837$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +0000838 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +0000839 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
840 "(internalize)"
Chris Lattnere3d98f12004-12-02 21:23:43 +0000841 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencer85d55ad2004-12-13 03:59:35 +0000842 $(Verb) $(RM) -f $@
Reid Spencer32f7e422004-12-02 09:28:21 +0000843 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencerf206bd72004-10-22 21:01:56 +0000844else
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000845$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +0000846 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +0000847 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencer85d55ad2004-12-13 03:59:35 +0000848 $(Verb) $(RM) -f $@
Reid Spencer32f7e422004-12-02 09:28:21 +0000849 $(Verb) $(LArchive) $@ $(ObjectsBC)
850
Reid Spencerf206bd72004-10-22 21:01:56 +0000851endif
852
Reid Spencer81cd0492004-10-23 20:04:14 +0000853clean-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000854ifneq ($(strip $(LibName.BCA)),)
855 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000856endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000857
Reid Spencer65086be2004-12-13 07:28:21 +0000858ifdef BYTECODE_DESTINATION
859BytecodeDestDir := $(BYTECODE_DESTINATION)
860else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000861BytecodeDestDir := $(PROJ_libdir)
Reid Spencer65086be2004-12-13 07:28:21 +0000862endif
863
864DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
Reid Spencer32f7e422004-12-02 09:28:21 +0000865
Reid Spencerd4bd3752004-12-03 20:08:48 +0000866install-bytecode-local:: $(DestBytecodeLib)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000867
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000868install-local:: $(DestBytecodeLib)
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000869
Reid Spencer65086be2004-12-13 07:28:21 +0000870$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
Reid Spencer32f7e422004-12-02 09:28:21 +0000871 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerdcc53752005-02-24 21:36:32 +0000872 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000873
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000874uninstall-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000875 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000876 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000877
878endif
Reid Spencere9fa5442005-02-14 21:54:08 +0000879endif
Vikram S. Adve15bd3ad2002-08-02 18:34:12 +0000880
Reid Spencerf88808a2004-10-30 09:19:36 +0000881#---------------------------------------------------------
882# ReLinked Library Targets:
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000883# If the user explicitly requests a relinked library with
884# BUILD_RELINKED, provide it. Otherwise, if they specify
885# neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
886# them one.
Reid Spencerf88808a2004-10-30 09:19:36 +0000887#---------------------------------------------------------
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000888ifndef BUILD_ARCHIVE
Chris Lattner76d98ba2002-07-23 17:56:16 +0000889ifndef DONT_BUILD_RELINKED
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000890BUILD_RELINKED = 1
891endif
892endif
893
894ifdef BUILD_RELINKED
Reid Spencerf206bd72004-10-22 21:01:56 +0000895
Reid Spencerf88808a2004-10-30 09:19:36 +0000896all-local:: $(LibName.O)
897
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000898$(LibName.O): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000899 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencere6458c32006-08-07 23:12:15 +0000900 $(Verb) $(LTRelink) -o $@ $(ObjectsO)
Reid Spencerf206bd72004-10-22 21:01:56 +0000901
Reid Spencer81cd0492004-10-23 20:04:14 +0000902clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000903ifneq ($(strip $(LibName.O)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000904 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencer12a3a052004-10-24 07:53:21 +0000905endif
906
Reid Spencerba6a3db2005-01-16 02:20:54 +0000907DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
Reid Spencer12a3a052004-10-24 07:53:21 +0000908
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000909install-local:: $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000910
Reid Spencerba6a3db2005-01-16 02:20:54 +0000911$(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000912 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000913 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000914
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000915uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000916 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000917 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000918
Chris Lattner76d98ba2002-07-23 17:56:16 +0000919endif
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000920
Reid Spencerf88808a2004-10-30 09:19:36 +0000921#---------------------------------------------------------
922# Archive Library Targets:
923# If the user wanted a regular archive library built,
924# then we provide targets for building them.
925#---------------------------------------------------------
Chris Lattner76d98ba2002-07-23 17:56:16 +0000926ifdef BUILD_ARCHIVE
Chris Lattner76d98ba2002-07-23 17:56:16 +0000927
Reid Spencerf88808a2004-10-30 09:19:36 +0000928all-local:: $(LibName.A)
929
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000930$(LibName.A): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000931 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000932 -$(Verb) $(RM) -f $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000933 $(Verb) $(Archive) $@ $(ObjectsO)
934 $(Verb) $(Ranlib) $@
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000935
Reid Spencer81cd0492004-10-23 20:04:14 +0000936clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000937ifneq ($(strip $(LibName.A)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000938 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000939endif
940
Reid Spencerba6a3db2005-01-16 02:20:54 +0000941DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
Reid Spencer12a3a052004-10-24 07:53:21 +0000942
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000943install-local:: $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000944
Reid Spencerba6a3db2005-01-16 02:20:54 +0000945$(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000946 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000947 $(Verb) $(MKDIR) $(PROJ_libdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000948 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000949
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000950uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000951 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000952 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000953
954endif
955
956# endif LIBRARYNAME
Reid Spencerf206bd72004-10-22 21:01:56 +0000957endif
958
Reid Spencerdcba7782004-10-24 08:21:04 +0000959###############################################################################
960# Tool Build Rules: Build executable tool based on TOOLNAME option
961###############################################################################
962
Chris Lattner07c7c192001-09-07 22:57:58 +0000963ifdef TOOLNAME
964
Reid Spencerf88808a2004-10-30 09:19:36 +0000965#---------------------------------------------------------
966# Set up variables for building a tool.
967#---------------------------------------------------------
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000968ifdef EXAMPLE_TOOL
Reid Spencer98a2d982005-05-19 21:03:11 +0000969ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000970else
Reid Spencer98a2d982005-05-19 21:03:11 +0000971ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000972endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000973
Reid Spencerf88808a2004-10-30 09:19:36 +0000974#---------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000975# Tell make that we need to rebuild subdirectories before
976# we can link the tool. This affects things like LLI which
977# has library subdirectories.
978#---------------------------------------------------------
979$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner3ecb7762003-01-22 16:13:31 +0000980
Reid Spencerf88808a2004-10-30 09:19:36 +0000981#---------------------------------------------------------
982# Provide targets for building the tools
983#---------------------------------------------------------
984all-local:: $(ToolBuildPath)
John Criswell8224df92003-06-27 16:58:44 +0000985
Reid Spencer81cd0492004-10-23 20:04:14 +0000986clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000987ifneq ($(strip $(ToolBuildPath)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000988 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencer12a3a052004-10-24 07:53:21 +0000989endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000990
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000991ifdef EXAMPLE_TOOL
992$(ToolBuildPath): $(ExmplDir)/.dir
993else
994$(ToolBuildPath): $(ToolDir)/.dir
995endif
996
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000997$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000998 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencere6458c32006-08-07 23:12:15 +0000999 $(Verb) $(LTLink) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
Reid Spencer10536582006-05-16 06:25:14 +00001000 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001001 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
1002 $(StripWarnMsg)
Reid Spencer12a3a052004-10-24 07:53:21 +00001003
Reid Spencerba6a3db2005-01-16 02:20:54 +00001004DestTool = $(PROJ_bindir)/$(TOOLNAME)
Reid Spencer12a3a052004-10-24 07:53:21 +00001005
Reid Spencerbe6a4e92004-10-28 07:57:28 +00001006install-local:: $(DestTool)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001007
Reid Spencerba6a3db2005-01-16 02:20:54 +00001008$(DestTool): $(PROJ_bindir) $(ToolBuildPath)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001009 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencerc43b1d42005-02-24 03:56:32 +00001010 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +00001011
Reid Spencerbe6a4e92004-10-28 07:57:28 +00001012uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001013 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001014 -$(Verb) $(RM) -f $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +00001015
Reid Spencerf206bd72004-10-22 21:01:56 +00001016endif
Chris Lattner07c7c192001-09-07 22:57:58 +00001017
Reid Spencerf88808a2004-10-30 09:19:36 +00001018###############################################################################
1019# Object Build Rules: Build object files based on sources
1020###############################################################################
1021
Duraid Madinacbbc1842006-02-15 03:23:26 +00001022# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1023ifeq ($(OS),HP-UX)
1024 DISABLE_AUTO_DEPENDENCIES=1
1025endif
1026
Chris Lattner085c7152006-06-21 20:58:03 +00001027ifdef SHARED_LIBRARY
1028PIC_FLAG = "(PIC)"
1029MAYBE_PIC_Compile.CXX = $(LTCompile.CXX)
1030MAYBE_PIC_Compile.C = $(LTCompile.C)
1031else
1032MAYBE_PIC_Compile.CXX = $(Compile.CXX)
1033MAYBE_PIC_Compile.C = $(Compile.C)
1034endif
1035
Reid Spencerf88808a2004-10-30 09:19:36 +00001036# Provide rule sets for when dependency generation is enabled
Reid Spencerf206bd72004-10-22 21:01:56 +00001037ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve20aa62f2002-09-20 14:03:13 +00001038
Reid Spencerf88808a2004-10-30 09:19:36 +00001039#---------------------------------------------------------
1040# Create .lo files in the ObjDir directory from the .cpp and .c files...
1041#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001042
Chris Lattner2a023902004-12-16 17:28:50 +00001043$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001044 $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
1045 $(Verb) if $(MAYBE_PIC_Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
1046 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
1047 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +00001048
Chris Lattnerf60c1702005-02-04 21:28:50 +00001049$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001050 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1051 $(Verb) if $(MAYBE_PIC_Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
Chris Lattnerf60c1702005-02-04 21:28:50 +00001052 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
1053 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
1054
Chris Lattner2a023902004-12-16 17:28:50 +00001055$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001056 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1057 $(Verb) if $(MAYBE_PIC_Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001058 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
1059 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +00001060
Reid Spencerf88808a2004-10-30 09:19:36 +00001061#---------------------------------------------------------
Chris Lattnerf60c1702005-02-04 21:28:50 +00001062# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
Reid Spencerf88808a2004-10-30 09:19:36 +00001063#---------------------------------------------------------
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001064
1065$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001066 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001067 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1068 $< -o $@ -S -emit-llvm ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001069 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1070 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +00001071
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001072$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001073 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001074 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1075 $< -o $@ -S -emit-llvm ; \
Chris Lattnerf60c1702005-02-04 21:28:50 +00001076 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1077 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1078
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001079$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001080 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001081 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" \
1082 $< -o $@ -S -emit-llvm ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001083 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1084 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +00001085
Reid Spencerf88808a2004-10-30 09:19:36 +00001086# Provide alternate rule sets if dependencies are disabled
Reid Spencerf206bd72004-10-22 21:01:56 +00001087else
1088
Chris Lattner2a023902004-12-16 17:28:50 +00001089$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001090 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1091 $(MAYBE_PIC_Compile.CXX) $< -o $@
Reid Spencer81cd0492004-10-23 20:04:14 +00001092
Chris Lattnerf60c1702005-02-04 21:28:50 +00001093$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001094 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1095 $(MAYBE_PIC_Compile.CXX) $< -o $@
Chris Lattnerf60c1702005-02-04 21:28:50 +00001096
Chris Lattner2a023902004-12-16 17:28:50 +00001097$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattner085c7152006-06-21 20:58:03 +00001098 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1099 $(MAYBE_PIC_Compile.C) $< -o $@
Reid Spencerf206bd72004-10-22 21:01:56 +00001100
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001101$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001102 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001103 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Reid Spencerf206bd72004-10-22 21:01:56 +00001104
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001105$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001106 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001107 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Chris Lattnerf60c1702005-02-04 21:28:50 +00001108
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001109$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001110 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001111 $(BCCompile.C) $< -o $@ -S -emit-llvm
Brian Gaeke0f148bc2003-12-10 00:26:28 +00001112
Chris Lattner07c7c192001-09-07 22:57:58 +00001113endif
1114
Chris Lattner161a84e2006-06-21 21:01:20 +00001115
1116## Rules for building preprocessed (.i/.ii) outputs.
1117$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1118 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1119 $(Verb) $(Preprocess.CXX) $< -o $@
1120
1121$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1122 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1123 $(Verb) $(Preprocess.CXX) $< -o $@
1124
1125 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1126 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1127 $(Verb) $(Preprocess.C) $< -o $@
1128
1129
1130$(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1131 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1132 $(MAYBE_PIC_Compile.CXX) $< -o $@ -S
1133
1134$(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1135 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1136 $(MAYBE_PIC_Compile.CXX) $< -o $@ -S
1137
1138$(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1139 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1140 $(MAYBE_PIC_Compile.C) $< -o $@ -S
1141
1142
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001143# make the C and C++ compilers strip debug info out of bytecode libraries.
1144ifdef DEBUG_RUNTIME
1145$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1146 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Chris Lattner5b59d7c2006-03-09 06:00:05 +00001147 $(Verb) $(GCCAS) $< -o $@
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001148else
1149$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1150 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Chris Lattner5b59d7c2006-03-09 06:00:05 +00001151 $(Verb) $(GCCAS) -strip-debug $< -o $@
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001152endif
1153
1154
Reid Spencerf88808a2004-10-30 09:19:36 +00001155#---------------------------------------------------------
1156# Provide rule to build .bc files from .ll sources,
1157# regardless of dependencies
1158#---------------------------------------------------------
1159$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001160 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +00001161 $(Verb) $(LLVMAS) $< -f -o $@
1162
1163###############################################################################
1164# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1165###############################################################################
Chris Lattner0c4f4fe2003-08-15 02:18:35 +00001166
Reid Spencerf206bd72004-10-22 21:01:56 +00001167ifdef TARGET
1168
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001169TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1170 $(LLVM_SRC_ROOT)/lib/Target/Target.td \
Chris Lattner8a87f5f2006-03-03 01:54:54 +00001171 $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td \
1172 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td)
Reid Spencerf88808a2004-10-30 09:19:36 +00001173INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Chris Lattner2a023902004-12-16 17:28:50 +00001174INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1175.PRECIOUS: $(INCTMPFiles) $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001176
Chris Lattner2a023902004-12-16 17:28:50 +00001177# All of these files depend on tblgen and the .td files.
1178$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001179
Chris Lattnerf86914d2004-12-16 17:38:56 +00001180# INCFiles rule: All of the tblgen generated files are emitted to
1181# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1182# us to only "touch" the real file if the contents of it change. IOW, if
1183# tblgen is modified, all of the .inc.tmp files are regereated, but no
1184# dependencies of the .inc files are, unless the contents of the .inc file
1185# changes.
1186$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
Reid Spencerafdc82c2004-12-16 18:26:53 +00001187 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
Chris Lattner2a023902004-12-16 17:28:50 +00001188
1189$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1190$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001191 $(Echo) "Building $(<F) register names with tblgen"
1192 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001193
Chris Lattner2a023902004-12-16 17:28:50 +00001194$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1195$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001196 $(Echo) "Building $(<F) register information header with tblgen"
1197 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001198
Chris Lattner2a023902004-12-16 17:28:50 +00001199$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1200$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001201 $(Echo) "Building $(<F) register info implementation with tblgen"
1202 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001203
Chris Lattner2a023902004-12-16 17:28:50 +00001204$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1205$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001206 $(Echo) "Building $(<F) instruction names with tblgen"
1207 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001208
Chris Lattner2a023902004-12-16 17:28:50 +00001209$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1210$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001211 $(Echo) "Building $(<F) instruction information with tblgen"
1212 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001213
Chris Lattner2a023902004-12-16 17:28:50 +00001214$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1215$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001216 $(Echo) "Building $(<F) assembly writer with tblgen"
1217 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001218
Chris Lattner22f937a2004-12-16 17:34:04 +00001219$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1220$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1221 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Reid Spencerf88808a2004-10-30 09:19:36 +00001222 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001223
Chris Lattner2a023902004-12-16 17:28:50 +00001224$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1225$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001226 $(Echo) "Building $(<F) code emitter with tblgen"
1227 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001228
Chris Lattner33f98bd2005-09-03 01:15:25 +00001229$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1230$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1231 $(Echo) "Building $(<F) instruction selector implementation with tblgen"
1232 $(Verb) $(TableGen) -gen-dag-isel -o $@ $<
1233
Jim Laskey9ed90322005-10-21 19:05:19 +00001234$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1235$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1236 $(Echo) "Building $(<F) subtarget information with tblgen"
1237 $(Verb) $(TableGen) -gen-subtarget -o $@ $<
Chris Lattner33f98bd2005-09-03 01:15:25 +00001238
Reid Spencer81cd0492004-10-23 20:04:14 +00001239clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001240 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001241
1242endif
Chris Lattner0c4f4fe2003-08-15 02:18:35 +00001243
Reid Spencerf88808a2004-10-30 09:19:36 +00001244###############################################################################
1245# LEX AND YACC: Provide rules for generating sources with lex and yacc
1246###############################################################################
Chris Lattnerdb644dd2003-01-16 22:44:19 +00001247
Reid Spencerf88808a2004-10-30 09:19:36 +00001248#---------------------------------------------------------
1249# Provide rules for generating a .cpp source file from
1250# (f)lex input sources.
1251#---------------------------------------------------------
1252
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001253LexFiles := $(filter %.l,$(Sources))
Reid Spencerf88808a2004-10-30 09:19:36 +00001254
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001255ifneq ($(LexFiles),)
1256
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001257# Cancel built-in rules for lex
1258%.c: %.l
1259%.cpp: %.l
Reid Spencerf88808a2004-10-30 09:19:36 +00001260
Chris Lattner8104b4c2006-02-14 05:12:00 +00001261all:: $(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs)
1262
Reid Spencerf88808a2004-10-30 09:19:36 +00001263# Note the extra sed filtering here, used to cut down on the warnings emited
1264# by GCC. The last line is a gross hack to work around flex aparently not
1265# being able to resize the buffer on a large token input. Currently, for
1266# uninitialized string buffers in LLVM we can generate very long tokens, so
1267# this is a hack around it.
Chris Lattner92fc9b02003-08-15 20:00:47 +00001268# FIXME. (f.e. char Buffer[10000] )
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001269$(PROJ_SRC_DIR)/%.cpp: $(PROJ_SRC_DIR)/%.l
Reid Spencer993b95e2004-12-10 19:44:16 +00001270 $(Echo) Flexing $*.l
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001271 $(Verb) $(FLEX) -t $(PROJ_SRC_DIR)/$*.l | \
Reid Spencerf206bd72004-10-22 21:01:56 +00001272 $(SED) 's/void yyunput/inline void yyunput/' | \
1273 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1274 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001275 > $(PROJ_SRC_DIR)/$*.cpp
Chris Lattner8104b4c2006-02-14 05:12:00 +00001276
1277# IFF the .l file has changed since it was last checked into CVS, copy the .l
1278# file to .l.cvs and the generated .cpp file to .cpp.cvs. We use this mechanism
1279# so that people without flex can build LLVM by copying the .cvs files to the
1280# source location and building them.
1281$(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1282$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattner1e612822006-02-16 05:10:48 +00001283 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs || \
Chris Lattner8104b4c2006-02-14 05:12:00 +00001284 ($(CP) $< $@; $(CP) $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001285
Chris Lattner8104b4c2006-02-14 05:12:00 +00001286$(LexFiles:%.l=$(ObjDir)/%.o) : \
1287$(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
Chris Lattner2f7c9632001-06-06 20:29:01 +00001288
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001289clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001290 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001291
Reid Spencerf88808a2004-10-30 09:19:36 +00001292endif
1293
1294#---------------------------------------------------------
1295# Provide rules for generating a .cpp and .h source files
1296# from yacc (bison) input sources.
1297#---------------------------------------------------------
1298
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001299YaccFiles := $(filter %.y,$(Sources))
1300ifneq ($(YaccFiles),)
Reid Spencerf88808a2004-10-30 09:19:36 +00001301
1302.PRECIOUS: $(YaccOutput)
1303
Chris Lattnerb0240b22006-02-15 07:23:05 +00001304all:: $(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs)
Chris Lattnerc38a9752006-02-15 07:16:57 +00001305
Reid Spencerf88808a2004-10-30 09:19:36 +00001306# Cancel built-in rules for yacc
1307%.c: %.y
1308%.cpp: %.y
1309%.h: %.y
1310
Reid Spencerc49a8632005-12-21 23:17:06 +00001311# Rule for building the bison based parsers...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001312$(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
Reid Spencerf88808a2004-10-30 09:19:36 +00001313 $(Echo) "Bisoning $*.y"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001314 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1315 $(Verb) $(MV) -f $*.tab.c $(PROJ_SRC_DIR)/$*.cpp
1316 $(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
Chris Lattner2f7c9632001-06-06 20:29:01 +00001317
Chris Lattnerc38a9752006-02-15 07:16:57 +00001318# IFF the .y file has changed since it was last checked into CVS, copy the .y
1319# file to .y.cvs and the generated .cpp/.h file to .cpp.cvs/.h.cvs. We use this
1320# mechanism so that people without flex can build LLVM by copying the .cvs files
1321# to the source location and building them.
1322$(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1323$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattner1e612822006-02-16 05:10:48 +00001324 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs || \
Chris Lattnerc38a9752006-02-15 07:16:57 +00001325 ($(CP) $< $@; \
Chris Lattnerb0240b22006-02-15 07:23:05 +00001326 $(CP) $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs; \
Chris Lattnerc38a9752006-02-15 07:16:57 +00001327 $(CP) $(PROJ_SRC_DIR)/$*.h $(PROJ_SRC_DIR)/$*.h.cvs)
Reid Spencerc49a8632005-12-21 23:17:06 +00001328
Chris Lattnerc38a9752006-02-15 07:16:57 +00001329
1330$(YaccFiles:%.y=$(ObjDir)/%.o): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
1331
1332YaccOutput := $(YaccFiles:%.y=%.output)
Reid Spencerc49a8632005-12-21 23:17:06 +00001333
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001334clean-local::
Reid Spencerc49a8632005-12-21 23:17:06 +00001335 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencerf88808a2004-10-30 09:19:36 +00001336endif
Chris Lattner2f7c9632001-06-06 20:29:01 +00001337
Reid Spencerf88808a2004-10-30 09:19:36 +00001338###############################################################################
1339# OTHER RULES: Other rules needed
1340###############################################################################
Reid Spencerf206bd72004-10-22 21:01:56 +00001341
Chris Lattner23d47392003-01-16 21:06:18 +00001342# To create postscript files from dot files...
John Criswell4ffb8442003-10-02 19:02:02 +00001343ifneq ($(DOT),false)
Chris Lattner23d47392003-01-16 21:06:18 +00001344%.ps: %.dot
Reid Spencerf206bd72004-10-22 21:01:56 +00001345 $(DOT) -Tps < $< > $@
John Criswell3ef61af2003-06-30 21:59:07 +00001346else
1347%.ps: %.dot
Reid Spencerf88808a2004-10-30 09:19:36 +00001348 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell3ef61af2003-06-30 21:59:07 +00001349endif
Chris Lattner23d47392003-01-16 21:06:18 +00001350
John Criswell0a6e6aa2003-09-06 14:44:17 +00001351# This rules ensures that header files that are removed still have a rule for
1352# which they can be "generated." This allows make to ignore them and
1353# reproduce the dependency lists.
John Criswella8391af2003-09-18 18:37:08 +00001354%.h:: ;
Chris Lattnerf60c1702005-02-04 21:28:50 +00001355%.hpp:: ;
John Criswell0a6e6aa2003-09-06 14:44:17 +00001356
Reid Spencerf88808a2004-10-30 09:19:36 +00001357# Define clean-local to clean the current directory. Note that this uses a
1358# very conservative approach ensuring that empty variables do not cause
1359# errors or disastrous removal.
Reid Spencer81cd0492004-10-23 20:04:14 +00001360clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001361ifneq ($(strip $(ObjDir)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001362 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencer12a3a052004-10-24 07:53:21 +00001363endif
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001364 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke8625f682004-01-21 19:53:11 +00001365ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001366 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke8625f682004-01-21 19:53:11 +00001367endif
John Criswell3ef61af2003-06-30 21:59:07 +00001368
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001369clean-all-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001370 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001371
Reid Spencerf88808a2004-10-30 09:19:36 +00001372# Build tags database for Emacs/Xemacs:
Reid Spenceraee67e62004-11-12 02:27:36 +00001373tags:: TAGS CTAGS
1374
Reid Spencerf88808a2004-10-30 09:19:36 +00001375TAGS:
Reid Spencerba6a3db2005-01-16 02:20:54 +00001376 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1377 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1378 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1379 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spenceraee67e62004-11-12 02:27:36 +00001380 -name '*.cpp' -o -name '*.h' | \
Reid Spencerf88808a2004-10-30 09:19:36 +00001381 $(ETAGS) $(ETAGSFLAGS) -
1382
Reid Spenceraee67e62004-11-12 02:27:36 +00001383CTAGS:
Reid Spencerba6a3db2005-01-16 02:20:54 +00001384 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1385 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1386 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1387 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spenceraee67e62004-11-12 02:27:36 +00001388 \( -name '*.cpp' -o -name '*.h' \) -print | \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001389 ctags -ImtT -o $(PROJ_OBJ_ROOT)/CTAGS -L -
Reid Spenceraee67e62004-11-12 02:27:36 +00001390
1391
Reid Spencer81cd0492004-10-23 20:04:14 +00001392###############################################################################
1393# DEPENDENCIES: Include the dependency files if we should
1394###############################################################################
Chris Lattnere9d7d702003-08-22 14:10:16 +00001395ifndef DISABLE_AUTO_DEPENDENCIES
1396
Reid Spencer81cd0492004-10-23 20:04:14 +00001397# If its not one of the cleaning targets
Reid Spencerf88808a2004-10-30 09:19:36 +00001398ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencerf206bd72004-10-22 21:01:56 +00001399
Reid Spencer81cd0492004-10-23 20:04:14 +00001400# Get the list of dependency files
Reid Spencerf88808a2004-10-30 09:19:36 +00001401DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Chris Lattner8104b4c2006-02-14 05:12:00 +00001402DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
Misha Brukmanb891ffb2003-11-09 21:36:19 +00001403
Reid Spencer81cd0492004-10-23 20:04:14 +00001404-include /dev/null $(DependFiles)
1405
John Criswell48ecca62003-08-12 18:51:51 +00001406endif
Chris Lattner598222b2003-08-18 17:27:40 +00001407
Reid Spencerf88808a2004-10-30 09:19:36 +00001408endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001409
Reid Spencer100080c2004-10-25 08:27:37 +00001410###############################################################################
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001411# CHECK: Running the test suite
1412###############################################################################
1413
1414check::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001415 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1416 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001417 $(EchoCmd) Running test suite ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001418 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001419 TESTSUITE=$(TESTSUITE) ; \
1420 else \
1421 $(EchoCmd) No Makefile in test directory ; \
1422 fi ; \
1423 else \
1424 $(EchoCmd) No test directory ; \
1425 fi
1426
1427###############################################################################
Reid Spencerf88808a2004-10-30 09:19:36 +00001428# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer100080c2004-10-25 08:27:37 +00001429###############################################################################
1430
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001431#------------------------------------------------------------------------
1432# Define distribution related variables
1433#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +00001434DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1435DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1436TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1437DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1438DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1439DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
Reid Spencer100080c2004-10-25 08:27:37 +00001440DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1441 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001442 Makefile.config.in configure autoconf
1443DistOther := $(notdir $(wildcard \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001444 $(PROJ_SRC_DIR)/*.h \
1445 $(PROJ_SRC_DIR)/*.td \
1446 $(PROJ_SRC_DIR)/*.def \
1447 $(PROJ_SRC_DIR)/*.ll \
1448 $(PROJ_SRC_DIR)/*.in))
Reid Spencerf88808a2004-10-30 09:19:36 +00001449DistSubDirs := $(SubDirs)
Reid Spencerfc66af42004-11-29 05:00:33 +00001450DistSources = $(Sources) $(EXTRA_DIST)
1451DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer100080c2004-10-25 08:27:37 +00001452
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001453#------------------------------------------------------------------------
1454# We MUST build distribution with OBJ_DIR != SRC_DIR
1455#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +00001456ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001457dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerf88808a2004-10-30 09:19:36 +00001458 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001459
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001460else
1461
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001462#------------------------------------------------------------------------
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001463# Prevent attempt to run dist targets from anywhere but the top level
1464#------------------------------------------------------------------------
1465ifneq ($(LEVEL),.)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001466dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001467 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001468else
1469
1470#------------------------------------------------------------------------
1471# Provide the top level targets
1472#------------------------------------------------------------------------
1473
Reid Spencerf88808a2004-10-30 09:19:36 +00001474dist-gzip:: $(DistTarGZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001475
Reid Spencer81546582004-12-04 22:34:09 +00001476$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001477 $(Echo) Packing gzipped distribution tar file.
Reid Spencerba6a3db2005-01-16 02:20:54 +00001478 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
Reid Spencerfc66af42004-11-29 05:00:33 +00001479 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001480
Reid Spencerf88808a2004-10-30 09:19:36 +00001481dist-bzip2:: $(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001482
Reid Spencer81546582004-12-04 22:34:09 +00001483$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001484 $(Echo) Packing bzipped distribution tar file.
Reid Spencerba6a3db2005-01-16 02:20:54 +00001485 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
Reid Spencerfc66af42004-11-29 05:00:33 +00001486 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001487
Reid Spencerf88808a2004-10-30 09:19:36 +00001488dist-zip:: $(DistZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001489
Reid Spencer81546582004-12-04 22:34:09 +00001490$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001491 $(Echo) Packing zipped distribution file.
1492 $(Verb) rm -f $(DistZip)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001493 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001494
1495dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001496 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001497
Reid Spencer3a468752005-01-28 19:52:32 +00001498DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001499
Reid Spencer81546582004-12-04 22:34:09 +00001500dist-check:: $(DistTarGZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001501 $(Echo) Checking distribution tar file.
1502 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001503 $(RM) -rf $(DistCheckDir) ; \
1504 fi
Reid Spencerf88808a2004-10-30 09:19:36 +00001505 $(Verb) $(MKDIR) $(DistCheckDir)
1506 $(Verb) cd $(DistCheckDir) && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001507 $(MKDIR) $(DistCheckDir)/build && \
1508 $(MKDIR) $(DistCheckDir)/install && \
1509 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1510 cd build && \
1511 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
Reid Spencer13f51932005-05-24 02:33:20 +00001512 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
Reid Spencer81546582004-12-04 22:34:09 +00001513 $(MAKE) all && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001514 $(MAKE) check && \
1515 $(MAKE) install && \
1516 $(MAKE) uninstall && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001517 $(MAKE) dist-clean && \
Reid Spencerf88808a2004-10-30 09:19:36 +00001518 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001519
1520dist-clean::
Reid Spencerf88808a2004-10-30 09:19:36 +00001521 $(Echo) Cleaning distribution files
Reid Spencer81546582004-12-04 22:34:09 +00001522 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1523 $(DistCheckDir)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001524
1525endif
1526
1527#------------------------------------------------------------------------
1528# Provide the recursive distdir target for building the distribution directory
1529#------------------------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +00001530distdir: $(DistDir)/.makedistdir
1531$(DistDir)/.makedistdir: $(DistSources)
Reid Spencerf88808a2004-10-30 09:19:36 +00001532 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001533 if test -d "$(DistDir)" ; then \
1534 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1535 exit 1 ; \
1536 fi ; \
Reid Spencer81546582004-12-04 22:34:09 +00001537 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001538 $(RM) -rf $(DistDir); \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001539 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer15b85092006-04-10 16:46:04 +00001540 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001541 fi
Reid Spencerfc66af42004-11-29 05:00:33 +00001542 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencerf88808a2004-10-30 09:19:36 +00001543 $(Verb) $(MKDIR) $(DistDir)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001544 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1545 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
Reid Spencer100080c2004-10-25 08:27:37 +00001546 for file in $(DistFiles) ; do \
1547 case "$$file" in \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001548 $(PROJ_SRC_DIR)/*) \
Reid Spencer81546582004-12-04 22:34:09 +00001549 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1550 ;; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001551 $(PROJ_SRC_ROOT)/*) \
Reid Spencer81546582004-12-04 22:34:09 +00001552 file=`echo "$$file" | \
1553 sed "s#^$$srcrootstrip/##"` \
1554 ;; \
Reid Spencer100080c2004-10-25 08:27:37 +00001555 esac; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001556 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1557 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1558 from_dir="$(PROJ_SRC_DIR)" ; \
Reid Spencer81546582004-12-04 22:34:09 +00001559 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001560 from_dir=. ; \
Reid Spencer81546582004-12-04 22:34:09 +00001561 fi ; \
1562 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001563 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1564 to_dir="$(DistDir)/$$dir"; \
1565 $(MKDIR) "$$to_dir" ; \
1566 else \
1567 to_dir="$(DistDir)"; \
1568 fi; \
1569 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1570 if test -n "$$mid_dir" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001571 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001572 fi ; \
1573 if test -d "$$from_dir/$$file"; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001574 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1575 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
Reid Spencer13f51932005-05-24 02:33:20 +00001576 cd $(PROJ_SRC_DIR) ; \
1577 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1578 ( cd $$to_dir ; $(TAR) xf - ) ; \
1579 cd $(PROJ_OBJ_DIR) ; \
1580 else \
1581 cd $$from_dir ; \
1582 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1583 ( cd $$to_dir ; $(TAR) xf - ) ; \
1584 cd $(PROJ_OBJ_DIR) ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001585 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +00001586 elif test -f "$$from_dir/$$file" ; then \
Reid Spencerafdc82c2004-12-16 18:26:53 +00001587 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001588 elif test -L "$$from_dir/$$file" ; then \
Reid Spencerafdc82c2004-12-16 18:26:53 +00001589 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001590 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer81546582004-12-04 22:34:09 +00001591 $(EchoCmd) "===== WARNING: Distribution Source " \
1592 "$$from_dir/$$file Not Found!" ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001593 elif test "$(Verb)" != '@' ; then \
1594 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001595 fi; \
1596 done
Reid Spencerf88808a2004-10-30 09:19:36 +00001597 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer100080c2004-10-25 08:27:37 +00001598 if test "$$subdir" \!= "." ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001599 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001600 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer15b85092006-04-10 16:46:04 +00001601 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
Reid Spencer056f0222006-04-07 16:06:18 +00001602 DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001603 fi; \
1604 done
Reid Spencer81546582004-12-04 22:34:09 +00001605 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer13f51932005-05-24 02:33:20 +00001606 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
Chris Lattnerb8e7aa02006-02-14 04:27:15 +00001607 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1608 -name .svn \) -print` ;\
Reid Spencer81546582004-12-04 22:34:09 +00001609 $(MAKE) dist-hook ; \
1610 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1611 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1612 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1613 -o ! -type d ! -perm -444 -exec \
1614 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1615 || chmod -R a+r $(DistDir) ; \
1616 fi
Reid Spencer100080c2004-10-25 08:27:37 +00001617
Reid Spencerf88808a2004-10-30 09:19:36 +00001618# This is invoked by distdir target, define it as a no-op to avoid errors if not
1619# defined by user.
Reid Spencer100080c2004-10-25 08:27:37 +00001620dist-hook::
1621
Reid Spencer23a70372004-10-22 23:06:30 +00001622endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001623
1624###############################################################################
Reid Spencer12a3a052004-10-24 07:53:21 +00001625# TOP LEVEL - targets only to apply at the top level directory
1626###############################################################################
1627
1628ifeq ($(LEVEL),.)
1629
1630#------------------------------------------------------------------------
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001631# Install support for the project's include files:
Reid Spencer12a3a052004-10-24 07:53:21 +00001632#------------------------------------------------------------------------
1633install-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001634 $(Echo) Installing include files
Reid Spencerba6a3db2005-01-16 02:20:54 +00001635 $(Verb) $(MKDIR) $(PROJ_includedir)
Reid Spencerc43b1d42005-02-24 03:56:32 +00001636 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001637 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer48a82f42005-02-16 15:54:03 +00001638 for hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
1639 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS ` ; do \
Reid Spencerc43b1d42005-02-24 03:56:32 +00001640 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1641 if test \! -d "$$instdir" ; then \
1642 $(EchoCmd) Making install directory $$instdir ; \
1643 $(MKDIR) $$instdir ;\
1644 fi ; \
1645 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer48a82f42005-02-16 15:54:03 +00001646 done ; \
Reid Spencer12a3a052004-10-24 07:53:21 +00001647 fi
Reid Spencer528c9802005-12-23 22:27:56 +00001648ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencerc43b1d42005-02-24 03:56:32 +00001649 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
Reid Spencer48a82f42005-02-16 15:54:03 +00001650 cd $(PROJ_OBJ_ROOT)/include && \
Reid Spencer528c9802005-12-23 22:27:56 +00001651 for hdr in `find . -type f -print | grep -v CVS` ; do \
Reid Spencerc43b1d42005-02-24 03:56:32 +00001652 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer48a82f42005-02-16 15:54:03 +00001653 done ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001654 fi
Reid Spencer528c9802005-12-23 22:27:56 +00001655endif
Reid Spencer12a3a052004-10-24 07:53:21 +00001656
1657uninstall-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001658 $(Echo) Uninstalling include files
Reid Spencerba6a3db2005-01-16 02:20:54 +00001659 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1660 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer12a3a052004-10-24 07:53:21 +00001661 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001662 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' \
1663 -o -name '*.in' ')' -print ')' | \
1664 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001665 cd $(PROJ_SRC_ROOT)/include && \
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001666 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1667 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001668 fi
Reid Spencer12a3a052004-10-24 07:53:21 +00001669
Reid Spencer12a3a052004-10-24 07:53:21 +00001670endif
1671
Reid Spencerf206bd72004-10-22 21:01:56 +00001672#------------------------------------------------------------------------
1673# Print out the directories used for building
Reid Spencerf88808a2004-10-30 09:19:36 +00001674#------------------------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001675printvars::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001676 $(Echo) "BuildMode : " '$(BuildMode)'
1677 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1678 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1679 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1680 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1681 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1682 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1683 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1684 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1685 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1686 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
Reid Spencerfe0a01e2005-02-16 16:13:02 +00001687 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
Reid Spencerba6a3db2005-01-16 02:20:54 +00001688 $(Echo) "UserTargets : " '$(UserTargets)'
1689 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1690 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1691 $(Echo) "ObjDir : " '$(ObjDir)'
1692 $(Echo) "LibDir : " '$(LibDir)'
1693 $(Echo) "ToolDir : " '$(ToolDir)'
1694 $(Echo) "ExmplDir : " '$(ExmplDir)'
1695 $(Echo) "Sources : " '$(Sources)'
1696 $(Echo) "TDFiles : " '$(TDFiles)'
1697 $(Echo) "INCFiles : " '$(INCFiles)'
1698 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
Reid Spencerfefb9ea2005-03-01 16:27:06 +00001699 $(Echo) "PreConditions: " '$(PreConditions)'
Reid Spencerba6a3db2005-01-16 02:20:54 +00001700 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1701 $(Echo) "Compile.C : " '$(Compile.C)'
1702 $(Echo) "Archive : " '$(Archive)'
1703 $(Echo) "YaccFiles : " '$(YaccFiles)'
1704 $(Echo) "LexFiles : " '$(LexFiles)'
1705 $(Echo) "Module : " '$(Module)'
Reid Spencerb48e3f82005-08-24 10:43:10 +00001706 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
Reid Spencerece13582006-04-09 23:41:14 +00001707 $(Echo) "SubDirs : " '$(SubDirs)'