blob: 3fe8090c9bdad67172e28dd5635591182ba8f919 [file] [log] [blame]
Misha Brukman6d5ab862004-04-24 00:10:56 +00001#===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
2#
John Criswelld8846c12003-10-21 14:33:46 +00003# The LLVM Compiler Infrastructure
4#
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 Brukman6d5ab862004-04-24 00:10:56 +00008#===------------------------------------------------------------------------===#
Chris Lattner00950542001-06-06 20:29:01 +00009#
Reid Spencer3a561f52004-10-23 20:04:14 +000010# This file is included by all of the LLVM makefiles. For details on how to use
11# it properly, please see the document MakefileGuide.html in the docs directory.
Chris Lattneraf06a082003-08-15 03:02:52 +000012#
Chris Lattner77efe272006-02-14 04:27:15 +000013#===-----------------------------------------------------------------------====#
Chris Lattner00950542001-06-06 20:29:01 +000014
Reid Spencercc2d1e22004-10-30 09:19:36 +000015################################################################################
Reid Spencer3a561f52004-10-23 20:04:14 +000016# TARGETS: Define standard targets that can be invoked
Reid Spencercc2d1e22004-10-30 09:19:36 +000017################################################################################
John Criswell7a73b802003-06-30 21:59:07 +000018
Chris Lattner00950542001-06-06 20:29:01 +000019#--------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +000020# Define the various target sets
21#--------------------------------------------------------------------
Chris Lattner7dc02822004-12-03 21:05:57 +000022RecursiveTargets := all clean clean-all install uninstall install-bytecode
Reid Spencer9e8d54a2004-12-06 05:35:13 +000023LocalTargets := all-local clean-local clean-all-local check-local \
Reid Spencer44cb1b32004-12-03 20:08:48 +000024 install-local printvars uninstall-local \
25 install-bytecode-local
Reid Spencer9e8d54a2004-12-06 05:35:13 +000026TopLevelTargets := check dist dist-check dist-clean tags dist-gzip dist-bzip2 \
Reid Spencercc2d1e22004-10-30 09:19:36 +000027 dist-zip
28UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
29InternalTargets := preconditions distdir dist-hook
Reid Spencer3a561f52004-10-23 20:04:14 +000030
Reid Spencercc2d1e22004-10-30 09:19:36 +000031################################################################################
Reid Spencer9411c642004-10-26 22:26:33 +000032# INITIALIZATION: Basic things the makefile needs
Reid Spencercc2d1e22004-10-30 09:19:36 +000033################################################################################
34
35#--------------------------------------------------------------------
36# Set the VPATH so that we can find source files.
37#--------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +000038VPATH=$(PROJ_SRC_DIR)
Reid Spencer9411c642004-10-26 22:26:33 +000039
40#--------------------------------------------------------------------
41# Reset the list of suffixes we know how to build
42#--------------------------------------------------------------------
43.SUFFIXES:
Chris Lattner89681112006-01-27 22:13:12 +000044.SUFFIXES: .c .cpp .cc .h .hpp .y .l .lo .o .a .bc .td .ps .dot .ll
Reid Spencercc2d1e22004-10-30 09:19:36 +000045.SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
Reid Spencer9411c642004-10-26 22:26:33 +000046
Reid Spencer3a561f52004-10-23 20:04:14 +000047#--------------------------------------------------------------------
48# Mark all of these targets as phony to avoid implicit rule search
49#--------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000050.PHONY: $(UserTargets) $(InternalTargets)
Reid Spencer3a561f52004-10-23 20:04:14 +000051
52#--------------------------------------------------------------------
Reid Spencer9411c642004-10-26 22:26:33 +000053# Make sure all the user-target rules are double colon rules and
54# they are defined first.
Reid Spencer3a561f52004-10-23 20:04:14 +000055#--------------------------------------------------------------------
56
Reid Spencercc2d1e22004-10-30 09:19:36 +000057$(UserTargets)::
Reid Spencer151f8ba2004-10-25 08:27:37 +000058
Reid Spencer9411c642004-10-26 22:26:33 +000059################################################################################
60# PRECONDITIONS: that which must be built/checked first
61################################################################################
62
Reid Spencer44cb1b32004-12-03 20:08:48 +000063SrcMakefiles := $(filter %Makefile %Makefile.tests,\
Reid Spencer11fde542005-01-16 02:20:54 +000064 $(wildcard $(PROJ_SRC_DIR)/Makefile*))
65ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
66ConfigureScript := $(PROJ_SRC_ROOT)/configure
67ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
68MakefileConfigIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
69MakefileCommonIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
70MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
71MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
72PreConditions := $(ConfigStatusScript) $(ObjMakefiles)
73ifneq ($(MakefileCommonIn),)
74PreConditions += $(MakefileCommon)
75endif
76ifneq ($(MakefileConfigIn),)
77PreConditions += $(MakefileConfig)
78endif
Reid Spencer9411c642004-10-26 22:26:33 +000079
Reid Spencerca739c62005-08-25 04:59:49 +000080preconditions: $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +000081
82#------------------------------------------------------------------------
83# Make sure the BUILT_SOURCES are built first
84#------------------------------------------------------------------------
Reid Spencer07a549a2004-12-16 07:15:16 +000085$(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000086
87clean-local::
88ifneq ($(strip $(BUILT_SOURCES)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +000089 -$(Verb) $(RM) -f $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000090endif
91
Reid Spencer11fde542005-01-16 02:20:54 +000092ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
Reid Spencer31f95242004-12-16 08:00:46 +000093spotless:
Reid Spencer31f95242004-12-16 08:00:46 +000094 $(Verb) if test -x config.status ; then \
Reid Spencer11fde542005-01-16 02:20:54 +000095 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
Reid Spencer39b73632004-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 Spencer31f95242004-12-16 08:00:46 +0000100 $(RM) -rf * ; \
Reid Spencer39b73632004-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 Spencer11fde542005-01-16 02:20:54 +0000105 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
Reid Spencer39b73632004-12-17 07:45:03 +0000106 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
107 $(ConfigStatusScript) ; \
Reid Spencer31f95242004-12-16 08:00:46 +0000108 else \
Reid Spencer11fde542005-01-16 02:20:54 +0000109 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
Reid Spencer31f95242004-12-16 08:00:46 +0000110 fi
Reid Spencer25e8a702005-12-21 23:17:06 +0000111else
112spotless:
113 $(EchoCmd) "spotless target not supported for objdir == srcdir"
Reid Spencer31f95242004-12-16 08:00:46 +0000114endif
115
Reid Spencercc2d1e22004-10-30 09:19:36 +0000116$(BUILT_SOURCES) : $(ObjMakefiles)
Reid Spencer80f0ef72004-10-28 00:41:43 +0000117
Reid Spencer9411c642004-10-26 22:26:33 +0000118#------------------------------------------------------------------------
119# Make sure we're not using a stale configuration
120#------------------------------------------------------------------------
Reid Spencerc3719842004-12-16 18:26:53 +0000121reconfigure:
Reid Spencer11fde542005-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 Spencer32924e02004-12-24 03:36:31 +0000126 fi ; \
Reid Spencerc3719842004-12-16 18:26:53 +0000127 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
128 $(ConfigStatusScript)
129
Reid Spencercc2d1e22004-10-30 09:19:36 +0000130.PRECIOUS: $(ConfigStatusScript)
131$(ConfigStatusScript): $(ConfigureScript)
132 $(Echo) Reconfiguring with $<
Reid Spencer11fde542005-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 Spencer32924e02004-12-24 03:36:31 +0000136 fi ; \
Reid Spencer7d277002004-11-29 12:37:44 +0000137 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
138 $(ConfigStatusScript)
Reid Spencer9411c642004-10-26 22:26:33 +0000139
Reid Spencer6f5f8b32005-08-25 04:44:18 +0000140#------------------------------------------------------------------------
Reid Spencer9411c642004-10-26 22:26:33 +0000141# Make sure the configuration makefile is up to date
142#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +0000143ifneq ($(MakefileConfigIn),)
144$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000145 $(Echo) Regenerating $@
Reid Spencer11fde542005-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 Spencer9411c642004-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 Spencer11fde542005-01-16 02:20:54 +0000159ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
Reid Spencer9411c642004-10-26 22:26:33 +0000160
Reid Spencer11fde542005-01-16 02:20:54 +0000161Makefile: $(PROJ_SRC_DIR)/Makefile
Reid Spencercc2d1e22004-10-30 09:19:36 +0000162 $(Echo) "Updating Makefile"
163 $(Verb) $(MKDIR) $(@D)
Reid Spencerc3719842004-12-16 18:26:53 +0000164 $(Verb) $(CP) -f $< $@
Reid Spencer9411c642004-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 Spencer11fde542005-01-16 02:20:54 +0000169$(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
Reid Spencer86606782004-10-26 23:10:00 +0000170 @case '$?' in \
171 *Makefile.rules) ;; \
172 *.in) ;; \
Reid Spencercc2d1e22004-10-30 09:19:36 +0000173 *) $(Echo) "Updating $(@F)" ; \
Reid Spencer86606782004-10-26 23:10:00 +0000174 $(MKDIR) $(@D) ; \
Reid Spencerc3719842004-12-16 18:26:53 +0000175 $(CP) -f $< $@ ;; \
Reid Spencer86606782004-10-26 23:10:00 +0000176 esac
177
Reid Spencer9411c642004-10-26 22:26:33 +0000178endif
179
180#------------------------------------------------------------------------
181# Set up the basic dependencies
182#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000183$(UserTargets):: $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +0000184
185all:: all-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000186clean:: clean-local
Reid Spencer3d659492004-11-02 16:36:03 +0000187clean-all:: clean-local clean-all-local
Reid Spencer9411c642004-10-26 22:26:33 +0000188install:: install-local
189uninstall:: uninstall-local
Reid Spencer9411c642004-10-26 22:26:33 +0000190install-local:: all-local
Reid Spencer44cb1b32004-12-03 20:08:48 +0000191install-bytecode:: install-bytecode-local
Reid Spencer3a561f52004-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 Lattner00950542001-06-06 20:29:01 +0000199#--------------------------------------------------------------------
200
Chris Lattnerd63b9642006-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 Spencer48fdf912006-06-01 19:03:21 +0000203ifneq ($(OS),MingW)
204 OPTIMIZE_OPTION := -O3
205else
206 OPTIMIZE_OPTION := -O2
207endif
Chris Lattnerd63b9642006-05-24 23:02:40 +0000208
Chris Lattner760da062003-03-14 20:25:22 +0000209ifdef ENABLE_PROFILING
Reid Spencer9af3b292004-11-01 07:50:27 +0000210 BuildMode := Profile
Chris Lattner041572f2006-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 Lattner760da062003-03-14 20:25:22 +0000214else
215 ifdef ENABLE_OPTIMIZED
Reid Spencer9af3b292004-11-01 07:50:27 +0000216 BuildMode := Release
Chris Lattner16620fc2006-07-27 18:19:51 +0000217 # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
Reid Spencer325a87e2005-01-02 17:43:20 +0000218 ifneq ($(OS),FreeBSD)
Chris Lattnere5aa8f32006-05-24 18:34:08 +0000219 ifneq ($(OS),Darwin)
Reid Spencer325a87e2005-01-02 17:43:20 +0000220 OmitFramePointer := -fomit-frame-pointer
221 endif
Chris Lattnere5aa8f32006-05-24 18:34:08 +0000222 endif
Chris Lattner16620fc2006-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 Lattnerd63b9642006-05-24 23:02:40 +0000229 CXX.Flags := $(OPTIMIZE_OPTION) $(OmitFramePointer)
230 C.Flags := $(OPTIMIZE_OPTION) $(OmitFramePointer)
231 LD.Flags := $(OPTIMIZE_OPTION)
Chris Lattner760da062003-03-14 20:25:22 +0000232 else
Reid Spencer9af3b292004-11-01 07:50:27 +0000233 BuildMode := Debug
Chris Lattner71927862006-03-21 01:06:41 +0000234 CXX.Flags := -g
235 C.Flags := -g
Evan Cheng11bcd752006-07-21 23:06:51 +0000236 LD.Flags := -g
Reid Spencer4d71b662004-10-22 21:01:56 +0000237 KEEP_SYMBOLS := 1
Chris Lattner760da062003-03-14 20:25:22 +0000238 endif
239endif
240
Reid Spencer854071c2006-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 Spencerf9f431c2006-04-09 23:41:14 +0000243ifdef DISABLE_ASSERTIONS
Reid Spencerbac3ca22006-04-07 16:06:18 +0000244 BuildMode := $(BuildMode)-Asserts
Chris Lattner71927862006-03-21 01:06:41 +0000245 CXX.Flags += -DNDEBUG
246 C.Flags += -DNDEBUG
Reid Spencerf9f431c2006-04-09 23:41:14 +0000247else
248 CXX.Flags += -D_DEBUG
249 C.Flags += -D_DEBUG
Chris Lattner71927862006-03-21 01:06:41 +0000250endif
251
Reid Spencerf2722ca2006-03-22 15:59:55 +0000252CXX.Flags += $(CXXFLAGS)
253C.Flags += $(CFLAGS)
254CPP.BaseFlags += $(CPPFLAGS)
255LD.Flags += $(LDFLAGS)
256AR.Flags := cru
Reid Spencercc2d1e22004-10-30 09:19:36 +0000257LibTool.Flags := --tag=CXX
Reid Spencer3a561f52004-10-23 20:04:14 +0000258
Chris Lattner16620fc2006-07-27 18:19:51 +0000259# Make Floating point IEEE compliant on Alpha.
Andrew Lenharth39bcf5b2005-02-13 03:41:10 +0000260ifeq ($(ARCH),Alpha)
Andrew Lenharth74bda2e2006-07-20 17:27:58 +0000261 CXX.Flags += -mieee -fPIC
262 CPP.BaseFlags += -mieee -fPIC
Andrew Lenharth39bcf5b2005-02-13 03:41:10 +0000263endif
264
Reid Spencer3a561f52004-10-23 20:04:14 +0000265#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000266# Directory locations
Reid Spencer3a561f52004-10-23 20:04:14 +0000267#--------------------------------------------------------------------
Reid Spencer11fde542005-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 Spencer815cbcf2004-11-18 10:03:46 +0000272LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer9a5acaf2004-11-18 20:04:39 +0000273LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer775bf892004-12-28 07:59:22 +0000274LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer2f138e72004-12-22 05:57:21 +0000275CFERuntimeLibDir := $(LLVMGCCDIR)/lib
John Criswell7a73b802003-06-30 21:59:07 +0000276
Reid Spencer3a561f52004-10-23 20:04:14 +0000277#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000278# Full Paths To Compiled Tools and Utilities
Reid Spencer3a561f52004-10-23 20:04:14 +0000279#--------------------------------------------------------------------
Reid Spencer3ca6d8b2005-01-14 16:33:36 +0000280EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
281Echo = @$(EchoCmd)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000282ifndef LIBTOOL
Reid Spencer4d71b662004-10-22 21:01:56 +0000283LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencercc2d1e22004-10-30 09:19:36 +0000284endif
285ifndef LLVMAS
286LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
287endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000288ifndef TBLGEN
Reid Spencere2cfe5d2006-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 Spencercc2d1e22004-10-30 09:19:36 +0000294endif
Chris Lattner478b3b42004-11-29 19:47:58 +0000295ifndef GCCAS
296GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
297endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000298ifndef GCCLD
299GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
300endif
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000301ifndef LDIS
302LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
303endif
304ifndef LLI
305LLI := $(LLVMToolDir)/lli$(EXEEXT)
306endif
Alkis Evlogimenoseebaf332005-02-27 10:21:37 +0000307ifndef LLC
308LLC := $(LLVMToolDir)/llc$(EXEEXT)
309endif
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000310ifndef LOPT
Alkis Evlogimenos20d793a2004-12-13 18:08:29 +0000311LOPT := $(LLVMToolDir)/opt$(EXEEXT)
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000312endif
Alkis Evlogimenos270e8512005-02-02 00:40:15 +0000313ifndef LBUGPOINT
314LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
315endif
316
John Criswellf5629d02005-01-03 17:42:57 +0000317LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
318LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000319
Reid Spencer3a561f52004-10-23 20:04:14 +0000320#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000321# Adjust to user's request
Reid Spencer3a561f52004-10-23 20:04:14 +0000322#--------------------------------------------------------------------
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000323
Reid Spencer492c2932005-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
326# shared library can be opened with dlopen
327ifdef SHARED_LIBRARY
Reid Spencercc2d1e22004-10-30 09:19:36 +0000328 LD.Flags += -rpath $(LibDir)
Reid Spencer492c2932005-01-11 04:31:07 +0000329 ifdef LOADABLE_MODULE
330 LD.Flags += -module
331 endif
332else
333 LibTool.Flags += --tag=disable-shared
John Criswell82f4a5a2003-07-31 20:58:51 +0000334endif
335
Reid Spencercceed9f2004-11-08 17:32:12 +0000336ifdef TOOL_VERBOSE
337 C.Flags += -v
338 CXX.Flags += -v
339 LD.Flags += -v
Reid Spencercceed9f2004-11-08 17:32:12 +0000340 VERBOSE := 1
341endif
342
Reid Spencer3a561f52004-10-23 20:04:14 +0000343# Adjust settings for verbose mode
Chris Lattner760da062003-03-14 20:25:22 +0000344ifndef VERBOSE
Reid Spencercc2d1e22004-10-30 09:19:36 +0000345 Verb := @
346 LibTool.Flags += --silent
347 AR.Flags += >/dev/null 2>/dev/null
Reid Spencer11fde542005-01-16 02:20:54 +0000348 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
Reid Spencer151f8ba2004-10-25 08:27:37 +0000349else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000350 ConfigureScriptFLAGS :=
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000351endif
352
Vikram S. Advefeeae582002-09-18 11:55:13 +0000353# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000354ifndef KEEP_SYMBOLS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000355 Strip := $(PLATFORMSTRIPOPTS)
356 StripWarnMsg := "(without symbols)"
Reid Spencer860598a2005-02-24 07:12:43 +0000357 Install.StripFlag += -s
Vikram S. Advefeeae582002-09-18 11:55:13 +0000358endif
359
Reid Spencer3a561f52004-10-23 20:04:14 +0000360# Adjust linker flags for building an executable
Reid Spencer4d71b662004-10-22 21:01:56 +0000361ifdef TOOLNAME
Reid Spencer815cbcf2004-11-18 10:03:46 +0000362ifdef EXAMPLE_TOOL
363 LD.Flags += -rpath $(ExmplDir) -export-dynamic
364else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000365 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000366endif
Reid Spencer815cbcf2004-11-18 10:03:46 +0000367endif
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000368
Reid Spencer3a561f52004-10-23 20:04:14 +0000369#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000370# Options To Invoke Tools
Reid Spencer3a561f52004-10-23 20:04:14 +0000371#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000372
Reid Spencer72f42bb2006-06-01 01:55:21 +0000373CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused -Wno-long-long \
Evan Cheng6cee0332006-06-20 18:50:48 +0000374 -pedantic $(EXTRA_OPTIONS)
Reid Spencer4d71b662004-10-22 21:01:56 +0000375
Duraid Madina0ad8fcf2005-05-16 06:38:09 +0000376ifeq ($(OS),HP-UX)
Duraid Madinaeb713402006-02-15 03:20:16 +0000377 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
Duraid Madina0ad8fcf2005-05-16 06:38:09 +0000378endif
379
Chris Lattner73faa392006-05-30 16:38:06 +0000380# If we are building a universal binary on Mac OS/X, pass extra options. This
381# is useful to people that want to link the LLVM libraries into their universal
Chris Lattner7dabf392006-06-29 19:38:04 +0000382# apps.
383#
384# The following can be optionally specified:
385# UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
386# For Mac OS/X 10.4 Intel machines, the traditional one is:
387# UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
388# UNIVERSAL_ARCH can be optionally specified to be a list of architectures
389# to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
390# i386/ppc only.
Chris Lattnerba466652006-04-06 06:30:15 +0000391ifdef UNIVERSAL
Chris Lattner7dabf392006-06-29 19:38:04 +0000392 ifndef UNIVERSAL_ARCH
393 UNIVERSAL_ARCH := i386 ppc
394 endif
395 UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
396 CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
397 Relink.Flags := $(UNIVERSAL_ARCH_OPTIONS:%=-XCClinker %)
Chris Lattnerf988e532006-06-16 21:47:59 +0000398 ifdef UNIVERSAL_SDK_PATH
399 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
400 Relink.Flags += -XCClinker -isysroot -XCClinker $(UNIVERSAL_SDK_PATH)
401 endif
402
403 # Building universal cannot compute dependencies automatically.
Chris Lattnerba466652006-04-06 06:30:15 +0000404 DISABLE_AUTO_DEPENDENCIES=1
405endif
406
Reid Spencerf2722ca2006-03-22 15:59:55 +0000407LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
408CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
409# All -I flags should go here, so that they don't confuse llvm-config.
410CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
411 -I$(PROJ_OBJ_ROOT)/include \
412 -I$(PROJ_SRC_ROOT)/include \
413 -I$(LLVM_OBJ_ROOT)/include \
414 -I$(LLVM_SRC_ROOT)/include \
415 $(CPP.BaseFlags)
Reid Spencer4d71b662004-10-22 21:01:56 +0000416
Reid Spencercc2d1e22004-10-30 09:19:36 +0000417Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
418LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
Reid Spencer2f138e72004-12-22 05:57:21 +0000419BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattner89681112006-01-27 22:13:12 +0000420 $(C.Flags)
Chris Lattner0cb09f12005-10-05 00:28:41 +0000421Preprocess.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -E $(C.Flags)
422
Reid Spencercc2d1e22004-10-30 09:19:36 +0000423Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
424LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
Reid Spencerbc52ad72004-12-24 14:47:34 +0000425BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattner89681112006-01-27 22:13:12 +0000426 $(CXX.Flags)
Chris Lattner0cb09f12005-10-05 00:28:41 +0000427Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
Reid Spencercc2d1e22004-10-30 09:19:36 +0000428Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencerc14c9362006-05-16 06:51:02 +0000429 $(CXX.Flags) $(CompileCommonOpts) $(LD.Flags) $(Strip)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000430Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencerc14c9362006-05-16 06:51:02 +0000431 $(CXX.Flags) $(CompileCommonOpts) $(Relink.Flags)
Reid Spencer1a9a69c2005-02-16 16:13:02 +0000432LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
433 $(Install.Flags)
Reid Spencer860598a2005-02-24 07:12:43 +0000434ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
Reid Spencerf2722ca2006-03-22 15:59:55 +0000435ScriptInstall = $(INSTALL) -m 0755
Reid Spencer860598a2005-02-24 07:12:43 +0000436DataInstall = $(INSTALL) -m 0644
Vladimir Pruse438c2a2006-05-16 06:39:36 +0000437TableGen = $(TBLGEN) -I $(PROJ_SRC_DIR) -I$(PROJ_SRC_ROOT)/include \
438 -I $(PROJ_SRC_ROOT)/lib/Target
Reid Spencercc2d1e22004-10-30 09:19:36 +0000439Archive = $(AR) $(AR.Flags)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000440LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencer4d71b662004-10-22 21:01:56 +0000441ifdef RANLIB
Reid Spencer3a561f52004-10-23 20:04:14 +0000442Ranlib = $(RANLIB)
Reid Spencer4d71b662004-10-22 21:01:56 +0000443else
Reid Spencer3a561f52004-10-23 20:04:14 +0000444Ranlib = ranlib
John Criswell7a73b802003-06-30 21:59:07 +0000445endif
446
Chris Lattner00950542001-06-06 20:29:01 +0000447#----------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +0000448# Get the list of source files and compute object file
449# names from them.
Reid Spencer3a561f52004-10-23 20:04:14 +0000450#----------------------------------------------------------
Chris Lattner89681112006-01-27 22:13:12 +0000451
452ifndef SOURCES
453 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
454 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
455 $(PROJ_SRC_DIR)/*.l))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000456else
Chris Lattner89681112006-01-27 22:13:12 +0000457 Sources := $(SOURCES)
458endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000459
Chris Lattner89681112006-01-27 22:13:12 +0000460ifdef BUILT_SOURCES
461Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Reid Spencer345235ca2004-12-04 22:34:09 +0000462endif
Reid Spencer3a561f52004-10-23 20:04:14 +0000463
Chris Lattner89681112006-01-27 22:13:12 +0000464BaseNameSources := $(sort $(basename $(Sources)))
465
466ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
467ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
468ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
469
Reid Spencer3a561f52004-10-23 20:04:14 +0000470###############################################################################
471# DIRECTORIES: Handle recursive descent of directory structure
472###############################################################################
John Criswell82f4a5a2003-07-31 20:58:51 +0000473
Chris Lattner00950542001-06-06 20:29:01 +0000474#---------------------------------------------------------
Reid Spencera69b1ea2004-10-28 09:15:28 +0000475# Provide rules to make install dirs. This must be early
476# in the file so they get built before dependencies
477#---------------------------------------------------------
478
Reid Spenceraa8bc432005-05-19 20:26:14 +0000479$(PROJ_bindir): $(PROJ_bindir)/.dir
480$(PROJ_libdir): $(PROJ_libdir)/.dir
481$(PROJ_includedir): $(PROJ_includedir)/.dir
482$(PROJ_etcdir): $(PROJ_etcdir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000483
Reid Spencercc2d1e22004-10-30 09:19:36 +0000484# To create other directories, as needed, and timestamp their creation
485%/.dir:
486 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfbbf3072004-11-29 05:00:33 +0000487 $(Verb) $(DATE) > $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000488
Reid Spencer815cbcf2004-11-18 10:03:46 +0000489.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
490.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000491
492#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000493# Handle the DIRS options for sequential construction
Chris Lattner00950542001-06-06 20:29:01 +0000494#---------------------------------------------------------
495
Reid Spencercc2d1e22004-10-30 09:19:36 +0000496SubDirs :=
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000497ifdef DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000498SubDirs += $(DIRS)
Chris Lattner82033602006-07-26 20:22:26 +0000499
500ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000501$(RecursiveTargets)::
502 $(Verb) for dir in $(DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000503 if [ ! -f $$dir/Makefile ]; then \
504 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000505 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000506 fi; \
Reid Spencerdd1aac32006-05-17 22:55:35 +0000507 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000508 done
Chris Lattner82033602006-07-26 20:22:26 +0000509else
510$(RecursiveTargets)::
511 $(Verb) for dir in $(DIRS); do \
512 ($(MAKE) -C $$dir $@ ) || exit 1; \
513 done
514endif
515
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000516endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000517
Reid Spencer3a561f52004-10-23 20:04:14 +0000518#---------------------------------------------------------
519# Handle the EXPERIMENTAL_DIRS options ensuring success
520# after each directory is built.
521#---------------------------------------------------------
522ifdef EXPERIMENTAL_DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000523$(RecursiveTargets)::
524 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer3a561f52004-10-23 20:04:14 +0000525 if [ ! -f $$dir/Makefile ]; then \
526 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000527 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000528 fi; \
Reid Spencerdd1aac32006-05-17 22:55:35 +0000529 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000530 done
531endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000532
Reid Spencer25e8a702005-12-21 23:17:06 +0000533#-----------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000534# Handle the PARALLEL_DIRS options for parallel construction
Reid Spencer25e8a702005-12-21 23:17:06 +0000535#-----------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000536ifdef PARALLEL_DIRS
537
Reid Spencercc2d1e22004-10-30 09:19:36 +0000538SubDirs += $(PARALLEL_DIRS)
539
Reid Spencer44cb1b32004-12-03 20:08:48 +0000540# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencercc2d1e22004-10-30 09:19:36 +0000541all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
542clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000543clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000544install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000545uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencer44cb1b32004-12-03 20:08:48 +0000546install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000547
Reid Spencer345235ca2004-12-04 22:34:09 +0000548ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer3a561f52004-10-23 20:04:14 +0000549
Reid Spencer345235ca2004-12-04 22:34:09 +0000550$(ParallelTargets) :
Reid Spencercc2d1e22004-10-30 09:19:36 +0000551 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencer4d71b662004-10-22 21:01:56 +0000552 $(MKDIR) $(@D); \
Reid Spencer11fde542005-01-16 02:20:54 +0000553 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswellb3866b62003-11-25 19:32:22 +0000554 fi; \
Reid Spencerdd1aac32006-05-17 22:55:35 +0000555 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ;
Chris Lattner00950542001-06-06 20:29:01 +0000556endif
557
Reid Spencer3a561f52004-10-23 20:04:14 +0000558#---------------------------------------------------------
559# Handle the OPTIONAL_DIRS options for directores that may
560# or may not exist.
561#---------------------------------------------------------
John Criswell2a6530f2003-06-27 16:58:44 +0000562ifdef OPTIONAL_DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000563
Reid Spencercc2d1e22004-10-30 09:19:36 +0000564SubDirs += $(OPTIONAL_DIRS)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000565
Chris Lattner82033602006-07-26 20:22:26 +0000566ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000567$(RecursiveTargets)::
568 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000569 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
Reid Spencer4d71b662004-10-22 21:01:56 +0000570 if [ ! -f $$dir/Makefile ]; then \
571 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000572 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000573 fi; \
Reid Spencerdd1aac32006-05-17 22:55:35 +0000574 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000575 fi \
John Criswell2a6530f2003-06-27 16:58:44 +0000576 done
Chris Lattner82033602006-07-26 20:22:26 +0000577else
578$(RecursiveTargets)::
579 $(Verb) for dir in $(OPTIONAL_DIRS); do \
580 ($(MAKE) -C$$dir $@ ) || exit 1; \
581 done
582endif
John Criswell2a6530f2003-06-27 16:58:44 +0000583endif
584
Reid Spencerfc945082004-08-20 09:20:05 +0000585#---------------------------------------------------------
586# Handle the CONFIG_FILES options
587#---------------------------------------------------------
588ifdef CONFIG_FILES
Reid Spencerfc945082004-08-20 09:20:05 +0000589
Reid Spencer11fde542005-01-16 02:20:54 +0000590install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
591 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000592 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000593 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
Reid Spencer4a0aaea2005-02-24 03:56:32 +0000594 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer11fde542005-01-16 02:20:54 +0000595 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
Reid Spencer4a0aaea2005-02-24 03:56:32 +0000596 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer1b426ab2004-11-23 05:59:53 +0000597 else \
598 $(ECHO) Error: cannot find config file $${file}. ; \
599 fi \
Reid Spencerfc945082004-08-20 09:20:05 +0000600 done
Reid Spencer3a561f52004-10-23 20:04:14 +0000601
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000602uninstall-local::
Reid Spencer11fde542005-01-16 02:20:54 +0000603 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000604 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000605 $(RM) -f $(PROJ_etcdir)/$${file} ; \
Reid Spencere5487ba2004-10-24 07:53:21 +0000606 done
607
Reid Spencerfc945082004-08-20 09:20:05 +0000608endif
609
Reid Spencer3a561f52004-10-23 20:04:14 +0000610###############################################################################
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000611# Set up variables for building libararies
612###############################################################################
613
614#---------------------------------------------------------
615# Handle the special "JIT" value for LLVM_LIBS which is a
616# shorthand for a bunch of libraries that get the correct
617# JIT support for a library or a tool that runs JIT.
618#---------------------------------------------------------
Reid Spencer205b02e2006-03-24 07:36:57 +0000619ifeq ($(firstword $(LLVMLIBS)),config)
620LLVM_CONFIG := $(LLVM_SRC_ROOT)/utils/llvm-config/llvm-config
Reid Spencerbac3ca22006-04-07 16:06:18 +0000621LLVMLIBS := $(shell $(LLVM_CONFIG) --libnames $(wordlist 2,9999,$(LLVMLIBS)))
622LLVMLIBS := $(patsubst lib%.a,%.a,$(LLVMLIBS))
Reid Spencer205b02e2006-03-24 07:36:57 +0000623LLVMLIBS := $(patsubst %.o,%,$(LLVMLIBS))
Reid Spencer205b02e2006-03-24 07:36:57 +0000624endif
625
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000626ifeq ($(LLVMLIBS),JIT)
627
628# Make sure we can get our own symbols in the tool
629Link += -dlopen self
630
631# Generic JIT libraries
Devang Patel2ebc1f82006-07-21 19:44:55 +0000632JIT_LIBS := LLVMInterpreter LLVMJIT LLVMSelectionDAG.a LLVMCodeGen.a \
633 LLVMExecutionEngine
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000634
635# You can enable the X86 JIT on a non-X86 host by setting the flag
636# ENABLE_X86_JIT on the make command line. If not, it will still be
637# enabled automagically on an X86 host.
638ifeq ($(ARCH), x86)
639 ENABLE_X86_JIT = 1
640endif
641
642# What the X86 JIT requires
643ifdef ENABLE_X86_JIT
Devang Patel2ebc1f82006-07-21 19:44:55 +0000644 JIT_LIBS += LLVMX86
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000645endif
646
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000647# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
648# ENABLE_PPC_JIT on the make command line. If not, it will still be
649# enabled automagically on an PowerPC host.
650ifeq ($(ARCH), PowerPC)
651 ENABLE_PPC_JIT = 1
652endif
653
654# What the PowerPC JIT requires
655ifdef ENABLE_PPC_JIT
Devang Patel2ebc1f82006-07-21 19:44:55 +0000656 JIT_LIBS += LLVMPowerPC
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000657endif
658
Andrew Lenharthddc31e82005-07-22 20:54:01 +0000659# You can enable the Alpha JIT on a non-Alpha host by setting the flag
660# ENABLE_ALPHA_JIT on the make command line. If not, it will still be
Misha Brukmanab25eda2005-07-22 22:43:40 +0000661# enabled automagically on an Alpha host.
Andrew Lenharthddc31e82005-07-22 20:54:01 +0000662ifeq ($(ARCH), Alpha)
663 ENABLE_ALPHA_JIT = 1
664endif
665
Andrew Lenharth22894e92005-07-22 22:00:24 +0000666# What the Alpha JIT requires
Andrew Lenharthddc31e82005-07-22 20:54:01 +0000667ifdef ENABLE_ALPHA_JIT
Devang Patel2ebc1f82006-07-21 19:44:55 +0000668 JIT_LIBS += LLVMAlpha
Andrew Lenharthddc31e82005-07-22 20:54:01 +0000669endif
670
John Criswella1156432005-10-27 15:54:34 +0000671LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts.a LLVMTransformUtils.a LLVMAnalysis.a \
Reid Spencer18c8b492006-06-01 01:30:27 +0000672 LLVMBCReader.a LLVMTarget.a LLVMCore.a LLVMSupport.a LLVMbzip2.a \
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000673 LLVMSystem.a $(PLATFORMLIBDL)
674endif
675
676#---------------------------------------------------------
677# Define various command line options pertaining to the
678# libraries needed when linking. There are "Proj" libs
679# (defined by the user's project) and "LLVM" libs (defined
680# by the # LLVM project).
681#---------------------------------------------------------
Andrew Lenharth7ac17522005-08-13 05:09:50 +0000682
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000683ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
684ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
685LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
686LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
687ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
688LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
689ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
690LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
691
692###############################################################################
Reid Spencer3a561f52004-10-23 20:04:14 +0000693# Library Build Rules: Four ways to build a library
694###############################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000695
Reid Spencer7980ea42004-12-05 05:17:22 +0000696#---------------------------------------------------------
697# Bytecode Module Targets:
698# If the user set MODULE_NAME then they want to build a
699# bytecode module from the sources. We compile all the
700# sources and link it together into a single bytecode
701# module.
702#---------------------------------------------------------
703
704ifdef MODULE_NAME
Reid Spencer9a8398e2005-02-14 21:54:08 +0000705ifeq ($(strip $(LLVMGCC)),)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000706$(warning Modules require llvm-gcc but no llvm-gcc is available ****)
Reid Spencer9a8398e2005-02-14 21:54:08 +0000707else
Reid Spencer7980ea42004-12-05 05:17:22 +0000708
709Module := $(LibDir)/$(MODULE_NAME).bc
Reid Spencerbbd5e432006-04-12 18:21:35 +0000710LinkModule := $(GCCLD) -L$(CFERuntimeLibDir)
711
Reid Spencer7980ea42004-12-05 05:17:22 +0000712
713ifdef EXPORTED_SYMBOL_FILE
Chris Lattner89681112006-01-27 22:13:12 +0000714LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer7980ea42004-12-05 05:17:22 +0000715endif
716
717$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000718 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
Reid Spencer7980ea42004-12-05 05:17:22 +0000719 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
720
721all-local:: $(Module)
722
723clean-local::
724ifneq ($(strip $(Module)),)
725 -$(Verb) $(RM) -f $(Module)
726endif
727
Reid Spencerab3690b2004-12-13 07:38:07 +0000728ifdef BYTECODE_DESTINATION
729ModuleDestDir := $(BYTECODE_DESTINATION)
730else
Reid Spencer11fde542005-01-16 02:20:54 +0000731ModuleDestDir := $(PROJ_libdir)
Reid Spencerab3690b2004-12-13 07:38:07 +0000732endif
Reid Spencer7980ea42004-12-05 05:17:22 +0000733
Reid Spencerab3690b2004-12-13 07:38:07 +0000734DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
735
736install-module:: $(DestModule)
Reid Spencer7980ea42004-12-05 05:17:22 +0000737install-local:: $(DestModule)
738
Reid Spencerab3690b2004-12-13 07:38:07 +0000739$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencer7980ea42004-12-05 05:17:22 +0000740 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
Reid Spencer151bbe42005-02-24 21:30:37 +0000741 $(Verb) $(DataInstall) $(Module) $(DestModule)
Reid Spencer7980ea42004-12-05 05:17:22 +0000742
743uninstall-local::
744 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
745 -$(Verb) $(RM) -f $(DestModule)
746
747endif
Reid Spencer9a8398e2005-02-14 21:54:08 +0000748endif
Brian Gaeke8abff792004-01-22 22:53:48 +0000749
Reid Spencer3a561f52004-10-23 20:04:14 +0000750# if we're building a library ...
Chris Lattner00950542001-06-06 20:29:01 +0000751ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000752
Chris Lattner2a548c52002-09-16 22:36:42 +0000753# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000754LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencer492c2932005-01-11 04:31:07 +0000755ifdef LOADABLE_MODULE
756LibName.LA := $(LibDir)/$(LIBRARYNAME).la
757else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000758LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
Reid Spencer492c2932005-01-11 04:31:07 +0000759endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000760LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
761LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer9a2f1372004-12-02 09:28:21 +0000762LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000763
Reid Spencer3a561f52004-10-23 20:04:14 +0000764#---------------------------------------------------------
765# Shared Library Targets:
766# If the user asked for a shared library to be built
767# with the SHARED_LIBRARY variable, then we provide
768# targets for building them.
769#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000770ifdef SHARED_LIBRARY
771
Reid Spencercc2d1e22004-10-30 09:19:36 +0000772all-local:: $(LibName.LA)
Reid Spencer4d71b662004-10-22 21:01:56 +0000773
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000774ifdef LINK_LIBS_IN_SHARED
775$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
776 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
777 $(Verb) $(Link) -o $@ $(ObjectsLO) \
778 $(ProjLibsOptions) $(LLVMLibsOptions)
779 $(Verb) $(LTInstall) $@ $(LibDir)
780else
Reid Spencerf2ac1892004-12-16 07:36:08 +0000781$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000782 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000783 $(Verb) $(Link) -o $@ $(ObjectsLO)
784 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000785endif
Reid Spencer3a561f52004-10-23 20:04:14 +0000786
787clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000788ifneq ($(strip $(LibName.LA)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000789 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000790endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000791
Reid Spencer11fde542005-01-16 02:20:54 +0000792DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencer4d71b662004-10-22 21:01:56 +0000793
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000794install-local:: $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000795
Reid Spencer11fde542005-01-16 02:20:54 +0000796$(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
Reid Spencer9af3b292004-11-01 07:50:27 +0000797 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000798 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
Reid Spencer11fde542005-01-16 02:20:54 +0000799 $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
Reid Spencere5487ba2004-10-24 07:53:21 +0000800
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000801uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000802 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencer11fde542005-01-16 02:20:54 +0000803 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
Reid Spencere5487ba2004-10-24 07:53:21 +0000804
Reid Spencer4d71b662004-10-22 21:01:56 +0000805endif
806
Reid Spencer3a561f52004-10-23 20:04:14 +0000807#---------------------------------------------------------
808# Bytecode Library Targets:
809# If the user asked for a bytecode library to be built
810# with the BYTECODE_LIBRARY variable, then we provide
811# targets for building them.
812#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000813ifdef BYTECODE_LIBRARY
Reid Spencer9a8398e2005-02-14 21:54:08 +0000814ifeq ($(strip $(LLVMGCC)),)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000815$(warning Bytecode libraries require llvm-gcc which could not be found ****)
Reid Spencer9a8398e2005-02-14 21:54:08 +0000816else
Reid Spencer4d71b662004-10-22 21:01:56 +0000817
Reid Spencer9a2f1372004-12-02 09:28:21 +0000818all-local:: $(LibName.BCA)
819
820ifdef EXPORTED_SYMBOL_FILE
Chris Lattner73faa392006-05-30 16:38:06 +0000821BCLinkLib = $(GCCLD) -L$(CFERuntimeLibDir) \
822 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000823
Reid Spencerf2ac1892004-12-16 07:36:08 +0000824$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
Chris Lattner264ccbe2004-12-15 17:14:06 +0000825 $(LLVMToolDir)/llvm-ar
Reid Spencer9a2f1372004-12-02 09:28:21 +0000826 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
827 "(internalize)"
Chris Lattnerb0ea8642004-12-02 21:23:43 +0000828 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencerefd6bb32004-12-13 03:59:35 +0000829 $(Verb) $(RM) -f $@
Reid Spencer9a2f1372004-12-02 09:28:21 +0000830 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencer4d71b662004-10-22 21:01:56 +0000831else
Reid Spencerf2ac1892004-12-16 07:36:08 +0000832$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
Chris Lattner264ccbe2004-12-15 17:14:06 +0000833 $(LLVMToolDir)/llvm-ar
Reid Spencer9a2f1372004-12-02 09:28:21 +0000834 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencerefd6bb32004-12-13 03:59:35 +0000835 $(Verb) $(RM) -f $@
Reid Spencer9a2f1372004-12-02 09:28:21 +0000836 $(Verb) $(LArchive) $@ $(ObjectsBC)
837
Reid Spencer4d71b662004-10-22 21:01:56 +0000838endif
839
Reid Spencer3a561f52004-10-23 20:04:14 +0000840clean-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000841ifneq ($(strip $(LibName.BCA)),)
842 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000843endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000844
Reid Spencer8f094f32004-12-13 07:28:21 +0000845ifdef BYTECODE_DESTINATION
846BytecodeDestDir := $(BYTECODE_DESTINATION)
847else
Reid Spencer11fde542005-01-16 02:20:54 +0000848BytecodeDestDir := $(PROJ_libdir)
Reid Spencer8f094f32004-12-13 07:28:21 +0000849endif
850
851DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
Reid Spencer9a2f1372004-12-02 09:28:21 +0000852
Reid Spencer44cb1b32004-12-03 20:08:48 +0000853install-bytecode-local:: $(DestBytecodeLib)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000854
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000855install-local:: $(DestBytecodeLib)
Chris Lattner481cc7c2003-08-15 02:18:35 +0000856
Reid Spencer8f094f32004-12-13 07:28:21 +0000857$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000858 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerb80621f2005-02-24 21:36:32 +0000859 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000860
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000861uninstall-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000862 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000863 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000864
865endif
Reid Spencer9a8398e2005-02-14 21:54:08 +0000866endif
Vikram S. Adve60f56062002-08-02 18:34:12 +0000867
Reid Spencercc2d1e22004-10-30 09:19:36 +0000868#---------------------------------------------------------
869# ReLinked Library Targets:
Chris Lattner89938082005-10-24 02:21:45 +0000870# If the user explicitly requests a relinked library with
871# BUILD_RELINKED, provide it. Otherwise, if they specify
872# neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
873# them one.
Reid Spencercc2d1e22004-10-30 09:19:36 +0000874#---------------------------------------------------------
Chris Lattner89938082005-10-24 02:21:45 +0000875ifndef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000876ifndef DONT_BUILD_RELINKED
Chris Lattner89938082005-10-24 02:21:45 +0000877BUILD_RELINKED = 1
878endif
879endif
880
881ifdef BUILD_RELINKED
Reid Spencer4d71b662004-10-22 21:01:56 +0000882
Reid Spencercc2d1e22004-10-30 09:19:36 +0000883all-local:: $(LibName.O)
884
Reid Spencerf2ac1892004-12-16 07:36:08 +0000885$(LibName.O): $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000886 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000887 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencer4d71b662004-10-22 21:01:56 +0000888
Reid Spencer3a561f52004-10-23 20:04:14 +0000889clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000890ifneq ($(strip $(LibName.O)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000891 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencere5487ba2004-10-24 07:53:21 +0000892endif
893
Reid Spencer11fde542005-01-16 02:20:54 +0000894DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
Reid Spencere5487ba2004-10-24 07:53:21 +0000895
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000896install-local:: $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000897
Reid Spencer11fde542005-01-16 02:20:54 +0000898$(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
Reid Spencer9af3b292004-11-01 07:50:27 +0000899 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000900 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000901
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000902uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000903 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000904 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000905
Chris Lattnere62dbe92002-07-23 17:56:16 +0000906endif
Chris Lattner760da062003-03-14 20:25:22 +0000907
Reid Spencercc2d1e22004-10-30 09:19:36 +0000908#---------------------------------------------------------
909# Archive Library Targets:
910# If the user wanted a regular archive library built,
911# then we provide targets for building them.
912#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000913ifdef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000914
Reid Spencercc2d1e22004-10-30 09:19:36 +0000915all-local:: $(LibName.A)
916
Reid Spencerf2ac1892004-12-16 07:36:08 +0000917$(LibName.A): $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000918 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000919 -$(Verb) $(RM) -f $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000920 $(Verb) $(Archive) $@ $(ObjectsO)
921 $(Verb) $(Ranlib) $@
Vikram S. Adve41e78912002-09-20 14:03:13 +0000922
Reid Spencer3a561f52004-10-23 20:04:14 +0000923clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000924ifneq ($(strip $(LibName.A)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000925 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner00950542001-06-06 20:29:01 +0000926endif
927
Reid Spencer11fde542005-01-16 02:20:54 +0000928DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
Reid Spencere5487ba2004-10-24 07:53:21 +0000929
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000930install-local:: $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000931
Reid Spencer11fde542005-01-16 02:20:54 +0000932$(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
Reid Spencer9af3b292004-11-01 07:50:27 +0000933 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencer11fde542005-01-16 02:20:54 +0000934 $(Verb) $(MKDIR) $(PROJ_libdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000935 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000936
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000937uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000938 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000939 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000940
941endif
942
943# endif LIBRARYNAME
Reid Spencer4d71b662004-10-22 21:01:56 +0000944endif
945
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000946###############################################################################
947# Tool Build Rules: Build executable tool based on TOOLNAME option
948###############################################################################
949
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000950ifdef TOOLNAME
951
Reid Spencercc2d1e22004-10-30 09:19:36 +0000952#---------------------------------------------------------
953# Set up variables for building a tool.
954#---------------------------------------------------------
Reid Spencer815cbcf2004-11-18 10:03:46 +0000955ifdef EXAMPLE_TOOL
Reid Spencer5da2d082005-05-19 21:03:11 +0000956ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000957else
Reid Spencer5da2d082005-05-19 21:03:11 +0000958ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000959endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000960
Reid Spencercc2d1e22004-10-30 09:19:36 +0000961#---------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000962# Tell make that we need to rebuild subdirectories before
963# we can link the tool. This affects things like LLI which
964# has library subdirectories.
965#---------------------------------------------------------
966$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000967
Reid Spencercc2d1e22004-10-30 09:19:36 +0000968#---------------------------------------------------------
969# Provide targets for building the tools
970#---------------------------------------------------------
971all-local:: $(ToolBuildPath)
John Criswell2a6530f2003-06-27 16:58:44 +0000972
Reid Spencer3a561f52004-10-23 20:04:14 +0000973clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000974ifneq ($(strip $(ToolBuildPath)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000975 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencere5487ba2004-10-24 07:53:21 +0000976endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000977
Reid Spencer815cbcf2004-11-18 10:03:46 +0000978ifdef EXAMPLE_TOOL
979$(ToolBuildPath): $(ExmplDir)/.dir
980else
981$(ToolBuildPath): $(ToolDir)/.dir
982endif
983
Reid Spencerf2ac1892004-12-16 07:36:08 +0000984$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencer9af3b292004-11-01 07:50:27 +0000985 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencerab519972006-05-16 06:25:14 +0000986 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
987 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
Chris Lattnerd25ad612006-02-14 04:25:54 +0000988 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
989 $(StripWarnMsg)
Reid Spencere5487ba2004-10-24 07:53:21 +0000990
Reid Spencer11fde542005-01-16 02:20:54 +0000991DestTool = $(PROJ_bindir)/$(TOOLNAME)
Reid Spencere5487ba2004-10-24 07:53:21 +0000992
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000993install-local:: $(DestTool)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000994
Reid Spencer11fde542005-01-16 02:20:54 +0000995$(DestTool): $(PROJ_bindir) $(ToolBuildPath)
Reid Spencer9af3b292004-11-01 07:50:27 +0000996 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencer4a0aaea2005-02-24 03:56:32 +0000997 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000998
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000999uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +00001000 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001001 -$(Verb) $(RM) -f $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +00001002
Reid Spencer4d71b662004-10-22 21:01:56 +00001003endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +00001004
Reid Spencercc2d1e22004-10-30 09:19:36 +00001005###############################################################################
1006# Object Build Rules: Build object files based on sources
1007###############################################################################
1008
Duraid Madina197ab872006-02-15 03:23:26 +00001009# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
1010ifeq ($(OS),HP-UX)
1011 DISABLE_AUTO_DEPENDENCIES=1
1012endif
1013
Chris Lattnerd92490f2006-06-21 20:58:03 +00001014ifdef SHARED_LIBRARY
1015PIC_FLAG = "(PIC)"
1016MAYBE_PIC_Compile.CXX = $(LTCompile.CXX)
1017MAYBE_PIC_Compile.C = $(LTCompile.C)
1018else
1019MAYBE_PIC_Compile.CXX = $(Compile.CXX)
1020MAYBE_PIC_Compile.C = $(Compile.C)
1021endif
1022
Reid Spencercc2d1e22004-10-30 09:19:36 +00001023# Provide rule sets for when dependency generation is enabled
Reid Spencer4d71b662004-10-22 21:01:56 +00001024ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve41e78912002-09-20 14:03:13 +00001025
Reid Spencercc2d1e22004-10-30 09:19:36 +00001026#---------------------------------------------------------
1027# Create .lo files in the ObjDir directory from the .cpp and .c files...
1028#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001029
Chris Lattner3c473472004-12-16 17:28:50 +00001030$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerd92490f2006-06-21 20:58:03 +00001031 $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
1032 $(Verb) if $(MAYBE_PIC_Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
1033 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
1034 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +00001035
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001036$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerd92490f2006-06-21 20:58:03 +00001037 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1038 $(Verb) if $(MAYBE_PIC_Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001039 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
1040 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
1041
Chris Lattner3c473472004-12-16 17:28:50 +00001042$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerd92490f2006-06-21 20:58:03 +00001043 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1044 $(Verb) if $(MAYBE_PIC_Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001045 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
1046 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +00001047
Reid Spencercc2d1e22004-10-30 09:19:36 +00001048#---------------------------------------------------------
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001049# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
Reid Spencercc2d1e22004-10-30 09:19:36 +00001050#---------------------------------------------------------
Chris Lattner89681112006-01-27 22:13:12 +00001051
1052$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001053 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattnerd25ad612006-02-14 04:25:54 +00001054 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1055 $< -o $@ -S -emit-llvm ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001056 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1057 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +00001058
Chris Lattner89681112006-01-27 22:13:12 +00001059$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001060 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattnerd25ad612006-02-14 04:25:54 +00001061 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1062 $< -o $@ -S -emit-llvm ; \
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001063 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1064 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1065
Chris Lattner89681112006-01-27 22:13:12 +00001066$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001067 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattnerd25ad612006-02-14 04:25:54 +00001068 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" \
1069 $< -o $@ -S -emit-llvm ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001070 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1071 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +00001072
Reid Spencercc2d1e22004-10-30 09:19:36 +00001073# Provide alternate rule sets if dependencies are disabled
Reid Spencer4d71b662004-10-22 21:01:56 +00001074else
1075
Chris Lattner3c473472004-12-16 17:28:50 +00001076$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerd92490f2006-06-21 20:58:03 +00001077 $(Echo) "Compiling $*.cpp for $(BuildMode) build" $(PIC_FLAG)
1078 $(MAYBE_PIC_Compile.CXX) $< -o $@
Reid Spencer3a561f52004-10-23 20:04:14 +00001079
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001080$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerd92490f2006-06-21 20:58:03 +00001081 $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
1082 $(MAYBE_PIC_Compile.CXX) $< -o $@
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001083
Chris Lattner3c473472004-12-16 17:28:50 +00001084$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerd92490f2006-06-21 20:58:03 +00001085 $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
1086 $(MAYBE_PIC_Compile.C) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +00001087
Chris Lattner89681112006-01-27 22:13:12 +00001088$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001089 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001090 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Reid Spencer4d71b662004-10-22 21:01:56 +00001091
Chris Lattner89681112006-01-27 22:13:12 +00001092$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001093 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001094 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001095
Chris Lattner89681112006-01-27 22:13:12 +00001096$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001097 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001098 $(BCCompile.C) $< -o $@ -S -emit-llvm
Brian Gaeke44909cf2003-12-10 00:26:28 +00001099
Chris Lattner1cbc29f2001-09-07 22:57:58 +00001100endif
1101
Chris Lattner8eb12de2006-06-21 21:01:20 +00001102
1103## Rules for building preprocessed (.i/.ii) outputs.
1104$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1105 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1106 $(Verb) $(Preprocess.CXX) $< -o $@
1107
1108$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1109 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1110 $(Verb) $(Preprocess.CXX) $< -o $@
1111
1112 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1113 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1114 $(Verb) $(Preprocess.C) $< -o $@
1115
1116
1117$(ObjDir)/%.s: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1118 $(Echo) "Compiling $*.cpp to asm for $(BuildMode) build" $(PIC_FLAG)
1119 $(MAYBE_PIC_Compile.CXX) $< -o $@ -S
1120
1121$(ObjDir)/%.s: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1122 $(Echo) "Compiling $*.cc to asm for $(BuildMode) build" $(PIC_FLAG)
1123 $(MAYBE_PIC_Compile.CXX) $< -o $@ -S
1124
1125$(ObjDir)/%.s: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1126 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
1127 $(MAYBE_PIC_Compile.C) $< -o $@ -S
1128
1129
Chris Lattner89681112006-01-27 22:13:12 +00001130# make the C and C++ compilers strip debug info out of bytecode libraries.
1131ifdef DEBUG_RUNTIME
1132$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1133 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Chris Lattnerc0977982006-03-09 06:00:05 +00001134 $(Verb) $(GCCAS) $< -o $@
Chris Lattner89681112006-01-27 22:13:12 +00001135else
1136$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1137 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Chris Lattnerc0977982006-03-09 06:00:05 +00001138 $(Verb) $(GCCAS) -strip-debug $< -o $@
Chris Lattner89681112006-01-27 22:13:12 +00001139endif
1140
1141
Reid Spencercc2d1e22004-10-30 09:19:36 +00001142#---------------------------------------------------------
1143# Provide rule to build .bc files from .ll sources,
1144# regardless of dependencies
1145#---------------------------------------------------------
1146$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencer9af3b292004-11-01 07:50:27 +00001147 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001148 $(Verb) $(LLVMAS) $< -f -o $@
1149
1150###############################################################################
1151# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1152###############################################################################
Chris Lattner481cc7c2003-08-15 02:18:35 +00001153
Reid Spencer4d71b662004-10-22 21:01:56 +00001154ifdef TARGET
1155
Chris Lattnerd25ad612006-02-14 04:25:54 +00001156TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1157 $(LLVM_SRC_ROOT)/lib/Target/Target.td \
Chris Lattnercb3fc532006-03-03 01:54:54 +00001158 $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td \
1159 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001160INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Chris Lattner3c473472004-12-16 17:28:50 +00001161INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1162.PRECIOUS: $(INCTMPFiles) $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001163
Chris Lattner3c473472004-12-16 17:28:50 +00001164# All of these files depend on tblgen and the .td files.
1165$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001166
Chris Lattner23ee7952004-12-16 17:38:56 +00001167# INCFiles rule: All of the tblgen generated files are emitted to
1168# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1169# us to only "touch" the real file if the contents of it change. IOW, if
1170# tblgen is modified, all of the .inc.tmp files are regereated, but no
1171# dependencies of the .inc files are, unless the contents of the .inc file
1172# changes.
1173$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
Reid Spencerc3719842004-12-16 18:26:53 +00001174 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
Chris Lattner3c473472004-12-16 17:28:50 +00001175
1176$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1177$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001178 $(Echo) "Building $(<F) register names with tblgen"
1179 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001180
Chris Lattner3c473472004-12-16 17:28:50 +00001181$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1182$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001183 $(Echo) "Building $(<F) register information header with tblgen"
1184 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001185
Chris Lattner3c473472004-12-16 17:28:50 +00001186$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1187$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001188 $(Echo) "Building $(<F) register info implementation with tblgen"
1189 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001190
Chris Lattner3c473472004-12-16 17:28:50 +00001191$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1192$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001193 $(Echo) "Building $(<F) instruction names with tblgen"
1194 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001195
Chris Lattner3c473472004-12-16 17:28:50 +00001196$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1197$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001198 $(Echo) "Building $(<F) instruction information with tblgen"
1199 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001200
Chris Lattner3c473472004-12-16 17:28:50 +00001201$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1202$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001203 $(Echo) "Building $(<F) assembly writer with tblgen"
1204 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001205
Chris Lattner02a4f902004-12-16 17:34:04 +00001206$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1207$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1208 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001209 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001210
Chris Lattner3c473472004-12-16 17:28:50 +00001211$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1212$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001213 $(Echo) "Building $(<F) code emitter with tblgen"
1214 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001215
Chris Lattnerf31f09e2005-09-03 01:15:25 +00001216$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1217$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1218 $(Echo) "Building $(<F) instruction selector implementation with tblgen"
1219 $(Verb) $(TableGen) -gen-dag-isel -o $@ $<
1220
Jim Laskeyf5fc2cb2005-10-21 19:05:19 +00001221$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1222$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1223 $(Echo) "Building $(<F) subtarget information with tblgen"
1224 $(Verb) $(TableGen) -gen-subtarget -o $@ $<
Chris Lattnerf31f09e2005-09-03 01:15:25 +00001225
Reid Spencer3a561f52004-10-23 20:04:14 +00001226clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001227 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001228
1229endif
Chris Lattner481cc7c2003-08-15 02:18:35 +00001230
Reid Spencercc2d1e22004-10-30 09:19:36 +00001231###############################################################################
1232# LEX AND YACC: Provide rules for generating sources with lex and yacc
1233###############################################################################
Chris Lattnere8996782003-01-16 22:44:19 +00001234
Reid Spencercc2d1e22004-10-30 09:19:36 +00001235#---------------------------------------------------------
1236# Provide rules for generating a .cpp source file from
1237# (f)lex input sources.
1238#---------------------------------------------------------
1239
Reid Spencer3d659492004-11-02 16:36:03 +00001240LexFiles := $(filter %.l,$(Sources))
Reid Spencercc2d1e22004-10-30 09:19:36 +00001241
Reid Spencer3d659492004-11-02 16:36:03 +00001242ifneq ($(LexFiles),)
1243
Reid Spencer68a24bd2005-08-27 18:50:39 +00001244# Cancel built-in rules for lex
1245%.c: %.l
1246%.cpp: %.l
Reid Spencercc2d1e22004-10-30 09:19:36 +00001247
Chris Lattner342567c2006-02-14 05:12:00 +00001248all:: $(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs)
1249
Reid Spencercc2d1e22004-10-30 09:19:36 +00001250# Note the extra sed filtering here, used to cut down on the warnings emited
1251# by GCC. The last line is a gross hack to work around flex aparently not
1252# being able to resize the buffer on a large token input. Currently, for
1253# uninitialized string buffers in LLVM we can generate very long tokens, so
1254# this is a hack around it.
Chris Lattnerb7dc2b92003-08-15 20:00:47 +00001255# FIXME. (f.e. char Buffer[10000] )
Reid Spencer68a24bd2005-08-27 18:50:39 +00001256$(PROJ_SRC_DIR)/%.cpp: $(PROJ_SRC_DIR)/%.l
Reid Spencerc2ef8cd2004-12-10 19:44:16 +00001257 $(Echo) Flexing $*.l
Reid Spencer68a24bd2005-08-27 18:50:39 +00001258 $(Verb) $(FLEX) -t $(PROJ_SRC_DIR)/$*.l | \
Reid Spencer4d71b662004-10-22 21:01:56 +00001259 $(SED) 's/void yyunput/inline void yyunput/' | \
1260 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1261 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001262 > $(PROJ_SRC_DIR)/$*.cpp
Chris Lattner342567c2006-02-14 05:12:00 +00001263
1264# IFF the .l file has changed since it was last checked into CVS, copy the .l
1265# file to .l.cvs and the generated .cpp file to .cpp.cvs. We use this mechanism
1266# so that people without flex can build LLVM by copying the .cvs files to the
1267# source location and building them.
1268$(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1269$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattneraf2f3512006-02-16 05:10:48 +00001270 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs || \
Chris Lattner342567c2006-02-14 05:12:00 +00001271 ($(CP) $< $@; $(CP) $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001272
Chris Lattner342567c2006-02-14 05:12:00 +00001273$(LexFiles:%.l=$(ObjDir)/%.o) : \
1274$(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
Chris Lattner00950542001-06-06 20:29:01 +00001275
Reid Spencer9af3b292004-11-01 07:50:27 +00001276clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001277 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencer9af3b292004-11-01 07:50:27 +00001278
Reid Spencercc2d1e22004-10-30 09:19:36 +00001279endif
1280
1281#---------------------------------------------------------
1282# Provide rules for generating a .cpp and .h source files
1283# from yacc (bison) input sources.
1284#---------------------------------------------------------
1285
Reid Spencer3d659492004-11-02 16:36:03 +00001286YaccFiles := $(filter %.y,$(Sources))
1287ifneq ($(YaccFiles),)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001288
1289.PRECIOUS: $(YaccOutput)
1290
Chris Lattner1f1edce2006-02-15 07:23:05 +00001291all:: $(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs)
Chris Lattner6599c752006-02-15 07:16:57 +00001292
Reid Spencercc2d1e22004-10-30 09:19:36 +00001293# Cancel built-in rules for yacc
1294%.c: %.y
1295%.cpp: %.y
1296%.h: %.y
1297
Reid Spencer25e8a702005-12-21 23:17:06 +00001298# Rule for building the bison based parsers...
Reid Spencer68a24bd2005-08-27 18:50:39 +00001299$(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
Reid Spencercc2d1e22004-10-30 09:19:36 +00001300 $(Echo) "Bisoning $*.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001301 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1302 $(Verb) $(MV) -f $*.tab.c $(PROJ_SRC_DIR)/$*.cpp
1303 $(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
Chris Lattner00950542001-06-06 20:29:01 +00001304
Chris Lattner6599c752006-02-15 07:16:57 +00001305# IFF the .y file has changed since it was last checked into CVS, copy the .y
1306# file to .y.cvs and the generated .cpp/.h file to .cpp.cvs/.h.cvs. We use this
1307# mechanism so that people without flex can build LLVM by copying the .cvs files
1308# to the source location and building them.
1309$(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1310$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattneraf2f3512006-02-16 05:10:48 +00001311 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs || \
Chris Lattner6599c752006-02-15 07:16:57 +00001312 ($(CP) $< $@; \
Chris Lattner1f1edce2006-02-15 07:23:05 +00001313 $(CP) $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs; \
Chris Lattner6599c752006-02-15 07:16:57 +00001314 $(CP) $(PROJ_SRC_DIR)/$*.h $(PROJ_SRC_DIR)/$*.h.cvs)
Reid Spencer25e8a702005-12-21 23:17:06 +00001315
Chris Lattner6599c752006-02-15 07:16:57 +00001316
1317$(YaccFiles:%.y=$(ObjDir)/%.o): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
1318
1319YaccOutput := $(YaccFiles:%.y=%.output)
Reid Spencer25e8a702005-12-21 23:17:06 +00001320
Reid Spencer9af3b292004-11-01 07:50:27 +00001321clean-local::
Reid Spencer25e8a702005-12-21 23:17:06 +00001322 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001323endif
Chris Lattner00950542001-06-06 20:29:01 +00001324
Reid Spencercc2d1e22004-10-30 09:19:36 +00001325###############################################################################
1326# OTHER RULES: Other rules needed
1327###############################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +00001328
Chris Lattner30440c62003-01-16 21:06:18 +00001329# To create postscript files from dot files...
John Criswelle0f9ac62003-10-02 19:02:02 +00001330ifneq ($(DOT),false)
Chris Lattner30440c62003-01-16 21:06:18 +00001331%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +00001332 $(DOT) -Tps < $< > $@
John Criswell7a73b802003-06-30 21:59:07 +00001333else
1334%.ps: %.dot
Reid Spencercc2d1e22004-10-30 09:19:36 +00001335 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell7a73b802003-06-30 21:59:07 +00001336endif
Chris Lattner30440c62003-01-16 21:06:18 +00001337
John Criswell7f336952003-09-06 14:44:17 +00001338# This rules ensures that header files that are removed still have a rule for
1339# which they can be "generated." This allows make to ignore them and
1340# reproduce the dependency lists.
John Criswell4b6e5d12003-09-18 18:37:08 +00001341%.h:: ;
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001342%.hpp:: ;
John Criswell7f336952003-09-06 14:44:17 +00001343
Reid Spencercc2d1e22004-10-30 09:19:36 +00001344# Define clean-local to clean the current directory. Note that this uses a
1345# very conservative approach ensuring that empty variables do not cause
1346# errors or disastrous removal.
Reid Spencer3a561f52004-10-23 20:04:14 +00001347clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001348ifneq ($(strip $(ObjDir)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001349 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencere5487ba2004-10-24 07:53:21 +00001350endif
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001351 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001352ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001353 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001354endif
John Criswell7a73b802003-06-30 21:59:07 +00001355
Reid Spencer3d659492004-11-02 16:36:03 +00001356clean-all-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001357 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer3d659492004-11-02 16:36:03 +00001358
Reid Spencercc2d1e22004-10-30 09:19:36 +00001359# Build tags database for Emacs/Xemacs:
Reid Spencer12d79512004-11-12 02:27:36 +00001360tags:: TAGS CTAGS
1361
Reid Spencercc2d1e22004-10-30 09:19:36 +00001362TAGS:
Reid Spencer11fde542005-01-16 02:20:54 +00001363 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1364 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1365 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1366 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spencer12d79512004-11-12 02:27:36 +00001367 -name '*.cpp' -o -name '*.h' | \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001368 $(ETAGS) $(ETAGSFLAGS) -
1369
Reid Spencer12d79512004-11-12 02:27:36 +00001370CTAGS:
Reid Spencer11fde542005-01-16 02:20:54 +00001371 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1372 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1373 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1374 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spencer12d79512004-11-12 02:27:36 +00001375 \( -name '*.cpp' -o -name '*.h' \) -print | \
Reid Spencer11fde542005-01-16 02:20:54 +00001376 ctags -ImtT -o $(PROJ_OBJ_ROOT)/CTAGS -L -
Reid Spencer12d79512004-11-12 02:27:36 +00001377
1378
Reid Spencer3a561f52004-10-23 20:04:14 +00001379###############################################################################
1380# DEPENDENCIES: Include the dependency files if we should
1381###############################################################################
Chris Lattner33ad24a2003-08-22 14:10:16 +00001382ifndef DISABLE_AUTO_DEPENDENCIES
1383
Reid Spencer3a561f52004-10-23 20:04:14 +00001384# If its not one of the cleaning targets
Reid Spencercc2d1e22004-10-30 09:19:36 +00001385ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencer4d71b662004-10-22 21:01:56 +00001386
Reid Spencer3a561f52004-10-23 20:04:14 +00001387# Get the list of dependency files
Reid Spencercc2d1e22004-10-30 09:19:36 +00001388DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Chris Lattner342567c2006-02-14 05:12:00 +00001389DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
Misha Brukman4f7a8cf2003-11-09 21:36:19 +00001390
Reid Spencer3a561f52004-10-23 20:04:14 +00001391-include /dev/null $(DependFiles)
1392
John Criswelld741bcf2003-08-12 18:51:51 +00001393endif
Chris Lattner1ddb6b62003-08-18 17:27:40 +00001394
Reid Spencercc2d1e22004-10-30 09:19:36 +00001395endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001396
Reid Spencer151f8ba2004-10-25 08:27:37 +00001397###############################################################################
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001398# CHECK: Running the test suite
1399###############################################################################
1400
1401check::
Reid Spencer11fde542005-01-16 02:20:54 +00001402 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1403 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001404 $(EchoCmd) Running test suite ; \
Reid Spencer11fde542005-01-16 02:20:54 +00001405 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001406 TESTSUITE=$(TESTSUITE) ; \
1407 else \
1408 $(EchoCmd) No Makefile in test directory ; \
1409 fi ; \
1410 else \
1411 $(EchoCmd) No test directory ; \
1412 fi
1413
1414###############################################################################
Reid Spencercc2d1e22004-10-30 09:19:36 +00001415# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer151f8ba2004-10-25 08:27:37 +00001416###############################################################################
1417
Reid Spencere45ebfa2004-10-26 07:09:33 +00001418#------------------------------------------------------------------------
1419# Define distribution related variables
1420#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +00001421DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1422DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1423TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1424DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1425DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1426DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
Reid Spencer151f8ba2004-10-25 08:27:37 +00001427DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1428 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001429 Makefile.config.in configure autoconf
1430DistOther := $(notdir $(wildcard \
Reid Spencer11fde542005-01-16 02:20:54 +00001431 $(PROJ_SRC_DIR)/*.h \
1432 $(PROJ_SRC_DIR)/*.td \
1433 $(PROJ_SRC_DIR)/*.def \
1434 $(PROJ_SRC_DIR)/*.ll \
1435 $(PROJ_SRC_DIR)/*.in))
Reid Spencercc2d1e22004-10-30 09:19:36 +00001436DistSubDirs := $(SubDirs)
Reid Spencerfbbf3072004-11-29 05:00:33 +00001437DistSources = $(Sources) $(EXTRA_DIST)
1438DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer151f8ba2004-10-25 08:27:37 +00001439
Reid Spencere45ebfa2004-10-26 07:09:33 +00001440#------------------------------------------------------------------------
1441# We MUST build distribution with OBJ_DIR != SRC_DIR
1442#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +00001443ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
Reid Spencere45ebfa2004-10-26 07:09:33 +00001444dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001445 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencere45ebfa2004-10-26 07:09:33 +00001446
Reid Spencere45ebfa2004-10-26 07:09:33 +00001447else
1448
Reid Spencere45ebfa2004-10-26 07:09:33 +00001449#------------------------------------------------------------------------
Reid Spencere45ebfa2004-10-26 07:09:33 +00001450# Prevent attempt to run dist targets from anywhere but the top level
1451#------------------------------------------------------------------------
1452ifneq ($(LEVEL),.)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001453dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencer11fde542005-01-16 02:20:54 +00001454 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001455else
1456
1457#------------------------------------------------------------------------
1458# Provide the top level targets
1459#------------------------------------------------------------------------
1460
Reid Spencercc2d1e22004-10-30 09:19:36 +00001461dist-gzip:: $(DistTarGZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001462
Reid Spencer345235ca2004-12-04 22:34:09 +00001463$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001464 $(Echo) Packing gzipped distribution tar file.
Reid Spencer11fde542005-01-16 02:20:54 +00001465 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
Reid Spencerfbbf3072004-11-29 05:00:33 +00001466 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencere45ebfa2004-10-26 07:09:33 +00001467
Reid Spencercc2d1e22004-10-30 09:19:36 +00001468dist-bzip2:: $(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001469
Reid Spencer345235ca2004-12-04 22:34:09 +00001470$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001471 $(Echo) Packing bzipped distribution tar file.
Reid Spencer11fde542005-01-16 02:20:54 +00001472 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
Reid Spencerfbbf3072004-11-29 05:00:33 +00001473 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001474
Reid Spencercc2d1e22004-10-30 09:19:36 +00001475dist-zip:: $(DistZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001476
Reid Spencer345235ca2004-12-04 22:34:09 +00001477$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001478 $(Echo) Packing zipped distribution file.
1479 $(Verb) rm -f $(DistZip)
Reid Spencer11fde542005-01-16 02:20:54 +00001480 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001481
1482dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001483 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001484
Reid Spencerf8f57402005-01-28 19:52:32 +00001485DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
Reid Spencere45ebfa2004-10-26 07:09:33 +00001486
Reid Spencer345235ca2004-12-04 22:34:09 +00001487dist-check:: $(DistTarGZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001488 $(Echo) Checking distribution tar file.
1489 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001490 $(RM) -rf $(DistCheckDir) ; \
1491 fi
Reid Spencercc2d1e22004-10-30 09:19:36 +00001492 $(Verb) $(MKDIR) $(DistCheckDir)
1493 $(Verb) cd $(DistCheckDir) && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001494 $(MKDIR) $(DistCheckDir)/build && \
1495 $(MKDIR) $(DistCheckDir)/install && \
1496 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1497 cd build && \
1498 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
Reid Spencer45eeed92005-05-24 02:33:20 +00001499 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
Reid Spencer345235ca2004-12-04 22:34:09 +00001500 $(MAKE) all && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001501 $(MAKE) check && \
1502 $(MAKE) install && \
1503 $(MAKE) uninstall && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001504 $(MAKE) dist-clean && \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001505 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001506
1507dist-clean::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001508 $(Echo) Cleaning distribution files
Reid Spencer345235ca2004-12-04 22:34:09 +00001509 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1510 $(DistCheckDir)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001511
1512endif
1513
1514#------------------------------------------------------------------------
1515# Provide the recursive distdir target for building the distribution directory
1516#------------------------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +00001517distdir: $(DistDir)/.makedistdir
1518$(DistDir)/.makedistdir: $(DistSources)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001519 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001520 if test -d "$(DistDir)" ; then \
1521 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1522 exit 1 ; \
1523 fi ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001524 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001525 $(RM) -rf $(DistDir); \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001526 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer854071c2006-04-10 16:46:04 +00001527 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001528 fi
Reid Spencerfbbf3072004-11-29 05:00:33 +00001529 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001530 $(Verb) $(MKDIR) $(DistDir)
Reid Spencer11fde542005-01-16 02:20:54 +00001531 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1532 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001533 for file in $(DistFiles) ; do \
1534 case "$$file" in \
Reid Spencer11fde542005-01-16 02:20:54 +00001535 $(PROJ_SRC_DIR)/*) \
Reid Spencer345235ca2004-12-04 22:34:09 +00001536 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1537 ;; \
Reid Spencer11fde542005-01-16 02:20:54 +00001538 $(PROJ_SRC_ROOT)/*) \
Reid Spencer345235ca2004-12-04 22:34:09 +00001539 file=`echo "$$file" | \
1540 sed "s#^$$srcrootstrip/##"` \
1541 ;; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001542 esac; \
Reid Spencer11fde542005-01-16 02:20:54 +00001543 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1544 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1545 from_dir="$(PROJ_SRC_DIR)" ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001546 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001547 from_dir=. ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001548 fi ; \
1549 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001550 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1551 to_dir="$(DistDir)/$$dir"; \
1552 $(MKDIR) "$$to_dir" ; \
1553 else \
1554 to_dir="$(DistDir)"; \
1555 fi; \
1556 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1557 if test -n "$$mid_dir" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001558 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001559 fi ; \
1560 if test -d "$$from_dir/$$file"; then \
Reid Spencer11fde542005-01-16 02:20:54 +00001561 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1562 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
Reid Spencer45eeed92005-05-24 02:33:20 +00001563 cd $(PROJ_SRC_DIR) ; \
1564 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1565 ( cd $$to_dir ; $(TAR) xf - ) ; \
1566 cd $(PROJ_OBJ_DIR) ; \
1567 else \
1568 cd $$from_dir ; \
1569 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1570 ( cd $$to_dir ; $(TAR) xf - ) ; \
1571 cd $(PROJ_OBJ_DIR) ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001572 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001573 elif test -f "$$from_dir/$$file" ; then \
Reid Spencerc3719842004-12-16 18:26:53 +00001574 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001575 elif test -L "$$from_dir/$$file" ; then \
Reid Spencerc3719842004-12-16 18:26:53 +00001576 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001577 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer345235ca2004-12-04 22:34:09 +00001578 $(EchoCmd) "===== WARNING: Distribution Source " \
1579 "$$from_dir/$$file Not Found!" ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001580 elif test "$(Verb)" != '@' ; then \
1581 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001582 fi; \
1583 done
Reid Spencercc2d1e22004-10-30 09:19:36 +00001584 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001585 if test "$$subdir" \!= "." ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001586 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001587 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer854071c2006-04-10 16:46:04 +00001588 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
Reid Spencerbac3ca22006-04-07 16:06:18 +00001589 DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001590 fi; \
1591 done
Reid Spencer345235ca2004-12-04 22:34:09 +00001592 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer45eeed92005-05-24 02:33:20 +00001593 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
Chris Lattner77efe272006-02-14 04:27:15 +00001594 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1595 -name .svn \) -print` ;\
Reid Spencer345235ca2004-12-04 22:34:09 +00001596 $(MAKE) dist-hook ; \
1597 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1598 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1599 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1600 -o ! -type d ! -perm -444 -exec \
1601 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1602 || chmod -R a+r $(DistDir) ; \
1603 fi
Reid Spencer151f8ba2004-10-25 08:27:37 +00001604
Reid Spencercc2d1e22004-10-30 09:19:36 +00001605# This is invoked by distdir target, define it as a no-op to avoid errors if not
1606# defined by user.
Reid Spencer151f8ba2004-10-25 08:27:37 +00001607dist-hook::
1608
Reid Spencere53e3972004-10-22 23:06:30 +00001609endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001610
1611###############################################################################
Reid Spencere5487ba2004-10-24 07:53:21 +00001612# TOP LEVEL - targets only to apply at the top level directory
1613###############################################################################
1614
1615ifeq ($(LEVEL),.)
1616
1617#------------------------------------------------------------------------
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001618# Install support for the project's include files:
Reid Spencere5487ba2004-10-24 07:53:21 +00001619#------------------------------------------------------------------------
1620install-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001621 $(Echo) Installing include files
Reid Spencer11fde542005-01-16 02:20:54 +00001622 $(Verb) $(MKDIR) $(PROJ_includedir)
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001623 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
Reid Spencer11fde542005-01-16 02:20:54 +00001624 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer2edabc02005-02-16 15:54:03 +00001625 for hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
1626 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS ` ; do \
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001627 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1628 if test \! -d "$$instdir" ; then \
1629 $(EchoCmd) Making install directory $$instdir ; \
1630 $(MKDIR) $$instdir ;\
1631 fi ; \
1632 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer2edabc02005-02-16 15:54:03 +00001633 done ; \
Reid Spencere5487ba2004-10-24 07:53:21 +00001634 fi
Reid Spencer443045a2005-12-23 22:27:56 +00001635ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001636 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
Reid Spencer2edabc02005-02-16 15:54:03 +00001637 cd $(PROJ_OBJ_ROOT)/include && \
Reid Spencer443045a2005-12-23 22:27:56 +00001638 for hdr in `find . -type f -print | grep -v CVS` ; do \
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001639 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer2edabc02005-02-16 15:54:03 +00001640 done ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001641 fi
Reid Spencer443045a2005-12-23 22:27:56 +00001642endif
Reid Spencere5487ba2004-10-24 07:53:21 +00001643
1644uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001645 $(Echo) Uninstalling include files
Reid Spencer11fde542005-01-16 02:20:54 +00001646 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1647 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencere5487ba2004-10-24 07:53:21 +00001648 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
Chris Lattnerd25ad612006-02-14 04:25:54 +00001649 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' \
1650 -o -name '*.in' ')' -print ')' | \
1651 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001652 cd $(PROJ_SRC_ROOT)/include && \
Chris Lattnerd25ad612006-02-14 04:25:54 +00001653 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1654 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001655 fi
Reid Spencere5487ba2004-10-24 07:53:21 +00001656
Reid Spencere5487ba2004-10-24 07:53:21 +00001657endif
1658
Reid Spencer4d71b662004-10-22 21:01:56 +00001659#------------------------------------------------------------------------
1660# Print out the directories used for building
Reid Spencercc2d1e22004-10-30 09:19:36 +00001661#------------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001662printvars::
Reid Spencer11fde542005-01-16 02:20:54 +00001663 $(Echo) "BuildMode : " '$(BuildMode)'
1664 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1665 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1666 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1667 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1668 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1669 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1670 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1671 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1672 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1673 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
Reid Spencer1a9a69c2005-02-16 16:13:02 +00001674 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
Reid Spencer11fde542005-01-16 02:20:54 +00001675 $(Echo) "UserTargets : " '$(UserTargets)'
1676 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1677 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1678 $(Echo) "ObjDir : " '$(ObjDir)'
1679 $(Echo) "LibDir : " '$(LibDir)'
1680 $(Echo) "ToolDir : " '$(ToolDir)'
1681 $(Echo) "ExmplDir : " '$(ExmplDir)'
1682 $(Echo) "Sources : " '$(Sources)'
1683 $(Echo) "TDFiles : " '$(TDFiles)'
1684 $(Echo) "INCFiles : " '$(INCFiles)'
1685 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
Reid Spencere0acb762005-03-01 16:27:06 +00001686 $(Echo) "PreConditions: " '$(PreConditions)'
Reid Spencer11fde542005-01-16 02:20:54 +00001687 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1688 $(Echo) "Compile.C : " '$(Compile.C)'
1689 $(Echo) "Archive : " '$(Archive)'
1690 $(Echo) "YaccFiles : " '$(YaccFiles)'
1691 $(Echo) "LexFiles : " '$(LexFiles)'
1692 $(Echo) "Module : " '$(Module)'
Reid Spencer755bcf02005-08-24 10:43:10 +00001693 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
Reid Spencerf9f431c2006-04-09 23:41:14 +00001694 $(Echo) "SubDirs : " '$(SubDirs)'