blob: 115100ef2a95964cb53c4b9d5d5d061b13d44397 [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 Lattner760da062003-03-14 20:25:22 +0000201ifdef ENABLE_PROFILING
Reid Spencer9af3b292004-11-01 07:50:27 +0000202 BuildMode := Profile
Chris Lattner71927862006-03-21 01:06:41 +0000203 CXX.Flags := -O3 -felide-constructors -finline-functions -pg
204 C.Flags := -O3 -pg
205 LD.Flags := -O3 -pg
Chris Lattner760da062003-03-14 20:25:22 +0000206else
207 ifdef ENABLE_OPTIMIZED
Reid Spencer9af3b292004-11-01 07:50:27 +0000208 BuildMode := Release
Reid Spencer325a87e2005-01-02 17:43:20 +0000209 # Don't use -fomit-frame-pointer on FreeBSD
210 ifneq ($(OS),FreeBSD)
211 OmitFramePointer := -fomit-frame-pointer
212 endif
Chris Lattner71927862006-03-21 01:06:41 +0000213 CXX.Flags := -O3 -finline-functions -felide-constructors $(OmitFramePointer)
214 C.Flags := -O3 $(OmitFramePointer)
215 LD.Flags := -O3
Chris Lattner760da062003-03-14 20:25:22 +0000216 else
Reid Spencer9af3b292004-11-01 07:50:27 +0000217 BuildMode := Debug
Chris Lattner71927862006-03-21 01:06:41 +0000218 CXX.Flags := -g
219 C.Flags := -g
220 LD.Flags := -g
Reid Spencer4d71b662004-10-22 21:01:56 +0000221 KEEP_SYMBOLS := 1
Chris Lattner760da062003-03-14 20:25:22 +0000222 endif
223endif
224
Reid Spencer854071c2006-04-10 16:46:04 +0000225# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
226# then disable assertions by defining the appropriate preprocessor symbols.
Reid Spencerf9f431c2006-04-09 23:41:14 +0000227ifdef DISABLE_ASSERTIONS
Reid Spencerbac3ca22006-04-07 16:06:18 +0000228 BuildMode := $(BuildMode)-Asserts
Chris Lattner71927862006-03-21 01:06:41 +0000229 CXX.Flags += -DNDEBUG
230 C.Flags += -DNDEBUG
Reid Spencerf9f431c2006-04-09 23:41:14 +0000231else
232 CXX.Flags += -D_DEBUG
233 C.Flags += -D_DEBUG
Chris Lattner71927862006-03-21 01:06:41 +0000234endif
235
Reid Spencerf2722ca2006-03-22 15:59:55 +0000236CXX.Flags += $(CXXFLAGS)
237C.Flags += $(CFLAGS)
238CPP.BaseFlags += $(CPPFLAGS)
239LD.Flags += $(LDFLAGS)
240AR.Flags := cru
Reid Spencercc2d1e22004-10-30 09:19:36 +0000241LibTool.Flags := --tag=CXX
Reid Spencer3a561f52004-10-23 20:04:14 +0000242
Andrew Lenharth39bcf5b2005-02-13 03:41:10 +0000243#Make Floating point ieee complient on alpha
244ifeq ($(ARCH),Alpha)
Reid Spencerf2722ca2006-03-22 15:59:55 +0000245 CXX.Flags += -mieee
246 CPP.BaseFlags += -mieee
Andrew Lenharth39bcf5b2005-02-13 03:41:10 +0000247endif
248
Reid Spencer3a561f52004-10-23 20:04:14 +0000249#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000250# Directory locations
Reid Spencer3a561f52004-10-23 20:04:14 +0000251#--------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +0000252ObjDir := $(PROJ_OBJ_DIR)/$(BuildMode)
253LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
254ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
255ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer815cbcf2004-11-18 10:03:46 +0000256LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer9a5acaf2004-11-18 20:04:39 +0000257LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer775bf892004-12-28 07:59:22 +0000258LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer2f138e72004-12-22 05:57:21 +0000259CFERuntimeLibDir := $(LLVMGCCDIR)/lib
John Criswell7a73b802003-06-30 21:59:07 +0000260
Reid Spencer3a561f52004-10-23 20:04:14 +0000261#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000262# Full Paths To Compiled Tools and Utilities
Reid Spencer3a561f52004-10-23 20:04:14 +0000263#--------------------------------------------------------------------
Reid Spencer3ca6d8b2005-01-14 16:33:36 +0000264EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
265Echo = @$(EchoCmd)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000266ifndef LIBTOOL
Reid Spencer4d71b662004-10-22 21:01:56 +0000267LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencercc2d1e22004-10-30 09:19:36 +0000268endif
269ifndef LLVMAS
270LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
271endif
272ifndef BURG
273BURG := $(LLVMToolDir)/burg$(EXEEXT)
274endif
275ifndef TBLGEN
276TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
277endif
Chris Lattner478b3b42004-11-29 19:47:58 +0000278ifndef GCCAS
279GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
280endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000281ifndef GCCLD
282GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
283endif
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000284ifndef LDIS
285LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
286endif
287ifndef LLI
288LLI := $(LLVMToolDir)/lli$(EXEEXT)
289endif
Alkis Evlogimenoseebaf332005-02-27 10:21:37 +0000290ifndef LLC
291LLC := $(LLVMToolDir)/llc$(EXEEXT)
292endif
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000293ifndef LOPT
Alkis Evlogimenos20d793a2004-12-13 18:08:29 +0000294LOPT := $(LLVMToolDir)/opt$(EXEEXT)
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000295endif
Alkis Evlogimenos270e8512005-02-02 00:40:15 +0000296ifndef LBUGPOINT
297LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
298endif
299
John Criswellf5629d02005-01-03 17:42:57 +0000300LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
301LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000302
Reid Spencer3a561f52004-10-23 20:04:14 +0000303#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000304# Adjust to user's request
Reid Spencer3a561f52004-10-23 20:04:14 +0000305#--------------------------------------------------------------------
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000306
Reid Spencer492c2932005-01-11 04:31:07 +0000307# Adjust LD.Flags and Libtool.Flags depending on the kind of library that is
308# to be built. Note that if LOADABLE_MODULE is specified then the resulting
309# shared library can be opened with dlopen
310ifdef SHARED_LIBRARY
Reid Spencercc2d1e22004-10-30 09:19:36 +0000311 LD.Flags += -rpath $(LibDir)
Reid Spencer492c2932005-01-11 04:31:07 +0000312 ifdef LOADABLE_MODULE
313 LD.Flags += -module
314 endif
315else
316 LibTool.Flags += --tag=disable-shared
John Criswell82f4a5a2003-07-31 20:58:51 +0000317endif
318
Reid Spencercceed9f2004-11-08 17:32:12 +0000319ifdef TOOL_VERBOSE
320 C.Flags += -v
321 CXX.Flags += -v
322 LD.Flags += -v
Reid Spencercceed9f2004-11-08 17:32:12 +0000323 VERBOSE := 1
324endif
325
Reid Spencer3a561f52004-10-23 20:04:14 +0000326# Adjust settings for verbose mode
Chris Lattner760da062003-03-14 20:25:22 +0000327ifndef VERBOSE
Reid Spencercc2d1e22004-10-30 09:19:36 +0000328 Verb := @
329 LibTool.Flags += --silent
330 AR.Flags += >/dev/null 2>/dev/null
Reid Spencer11fde542005-01-16 02:20:54 +0000331 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
Reid Spencer151f8ba2004-10-25 08:27:37 +0000332else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000333 ConfigureScriptFLAGS :=
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000334endif
335
Vikram S. Advefeeae582002-09-18 11:55:13 +0000336# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000337ifndef KEEP_SYMBOLS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000338 Strip := $(PLATFORMSTRIPOPTS)
339 StripWarnMsg := "(without symbols)"
Reid Spencer860598a2005-02-24 07:12:43 +0000340 Install.StripFlag += -s
Vikram S. Advefeeae582002-09-18 11:55:13 +0000341endif
342
Reid Spencer3a561f52004-10-23 20:04:14 +0000343# Adjust linker flags for building an executable
Reid Spencer4d71b662004-10-22 21:01:56 +0000344ifdef TOOLNAME
Reid Spencer815cbcf2004-11-18 10:03:46 +0000345ifdef EXAMPLE_TOOL
346 LD.Flags += -rpath $(ExmplDir) -export-dynamic
347else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000348 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000349endif
Reid Spencer815cbcf2004-11-18 10:03:46 +0000350endif
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000351
Reid Spencer3a561f52004-10-23 20:04:14 +0000352#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000353# Options To Invoke Tools
Reid Spencer3a561f52004-10-23 20:04:14 +0000354#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000355
356CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
357
Duraid Madina0ad8fcf2005-05-16 06:38:09 +0000358ifeq ($(OS),HP-UX)
Duraid Madinaeb713402006-02-15 03:20:16 +0000359 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
Duraid Madina0ad8fcf2005-05-16 06:38:09 +0000360endif
361
Chris Lattnerba466652006-04-06 06:30:15 +0000362# If we are building a universal binary on Mac OS/X, pass extra options. This is
363# useful to people that want to link the LLVM libraries into their universal apps.
364ifdef UNIVERSAL
365 CompileCommonOpts += -arch i386 -arch ppc -isysroot /Developer/SDKs/MACOSX10.4u.sdk/
366 DISABLE_AUTO_DEPENDENCIES=1
367endif
368
Evan Cheng4d0586b2006-04-07 08:31:56 +0000369# Temporary workaround for a Mac OSX / x86 compatibility issue.
370ifeq ($(OS),Darwin)
371ifeq ($(ARCH),x86)
372 CXX.Flags += -fno-use-cxa-atexit
373endif
Evan Chengafd131e2006-04-07 08:10:09 +0000374endif
375
Reid Spencerf2722ca2006-03-22 15:59:55 +0000376LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
377CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
378# All -I flags should go here, so that they don't confuse llvm-config.
379CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
380 -I$(PROJ_OBJ_ROOT)/include \
381 -I$(PROJ_SRC_ROOT)/include \
382 -I$(LLVM_OBJ_ROOT)/include \
383 -I$(LLVM_SRC_ROOT)/include \
384 $(CPP.BaseFlags)
Reid Spencer4d71b662004-10-22 21:01:56 +0000385
Reid Spencercc2d1e22004-10-30 09:19:36 +0000386Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
387LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
Reid Spencer2f138e72004-12-22 05:57:21 +0000388BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattner89681112006-01-27 22:13:12 +0000389 $(C.Flags)
Chris Lattner0cb09f12005-10-05 00:28:41 +0000390Preprocess.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -E $(C.Flags)
391
Reid Spencercc2d1e22004-10-30 09:19:36 +0000392Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
393LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
Reid Spencerbc52ad72004-12-24 14:47:34 +0000394BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattner89681112006-01-27 22:13:12 +0000395 $(CXX.Flags)
Chris Lattner0cb09f12005-10-05 00:28:41 +0000396Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
Reid Spencercc2d1e22004-10-30 09:19:36 +0000397Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
398 $(CompileCommonOpts) $(LD.Flags) $(Strip)
399Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencera69b1ea2004-10-28 09:15:28 +0000400 $(CompileCommonOpts)
Reid Spencer1a9a69c2005-02-16 16:13:02 +0000401LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
402 $(Install.Flags)
Reid Spencer860598a2005-02-24 07:12:43 +0000403ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
Reid Spencerf2722ca2006-03-22 15:59:55 +0000404ScriptInstall = $(INSTALL) -m 0755
Reid Spencer860598a2005-02-24 07:12:43 +0000405DataInstall = $(INSTALL) -m 0644
Reid Spencer11fde542005-01-16 02:20:54 +0000406Burg = $(BURG) -I $(PROJ_SRC_DIR)
Chris Lattnercb3fc532006-03-03 01:54:54 +0000407TableGen = $(TBLGEN) -I $(PROJ_SRC_DIR) -I$(PROJ_SRC_ROOT)/include
Reid Spencercc2d1e22004-10-30 09:19:36 +0000408Archive = $(AR) $(AR.Flags)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000409LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencer4d71b662004-10-22 21:01:56 +0000410ifdef RANLIB
Reid Spencer3a561f52004-10-23 20:04:14 +0000411Ranlib = $(RANLIB)
Reid Spencer4d71b662004-10-22 21:01:56 +0000412else
Reid Spencer3a561f52004-10-23 20:04:14 +0000413Ranlib = ranlib
John Criswell7a73b802003-06-30 21:59:07 +0000414endif
415
Chris Lattner00950542001-06-06 20:29:01 +0000416#----------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +0000417# Get the list of source files and compute object file
418# names from them.
Reid Spencer3a561f52004-10-23 20:04:14 +0000419#----------------------------------------------------------
Chris Lattner89681112006-01-27 22:13:12 +0000420
421ifndef SOURCES
422 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
423 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
424 $(PROJ_SRC_DIR)/*.l))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000425else
Chris Lattner89681112006-01-27 22:13:12 +0000426 Sources := $(SOURCES)
427endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000428
Chris Lattner89681112006-01-27 22:13:12 +0000429ifdef BUILT_SOURCES
430Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Reid Spencer345235ca2004-12-04 22:34:09 +0000431endif
Reid Spencer3a561f52004-10-23 20:04:14 +0000432
Chris Lattner89681112006-01-27 22:13:12 +0000433BaseNameSources := $(sort $(basename $(Sources)))
434
435ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
436ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
437ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
438
Reid Spencer3a561f52004-10-23 20:04:14 +0000439###############################################################################
440# DIRECTORIES: Handle recursive descent of directory structure
441###############################################################################
John Criswell82f4a5a2003-07-31 20:58:51 +0000442
Chris Lattner00950542001-06-06 20:29:01 +0000443#---------------------------------------------------------
Reid Spencera69b1ea2004-10-28 09:15:28 +0000444# Provide rules to make install dirs. This must be early
445# in the file so they get built before dependencies
446#---------------------------------------------------------
447
Reid Spenceraa8bc432005-05-19 20:26:14 +0000448$(PROJ_bindir): $(PROJ_bindir)/.dir
449$(PROJ_libdir): $(PROJ_libdir)/.dir
450$(PROJ_includedir): $(PROJ_includedir)/.dir
451$(PROJ_etcdir): $(PROJ_etcdir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000452
Reid Spencercc2d1e22004-10-30 09:19:36 +0000453# To create other directories, as needed, and timestamp their creation
454%/.dir:
455 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfbbf3072004-11-29 05:00:33 +0000456 $(Verb) $(DATE) > $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000457
Reid Spencer815cbcf2004-11-18 10:03:46 +0000458.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
459.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000460
461#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000462# Handle the DIRS options for sequential construction
Chris Lattner00950542001-06-06 20:29:01 +0000463#---------------------------------------------------------
464
Reid Spencercc2d1e22004-10-30 09:19:36 +0000465SubDirs :=
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000466ifdef DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000467SubDirs += $(DIRS)
468$(RecursiveTargets)::
469 $(Verb) for dir in $(DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000470 if [ ! -f $$dir/Makefile ]; then \
471 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000472 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000473 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000474 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
475 ($(MAKE) -C $$dir $@ ) || exit 1; \
476 fi ; \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000477 done
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000478endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000479
Reid Spencer3a561f52004-10-23 20:04:14 +0000480#---------------------------------------------------------
481# Handle the EXPERIMENTAL_DIRS options ensuring success
482# after each directory is built.
483#---------------------------------------------------------
484ifdef EXPERIMENTAL_DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000485$(RecursiveTargets)::
486 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer3a561f52004-10-23 20:04:14 +0000487 if [ ! -f $$dir/Makefile ]; then \
488 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000489 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000490 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000491 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
492 ($(MAKE) -C $$dir $@ ) || exit 0; \
493 fi ; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000494 done
495endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000496
Reid Spencer25e8a702005-12-21 23:17:06 +0000497#-----------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000498# Handle the PARALLEL_DIRS options for parallel construction
Reid Spencer25e8a702005-12-21 23:17:06 +0000499#-----------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000500ifdef PARALLEL_DIRS
501
Reid Spencercc2d1e22004-10-30 09:19:36 +0000502SubDirs += $(PARALLEL_DIRS)
503
Reid Spencer44cb1b32004-12-03 20:08:48 +0000504# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencercc2d1e22004-10-30 09:19:36 +0000505all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
506clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000507clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000508install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000509uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencer44cb1b32004-12-03 20:08:48 +0000510install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000511
Reid Spencer345235ca2004-12-04 22:34:09 +0000512ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer3a561f52004-10-23 20:04:14 +0000513
Reid Spencer345235ca2004-12-04 22:34:09 +0000514$(ParallelTargets) :
Reid Spencercc2d1e22004-10-30 09:19:36 +0000515 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencer4d71b662004-10-22 21:01:56 +0000516 $(MKDIR) $(@D); \
Reid Spencer11fde542005-01-16 02:20:54 +0000517 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswellb3866b62003-11-25 19:32:22 +0000518 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000519 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
520 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
521 fi
Chris Lattner00950542001-06-06 20:29:01 +0000522endif
523
Reid Spencer3a561f52004-10-23 20:04:14 +0000524#---------------------------------------------------------
525# Handle the OPTIONAL_DIRS options for directores that may
526# or may not exist.
527#---------------------------------------------------------
John Criswell2a6530f2003-06-27 16:58:44 +0000528ifdef OPTIONAL_DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000529
Reid Spencercc2d1e22004-10-30 09:19:36 +0000530SubDirs += $(OPTIONAL_DIRS)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000531
Reid Spencercc2d1e22004-10-30 09:19:36 +0000532$(RecursiveTargets)::
533 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000534 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
Reid Spencer4d71b662004-10-22 21:01:56 +0000535 if [ ! -f $$dir/Makefile ]; then \
536 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000537 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000538 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000539 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
540 ($(MAKE) -C$$dir $@ ) || exit 1; \
541 fi ; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000542 fi \
John Criswell2a6530f2003-06-27 16:58:44 +0000543 done
544endif
545
Reid Spencerfc945082004-08-20 09:20:05 +0000546#---------------------------------------------------------
547# Handle the CONFIG_FILES options
548#---------------------------------------------------------
549ifdef CONFIG_FILES
Reid Spencerfc945082004-08-20 09:20:05 +0000550
Reid Spencer11fde542005-01-16 02:20:54 +0000551install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
552 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000553 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000554 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
Reid Spencer4a0aaea2005-02-24 03:56:32 +0000555 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer11fde542005-01-16 02:20:54 +0000556 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
Reid Spencer4a0aaea2005-02-24 03:56:32 +0000557 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer1b426ab2004-11-23 05:59:53 +0000558 else \
559 $(ECHO) Error: cannot find config file $${file}. ; \
560 fi \
Reid Spencerfc945082004-08-20 09:20:05 +0000561 done
Reid Spencer3a561f52004-10-23 20:04:14 +0000562
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000563uninstall-local::
Reid Spencer11fde542005-01-16 02:20:54 +0000564 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000565 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000566 $(RM) -f $(PROJ_etcdir)/$${file} ; \
Reid Spencere5487ba2004-10-24 07:53:21 +0000567 done
568
Reid Spencerfc945082004-08-20 09:20:05 +0000569endif
570
Reid Spencer3a561f52004-10-23 20:04:14 +0000571###############################################################################
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000572# Set up variables for building libararies
573###############################################################################
574
575#---------------------------------------------------------
576# Handle the special "JIT" value for LLVM_LIBS which is a
577# shorthand for a bunch of libraries that get the correct
578# JIT support for a library or a tool that runs JIT.
579#---------------------------------------------------------
Reid Spencer205b02e2006-03-24 07:36:57 +0000580ifeq ($(firstword $(LLVMLIBS)),config)
581LLVM_CONFIG := $(LLVM_SRC_ROOT)/utils/llvm-config/llvm-config
Reid Spencerbac3ca22006-04-07 16:06:18 +0000582LLVMLIBS := $(shell $(LLVM_CONFIG) --libnames $(wordlist 2,9999,$(LLVMLIBS)))
583LLVMLIBS := $(patsubst lib%.a,%.a,$(LLVMLIBS))
Reid Spencer205b02e2006-03-24 07:36:57 +0000584LLVMLIBS := $(patsubst %.o,%,$(LLVMLIBS))
Reid Spencer205b02e2006-03-24 07:36:57 +0000585endif
586
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000587ifeq ($(LLVMLIBS),JIT)
588
589# Make sure we can get our own symbols in the tool
590Link += -dlopen self
591
592# Generic JIT libraries
593JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
594
595# You can enable the X86 JIT on a non-X86 host by setting the flag
596# ENABLE_X86_JIT on the make command line. If not, it will still be
597# enabled automagically on an X86 host.
598ifeq ($(ARCH), x86)
599 ENABLE_X86_JIT = 1
600endif
601
602# What the X86 JIT requires
603ifdef ENABLE_X86_JIT
604 JIT_LIBS += LLVMX86 LLVMSelectionDAG
605endif
606
607# You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
608# ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
609# enabled automagically on an SparcV9 host.
610ifeq ($(ARCH), Sparc)
611 ENABLE_SPARCV9_JIT = 1
612endif
613
614# What the Sparc JIT requires
615ifdef ENABLE_SPARCV9_JIT
616 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
John Criswelle96a1a52005-10-26 20:35:13 +0000617 LLVMSparcV9LiveVar LLVMInstrumentation.a \
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000618 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
John Criswelle96a1a52005-10-26 20:35:13 +0000619 LLVMDataStructure LLVMSparcV9RegAlloc
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000620endif
621
622# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
623# ENABLE_PPC_JIT on the make command line. If not, it will still be
624# enabled automagically on an PowerPC host.
625ifeq ($(ARCH), PowerPC)
626 ENABLE_PPC_JIT = 1
627endif
628
629# What the PowerPC JIT requires
630ifdef ENABLE_PPC_JIT
631 JIT_LIBS += LLVMPowerPC LLVMSelectionDAG
632endif
633
Andrew Lenharthddc31e82005-07-22 20:54:01 +0000634# You can enable the Alpha JIT on a non-Alpha host by setting the flag
635# ENABLE_ALPHA_JIT on the make command line. If not, it will still be
Misha Brukmanab25eda2005-07-22 22:43:40 +0000636# enabled automagically on an Alpha host.
Andrew Lenharthddc31e82005-07-22 20:54:01 +0000637ifeq ($(ARCH), Alpha)
638 ENABLE_ALPHA_JIT = 1
639endif
640
Andrew Lenharth22894e92005-07-22 22:00:24 +0000641# What the Alpha JIT requires
Andrew Lenharthddc31e82005-07-22 20:54:01 +0000642ifdef ENABLE_ALPHA_JIT
643 JIT_LIBS += LLVMAlpha LLVMSelectionDAG
644endif
645
John Criswella1156432005-10-27 15:54:34 +0000646LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts.a LLVMTransformUtils.a LLVMAnalysis.a \
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000647 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
648 LLVMSystem.a $(PLATFORMLIBDL)
649endif
650
651#---------------------------------------------------------
652# Define various command line options pertaining to the
653# libraries needed when linking. There are "Proj" libs
654# (defined by the user's project) and "LLVM" libs (defined
655# by the # LLVM project).
656#---------------------------------------------------------
Misha Brukman6c26da62005-08-17 02:38:56 +0000657# Some versions of gcc on Alpha produce too many symbols, so use a .a file
Andrew Lenharth7ac17522005-08-13 05:09:50 +0000658ifeq ($(ARCH),Alpha)
659USEDLIBS := $(subst LLVMCore, LLVMCore.a, $(USEDLIBS))
660LLVMLIBS := $(subst LLVMCore, LLVMCore.a, $(LLVMLIBS))
Reid Spencerf2722ca2006-03-22 15:59:55 +0000661CORE_IS_ARCHIVE := 1
662else
663CORE_IS_ARCHIVE := 0
Andrew Lenharth7ac17522005-08-13 05:09:50 +0000664endif
665
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000666ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
667ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
668LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
669LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
670ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
671LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
672ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
673LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
674
675###############################################################################
Reid Spencer3a561f52004-10-23 20:04:14 +0000676# Library Build Rules: Four ways to build a library
677###############################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000678
Reid Spencer7980ea42004-12-05 05:17:22 +0000679#---------------------------------------------------------
680# Bytecode Module Targets:
681# If the user set MODULE_NAME then they want to build a
682# bytecode module from the sources. We compile all the
683# sources and link it together into a single bytecode
684# module.
685#---------------------------------------------------------
686
687ifdef MODULE_NAME
Reid Spencer9a8398e2005-02-14 21:54:08 +0000688ifeq ($(strip $(LLVMGCC)),)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000689$(warning Modules require llvm-gcc but no llvm-gcc is available ****)
Reid Spencer9a8398e2005-02-14 21:54:08 +0000690else
Reid Spencer7980ea42004-12-05 05:17:22 +0000691
692Module := $(LibDir)/$(MODULE_NAME).bc
Chris Lattner89681112006-01-27 22:13:12 +0000693LinkModule := $(GCCLD)
Reid Spencer7980ea42004-12-05 05:17:22 +0000694
695ifdef EXPORTED_SYMBOL_FILE
Chris Lattner89681112006-01-27 22:13:12 +0000696LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer7980ea42004-12-05 05:17:22 +0000697endif
698
699$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000700 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
Reid Spencer7980ea42004-12-05 05:17:22 +0000701 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
702
703all-local:: $(Module)
704
705clean-local::
706ifneq ($(strip $(Module)),)
707 -$(Verb) $(RM) -f $(Module)
708endif
709
Reid Spencerab3690b2004-12-13 07:38:07 +0000710ifdef BYTECODE_DESTINATION
711ModuleDestDir := $(BYTECODE_DESTINATION)
712else
Reid Spencer11fde542005-01-16 02:20:54 +0000713ModuleDestDir := $(PROJ_libdir)
Reid Spencerab3690b2004-12-13 07:38:07 +0000714endif
Reid Spencer7980ea42004-12-05 05:17:22 +0000715
Reid Spencerab3690b2004-12-13 07:38:07 +0000716DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
717
718install-module:: $(DestModule)
Reid Spencer7980ea42004-12-05 05:17:22 +0000719install-local:: $(DestModule)
720
Reid Spencerab3690b2004-12-13 07:38:07 +0000721$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencer7980ea42004-12-05 05:17:22 +0000722 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
Reid Spencer151bbe42005-02-24 21:30:37 +0000723 $(Verb) $(DataInstall) $(Module) $(DestModule)
Reid Spencer7980ea42004-12-05 05:17:22 +0000724
725uninstall-local::
726 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
727 -$(Verb) $(RM) -f $(DestModule)
728
729endif
Reid Spencer9a8398e2005-02-14 21:54:08 +0000730endif
Brian Gaeke8abff792004-01-22 22:53:48 +0000731
Reid Spencer3a561f52004-10-23 20:04:14 +0000732# if we're building a library ...
Chris Lattner00950542001-06-06 20:29:01 +0000733ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000734
Chris Lattner2a548c52002-09-16 22:36:42 +0000735# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000736LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencer492c2932005-01-11 04:31:07 +0000737ifdef LOADABLE_MODULE
738LibName.LA := $(LibDir)/$(LIBRARYNAME).la
739else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000740LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
Reid Spencer492c2932005-01-11 04:31:07 +0000741endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000742LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
743LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer9a2f1372004-12-02 09:28:21 +0000744LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000745
Reid Spencer3a561f52004-10-23 20:04:14 +0000746#---------------------------------------------------------
747# Shared Library Targets:
748# If the user asked for a shared library to be built
749# with the SHARED_LIBRARY variable, then we provide
750# targets for building them.
751#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000752ifdef SHARED_LIBRARY
753
Reid Spencercc2d1e22004-10-30 09:19:36 +0000754all-local:: $(LibName.LA)
Reid Spencer4d71b662004-10-22 21:01:56 +0000755
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000756ifdef LINK_LIBS_IN_SHARED
757$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
758 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
759 $(Verb) $(Link) -o $@ $(ObjectsLO) \
760 $(ProjLibsOptions) $(LLVMLibsOptions)
761 $(Verb) $(LTInstall) $@ $(LibDir)
762else
Reid Spencerf2ac1892004-12-16 07:36:08 +0000763$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000764 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000765 $(Verb) $(Link) -o $@ $(ObjectsLO)
766 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000767endif
Reid Spencer3a561f52004-10-23 20:04:14 +0000768
769clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000770ifneq ($(strip $(LibName.LA)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000771 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000772endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000773
Reid Spencer11fde542005-01-16 02:20:54 +0000774DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencer4d71b662004-10-22 21:01:56 +0000775
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000776install-local:: $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000777
Reid Spencer11fde542005-01-16 02:20:54 +0000778$(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
Reid Spencer9af3b292004-11-01 07:50:27 +0000779 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000780 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
Reid Spencer11fde542005-01-16 02:20:54 +0000781 $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
Reid Spencere5487ba2004-10-24 07:53:21 +0000782
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000783uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000784 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencer11fde542005-01-16 02:20:54 +0000785 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
Reid Spencere5487ba2004-10-24 07:53:21 +0000786
Reid Spencer4d71b662004-10-22 21:01:56 +0000787endif
788
Reid Spencer3a561f52004-10-23 20:04:14 +0000789#---------------------------------------------------------
790# Bytecode Library Targets:
791# If the user asked for a bytecode library to be built
792# with the BYTECODE_LIBRARY variable, then we provide
793# targets for building them.
794#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000795ifdef BYTECODE_LIBRARY
Reid Spencer9a8398e2005-02-14 21:54:08 +0000796ifeq ($(strip $(LLVMGCC)),)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000797$(warning Bytecode libraries require llvm-gcc which could not be found ****)
Reid Spencer9a8398e2005-02-14 21:54:08 +0000798else
Reid Spencer4d71b662004-10-22 21:01:56 +0000799
Reid Spencer9a2f1372004-12-02 09:28:21 +0000800all-local:: $(LibName.BCA)
801
802ifdef EXPORTED_SYMBOL_FILE
Chris Lattner89681112006-01-27 22:13:12 +0000803BCLinkLib = $(GCCLD) -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000804
Reid Spencerf2ac1892004-12-16 07:36:08 +0000805$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
Chris Lattner264ccbe2004-12-15 17:14:06 +0000806 $(LLVMToolDir)/llvm-ar
Reid Spencer9a2f1372004-12-02 09:28:21 +0000807 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
808 "(internalize)"
Chris Lattnerb0ea8642004-12-02 21:23:43 +0000809 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencerefd6bb32004-12-13 03:59:35 +0000810 $(Verb) $(RM) -f $@
Reid Spencer9a2f1372004-12-02 09:28:21 +0000811 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencer4d71b662004-10-22 21:01:56 +0000812else
Reid Spencerf2ac1892004-12-16 07:36:08 +0000813$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
Chris Lattner264ccbe2004-12-15 17:14:06 +0000814 $(LLVMToolDir)/llvm-ar
Reid Spencer9a2f1372004-12-02 09:28:21 +0000815 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencerefd6bb32004-12-13 03:59:35 +0000816 $(Verb) $(RM) -f $@
Reid Spencer9a2f1372004-12-02 09:28:21 +0000817 $(Verb) $(LArchive) $@ $(ObjectsBC)
818
Reid Spencer4d71b662004-10-22 21:01:56 +0000819endif
820
Reid Spencer3a561f52004-10-23 20:04:14 +0000821clean-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000822ifneq ($(strip $(LibName.BCA)),)
823 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000824endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000825
Reid Spencer8f094f32004-12-13 07:28:21 +0000826ifdef BYTECODE_DESTINATION
827BytecodeDestDir := $(BYTECODE_DESTINATION)
828else
Reid Spencer11fde542005-01-16 02:20:54 +0000829BytecodeDestDir := $(PROJ_libdir)
Reid Spencer8f094f32004-12-13 07:28:21 +0000830endif
831
832DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
Reid Spencer9a2f1372004-12-02 09:28:21 +0000833
Reid Spencer44cb1b32004-12-03 20:08:48 +0000834install-bytecode-local:: $(DestBytecodeLib)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000835
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000836install-local:: $(DestBytecodeLib)
Chris Lattner481cc7c2003-08-15 02:18:35 +0000837
Reid Spencer8f094f32004-12-13 07:28:21 +0000838$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000839 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerb80621f2005-02-24 21:36:32 +0000840 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000841
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000842uninstall-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000843 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000844 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000845
846endif
Reid Spencer9a8398e2005-02-14 21:54:08 +0000847endif
Vikram S. Adve60f56062002-08-02 18:34:12 +0000848
Reid Spencercc2d1e22004-10-30 09:19:36 +0000849#---------------------------------------------------------
850# ReLinked Library Targets:
Chris Lattner89938082005-10-24 02:21:45 +0000851# If the user explicitly requests a relinked library with
852# BUILD_RELINKED, provide it. Otherwise, if they specify
853# neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
854# them one.
Reid Spencercc2d1e22004-10-30 09:19:36 +0000855#---------------------------------------------------------
Chris Lattner89938082005-10-24 02:21:45 +0000856ifndef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000857ifndef DONT_BUILD_RELINKED
Chris Lattner89938082005-10-24 02:21:45 +0000858BUILD_RELINKED = 1
859endif
860endif
861
862ifdef BUILD_RELINKED
Reid Spencer4d71b662004-10-22 21:01:56 +0000863
Reid Spencercc2d1e22004-10-30 09:19:36 +0000864all-local:: $(LibName.O)
865
Reid Spencerf2ac1892004-12-16 07:36:08 +0000866$(LibName.O): $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000867 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000868 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencer4d71b662004-10-22 21:01:56 +0000869
Reid Spencer3a561f52004-10-23 20:04:14 +0000870clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000871ifneq ($(strip $(LibName.O)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000872 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencere5487ba2004-10-24 07:53:21 +0000873endif
874
Reid Spencer11fde542005-01-16 02:20:54 +0000875DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
Reid Spencere5487ba2004-10-24 07:53:21 +0000876
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000877install-local:: $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000878
Reid Spencer11fde542005-01-16 02:20:54 +0000879$(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
Reid Spencer9af3b292004-11-01 07:50:27 +0000880 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000881 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000882
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000883uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000884 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000885 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000886
Chris Lattnere62dbe92002-07-23 17:56:16 +0000887endif
Chris Lattner760da062003-03-14 20:25:22 +0000888
Reid Spencercc2d1e22004-10-30 09:19:36 +0000889#---------------------------------------------------------
890# Archive Library Targets:
891# If the user wanted a regular archive library built,
892# then we provide targets for building them.
893#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000894ifdef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000895
Reid Spencercc2d1e22004-10-30 09:19:36 +0000896all-local:: $(LibName.A)
897
Reid Spencerf2ac1892004-12-16 07:36:08 +0000898$(LibName.A): $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000899 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000900 -$(Verb) $(RM) -f $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000901 $(Verb) $(Archive) $@ $(ObjectsO)
902 $(Verb) $(Ranlib) $@
Vikram S. Adve41e78912002-09-20 14:03:13 +0000903
Reid Spencer3a561f52004-10-23 20:04:14 +0000904clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000905ifneq ($(strip $(LibName.A)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000906 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner00950542001-06-06 20:29:01 +0000907endif
908
Reid Spencer11fde542005-01-16 02:20:54 +0000909DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
Reid Spencere5487ba2004-10-24 07:53:21 +0000910
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000911install-local:: $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000912
Reid Spencer11fde542005-01-16 02:20:54 +0000913$(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
Reid Spencer9af3b292004-11-01 07:50:27 +0000914 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencer11fde542005-01-16 02:20:54 +0000915 $(Verb) $(MKDIR) $(PROJ_libdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000916 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000917
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000918uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000919 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000920 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000921
922endif
923
924# endif LIBRARYNAME
Reid Spencer4d71b662004-10-22 21:01:56 +0000925endif
926
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000927###############################################################################
928# Tool Build Rules: Build executable tool based on TOOLNAME option
929###############################################################################
930
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000931ifdef TOOLNAME
932
Reid Spencercc2d1e22004-10-30 09:19:36 +0000933#---------------------------------------------------------
934# Set up variables for building a tool.
935#---------------------------------------------------------
Reid Spencer815cbcf2004-11-18 10:03:46 +0000936ifdef EXAMPLE_TOOL
Reid Spencer5da2d082005-05-19 21:03:11 +0000937ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000938else
Reid Spencer5da2d082005-05-19 21:03:11 +0000939ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000940endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000941
Reid Spencercc2d1e22004-10-30 09:19:36 +0000942#---------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000943# Tell make that we need to rebuild subdirectories before
944# we can link the tool. This affects things like LLI which
945# has library subdirectories.
946#---------------------------------------------------------
947$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000948
Reid Spencercc2d1e22004-10-30 09:19:36 +0000949#---------------------------------------------------------
950# Provide targets for building the tools
951#---------------------------------------------------------
952all-local:: $(ToolBuildPath)
John Criswell2a6530f2003-06-27 16:58:44 +0000953
Reid Spencer3a561f52004-10-23 20:04:14 +0000954clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000955ifneq ($(strip $(ToolBuildPath)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000956 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencere5487ba2004-10-24 07:53:21 +0000957endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000958
Reid Spencer815cbcf2004-11-18 10:03:46 +0000959ifdef EXAMPLE_TOOL
960$(ToolBuildPath): $(ExmplDir)/.dir
961else
962$(ToolBuildPath): $(ToolDir)/.dir
963endif
964
Reid Spencerf2ac1892004-12-16 07:36:08 +0000965$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencer9af3b292004-11-01 07:50:27 +0000966 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Chris Lattnerbe3c2f22006-03-10 21:01:34 +0000967 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(LLVMLibsOptions) \
968 $(ProjLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
Chris Lattnerd25ad612006-02-14 04:25:54 +0000969 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
970 $(StripWarnMsg)
Reid Spencere5487ba2004-10-24 07:53:21 +0000971
Reid Spencer11fde542005-01-16 02:20:54 +0000972DestTool = $(PROJ_bindir)/$(TOOLNAME)
Reid Spencere5487ba2004-10-24 07:53:21 +0000973
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000974install-local:: $(DestTool)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000975
Reid Spencer11fde542005-01-16 02:20:54 +0000976$(DestTool): $(PROJ_bindir) $(ToolBuildPath)
Reid Spencer9af3b292004-11-01 07:50:27 +0000977 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencer4a0aaea2005-02-24 03:56:32 +0000978 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000979
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000980uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000981 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000982 -$(Verb) $(RM) -f $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000983
Reid Spencer4d71b662004-10-22 21:01:56 +0000984endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000985
Reid Spencercc2d1e22004-10-30 09:19:36 +0000986###############################################################################
987# Object Build Rules: Build object files based on sources
988###############################################################################
989
Duraid Madina197ab872006-02-15 03:23:26 +0000990# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
991ifeq ($(OS),HP-UX)
992 DISABLE_AUTO_DEPENDENCIES=1
993endif
994
Reid Spencercc2d1e22004-10-30 09:19:36 +0000995# Provide rule sets for when dependency generation is enabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000996ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve41e78912002-09-20 14:03:13 +0000997
Reid Spencercc2d1e22004-10-30 09:19:36 +0000998#---------------------------------------------------------
999# Create .lo files in the ObjDir directory from the .cpp and .c files...
1000#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001001ifdef SHARED_LIBRARY
1002
Chris Lattner3c473472004-12-16 17:28:50 +00001003$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001004 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Chris Lattner77efe272006-02-14 04:27:15 +00001005 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
Reid Spencercc2d1e22004-10-30 09:19:36 +00001006 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
1007 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +00001008
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001009$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1010 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
Chris Lattner77efe272006-02-14 04:27:15 +00001011 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001012 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
1013 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
1014
Chris Lattner3c473472004-12-16 17:28:50 +00001015$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001016 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001017 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
1018 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
1019 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +00001020
Reid Spencercc2d1e22004-10-30 09:19:36 +00001021#---------------------------------------------------------
1022# Create .o files in the ObjDir directory from the .cpp and .c files...
1023#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001024else
Reid Spencer4d71b662004-10-22 21:01:56 +00001025
Chris Lattner3c473472004-12-16 17:28:50 +00001026$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001027 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001028 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
1029 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
1030 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +00001031
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001032$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1033 $(Echo) "Compiling $*.cc for $(BuildMode) build"
1034 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
1035 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
1036 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
1037
Chris Lattner3c473472004-12-16 17:28:50 +00001038$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001039 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001040 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
1041 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
1042 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +00001043
1044endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001045
Chris Lattner0cb09f12005-10-05 00:28:41 +00001046## Rules for building preprocessed (.i/.ii) outputs.
1047$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1048 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1049 $(Verb) $(Preprocess.CXX) $< -o $@
1050
1051$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1052 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1053 $(Verb) $(Preprocess.CXX) $< -o $@
1054
1055 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1056 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1057 $(Verb) $(Preprocess.C) $< -o $@
1058
1059
Reid Spencercc2d1e22004-10-30 09:19:36 +00001060#---------------------------------------------------------
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001061# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
Reid Spencercc2d1e22004-10-30 09:19:36 +00001062#---------------------------------------------------------
Chris Lattner89681112006-01-27 22:13:12 +00001063
1064$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001065 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattnerd25ad612006-02-14 04:25:54 +00001066 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1067 $< -o $@ -S -emit-llvm ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001068 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1069 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +00001070
Chris Lattner89681112006-01-27 22:13:12 +00001071$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001072 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattnerd25ad612006-02-14 04:25:54 +00001073 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1074 $< -o $@ -S -emit-llvm ; \
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001075 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1076 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1077
Chris Lattner89681112006-01-27 22:13:12 +00001078$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001079 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattnerd25ad612006-02-14 04:25:54 +00001080 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" \
1081 $< -o $@ -S -emit-llvm ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001082 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1083 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +00001084
Reid Spencercc2d1e22004-10-30 09:19:36 +00001085# Provide alternate rule sets if dependencies are disabled
Reid Spencer4d71b662004-10-22 21:01:56 +00001086else
1087
Reid Spencer3a561f52004-10-23 20:04:14 +00001088ifdef SHARED_LIBRARY
1089
Chris Lattner3c473472004-12-16 17:28:50 +00001090$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001091 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +00001092 $(LTCompile.CXX) $< -o $@
1093
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001094$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1095 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
1096 $(LTCompile.CXX) $< -o $@
1097
Chris Lattner3c473472004-12-16 17:28:50 +00001098$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerc3719842004-12-16 18:26:53 +00001099 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +00001100 $(LTCompile.C) $< -o $@
1101
1102else
Reid Spencer4d71b662004-10-22 21:01:56 +00001103
Chris Lattner3c473472004-12-16 17:28:50 +00001104$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001105 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +00001106 $(Compile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +00001107
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001108$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1109 $(Echo) "Compiling $*.cc for $(BuildMode) build"
1110 $(Compile.CXX) $< -o $@
1111
Chris Lattner3c473472004-12-16 17:28:50 +00001112$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerc3719842004-12-16 18:26:53 +00001113 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +00001114 $(Compile.C) $< -o $@
1115endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001116
Chris Lattner89681112006-01-27 22:13:12 +00001117$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001118 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001119 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Reid Spencer4d71b662004-10-22 21:01:56 +00001120
Chris Lattner89681112006-01-27 22:13:12 +00001121$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001122 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001123 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001124
Chris Lattner89681112006-01-27 22:13:12 +00001125$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001126 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001127 $(BCCompile.C) $< -o $@ -S -emit-llvm
Brian Gaeke44909cf2003-12-10 00:26:28 +00001128
Chris Lattner1cbc29f2001-09-07 22:57:58 +00001129endif
1130
Chris Lattner89681112006-01-27 22:13:12 +00001131# make the C and C++ compilers strip debug info out of bytecode libraries.
1132ifdef DEBUG_RUNTIME
1133$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1134 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Chris Lattnerc0977982006-03-09 06:00:05 +00001135 $(Verb) $(GCCAS) $< -o $@
Chris Lattner89681112006-01-27 22:13:12 +00001136else
1137$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1138 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Chris Lattnerc0977982006-03-09 06:00:05 +00001139 $(Verb) $(GCCAS) -strip-debug $< -o $@
Chris Lattner89681112006-01-27 22:13:12 +00001140endif
1141
1142
Reid Spencercc2d1e22004-10-30 09:19:36 +00001143#---------------------------------------------------------
1144# Provide rule to build .bc files from .ll sources,
1145# regardless of dependencies
1146#---------------------------------------------------------
1147$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencer9af3b292004-11-01 07:50:27 +00001148 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001149 $(Verb) $(LLVMAS) $< -f -o $@
1150
1151###############################################################################
1152# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1153###############################################################################
Chris Lattner481cc7c2003-08-15 02:18:35 +00001154
Reid Spencer4d71b662004-10-22 21:01:56 +00001155ifdef TARGET
1156
Chris Lattnerd25ad612006-02-14 04:25:54 +00001157TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1158 $(LLVM_SRC_ROOT)/lib/Target/Target.td \
Chris Lattnercb3fc532006-03-03 01:54:54 +00001159 $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td \
1160 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001161INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Chris Lattner3c473472004-12-16 17:28:50 +00001162INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1163.PRECIOUS: $(INCTMPFiles) $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001164
Chris Lattner3c473472004-12-16 17:28:50 +00001165# All of these files depend on tblgen and the .td files.
1166$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001167
Chris Lattner23ee7952004-12-16 17:38:56 +00001168# INCFiles rule: All of the tblgen generated files are emitted to
1169# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1170# us to only "touch" the real file if the contents of it change. IOW, if
1171# tblgen is modified, all of the .inc.tmp files are regereated, but no
1172# dependencies of the .inc files are, unless the contents of the .inc file
1173# changes.
1174$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
Reid Spencerc3719842004-12-16 18:26:53 +00001175 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
Chris Lattner3c473472004-12-16 17:28:50 +00001176
1177$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1178$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001179 $(Echo) "Building $(<F) register names with tblgen"
1180 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001181
Chris Lattner3c473472004-12-16 17:28:50 +00001182$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1183$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001184 $(Echo) "Building $(<F) register information header with tblgen"
1185 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001186
Chris Lattner3c473472004-12-16 17:28:50 +00001187$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1188$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001189 $(Echo) "Building $(<F) register info implementation with tblgen"
1190 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001191
Chris Lattner3c473472004-12-16 17:28:50 +00001192$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1193$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001194 $(Echo) "Building $(<F) instruction names with tblgen"
1195 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001196
Chris Lattner3c473472004-12-16 17:28:50 +00001197$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1198$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001199 $(Echo) "Building $(<F) instruction information with tblgen"
1200 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001201
Chris Lattner3c473472004-12-16 17:28:50 +00001202$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1203$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001204 $(Echo) "Building $(<F) assembly writer with tblgen"
1205 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001206
Chris Lattner02a4f902004-12-16 17:34:04 +00001207$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1208$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1209 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001210 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001211
Chris Lattner3c473472004-12-16 17:28:50 +00001212$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1213$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001214 $(Echo) "Building $(<F) code emitter with tblgen"
1215 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001216
Chris Lattnerf31f09e2005-09-03 01:15:25 +00001217$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1218$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1219 $(Echo) "Building $(<F) instruction selector implementation with tblgen"
1220 $(Verb) $(TableGen) -gen-dag-isel -o $@ $<
1221
Jim Laskeyf5fc2cb2005-10-21 19:05:19 +00001222$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1223$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1224 $(Echo) "Building $(<F) subtarget information with tblgen"
1225 $(Verb) $(TableGen) -gen-subtarget -o $@ $<
Chris Lattnerf31f09e2005-09-03 01:15:25 +00001226
Reid Spencer3a561f52004-10-23 20:04:14 +00001227clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001228 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001229
1230endif
Chris Lattner481cc7c2003-08-15 02:18:35 +00001231
Reid Spencercc2d1e22004-10-30 09:19:36 +00001232###############################################################################
1233# LEX AND YACC: Provide rules for generating sources with lex and yacc
1234###############################################################################
Chris Lattnere8996782003-01-16 22:44:19 +00001235
Reid Spencercc2d1e22004-10-30 09:19:36 +00001236#---------------------------------------------------------
1237# Provide rules for generating a .cpp source file from
1238# (f)lex input sources.
1239#---------------------------------------------------------
1240
Reid Spencer3d659492004-11-02 16:36:03 +00001241LexFiles := $(filter %.l,$(Sources))
Reid Spencercc2d1e22004-10-30 09:19:36 +00001242
Reid Spencer3d659492004-11-02 16:36:03 +00001243ifneq ($(LexFiles),)
1244
Reid Spencer68a24bd2005-08-27 18:50:39 +00001245# Cancel built-in rules for lex
1246%.c: %.l
1247%.cpp: %.l
Reid Spencercc2d1e22004-10-30 09:19:36 +00001248
Chris Lattner342567c2006-02-14 05:12:00 +00001249all:: $(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs)
1250
Reid Spencercc2d1e22004-10-30 09:19:36 +00001251# Note the extra sed filtering here, used to cut down on the warnings emited
1252# by GCC. The last line is a gross hack to work around flex aparently not
1253# being able to resize the buffer on a large token input. Currently, for
1254# uninitialized string buffers in LLVM we can generate very long tokens, so
1255# this is a hack around it.
Chris Lattnerb7dc2b92003-08-15 20:00:47 +00001256# FIXME. (f.e. char Buffer[10000] )
Reid Spencer68a24bd2005-08-27 18:50:39 +00001257$(PROJ_SRC_DIR)/%.cpp: $(PROJ_SRC_DIR)/%.l
Reid Spencerc2ef8cd2004-12-10 19:44:16 +00001258 $(Echo) Flexing $*.l
Reid Spencer68a24bd2005-08-27 18:50:39 +00001259 $(Verb) $(FLEX) -t $(PROJ_SRC_DIR)/$*.l | \
Reid Spencer4d71b662004-10-22 21:01:56 +00001260 $(SED) 's/void yyunput/inline void yyunput/' | \
1261 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1262 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001263 > $(PROJ_SRC_DIR)/$*.cpp
Chris Lattner342567c2006-02-14 05:12:00 +00001264
1265# IFF the .l file has changed since it was last checked into CVS, copy the .l
1266# file to .l.cvs and the generated .cpp file to .cpp.cvs. We use this mechanism
1267# so that people without flex can build LLVM by copying the .cvs files to the
1268# source location and building them.
1269$(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1270$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattneraf2f3512006-02-16 05:10:48 +00001271 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs || \
Chris Lattner342567c2006-02-14 05:12:00 +00001272 ($(CP) $< $@; $(CP) $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001273
Chris Lattner342567c2006-02-14 05:12:00 +00001274$(LexFiles:%.l=$(ObjDir)/%.o) : \
1275$(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
Chris Lattner00950542001-06-06 20:29:01 +00001276
Reid Spencer9af3b292004-11-01 07:50:27 +00001277clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001278 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencer9af3b292004-11-01 07:50:27 +00001279
Reid Spencercc2d1e22004-10-30 09:19:36 +00001280endif
1281
1282#---------------------------------------------------------
1283# Provide rules for generating a .cpp and .h source files
1284# from yacc (bison) input sources.
1285#---------------------------------------------------------
1286
Reid Spencer3d659492004-11-02 16:36:03 +00001287YaccFiles := $(filter %.y,$(Sources))
1288ifneq ($(YaccFiles),)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001289
1290.PRECIOUS: $(YaccOutput)
1291
Chris Lattner1f1edce2006-02-15 07:23:05 +00001292all:: $(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs)
Chris Lattner6599c752006-02-15 07:16:57 +00001293
Reid Spencercc2d1e22004-10-30 09:19:36 +00001294# Cancel built-in rules for yacc
1295%.c: %.y
1296%.cpp: %.y
1297%.h: %.y
1298
Reid Spencer25e8a702005-12-21 23:17:06 +00001299# Rule for building the bison based parsers...
Reid Spencer68a24bd2005-08-27 18:50:39 +00001300$(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
Reid Spencercc2d1e22004-10-30 09:19:36 +00001301 $(Echo) "Bisoning $*.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001302 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1303 $(Verb) $(MV) -f $*.tab.c $(PROJ_SRC_DIR)/$*.cpp
1304 $(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
Chris Lattner00950542001-06-06 20:29:01 +00001305
Chris Lattner6599c752006-02-15 07:16:57 +00001306# IFF the .y file has changed since it was last checked into CVS, copy the .y
1307# file to .y.cvs and the generated .cpp/.h file to .cpp.cvs/.h.cvs. We use this
1308# mechanism so that people without flex can build LLVM by copying the .cvs files
1309# to the source location and building them.
1310$(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1311$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattneraf2f3512006-02-16 05:10:48 +00001312 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs || \
Chris Lattner6599c752006-02-15 07:16:57 +00001313 ($(CP) $< $@; \
Chris Lattner1f1edce2006-02-15 07:23:05 +00001314 $(CP) $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs; \
Chris Lattner6599c752006-02-15 07:16:57 +00001315 $(CP) $(PROJ_SRC_DIR)/$*.h $(PROJ_SRC_DIR)/$*.h.cvs)
Reid Spencer25e8a702005-12-21 23:17:06 +00001316
Chris Lattner6599c752006-02-15 07:16:57 +00001317
1318$(YaccFiles:%.y=$(ObjDir)/%.o): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
1319
1320YaccOutput := $(YaccFiles:%.y=%.output)
Reid Spencer25e8a702005-12-21 23:17:06 +00001321
Reid Spencer9af3b292004-11-01 07:50:27 +00001322clean-local::
Reid Spencer25e8a702005-12-21 23:17:06 +00001323 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001324endif
Chris Lattner00950542001-06-06 20:29:01 +00001325
Reid Spencercc2d1e22004-10-30 09:19:36 +00001326###############################################################################
1327# OTHER RULES: Other rules needed
1328###############################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +00001329
Chris Lattner30440c62003-01-16 21:06:18 +00001330# To create postscript files from dot files...
John Criswelle0f9ac62003-10-02 19:02:02 +00001331ifneq ($(DOT),false)
Chris Lattner30440c62003-01-16 21:06:18 +00001332%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +00001333 $(DOT) -Tps < $< > $@
John Criswell7a73b802003-06-30 21:59:07 +00001334else
1335%.ps: %.dot
Reid Spencercc2d1e22004-10-30 09:19:36 +00001336 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell7a73b802003-06-30 21:59:07 +00001337endif
Chris Lattner30440c62003-01-16 21:06:18 +00001338
John Criswell7f336952003-09-06 14:44:17 +00001339# This rules ensures that header files that are removed still have a rule for
1340# which they can be "generated." This allows make to ignore them and
1341# reproduce the dependency lists.
John Criswell4b6e5d12003-09-18 18:37:08 +00001342%.h:: ;
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001343%.hpp:: ;
John Criswell7f336952003-09-06 14:44:17 +00001344
Reid Spencercc2d1e22004-10-30 09:19:36 +00001345# Define clean-local to clean the current directory. Note that this uses a
1346# very conservative approach ensuring that empty variables do not cause
1347# errors or disastrous removal.
Reid Spencer3a561f52004-10-23 20:04:14 +00001348clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001349ifneq ($(strip $(ObjDir)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001350 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencere5487ba2004-10-24 07:53:21 +00001351endif
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001352 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001353ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001354 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001355endif
John Criswell7a73b802003-06-30 21:59:07 +00001356
Reid Spencer3d659492004-11-02 16:36:03 +00001357clean-all-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001358 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer3d659492004-11-02 16:36:03 +00001359
Reid Spencercc2d1e22004-10-30 09:19:36 +00001360# Build tags database for Emacs/Xemacs:
Reid Spencer12d79512004-11-12 02:27:36 +00001361tags:: TAGS CTAGS
1362
Reid Spencercc2d1e22004-10-30 09:19:36 +00001363TAGS:
Reid Spencer11fde542005-01-16 02:20:54 +00001364 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1365 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1366 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1367 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spencer12d79512004-11-12 02:27:36 +00001368 -name '*.cpp' -o -name '*.h' | \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001369 $(ETAGS) $(ETAGSFLAGS) -
1370
Reid Spencer12d79512004-11-12 02:27:36 +00001371CTAGS:
Reid Spencer11fde542005-01-16 02:20:54 +00001372 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1373 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1374 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1375 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spencer12d79512004-11-12 02:27:36 +00001376 \( -name '*.cpp' -o -name '*.h' \) -print | \
Reid Spencer11fde542005-01-16 02:20:54 +00001377 ctags -ImtT -o $(PROJ_OBJ_ROOT)/CTAGS -L -
Reid Spencer12d79512004-11-12 02:27:36 +00001378
1379
Reid Spencer3a561f52004-10-23 20:04:14 +00001380###############################################################################
1381# DEPENDENCIES: Include the dependency files if we should
1382###############################################################################
Chris Lattner33ad24a2003-08-22 14:10:16 +00001383ifndef DISABLE_AUTO_DEPENDENCIES
1384
Reid Spencer3a561f52004-10-23 20:04:14 +00001385# If its not one of the cleaning targets
Reid Spencercc2d1e22004-10-30 09:19:36 +00001386ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencer4d71b662004-10-22 21:01:56 +00001387
Reid Spencer3a561f52004-10-23 20:04:14 +00001388# Get the list of dependency files
Reid Spencercc2d1e22004-10-30 09:19:36 +00001389DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Chris Lattner342567c2006-02-14 05:12:00 +00001390DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
Misha Brukman4f7a8cf2003-11-09 21:36:19 +00001391
Reid Spencer3a561f52004-10-23 20:04:14 +00001392-include /dev/null $(DependFiles)
1393
John Criswelld741bcf2003-08-12 18:51:51 +00001394endif
Chris Lattner1ddb6b62003-08-18 17:27:40 +00001395
Reid Spencercc2d1e22004-10-30 09:19:36 +00001396endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001397
Reid Spencer151f8ba2004-10-25 08:27:37 +00001398###############################################################################
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001399# CHECK: Running the test suite
1400###############################################################################
1401
1402check::
Reid Spencer11fde542005-01-16 02:20:54 +00001403 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1404 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001405 $(EchoCmd) Running test suite ; \
Reid Spencer11fde542005-01-16 02:20:54 +00001406 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001407 TESTSUITE=$(TESTSUITE) ; \
1408 else \
1409 $(EchoCmd) No Makefile in test directory ; \
1410 fi ; \
1411 else \
1412 $(EchoCmd) No test directory ; \
1413 fi
1414
1415###############################################################################
Reid Spencercc2d1e22004-10-30 09:19:36 +00001416# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer151f8ba2004-10-25 08:27:37 +00001417###############################################################################
1418
Reid Spencere45ebfa2004-10-26 07:09:33 +00001419#------------------------------------------------------------------------
1420# Define distribution related variables
1421#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +00001422DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1423DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1424TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1425DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1426DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1427DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
Reid Spencer151f8ba2004-10-25 08:27:37 +00001428DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1429 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001430 Makefile.config.in configure autoconf
1431DistOther := $(notdir $(wildcard \
Reid Spencer11fde542005-01-16 02:20:54 +00001432 $(PROJ_SRC_DIR)/*.h \
1433 $(PROJ_SRC_DIR)/*.td \
1434 $(PROJ_SRC_DIR)/*.def \
1435 $(PROJ_SRC_DIR)/*.ll \
1436 $(PROJ_SRC_DIR)/*.in))
Reid Spencercc2d1e22004-10-30 09:19:36 +00001437DistSubDirs := $(SubDirs)
Reid Spencerfbbf3072004-11-29 05:00:33 +00001438DistSources = $(Sources) $(EXTRA_DIST)
1439DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer151f8ba2004-10-25 08:27:37 +00001440
Reid Spencere45ebfa2004-10-26 07:09:33 +00001441#------------------------------------------------------------------------
1442# We MUST build distribution with OBJ_DIR != SRC_DIR
1443#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +00001444ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
Reid Spencere45ebfa2004-10-26 07:09:33 +00001445dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001446 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencere45ebfa2004-10-26 07:09:33 +00001447
Reid Spencere45ebfa2004-10-26 07:09:33 +00001448else
1449
Reid Spencere45ebfa2004-10-26 07:09:33 +00001450#------------------------------------------------------------------------
Reid Spencere45ebfa2004-10-26 07:09:33 +00001451# Prevent attempt to run dist targets from anywhere but the top level
1452#------------------------------------------------------------------------
1453ifneq ($(LEVEL),.)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001454dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencer11fde542005-01-16 02:20:54 +00001455 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001456else
1457
1458#------------------------------------------------------------------------
1459# Provide the top level targets
1460#------------------------------------------------------------------------
1461
Reid Spencercc2d1e22004-10-30 09:19:36 +00001462dist-gzip:: $(DistTarGZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001463
Reid Spencer345235ca2004-12-04 22:34:09 +00001464$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001465 $(Echo) Packing gzipped distribution tar file.
Reid Spencer11fde542005-01-16 02:20:54 +00001466 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
Reid Spencerfbbf3072004-11-29 05:00:33 +00001467 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencere45ebfa2004-10-26 07:09:33 +00001468
Reid Spencercc2d1e22004-10-30 09:19:36 +00001469dist-bzip2:: $(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001470
Reid Spencer345235ca2004-12-04 22:34:09 +00001471$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001472 $(Echo) Packing bzipped distribution tar file.
Reid Spencer11fde542005-01-16 02:20:54 +00001473 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
Reid Spencerfbbf3072004-11-29 05:00:33 +00001474 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001475
Reid Spencercc2d1e22004-10-30 09:19:36 +00001476dist-zip:: $(DistZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001477
Reid Spencer345235ca2004-12-04 22:34:09 +00001478$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001479 $(Echo) Packing zipped distribution file.
1480 $(Verb) rm -f $(DistZip)
Reid Spencer11fde542005-01-16 02:20:54 +00001481 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001482
1483dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001484 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001485
Reid Spencerf8f57402005-01-28 19:52:32 +00001486DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
Reid Spencere45ebfa2004-10-26 07:09:33 +00001487
Reid Spencer345235ca2004-12-04 22:34:09 +00001488dist-check:: $(DistTarGZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001489 $(Echo) Checking distribution tar file.
1490 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001491 $(RM) -rf $(DistCheckDir) ; \
1492 fi
Reid Spencercc2d1e22004-10-30 09:19:36 +00001493 $(Verb) $(MKDIR) $(DistCheckDir)
1494 $(Verb) cd $(DistCheckDir) && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001495 $(MKDIR) $(DistCheckDir)/build && \
1496 $(MKDIR) $(DistCheckDir)/install && \
1497 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1498 cd build && \
1499 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
Reid Spencer45eeed92005-05-24 02:33:20 +00001500 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
Reid Spencer345235ca2004-12-04 22:34:09 +00001501 $(MAKE) all && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001502 $(MAKE) check && \
1503 $(MAKE) install && \
1504 $(MAKE) uninstall && \
1505 $(MAKE) dist && \
1506 $(MAKE) clean && \
1507 $(MAKE) dist-clean && \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001508 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001509
1510dist-clean::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001511 $(Echo) Cleaning distribution files
Reid Spencer345235ca2004-12-04 22:34:09 +00001512 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1513 $(DistCheckDir)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001514
1515endif
1516
1517#------------------------------------------------------------------------
1518# Provide the recursive distdir target for building the distribution directory
1519#------------------------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +00001520distdir: $(DistDir)/.makedistdir
1521$(DistDir)/.makedistdir: $(DistSources)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001522 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001523 if test -d "$(DistDir)" ; then \
1524 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1525 exit 1 ; \
1526 fi ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001527 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001528 $(RM) -rf $(DistDir); \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001529 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer854071c2006-04-10 16:46:04 +00001530 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001531 fi
Reid Spencerfbbf3072004-11-29 05:00:33 +00001532 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001533 $(Verb) $(MKDIR) $(DistDir)
Reid Spencer11fde542005-01-16 02:20:54 +00001534 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1535 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001536 for file in $(DistFiles) ; do \
1537 case "$$file" in \
Reid Spencer11fde542005-01-16 02:20:54 +00001538 $(PROJ_SRC_DIR)/*) \
Reid Spencer345235ca2004-12-04 22:34:09 +00001539 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1540 ;; \
Reid Spencer11fde542005-01-16 02:20:54 +00001541 $(PROJ_SRC_ROOT)/*) \
Reid Spencer345235ca2004-12-04 22:34:09 +00001542 file=`echo "$$file" | \
1543 sed "s#^$$srcrootstrip/##"` \
1544 ;; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001545 esac; \
Reid Spencer11fde542005-01-16 02:20:54 +00001546 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1547 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1548 from_dir="$(PROJ_SRC_DIR)" ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001549 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001550 from_dir=. ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001551 fi ; \
1552 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001553 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1554 to_dir="$(DistDir)/$$dir"; \
1555 $(MKDIR) "$$to_dir" ; \
1556 else \
1557 to_dir="$(DistDir)"; \
1558 fi; \
1559 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1560 if test -n "$$mid_dir" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001561 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001562 fi ; \
1563 if test -d "$$from_dir/$$file"; then \
Reid Spencer11fde542005-01-16 02:20:54 +00001564 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1565 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
Reid Spencer45eeed92005-05-24 02:33:20 +00001566 cd $(PROJ_SRC_DIR) ; \
1567 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1568 ( cd $$to_dir ; $(TAR) xf - ) ; \
1569 cd $(PROJ_OBJ_DIR) ; \
1570 else \
1571 cd $$from_dir ; \
1572 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1573 ( cd $$to_dir ; $(TAR) xf - ) ; \
1574 cd $(PROJ_OBJ_DIR) ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001575 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001576 elif test -f "$$from_dir/$$file" ; then \
Reid Spencerc3719842004-12-16 18:26:53 +00001577 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001578 elif test -L "$$from_dir/$$file" ; then \
Reid Spencerc3719842004-12-16 18:26:53 +00001579 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001580 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer345235ca2004-12-04 22:34:09 +00001581 $(EchoCmd) "===== WARNING: Distribution Source " \
1582 "$$from_dir/$$file Not Found!" ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001583 elif test "$(Verb)" != '@' ; then \
1584 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001585 fi; \
1586 done
Reid Spencercc2d1e22004-10-30 09:19:36 +00001587 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001588 if test "$$subdir" \!= "." ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001589 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001590 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer854071c2006-04-10 16:46:04 +00001591 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
Reid Spencerbac3ca22006-04-07 16:06:18 +00001592 DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001593 fi; \
1594 done
Reid Spencer345235ca2004-12-04 22:34:09 +00001595 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer45eeed92005-05-24 02:33:20 +00001596 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
Chris Lattner77efe272006-02-14 04:27:15 +00001597 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1598 -name .svn \) -print` ;\
Reid Spencer345235ca2004-12-04 22:34:09 +00001599 $(MAKE) dist-hook ; \
1600 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1601 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1602 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1603 -o ! -type d ! -perm -444 -exec \
1604 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1605 || chmod -R a+r $(DistDir) ; \
1606 fi
Reid Spencer151f8ba2004-10-25 08:27:37 +00001607
Reid Spencercc2d1e22004-10-30 09:19:36 +00001608# This is invoked by distdir target, define it as a no-op to avoid errors if not
1609# defined by user.
Reid Spencer151f8ba2004-10-25 08:27:37 +00001610dist-hook::
1611
Reid Spencere53e3972004-10-22 23:06:30 +00001612endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001613
1614###############################################################################
Reid Spencere5487ba2004-10-24 07:53:21 +00001615# TOP LEVEL - targets only to apply at the top level directory
1616###############################################################################
1617
1618ifeq ($(LEVEL),.)
1619
1620#------------------------------------------------------------------------
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001621# Install support for the project's include files:
Reid Spencere5487ba2004-10-24 07:53:21 +00001622#------------------------------------------------------------------------
1623install-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001624 $(Echo) Installing include files
Reid Spencer11fde542005-01-16 02:20:54 +00001625 $(Verb) $(MKDIR) $(PROJ_includedir)
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001626 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
Reid Spencer11fde542005-01-16 02:20:54 +00001627 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer2edabc02005-02-16 15:54:03 +00001628 for hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
1629 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS ` ; do \
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001630 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1631 if test \! -d "$$instdir" ; then \
1632 $(EchoCmd) Making install directory $$instdir ; \
1633 $(MKDIR) $$instdir ;\
1634 fi ; \
1635 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer2edabc02005-02-16 15:54:03 +00001636 done ; \
Reid Spencere5487ba2004-10-24 07:53:21 +00001637 fi
Reid Spencer443045a2005-12-23 22:27:56 +00001638ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001639 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
Reid Spencer2edabc02005-02-16 15:54:03 +00001640 cd $(PROJ_OBJ_ROOT)/include && \
Reid Spencer443045a2005-12-23 22:27:56 +00001641 for hdr in `find . -type f -print | grep -v CVS` ; do \
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001642 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer2edabc02005-02-16 15:54:03 +00001643 done ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001644 fi
Reid Spencer443045a2005-12-23 22:27:56 +00001645endif
Reid Spencere5487ba2004-10-24 07:53:21 +00001646
1647uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001648 $(Echo) Uninstalling include files
Reid Spencer11fde542005-01-16 02:20:54 +00001649 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1650 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencere5487ba2004-10-24 07:53:21 +00001651 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
Chris Lattnerd25ad612006-02-14 04:25:54 +00001652 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' \
1653 -o -name '*.in' ')' -print ')' | \
1654 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001655 cd $(PROJ_SRC_ROOT)/include && \
Chris Lattnerd25ad612006-02-14 04:25:54 +00001656 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1657 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001658 fi
Reid Spencere5487ba2004-10-24 07:53:21 +00001659
Reid Spencere5487ba2004-10-24 07:53:21 +00001660endif
1661
Reid Spencer4d71b662004-10-22 21:01:56 +00001662#------------------------------------------------------------------------
1663# Print out the directories used for building
Reid Spencercc2d1e22004-10-30 09:19:36 +00001664#------------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001665printvars::
Reid Spencer11fde542005-01-16 02:20:54 +00001666 $(Echo) "BuildMode : " '$(BuildMode)'
1667 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1668 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1669 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1670 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1671 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1672 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1673 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1674 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1675 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1676 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
Reid Spencer1a9a69c2005-02-16 16:13:02 +00001677 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
Reid Spencer11fde542005-01-16 02:20:54 +00001678 $(Echo) "UserTargets : " '$(UserTargets)'
1679 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1680 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1681 $(Echo) "ObjDir : " '$(ObjDir)'
1682 $(Echo) "LibDir : " '$(LibDir)'
1683 $(Echo) "ToolDir : " '$(ToolDir)'
1684 $(Echo) "ExmplDir : " '$(ExmplDir)'
1685 $(Echo) "Sources : " '$(Sources)'
1686 $(Echo) "TDFiles : " '$(TDFiles)'
1687 $(Echo) "INCFiles : " '$(INCFiles)'
1688 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
Reid Spencere0acb762005-03-01 16:27:06 +00001689 $(Echo) "PreConditions: " '$(PreConditions)'
Reid Spencer11fde542005-01-16 02:20:54 +00001690 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1691 $(Echo) "Compile.C : " '$(Compile.C)'
1692 $(Echo) "Archive : " '$(Archive)'
1693 $(Echo) "YaccFiles : " '$(YaccFiles)'
1694 $(Echo) "LexFiles : " '$(LexFiles)'
1695 $(Echo) "Module : " '$(Module)'
Reid Spencer755bcf02005-08-24 10:43:10 +00001696 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
Reid Spencerf9f431c2006-04-09 23:41:14 +00001697 $(Echo) "SubDirs : " '$(SubDirs)'