blob: df8f63f6f1aa7ea4913e3b4ebdd4986fa298cbb9 [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 Lattnerd63b9642006-05-24 23:02:40 +0000211 CXX.Flags := $(OPTIMIZE_OPTION) -pg
212 C.Flags := $(OPTIMIZE_OPTION) -pg
213 LD.Flags := $(OPTIMIZE_OPTION) -pg
Chris Lattner760da062003-03-14 20:25:22 +0000214else
215 ifdef ENABLE_OPTIMIZED
Reid Spencer9af3b292004-11-01 07:50:27 +0000216 BuildMode := Release
Reid Spencer325a87e2005-01-02 17:43:20 +0000217 # Don't use -fomit-frame-pointer on FreeBSD
218 ifneq ($(OS),FreeBSD)
Chris Lattnere5aa8f32006-05-24 18:34:08 +0000219 # Don't use -fomit-frame-pointer on Darwin, it breaks backtraces.
220 ifneq ($(OS),Darwin)
Reid Spencer325a87e2005-01-02 17:43:20 +0000221 OmitFramePointer := -fomit-frame-pointer
222 endif
Chris Lattnere5aa8f32006-05-24 18:34:08 +0000223 endif
Chris Lattnerd63b9642006-05-24 23:02:40 +0000224 CXX.Flags := $(OPTIMIZE_OPTION) $(OmitFramePointer)
225 C.Flags := $(OPTIMIZE_OPTION) $(OmitFramePointer)
226 LD.Flags := $(OPTIMIZE_OPTION)
Chris Lattner760da062003-03-14 20:25:22 +0000227 else
Reid Spencer9af3b292004-11-01 07:50:27 +0000228 BuildMode := Debug
Chris Lattner71927862006-03-21 01:06:41 +0000229 CXX.Flags := -g
230 C.Flags := -g
231 LD.Flags := -g
Reid Spencer4d71b662004-10-22 21:01:56 +0000232 KEEP_SYMBOLS := 1
Chris Lattner760da062003-03-14 20:25:22 +0000233 endif
234endif
235
Reid Spencer854071c2006-04-10 16:46:04 +0000236# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
237# then disable assertions by defining the appropriate preprocessor symbols.
Reid Spencerf9f431c2006-04-09 23:41:14 +0000238ifdef DISABLE_ASSERTIONS
Reid Spencerbac3ca22006-04-07 16:06:18 +0000239 BuildMode := $(BuildMode)-Asserts
Chris Lattner71927862006-03-21 01:06:41 +0000240 CXX.Flags += -DNDEBUG
241 C.Flags += -DNDEBUG
Reid Spencerf9f431c2006-04-09 23:41:14 +0000242else
243 CXX.Flags += -D_DEBUG
244 C.Flags += -D_DEBUG
Chris Lattner71927862006-03-21 01:06:41 +0000245endif
246
Reid Spencerf2722ca2006-03-22 15:59:55 +0000247CXX.Flags += $(CXXFLAGS)
248C.Flags += $(CFLAGS)
249CPP.BaseFlags += $(CPPFLAGS)
250LD.Flags += $(LDFLAGS)
251AR.Flags := cru
Reid Spencercc2d1e22004-10-30 09:19:36 +0000252LibTool.Flags := --tag=CXX
Reid Spencer3a561f52004-10-23 20:04:14 +0000253
Andrew Lenharth39bcf5b2005-02-13 03:41:10 +0000254#Make Floating point ieee complient on alpha
255ifeq ($(ARCH),Alpha)
Reid Spencerf2722ca2006-03-22 15:59:55 +0000256 CXX.Flags += -mieee
257 CPP.BaseFlags += -mieee
Andrew Lenharth39bcf5b2005-02-13 03:41:10 +0000258endif
259
Reid Spencer3a561f52004-10-23 20:04:14 +0000260#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000261# Directory locations
Reid Spencer3a561f52004-10-23 20:04:14 +0000262#--------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +0000263ObjDir := $(PROJ_OBJ_DIR)/$(BuildMode)
264LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
265ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
266ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer815cbcf2004-11-18 10:03:46 +0000267LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer9a5acaf2004-11-18 20:04:39 +0000268LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer775bf892004-12-28 07:59:22 +0000269LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer2f138e72004-12-22 05:57:21 +0000270CFERuntimeLibDir := $(LLVMGCCDIR)/lib
John Criswell7a73b802003-06-30 21:59:07 +0000271
Reid Spencer3a561f52004-10-23 20:04:14 +0000272#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000273# Full Paths To Compiled Tools and Utilities
Reid Spencer3a561f52004-10-23 20:04:14 +0000274#--------------------------------------------------------------------
Reid Spencer3ca6d8b2005-01-14 16:33:36 +0000275EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
276Echo = @$(EchoCmd)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000277ifndef LIBTOOL
Reid Spencer4d71b662004-10-22 21:01:56 +0000278LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencercc2d1e22004-10-30 09:19:36 +0000279endif
280ifndef LLVMAS
281LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
282endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000283ifndef TBLGEN
284TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
285endif
Chris Lattner478b3b42004-11-29 19:47:58 +0000286ifndef GCCAS
287GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
288endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000289ifndef GCCLD
290GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
291endif
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000292ifndef LDIS
293LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
294endif
295ifndef LLI
296LLI := $(LLVMToolDir)/lli$(EXEEXT)
297endif
Alkis Evlogimenoseebaf332005-02-27 10:21:37 +0000298ifndef LLC
299LLC := $(LLVMToolDir)/llc$(EXEEXT)
300endif
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000301ifndef LOPT
Alkis Evlogimenos20d793a2004-12-13 18:08:29 +0000302LOPT := $(LLVMToolDir)/opt$(EXEEXT)
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000303endif
Alkis Evlogimenos270e8512005-02-02 00:40:15 +0000304ifndef LBUGPOINT
305LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
306endif
307
John Criswellf5629d02005-01-03 17:42:57 +0000308LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
309LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000310
Reid Spencer3a561f52004-10-23 20:04:14 +0000311#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000312# Adjust to user's request
Reid Spencer3a561f52004-10-23 20:04:14 +0000313#--------------------------------------------------------------------
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000314
Reid Spencer492c2932005-01-11 04:31:07 +0000315# Adjust LD.Flags and Libtool.Flags depending on the kind of library that is
316# to be built. Note that if LOADABLE_MODULE is specified then the resulting
317# shared library can be opened with dlopen
318ifdef SHARED_LIBRARY
Reid Spencercc2d1e22004-10-30 09:19:36 +0000319 LD.Flags += -rpath $(LibDir)
Reid Spencer492c2932005-01-11 04:31:07 +0000320 ifdef LOADABLE_MODULE
321 LD.Flags += -module
322 endif
323else
324 LibTool.Flags += --tag=disable-shared
John Criswell82f4a5a2003-07-31 20:58:51 +0000325endif
326
Reid Spencercceed9f2004-11-08 17:32:12 +0000327ifdef TOOL_VERBOSE
328 C.Flags += -v
329 CXX.Flags += -v
330 LD.Flags += -v
Reid Spencercceed9f2004-11-08 17:32:12 +0000331 VERBOSE := 1
332endif
333
Reid Spencer3a561f52004-10-23 20:04:14 +0000334# Adjust settings for verbose mode
Chris Lattner760da062003-03-14 20:25:22 +0000335ifndef VERBOSE
Reid Spencercc2d1e22004-10-30 09:19:36 +0000336 Verb := @
337 LibTool.Flags += --silent
338 AR.Flags += >/dev/null 2>/dev/null
Reid Spencer11fde542005-01-16 02:20:54 +0000339 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
Reid Spencer151f8ba2004-10-25 08:27:37 +0000340else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000341 ConfigureScriptFLAGS :=
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000342endif
343
Vikram S. Advefeeae582002-09-18 11:55:13 +0000344# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000345ifndef KEEP_SYMBOLS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000346 Strip := $(PLATFORMSTRIPOPTS)
347 StripWarnMsg := "(without symbols)"
Reid Spencer860598a2005-02-24 07:12:43 +0000348 Install.StripFlag += -s
Vikram S. Advefeeae582002-09-18 11:55:13 +0000349endif
350
Reid Spencer3a561f52004-10-23 20:04:14 +0000351# Adjust linker flags for building an executable
Reid Spencer4d71b662004-10-22 21:01:56 +0000352ifdef TOOLNAME
Reid Spencer815cbcf2004-11-18 10:03:46 +0000353ifdef EXAMPLE_TOOL
354 LD.Flags += -rpath $(ExmplDir) -export-dynamic
355else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000356 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000357endif
Reid Spencer815cbcf2004-11-18 10:03:46 +0000358endif
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000359
Reid Spencer3a561f52004-10-23 20:04:14 +0000360#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000361# Options To Invoke Tools
Reid Spencer3a561f52004-10-23 20:04:14 +0000362#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000363
Reid Spencer72f42bb2006-06-01 01:55:21 +0000364CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused -Wno-long-long \
365 -pedantic
Reid Spencer4d71b662004-10-22 21:01:56 +0000366
Duraid Madina0ad8fcf2005-05-16 06:38:09 +0000367ifeq ($(OS),HP-UX)
Duraid Madinaeb713402006-02-15 03:20:16 +0000368 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
Duraid Madina0ad8fcf2005-05-16 06:38:09 +0000369endif
370
Chris Lattner73faa392006-05-30 16:38:06 +0000371# If we are building a universal binary on Mac OS/X, pass extra options. This
372# is useful to people that want to link the LLVM libraries into their universal
Chris Lattnerf988e532006-06-16 21:47:59 +0000373# apps. The UNIVERSAL_SDK_PATH variable can optionally be specified as a path
374# to the SDK to use. For Mac OS/X 10.4 Intel machines, the traditional one is:
375# UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
Chris Lattnerba466652006-04-06 06:30:15 +0000376ifdef UNIVERSAL
Chris Lattnerf988e532006-06-16 21:47:59 +0000377 CompileCommonOpts += -arch i386 -arch ppc
Chris Lattner3a00a3e2006-04-19 18:45:29 +0000378 Relink.Flags := -XCClinker -arch -XCClinker i386 -XCClinker -arch \
Chris Lattnerf988e532006-06-16 21:47:59 +0000379 -XCClinker ppc
380 ifdef UNIVERSAL_SDK_PATH
381 CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
382 Relink.Flags += -XCClinker -isysroot -XCClinker $(UNIVERSAL_SDK_PATH)
383 endif
384
385 # Building universal cannot compute dependencies automatically.
Chris Lattnerba466652006-04-06 06:30:15 +0000386 DISABLE_AUTO_DEPENDENCIES=1
387endif
388
Chris Lattner73faa392006-05-30 16:38:06 +0000389# Temporary workaround for a Mac OSX compatibility issue.
Evan Cheng4d0586b2006-04-07 08:31:56 +0000390ifeq ($(OS),Darwin)
Evan Cheng4d0586b2006-04-07 08:31:56 +0000391 CXX.Flags += -fno-use-cxa-atexit
392endif
Evan Chengafd131e2006-04-07 08:10:09 +0000393
Reid Spencerf2722ca2006-03-22 15:59:55 +0000394LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
395CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
396# All -I flags should go here, so that they don't confuse llvm-config.
397CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
398 -I$(PROJ_OBJ_ROOT)/include \
399 -I$(PROJ_SRC_ROOT)/include \
400 -I$(LLVM_OBJ_ROOT)/include \
401 -I$(LLVM_SRC_ROOT)/include \
402 $(CPP.BaseFlags)
Reid Spencer4d71b662004-10-22 21:01:56 +0000403
Reid Spencercc2d1e22004-10-30 09:19:36 +0000404Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
405LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
Reid Spencer2f138e72004-12-22 05:57:21 +0000406BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattner89681112006-01-27 22:13:12 +0000407 $(C.Flags)
Chris Lattner0cb09f12005-10-05 00:28:41 +0000408Preprocess.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -E $(C.Flags)
409
Reid Spencercc2d1e22004-10-30 09:19:36 +0000410Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
411LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
Reid Spencerbc52ad72004-12-24 14:47:34 +0000412BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattner89681112006-01-27 22:13:12 +0000413 $(CXX.Flags)
Chris Lattner0cb09f12005-10-05 00:28:41 +0000414Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
Reid Spencercc2d1e22004-10-30 09:19:36 +0000415Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencerc14c9362006-05-16 06:51:02 +0000416 $(CXX.Flags) $(CompileCommonOpts) $(LD.Flags) $(Strip)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000417Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencerc14c9362006-05-16 06:51:02 +0000418 $(CXX.Flags) $(CompileCommonOpts) $(Relink.Flags)
Reid Spencer1a9a69c2005-02-16 16:13:02 +0000419LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
420 $(Install.Flags)
Reid Spencer860598a2005-02-24 07:12:43 +0000421ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
Reid Spencerf2722ca2006-03-22 15:59:55 +0000422ScriptInstall = $(INSTALL) -m 0755
Reid Spencer860598a2005-02-24 07:12:43 +0000423DataInstall = $(INSTALL) -m 0644
Vladimir Pruse438c2a2006-05-16 06:39:36 +0000424TableGen = $(TBLGEN) -I $(PROJ_SRC_DIR) -I$(PROJ_SRC_ROOT)/include \
425 -I $(PROJ_SRC_ROOT)/lib/Target
Reid Spencercc2d1e22004-10-30 09:19:36 +0000426Archive = $(AR) $(AR.Flags)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000427LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencer4d71b662004-10-22 21:01:56 +0000428ifdef RANLIB
Reid Spencer3a561f52004-10-23 20:04:14 +0000429Ranlib = $(RANLIB)
Reid Spencer4d71b662004-10-22 21:01:56 +0000430else
Reid Spencer3a561f52004-10-23 20:04:14 +0000431Ranlib = ranlib
John Criswell7a73b802003-06-30 21:59:07 +0000432endif
433
Chris Lattner00950542001-06-06 20:29:01 +0000434#----------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +0000435# Get the list of source files and compute object file
436# names from them.
Reid Spencer3a561f52004-10-23 20:04:14 +0000437#----------------------------------------------------------
Chris Lattner89681112006-01-27 22:13:12 +0000438
439ifndef SOURCES
440 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
441 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
442 $(PROJ_SRC_DIR)/*.l))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000443else
Chris Lattner89681112006-01-27 22:13:12 +0000444 Sources := $(SOURCES)
445endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000446
Chris Lattner89681112006-01-27 22:13:12 +0000447ifdef BUILT_SOURCES
448Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Reid Spencer345235ca2004-12-04 22:34:09 +0000449endif
Reid Spencer3a561f52004-10-23 20:04:14 +0000450
Chris Lattner89681112006-01-27 22:13:12 +0000451BaseNameSources := $(sort $(basename $(Sources)))
452
453ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
454ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
455ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
456
Reid Spencer3a561f52004-10-23 20:04:14 +0000457###############################################################################
458# DIRECTORIES: Handle recursive descent of directory structure
459###############################################################################
John Criswell82f4a5a2003-07-31 20:58:51 +0000460
Chris Lattner00950542001-06-06 20:29:01 +0000461#---------------------------------------------------------
Reid Spencera69b1ea2004-10-28 09:15:28 +0000462# Provide rules to make install dirs. This must be early
463# in the file so they get built before dependencies
464#---------------------------------------------------------
465
Reid Spenceraa8bc432005-05-19 20:26:14 +0000466$(PROJ_bindir): $(PROJ_bindir)/.dir
467$(PROJ_libdir): $(PROJ_libdir)/.dir
468$(PROJ_includedir): $(PROJ_includedir)/.dir
469$(PROJ_etcdir): $(PROJ_etcdir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000470
Reid Spencercc2d1e22004-10-30 09:19:36 +0000471# To create other directories, as needed, and timestamp their creation
472%/.dir:
473 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfbbf3072004-11-29 05:00:33 +0000474 $(Verb) $(DATE) > $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000475
Reid Spencer815cbcf2004-11-18 10:03:46 +0000476.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
477.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000478
479#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000480# Handle the DIRS options for sequential construction
Chris Lattner00950542001-06-06 20:29:01 +0000481#---------------------------------------------------------
482
Reid Spencercc2d1e22004-10-30 09:19:36 +0000483SubDirs :=
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000484ifdef DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000485SubDirs += $(DIRS)
486$(RecursiveTargets)::
487 $(Verb) for dir in $(DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000488 if [ ! -f $$dir/Makefile ]; then \
489 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000490 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000491 fi; \
Reid Spencerdd1aac32006-05-17 22:55:35 +0000492 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000493 done
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000494endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000495
Reid Spencer3a561f52004-10-23 20:04:14 +0000496#---------------------------------------------------------
497# Handle the EXPERIMENTAL_DIRS options ensuring success
498# after each directory is built.
499#---------------------------------------------------------
500ifdef EXPERIMENTAL_DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000501$(RecursiveTargets)::
502 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer3a561f52004-10-23 20:04:14 +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 Spencer3a561f52004-10-23 20:04:14 +0000506 fi; \
Reid Spencerdd1aac32006-05-17 22:55:35 +0000507 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000508 done
509endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000510
Reid Spencer25e8a702005-12-21 23:17:06 +0000511#-----------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000512# Handle the PARALLEL_DIRS options for parallel construction
Reid Spencer25e8a702005-12-21 23:17:06 +0000513#-----------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000514ifdef PARALLEL_DIRS
515
Reid Spencercc2d1e22004-10-30 09:19:36 +0000516SubDirs += $(PARALLEL_DIRS)
517
Reid Spencer44cb1b32004-12-03 20:08:48 +0000518# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencercc2d1e22004-10-30 09:19:36 +0000519all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
520clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000521clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000522install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000523uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencer44cb1b32004-12-03 20:08:48 +0000524install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000525
Reid Spencer345235ca2004-12-04 22:34:09 +0000526ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer3a561f52004-10-23 20:04:14 +0000527
Reid Spencer345235ca2004-12-04 22:34:09 +0000528$(ParallelTargets) :
Reid Spencercc2d1e22004-10-30 09:19:36 +0000529 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencer4d71b662004-10-22 21:01:56 +0000530 $(MKDIR) $(@D); \
Reid Spencer11fde542005-01-16 02:20:54 +0000531 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswellb3866b62003-11-25 19:32:22 +0000532 fi; \
Reid Spencerdd1aac32006-05-17 22:55:35 +0000533 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ;
Chris Lattner00950542001-06-06 20:29:01 +0000534endif
535
Reid Spencer3a561f52004-10-23 20:04:14 +0000536#---------------------------------------------------------
537# Handle the OPTIONAL_DIRS options for directores that may
538# or may not exist.
539#---------------------------------------------------------
John Criswell2a6530f2003-06-27 16:58:44 +0000540ifdef OPTIONAL_DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000541
Reid Spencercc2d1e22004-10-30 09:19:36 +0000542SubDirs += $(OPTIONAL_DIRS)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000543
Reid Spencercc2d1e22004-10-30 09:19:36 +0000544$(RecursiveTargets)::
545 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000546 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
Reid Spencer4d71b662004-10-22 21:01:56 +0000547 if [ ! -f $$dir/Makefile ]; then \
548 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000549 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000550 fi; \
Reid Spencerdd1aac32006-05-17 22:55:35 +0000551 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000552 fi \
John Criswell2a6530f2003-06-27 16:58:44 +0000553 done
554endif
555
Reid Spencerfc945082004-08-20 09:20:05 +0000556#---------------------------------------------------------
557# Handle the CONFIG_FILES options
558#---------------------------------------------------------
559ifdef CONFIG_FILES
Reid Spencerfc945082004-08-20 09:20:05 +0000560
Reid Spencer11fde542005-01-16 02:20:54 +0000561install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
562 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000563 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000564 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
Reid Spencer4a0aaea2005-02-24 03:56:32 +0000565 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer11fde542005-01-16 02:20:54 +0000566 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
Reid Spencer4a0aaea2005-02-24 03:56:32 +0000567 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer1b426ab2004-11-23 05:59:53 +0000568 else \
569 $(ECHO) Error: cannot find config file $${file}. ; \
570 fi \
Reid Spencerfc945082004-08-20 09:20:05 +0000571 done
Reid Spencer3a561f52004-10-23 20:04:14 +0000572
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000573uninstall-local::
Reid Spencer11fde542005-01-16 02:20:54 +0000574 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000575 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000576 $(RM) -f $(PROJ_etcdir)/$${file} ; \
Reid Spencere5487ba2004-10-24 07:53:21 +0000577 done
578
Reid Spencerfc945082004-08-20 09:20:05 +0000579endif
580
Reid Spencer3a561f52004-10-23 20:04:14 +0000581###############################################################################
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000582# Set up variables for building libararies
583###############################################################################
584
585#---------------------------------------------------------
586# Handle the special "JIT" value for LLVM_LIBS which is a
587# shorthand for a bunch of libraries that get the correct
588# JIT support for a library or a tool that runs JIT.
589#---------------------------------------------------------
Reid Spencer205b02e2006-03-24 07:36:57 +0000590ifeq ($(firstword $(LLVMLIBS)),config)
591LLVM_CONFIG := $(LLVM_SRC_ROOT)/utils/llvm-config/llvm-config
Reid Spencerbac3ca22006-04-07 16:06:18 +0000592LLVMLIBS := $(shell $(LLVM_CONFIG) --libnames $(wordlist 2,9999,$(LLVMLIBS)))
593LLVMLIBS := $(patsubst lib%.a,%.a,$(LLVMLIBS))
Reid Spencer205b02e2006-03-24 07:36:57 +0000594LLVMLIBS := $(patsubst %.o,%,$(LLVMLIBS))
Reid Spencer205b02e2006-03-24 07:36:57 +0000595endif
596
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000597ifeq ($(LLVMLIBS),JIT)
598
599# Make sure we can get our own symbols in the tool
600Link += -dlopen self
601
602# Generic JIT libraries
603JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
604
605# You can enable the X86 JIT on a non-X86 host by setting the flag
606# ENABLE_X86_JIT on the make command line. If not, it will still be
607# enabled automagically on an X86 host.
608ifeq ($(ARCH), x86)
609 ENABLE_X86_JIT = 1
610endif
611
612# What the X86 JIT requires
613ifdef ENABLE_X86_JIT
614 JIT_LIBS += LLVMX86 LLVMSelectionDAG
615endif
616
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000617# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
618# ENABLE_PPC_JIT on the make command line. If not, it will still be
619# enabled automagically on an PowerPC host.
620ifeq ($(ARCH), PowerPC)
621 ENABLE_PPC_JIT = 1
622endif
623
624# What the PowerPC JIT requires
625ifdef ENABLE_PPC_JIT
626 JIT_LIBS += LLVMPowerPC LLVMSelectionDAG
627endif
628
Andrew Lenharthddc31e82005-07-22 20:54:01 +0000629# You can enable the Alpha JIT on a non-Alpha host by setting the flag
630# ENABLE_ALPHA_JIT on the make command line. If not, it will still be
Misha Brukmanab25eda2005-07-22 22:43:40 +0000631# enabled automagically on an Alpha host.
Andrew Lenharthddc31e82005-07-22 20:54:01 +0000632ifeq ($(ARCH), Alpha)
633 ENABLE_ALPHA_JIT = 1
634endif
635
Andrew Lenharth22894e92005-07-22 22:00:24 +0000636# What the Alpha JIT requires
Andrew Lenharthddc31e82005-07-22 20:54:01 +0000637ifdef ENABLE_ALPHA_JIT
638 JIT_LIBS += LLVMAlpha LLVMSelectionDAG
639endif
640
John Criswella1156432005-10-27 15:54:34 +0000641LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts.a LLVMTransformUtils.a LLVMAnalysis.a \
Reid Spencer18c8b492006-06-01 01:30:27 +0000642 LLVMBCReader.a LLVMTarget.a LLVMCore.a LLVMSupport.a LLVMbzip2.a \
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000643 LLVMSystem.a $(PLATFORMLIBDL)
644endif
645
646#---------------------------------------------------------
647# Define various command line options pertaining to the
648# libraries needed when linking. There are "Proj" libs
649# (defined by the user's project) and "LLVM" libs (defined
650# by the # LLVM project).
651#---------------------------------------------------------
Andrew Lenharth7ac17522005-08-13 05:09:50 +0000652
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000653ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
654ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
655LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
656LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
657ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
658LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
659ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
660LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
661
662###############################################################################
Reid Spencer3a561f52004-10-23 20:04:14 +0000663# Library Build Rules: Four ways to build a library
664###############################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000665
Reid Spencer7980ea42004-12-05 05:17:22 +0000666#---------------------------------------------------------
667# Bytecode Module Targets:
668# If the user set MODULE_NAME then they want to build a
669# bytecode module from the sources. We compile all the
670# sources and link it together into a single bytecode
671# module.
672#---------------------------------------------------------
673
674ifdef MODULE_NAME
Reid Spencer9a8398e2005-02-14 21:54:08 +0000675ifeq ($(strip $(LLVMGCC)),)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000676$(warning Modules require llvm-gcc but no llvm-gcc is available ****)
Reid Spencer9a8398e2005-02-14 21:54:08 +0000677else
Reid Spencer7980ea42004-12-05 05:17:22 +0000678
679Module := $(LibDir)/$(MODULE_NAME).bc
Reid Spencerbbd5e432006-04-12 18:21:35 +0000680LinkModule := $(GCCLD) -L$(CFERuntimeLibDir)
681
Reid Spencer7980ea42004-12-05 05:17:22 +0000682
683ifdef EXPORTED_SYMBOL_FILE
Chris Lattner89681112006-01-27 22:13:12 +0000684LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer7980ea42004-12-05 05:17:22 +0000685endif
686
687$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000688 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
Reid Spencer7980ea42004-12-05 05:17:22 +0000689 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
690
691all-local:: $(Module)
692
693clean-local::
694ifneq ($(strip $(Module)),)
695 -$(Verb) $(RM) -f $(Module)
696endif
697
Reid Spencerab3690b2004-12-13 07:38:07 +0000698ifdef BYTECODE_DESTINATION
699ModuleDestDir := $(BYTECODE_DESTINATION)
700else
Reid Spencer11fde542005-01-16 02:20:54 +0000701ModuleDestDir := $(PROJ_libdir)
Reid Spencerab3690b2004-12-13 07:38:07 +0000702endif
Reid Spencer7980ea42004-12-05 05:17:22 +0000703
Reid Spencerab3690b2004-12-13 07:38:07 +0000704DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
705
706install-module:: $(DestModule)
Reid Spencer7980ea42004-12-05 05:17:22 +0000707install-local:: $(DestModule)
708
Reid Spencerab3690b2004-12-13 07:38:07 +0000709$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencer7980ea42004-12-05 05:17:22 +0000710 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
Reid Spencer151bbe42005-02-24 21:30:37 +0000711 $(Verb) $(DataInstall) $(Module) $(DestModule)
Reid Spencer7980ea42004-12-05 05:17:22 +0000712
713uninstall-local::
714 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
715 -$(Verb) $(RM) -f $(DestModule)
716
717endif
Reid Spencer9a8398e2005-02-14 21:54:08 +0000718endif
Brian Gaeke8abff792004-01-22 22:53:48 +0000719
Reid Spencer3a561f52004-10-23 20:04:14 +0000720# if we're building a library ...
Chris Lattner00950542001-06-06 20:29:01 +0000721ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000722
Chris Lattner2a548c52002-09-16 22:36:42 +0000723# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000724LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencer492c2932005-01-11 04:31:07 +0000725ifdef LOADABLE_MODULE
726LibName.LA := $(LibDir)/$(LIBRARYNAME).la
727else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000728LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
Reid Spencer492c2932005-01-11 04:31:07 +0000729endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000730LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
731LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer9a2f1372004-12-02 09:28:21 +0000732LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000733
Reid Spencer3a561f52004-10-23 20:04:14 +0000734#---------------------------------------------------------
735# Shared Library Targets:
736# If the user asked for a shared library to be built
737# with the SHARED_LIBRARY variable, then we provide
738# targets for building them.
739#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000740ifdef SHARED_LIBRARY
741
Reid Spencercc2d1e22004-10-30 09:19:36 +0000742all-local:: $(LibName.LA)
Reid Spencer4d71b662004-10-22 21:01:56 +0000743
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000744ifdef LINK_LIBS_IN_SHARED
745$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
746 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
747 $(Verb) $(Link) -o $@ $(ObjectsLO) \
748 $(ProjLibsOptions) $(LLVMLibsOptions)
749 $(Verb) $(LTInstall) $@ $(LibDir)
750else
Reid Spencerf2ac1892004-12-16 07:36:08 +0000751$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000752 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000753 $(Verb) $(Link) -o $@ $(ObjectsLO)
754 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000755endif
Reid Spencer3a561f52004-10-23 20:04:14 +0000756
757clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000758ifneq ($(strip $(LibName.LA)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000759 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000760endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000761
Reid Spencer11fde542005-01-16 02:20:54 +0000762DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencer4d71b662004-10-22 21:01:56 +0000763
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000764install-local:: $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000765
Reid Spencer11fde542005-01-16 02:20:54 +0000766$(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
Reid Spencer9af3b292004-11-01 07:50:27 +0000767 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000768 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
Reid Spencer11fde542005-01-16 02:20:54 +0000769 $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
Reid Spencere5487ba2004-10-24 07:53:21 +0000770
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000771uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000772 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencer11fde542005-01-16 02:20:54 +0000773 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
Reid Spencere5487ba2004-10-24 07:53:21 +0000774
Reid Spencer4d71b662004-10-22 21:01:56 +0000775endif
776
Reid Spencer3a561f52004-10-23 20:04:14 +0000777#---------------------------------------------------------
778# Bytecode Library Targets:
779# If the user asked for a bytecode library to be built
780# with the BYTECODE_LIBRARY variable, then we provide
781# targets for building them.
782#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000783ifdef BYTECODE_LIBRARY
Reid Spencer9a8398e2005-02-14 21:54:08 +0000784ifeq ($(strip $(LLVMGCC)),)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000785$(warning Bytecode libraries require llvm-gcc which could not be found ****)
Reid Spencer9a8398e2005-02-14 21:54:08 +0000786else
Reid Spencer4d71b662004-10-22 21:01:56 +0000787
Reid Spencer9a2f1372004-12-02 09:28:21 +0000788all-local:: $(LibName.BCA)
789
790ifdef EXPORTED_SYMBOL_FILE
Chris Lattner73faa392006-05-30 16:38:06 +0000791BCLinkLib = $(GCCLD) -L$(CFERuntimeLibDir) \
792 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000793
Reid Spencerf2ac1892004-12-16 07:36:08 +0000794$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
Chris Lattner264ccbe2004-12-15 17:14:06 +0000795 $(LLVMToolDir)/llvm-ar
Reid Spencer9a2f1372004-12-02 09:28:21 +0000796 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
797 "(internalize)"
Chris Lattnerb0ea8642004-12-02 21:23:43 +0000798 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencerefd6bb32004-12-13 03:59:35 +0000799 $(Verb) $(RM) -f $@
Reid Spencer9a2f1372004-12-02 09:28:21 +0000800 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencer4d71b662004-10-22 21:01:56 +0000801else
Reid Spencerf2ac1892004-12-16 07:36:08 +0000802$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
Chris Lattner264ccbe2004-12-15 17:14:06 +0000803 $(LLVMToolDir)/llvm-ar
Reid Spencer9a2f1372004-12-02 09:28:21 +0000804 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencerefd6bb32004-12-13 03:59:35 +0000805 $(Verb) $(RM) -f $@
Reid Spencer9a2f1372004-12-02 09:28:21 +0000806 $(Verb) $(LArchive) $@ $(ObjectsBC)
807
Reid Spencer4d71b662004-10-22 21:01:56 +0000808endif
809
Reid Spencer3a561f52004-10-23 20:04:14 +0000810clean-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000811ifneq ($(strip $(LibName.BCA)),)
812 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000813endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000814
Reid Spencer8f094f32004-12-13 07:28:21 +0000815ifdef BYTECODE_DESTINATION
816BytecodeDestDir := $(BYTECODE_DESTINATION)
817else
Reid Spencer11fde542005-01-16 02:20:54 +0000818BytecodeDestDir := $(PROJ_libdir)
Reid Spencer8f094f32004-12-13 07:28:21 +0000819endif
820
821DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
Reid Spencer9a2f1372004-12-02 09:28:21 +0000822
Reid Spencer44cb1b32004-12-03 20:08:48 +0000823install-bytecode-local:: $(DestBytecodeLib)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000824
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000825install-local:: $(DestBytecodeLib)
Chris Lattner481cc7c2003-08-15 02:18:35 +0000826
Reid Spencer8f094f32004-12-13 07:28:21 +0000827$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000828 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerb80621f2005-02-24 21:36:32 +0000829 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000830
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000831uninstall-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000832 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000833 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000834
835endif
Reid Spencer9a8398e2005-02-14 21:54:08 +0000836endif
Vikram S. Adve60f56062002-08-02 18:34:12 +0000837
Reid Spencercc2d1e22004-10-30 09:19:36 +0000838#---------------------------------------------------------
839# ReLinked Library Targets:
Chris Lattner89938082005-10-24 02:21:45 +0000840# If the user explicitly requests a relinked library with
841# BUILD_RELINKED, provide it. Otherwise, if they specify
842# neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
843# them one.
Reid Spencercc2d1e22004-10-30 09:19:36 +0000844#---------------------------------------------------------
Chris Lattner89938082005-10-24 02:21:45 +0000845ifndef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000846ifndef DONT_BUILD_RELINKED
Chris Lattner89938082005-10-24 02:21:45 +0000847BUILD_RELINKED = 1
848endif
849endif
850
851ifdef BUILD_RELINKED
Reid Spencer4d71b662004-10-22 21:01:56 +0000852
Reid Spencercc2d1e22004-10-30 09:19:36 +0000853all-local:: $(LibName.O)
854
Reid Spencerf2ac1892004-12-16 07:36:08 +0000855$(LibName.O): $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000856 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000857 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencer4d71b662004-10-22 21:01:56 +0000858
Reid Spencer3a561f52004-10-23 20:04:14 +0000859clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000860ifneq ($(strip $(LibName.O)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000861 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencere5487ba2004-10-24 07:53:21 +0000862endif
863
Reid Spencer11fde542005-01-16 02:20:54 +0000864DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
Reid Spencere5487ba2004-10-24 07:53:21 +0000865
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000866install-local:: $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000867
Reid Spencer11fde542005-01-16 02:20:54 +0000868$(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
Reid Spencer9af3b292004-11-01 07:50:27 +0000869 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000870 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000871
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000872uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000873 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000874 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000875
Chris Lattnere62dbe92002-07-23 17:56:16 +0000876endif
Chris Lattner760da062003-03-14 20:25:22 +0000877
Reid Spencercc2d1e22004-10-30 09:19:36 +0000878#---------------------------------------------------------
879# Archive Library Targets:
880# If the user wanted a regular archive library built,
881# then we provide targets for building them.
882#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000883ifdef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000884
Reid Spencercc2d1e22004-10-30 09:19:36 +0000885all-local:: $(LibName.A)
886
Reid Spencerf2ac1892004-12-16 07:36:08 +0000887$(LibName.A): $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000888 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000889 -$(Verb) $(RM) -f $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000890 $(Verb) $(Archive) $@ $(ObjectsO)
891 $(Verb) $(Ranlib) $@
Vikram S. Adve41e78912002-09-20 14:03:13 +0000892
Reid Spencer3a561f52004-10-23 20:04:14 +0000893clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000894ifneq ($(strip $(LibName.A)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000895 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner00950542001-06-06 20:29:01 +0000896endif
897
Reid Spencer11fde542005-01-16 02:20:54 +0000898DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
Reid Spencere5487ba2004-10-24 07:53:21 +0000899
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000900install-local:: $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000901
Reid Spencer11fde542005-01-16 02:20:54 +0000902$(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
Reid Spencer9af3b292004-11-01 07:50:27 +0000903 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencer11fde542005-01-16 02:20:54 +0000904 $(Verb) $(MKDIR) $(PROJ_libdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000905 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000906
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000907uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000908 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000909 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000910
911endif
912
913# endif LIBRARYNAME
Reid Spencer4d71b662004-10-22 21:01:56 +0000914endif
915
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000916###############################################################################
917# Tool Build Rules: Build executable tool based on TOOLNAME option
918###############################################################################
919
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000920ifdef TOOLNAME
921
Reid Spencercc2d1e22004-10-30 09:19:36 +0000922#---------------------------------------------------------
923# Set up variables for building a tool.
924#---------------------------------------------------------
Reid Spencer815cbcf2004-11-18 10:03:46 +0000925ifdef EXAMPLE_TOOL
Reid Spencer5da2d082005-05-19 21:03:11 +0000926ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000927else
Reid Spencer5da2d082005-05-19 21:03:11 +0000928ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000929endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000930
Reid Spencercc2d1e22004-10-30 09:19:36 +0000931#---------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000932# Tell make that we need to rebuild subdirectories before
933# we can link the tool. This affects things like LLI which
934# has library subdirectories.
935#---------------------------------------------------------
936$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000937
Reid Spencercc2d1e22004-10-30 09:19:36 +0000938#---------------------------------------------------------
939# Provide targets for building the tools
940#---------------------------------------------------------
941all-local:: $(ToolBuildPath)
John Criswell2a6530f2003-06-27 16:58:44 +0000942
Reid Spencer3a561f52004-10-23 20:04:14 +0000943clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000944ifneq ($(strip $(ToolBuildPath)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000945 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencere5487ba2004-10-24 07:53:21 +0000946endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000947
Reid Spencer815cbcf2004-11-18 10:03:46 +0000948ifdef EXAMPLE_TOOL
949$(ToolBuildPath): $(ExmplDir)/.dir
950else
951$(ToolBuildPath): $(ToolDir)/.dir
952endif
953
Reid Spencerf2ac1892004-12-16 07:36:08 +0000954$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencer9af3b292004-11-01 07:50:27 +0000955 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencerab519972006-05-16 06:25:14 +0000956 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
957 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
Chris Lattnerd25ad612006-02-14 04:25:54 +0000958 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
959 $(StripWarnMsg)
Reid Spencere5487ba2004-10-24 07:53:21 +0000960
Reid Spencer11fde542005-01-16 02:20:54 +0000961DestTool = $(PROJ_bindir)/$(TOOLNAME)
Reid Spencere5487ba2004-10-24 07:53:21 +0000962
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000963install-local:: $(DestTool)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000964
Reid Spencer11fde542005-01-16 02:20:54 +0000965$(DestTool): $(PROJ_bindir) $(ToolBuildPath)
Reid Spencer9af3b292004-11-01 07:50:27 +0000966 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencer4a0aaea2005-02-24 03:56:32 +0000967 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000968
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000969uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000970 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000971 -$(Verb) $(RM) -f $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000972
Reid Spencer4d71b662004-10-22 21:01:56 +0000973endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000974
Reid Spencercc2d1e22004-10-30 09:19:36 +0000975###############################################################################
976# Object Build Rules: Build object files based on sources
977###############################################################################
978
Duraid Madina197ab872006-02-15 03:23:26 +0000979# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
980ifeq ($(OS),HP-UX)
981 DISABLE_AUTO_DEPENDENCIES=1
982endif
983
Reid Spencercc2d1e22004-10-30 09:19:36 +0000984# Provide rule sets for when dependency generation is enabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000985ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve41e78912002-09-20 14:03:13 +0000986
Reid Spencercc2d1e22004-10-30 09:19:36 +0000987#---------------------------------------------------------
988# Create .lo files in the ObjDir directory from the .cpp and .c files...
989#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000990ifdef SHARED_LIBRARY
991
Chris Lattner3c473472004-12-16 17:28:50 +0000992$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +0000993 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Chris Lattner77efe272006-02-14 04:27:15 +0000994 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
Reid Spencercc2d1e22004-10-30 09:19:36 +0000995 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
996 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000997
Chris Lattnerb05a76c2005-02-04 21:28:50 +0000998$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
999 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
Chris Lattner77efe272006-02-14 04:27:15 +00001000 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001001 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
1002 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
1003
Chris Lattner3c473472004-12-16 17:28:50 +00001004$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001005 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001006 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
1007 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
1008 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +00001009
Reid Spencercc2d1e22004-10-30 09:19:36 +00001010#---------------------------------------------------------
1011# Create .o files in the ObjDir directory from the .cpp and .c files...
1012#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001013else
Reid Spencer4d71b662004-10-22 21:01:56 +00001014
Chris Lattner3c473472004-12-16 17:28:50 +00001015$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001016 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001017 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
1018 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
1019 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +00001020
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001021$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1022 $(Echo) "Compiling $*.cc for $(BuildMode) build"
1023 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
1024 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
1025 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
1026
Chris Lattner3c473472004-12-16 17:28:50 +00001027$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001028 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001029 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
1030 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
1031 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +00001032
1033endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001034
Chris Lattner0cb09f12005-10-05 00:28:41 +00001035## Rules for building preprocessed (.i/.ii) outputs.
1036$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1037 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1038 $(Verb) $(Preprocess.CXX) $< -o $@
1039
1040$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1041 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1042 $(Verb) $(Preprocess.CXX) $< -o $@
1043
1044 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1045 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1046 $(Verb) $(Preprocess.C) $< -o $@
1047
1048
Reid Spencercc2d1e22004-10-30 09:19:36 +00001049#---------------------------------------------------------
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001050# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
Reid Spencercc2d1e22004-10-30 09:19:36 +00001051#---------------------------------------------------------
Chris Lattner89681112006-01-27 22:13:12 +00001052
1053$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001054 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattnerd25ad612006-02-14 04:25:54 +00001055 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1056 $< -o $@ -S -emit-llvm ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001057 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1058 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +00001059
Chris Lattner89681112006-01-27 22:13:12 +00001060$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001061 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattnerd25ad612006-02-14 04:25:54 +00001062 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1063 $< -o $@ -S -emit-llvm ; \
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001064 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1065 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1066
Chris Lattner89681112006-01-27 22:13:12 +00001067$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001068 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattnerd25ad612006-02-14 04:25:54 +00001069 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" \
1070 $< -o $@ -S -emit-llvm ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001071 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1072 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +00001073
Reid Spencercc2d1e22004-10-30 09:19:36 +00001074# Provide alternate rule sets if dependencies are disabled
Reid Spencer4d71b662004-10-22 21:01:56 +00001075else
1076
Reid Spencer3a561f52004-10-23 20:04:14 +00001077ifdef SHARED_LIBRARY
1078
Chris Lattner3c473472004-12-16 17:28:50 +00001079$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001080 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +00001081 $(LTCompile.CXX) $< -o $@
1082
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001083$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1084 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
1085 $(LTCompile.CXX) $< -o $@
1086
Chris Lattner3c473472004-12-16 17:28:50 +00001087$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerc3719842004-12-16 18:26:53 +00001088 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +00001089 $(LTCompile.C) $< -o $@
1090
1091else
Reid Spencer4d71b662004-10-22 21:01:56 +00001092
Chris Lattner3c473472004-12-16 17:28:50 +00001093$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001094 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +00001095 $(Compile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +00001096
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001097$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1098 $(Echo) "Compiling $*.cc for $(BuildMode) build"
1099 $(Compile.CXX) $< -o $@
1100
Chris Lattner3c473472004-12-16 17:28:50 +00001101$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerc3719842004-12-16 18:26:53 +00001102 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +00001103 $(Compile.C) $< -o $@
1104endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001105
Chris Lattner89681112006-01-27 22:13:12 +00001106$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001107 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001108 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Reid Spencer4d71b662004-10-22 21:01:56 +00001109
Chris Lattner89681112006-01-27 22:13:12 +00001110$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001111 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001112 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001113
Chris Lattner89681112006-01-27 22:13:12 +00001114$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001115 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001116 $(BCCompile.C) $< -o $@ -S -emit-llvm
Brian Gaeke44909cf2003-12-10 00:26:28 +00001117
Chris Lattner1cbc29f2001-09-07 22:57:58 +00001118endif
1119
Chris Lattner89681112006-01-27 22:13:12 +00001120# make the C and C++ compilers strip debug info out of bytecode libraries.
1121ifdef DEBUG_RUNTIME
1122$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1123 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Chris Lattnerc0977982006-03-09 06:00:05 +00001124 $(Verb) $(GCCAS) $< -o $@
Chris Lattner89681112006-01-27 22:13:12 +00001125else
1126$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1127 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Chris Lattnerc0977982006-03-09 06:00:05 +00001128 $(Verb) $(GCCAS) -strip-debug $< -o $@
Chris Lattner89681112006-01-27 22:13:12 +00001129endif
1130
1131
Reid Spencercc2d1e22004-10-30 09:19:36 +00001132#---------------------------------------------------------
1133# Provide rule to build .bc files from .ll sources,
1134# regardless of dependencies
1135#---------------------------------------------------------
1136$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencer9af3b292004-11-01 07:50:27 +00001137 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001138 $(Verb) $(LLVMAS) $< -f -o $@
1139
1140###############################################################################
1141# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1142###############################################################################
Chris Lattner481cc7c2003-08-15 02:18:35 +00001143
Reid Spencer4d71b662004-10-22 21:01:56 +00001144ifdef TARGET
1145
Chris Lattnerd25ad612006-02-14 04:25:54 +00001146TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1147 $(LLVM_SRC_ROOT)/lib/Target/Target.td \
Chris Lattnercb3fc532006-03-03 01:54:54 +00001148 $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td \
1149 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001150INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Chris Lattner3c473472004-12-16 17:28:50 +00001151INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1152.PRECIOUS: $(INCTMPFiles) $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001153
Chris Lattner3c473472004-12-16 17:28:50 +00001154# All of these files depend on tblgen and the .td files.
1155$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001156
Chris Lattner23ee7952004-12-16 17:38:56 +00001157# INCFiles rule: All of the tblgen generated files are emitted to
1158# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1159# us to only "touch" the real file if the contents of it change. IOW, if
1160# tblgen is modified, all of the .inc.tmp files are regereated, but no
1161# dependencies of the .inc files are, unless the contents of the .inc file
1162# changes.
1163$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
Reid Spencerc3719842004-12-16 18:26:53 +00001164 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
Chris Lattner3c473472004-12-16 17:28:50 +00001165
1166$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1167$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001168 $(Echo) "Building $(<F) register names with tblgen"
1169 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001170
Chris Lattner3c473472004-12-16 17:28:50 +00001171$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1172$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001173 $(Echo) "Building $(<F) register information header with tblgen"
1174 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001175
Chris Lattner3c473472004-12-16 17:28:50 +00001176$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1177$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001178 $(Echo) "Building $(<F) register info implementation with tblgen"
1179 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001180
Chris Lattner3c473472004-12-16 17:28:50 +00001181$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1182$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001183 $(Echo) "Building $(<F) instruction names with tblgen"
1184 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001185
Chris Lattner3c473472004-12-16 17:28:50 +00001186$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1187$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001188 $(Echo) "Building $(<F) instruction information with tblgen"
1189 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001190
Chris Lattner3c473472004-12-16 17:28:50 +00001191$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1192$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001193 $(Echo) "Building $(<F) assembly writer with tblgen"
1194 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001195
Chris Lattner02a4f902004-12-16 17:34:04 +00001196$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1197$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1198 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001199 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001200
Chris Lattner3c473472004-12-16 17:28:50 +00001201$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1202$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001203 $(Echo) "Building $(<F) code emitter with tblgen"
1204 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001205
Chris Lattnerf31f09e2005-09-03 01:15:25 +00001206$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1207$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1208 $(Echo) "Building $(<F) instruction selector implementation with tblgen"
1209 $(Verb) $(TableGen) -gen-dag-isel -o $@ $<
1210
Jim Laskeyf5fc2cb2005-10-21 19:05:19 +00001211$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1212$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1213 $(Echo) "Building $(<F) subtarget information with tblgen"
1214 $(Verb) $(TableGen) -gen-subtarget -o $@ $<
Chris Lattnerf31f09e2005-09-03 01:15:25 +00001215
Reid Spencer3a561f52004-10-23 20:04:14 +00001216clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001217 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001218
1219endif
Chris Lattner481cc7c2003-08-15 02:18:35 +00001220
Reid Spencercc2d1e22004-10-30 09:19:36 +00001221###############################################################################
1222# LEX AND YACC: Provide rules for generating sources with lex and yacc
1223###############################################################################
Chris Lattnere8996782003-01-16 22:44:19 +00001224
Reid Spencercc2d1e22004-10-30 09:19:36 +00001225#---------------------------------------------------------
1226# Provide rules for generating a .cpp source file from
1227# (f)lex input sources.
1228#---------------------------------------------------------
1229
Reid Spencer3d659492004-11-02 16:36:03 +00001230LexFiles := $(filter %.l,$(Sources))
Reid Spencercc2d1e22004-10-30 09:19:36 +00001231
Reid Spencer3d659492004-11-02 16:36:03 +00001232ifneq ($(LexFiles),)
1233
Reid Spencer68a24bd2005-08-27 18:50:39 +00001234# Cancel built-in rules for lex
1235%.c: %.l
1236%.cpp: %.l
Reid Spencercc2d1e22004-10-30 09:19:36 +00001237
Chris Lattner342567c2006-02-14 05:12:00 +00001238all:: $(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs)
1239
Reid Spencercc2d1e22004-10-30 09:19:36 +00001240# Note the extra sed filtering here, used to cut down on the warnings emited
1241# by GCC. The last line is a gross hack to work around flex aparently not
1242# being able to resize the buffer on a large token input. Currently, for
1243# uninitialized string buffers in LLVM we can generate very long tokens, so
1244# this is a hack around it.
Chris Lattnerb7dc2b92003-08-15 20:00:47 +00001245# FIXME. (f.e. char Buffer[10000] )
Reid Spencer68a24bd2005-08-27 18:50:39 +00001246$(PROJ_SRC_DIR)/%.cpp: $(PROJ_SRC_DIR)/%.l
Reid Spencerc2ef8cd2004-12-10 19:44:16 +00001247 $(Echo) Flexing $*.l
Reid Spencer68a24bd2005-08-27 18:50:39 +00001248 $(Verb) $(FLEX) -t $(PROJ_SRC_DIR)/$*.l | \
Reid Spencer4d71b662004-10-22 21:01:56 +00001249 $(SED) 's/void yyunput/inline void yyunput/' | \
1250 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1251 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001252 > $(PROJ_SRC_DIR)/$*.cpp
Chris Lattner342567c2006-02-14 05:12:00 +00001253
1254# IFF the .l file has changed since it was last checked into CVS, copy the .l
1255# file to .l.cvs and the generated .cpp file to .cpp.cvs. We use this mechanism
1256# so that people without flex can build LLVM by copying the .cvs files to the
1257# source location and building them.
1258$(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1259$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattneraf2f3512006-02-16 05:10:48 +00001260 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs || \
Chris Lattner342567c2006-02-14 05:12:00 +00001261 ($(CP) $< $@; $(CP) $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001262
Chris Lattner342567c2006-02-14 05:12:00 +00001263$(LexFiles:%.l=$(ObjDir)/%.o) : \
1264$(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
Chris Lattner00950542001-06-06 20:29:01 +00001265
Reid Spencer9af3b292004-11-01 07:50:27 +00001266clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001267 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencer9af3b292004-11-01 07:50:27 +00001268
Reid Spencercc2d1e22004-10-30 09:19:36 +00001269endif
1270
1271#---------------------------------------------------------
1272# Provide rules for generating a .cpp and .h source files
1273# from yacc (bison) input sources.
1274#---------------------------------------------------------
1275
Reid Spencer3d659492004-11-02 16:36:03 +00001276YaccFiles := $(filter %.y,$(Sources))
1277ifneq ($(YaccFiles),)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001278
1279.PRECIOUS: $(YaccOutput)
1280
Chris Lattner1f1edce2006-02-15 07:23:05 +00001281all:: $(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs)
Chris Lattner6599c752006-02-15 07:16:57 +00001282
Reid Spencercc2d1e22004-10-30 09:19:36 +00001283# Cancel built-in rules for yacc
1284%.c: %.y
1285%.cpp: %.y
1286%.h: %.y
1287
Reid Spencer25e8a702005-12-21 23:17:06 +00001288# Rule for building the bison based parsers...
Reid Spencer68a24bd2005-08-27 18:50:39 +00001289$(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
Reid Spencercc2d1e22004-10-30 09:19:36 +00001290 $(Echo) "Bisoning $*.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001291 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1292 $(Verb) $(MV) -f $*.tab.c $(PROJ_SRC_DIR)/$*.cpp
1293 $(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
Chris Lattner00950542001-06-06 20:29:01 +00001294
Chris Lattner6599c752006-02-15 07:16:57 +00001295# IFF the .y file has changed since it was last checked into CVS, copy the .y
1296# file to .y.cvs and the generated .cpp/.h file to .cpp.cvs/.h.cvs. We use this
1297# mechanism so that people without flex can build LLVM by copying the .cvs files
1298# to the source location and building them.
1299$(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1300$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattneraf2f3512006-02-16 05:10:48 +00001301 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs || \
Chris Lattner6599c752006-02-15 07:16:57 +00001302 ($(CP) $< $@; \
Chris Lattner1f1edce2006-02-15 07:23:05 +00001303 $(CP) $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs; \
Chris Lattner6599c752006-02-15 07:16:57 +00001304 $(CP) $(PROJ_SRC_DIR)/$*.h $(PROJ_SRC_DIR)/$*.h.cvs)
Reid Spencer25e8a702005-12-21 23:17:06 +00001305
Chris Lattner6599c752006-02-15 07:16:57 +00001306
1307$(YaccFiles:%.y=$(ObjDir)/%.o): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
1308
1309YaccOutput := $(YaccFiles:%.y=%.output)
Reid Spencer25e8a702005-12-21 23:17:06 +00001310
Reid Spencer9af3b292004-11-01 07:50:27 +00001311clean-local::
Reid Spencer25e8a702005-12-21 23:17:06 +00001312 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001313endif
Chris Lattner00950542001-06-06 20:29:01 +00001314
Reid Spencercc2d1e22004-10-30 09:19:36 +00001315###############################################################################
1316# OTHER RULES: Other rules needed
1317###############################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +00001318
Chris Lattner30440c62003-01-16 21:06:18 +00001319# To create postscript files from dot files...
John Criswelle0f9ac62003-10-02 19:02:02 +00001320ifneq ($(DOT),false)
Chris Lattner30440c62003-01-16 21:06:18 +00001321%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +00001322 $(DOT) -Tps < $< > $@
John Criswell7a73b802003-06-30 21:59:07 +00001323else
1324%.ps: %.dot
Reid Spencercc2d1e22004-10-30 09:19:36 +00001325 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell7a73b802003-06-30 21:59:07 +00001326endif
Chris Lattner30440c62003-01-16 21:06:18 +00001327
John Criswell7f336952003-09-06 14:44:17 +00001328# This rules ensures that header files that are removed still have a rule for
1329# which they can be "generated." This allows make to ignore them and
1330# reproduce the dependency lists.
John Criswell4b6e5d12003-09-18 18:37:08 +00001331%.h:: ;
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001332%.hpp:: ;
John Criswell7f336952003-09-06 14:44:17 +00001333
Reid Spencercc2d1e22004-10-30 09:19:36 +00001334# Define clean-local to clean the current directory. Note that this uses a
1335# very conservative approach ensuring that empty variables do not cause
1336# errors or disastrous removal.
Reid Spencer3a561f52004-10-23 20:04:14 +00001337clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001338ifneq ($(strip $(ObjDir)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001339 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencere5487ba2004-10-24 07:53:21 +00001340endif
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001341 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001342ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001343 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001344endif
John Criswell7a73b802003-06-30 21:59:07 +00001345
Reid Spencer3d659492004-11-02 16:36:03 +00001346clean-all-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001347 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer3d659492004-11-02 16:36:03 +00001348
Reid Spencercc2d1e22004-10-30 09:19:36 +00001349# Build tags database for Emacs/Xemacs:
Reid Spencer12d79512004-11-12 02:27:36 +00001350tags:: TAGS CTAGS
1351
Reid Spencercc2d1e22004-10-30 09:19:36 +00001352TAGS:
Reid Spencer11fde542005-01-16 02:20:54 +00001353 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1354 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1355 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1356 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spencer12d79512004-11-12 02:27:36 +00001357 -name '*.cpp' -o -name '*.h' | \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001358 $(ETAGS) $(ETAGSFLAGS) -
1359
Reid Spencer12d79512004-11-12 02:27:36 +00001360CTAGS:
Reid Spencer11fde542005-01-16 02:20:54 +00001361 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1362 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1363 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1364 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spencer12d79512004-11-12 02:27:36 +00001365 \( -name '*.cpp' -o -name '*.h' \) -print | \
Reid Spencer11fde542005-01-16 02:20:54 +00001366 ctags -ImtT -o $(PROJ_OBJ_ROOT)/CTAGS -L -
Reid Spencer12d79512004-11-12 02:27:36 +00001367
1368
Reid Spencer3a561f52004-10-23 20:04:14 +00001369###############################################################################
1370# DEPENDENCIES: Include the dependency files if we should
1371###############################################################################
Chris Lattner33ad24a2003-08-22 14:10:16 +00001372ifndef DISABLE_AUTO_DEPENDENCIES
1373
Reid Spencer3a561f52004-10-23 20:04:14 +00001374# If its not one of the cleaning targets
Reid Spencercc2d1e22004-10-30 09:19:36 +00001375ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencer4d71b662004-10-22 21:01:56 +00001376
Reid Spencer3a561f52004-10-23 20:04:14 +00001377# Get the list of dependency files
Reid Spencercc2d1e22004-10-30 09:19:36 +00001378DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Chris Lattner342567c2006-02-14 05:12:00 +00001379DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
Misha Brukman4f7a8cf2003-11-09 21:36:19 +00001380
Reid Spencer3a561f52004-10-23 20:04:14 +00001381-include /dev/null $(DependFiles)
1382
John Criswelld741bcf2003-08-12 18:51:51 +00001383endif
Chris Lattner1ddb6b62003-08-18 17:27:40 +00001384
Reid Spencercc2d1e22004-10-30 09:19:36 +00001385endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001386
Reid Spencer151f8ba2004-10-25 08:27:37 +00001387###############################################################################
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001388# CHECK: Running the test suite
1389###############################################################################
1390
1391check::
Reid Spencer11fde542005-01-16 02:20:54 +00001392 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1393 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001394 $(EchoCmd) Running test suite ; \
Reid Spencer11fde542005-01-16 02:20:54 +00001395 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001396 TESTSUITE=$(TESTSUITE) ; \
1397 else \
1398 $(EchoCmd) No Makefile in test directory ; \
1399 fi ; \
1400 else \
1401 $(EchoCmd) No test directory ; \
1402 fi
1403
1404###############################################################################
Reid Spencercc2d1e22004-10-30 09:19:36 +00001405# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer151f8ba2004-10-25 08:27:37 +00001406###############################################################################
1407
Reid Spencere45ebfa2004-10-26 07:09:33 +00001408#------------------------------------------------------------------------
1409# Define distribution related variables
1410#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +00001411DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1412DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1413TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1414DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1415DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1416DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
Reid Spencer151f8ba2004-10-25 08:27:37 +00001417DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1418 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001419 Makefile.config.in configure autoconf
1420DistOther := $(notdir $(wildcard \
Reid Spencer11fde542005-01-16 02:20:54 +00001421 $(PROJ_SRC_DIR)/*.h \
1422 $(PROJ_SRC_DIR)/*.td \
1423 $(PROJ_SRC_DIR)/*.def \
1424 $(PROJ_SRC_DIR)/*.ll \
1425 $(PROJ_SRC_DIR)/*.in))
Reid Spencercc2d1e22004-10-30 09:19:36 +00001426DistSubDirs := $(SubDirs)
Reid Spencerfbbf3072004-11-29 05:00:33 +00001427DistSources = $(Sources) $(EXTRA_DIST)
1428DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer151f8ba2004-10-25 08:27:37 +00001429
Reid Spencere45ebfa2004-10-26 07:09:33 +00001430#------------------------------------------------------------------------
1431# We MUST build distribution with OBJ_DIR != SRC_DIR
1432#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +00001433ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
Reid Spencere45ebfa2004-10-26 07:09:33 +00001434dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001435 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencere45ebfa2004-10-26 07:09:33 +00001436
Reid Spencere45ebfa2004-10-26 07:09:33 +00001437else
1438
Reid Spencere45ebfa2004-10-26 07:09:33 +00001439#------------------------------------------------------------------------
Reid Spencere45ebfa2004-10-26 07:09:33 +00001440# Prevent attempt to run dist targets from anywhere but the top level
1441#------------------------------------------------------------------------
1442ifneq ($(LEVEL),.)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001443dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencer11fde542005-01-16 02:20:54 +00001444 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001445else
1446
1447#------------------------------------------------------------------------
1448# Provide the top level targets
1449#------------------------------------------------------------------------
1450
Reid Spencercc2d1e22004-10-30 09:19:36 +00001451dist-gzip:: $(DistTarGZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001452
Reid Spencer345235ca2004-12-04 22:34:09 +00001453$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001454 $(Echo) Packing gzipped distribution tar file.
Reid Spencer11fde542005-01-16 02:20:54 +00001455 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
Reid Spencerfbbf3072004-11-29 05:00:33 +00001456 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencere45ebfa2004-10-26 07:09:33 +00001457
Reid Spencercc2d1e22004-10-30 09:19:36 +00001458dist-bzip2:: $(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001459
Reid Spencer345235ca2004-12-04 22:34:09 +00001460$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001461 $(Echo) Packing bzipped distribution tar file.
Reid Spencer11fde542005-01-16 02:20:54 +00001462 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
Reid Spencerfbbf3072004-11-29 05:00:33 +00001463 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001464
Reid Spencercc2d1e22004-10-30 09:19:36 +00001465dist-zip:: $(DistZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001466
Reid Spencer345235ca2004-12-04 22:34:09 +00001467$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001468 $(Echo) Packing zipped distribution file.
1469 $(Verb) rm -f $(DistZip)
Reid Spencer11fde542005-01-16 02:20:54 +00001470 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001471
1472dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001473 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001474
Reid Spencerf8f57402005-01-28 19:52:32 +00001475DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
Reid Spencere45ebfa2004-10-26 07:09:33 +00001476
Reid Spencer345235ca2004-12-04 22:34:09 +00001477dist-check:: $(DistTarGZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001478 $(Echo) Checking distribution tar file.
1479 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001480 $(RM) -rf $(DistCheckDir) ; \
1481 fi
Reid Spencercc2d1e22004-10-30 09:19:36 +00001482 $(Verb) $(MKDIR) $(DistCheckDir)
1483 $(Verb) cd $(DistCheckDir) && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001484 $(MKDIR) $(DistCheckDir)/build && \
1485 $(MKDIR) $(DistCheckDir)/install && \
1486 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1487 cd build && \
1488 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
Reid Spencer45eeed92005-05-24 02:33:20 +00001489 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
Reid Spencer345235ca2004-12-04 22:34:09 +00001490 $(MAKE) all && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001491 $(MAKE) check && \
1492 $(MAKE) install && \
1493 $(MAKE) uninstall && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001494 $(MAKE) dist-clean && \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001495 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001496
1497dist-clean::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001498 $(Echo) Cleaning distribution files
Reid Spencer345235ca2004-12-04 22:34:09 +00001499 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1500 $(DistCheckDir)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001501
1502endif
1503
1504#------------------------------------------------------------------------
1505# Provide the recursive distdir target for building the distribution directory
1506#------------------------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +00001507distdir: $(DistDir)/.makedistdir
1508$(DistDir)/.makedistdir: $(DistSources)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001509 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001510 if test -d "$(DistDir)" ; then \
1511 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1512 exit 1 ; \
1513 fi ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001514 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001515 $(RM) -rf $(DistDir); \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001516 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer854071c2006-04-10 16:46:04 +00001517 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001518 fi
Reid Spencerfbbf3072004-11-29 05:00:33 +00001519 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001520 $(Verb) $(MKDIR) $(DistDir)
Reid Spencer11fde542005-01-16 02:20:54 +00001521 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1522 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001523 for file in $(DistFiles) ; do \
1524 case "$$file" in \
Reid Spencer11fde542005-01-16 02:20:54 +00001525 $(PROJ_SRC_DIR)/*) \
Reid Spencer345235ca2004-12-04 22:34:09 +00001526 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1527 ;; \
Reid Spencer11fde542005-01-16 02:20:54 +00001528 $(PROJ_SRC_ROOT)/*) \
Reid Spencer345235ca2004-12-04 22:34:09 +00001529 file=`echo "$$file" | \
1530 sed "s#^$$srcrootstrip/##"` \
1531 ;; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001532 esac; \
Reid Spencer11fde542005-01-16 02:20:54 +00001533 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1534 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1535 from_dir="$(PROJ_SRC_DIR)" ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001536 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001537 from_dir=. ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001538 fi ; \
1539 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001540 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1541 to_dir="$(DistDir)/$$dir"; \
1542 $(MKDIR) "$$to_dir" ; \
1543 else \
1544 to_dir="$(DistDir)"; \
1545 fi; \
1546 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1547 if test -n "$$mid_dir" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001548 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001549 fi ; \
1550 if test -d "$$from_dir/$$file"; then \
Reid Spencer11fde542005-01-16 02:20:54 +00001551 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1552 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
Reid Spencer45eeed92005-05-24 02:33:20 +00001553 cd $(PROJ_SRC_DIR) ; \
1554 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1555 ( cd $$to_dir ; $(TAR) xf - ) ; \
1556 cd $(PROJ_OBJ_DIR) ; \
1557 else \
1558 cd $$from_dir ; \
1559 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1560 ( cd $$to_dir ; $(TAR) xf - ) ; \
1561 cd $(PROJ_OBJ_DIR) ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001562 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001563 elif test -f "$$from_dir/$$file" ; then \
Reid Spencerc3719842004-12-16 18:26:53 +00001564 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001565 elif test -L "$$from_dir/$$file" ; then \
Reid Spencerc3719842004-12-16 18:26:53 +00001566 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001567 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer345235ca2004-12-04 22:34:09 +00001568 $(EchoCmd) "===== WARNING: Distribution Source " \
1569 "$$from_dir/$$file Not Found!" ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001570 elif test "$(Verb)" != '@' ; then \
1571 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001572 fi; \
1573 done
Reid Spencercc2d1e22004-10-30 09:19:36 +00001574 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001575 if test "$$subdir" \!= "." ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001576 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001577 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer854071c2006-04-10 16:46:04 +00001578 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
Reid Spencerbac3ca22006-04-07 16:06:18 +00001579 DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001580 fi; \
1581 done
Reid Spencer345235ca2004-12-04 22:34:09 +00001582 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer45eeed92005-05-24 02:33:20 +00001583 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
Chris Lattner77efe272006-02-14 04:27:15 +00001584 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1585 -name .svn \) -print` ;\
Reid Spencer345235ca2004-12-04 22:34:09 +00001586 $(MAKE) dist-hook ; \
1587 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1588 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1589 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1590 -o ! -type d ! -perm -444 -exec \
1591 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1592 || chmod -R a+r $(DistDir) ; \
1593 fi
Reid Spencer151f8ba2004-10-25 08:27:37 +00001594
Reid Spencercc2d1e22004-10-30 09:19:36 +00001595# This is invoked by distdir target, define it as a no-op to avoid errors if not
1596# defined by user.
Reid Spencer151f8ba2004-10-25 08:27:37 +00001597dist-hook::
1598
Reid Spencere53e3972004-10-22 23:06:30 +00001599endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001600
1601###############################################################################
Reid Spencere5487ba2004-10-24 07:53:21 +00001602# TOP LEVEL - targets only to apply at the top level directory
1603###############################################################################
1604
1605ifeq ($(LEVEL),.)
1606
1607#------------------------------------------------------------------------
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001608# Install support for the project's include files:
Reid Spencere5487ba2004-10-24 07:53:21 +00001609#------------------------------------------------------------------------
1610install-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001611 $(Echo) Installing include files
Reid Spencer11fde542005-01-16 02:20:54 +00001612 $(Verb) $(MKDIR) $(PROJ_includedir)
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001613 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
Reid Spencer11fde542005-01-16 02:20:54 +00001614 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer2edabc02005-02-16 15:54:03 +00001615 for hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
1616 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS ` ; do \
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001617 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1618 if test \! -d "$$instdir" ; then \
1619 $(EchoCmd) Making install directory $$instdir ; \
1620 $(MKDIR) $$instdir ;\
1621 fi ; \
1622 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer2edabc02005-02-16 15:54:03 +00001623 done ; \
Reid Spencere5487ba2004-10-24 07:53:21 +00001624 fi
Reid Spencer443045a2005-12-23 22:27:56 +00001625ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001626 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
Reid Spencer2edabc02005-02-16 15:54:03 +00001627 cd $(PROJ_OBJ_ROOT)/include && \
Reid Spencer443045a2005-12-23 22:27:56 +00001628 for hdr in `find . -type f -print | grep -v CVS` ; do \
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001629 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer2edabc02005-02-16 15:54:03 +00001630 done ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001631 fi
Reid Spencer443045a2005-12-23 22:27:56 +00001632endif
Reid Spencere5487ba2004-10-24 07:53:21 +00001633
1634uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001635 $(Echo) Uninstalling include files
Reid Spencer11fde542005-01-16 02:20:54 +00001636 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1637 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencere5487ba2004-10-24 07:53:21 +00001638 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
Chris Lattnerd25ad612006-02-14 04:25:54 +00001639 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' \
1640 -o -name '*.in' ')' -print ')' | \
1641 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001642 cd $(PROJ_SRC_ROOT)/include && \
Chris Lattnerd25ad612006-02-14 04:25:54 +00001643 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1644 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001645 fi
Reid Spencere5487ba2004-10-24 07:53:21 +00001646
Reid Spencere5487ba2004-10-24 07:53:21 +00001647endif
1648
Reid Spencer4d71b662004-10-22 21:01:56 +00001649#------------------------------------------------------------------------
1650# Print out the directories used for building
Reid Spencercc2d1e22004-10-30 09:19:36 +00001651#------------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001652printvars::
Reid Spencer11fde542005-01-16 02:20:54 +00001653 $(Echo) "BuildMode : " '$(BuildMode)'
1654 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1655 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1656 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1657 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1658 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1659 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1660 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1661 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1662 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1663 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
Reid Spencer1a9a69c2005-02-16 16:13:02 +00001664 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
Reid Spencer11fde542005-01-16 02:20:54 +00001665 $(Echo) "UserTargets : " '$(UserTargets)'
1666 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1667 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1668 $(Echo) "ObjDir : " '$(ObjDir)'
1669 $(Echo) "LibDir : " '$(LibDir)'
1670 $(Echo) "ToolDir : " '$(ToolDir)'
1671 $(Echo) "ExmplDir : " '$(ExmplDir)'
1672 $(Echo) "Sources : " '$(Sources)'
1673 $(Echo) "TDFiles : " '$(TDFiles)'
1674 $(Echo) "INCFiles : " '$(INCFiles)'
1675 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
Reid Spencere0acb762005-03-01 16:27:06 +00001676 $(Echo) "PreConditions: " '$(PreConditions)'
Reid Spencer11fde542005-01-16 02:20:54 +00001677 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1678 $(Echo) "Compile.C : " '$(Compile.C)'
1679 $(Echo) "Archive : " '$(Archive)'
1680 $(Echo) "YaccFiles : " '$(YaccFiles)'
1681 $(Echo) "LexFiles : " '$(LexFiles)'
1682 $(Echo) "Module : " '$(Module)'
Reid Spencer755bcf02005-08-24 10:43:10 +00001683 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
Reid Spencerf9f431c2006-04-09 23:41:14 +00001684 $(Echo) "SubDirs : " '$(SubDirs)'