blob: 96f2343fe04cb1257ee43026060753166281aa42 [file] [log] [blame]
Misha Brukman7426c892004-04-24 00:10:56 +00001#===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
2#
John Criswell23e43fb2003-10-21 14:33:46 +00003# The LLVM Compiler Infrastructure
4#
5# This file was developed by the LLVM research group and is distributed under
6# the University of Illinois Open Source License. See LICENSE.TXT for details.
7#
Misha Brukman7426c892004-04-24 00:10:56 +00008#===------------------------------------------------------------------------===#
Chris Lattner2f7c9632001-06-06 20:29:01 +00009#
Reid Spencer81cd0492004-10-23 20:04:14 +000010# This file is included by all of the LLVM makefiles. For details on how to use
11# it properly, please see the document MakefileGuide.html in the docs directory.
Chris Lattner2e9fc94a2003-08-15 03:02:52 +000012#
Chris Lattnerb8e7aa02006-02-14 04:27:15 +000013#===-----------------------------------------------------------------------====#
Chris Lattner2f7c9632001-06-06 20:29:01 +000014
Reid Spencerf88808a2004-10-30 09:19:36 +000015################################################################################
Reid Spencer81cd0492004-10-23 20:04:14 +000016# TARGETS: Define standard targets that can be invoked
Reid Spencerf88808a2004-10-30 09:19:36 +000017################################################################################
John Criswell3ef61af2003-06-30 21:59:07 +000018
Chris Lattner2f7c9632001-06-06 20:29:01 +000019#--------------------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +000020# Define the various target sets
21#--------------------------------------------------------------------
Chris Lattner661a7142004-12-03 21:05:57 +000022RecursiveTargets := all clean clean-all install uninstall install-bytecode
Reid Spencer8b5ebe52004-12-06 05:35:13 +000023LocalTargets := all-local clean-local clean-all-local check-local \
Reid Spencerd4bd3752004-12-03 20:08:48 +000024 install-local printvars uninstall-local \
25 install-bytecode-local
Reid Spencer8b5ebe52004-12-06 05:35:13 +000026TopLevelTargets := check dist dist-check dist-clean tags dist-gzip dist-bzip2 \
Reid Spencerf88808a2004-10-30 09:19:36 +000027 dist-zip
28UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
29InternalTargets := preconditions distdir dist-hook
Reid Spencer81cd0492004-10-23 20:04:14 +000030
Reid Spencerf88808a2004-10-30 09:19:36 +000031################################################################################
Reid Spencer77a46d22004-10-26 22:26:33 +000032# INITIALIZATION: Basic things the makefile needs
Reid Spencerf88808a2004-10-30 09:19:36 +000033################################################################################
34
35#--------------------------------------------------------------------
36# Set the VPATH so that we can find source files.
37#--------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +000038VPATH=$(PROJ_SRC_DIR)
Reid Spencer77a46d22004-10-26 22:26:33 +000039
40#--------------------------------------------------------------------
41# Reset the list of suffixes we know how to build
42#--------------------------------------------------------------------
43.SUFFIXES:
Chris Lattnerb3eb31f2006-01-27 22:13:12 +000044.SUFFIXES: .c .cpp .cc .h .hpp .y .l .lo .o .a .bc .td .ps .dot .ll
Reid Spencerf88808a2004-10-30 09:19:36 +000045.SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
Reid Spencer77a46d22004-10-26 22:26:33 +000046
Reid Spencer81cd0492004-10-23 20:04:14 +000047#--------------------------------------------------------------------
48# Mark all of these targets as phony to avoid implicit rule search
49#--------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +000050.PHONY: $(UserTargets) $(InternalTargets)
Reid Spencer81cd0492004-10-23 20:04:14 +000051
52#--------------------------------------------------------------------
Reid Spencer77a46d22004-10-26 22:26:33 +000053# Make sure all the user-target rules are double colon rules and
54# they are defined first.
Reid Spencer81cd0492004-10-23 20:04:14 +000055#--------------------------------------------------------------------
56
Reid Spencerf88808a2004-10-30 09:19:36 +000057$(UserTargets)::
Reid Spencer100080c2004-10-25 08:27:37 +000058
Reid Spencer77a46d22004-10-26 22:26:33 +000059################################################################################
60# PRECONDITIONS: that which must be built/checked first
61################################################################################
62
Reid Spencerd4bd3752004-12-03 20:08:48 +000063SrcMakefiles := $(filter %Makefile %Makefile.tests,\
Reid Spencerba6a3db2005-01-16 02:20:54 +000064 $(wildcard $(PROJ_SRC_DIR)/Makefile*))
65ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
66ConfigureScript := $(PROJ_SRC_ROOT)/configure
67ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
68MakefileConfigIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
69MakefileCommonIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
70MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
71MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
72PreConditions := $(ConfigStatusScript) $(ObjMakefiles)
73ifneq ($(MakefileCommonIn),)
74PreConditions += $(MakefileCommon)
75endif
76ifneq ($(MakefileConfigIn),)
77PreConditions += $(MakefileConfig)
78endif
Reid Spencer77a46d22004-10-26 22:26:33 +000079
Reid Spencer53846bc2005-08-25 04:59:49 +000080preconditions: $(PreConditions)
Reid Spencer77a46d22004-10-26 22:26:33 +000081
82#------------------------------------------------------------------------
83# Make sure the BUILT_SOURCES are built first
84#------------------------------------------------------------------------
Reid Spencer97e40f12004-12-16 07:15:16 +000085$(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
Reid Spencer77a46d22004-10-26 22:26:33 +000086
87clean-local::
88ifneq ($(strip $(BUILT_SOURCES)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +000089 -$(Verb) $(RM) -f $(BUILT_SOURCES)
Reid Spencer77a46d22004-10-26 22:26:33 +000090endif
91
Reid Spencerba6a3db2005-01-16 02:20:54 +000092ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
Reid Spencer55814372004-12-16 08:00:46 +000093spotless:
Reid Spencer55814372004-12-16 08:00:46 +000094 $(Verb) if test -x config.status ; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +000095 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
Reid Spencer7ef8e662004-12-17 07:45:03 +000096 $(MKDIR) .spotless.save ; \
97 $(MV) config.status .spotless.save ; \
98 $(MV) mklib .spotless.save ; \
99 $(MV) projects .spotless.save ; \
Reid Spencer55814372004-12-16 08:00:46 +0000100 $(RM) -rf * ; \
Reid Spencer7ef8e662004-12-17 07:45:03 +0000101 $(MV) .spotless.save/config.status . ; \
102 $(MV) .spotless.save/mklib . ; \
103 $(MV) .spotless.save/projects . ; \
104 $(RM) -rf .spotless.save ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000105 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
Reid Spencer7ef8e662004-12-17 07:45:03 +0000106 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
107 $(ConfigStatusScript) ; \
Reid Spencer55814372004-12-16 08:00:46 +0000108 else \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000109 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
Reid Spencer55814372004-12-16 08:00:46 +0000110 fi
Reid Spencerc49a8632005-12-21 23:17:06 +0000111else
112spotless:
113 $(EchoCmd) "spotless target not supported for objdir == srcdir"
Reid Spencer55814372004-12-16 08:00:46 +0000114endif
115
Reid Spencerf88808a2004-10-30 09:19:36 +0000116$(BUILT_SOURCES) : $(ObjMakefiles)
Reid Spencerb7f710a2004-10-28 00:41:43 +0000117
Reid Spencer77a46d22004-10-26 22:26:33 +0000118#------------------------------------------------------------------------
119# Make sure we're not using a stale configuration
120#------------------------------------------------------------------------
Reid Spencerafdc82c2004-12-16 18:26:53 +0000121reconfigure:
Reid Spencerba6a3db2005-01-16 02:20:54 +0000122 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
123 $(Verb) cd $(PROJ_OBJ_ROOT) && \
124 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
125 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
Reid Spencer35655d62004-12-24 03:36:31 +0000126 fi ; \
Reid Spencerafdc82c2004-12-16 18:26:53 +0000127 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
128 $(ConfigStatusScript)
129
Reid Spencerf88808a2004-10-30 09:19:36 +0000130.PRECIOUS: $(ConfigStatusScript)
131$(ConfigStatusScript): $(ConfigureScript)
132 $(Echo) Reconfiguring with $<
Reid Spencerba6a3db2005-01-16 02:20:54 +0000133 $(Verb) cd $(PROJ_OBJ_ROOT) && \
134 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
135 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
Reid Spencer35655d62004-12-24 03:36:31 +0000136 fi ; \
Reid Spencer50f34872004-11-29 12:37:44 +0000137 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
138 $(ConfigStatusScript)
Reid Spencer77a46d22004-10-26 22:26:33 +0000139
Reid Spencer83bde552005-08-25 04:44:18 +0000140#------------------------------------------------------------------------
Reid Spencer77a46d22004-10-26 22:26:33 +0000141# Make sure the configuration makefile is up to date
142#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +0000143ifneq ($(MakefileConfigIn),)
144$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
Reid Spencerf88808a2004-10-30 09:19:36 +0000145 $(Echo) Regenerating $@
Reid Spencerba6a3db2005-01-16 02:20:54 +0000146 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
147endif
148
149ifneq ($(MakefileCommonIn),)
150$(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
151 $(Echo) Regenerating $@
152 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
153endif
Reid Spencer77a46d22004-10-26 22:26:33 +0000154
155#------------------------------------------------------------------------
156# If the Makefile in the source tree has been updated, copy it over into the
157# build tree. But, only do this if the source and object makefiles differ
158#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +0000159ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
Reid Spencer77a46d22004-10-26 22:26:33 +0000160
Reid Spencerba6a3db2005-01-16 02:20:54 +0000161Makefile: $(PROJ_SRC_DIR)/Makefile
Reid Spencerf88808a2004-10-30 09:19:36 +0000162 $(Echo) "Updating Makefile"
163 $(Verb) $(MKDIR) $(@D)
Reid Spencerafdc82c2004-12-16 18:26:53 +0000164 $(Verb) $(CP) -f $< $@
Reid Spencer77a46d22004-10-26 22:26:33 +0000165
166# Copy the Makefile.* files unless we're in the root directory which avoids
167# the copying of Makefile.config.in or other things that should be explicitly
168# taken care of.
Reid Spencerba6a3db2005-01-16 02:20:54 +0000169$(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
Reid Spencerd94bb332004-10-26 23:10:00 +0000170 @case '$?' in \
171 *Makefile.rules) ;; \
172 *.in) ;; \
Reid Spencerf88808a2004-10-30 09:19:36 +0000173 *) $(Echo) "Updating $(@F)" ; \
Reid Spencerd94bb332004-10-26 23:10:00 +0000174 $(MKDIR) $(@D) ; \
Reid Spencerafdc82c2004-12-16 18:26:53 +0000175 $(CP) -f $< $@ ;; \
Reid Spencerd94bb332004-10-26 23:10:00 +0000176 esac
177
Reid Spencer77a46d22004-10-26 22:26:33 +0000178endif
179
180#------------------------------------------------------------------------
181# Set up the basic dependencies
182#------------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000183$(UserTargets):: $(PreConditions)
Reid Spencer77a46d22004-10-26 22:26:33 +0000184
185all:: all-local
Reid Spencer81cd0492004-10-23 20:04:14 +0000186clean:: clean-local
Reid Spencer9d0c1e02004-11-02 16:36:03 +0000187clean-all:: clean-local clean-all-local
Reid Spencer77a46d22004-10-26 22:26:33 +0000188install:: install-local
189uninstall:: uninstall-local
Reid Spencer77a46d22004-10-26 22:26:33 +0000190install-local:: all-local
Reid Spencerd4bd3752004-12-03 20:08:48 +0000191install-bytecode:: install-bytecode-local
Reid Spencer81cd0492004-10-23 20:04:14 +0000192
193###############################################################################
194# VARIABLES: Set up various variables based on configuration data
195###############################################################################
196
197#--------------------------------------------------------------------
198# Variables derived from configuration we are building
Chris Lattner2f7c9632001-06-06 20:29:01 +0000199#--------------------------------------------------------------------
200
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000201ifdef ENABLE_PROFILING
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000202 BuildMode := Profile
Chris Lattner98c79c32006-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 Lattnerc2bd7cf2003-03-14 20:25:22 +0000206else
207 ifdef ENABLE_OPTIMIZED
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000208 BuildMode := Release
Reid Spencer34982d82005-01-02 17:43:20 +0000209 # Don't use -fomit-frame-pointer on FreeBSD
210 ifneq ($(OS),FreeBSD)
Chris Lattner040c1102006-05-24 18:34:08 +0000211 # Don't use -fomit-frame-pointer on Darwin, it breaks backtraces.
212 ifneq ($(OS),Darwin)
Reid Spencer34982d82005-01-02 17:43:20 +0000213 OmitFramePointer := -fomit-frame-pointer
214 endif
Chris Lattner040c1102006-05-24 18:34:08 +0000215 endif
Chris Lattner98c79c32006-03-21 01:06:41 +0000216 CXX.Flags := -O3 -finline-functions -felide-constructors $(OmitFramePointer)
217 C.Flags := -O3 $(OmitFramePointer)
218 LD.Flags := -O3
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000219 else
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000220 BuildMode := Debug
Chris Lattner98c79c32006-03-21 01:06:41 +0000221 CXX.Flags := -g
222 C.Flags := -g
223 LD.Flags := -g
Reid Spencerf206bd72004-10-22 21:01:56 +0000224 KEEP_SYMBOLS := 1
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000225 endif
226endif
227
Reid Spencer15b85092006-04-10 16:46:04 +0000228# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
229# then disable assertions by defining the appropriate preprocessor symbols.
Reid Spencerece13582006-04-09 23:41:14 +0000230ifdef DISABLE_ASSERTIONS
Reid Spencer056f0222006-04-07 16:06:18 +0000231 BuildMode := $(BuildMode)-Asserts
Chris Lattner98c79c32006-03-21 01:06:41 +0000232 CXX.Flags += -DNDEBUG
233 C.Flags += -DNDEBUG
Reid Spencerece13582006-04-09 23:41:14 +0000234else
235 CXX.Flags += -D_DEBUG
236 C.Flags += -D_DEBUG
Chris Lattner98c79c32006-03-21 01:06:41 +0000237endif
238
Reid Spencer6f682b72006-03-22 15:59:55 +0000239CXX.Flags += $(CXXFLAGS)
240C.Flags += $(CFLAGS)
241CPP.BaseFlags += $(CPPFLAGS)
242LD.Flags += $(LDFLAGS)
243AR.Flags := cru
Reid Spencerf88808a2004-10-30 09:19:36 +0000244LibTool.Flags := --tag=CXX
Reid Spencer81cd0492004-10-23 20:04:14 +0000245
Andrew Lenharth9a98def2005-02-13 03:41:10 +0000246#Make Floating point ieee complient on alpha
247ifeq ($(ARCH),Alpha)
Reid Spencer6f682b72006-03-22 15:59:55 +0000248 CXX.Flags += -mieee
249 CPP.BaseFlags += -mieee
Andrew Lenharth9a98def2005-02-13 03:41:10 +0000250endif
251
Reid Spencer81cd0492004-10-23 20:04:14 +0000252#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000253# Directory locations
Reid Spencer81cd0492004-10-23 20:04:14 +0000254#--------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +0000255ObjDir := $(PROJ_OBJ_DIR)/$(BuildMode)
256LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
257ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
258ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000259LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer0dbf1012004-11-18 20:04:39 +0000260LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencerb9f8de62004-12-28 07:59:22 +0000261LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer2bba41c2004-12-22 05:57:21 +0000262CFERuntimeLibDir := $(LLVMGCCDIR)/lib
John Criswell3ef61af2003-06-30 21:59:07 +0000263
Reid Spencer81cd0492004-10-23 20:04:14 +0000264#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000265# Full Paths To Compiled Tools and Utilities
Reid Spencer81cd0492004-10-23 20:04:14 +0000266#--------------------------------------------------------------------
Reid Spencerb12e2902005-01-14 16:33:36 +0000267EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
268Echo = @$(EchoCmd)
Reid Spencerf88808a2004-10-30 09:19:36 +0000269ifndef LIBTOOL
Reid Spencerf206bd72004-10-22 21:01:56 +0000270LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencerf88808a2004-10-30 09:19:36 +0000271endif
272ifndef LLVMAS
273LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
274endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000275ifndef TBLGEN
276TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
277endif
Chris Lattner0ea40c92004-11-29 19:47:58 +0000278ifndef GCCAS
279GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
280endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000281ifndef GCCLD
282GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
283endif
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000284ifndef LDIS
285LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
286endif
287ifndef LLI
288LLI := $(LLVMToolDir)/lli$(EXEEXT)
289endif
Alkis Evlogimenos24340582005-02-27 10:21:37 +0000290ifndef LLC
291LLC := $(LLVMToolDir)/llc$(EXEEXT)
292endif
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000293ifndef LOPT
Alkis Evlogimenos7c7705d2004-12-13 18:08:29 +0000294LOPT := $(LLVMToolDir)/opt$(EXEEXT)
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000295endif
Alkis Evlogimenos7c04a3d2005-02-02 00:40:15 +0000296ifndef LBUGPOINT
297LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
298endif
299
John Criswelldc665012005-01-03 17:42:57 +0000300LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
301LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000302
Reid Spencer81cd0492004-10-23 20:04:14 +0000303#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000304# Adjust to user's request
Reid Spencer81cd0492004-10-23 20:04:14 +0000305#--------------------------------------------------------------------
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000306
Reid Spencer87e645c2005-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 Spencerf88808a2004-10-30 09:19:36 +0000311 LD.Flags += -rpath $(LibDir)
Reid Spencer87e645c2005-01-11 04:31:07 +0000312 ifdef LOADABLE_MODULE
313 LD.Flags += -module
314 endif
315else
316 LibTool.Flags += --tag=disable-shared
John Criswell3601f372003-07-31 20:58:51 +0000317endif
318
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000319ifdef TOOL_VERBOSE
320 C.Flags += -v
321 CXX.Flags += -v
322 LD.Flags += -v
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000323 VERBOSE := 1
324endif
325
Reid Spencer81cd0492004-10-23 20:04:14 +0000326# Adjust settings for verbose mode
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000327ifndef VERBOSE
Reid Spencerf88808a2004-10-30 09:19:36 +0000328 Verb := @
329 LibTool.Flags += --silent
330 AR.Flags += >/dev/null 2>/dev/null
Reid Spencerba6a3db2005-01-16 02:20:54 +0000331 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
Reid Spencer100080c2004-10-25 08:27:37 +0000332else
Reid Spencerf88808a2004-10-30 09:19:36 +0000333 ConfigureScriptFLAGS :=
Misha Brukman1326a7c2002-09-12 16:05:39 +0000334endif
335
Vikram S. Adved141c282002-09-18 11:55:13 +0000336# By default, strip symbol information from executable
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000337ifndef KEEP_SYMBOLS
Reid Spencerf88808a2004-10-30 09:19:36 +0000338 Strip := $(PLATFORMSTRIPOPTS)
339 StripWarnMsg := "(without symbols)"
Reid Spencer247a10e2005-02-24 07:12:43 +0000340 Install.StripFlag += -s
Vikram S. Adved141c282002-09-18 11:55:13 +0000341endif
342
Reid Spencer81cd0492004-10-23 20:04:14 +0000343# Adjust linker flags for building an executable
Reid Spencerf206bd72004-10-22 21:01:56 +0000344ifdef TOOLNAME
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000345ifdef EXAMPLE_TOOL
346 LD.Flags += -rpath $(ExmplDir) -export-dynamic
347else
Reid Spencerf88808a2004-10-30 09:19:36 +0000348 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000349endif
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000350endif
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000351
Reid Spencer81cd0492004-10-23 20:04:14 +0000352#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000353# Options To Invoke Tools
Reid Spencer81cd0492004-10-23 20:04:14 +0000354#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000355
356CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
357
Duraid Madina60c9a3c2005-05-16 06:38:09 +0000358ifeq ($(OS),HP-UX)
Duraid Madina1f898af2006-02-15 03:20:16 +0000359 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
Duraid Madina60c9a3c2005-05-16 06:38:09 +0000360endif
361
Chris Lattnerd81eba52006-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
Chris Lattnerf2f4aed2006-04-19 18:45:29 +0000365 CompileCommonOpts += \
366 -arch i386 -arch ppc -isysroot /Developer/SDKs/MACOSX10.4u.sdk/
367 Relink.Flags := -XCClinker -arch -XCClinker i386 -XCClinker -arch \
368 -XCClinker ppc -XCClinker \
369 -isysroot -XCClinker /Developer/SDKs/MACOSX10.4u.sdk/
Chris Lattnerd81eba52006-04-06 06:30:15 +0000370 DISABLE_AUTO_DEPENDENCIES=1
371endif
372
Evan Chengbb66ec22006-04-07 08:31:56 +0000373# Temporary workaround for a Mac OSX / x86 compatibility issue.
374ifeq ($(OS),Darwin)
375ifeq ($(ARCH),x86)
376 CXX.Flags += -fno-use-cxa-atexit
377endif
Evan Cheng1e86e672006-04-07 08:10:09 +0000378endif
379
Reid Spencer6f682b72006-03-22 15:59:55 +0000380LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
381CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
382# All -I flags should go here, so that they don't confuse llvm-config.
383CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
384 -I$(PROJ_OBJ_ROOT)/include \
385 -I$(PROJ_SRC_ROOT)/include \
386 -I$(LLVM_OBJ_ROOT)/include \
387 -I$(LLVM_SRC_ROOT)/include \
388 $(CPP.BaseFlags)
Reid Spencerf206bd72004-10-22 21:01:56 +0000389
Reid Spencerf88808a2004-10-30 09:19:36 +0000390Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
391LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
Reid Spencer2bba41c2004-12-22 05:57:21 +0000392BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000393 $(C.Flags)
Chris Lattnerbb087952005-10-05 00:28:41 +0000394Preprocess.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -E $(C.Flags)
395
Reid Spencerf88808a2004-10-30 09:19:36 +0000396Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
397LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
Reid Spencerc005fba2004-12-24 14:47:34 +0000398BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000399 $(CXX.Flags)
Chris Lattnerbb087952005-10-05 00:28:41 +0000400Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
Reid Spencerf88808a2004-10-30 09:19:36 +0000401Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencer540c1b92006-05-16 06:51:02 +0000402 $(CXX.Flags) $(CompileCommonOpts) $(LD.Flags) $(Strip)
Reid Spencerf88808a2004-10-30 09:19:36 +0000403Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencer540c1b92006-05-16 06:51:02 +0000404 $(CXX.Flags) $(CompileCommonOpts) $(Relink.Flags)
Reid Spencerfe0a01e2005-02-16 16:13:02 +0000405LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
406 $(Install.Flags)
Reid Spencer247a10e2005-02-24 07:12:43 +0000407ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
Reid Spencer6f682b72006-03-22 15:59:55 +0000408ScriptInstall = $(INSTALL) -m 0755
Reid Spencer247a10e2005-02-24 07:12:43 +0000409DataInstall = $(INSTALL) -m 0644
Vladimir Prus788db2c2006-05-16 06:39:36 +0000410TableGen = $(TBLGEN) -I $(PROJ_SRC_DIR) -I$(PROJ_SRC_ROOT)/include \
411 -I $(PROJ_SRC_ROOT)/lib/Target
Reid Spencerf88808a2004-10-30 09:19:36 +0000412Archive = $(AR) $(AR.Flags)
Reid Spencer32f7e422004-12-02 09:28:21 +0000413LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencerf206bd72004-10-22 21:01:56 +0000414ifdef RANLIB
Reid Spencer81cd0492004-10-23 20:04:14 +0000415Ranlib = $(RANLIB)
Reid Spencerf206bd72004-10-22 21:01:56 +0000416else
Reid Spencer81cd0492004-10-23 20:04:14 +0000417Ranlib = ranlib
John Criswell3ef61af2003-06-30 21:59:07 +0000418endif
419
Chris Lattner2f7c9632001-06-06 20:29:01 +0000420#----------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +0000421# Get the list of source files and compute object file
422# names from them.
Reid Spencer81cd0492004-10-23 20:04:14 +0000423#----------------------------------------------------------
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000424
425ifndef SOURCES
426 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
427 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
428 $(PROJ_SRC_DIR)/*.l))
Reid Spencerf88808a2004-10-30 09:19:36 +0000429else
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000430 Sources := $(SOURCES)
431endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000432
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000433ifdef BUILT_SOURCES
434Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Reid Spencer81546582004-12-04 22:34:09 +0000435endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000436
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000437BaseNameSources := $(sort $(basename $(Sources)))
438
439ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
440ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
441ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
442
Reid Spencer81cd0492004-10-23 20:04:14 +0000443###############################################################################
444# DIRECTORIES: Handle recursive descent of directory structure
445###############################################################################
John Criswell3601f372003-07-31 20:58:51 +0000446
Chris Lattner2f7c9632001-06-06 20:29:01 +0000447#---------------------------------------------------------
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000448# Provide rules to make install dirs. This must be early
449# in the file so they get built before dependencies
450#---------------------------------------------------------
451
Reid Spencer90b689d2005-05-19 20:26:14 +0000452$(PROJ_bindir): $(PROJ_bindir)/.dir
453$(PROJ_libdir): $(PROJ_libdir)/.dir
454$(PROJ_includedir): $(PROJ_includedir)/.dir
455$(PROJ_etcdir): $(PROJ_etcdir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000456
Reid Spencerf88808a2004-10-30 09:19:36 +0000457# To create other directories, as needed, and timestamp their creation
458%/.dir:
459 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfc66af42004-11-29 05:00:33 +0000460 $(Verb) $(DATE) > $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000461
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000462.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
463.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000464
465#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000466# Handle the DIRS options for sequential construction
Chris Lattner2f7c9632001-06-06 20:29:01 +0000467#---------------------------------------------------------
468
Reid Spencerf88808a2004-10-30 09:19:36 +0000469SubDirs :=
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000470ifdef DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000471SubDirs += $(DIRS)
472$(RecursiveTargets)::
473 $(Verb) for dir in $(DIRS); do \
Reid Spencerf206bd72004-10-22 21:01:56 +0000474 if [ ! -f $$dir/Makefile ]; then \
475 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000476 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000477 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000478 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattner539a23c2002-09-17 23:35:02 +0000479 done
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000480endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000481
Reid Spencer81cd0492004-10-23 20:04:14 +0000482#---------------------------------------------------------
483# Handle the EXPERIMENTAL_DIRS options ensuring success
484# after each directory is built.
485#---------------------------------------------------------
486ifdef EXPERIMENTAL_DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000487$(RecursiveTargets)::
488 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer81cd0492004-10-23 20:04:14 +0000489 if [ ! -f $$dir/Makefile ]; then \
490 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000491 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000492 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000493 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000494 done
495endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000496
Reid Spencerc49a8632005-12-21 23:17:06 +0000497#-----------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000498# Handle the PARALLEL_DIRS options for parallel construction
Reid Spencerc49a8632005-12-21 23:17:06 +0000499#-----------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000500ifdef PARALLEL_DIRS
501
Reid Spencerf88808a2004-10-30 09:19:36 +0000502SubDirs += $(PARALLEL_DIRS)
503
Reid Spencerd4bd3752004-12-03 20:08:48 +0000504# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencerf88808a2004-10-30 09:19:36 +0000505all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
506clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000507clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencerf88808a2004-10-30 09:19:36 +0000508install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000509uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencerd4bd3752004-12-03 20:08:48 +0000510install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000511
Reid Spencer81546582004-12-04 22:34:09 +0000512ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer81cd0492004-10-23 20:04:14 +0000513
Reid Spencer81546582004-12-04 22:34:09 +0000514$(ParallelTargets) :
Reid Spencerf88808a2004-10-30 09:19:36 +0000515 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencerf206bd72004-10-22 21:01:56 +0000516 $(MKDIR) $(@D); \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000517 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswell6df35dd2003-11-25 19:32:22 +0000518 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000519 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ;
Chris Lattner2f7c9632001-06-06 20:29:01 +0000520endif
521
Reid Spencer81cd0492004-10-23 20:04:14 +0000522#---------------------------------------------------------
523# Handle the OPTIONAL_DIRS options for directores that may
524# or may not exist.
525#---------------------------------------------------------
John Criswell8224df92003-06-27 16:58:44 +0000526ifdef OPTIONAL_DIRS
Reid Spencer100080c2004-10-25 08:27:37 +0000527
Reid Spencerf88808a2004-10-30 09:19:36 +0000528SubDirs += $(OPTIONAL_DIRS)
Reid Spencer100080c2004-10-25 08:27:37 +0000529
Reid Spencerf88808a2004-10-30 09:19:36 +0000530$(RecursiveTargets)::
531 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000532 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
Reid Spencerf206bd72004-10-22 21:01:56 +0000533 if [ ! -f $$dir/Makefile ]; then \
534 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000535 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000536 fi; \
Reid Spencera22a5b32006-05-17 22:55:35 +0000537 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000538 fi \
John Criswell8224df92003-06-27 16:58:44 +0000539 done
540endif
541
Reid Spencercc51e7b2004-08-20 09:20:05 +0000542#---------------------------------------------------------
543# Handle the CONFIG_FILES options
544#---------------------------------------------------------
545ifdef CONFIG_FILES
Reid Spencercc51e7b2004-08-20 09:20:05 +0000546
Reid Spencerba6a3db2005-01-16 02:20:54 +0000547install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
548 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000549 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000550 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
Reid Spencerc43b1d42005-02-24 03:56:32 +0000551 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000552 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
Reid Spencerc43b1d42005-02-24 03:56:32 +0000553 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer39d6a612004-11-23 05:59:53 +0000554 else \
555 $(ECHO) Error: cannot find config file $${file}. ; \
556 fi \
Reid Spencercc51e7b2004-08-20 09:20:05 +0000557 done
Reid Spencer81cd0492004-10-23 20:04:14 +0000558
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000559uninstall-local::
Reid Spencerba6a3db2005-01-16 02:20:54 +0000560 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000561 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000562 $(RM) -f $(PROJ_etcdir)/$${file} ; \
Reid Spencer12a3a052004-10-24 07:53:21 +0000563 done
564
Reid Spencercc51e7b2004-08-20 09:20:05 +0000565endif
566
Reid Spencer81cd0492004-10-23 20:04:14 +0000567###############################################################################
Reid Spencera80f1672005-05-19 00:37:31 +0000568# Set up variables for building libararies
569###############################################################################
570
571#---------------------------------------------------------
572# Handle the special "JIT" value for LLVM_LIBS which is a
573# shorthand for a bunch of libraries that get the correct
574# JIT support for a library or a tool that runs JIT.
575#---------------------------------------------------------
Reid Spencerd813b952006-03-24 07:36:57 +0000576ifeq ($(firstword $(LLVMLIBS)),config)
577LLVM_CONFIG := $(LLVM_SRC_ROOT)/utils/llvm-config/llvm-config
Reid Spencer056f0222006-04-07 16:06:18 +0000578LLVMLIBS := $(shell $(LLVM_CONFIG) --libnames $(wordlist 2,9999,$(LLVMLIBS)))
579LLVMLIBS := $(patsubst lib%.a,%.a,$(LLVMLIBS))
Reid Spencerd813b952006-03-24 07:36:57 +0000580LLVMLIBS := $(patsubst %.o,%,$(LLVMLIBS))
Reid Spencerd813b952006-03-24 07:36:57 +0000581endif
582
Reid Spencera80f1672005-05-19 00:37:31 +0000583ifeq ($(LLVMLIBS),JIT)
584
585# Make sure we can get our own symbols in the tool
586Link += -dlopen self
587
588# Generic JIT libraries
589JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
590
591# You can enable the X86 JIT on a non-X86 host by setting the flag
592# ENABLE_X86_JIT on the make command line. If not, it will still be
593# enabled automagically on an X86 host.
594ifeq ($(ARCH), x86)
595 ENABLE_X86_JIT = 1
596endif
597
598# What the X86 JIT requires
599ifdef ENABLE_X86_JIT
600 JIT_LIBS += LLVMX86 LLVMSelectionDAG
601endif
602
Reid Spencera80f1672005-05-19 00:37:31 +0000603# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
604# ENABLE_PPC_JIT on the make command line. If not, it will still be
605# enabled automagically on an PowerPC host.
606ifeq ($(ARCH), PowerPC)
607 ENABLE_PPC_JIT = 1
608endif
609
610# What the PowerPC JIT requires
611ifdef ENABLE_PPC_JIT
612 JIT_LIBS += LLVMPowerPC LLVMSelectionDAG
613endif
614
Andrew Lenharthc7fe0f52005-07-22 20:54:01 +0000615# You can enable the Alpha JIT on a non-Alpha host by setting the flag
616# ENABLE_ALPHA_JIT on the make command line. If not, it will still be
Misha Brukman08c36452005-07-22 22:43:40 +0000617# enabled automagically on an Alpha host.
Andrew Lenharthc7fe0f52005-07-22 20:54:01 +0000618ifeq ($(ARCH), Alpha)
619 ENABLE_ALPHA_JIT = 1
620endif
621
Andrew Lenharth99007012005-07-22 22:00:24 +0000622# What the Alpha JIT requires
Andrew Lenharthc7fe0f52005-07-22 20:54:01 +0000623ifdef ENABLE_ALPHA_JIT
624 JIT_LIBS += LLVMAlpha LLVMSelectionDAG
625endif
626
John Criswellfe5f33b2005-10-27 15:54:34 +0000627LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts.a LLVMTransformUtils.a LLVMAnalysis.a \
Owen Anderson68afff22006-05-11 03:10:15 +0000628 LLVMBCReader LLVMTarget.a LLVMCore LLVMSupport.a LLVMbzip2 \
Reid Spencera80f1672005-05-19 00:37:31 +0000629 LLVMSystem.a $(PLATFORMLIBDL)
630endif
631
632#---------------------------------------------------------
633# Define various command line options pertaining to the
634# libraries needed when linking. There are "Proj" libs
635# (defined by the user's project) and "LLVM" libs (defined
636# by the # LLVM project).
637#---------------------------------------------------------
Misha Brukman5fbf58a2005-08-17 02:38:56 +0000638# Some versions of gcc on Alpha produce too many symbols, so use a .a file
Andrew Lenharth6b62b472005-08-13 05:09:50 +0000639ifeq ($(ARCH),Alpha)
Reid Spencer10536582006-05-16 06:25:14 +0000640USEDLIBS := $(subst LLVMCore, LLVMCore.a, $(USEDLIBS))
Andrew Lenharth6b62b472005-08-13 05:09:50 +0000641LLVMLIBS := $(subst LLVMCore, LLVMCore.a, $(LLVMLIBS))
Reid Spencer6f682b72006-03-22 15:59:55 +0000642CORE_IS_ARCHIVE := 1
643else
644CORE_IS_ARCHIVE := 0
Andrew Lenharth6b62b472005-08-13 05:09:50 +0000645endif
646
Reid Spencera80f1672005-05-19 00:37:31 +0000647ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
648ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
649LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
650LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
651ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
652LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
653ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
654LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
655
656###############################################################################
Reid Spencer81cd0492004-10-23 20:04:14 +0000657# Library Build Rules: Four ways to build a library
658###############################################################################
Chris Lattner2f7c9632001-06-06 20:29:01 +0000659
Reid Spencerd78077d2004-12-05 05:17:22 +0000660#---------------------------------------------------------
661# Bytecode Module Targets:
662# If the user set MODULE_NAME then they want to build a
663# bytecode module from the sources. We compile all the
664# sources and link it together into a single bytecode
665# module.
666#---------------------------------------------------------
667
668ifdef MODULE_NAME
Reid Spencere9fa5442005-02-14 21:54:08 +0000669ifeq ($(strip $(LLVMGCC)),)
Reid Spencer83745dd2005-05-13 18:32:54 +0000670$(warning Modules require llvm-gcc but no llvm-gcc is available ****)
Reid Spencere9fa5442005-02-14 21:54:08 +0000671else
Reid Spencerd78077d2004-12-05 05:17:22 +0000672
673Module := $(LibDir)/$(MODULE_NAME).bc
Reid Spencer78ede562006-04-12 18:21:35 +0000674LinkModule := $(GCCLD) -L$(CFERuntimeLibDir)
675
Reid Spencerd78077d2004-12-05 05:17:22 +0000676
677ifdef EXPORTED_SYMBOL_FILE
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000678LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencerd78077d2004-12-05 05:17:22 +0000679endif
680
681$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
Reid Spencer83745dd2005-05-13 18:32:54 +0000682 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
Reid Spencerd78077d2004-12-05 05:17:22 +0000683 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
684
685all-local:: $(Module)
686
687clean-local::
688ifneq ($(strip $(Module)),)
689 -$(Verb) $(RM) -f $(Module)
690endif
691
Reid Spencerefe3a822004-12-13 07:38:07 +0000692ifdef BYTECODE_DESTINATION
693ModuleDestDir := $(BYTECODE_DESTINATION)
694else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000695ModuleDestDir := $(PROJ_libdir)
Reid Spencerefe3a822004-12-13 07:38:07 +0000696endif
Reid Spencerd78077d2004-12-05 05:17:22 +0000697
Reid Spencerefe3a822004-12-13 07:38:07 +0000698DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
699
700install-module:: $(DestModule)
Reid Spencerd78077d2004-12-05 05:17:22 +0000701install-local:: $(DestModule)
702
Reid Spencerefe3a822004-12-13 07:38:07 +0000703$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencerd78077d2004-12-05 05:17:22 +0000704 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
Reid Spencerd77a4c02005-02-24 21:30:37 +0000705 $(Verb) $(DataInstall) $(Module) $(DestModule)
Reid Spencerd78077d2004-12-05 05:17:22 +0000706
707uninstall-local::
708 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
709 -$(Verb) $(RM) -f $(DestModule)
710
711endif
Reid Spencere9fa5442005-02-14 21:54:08 +0000712endif
Brian Gaekeecc92bf2004-01-22 22:53:48 +0000713
Reid Spencer81cd0492004-10-23 20:04:14 +0000714# if we're building a library ...
Chris Lattner2f7c9632001-06-06 20:29:01 +0000715ifdef LIBRARYNAME
Vikram S. Advefe346892001-07-15 13:16:47 +0000716
Chris Lattner0100eab2002-09-16 22:36:42 +0000717# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000718LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencer87e645c2005-01-11 04:31:07 +0000719ifdef LOADABLE_MODULE
720LibName.LA := $(LibDir)/$(LIBRARYNAME).la
721else
Reid Spencerf88808a2004-10-30 09:19:36 +0000722LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
Reid Spencer87e645c2005-01-11 04:31:07 +0000723endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000724LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
725LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer32f7e422004-12-02 09:28:21 +0000726LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000727
Reid Spencer81cd0492004-10-23 20:04:14 +0000728#---------------------------------------------------------
729# Shared Library Targets:
730# If the user asked for a shared library to be built
731# with the SHARED_LIBRARY variable, then we provide
732# targets for building them.
733#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000734ifdef SHARED_LIBRARY
735
Reid Spencerf88808a2004-10-30 09:19:36 +0000736all-local:: $(LibName.LA)
Reid Spencerf206bd72004-10-22 21:01:56 +0000737
Reid Spencera80f1672005-05-19 00:37:31 +0000738ifdef LINK_LIBS_IN_SHARED
739$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
740 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
741 $(Verb) $(Link) -o $@ $(ObjectsLO) \
742 $(ProjLibsOptions) $(LLVMLibsOptions)
743 $(Verb) $(LTInstall) $@ $(LibDir)
744else
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000745$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000746 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf88808a2004-10-30 09:19:36 +0000747 $(Verb) $(Link) -o $@ $(ObjectsLO)
748 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencera80f1672005-05-19 00:37:31 +0000749endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000750
751clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000752ifneq ($(strip $(LibName.LA)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000753 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000754endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000755
Reid Spencerba6a3db2005-01-16 02:20:54 +0000756DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf206bd72004-10-22 21:01:56 +0000757
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000758install-local:: $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000759
Reid Spencerba6a3db2005-01-16 02:20:54 +0000760$(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000761 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000762 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000763 $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
Reid Spencer12a3a052004-10-24 07:53:21 +0000764
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000765uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000766 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000767 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
Reid Spencer12a3a052004-10-24 07:53:21 +0000768
Reid Spencerf206bd72004-10-22 21:01:56 +0000769endif
770
Reid Spencer81cd0492004-10-23 20:04:14 +0000771#---------------------------------------------------------
772# Bytecode Library Targets:
773# If the user asked for a bytecode library to be built
774# with the BYTECODE_LIBRARY variable, then we provide
775# targets for building them.
776#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000777ifdef BYTECODE_LIBRARY
Reid Spencere9fa5442005-02-14 21:54:08 +0000778ifeq ($(strip $(LLVMGCC)),)
Reid Spencer83745dd2005-05-13 18:32:54 +0000779$(warning Bytecode libraries require llvm-gcc which could not be found ****)
Reid Spencere9fa5442005-02-14 21:54:08 +0000780else
Reid Spencerf206bd72004-10-22 21:01:56 +0000781
Reid Spencer32f7e422004-12-02 09:28:21 +0000782all-local:: $(LibName.BCA)
783
784ifdef EXPORTED_SYMBOL_FILE
Reid Spencer78ede562006-04-12 18:21:35 +0000785BCLinkLib = $(GCCLD) -L$(CFERuntimeLibDir) -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer32f7e422004-12-02 09:28:21 +0000786
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000787$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +0000788 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +0000789 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
790 "(internalize)"
Chris Lattnere3d98f12004-12-02 21:23:43 +0000791 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencer85d55ad2004-12-13 03:59:35 +0000792 $(Verb) $(RM) -f $@
Reid Spencer32f7e422004-12-02 09:28:21 +0000793 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencerf206bd72004-10-22 21:01:56 +0000794else
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000795$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +0000796 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +0000797 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencer85d55ad2004-12-13 03:59:35 +0000798 $(Verb) $(RM) -f $@
Reid Spencer32f7e422004-12-02 09:28:21 +0000799 $(Verb) $(LArchive) $@ $(ObjectsBC)
800
Reid Spencerf206bd72004-10-22 21:01:56 +0000801endif
802
Reid Spencer81cd0492004-10-23 20:04:14 +0000803clean-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000804ifneq ($(strip $(LibName.BCA)),)
805 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000806endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000807
Reid Spencer65086be2004-12-13 07:28:21 +0000808ifdef BYTECODE_DESTINATION
809BytecodeDestDir := $(BYTECODE_DESTINATION)
810else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000811BytecodeDestDir := $(PROJ_libdir)
Reid Spencer65086be2004-12-13 07:28:21 +0000812endif
813
814DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
Reid Spencer32f7e422004-12-02 09:28:21 +0000815
Reid Spencerd4bd3752004-12-03 20:08:48 +0000816install-bytecode-local:: $(DestBytecodeLib)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000817
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000818install-local:: $(DestBytecodeLib)
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000819
Reid Spencer65086be2004-12-13 07:28:21 +0000820$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
Reid Spencer32f7e422004-12-02 09:28:21 +0000821 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerdcc53752005-02-24 21:36:32 +0000822 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000823
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000824uninstall-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000825 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000826 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000827
828endif
Reid Spencere9fa5442005-02-14 21:54:08 +0000829endif
Vikram S. Adve15bd3ad2002-08-02 18:34:12 +0000830
Reid Spencerf88808a2004-10-30 09:19:36 +0000831#---------------------------------------------------------
832# ReLinked Library Targets:
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000833# If the user explicitly requests a relinked library with
834# BUILD_RELINKED, provide it. Otherwise, if they specify
835# neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
836# them one.
Reid Spencerf88808a2004-10-30 09:19:36 +0000837#---------------------------------------------------------
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000838ifndef BUILD_ARCHIVE
Chris Lattner76d98ba2002-07-23 17:56:16 +0000839ifndef DONT_BUILD_RELINKED
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000840BUILD_RELINKED = 1
841endif
842endif
843
844ifdef BUILD_RELINKED
Reid Spencerf206bd72004-10-22 21:01:56 +0000845
Reid Spencerf88808a2004-10-30 09:19:36 +0000846all-local:: $(LibName.O)
847
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000848$(LibName.O): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000849 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencerf88808a2004-10-30 09:19:36 +0000850 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencerf206bd72004-10-22 21:01:56 +0000851
Reid Spencer81cd0492004-10-23 20:04:14 +0000852clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000853ifneq ($(strip $(LibName.O)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000854 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencer12a3a052004-10-24 07:53:21 +0000855endif
856
Reid Spencerba6a3db2005-01-16 02:20:54 +0000857DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
Reid Spencer12a3a052004-10-24 07:53:21 +0000858
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000859install-local:: $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000860
Reid Spencerba6a3db2005-01-16 02:20:54 +0000861$(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000862 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000863 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000864
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000865uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000866 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000867 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000868
Chris Lattner76d98ba2002-07-23 17:56:16 +0000869endif
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000870
Reid Spencerf88808a2004-10-30 09:19:36 +0000871#---------------------------------------------------------
872# Archive Library Targets:
873# If the user wanted a regular archive library built,
874# then we provide targets for building them.
875#---------------------------------------------------------
Chris Lattner76d98ba2002-07-23 17:56:16 +0000876ifdef BUILD_ARCHIVE
Chris Lattner76d98ba2002-07-23 17:56:16 +0000877
Reid Spencerf88808a2004-10-30 09:19:36 +0000878all-local:: $(LibName.A)
879
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000880$(LibName.A): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000881 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000882 -$(Verb) $(RM) -f $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000883 $(Verb) $(Archive) $@ $(ObjectsO)
884 $(Verb) $(Ranlib) $@
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000885
Reid Spencer81cd0492004-10-23 20:04:14 +0000886clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000887ifneq ($(strip $(LibName.A)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000888 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000889endif
890
Reid Spencerba6a3db2005-01-16 02:20:54 +0000891DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
Reid Spencer12a3a052004-10-24 07:53:21 +0000892
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000893install-local:: $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000894
Reid Spencerba6a3db2005-01-16 02:20:54 +0000895$(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000896 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000897 $(Verb) $(MKDIR) $(PROJ_libdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000898 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000899
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000900uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000901 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000902 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000903
904endif
905
906# endif LIBRARYNAME
Reid Spencerf206bd72004-10-22 21:01:56 +0000907endif
908
Reid Spencerdcba7782004-10-24 08:21:04 +0000909###############################################################################
910# Tool Build Rules: Build executable tool based on TOOLNAME option
911###############################################################################
912
Chris Lattner07c7c192001-09-07 22:57:58 +0000913ifdef TOOLNAME
914
Reid Spencerf88808a2004-10-30 09:19:36 +0000915#---------------------------------------------------------
916# Set up variables for building a tool.
917#---------------------------------------------------------
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000918ifdef EXAMPLE_TOOL
Reid Spencer98a2d982005-05-19 21:03:11 +0000919ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000920else
Reid Spencer98a2d982005-05-19 21:03:11 +0000921ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000922endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000923
Reid Spencerf88808a2004-10-30 09:19:36 +0000924#---------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000925# Tell make that we need to rebuild subdirectories before
926# we can link the tool. This affects things like LLI which
927# has library subdirectories.
928#---------------------------------------------------------
929$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner3ecb7762003-01-22 16:13:31 +0000930
Reid Spencerf88808a2004-10-30 09:19:36 +0000931#---------------------------------------------------------
932# Provide targets for building the tools
933#---------------------------------------------------------
934all-local:: $(ToolBuildPath)
John Criswell8224df92003-06-27 16:58:44 +0000935
Reid Spencer81cd0492004-10-23 20:04:14 +0000936clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000937ifneq ($(strip $(ToolBuildPath)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000938 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencer12a3a052004-10-24 07:53:21 +0000939endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000940
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000941ifdef EXAMPLE_TOOL
942$(ToolBuildPath): $(ExmplDir)/.dir
943else
944$(ToolBuildPath): $(ToolDir)/.dir
945endif
946
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000947$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000948 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencer10536582006-05-16 06:25:14 +0000949 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
950 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
Chris Lattnere2dcbe02006-02-14 04:25:54 +0000951 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
952 $(StripWarnMsg)
Reid Spencer12a3a052004-10-24 07:53:21 +0000953
Reid Spencerba6a3db2005-01-16 02:20:54 +0000954DestTool = $(PROJ_bindir)/$(TOOLNAME)
Reid Spencer12a3a052004-10-24 07:53:21 +0000955
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000956install-local:: $(DestTool)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000957
Reid Spencerba6a3db2005-01-16 02:20:54 +0000958$(DestTool): $(PROJ_bindir) $(ToolBuildPath)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000959 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencerc43b1d42005-02-24 03:56:32 +0000960 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000961
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000962uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000963 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000964 -$(Verb) $(RM) -f $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000965
Reid Spencerf206bd72004-10-22 21:01:56 +0000966endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000967
Reid Spencerf88808a2004-10-30 09:19:36 +0000968###############################################################################
969# Object Build Rules: Build object files based on sources
970###############################################################################
971
Duraid Madinacbbc1842006-02-15 03:23:26 +0000972# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
973ifeq ($(OS),HP-UX)
974 DISABLE_AUTO_DEPENDENCIES=1
975endif
976
Reid Spencerf88808a2004-10-30 09:19:36 +0000977# Provide rule sets for when dependency generation is enabled
Reid Spencerf206bd72004-10-22 21:01:56 +0000978ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000979
Reid Spencerf88808a2004-10-30 09:19:36 +0000980#---------------------------------------------------------
981# Create .lo files in the ObjDir directory from the .cpp and .c files...
982#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000983ifdef SHARED_LIBRARY
984
Chris Lattner2a023902004-12-16 17:28:50 +0000985$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000986 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Chris Lattnerb8e7aa02006-02-14 04:27:15 +0000987 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
Reid Spencerf88808a2004-10-30 09:19:36 +0000988 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
989 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000990
Chris Lattnerf60c1702005-02-04 21:28:50 +0000991$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
992 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
Chris Lattnerb8e7aa02006-02-14 04:27:15 +0000993 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
Chris Lattnerf60c1702005-02-04 21:28:50 +0000994 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
995 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
996
Chris Lattner2a023902004-12-16 17:28:50 +0000997$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000998 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencerf88808a2004-10-30 09:19:36 +0000999 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
1000 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
1001 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +00001002
Reid Spencerf88808a2004-10-30 09:19:36 +00001003#---------------------------------------------------------
1004# Create .o files in the ObjDir directory from the .cpp and .c files...
1005#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001006else
Reid Spencerf206bd72004-10-22 21:01:56 +00001007
Chris Lattner2a023902004-12-16 17:28:50 +00001008$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001009 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +00001010 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
1011 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
1012 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +00001013
Chris Lattnerf60c1702005-02-04 21:28:50 +00001014$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1015 $(Echo) "Compiling $*.cc for $(BuildMode) build"
1016 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
1017 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
1018 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
1019
Chris Lattner2a023902004-12-16 17:28:50 +00001020$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001021 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +00001022 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
1023 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
1024 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +00001025
1026endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001027
Chris Lattnerbb087952005-10-05 00:28:41 +00001028## Rules for building preprocessed (.i/.ii) outputs.
1029$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1030 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1031 $(Verb) $(Preprocess.CXX) $< -o $@
1032
1033$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1034 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1035 $(Verb) $(Preprocess.CXX) $< -o $@
1036
1037 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1038 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1039 $(Verb) $(Preprocess.C) $< -o $@
1040
1041
Reid Spencerf88808a2004-10-30 09:19:36 +00001042#---------------------------------------------------------
Chris Lattnerf60c1702005-02-04 21:28:50 +00001043# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
Reid Spencerf88808a2004-10-30 09:19:36 +00001044#---------------------------------------------------------
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001045
1046$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001047 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001048 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1049 $< -o $@ -S -emit-llvm ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001050 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1051 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +00001052
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001053$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001054 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001055 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1056 $< -o $@ -S -emit-llvm ; \
Chris Lattnerf60c1702005-02-04 21:28:50 +00001057 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1058 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1059
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001060$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001061 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001062 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" \
1063 $< -o $@ -S -emit-llvm ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001064 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1065 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +00001066
Reid Spencerf88808a2004-10-30 09:19:36 +00001067# Provide alternate rule sets if dependencies are disabled
Reid Spencerf206bd72004-10-22 21:01:56 +00001068else
1069
Reid Spencer81cd0492004-10-23 20:04:14 +00001070ifdef SHARED_LIBRARY
1071
Chris Lattner2a023902004-12-16 17:28:50 +00001072$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001073 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +00001074 $(LTCompile.CXX) $< -o $@
1075
Chris Lattnerf60c1702005-02-04 21:28:50 +00001076$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1077 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
1078 $(LTCompile.CXX) $< -o $@
1079
Chris Lattner2a023902004-12-16 17:28:50 +00001080$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerafdc82c2004-12-16 18:26:53 +00001081 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +00001082 $(LTCompile.C) $< -o $@
1083
1084else
Reid Spencerf206bd72004-10-22 21:01:56 +00001085
Chris Lattner2a023902004-12-16 17:28:50 +00001086$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001087 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer81cd0492004-10-23 20:04:14 +00001088 $(Compile.CXX) $< -o $@
Reid Spencerf206bd72004-10-22 21:01:56 +00001089
Chris Lattnerf60c1702005-02-04 21:28:50 +00001090$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1091 $(Echo) "Compiling $*.cc for $(BuildMode) build"
1092 $(Compile.CXX) $< -o $@
1093
Chris Lattner2a023902004-12-16 17:28:50 +00001094$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerafdc82c2004-12-16 18:26:53 +00001095 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencer81cd0492004-10-23 20:04:14 +00001096 $(Compile.C) $< -o $@
1097endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001098
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001099$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001100 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001101 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Reid Spencerf206bd72004-10-22 21:01:56 +00001102
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001103$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001104 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001105 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Chris Lattnerf60c1702005-02-04 21:28:50 +00001106
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001107$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001108 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001109 $(BCCompile.C) $< -o $@ -S -emit-llvm
Brian Gaeke0f148bc2003-12-10 00:26:28 +00001110
Chris Lattner07c7c192001-09-07 22:57:58 +00001111endif
1112
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001113# make the C and C++ compilers strip debug info out of bytecode libraries.
1114ifdef DEBUG_RUNTIME
1115$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1116 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Chris Lattner5b59d7c2006-03-09 06:00:05 +00001117 $(Verb) $(GCCAS) $< -o $@
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001118else
1119$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1120 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Chris Lattner5b59d7c2006-03-09 06:00:05 +00001121 $(Verb) $(GCCAS) -strip-debug $< -o $@
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001122endif
1123
1124
Reid Spencerf88808a2004-10-30 09:19:36 +00001125#---------------------------------------------------------
1126# Provide rule to build .bc files from .ll sources,
1127# regardless of dependencies
1128#---------------------------------------------------------
1129$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001130 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +00001131 $(Verb) $(LLVMAS) $< -f -o $@
1132
1133###############################################################################
1134# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1135###############################################################################
Chris Lattner0c4f4fe2003-08-15 02:18:35 +00001136
Reid Spencerf206bd72004-10-22 21:01:56 +00001137ifdef TARGET
1138
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001139TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1140 $(LLVM_SRC_ROOT)/lib/Target/Target.td \
Chris Lattner8a87f5f2006-03-03 01:54:54 +00001141 $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td \
1142 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td)
Reid Spencerf88808a2004-10-30 09:19:36 +00001143INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Chris Lattner2a023902004-12-16 17:28:50 +00001144INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1145.PRECIOUS: $(INCTMPFiles) $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001146
Chris Lattner2a023902004-12-16 17:28:50 +00001147# All of these files depend on tblgen and the .td files.
1148$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001149
Chris Lattnerf86914d2004-12-16 17:38:56 +00001150# INCFiles rule: All of the tblgen generated files are emitted to
1151# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1152# us to only "touch" the real file if the contents of it change. IOW, if
1153# tblgen is modified, all of the .inc.tmp files are regereated, but no
1154# dependencies of the .inc files are, unless the contents of the .inc file
1155# changes.
1156$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
Reid Spencerafdc82c2004-12-16 18:26:53 +00001157 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
Chris Lattner2a023902004-12-16 17:28:50 +00001158
1159$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1160$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001161 $(Echo) "Building $(<F) register names with tblgen"
1162 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001163
Chris Lattner2a023902004-12-16 17:28:50 +00001164$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1165$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001166 $(Echo) "Building $(<F) register information header with tblgen"
1167 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001168
Chris Lattner2a023902004-12-16 17:28:50 +00001169$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1170$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001171 $(Echo) "Building $(<F) register info implementation with tblgen"
1172 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001173
Chris Lattner2a023902004-12-16 17:28:50 +00001174$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1175$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001176 $(Echo) "Building $(<F) instruction names with tblgen"
1177 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001178
Chris Lattner2a023902004-12-16 17:28:50 +00001179$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1180$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001181 $(Echo) "Building $(<F) instruction information with tblgen"
1182 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001183
Chris Lattner2a023902004-12-16 17:28:50 +00001184$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1185$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001186 $(Echo) "Building $(<F) assembly writer with tblgen"
1187 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001188
Chris Lattner22f937a2004-12-16 17:34:04 +00001189$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1190$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1191 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Reid Spencerf88808a2004-10-30 09:19:36 +00001192 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001193
Chris Lattner2a023902004-12-16 17:28:50 +00001194$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1195$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001196 $(Echo) "Building $(<F) code emitter with tblgen"
1197 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001198
Chris Lattner33f98bd2005-09-03 01:15:25 +00001199$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1200$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1201 $(Echo) "Building $(<F) instruction selector implementation with tblgen"
1202 $(Verb) $(TableGen) -gen-dag-isel -o $@ $<
1203
Jim Laskey9ed90322005-10-21 19:05:19 +00001204$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1205$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1206 $(Echo) "Building $(<F) subtarget information with tblgen"
1207 $(Verb) $(TableGen) -gen-subtarget -o $@ $<
Chris Lattner33f98bd2005-09-03 01:15:25 +00001208
Reid Spencer81cd0492004-10-23 20:04:14 +00001209clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001210 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001211
1212endif
Chris Lattner0c4f4fe2003-08-15 02:18:35 +00001213
Reid Spencerf88808a2004-10-30 09:19:36 +00001214###############################################################################
1215# LEX AND YACC: Provide rules for generating sources with lex and yacc
1216###############################################################################
Chris Lattnerdb644dd2003-01-16 22:44:19 +00001217
Reid Spencerf88808a2004-10-30 09:19:36 +00001218#---------------------------------------------------------
1219# Provide rules for generating a .cpp source file from
1220# (f)lex input sources.
1221#---------------------------------------------------------
1222
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001223LexFiles := $(filter %.l,$(Sources))
Reid Spencerf88808a2004-10-30 09:19:36 +00001224
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001225ifneq ($(LexFiles),)
1226
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001227# Cancel built-in rules for lex
1228%.c: %.l
1229%.cpp: %.l
Reid Spencerf88808a2004-10-30 09:19:36 +00001230
Chris Lattner8104b4c2006-02-14 05:12:00 +00001231all:: $(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs)
1232
Reid Spencerf88808a2004-10-30 09:19:36 +00001233# Note the extra sed filtering here, used to cut down on the warnings emited
1234# by GCC. The last line is a gross hack to work around flex aparently not
1235# being able to resize the buffer on a large token input. Currently, for
1236# uninitialized string buffers in LLVM we can generate very long tokens, so
1237# this is a hack around it.
Chris Lattner92fc9b02003-08-15 20:00:47 +00001238# FIXME. (f.e. char Buffer[10000] )
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001239$(PROJ_SRC_DIR)/%.cpp: $(PROJ_SRC_DIR)/%.l
Reid Spencer993b95e2004-12-10 19:44:16 +00001240 $(Echo) Flexing $*.l
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001241 $(Verb) $(FLEX) -t $(PROJ_SRC_DIR)/$*.l | \
Reid Spencerf206bd72004-10-22 21:01:56 +00001242 $(SED) 's/void yyunput/inline void yyunput/' | \
1243 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1244 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001245 > $(PROJ_SRC_DIR)/$*.cpp
Chris Lattner8104b4c2006-02-14 05:12:00 +00001246
1247# IFF the .l file has changed since it was last checked into CVS, copy the .l
1248# file to .l.cvs and the generated .cpp file to .cpp.cvs. We use this mechanism
1249# so that people without flex can build LLVM by copying the .cvs files to the
1250# source location and building them.
1251$(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1252$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattner1e612822006-02-16 05:10:48 +00001253 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs || \
Chris Lattner8104b4c2006-02-14 05:12:00 +00001254 ($(CP) $< $@; $(CP) $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001255
Chris Lattner8104b4c2006-02-14 05:12:00 +00001256$(LexFiles:%.l=$(ObjDir)/%.o) : \
1257$(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
Chris Lattner2f7c9632001-06-06 20:29:01 +00001258
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001259clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001260 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001261
Reid Spencerf88808a2004-10-30 09:19:36 +00001262endif
1263
1264#---------------------------------------------------------
1265# Provide rules for generating a .cpp and .h source files
1266# from yacc (bison) input sources.
1267#---------------------------------------------------------
1268
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001269YaccFiles := $(filter %.y,$(Sources))
1270ifneq ($(YaccFiles),)
Reid Spencerf88808a2004-10-30 09:19:36 +00001271
1272.PRECIOUS: $(YaccOutput)
1273
Chris Lattnerb0240b22006-02-15 07:23:05 +00001274all:: $(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs)
Chris Lattnerc38a9752006-02-15 07:16:57 +00001275
Reid Spencerf88808a2004-10-30 09:19:36 +00001276# Cancel built-in rules for yacc
1277%.c: %.y
1278%.cpp: %.y
1279%.h: %.y
1280
Reid Spencerc49a8632005-12-21 23:17:06 +00001281# Rule for building the bison based parsers...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001282$(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
Reid Spencerf88808a2004-10-30 09:19:36 +00001283 $(Echo) "Bisoning $*.y"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001284 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1285 $(Verb) $(MV) -f $*.tab.c $(PROJ_SRC_DIR)/$*.cpp
1286 $(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
Chris Lattner2f7c9632001-06-06 20:29:01 +00001287
Chris Lattnerc38a9752006-02-15 07:16:57 +00001288# IFF the .y file has changed since it was last checked into CVS, copy the .y
1289# file to .y.cvs and the generated .cpp/.h file to .cpp.cvs/.h.cvs. We use this
1290# mechanism so that people without flex can build LLVM by copying the .cvs files
1291# to the source location and building them.
1292$(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1293$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattner1e612822006-02-16 05:10:48 +00001294 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs || \
Chris Lattnerc38a9752006-02-15 07:16:57 +00001295 ($(CP) $< $@; \
Chris Lattnerb0240b22006-02-15 07:23:05 +00001296 $(CP) $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs; \
Chris Lattnerc38a9752006-02-15 07:16:57 +00001297 $(CP) $(PROJ_SRC_DIR)/$*.h $(PROJ_SRC_DIR)/$*.h.cvs)
Reid Spencerc49a8632005-12-21 23:17:06 +00001298
Chris Lattnerc38a9752006-02-15 07:16:57 +00001299
1300$(YaccFiles:%.y=$(ObjDir)/%.o): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
1301
1302YaccOutput := $(YaccFiles:%.y=%.output)
Reid Spencerc49a8632005-12-21 23:17:06 +00001303
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001304clean-local::
Reid Spencerc49a8632005-12-21 23:17:06 +00001305 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencerf88808a2004-10-30 09:19:36 +00001306endif
Chris Lattner2f7c9632001-06-06 20:29:01 +00001307
Reid Spencerf88808a2004-10-30 09:19:36 +00001308###############################################################################
1309# OTHER RULES: Other rules needed
1310###############################################################################
Reid Spencerf206bd72004-10-22 21:01:56 +00001311
Chris Lattner23d47392003-01-16 21:06:18 +00001312# To create postscript files from dot files...
John Criswell4ffb8442003-10-02 19:02:02 +00001313ifneq ($(DOT),false)
Chris Lattner23d47392003-01-16 21:06:18 +00001314%.ps: %.dot
Reid Spencerf206bd72004-10-22 21:01:56 +00001315 $(DOT) -Tps < $< > $@
John Criswell3ef61af2003-06-30 21:59:07 +00001316else
1317%.ps: %.dot
Reid Spencerf88808a2004-10-30 09:19:36 +00001318 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell3ef61af2003-06-30 21:59:07 +00001319endif
Chris Lattner23d47392003-01-16 21:06:18 +00001320
John Criswell0a6e6aa2003-09-06 14:44:17 +00001321# This rules ensures that header files that are removed still have a rule for
1322# which they can be "generated." This allows make to ignore them and
1323# reproduce the dependency lists.
John Criswella8391af2003-09-18 18:37:08 +00001324%.h:: ;
Chris Lattnerf60c1702005-02-04 21:28:50 +00001325%.hpp:: ;
John Criswell0a6e6aa2003-09-06 14:44:17 +00001326
Reid Spencerf88808a2004-10-30 09:19:36 +00001327# Define clean-local to clean the current directory. Note that this uses a
1328# very conservative approach ensuring that empty variables do not cause
1329# errors or disastrous removal.
Reid Spencer81cd0492004-10-23 20:04:14 +00001330clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001331ifneq ($(strip $(ObjDir)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001332 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencer12a3a052004-10-24 07:53:21 +00001333endif
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001334 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke8625f682004-01-21 19:53:11 +00001335ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001336 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke8625f682004-01-21 19:53:11 +00001337endif
John Criswell3ef61af2003-06-30 21:59:07 +00001338
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001339clean-all-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001340 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001341
Reid Spencerf88808a2004-10-30 09:19:36 +00001342# Build tags database for Emacs/Xemacs:
Reid Spenceraee67e62004-11-12 02:27:36 +00001343tags:: TAGS CTAGS
1344
Reid Spencerf88808a2004-10-30 09:19:36 +00001345TAGS:
Reid Spencerba6a3db2005-01-16 02:20:54 +00001346 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1347 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1348 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1349 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spenceraee67e62004-11-12 02:27:36 +00001350 -name '*.cpp' -o -name '*.h' | \
Reid Spencerf88808a2004-10-30 09:19:36 +00001351 $(ETAGS) $(ETAGSFLAGS) -
1352
Reid Spenceraee67e62004-11-12 02:27:36 +00001353CTAGS:
Reid Spencerba6a3db2005-01-16 02:20:54 +00001354 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1355 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1356 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1357 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spenceraee67e62004-11-12 02:27:36 +00001358 \( -name '*.cpp' -o -name '*.h' \) -print | \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001359 ctags -ImtT -o $(PROJ_OBJ_ROOT)/CTAGS -L -
Reid Spenceraee67e62004-11-12 02:27:36 +00001360
1361
Reid Spencer81cd0492004-10-23 20:04:14 +00001362###############################################################################
1363# DEPENDENCIES: Include the dependency files if we should
1364###############################################################################
Chris Lattnere9d7d702003-08-22 14:10:16 +00001365ifndef DISABLE_AUTO_DEPENDENCIES
1366
Reid Spencer81cd0492004-10-23 20:04:14 +00001367# If its not one of the cleaning targets
Reid Spencerf88808a2004-10-30 09:19:36 +00001368ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencerf206bd72004-10-22 21:01:56 +00001369
Reid Spencer81cd0492004-10-23 20:04:14 +00001370# Get the list of dependency files
Reid Spencerf88808a2004-10-30 09:19:36 +00001371DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Chris Lattner8104b4c2006-02-14 05:12:00 +00001372DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
Misha Brukmanb891ffb2003-11-09 21:36:19 +00001373
Reid Spencer81cd0492004-10-23 20:04:14 +00001374-include /dev/null $(DependFiles)
1375
John Criswell48ecca62003-08-12 18:51:51 +00001376endif
Chris Lattner598222b2003-08-18 17:27:40 +00001377
Reid Spencerf88808a2004-10-30 09:19:36 +00001378endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001379
Reid Spencer100080c2004-10-25 08:27:37 +00001380###############################################################################
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001381# CHECK: Running the test suite
1382###############################################################################
1383
1384check::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001385 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1386 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001387 $(EchoCmd) Running test suite ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001388 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001389 TESTSUITE=$(TESTSUITE) ; \
1390 else \
1391 $(EchoCmd) No Makefile in test directory ; \
1392 fi ; \
1393 else \
1394 $(EchoCmd) No test directory ; \
1395 fi
1396
1397###############################################################################
Reid Spencerf88808a2004-10-30 09:19:36 +00001398# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer100080c2004-10-25 08:27:37 +00001399###############################################################################
1400
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001401#------------------------------------------------------------------------
1402# Define distribution related variables
1403#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +00001404DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1405DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1406TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1407DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1408DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1409DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
Reid Spencer100080c2004-10-25 08:27:37 +00001410DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1411 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001412 Makefile.config.in configure autoconf
1413DistOther := $(notdir $(wildcard \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001414 $(PROJ_SRC_DIR)/*.h \
1415 $(PROJ_SRC_DIR)/*.td \
1416 $(PROJ_SRC_DIR)/*.def \
1417 $(PROJ_SRC_DIR)/*.ll \
1418 $(PROJ_SRC_DIR)/*.in))
Reid Spencerf88808a2004-10-30 09:19:36 +00001419DistSubDirs := $(SubDirs)
Reid Spencerfc66af42004-11-29 05:00:33 +00001420DistSources = $(Sources) $(EXTRA_DIST)
1421DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer100080c2004-10-25 08:27:37 +00001422
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001423#------------------------------------------------------------------------
1424# We MUST build distribution with OBJ_DIR != SRC_DIR
1425#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +00001426ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001427dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerf88808a2004-10-30 09:19:36 +00001428 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001429
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001430else
1431
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001432#------------------------------------------------------------------------
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001433# Prevent attempt to run dist targets from anywhere but the top level
1434#------------------------------------------------------------------------
1435ifneq ($(LEVEL),.)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001436dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001437 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001438else
1439
1440#------------------------------------------------------------------------
1441# Provide the top level targets
1442#------------------------------------------------------------------------
1443
Reid Spencerf88808a2004-10-30 09:19:36 +00001444dist-gzip:: $(DistTarGZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001445
Reid Spencer81546582004-12-04 22:34:09 +00001446$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001447 $(Echo) Packing gzipped distribution tar file.
Reid Spencerba6a3db2005-01-16 02:20:54 +00001448 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
Reid Spencerfc66af42004-11-29 05:00:33 +00001449 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001450
Reid Spencerf88808a2004-10-30 09:19:36 +00001451dist-bzip2:: $(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001452
Reid Spencer81546582004-12-04 22:34:09 +00001453$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001454 $(Echo) Packing bzipped distribution tar file.
Reid Spencerba6a3db2005-01-16 02:20:54 +00001455 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
Reid Spencerfc66af42004-11-29 05:00:33 +00001456 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001457
Reid Spencerf88808a2004-10-30 09:19:36 +00001458dist-zip:: $(DistZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001459
Reid Spencer81546582004-12-04 22:34:09 +00001460$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001461 $(Echo) Packing zipped distribution file.
1462 $(Verb) rm -f $(DistZip)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001463 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001464
1465dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001466 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001467
Reid Spencer3a468752005-01-28 19:52:32 +00001468DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001469
Reid Spencer81546582004-12-04 22:34:09 +00001470dist-check:: $(DistTarGZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001471 $(Echo) Checking distribution tar file.
1472 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001473 $(RM) -rf $(DistCheckDir) ; \
1474 fi
Reid Spencerf88808a2004-10-30 09:19:36 +00001475 $(Verb) $(MKDIR) $(DistCheckDir)
1476 $(Verb) cd $(DistCheckDir) && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001477 $(MKDIR) $(DistCheckDir)/build && \
1478 $(MKDIR) $(DistCheckDir)/install && \
1479 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1480 cd build && \
1481 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
Reid Spencer13f51932005-05-24 02:33:20 +00001482 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
Reid Spencer81546582004-12-04 22:34:09 +00001483 $(MAKE) all && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001484 $(MAKE) check && \
1485 $(MAKE) install && \
1486 $(MAKE) uninstall && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001487 $(MAKE) dist-clean && \
Reid Spencerf88808a2004-10-30 09:19:36 +00001488 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001489
1490dist-clean::
Reid Spencerf88808a2004-10-30 09:19:36 +00001491 $(Echo) Cleaning distribution files
Reid Spencer81546582004-12-04 22:34:09 +00001492 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1493 $(DistCheckDir)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001494
1495endif
1496
1497#------------------------------------------------------------------------
1498# Provide the recursive distdir target for building the distribution directory
1499#------------------------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +00001500distdir: $(DistDir)/.makedistdir
1501$(DistDir)/.makedistdir: $(DistSources)
Reid Spencerf88808a2004-10-30 09:19:36 +00001502 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001503 if test -d "$(DistDir)" ; then \
1504 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1505 exit 1 ; \
1506 fi ; \
Reid Spencer81546582004-12-04 22:34:09 +00001507 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001508 $(RM) -rf $(DistDir); \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001509 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer15b85092006-04-10 16:46:04 +00001510 $(MAKE) ENABLE_OPTIMIZED=1 all ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001511 fi
Reid Spencerfc66af42004-11-29 05:00:33 +00001512 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencerf88808a2004-10-30 09:19:36 +00001513 $(Verb) $(MKDIR) $(DistDir)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001514 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1515 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
Reid Spencer100080c2004-10-25 08:27:37 +00001516 for file in $(DistFiles) ; do \
1517 case "$$file" in \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001518 $(PROJ_SRC_DIR)/*) \
Reid Spencer81546582004-12-04 22:34:09 +00001519 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1520 ;; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001521 $(PROJ_SRC_ROOT)/*) \
Reid Spencer81546582004-12-04 22:34:09 +00001522 file=`echo "$$file" | \
1523 sed "s#^$$srcrootstrip/##"` \
1524 ;; \
Reid Spencer100080c2004-10-25 08:27:37 +00001525 esac; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001526 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1527 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1528 from_dir="$(PROJ_SRC_DIR)" ; \
Reid Spencer81546582004-12-04 22:34:09 +00001529 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001530 from_dir=. ; \
Reid Spencer81546582004-12-04 22:34:09 +00001531 fi ; \
1532 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001533 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1534 to_dir="$(DistDir)/$$dir"; \
1535 $(MKDIR) "$$to_dir" ; \
1536 else \
1537 to_dir="$(DistDir)"; \
1538 fi; \
1539 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1540 if test -n "$$mid_dir" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001541 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001542 fi ; \
1543 if test -d "$$from_dir/$$file"; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001544 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1545 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
Reid Spencer13f51932005-05-24 02:33:20 +00001546 cd $(PROJ_SRC_DIR) ; \
1547 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1548 ( cd $$to_dir ; $(TAR) xf - ) ; \
1549 cd $(PROJ_OBJ_DIR) ; \
1550 else \
1551 cd $$from_dir ; \
1552 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1553 ( cd $$to_dir ; $(TAR) xf - ) ; \
1554 cd $(PROJ_OBJ_DIR) ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001555 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +00001556 elif test -f "$$from_dir/$$file" ; then \
Reid Spencerafdc82c2004-12-16 18:26:53 +00001557 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001558 elif test -L "$$from_dir/$$file" ; then \
Reid Spencerafdc82c2004-12-16 18:26:53 +00001559 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001560 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer81546582004-12-04 22:34:09 +00001561 $(EchoCmd) "===== WARNING: Distribution Source " \
1562 "$$from_dir/$$file Not Found!" ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001563 elif test "$(Verb)" != '@' ; then \
1564 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001565 fi; \
1566 done
Reid Spencerf88808a2004-10-30 09:19:36 +00001567 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer100080c2004-10-25 08:27:37 +00001568 if test "$$subdir" \!= "." ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001569 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001570 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer15b85092006-04-10 16:46:04 +00001571 ( cd $$subdir && $(MAKE) ENABLE_OPTIMIZED=1 \
Reid Spencer056f0222006-04-07 16:06:18 +00001572 DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001573 fi; \
1574 done
Reid Spencer81546582004-12-04 22:34:09 +00001575 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer13f51932005-05-24 02:33:20 +00001576 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
Chris Lattnerb8e7aa02006-02-14 04:27:15 +00001577 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1578 -name .svn \) -print` ;\
Reid Spencer81546582004-12-04 22:34:09 +00001579 $(MAKE) dist-hook ; \
1580 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1581 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1582 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1583 -o ! -type d ! -perm -444 -exec \
1584 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1585 || chmod -R a+r $(DistDir) ; \
1586 fi
Reid Spencer100080c2004-10-25 08:27:37 +00001587
Reid Spencerf88808a2004-10-30 09:19:36 +00001588# This is invoked by distdir target, define it as a no-op to avoid errors if not
1589# defined by user.
Reid Spencer100080c2004-10-25 08:27:37 +00001590dist-hook::
1591
Reid Spencer23a70372004-10-22 23:06:30 +00001592endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001593
1594###############################################################################
Reid Spencer12a3a052004-10-24 07:53:21 +00001595# TOP LEVEL - targets only to apply at the top level directory
1596###############################################################################
1597
1598ifeq ($(LEVEL),.)
1599
1600#------------------------------------------------------------------------
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001601# Install support for the project's include files:
Reid Spencer12a3a052004-10-24 07:53:21 +00001602#------------------------------------------------------------------------
1603install-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001604 $(Echo) Installing include files
Reid Spencerba6a3db2005-01-16 02:20:54 +00001605 $(Verb) $(MKDIR) $(PROJ_includedir)
Reid Spencerc43b1d42005-02-24 03:56:32 +00001606 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001607 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer48a82f42005-02-16 15:54:03 +00001608 for hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
1609 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS ` ; do \
Reid Spencerc43b1d42005-02-24 03:56:32 +00001610 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1611 if test \! -d "$$instdir" ; then \
1612 $(EchoCmd) Making install directory $$instdir ; \
1613 $(MKDIR) $$instdir ;\
1614 fi ; \
1615 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer48a82f42005-02-16 15:54:03 +00001616 done ; \
Reid Spencer12a3a052004-10-24 07:53:21 +00001617 fi
Reid Spencer528c9802005-12-23 22:27:56 +00001618ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencerc43b1d42005-02-24 03:56:32 +00001619 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
Reid Spencer48a82f42005-02-16 15:54:03 +00001620 cd $(PROJ_OBJ_ROOT)/include && \
Reid Spencer528c9802005-12-23 22:27:56 +00001621 for hdr in `find . -type f -print | grep -v CVS` ; do \
Reid Spencerc43b1d42005-02-24 03:56:32 +00001622 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer48a82f42005-02-16 15:54:03 +00001623 done ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001624 fi
Reid Spencer528c9802005-12-23 22:27:56 +00001625endif
Reid Spencer12a3a052004-10-24 07:53:21 +00001626
1627uninstall-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001628 $(Echo) Uninstalling include files
Reid Spencerba6a3db2005-01-16 02:20:54 +00001629 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1630 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer12a3a052004-10-24 07:53:21 +00001631 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001632 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' \
1633 -o -name '*.in' ')' -print ')' | \
1634 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001635 cd $(PROJ_SRC_ROOT)/include && \
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001636 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1637 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001638 fi
Reid Spencer12a3a052004-10-24 07:53:21 +00001639
Reid Spencer12a3a052004-10-24 07:53:21 +00001640endif
1641
Reid Spencerf206bd72004-10-22 21:01:56 +00001642#------------------------------------------------------------------------
1643# Print out the directories used for building
Reid Spencerf88808a2004-10-30 09:19:36 +00001644#------------------------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001645printvars::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001646 $(Echo) "BuildMode : " '$(BuildMode)'
1647 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1648 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1649 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1650 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1651 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1652 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1653 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1654 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1655 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1656 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
Reid Spencerfe0a01e2005-02-16 16:13:02 +00001657 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
Reid Spencerba6a3db2005-01-16 02:20:54 +00001658 $(Echo) "UserTargets : " '$(UserTargets)'
1659 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1660 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1661 $(Echo) "ObjDir : " '$(ObjDir)'
1662 $(Echo) "LibDir : " '$(LibDir)'
1663 $(Echo) "ToolDir : " '$(ToolDir)'
1664 $(Echo) "ExmplDir : " '$(ExmplDir)'
1665 $(Echo) "Sources : " '$(Sources)'
1666 $(Echo) "TDFiles : " '$(TDFiles)'
1667 $(Echo) "INCFiles : " '$(INCFiles)'
1668 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
Reid Spencerfefb9ea2005-03-01 16:27:06 +00001669 $(Echo) "PreConditions: " '$(PreConditions)'
Reid Spencerba6a3db2005-01-16 02:20:54 +00001670 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1671 $(Echo) "Compile.C : " '$(Compile.C)'
1672 $(Echo) "Archive : " '$(Archive)'
1673 $(Echo) "YaccFiles : " '$(YaccFiles)'
1674 $(Echo) "LexFiles : " '$(LexFiles)'
1675 $(Echo) "Module : " '$(Module)'
Reid Spencerb48e3f82005-08-24 10:43:10 +00001676 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'
Reid Spencerece13582006-04-09 23:41:14 +00001677 $(Echo) "SubDirs : " '$(SubDirs)'