blob: affd0fb35989c2450c7242e4b7f947d2fd6164e9 [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)
211 OmitFramePointer := -fomit-frame-pointer
212 endif
Chris Lattner98c79c32006-03-21 01:06:41 +0000213 CXX.Flags := -O3 -finline-functions -felide-constructors $(OmitFramePointer)
214 C.Flags := -O3 $(OmitFramePointer)
215 LD.Flags := -O3
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000216 else
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000217 BuildMode := Debug
Chris Lattner98c79c32006-03-21 01:06:41 +0000218 CXX.Flags := -g
219 C.Flags := -g
220 LD.Flags := -g
Reid Spencerf206bd72004-10-22 21:01:56 +0000221 KEEP_SYMBOLS := 1
Chris Lattner98c79c32006-03-21 01:06:41 +0000222 # Assertions default to ON for debug builds.
223 ENABLE_ASSERTIONS := 1
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000224 endif
225endif
226
Chris Lattner98c79c32006-03-21 01:06:41 +0000227# If this is a debug build or if ENABLE_ASSERTIONS=1 is specified on the make
228# command line, enable assertions.
229ifdef ENABLE_ASSERTIONS
230 CXX.Flags += -D_DEBUG
231 C.Flags += -D_DEBUG
232else
233 CXX.Flags += -DNDEBUG
234 C.Flags += -DNDEBUG
235endif
236
Reid Spencer6f682b72006-03-22 15:59:55 +0000237CXX.Flags += $(CXXFLAGS)
238C.Flags += $(CFLAGS)
239CPP.BaseFlags += $(CPPFLAGS)
240LD.Flags += $(LDFLAGS)
241AR.Flags := cru
Reid Spencerf88808a2004-10-30 09:19:36 +0000242LibTool.Flags := --tag=CXX
Reid Spencer81cd0492004-10-23 20:04:14 +0000243
Andrew Lenharth9a98def2005-02-13 03:41:10 +0000244#Make Floating point ieee complient on alpha
245ifeq ($(ARCH),Alpha)
Reid Spencer6f682b72006-03-22 15:59:55 +0000246 CXX.Flags += -mieee
247 CPP.BaseFlags += -mieee
Andrew Lenharth9a98def2005-02-13 03:41:10 +0000248endif
249
Reid Spencer81cd0492004-10-23 20:04:14 +0000250#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000251# Directory locations
Reid Spencer81cd0492004-10-23 20:04:14 +0000252#--------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +0000253ObjDir := $(PROJ_OBJ_DIR)/$(BuildMode)
254LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
255ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
256ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000257LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer0dbf1012004-11-18 20:04:39 +0000258LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencerb9f8de62004-12-28 07:59:22 +0000259LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer2bba41c2004-12-22 05:57:21 +0000260CFERuntimeLibDir := $(LLVMGCCDIR)/lib
John Criswell3ef61af2003-06-30 21:59:07 +0000261
Reid Spencer81cd0492004-10-23 20:04:14 +0000262#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000263# Full Paths To Compiled Tools and Utilities
Reid Spencer81cd0492004-10-23 20:04:14 +0000264#--------------------------------------------------------------------
Reid Spencerb12e2902005-01-14 16:33:36 +0000265EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
266Echo = @$(EchoCmd)
Reid Spencerf88808a2004-10-30 09:19:36 +0000267ifndef LIBTOOL
Reid Spencerf206bd72004-10-22 21:01:56 +0000268LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencerf88808a2004-10-30 09:19:36 +0000269endif
270ifndef LLVMAS
271LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
272endif
273ifndef BURG
274BURG := $(LLVMToolDir)/burg$(EXEEXT)
275endif
276ifndef TBLGEN
277TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
278endif
Chris Lattner0ea40c92004-11-29 19:47:58 +0000279ifndef GCCAS
280GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
281endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000282ifndef GCCLD
283GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
284endif
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000285ifndef LDIS
286LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
287endif
288ifndef LLI
289LLI := $(LLVMToolDir)/lli$(EXEEXT)
290endif
Alkis Evlogimenos24340582005-02-27 10:21:37 +0000291ifndef LLC
292LLC := $(LLVMToolDir)/llc$(EXEEXT)
293endif
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000294ifndef LOPT
Alkis Evlogimenos7c7705d2004-12-13 18:08:29 +0000295LOPT := $(LLVMToolDir)/opt$(EXEEXT)
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000296endif
Alkis Evlogimenos7c04a3d2005-02-02 00:40:15 +0000297ifndef LBUGPOINT
298LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
299endif
300
John Criswelldc665012005-01-03 17:42:57 +0000301LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
302LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000303
Reid Spencer81cd0492004-10-23 20:04:14 +0000304#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000305# Adjust to user's request
Reid Spencer81cd0492004-10-23 20:04:14 +0000306#--------------------------------------------------------------------
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000307
Reid Spencer87e645c2005-01-11 04:31:07 +0000308# Adjust LD.Flags and Libtool.Flags depending on the kind of library that is
309# to be built. Note that if LOADABLE_MODULE is specified then the resulting
310# shared library can be opened with dlopen
311ifdef SHARED_LIBRARY
Reid Spencerf88808a2004-10-30 09:19:36 +0000312 LD.Flags += -rpath $(LibDir)
Reid Spencer87e645c2005-01-11 04:31:07 +0000313 ifdef LOADABLE_MODULE
314 LD.Flags += -module
315 endif
316else
317 LibTool.Flags += --tag=disable-shared
John Criswell3601f372003-07-31 20:58:51 +0000318endif
319
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000320ifdef TOOL_VERBOSE
321 C.Flags += -v
322 CXX.Flags += -v
323 LD.Flags += -v
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000324 VERBOSE := 1
325endif
326
Reid Spencer81cd0492004-10-23 20:04:14 +0000327# Adjust settings for verbose mode
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000328ifndef VERBOSE
Reid Spencerf88808a2004-10-30 09:19:36 +0000329 Verb := @
330 LibTool.Flags += --silent
331 AR.Flags += >/dev/null 2>/dev/null
Reid Spencerba6a3db2005-01-16 02:20:54 +0000332 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
Reid Spencer100080c2004-10-25 08:27:37 +0000333else
Reid Spencerf88808a2004-10-30 09:19:36 +0000334 ConfigureScriptFLAGS :=
Misha Brukman1326a7c2002-09-12 16:05:39 +0000335endif
336
Vikram S. Adved141c282002-09-18 11:55:13 +0000337# By default, strip symbol information from executable
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000338ifndef KEEP_SYMBOLS
Reid Spencerf88808a2004-10-30 09:19:36 +0000339 Strip := $(PLATFORMSTRIPOPTS)
340 StripWarnMsg := "(without symbols)"
Reid Spencer247a10e2005-02-24 07:12:43 +0000341 Install.StripFlag += -s
Vikram S. Adved141c282002-09-18 11:55:13 +0000342endif
343
Reid Spencer81cd0492004-10-23 20:04:14 +0000344# Adjust linker flags for building an executable
Reid Spencerf206bd72004-10-22 21:01:56 +0000345ifdef TOOLNAME
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000346ifdef EXAMPLE_TOOL
347 LD.Flags += -rpath $(ExmplDir) -export-dynamic
348else
Reid Spencerf88808a2004-10-30 09:19:36 +0000349 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000350endif
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000351endif
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000352
Reid Spencer81cd0492004-10-23 20:04:14 +0000353#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000354# Options To Invoke Tools
Reid Spencer81cd0492004-10-23 20:04:14 +0000355#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000356
357CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
358
Duraid Madina60c9a3c2005-05-16 06:38:09 +0000359ifeq ($(OS),HP-UX)
Duraid Madina1f898af2006-02-15 03:20:16 +0000360 CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
Duraid Madina60c9a3c2005-05-16 06:38:09 +0000361endif
362
Chris Lattnerd81eba52006-04-06 06:30:15 +0000363# If we are building a universal binary on Mac OS/X, pass extra options. This is
364# useful to people that want to link the LLVM libraries into their universal apps.
365ifdef UNIVERSAL
366 CompileCommonOpts += -arch i386 -arch ppc -isysroot /Developer/SDKs/MACOSX10.4u.sdk/
367 DISABLE_AUTO_DEPENDENCIES=1
368endif
369
Evan Chengbb66ec22006-04-07 08:31:56 +0000370# Temporary workaround for a Mac OSX / x86 compatibility issue.
371ifeq ($(OS),Darwin)
372ifeq ($(ARCH),x86)
373 CXX.Flags += -fno-use-cxa-atexit
374endif
Evan Cheng1e86e672006-04-07 08:10:09 +0000375endif
376
Reid Spencer6f682b72006-03-22 15:59:55 +0000377LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
378CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
379# All -I flags should go here, so that they don't confuse llvm-config.
380CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
381 -I$(PROJ_OBJ_ROOT)/include \
382 -I$(PROJ_SRC_ROOT)/include \
383 -I$(LLVM_OBJ_ROOT)/include \
384 -I$(LLVM_SRC_ROOT)/include \
385 $(CPP.BaseFlags)
Reid Spencerf206bd72004-10-22 21:01:56 +0000386
Reid Spencerf88808a2004-10-30 09:19:36 +0000387Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
388LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
Reid Spencer2bba41c2004-12-22 05:57:21 +0000389BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000390 $(C.Flags)
Chris Lattnerbb087952005-10-05 00:28:41 +0000391Preprocess.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -E $(C.Flags)
392
Reid Spencerf88808a2004-10-30 09:19:36 +0000393Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
394LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
Reid Spencerc005fba2004-12-24 14:47:34 +0000395BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000396 $(CXX.Flags)
Chris Lattnerbb087952005-10-05 00:28:41 +0000397Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
Reid Spencerf88808a2004-10-30 09:19:36 +0000398Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
399 $(CompileCommonOpts) $(LD.Flags) $(Strip)
400Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000401 $(CompileCommonOpts)
Reid Spencerfe0a01e2005-02-16 16:13:02 +0000402LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
403 $(Install.Flags)
Reid Spencer247a10e2005-02-24 07:12:43 +0000404ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
Reid Spencer6f682b72006-03-22 15:59:55 +0000405ScriptInstall = $(INSTALL) -m 0755
Reid Spencer247a10e2005-02-24 07:12:43 +0000406DataInstall = $(INSTALL) -m 0644
Reid Spencerba6a3db2005-01-16 02:20:54 +0000407Burg = $(BURG) -I $(PROJ_SRC_DIR)
Chris Lattner8a87f5f2006-03-03 01:54:54 +0000408TableGen = $(TBLGEN) -I $(PROJ_SRC_DIR) -I$(PROJ_SRC_ROOT)/include
Reid Spencerf88808a2004-10-30 09:19:36 +0000409Archive = $(AR) $(AR.Flags)
Reid Spencer32f7e422004-12-02 09:28:21 +0000410LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencerf206bd72004-10-22 21:01:56 +0000411ifdef RANLIB
Reid Spencer81cd0492004-10-23 20:04:14 +0000412Ranlib = $(RANLIB)
Reid Spencerf206bd72004-10-22 21:01:56 +0000413else
Reid Spencer81cd0492004-10-23 20:04:14 +0000414Ranlib = ranlib
John Criswell3ef61af2003-06-30 21:59:07 +0000415endif
416
Chris Lattner2f7c9632001-06-06 20:29:01 +0000417#----------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +0000418# Get the list of source files and compute object file
419# names from them.
Reid Spencer81cd0492004-10-23 20:04:14 +0000420#----------------------------------------------------------
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000421
422ifndef SOURCES
423 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
424 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
425 $(PROJ_SRC_DIR)/*.l))
Reid Spencerf88808a2004-10-30 09:19:36 +0000426else
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000427 Sources := $(SOURCES)
428endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000429
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000430ifdef BUILT_SOURCES
431Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Reid Spencer81546582004-12-04 22:34:09 +0000432endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000433
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000434BaseNameSources := $(sort $(basename $(Sources)))
435
436ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
437ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
438ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
439
Reid Spencer81cd0492004-10-23 20:04:14 +0000440###############################################################################
441# DIRECTORIES: Handle recursive descent of directory structure
442###############################################################################
John Criswell3601f372003-07-31 20:58:51 +0000443
Chris Lattner2f7c9632001-06-06 20:29:01 +0000444#---------------------------------------------------------
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000445# Provide rules to make install dirs. This must be early
446# in the file so they get built before dependencies
447#---------------------------------------------------------
448
Reid Spencer90b689d2005-05-19 20:26:14 +0000449$(PROJ_bindir): $(PROJ_bindir)/.dir
450$(PROJ_libdir): $(PROJ_libdir)/.dir
451$(PROJ_includedir): $(PROJ_includedir)/.dir
452$(PROJ_etcdir): $(PROJ_etcdir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000453
Reid Spencerf88808a2004-10-30 09:19:36 +0000454# To create other directories, as needed, and timestamp their creation
455%/.dir:
456 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfc66af42004-11-29 05:00:33 +0000457 $(Verb) $(DATE) > $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000458
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000459.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
460.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000461
462#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000463# Handle the DIRS options for sequential construction
Chris Lattner2f7c9632001-06-06 20:29:01 +0000464#---------------------------------------------------------
465
Reid Spencerf88808a2004-10-30 09:19:36 +0000466SubDirs :=
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000467ifdef DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000468SubDirs += $(DIRS)
469$(RecursiveTargets)::
470 $(Verb) for dir in $(DIRS); do \
Reid Spencerf206bd72004-10-22 21:01:56 +0000471 if [ ! -f $$dir/Makefile ]; then \
472 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000473 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000474 fi; \
Reid Spencer4e197482004-12-08 22:58:34 +0000475 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
476 ($(MAKE) -C $$dir $@ ) || exit 1; \
477 fi ; \
Chris Lattner539a23c2002-09-17 23:35:02 +0000478 done
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000479endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000480
Reid Spencer81cd0492004-10-23 20:04:14 +0000481#---------------------------------------------------------
482# Handle the EXPERIMENTAL_DIRS options ensuring success
483# after each directory is built.
484#---------------------------------------------------------
485ifdef EXPERIMENTAL_DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000486$(RecursiveTargets)::
487 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer81cd0492004-10-23 20:04:14 +0000488 if [ ! -f $$dir/Makefile ]; then \
489 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000490 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000491 fi; \
Reid Spencer4e197482004-12-08 22:58:34 +0000492 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
493 ($(MAKE) -C $$dir $@ ) || exit 0; \
494 fi ; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000495 done
496endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000497
Reid Spencerc49a8632005-12-21 23:17:06 +0000498#-----------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000499# Handle the PARALLEL_DIRS options for parallel construction
Reid Spencerc49a8632005-12-21 23:17:06 +0000500#-----------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000501ifdef PARALLEL_DIRS
502
Reid Spencerf88808a2004-10-30 09:19:36 +0000503SubDirs += $(PARALLEL_DIRS)
504
Reid Spencerd4bd3752004-12-03 20:08:48 +0000505# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencerf88808a2004-10-30 09:19:36 +0000506all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
507clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000508clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencerf88808a2004-10-30 09:19:36 +0000509install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000510uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencerd4bd3752004-12-03 20:08:48 +0000511install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000512
Reid Spencer81546582004-12-04 22:34:09 +0000513ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer81cd0492004-10-23 20:04:14 +0000514
Reid Spencer81546582004-12-04 22:34:09 +0000515$(ParallelTargets) :
Reid Spencerf88808a2004-10-30 09:19:36 +0000516 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencerf206bd72004-10-22 21:01:56 +0000517 $(MKDIR) $(@D); \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000518 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswell6df35dd2003-11-25 19:32:22 +0000519 fi; \
Reid Spencer4e197482004-12-08 22:58:34 +0000520 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
521 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
522 fi
Chris Lattner2f7c9632001-06-06 20:29:01 +0000523endif
524
Reid Spencer81cd0492004-10-23 20:04:14 +0000525#---------------------------------------------------------
526# Handle the OPTIONAL_DIRS options for directores that may
527# or may not exist.
528#---------------------------------------------------------
John Criswell8224df92003-06-27 16:58:44 +0000529ifdef OPTIONAL_DIRS
Reid Spencer100080c2004-10-25 08:27:37 +0000530
Reid Spencerf88808a2004-10-30 09:19:36 +0000531SubDirs += $(OPTIONAL_DIRS)
Reid Spencer100080c2004-10-25 08:27:37 +0000532
Reid Spencerf88808a2004-10-30 09:19:36 +0000533$(RecursiveTargets)::
534 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000535 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
Reid Spencerf206bd72004-10-22 21:01:56 +0000536 if [ ! -f $$dir/Makefile ]; then \
537 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000538 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000539 fi; \
Reid Spencer4e197482004-12-08 22:58:34 +0000540 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
541 ($(MAKE) -C$$dir $@ ) || exit 1; \
542 fi ; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000543 fi \
John Criswell8224df92003-06-27 16:58:44 +0000544 done
545endif
546
Reid Spencercc51e7b2004-08-20 09:20:05 +0000547#---------------------------------------------------------
548# Handle the CONFIG_FILES options
549#---------------------------------------------------------
550ifdef CONFIG_FILES
Reid Spencercc51e7b2004-08-20 09:20:05 +0000551
Reid Spencerba6a3db2005-01-16 02:20:54 +0000552install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
553 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000554 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000555 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
Reid Spencerc43b1d42005-02-24 03:56:32 +0000556 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000557 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
Reid Spencerc43b1d42005-02-24 03:56:32 +0000558 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer39d6a612004-11-23 05:59:53 +0000559 else \
560 $(ECHO) Error: cannot find config file $${file}. ; \
561 fi \
Reid Spencercc51e7b2004-08-20 09:20:05 +0000562 done
Reid Spencer81cd0492004-10-23 20:04:14 +0000563
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000564uninstall-local::
Reid Spencerba6a3db2005-01-16 02:20:54 +0000565 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000566 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000567 $(RM) -f $(PROJ_etcdir)/$${file} ; \
Reid Spencer12a3a052004-10-24 07:53:21 +0000568 done
569
Reid Spencercc51e7b2004-08-20 09:20:05 +0000570endif
571
Reid Spencer81cd0492004-10-23 20:04:14 +0000572###############################################################################
Reid Spencera80f1672005-05-19 00:37:31 +0000573# Set up variables for building libararies
574###############################################################################
575
576#---------------------------------------------------------
577# Handle the special "JIT" value for LLVM_LIBS which is a
578# shorthand for a bunch of libraries that get the correct
579# JIT support for a library or a tool that runs JIT.
580#---------------------------------------------------------
Reid Spencerd813b952006-03-24 07:36:57 +0000581ifeq ($(firstword $(LLVMLIBS)),config)
582LLVM_CONFIG := $(LLVM_SRC_ROOT)/utils/llvm-config/llvm-config
583LLVMLIBS := $(shell $(LLVM_CONFIG) $(wordlist 2,9999,$(LLVMLIBS)))
584LLVMLIBS := $(patsubst $(PROJ_libdir)/%,%,$(LLVMLIBS))
585LLVMLIBS := $(patsubst %.o,%,$(LLVMLIBS))
586LLVMLIBS := $(patsubst -l%,%.a,$(LLVMLIBS))
587endif
588
Reid Spencera80f1672005-05-19 00:37:31 +0000589ifeq ($(LLVMLIBS),JIT)
590
591# Make sure we can get our own symbols in the tool
592Link += -dlopen self
593
594# Generic JIT libraries
595JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
596
597# You can enable the X86 JIT on a non-X86 host by setting the flag
598# ENABLE_X86_JIT on the make command line. If not, it will still be
599# enabled automagically on an X86 host.
600ifeq ($(ARCH), x86)
601 ENABLE_X86_JIT = 1
602endif
603
604# What the X86 JIT requires
605ifdef ENABLE_X86_JIT
606 JIT_LIBS += LLVMX86 LLVMSelectionDAG
607endif
608
609# You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
610# ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
611# enabled automagically on an SparcV9 host.
612ifeq ($(ARCH), Sparc)
613 ENABLE_SPARCV9_JIT = 1
614endif
615
616# What the Sparc JIT requires
617ifdef ENABLE_SPARCV9_JIT
618 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
John Criswell94b7bea2005-10-26 20:35:13 +0000619 LLVMSparcV9LiveVar LLVMInstrumentation.a \
Reid Spencera80f1672005-05-19 00:37:31 +0000620 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
John Criswell94b7bea2005-10-26 20:35:13 +0000621 LLVMDataStructure LLVMSparcV9RegAlloc
Reid Spencera80f1672005-05-19 00:37:31 +0000622endif
623
624# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
625# ENABLE_PPC_JIT on the make command line. If not, it will still be
626# enabled automagically on an PowerPC host.
627ifeq ($(ARCH), PowerPC)
628 ENABLE_PPC_JIT = 1
629endif
630
631# What the PowerPC JIT requires
632ifdef ENABLE_PPC_JIT
633 JIT_LIBS += LLVMPowerPC LLVMSelectionDAG
634endif
635
Andrew Lenharthc7fe0f52005-07-22 20:54:01 +0000636# You can enable the Alpha JIT on a non-Alpha host by setting the flag
637# ENABLE_ALPHA_JIT on the make command line. If not, it will still be
Misha Brukman08c36452005-07-22 22:43:40 +0000638# enabled automagically on an Alpha host.
Andrew Lenharthc7fe0f52005-07-22 20:54:01 +0000639ifeq ($(ARCH), Alpha)
640 ENABLE_ALPHA_JIT = 1
641endif
642
Andrew Lenharth99007012005-07-22 22:00:24 +0000643# What the Alpha JIT requires
Andrew Lenharthc7fe0f52005-07-22 20:54:01 +0000644ifdef ENABLE_ALPHA_JIT
645 JIT_LIBS += LLVMAlpha LLVMSelectionDAG
646endif
647
John Criswellfe5f33b2005-10-27 15:54:34 +0000648LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts.a LLVMTransformUtils.a LLVMAnalysis.a \
Reid Spencera80f1672005-05-19 00:37:31 +0000649 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
650 LLVMSystem.a $(PLATFORMLIBDL)
651endif
652
653#---------------------------------------------------------
654# Define various command line options pertaining to the
655# libraries needed when linking. There are "Proj" libs
656# (defined by the user's project) and "LLVM" libs (defined
657# by the # LLVM project).
658#---------------------------------------------------------
Misha Brukman5fbf58a2005-08-17 02:38:56 +0000659# Some versions of gcc on Alpha produce too many symbols, so use a .a file
Andrew Lenharth6b62b472005-08-13 05:09:50 +0000660ifeq ($(ARCH),Alpha)
661USEDLIBS := $(subst LLVMCore, LLVMCore.a, $(USEDLIBS))
662LLVMLIBS := $(subst LLVMCore, LLVMCore.a, $(LLVMLIBS))
Reid Spencer6f682b72006-03-22 15:59:55 +0000663CORE_IS_ARCHIVE := 1
664else
665CORE_IS_ARCHIVE := 0
Andrew Lenharth6b62b472005-08-13 05:09:50 +0000666endif
667
Reid Spencera80f1672005-05-19 00:37:31 +0000668ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
669ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
670LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
671LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
672ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
673LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
674ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
675LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
676
677###############################################################################
Reid Spencer81cd0492004-10-23 20:04:14 +0000678# Library Build Rules: Four ways to build a library
679###############################################################################
Chris Lattner2f7c9632001-06-06 20:29:01 +0000680
Reid Spencerd78077d2004-12-05 05:17:22 +0000681#---------------------------------------------------------
682# Bytecode Module Targets:
683# If the user set MODULE_NAME then they want to build a
684# bytecode module from the sources. We compile all the
685# sources and link it together into a single bytecode
686# module.
687#---------------------------------------------------------
688
689ifdef MODULE_NAME
Reid Spencere9fa5442005-02-14 21:54:08 +0000690ifeq ($(strip $(LLVMGCC)),)
Reid Spencer83745dd2005-05-13 18:32:54 +0000691$(warning Modules require llvm-gcc but no llvm-gcc is available ****)
Reid Spencere9fa5442005-02-14 21:54:08 +0000692else
Reid Spencerd78077d2004-12-05 05:17:22 +0000693
694Module := $(LibDir)/$(MODULE_NAME).bc
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000695LinkModule := $(GCCLD)
Reid Spencerd78077d2004-12-05 05:17:22 +0000696
697ifdef EXPORTED_SYMBOL_FILE
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000698LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencerd78077d2004-12-05 05:17:22 +0000699endif
700
701$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
Reid Spencer83745dd2005-05-13 18:32:54 +0000702 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
Reid Spencerd78077d2004-12-05 05:17:22 +0000703 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
704
705all-local:: $(Module)
706
707clean-local::
708ifneq ($(strip $(Module)),)
709 -$(Verb) $(RM) -f $(Module)
710endif
711
Reid Spencerefe3a822004-12-13 07:38:07 +0000712ifdef BYTECODE_DESTINATION
713ModuleDestDir := $(BYTECODE_DESTINATION)
714else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000715ModuleDestDir := $(PROJ_libdir)
Reid Spencerefe3a822004-12-13 07:38:07 +0000716endif
Reid Spencerd78077d2004-12-05 05:17:22 +0000717
Reid Spencerefe3a822004-12-13 07:38:07 +0000718DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
719
720install-module:: $(DestModule)
Reid Spencerd78077d2004-12-05 05:17:22 +0000721install-local:: $(DestModule)
722
Reid Spencerefe3a822004-12-13 07:38:07 +0000723$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencerd78077d2004-12-05 05:17:22 +0000724 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
Reid Spencerd77a4c02005-02-24 21:30:37 +0000725 $(Verb) $(DataInstall) $(Module) $(DestModule)
Reid Spencerd78077d2004-12-05 05:17:22 +0000726
727uninstall-local::
728 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
729 -$(Verb) $(RM) -f $(DestModule)
730
731endif
Reid Spencere9fa5442005-02-14 21:54:08 +0000732endif
Brian Gaekeecc92bf2004-01-22 22:53:48 +0000733
Reid Spencer81cd0492004-10-23 20:04:14 +0000734# if we're building a library ...
Chris Lattner2f7c9632001-06-06 20:29:01 +0000735ifdef LIBRARYNAME
Vikram S. Advefe346892001-07-15 13:16:47 +0000736
Chris Lattner0100eab2002-09-16 22:36:42 +0000737# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000738LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencer87e645c2005-01-11 04:31:07 +0000739ifdef LOADABLE_MODULE
740LibName.LA := $(LibDir)/$(LIBRARYNAME).la
741else
Reid Spencerf88808a2004-10-30 09:19:36 +0000742LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
Reid Spencer87e645c2005-01-11 04:31:07 +0000743endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000744LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
745LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer32f7e422004-12-02 09:28:21 +0000746LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000747
Reid Spencer81cd0492004-10-23 20:04:14 +0000748#---------------------------------------------------------
749# Shared Library Targets:
750# If the user asked for a shared library to be built
751# with the SHARED_LIBRARY variable, then we provide
752# targets for building them.
753#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000754ifdef SHARED_LIBRARY
755
Reid Spencerf88808a2004-10-30 09:19:36 +0000756all-local:: $(LibName.LA)
Reid Spencerf206bd72004-10-22 21:01:56 +0000757
Reid Spencera80f1672005-05-19 00:37:31 +0000758ifdef LINK_LIBS_IN_SHARED
759$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
760 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
761 $(Verb) $(Link) -o $@ $(ObjectsLO) \
762 $(ProjLibsOptions) $(LLVMLibsOptions)
763 $(Verb) $(LTInstall) $@ $(LibDir)
764else
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000765$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000766 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf88808a2004-10-30 09:19:36 +0000767 $(Verb) $(Link) -o $@ $(ObjectsLO)
768 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencera80f1672005-05-19 00:37:31 +0000769endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000770
771clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000772ifneq ($(strip $(LibName.LA)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000773 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000774endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000775
Reid Spencerba6a3db2005-01-16 02:20:54 +0000776DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf206bd72004-10-22 21:01:56 +0000777
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000778install-local:: $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000779
Reid Spencerba6a3db2005-01-16 02:20:54 +0000780$(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000781 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000782 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000783 $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
Reid Spencer12a3a052004-10-24 07:53:21 +0000784
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000785uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000786 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000787 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
Reid Spencer12a3a052004-10-24 07:53:21 +0000788
Reid Spencerf206bd72004-10-22 21:01:56 +0000789endif
790
Reid Spencer81cd0492004-10-23 20:04:14 +0000791#---------------------------------------------------------
792# Bytecode Library Targets:
793# If the user asked for a bytecode library to be built
794# with the BYTECODE_LIBRARY variable, then we provide
795# targets for building them.
796#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000797ifdef BYTECODE_LIBRARY
Reid Spencere9fa5442005-02-14 21:54:08 +0000798ifeq ($(strip $(LLVMGCC)),)
Reid Spencer83745dd2005-05-13 18:32:54 +0000799$(warning Bytecode libraries require llvm-gcc which could not be found ****)
Reid Spencere9fa5442005-02-14 21:54:08 +0000800else
Reid Spencerf206bd72004-10-22 21:01:56 +0000801
Reid Spencer32f7e422004-12-02 09:28:21 +0000802all-local:: $(LibName.BCA)
803
804ifdef EXPORTED_SYMBOL_FILE
Chris Lattnerb3eb31f2006-01-27 22:13:12 +0000805BCLinkLib = $(GCCLD) -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer32f7e422004-12-02 09:28:21 +0000806
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000807$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +0000808 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +0000809 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
810 "(internalize)"
Chris Lattnere3d98f12004-12-02 21:23:43 +0000811 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencer85d55ad2004-12-13 03:59:35 +0000812 $(Verb) $(RM) -f $@
Reid Spencer32f7e422004-12-02 09:28:21 +0000813 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencerf206bd72004-10-22 21:01:56 +0000814else
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000815$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +0000816 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +0000817 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencer85d55ad2004-12-13 03:59:35 +0000818 $(Verb) $(RM) -f $@
Reid Spencer32f7e422004-12-02 09:28:21 +0000819 $(Verb) $(LArchive) $@ $(ObjectsBC)
820
Reid Spencerf206bd72004-10-22 21:01:56 +0000821endif
822
Reid Spencer81cd0492004-10-23 20:04:14 +0000823clean-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000824ifneq ($(strip $(LibName.BCA)),)
825 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000826endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000827
Reid Spencer65086be2004-12-13 07:28:21 +0000828ifdef BYTECODE_DESTINATION
829BytecodeDestDir := $(BYTECODE_DESTINATION)
830else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000831BytecodeDestDir := $(PROJ_libdir)
Reid Spencer65086be2004-12-13 07:28:21 +0000832endif
833
834DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
Reid Spencer32f7e422004-12-02 09:28:21 +0000835
Reid Spencerd4bd3752004-12-03 20:08:48 +0000836install-bytecode-local:: $(DestBytecodeLib)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000837
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000838install-local:: $(DestBytecodeLib)
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000839
Reid Spencer65086be2004-12-13 07:28:21 +0000840$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
Reid Spencer32f7e422004-12-02 09:28:21 +0000841 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerdcc53752005-02-24 21:36:32 +0000842 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000843
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000844uninstall-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000845 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000846 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000847
848endif
Reid Spencere9fa5442005-02-14 21:54:08 +0000849endif
Vikram S. Adve15bd3ad2002-08-02 18:34:12 +0000850
Reid Spencerf88808a2004-10-30 09:19:36 +0000851#---------------------------------------------------------
852# ReLinked Library Targets:
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000853# If the user explicitly requests a relinked library with
854# BUILD_RELINKED, provide it. Otherwise, if they specify
855# neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
856# them one.
Reid Spencerf88808a2004-10-30 09:19:36 +0000857#---------------------------------------------------------
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000858ifndef BUILD_ARCHIVE
Chris Lattner76d98ba2002-07-23 17:56:16 +0000859ifndef DONT_BUILD_RELINKED
Chris Lattner1b91cbd2005-10-24 02:21:45 +0000860BUILD_RELINKED = 1
861endif
862endif
863
864ifdef BUILD_RELINKED
Reid Spencerf206bd72004-10-22 21:01:56 +0000865
Reid Spencerf88808a2004-10-30 09:19:36 +0000866all-local:: $(LibName.O)
867
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000868$(LibName.O): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000869 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencerf88808a2004-10-30 09:19:36 +0000870 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencerf206bd72004-10-22 21:01:56 +0000871
Reid Spencer81cd0492004-10-23 20:04:14 +0000872clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000873ifneq ($(strip $(LibName.O)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000874 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencer12a3a052004-10-24 07:53:21 +0000875endif
876
Reid Spencerba6a3db2005-01-16 02:20:54 +0000877DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
Reid Spencer12a3a052004-10-24 07:53:21 +0000878
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000879install-local:: $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000880
Reid Spencerba6a3db2005-01-16 02:20:54 +0000881$(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000882 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000883 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000884
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000885uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000886 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000887 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000888
Chris Lattner76d98ba2002-07-23 17:56:16 +0000889endif
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000890
Reid Spencerf88808a2004-10-30 09:19:36 +0000891#---------------------------------------------------------
892# Archive Library Targets:
893# If the user wanted a regular archive library built,
894# then we provide targets for building them.
895#---------------------------------------------------------
Chris Lattner76d98ba2002-07-23 17:56:16 +0000896ifdef BUILD_ARCHIVE
Chris Lattner76d98ba2002-07-23 17:56:16 +0000897
Reid Spencerf88808a2004-10-30 09:19:36 +0000898all-local:: $(LibName.A)
899
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000900$(LibName.A): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000901 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000902 -$(Verb) $(RM) -f $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000903 $(Verb) $(Archive) $@ $(ObjectsO)
904 $(Verb) $(Ranlib) $@
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000905
Reid Spencer81cd0492004-10-23 20:04:14 +0000906clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000907ifneq ($(strip $(LibName.A)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000908 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000909endif
910
Reid Spencerba6a3db2005-01-16 02:20:54 +0000911DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
Reid Spencer12a3a052004-10-24 07:53:21 +0000912
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000913install-local:: $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000914
Reid Spencerba6a3db2005-01-16 02:20:54 +0000915$(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000916 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000917 $(Verb) $(MKDIR) $(PROJ_libdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000918 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000919
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000920uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000921 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000922 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000923
924endif
925
926# endif LIBRARYNAME
Reid Spencerf206bd72004-10-22 21:01:56 +0000927endif
928
Reid Spencerdcba7782004-10-24 08:21:04 +0000929###############################################################################
930# Tool Build Rules: Build executable tool based on TOOLNAME option
931###############################################################################
932
Chris Lattner07c7c192001-09-07 22:57:58 +0000933ifdef TOOLNAME
934
Reid Spencerf88808a2004-10-30 09:19:36 +0000935#---------------------------------------------------------
936# Set up variables for building a tool.
937#---------------------------------------------------------
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000938ifdef EXAMPLE_TOOL
Reid Spencer98a2d982005-05-19 21:03:11 +0000939ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000940else
Reid Spencer98a2d982005-05-19 21:03:11 +0000941ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000942endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000943
Reid Spencerf88808a2004-10-30 09:19:36 +0000944#---------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000945# Tell make that we need to rebuild subdirectories before
946# we can link the tool. This affects things like LLI which
947# has library subdirectories.
948#---------------------------------------------------------
949$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner3ecb7762003-01-22 16:13:31 +0000950
Reid Spencerf88808a2004-10-30 09:19:36 +0000951#---------------------------------------------------------
952# Provide targets for building the tools
953#---------------------------------------------------------
954all-local:: $(ToolBuildPath)
John Criswell8224df92003-06-27 16:58:44 +0000955
Reid Spencer81cd0492004-10-23 20:04:14 +0000956clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000957ifneq ($(strip $(ToolBuildPath)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000958 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencer12a3a052004-10-24 07:53:21 +0000959endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000960
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000961ifdef EXAMPLE_TOOL
962$(ToolBuildPath): $(ExmplDir)/.dir
963else
964$(ToolBuildPath): $(ToolDir)/.dir
965endif
966
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000967$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000968 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Chris Lattner35ac7612006-03-10 21:01:34 +0000969 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(LLVMLibsOptions) \
970 $(ProjLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
Chris Lattnere2dcbe02006-02-14 04:25:54 +0000971 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) \
972 $(StripWarnMsg)
Reid Spencer12a3a052004-10-24 07:53:21 +0000973
Reid Spencerba6a3db2005-01-16 02:20:54 +0000974DestTool = $(PROJ_bindir)/$(TOOLNAME)
Reid Spencer12a3a052004-10-24 07:53:21 +0000975
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000976install-local:: $(DestTool)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000977
Reid Spencerba6a3db2005-01-16 02:20:54 +0000978$(DestTool): $(PROJ_bindir) $(ToolBuildPath)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000979 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencerc43b1d42005-02-24 03:56:32 +0000980 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000981
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000982uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000983 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000984 -$(Verb) $(RM) -f $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000985
Reid Spencerf206bd72004-10-22 21:01:56 +0000986endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000987
Reid Spencerf88808a2004-10-30 09:19:36 +0000988###############################################################################
989# Object Build Rules: Build object files based on sources
990###############################################################################
991
Duraid Madinacbbc1842006-02-15 03:23:26 +0000992# FIXME: This should be checking for "if not GCC or ICC", not for "if HP-UX"
993ifeq ($(OS),HP-UX)
994 DISABLE_AUTO_DEPENDENCIES=1
995endif
996
Reid Spencerf88808a2004-10-30 09:19:36 +0000997# Provide rule sets for when dependency generation is enabled
Reid Spencerf206bd72004-10-22 21:01:56 +0000998ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000999
Reid Spencerf88808a2004-10-30 09:19:36 +00001000#---------------------------------------------------------
1001# Create .lo files in the ObjDir directory from the .cpp and .c files...
1002#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001003ifdef SHARED_LIBRARY
1004
Chris Lattner2a023902004-12-16 17:28:50 +00001005$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001006 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Chris Lattnerb8e7aa02006-02-14 04:27:15 +00001007 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
Reid Spencerf88808a2004-10-30 09:19:36 +00001008 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
1009 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +00001010
Chris Lattnerf60c1702005-02-04 21:28:50 +00001011$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1012 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
Chris Lattnerb8e7aa02006-02-14 04:27:15 +00001013 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
Chris Lattnerf60c1702005-02-04 21:28:50 +00001014 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
1015 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
1016
Chris Lattner2a023902004-12-16 17:28:50 +00001017$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001018 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencerf88808a2004-10-30 09:19:36 +00001019 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
1020 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
1021 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +00001022
Reid Spencerf88808a2004-10-30 09:19:36 +00001023#---------------------------------------------------------
1024# Create .o files in the ObjDir directory from the .cpp and .c files...
1025#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001026else
Reid Spencerf206bd72004-10-22 21:01:56 +00001027
Chris Lattner2a023902004-12-16 17:28:50 +00001028$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001029 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +00001030 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
1031 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
1032 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +00001033
Chris Lattnerf60c1702005-02-04 21:28:50 +00001034$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1035 $(Echo) "Compiling $*.cc for $(BuildMode) build"
1036 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
1037 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
1038 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
1039
Chris Lattner2a023902004-12-16 17:28:50 +00001040$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001041 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +00001042 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
1043 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
1044 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +00001045
1046endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001047
Chris Lattnerbb087952005-10-05 00:28:41 +00001048## Rules for building preprocessed (.i/.ii) outputs.
1049$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1050 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1051 $(Verb) $(Preprocess.CXX) $< -o $@
1052
1053$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1054 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1055 $(Verb) $(Preprocess.CXX) $< -o $@
1056
1057 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1058 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1059 $(Verb) $(Preprocess.C) $< -o $@
1060
1061
Reid Spencerf88808a2004-10-30 09:19:36 +00001062#---------------------------------------------------------
Chris Lattnerf60c1702005-02-04 21:28:50 +00001063# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
Reid Spencerf88808a2004-10-30 09:19:36 +00001064#---------------------------------------------------------
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001065
1066$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001067 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001068 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1069 $< -o $@ -S -emit-llvm ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001070 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1071 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +00001072
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001073$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001074 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001075 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" \
1076 $< -o $@ -S -emit-llvm ; \
Chris Lattnerf60c1702005-02-04 21:28:50 +00001077 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1078 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1079
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001080$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001081 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001082 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" \
1083 $< -o $@ -S -emit-llvm ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001084 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1085 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +00001086
Reid Spencerf88808a2004-10-30 09:19:36 +00001087# Provide alternate rule sets if dependencies are disabled
Reid Spencerf206bd72004-10-22 21:01:56 +00001088else
1089
Reid Spencer81cd0492004-10-23 20:04:14 +00001090ifdef SHARED_LIBRARY
1091
Chris Lattner2a023902004-12-16 17:28:50 +00001092$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001093 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +00001094 $(LTCompile.CXX) $< -o $@
1095
Chris Lattnerf60c1702005-02-04 21:28:50 +00001096$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1097 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
1098 $(LTCompile.CXX) $< -o $@
1099
Chris Lattner2a023902004-12-16 17:28:50 +00001100$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerafdc82c2004-12-16 18:26:53 +00001101 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +00001102 $(LTCompile.C) $< -o $@
1103
1104else
Reid Spencerf206bd72004-10-22 21:01:56 +00001105
Chris Lattner2a023902004-12-16 17:28:50 +00001106$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001107 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer81cd0492004-10-23 20:04:14 +00001108 $(Compile.CXX) $< -o $@
Reid Spencerf206bd72004-10-22 21:01:56 +00001109
Chris Lattnerf60c1702005-02-04 21:28:50 +00001110$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1111 $(Echo) "Compiling $*.cc for $(BuildMode) build"
1112 $(Compile.CXX) $< -o $@
1113
Chris Lattner2a023902004-12-16 17:28:50 +00001114$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerafdc82c2004-12-16 18:26:53 +00001115 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencer81cd0492004-10-23 20:04:14 +00001116 $(Compile.C) $< -o $@
1117endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001118
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001119$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001120 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001121 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Reid Spencerf206bd72004-10-22 21:01:56 +00001122
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001123$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerf60c1702005-02-04 21:28:50 +00001124 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001125 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Chris Lattnerf60c1702005-02-04 21:28:50 +00001126
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001127$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001128 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001129 $(BCCompile.C) $< -o $@ -S -emit-llvm
Brian Gaeke0f148bc2003-12-10 00:26:28 +00001130
Chris Lattner07c7c192001-09-07 22:57:58 +00001131endif
1132
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001133# make the C and C++ compilers strip debug info out of bytecode libraries.
1134ifdef DEBUG_RUNTIME
1135$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1136 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Chris Lattner5b59d7c2006-03-09 06:00:05 +00001137 $(Verb) $(GCCAS) $< -o $@
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001138else
1139$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1140 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
Chris Lattner5b59d7c2006-03-09 06:00:05 +00001141 $(Verb) $(GCCAS) -strip-debug $< -o $@
Chris Lattnerb3eb31f2006-01-27 22:13:12 +00001142endif
1143
1144
Reid Spencerf88808a2004-10-30 09:19:36 +00001145#---------------------------------------------------------
1146# Provide rule to build .bc files from .ll sources,
1147# regardless of dependencies
1148#---------------------------------------------------------
1149$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001150 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +00001151 $(Verb) $(LLVMAS) $< -f -o $@
1152
1153###############################################################################
1154# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1155###############################################################################
Chris Lattner0c4f4fe2003-08-15 02:18:35 +00001156
Reid Spencerf206bd72004-10-22 21:01:56 +00001157ifdef TARGET
1158
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001159TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
1160 $(LLVM_SRC_ROOT)/lib/Target/Target.td \
Chris Lattner8a87f5f2006-03-03 01:54:54 +00001161 $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td \
1162 $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td)
Reid Spencerf88808a2004-10-30 09:19:36 +00001163INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Chris Lattner2a023902004-12-16 17:28:50 +00001164INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1165.PRECIOUS: $(INCTMPFiles) $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001166
Chris Lattner2a023902004-12-16 17:28:50 +00001167# All of these files depend on tblgen and the .td files.
1168$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001169
Chris Lattnerf86914d2004-12-16 17:38:56 +00001170# INCFiles rule: All of the tblgen generated files are emitted to
1171# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1172# us to only "touch" the real file if the contents of it change. IOW, if
1173# tblgen is modified, all of the .inc.tmp files are regereated, but no
1174# dependencies of the .inc files are, unless the contents of the .inc file
1175# changes.
1176$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
Reid Spencerafdc82c2004-12-16 18:26:53 +00001177 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
Chris Lattner2a023902004-12-16 17:28:50 +00001178
1179$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1180$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001181 $(Echo) "Building $(<F) register names with tblgen"
1182 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001183
Chris Lattner2a023902004-12-16 17:28:50 +00001184$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1185$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001186 $(Echo) "Building $(<F) register information header with tblgen"
1187 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001188
Chris Lattner2a023902004-12-16 17:28:50 +00001189$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1190$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001191 $(Echo) "Building $(<F) register info implementation with tblgen"
1192 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001193
Chris Lattner2a023902004-12-16 17:28:50 +00001194$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1195$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001196 $(Echo) "Building $(<F) instruction names with tblgen"
1197 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001198
Chris Lattner2a023902004-12-16 17:28:50 +00001199$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1200$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001201 $(Echo) "Building $(<F) instruction information with tblgen"
1202 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001203
Chris Lattner2a023902004-12-16 17:28:50 +00001204$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1205$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001206 $(Echo) "Building $(<F) assembly writer with tblgen"
1207 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001208
Chris Lattner22f937a2004-12-16 17:34:04 +00001209$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1210$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1211 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Reid Spencerf88808a2004-10-30 09:19:36 +00001212 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001213
Chris Lattner2a023902004-12-16 17:28:50 +00001214$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1215$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001216 $(Echo) "Building $(<F) code emitter with tblgen"
1217 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001218
Chris Lattner33f98bd2005-09-03 01:15:25 +00001219$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1220$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1221 $(Echo) "Building $(<F) instruction selector implementation with tblgen"
1222 $(Verb) $(TableGen) -gen-dag-isel -o $@ $<
1223
Jim Laskey9ed90322005-10-21 19:05:19 +00001224$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1225$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1226 $(Echo) "Building $(<F) subtarget information with tblgen"
1227 $(Verb) $(TableGen) -gen-subtarget -o $@ $<
Chris Lattner33f98bd2005-09-03 01:15:25 +00001228
Reid Spencer81cd0492004-10-23 20:04:14 +00001229clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001230 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001231
1232endif
Chris Lattner0c4f4fe2003-08-15 02:18:35 +00001233
Reid Spencerf88808a2004-10-30 09:19:36 +00001234###############################################################################
1235# LEX AND YACC: Provide rules for generating sources with lex and yacc
1236###############################################################################
Chris Lattnerdb644dd2003-01-16 22:44:19 +00001237
Reid Spencerf88808a2004-10-30 09:19:36 +00001238#---------------------------------------------------------
1239# Provide rules for generating a .cpp source file from
1240# (f)lex input sources.
1241#---------------------------------------------------------
1242
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001243LexFiles := $(filter %.l,$(Sources))
Reid Spencerf88808a2004-10-30 09:19:36 +00001244
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001245ifneq ($(LexFiles),)
1246
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001247# Cancel built-in rules for lex
1248%.c: %.l
1249%.cpp: %.l
Reid Spencerf88808a2004-10-30 09:19:36 +00001250
Chris Lattner8104b4c2006-02-14 05:12:00 +00001251all:: $(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs)
1252
Reid Spencerf88808a2004-10-30 09:19:36 +00001253# Note the extra sed filtering here, used to cut down on the warnings emited
1254# by GCC. The last line is a gross hack to work around flex aparently not
1255# being able to resize the buffer on a large token input. Currently, for
1256# uninitialized string buffers in LLVM we can generate very long tokens, so
1257# this is a hack around it.
Chris Lattner92fc9b02003-08-15 20:00:47 +00001258# FIXME. (f.e. char Buffer[10000] )
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001259$(PROJ_SRC_DIR)/%.cpp: $(PROJ_SRC_DIR)/%.l
Reid Spencer993b95e2004-12-10 19:44:16 +00001260 $(Echo) Flexing $*.l
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001261 $(Verb) $(FLEX) -t $(PROJ_SRC_DIR)/$*.l | \
Reid Spencerf206bd72004-10-22 21:01:56 +00001262 $(SED) 's/void yyunput/inline void yyunput/' | \
1263 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1264 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001265 > $(PROJ_SRC_DIR)/$*.cpp
Chris Lattner8104b4c2006-02-14 05:12:00 +00001266
1267# IFF the .l file has changed since it was last checked into CVS, copy the .l
1268# file to .l.cvs and the generated .cpp file to .cpp.cvs. We use this mechanism
1269# so that people without flex can build LLVM by copying the .cvs files to the
1270# source location and building them.
1271$(LexFiles:%.l=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1272$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattner1e612822006-02-16 05:10:48 +00001273 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs || \
Chris Lattner8104b4c2006-02-14 05:12:00 +00001274 ($(CP) $< $@; $(CP) $(PROJ_SRC_DIR)/$*.l $(PROJ_SRC_DIR)/$*.l.cvs)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001275
Chris Lattner8104b4c2006-02-14 05:12:00 +00001276$(LexFiles:%.l=$(ObjDir)/%.o) : \
1277$(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
Chris Lattner2f7c9632001-06-06 20:29:01 +00001278
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001279clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001280 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001281
Reid Spencerf88808a2004-10-30 09:19:36 +00001282endif
1283
1284#---------------------------------------------------------
1285# Provide rules for generating a .cpp and .h source files
1286# from yacc (bison) input sources.
1287#---------------------------------------------------------
1288
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001289YaccFiles := $(filter %.y,$(Sources))
1290ifneq ($(YaccFiles),)
Reid Spencerf88808a2004-10-30 09:19:36 +00001291
1292.PRECIOUS: $(YaccOutput)
1293
Chris Lattnerb0240b22006-02-15 07:23:05 +00001294all:: $(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs)
Chris Lattnerc38a9752006-02-15 07:16:57 +00001295
Reid Spencerf88808a2004-10-30 09:19:36 +00001296# Cancel built-in rules for yacc
1297%.c: %.y
1298%.cpp: %.y
1299%.h: %.y
1300
Reid Spencerc49a8632005-12-21 23:17:06 +00001301# Rule for building the bison based parsers...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001302$(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
Reid Spencerf88808a2004-10-30 09:19:36 +00001303 $(Echo) "Bisoning $*.y"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001304 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1305 $(Verb) $(MV) -f $*.tab.c $(PROJ_SRC_DIR)/$*.cpp
1306 $(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
Chris Lattner2f7c9632001-06-06 20:29:01 +00001307
Chris Lattnerc38a9752006-02-15 07:16:57 +00001308# IFF the .y file has changed since it was last checked into CVS, copy the .y
1309# file to .y.cvs and the generated .cpp/.h file to .cpp.cvs/.h.cvs. We use this
1310# mechanism so that people without flex can build LLVM by copying the .cvs files
1311# to the source location and building them.
1312$(YaccFiles:%.y=$(PROJ_SRC_DIR)/%.cpp.cvs): \
1313$(PROJ_SRC_DIR)/%.cpp.cvs: $(PROJ_SRC_DIR)/%.cpp
Chris Lattner1e612822006-02-16 05:10:48 +00001314 $(Verb) $(CMP) -s $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs || \
Chris Lattnerc38a9752006-02-15 07:16:57 +00001315 ($(CP) $< $@; \
Chris Lattnerb0240b22006-02-15 07:23:05 +00001316 $(CP) $(PROJ_SRC_DIR)/$*.y $(PROJ_SRC_DIR)/$*.y.cvs; \
Chris Lattnerc38a9752006-02-15 07:16:57 +00001317 $(CP) $(PROJ_SRC_DIR)/$*.h $(PROJ_SRC_DIR)/$*.h.cvs)
Reid Spencerc49a8632005-12-21 23:17:06 +00001318
Chris Lattnerc38a9752006-02-15 07:16:57 +00001319
1320$(YaccFiles:%.y=$(ObjDir)/%.o): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
1321
1322YaccOutput := $(YaccFiles:%.y=%.output)
Reid Spencerc49a8632005-12-21 23:17:06 +00001323
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001324clean-local::
Reid Spencerc49a8632005-12-21 23:17:06 +00001325 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencerf88808a2004-10-30 09:19:36 +00001326endif
Chris Lattner2f7c9632001-06-06 20:29:01 +00001327
Reid Spencerf88808a2004-10-30 09:19:36 +00001328###############################################################################
1329# OTHER RULES: Other rules needed
1330###############################################################################
Reid Spencerf206bd72004-10-22 21:01:56 +00001331
Chris Lattner23d47392003-01-16 21:06:18 +00001332# To create postscript files from dot files...
John Criswell4ffb8442003-10-02 19:02:02 +00001333ifneq ($(DOT),false)
Chris Lattner23d47392003-01-16 21:06:18 +00001334%.ps: %.dot
Reid Spencerf206bd72004-10-22 21:01:56 +00001335 $(DOT) -Tps < $< > $@
John Criswell3ef61af2003-06-30 21:59:07 +00001336else
1337%.ps: %.dot
Reid Spencerf88808a2004-10-30 09:19:36 +00001338 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell3ef61af2003-06-30 21:59:07 +00001339endif
Chris Lattner23d47392003-01-16 21:06:18 +00001340
John Criswell0a6e6aa2003-09-06 14:44:17 +00001341# This rules ensures that header files that are removed still have a rule for
1342# which they can be "generated." This allows make to ignore them and
1343# reproduce the dependency lists.
John Criswella8391af2003-09-18 18:37:08 +00001344%.h:: ;
Chris Lattnerf60c1702005-02-04 21:28:50 +00001345%.hpp:: ;
John Criswell0a6e6aa2003-09-06 14:44:17 +00001346
Reid Spencerf88808a2004-10-30 09:19:36 +00001347# Define clean-local to clean the current directory. Note that this uses a
1348# very conservative approach ensuring that empty variables do not cause
1349# errors or disastrous removal.
Reid Spencer81cd0492004-10-23 20:04:14 +00001350clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001351ifneq ($(strip $(ObjDir)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001352 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencer12a3a052004-10-24 07:53:21 +00001353endif
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001354 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke8625f682004-01-21 19:53:11 +00001355ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001356 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke8625f682004-01-21 19:53:11 +00001357endif
John Criswell3ef61af2003-06-30 21:59:07 +00001358
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001359clean-all-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001360 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001361
Reid Spencerf88808a2004-10-30 09:19:36 +00001362# Build tags database for Emacs/Xemacs:
Reid Spenceraee67e62004-11-12 02:27:36 +00001363tags:: TAGS CTAGS
1364
Reid Spencerf88808a2004-10-30 09:19:36 +00001365TAGS:
Reid Spencerba6a3db2005-01-16 02:20:54 +00001366 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1367 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1368 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1369 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spenceraee67e62004-11-12 02:27:36 +00001370 -name '*.cpp' -o -name '*.h' | \
Reid Spencerf88808a2004-10-30 09:19:36 +00001371 $(ETAGS) $(ETAGSFLAGS) -
1372
Reid Spenceraee67e62004-11-12 02:27:36 +00001373CTAGS:
Reid Spencerba6a3db2005-01-16 02:20:54 +00001374 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1375 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1376 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1377 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spenceraee67e62004-11-12 02:27:36 +00001378 \( -name '*.cpp' -o -name '*.h' \) -print | \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001379 ctags -ImtT -o $(PROJ_OBJ_ROOT)/CTAGS -L -
Reid Spenceraee67e62004-11-12 02:27:36 +00001380
1381
Reid Spencer81cd0492004-10-23 20:04:14 +00001382###############################################################################
1383# DEPENDENCIES: Include the dependency files if we should
1384###############################################################################
Chris Lattnere9d7d702003-08-22 14:10:16 +00001385ifndef DISABLE_AUTO_DEPENDENCIES
1386
Reid Spencer81cd0492004-10-23 20:04:14 +00001387# If its not one of the cleaning targets
Reid Spencerf88808a2004-10-30 09:19:36 +00001388ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencerf206bd72004-10-22 21:01:56 +00001389
Reid Spencer81cd0492004-10-23 20:04:14 +00001390# Get the list of dependency files
Reid Spencerf88808a2004-10-30 09:19:36 +00001391DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Chris Lattner8104b4c2006-02-14 05:12:00 +00001392DependFiles := $(DependFiles:%=$(PROJ_OBJ_DIR)/$(BuildMode)/%.d)
Misha Brukmanb891ffb2003-11-09 21:36:19 +00001393
Reid Spencer81cd0492004-10-23 20:04:14 +00001394-include /dev/null $(DependFiles)
1395
John Criswell48ecca62003-08-12 18:51:51 +00001396endif
Chris Lattner598222b2003-08-18 17:27:40 +00001397
Reid Spencerf88808a2004-10-30 09:19:36 +00001398endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001399
Reid Spencer100080c2004-10-25 08:27:37 +00001400###############################################################################
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001401# CHECK: Running the test suite
1402###############################################################################
1403
1404check::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001405 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1406 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001407 $(EchoCmd) Running test suite ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001408 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001409 TESTSUITE=$(TESTSUITE) ; \
1410 else \
1411 $(EchoCmd) No Makefile in test directory ; \
1412 fi ; \
1413 else \
1414 $(EchoCmd) No test directory ; \
1415 fi
1416
1417###############################################################################
Reid Spencerf88808a2004-10-30 09:19:36 +00001418# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer100080c2004-10-25 08:27:37 +00001419###############################################################################
1420
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001421#------------------------------------------------------------------------
1422# Define distribution related variables
1423#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +00001424DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1425DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1426TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1427DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1428DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1429DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
Reid Spencer100080c2004-10-25 08:27:37 +00001430DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1431 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001432 Makefile.config.in configure autoconf
1433DistOther := $(notdir $(wildcard \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001434 $(PROJ_SRC_DIR)/*.h \
1435 $(PROJ_SRC_DIR)/*.td \
1436 $(PROJ_SRC_DIR)/*.def \
1437 $(PROJ_SRC_DIR)/*.ll \
1438 $(PROJ_SRC_DIR)/*.in))
Reid Spencerf88808a2004-10-30 09:19:36 +00001439DistSubDirs := $(SubDirs)
Reid Spencerfc66af42004-11-29 05:00:33 +00001440DistSources = $(Sources) $(EXTRA_DIST)
1441DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer100080c2004-10-25 08:27:37 +00001442
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001443#------------------------------------------------------------------------
1444# We MUST build distribution with OBJ_DIR != SRC_DIR
1445#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +00001446ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001447dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerf88808a2004-10-30 09:19:36 +00001448 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001449
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001450else
1451
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001452#------------------------------------------------------------------------
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001453# Prevent attempt to run dist targets from anywhere but the top level
1454#------------------------------------------------------------------------
1455ifneq ($(LEVEL),.)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001456dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001457 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001458else
1459
1460#------------------------------------------------------------------------
1461# Provide the top level targets
1462#------------------------------------------------------------------------
1463
Reid Spencerf88808a2004-10-30 09:19:36 +00001464dist-gzip:: $(DistTarGZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001465
Reid Spencer81546582004-12-04 22:34:09 +00001466$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001467 $(Echo) Packing gzipped distribution tar file.
Reid Spencerba6a3db2005-01-16 02:20:54 +00001468 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
Reid Spencerfc66af42004-11-29 05:00:33 +00001469 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001470
Reid Spencerf88808a2004-10-30 09:19:36 +00001471dist-bzip2:: $(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001472
Reid Spencer81546582004-12-04 22:34:09 +00001473$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001474 $(Echo) Packing bzipped distribution tar file.
Reid Spencerba6a3db2005-01-16 02:20:54 +00001475 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
Reid Spencerfc66af42004-11-29 05:00:33 +00001476 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001477
Reid Spencerf88808a2004-10-30 09:19:36 +00001478dist-zip:: $(DistZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001479
Reid Spencer81546582004-12-04 22:34:09 +00001480$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001481 $(Echo) Packing zipped distribution file.
1482 $(Verb) rm -f $(DistZip)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001483 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001484
1485dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001486 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001487
Reid Spencer3a468752005-01-28 19:52:32 +00001488DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001489
Reid Spencer81546582004-12-04 22:34:09 +00001490dist-check:: $(DistTarGZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001491 $(Echo) Checking distribution tar file.
1492 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001493 $(RM) -rf $(DistCheckDir) ; \
1494 fi
Reid Spencerf88808a2004-10-30 09:19:36 +00001495 $(Verb) $(MKDIR) $(DistCheckDir)
1496 $(Verb) cd $(DistCheckDir) && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001497 $(MKDIR) $(DistCheckDir)/build && \
1498 $(MKDIR) $(DistCheckDir)/install && \
1499 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1500 cd build && \
1501 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
Reid Spencer13f51932005-05-24 02:33:20 +00001502 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
Reid Spencer81546582004-12-04 22:34:09 +00001503 $(MAKE) all && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001504 $(MAKE) check && \
1505 $(MAKE) install && \
1506 $(MAKE) uninstall && \
1507 $(MAKE) dist && \
1508 $(MAKE) clean && \
1509 $(MAKE) dist-clean && \
Reid Spencerf88808a2004-10-30 09:19:36 +00001510 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001511
1512dist-clean::
Reid Spencerf88808a2004-10-30 09:19:36 +00001513 $(Echo) Cleaning distribution files
Reid Spencer81546582004-12-04 22:34:09 +00001514 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1515 $(DistCheckDir)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001516
1517endif
1518
1519#------------------------------------------------------------------------
1520# Provide the recursive distdir target for building the distribution directory
1521#------------------------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +00001522distdir: $(DistDir)/.makedistdir
1523$(DistDir)/.makedistdir: $(DistSources)
Reid Spencerf88808a2004-10-30 09:19:36 +00001524 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001525 if test -d "$(DistDir)" ; then \
1526 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1527 exit 1 ; \
1528 fi ; \
Reid Spencer81546582004-12-04 22:34:09 +00001529 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001530 $(RM) -rf $(DistDir); \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001531 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer81546582004-12-04 22:34:09 +00001532 $(MAKE) all ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001533 fi
Reid Spencerfc66af42004-11-29 05:00:33 +00001534 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencerf88808a2004-10-30 09:19:36 +00001535 $(Verb) $(MKDIR) $(DistDir)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001536 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1537 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
Reid Spencer100080c2004-10-25 08:27:37 +00001538 for file in $(DistFiles) ; do \
1539 case "$$file" in \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001540 $(PROJ_SRC_DIR)/*) \
Reid Spencer81546582004-12-04 22:34:09 +00001541 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1542 ;; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001543 $(PROJ_SRC_ROOT)/*) \
Reid Spencer81546582004-12-04 22:34:09 +00001544 file=`echo "$$file" | \
1545 sed "s#^$$srcrootstrip/##"` \
1546 ;; \
Reid Spencer100080c2004-10-25 08:27:37 +00001547 esac; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001548 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1549 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1550 from_dir="$(PROJ_SRC_DIR)" ; \
Reid Spencer81546582004-12-04 22:34:09 +00001551 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001552 from_dir=. ; \
Reid Spencer81546582004-12-04 22:34:09 +00001553 fi ; \
1554 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001555 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1556 to_dir="$(DistDir)/$$dir"; \
1557 $(MKDIR) "$$to_dir" ; \
1558 else \
1559 to_dir="$(DistDir)"; \
1560 fi; \
1561 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1562 if test -n "$$mid_dir" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001563 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001564 fi ; \
1565 if test -d "$$from_dir/$$file"; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001566 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1567 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
Reid Spencer13f51932005-05-24 02:33:20 +00001568 cd $(PROJ_SRC_DIR) ; \
1569 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1570 ( cd $$to_dir ; $(TAR) xf - ) ; \
1571 cd $(PROJ_OBJ_DIR) ; \
1572 else \
1573 cd $$from_dir ; \
1574 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1575 ( cd $$to_dir ; $(TAR) xf - ) ; \
1576 cd $(PROJ_OBJ_DIR) ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001577 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +00001578 elif test -f "$$from_dir/$$file" ; then \
Reid Spencerafdc82c2004-12-16 18:26:53 +00001579 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001580 elif test -L "$$from_dir/$$file" ; then \
Reid Spencerafdc82c2004-12-16 18:26:53 +00001581 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001582 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer81546582004-12-04 22:34:09 +00001583 $(EchoCmd) "===== WARNING: Distribution Source " \
1584 "$$from_dir/$$file Not Found!" ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001585 elif test "$(Verb)" != '@' ; then \
1586 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001587 fi; \
1588 done
Reid Spencerf88808a2004-10-30 09:19:36 +00001589 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer100080c2004-10-25 08:27:37 +00001590 if test "$$subdir" \!= "." ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001591 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001592 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer81546582004-12-04 22:34:09 +00001593 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1594 exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001595 fi; \
1596 done
Reid Spencer81546582004-12-04 22:34:09 +00001597 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer13f51932005-05-24 02:33:20 +00001598 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
Chris Lattnerb8e7aa02006-02-14 04:27:15 +00001599 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o \
1600 -name .svn \) -print` ;\
Reid Spencer81546582004-12-04 22:34:09 +00001601 $(MAKE) dist-hook ; \
1602 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1603 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1604 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1605 -o ! -type d ! -perm -444 -exec \
1606 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1607 || chmod -R a+r $(DistDir) ; \
1608 fi
Reid Spencer100080c2004-10-25 08:27:37 +00001609
Reid Spencerf88808a2004-10-30 09:19:36 +00001610# This is invoked by distdir target, define it as a no-op to avoid errors if not
1611# defined by user.
Reid Spencer100080c2004-10-25 08:27:37 +00001612dist-hook::
1613
Reid Spencer23a70372004-10-22 23:06:30 +00001614endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001615
1616###############################################################################
Reid Spencer12a3a052004-10-24 07:53:21 +00001617# TOP LEVEL - targets only to apply at the top level directory
1618###############################################################################
1619
1620ifeq ($(LEVEL),.)
1621
1622#------------------------------------------------------------------------
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001623# Install support for the project's include files:
Reid Spencer12a3a052004-10-24 07:53:21 +00001624#------------------------------------------------------------------------
1625install-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001626 $(Echo) Installing include files
Reid Spencerba6a3db2005-01-16 02:20:54 +00001627 $(Verb) $(MKDIR) $(PROJ_includedir)
Reid Spencerc43b1d42005-02-24 03:56:32 +00001628 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001629 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer48a82f42005-02-16 15:54:03 +00001630 for hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
1631 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS ` ; do \
Reid Spencerc43b1d42005-02-24 03:56:32 +00001632 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1633 if test \! -d "$$instdir" ; then \
1634 $(EchoCmd) Making install directory $$instdir ; \
1635 $(MKDIR) $$instdir ;\
1636 fi ; \
1637 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer48a82f42005-02-16 15:54:03 +00001638 done ; \
Reid Spencer12a3a052004-10-24 07:53:21 +00001639 fi
Reid Spencer528c9802005-12-23 22:27:56 +00001640ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencerc43b1d42005-02-24 03:56:32 +00001641 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
Reid Spencer48a82f42005-02-16 15:54:03 +00001642 cd $(PROJ_OBJ_ROOT)/include && \
Reid Spencer528c9802005-12-23 22:27:56 +00001643 for hdr in `find . -type f -print | grep -v CVS` ; do \
Reid Spencerc43b1d42005-02-24 03:56:32 +00001644 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer48a82f42005-02-16 15:54:03 +00001645 done ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001646 fi
Reid Spencer528c9802005-12-23 22:27:56 +00001647endif
Reid Spencer12a3a052004-10-24 07:53:21 +00001648
1649uninstall-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001650 $(Echo) Uninstalling include files
Reid Spencerba6a3db2005-01-16 02:20:54 +00001651 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1652 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer12a3a052004-10-24 07:53:21 +00001653 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001654 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' \
1655 -o -name '*.in' ')' -print ')' | \
1656 grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001657 cd $(PROJ_SRC_ROOT)/include && \
Chris Lattnere2dcbe02006-02-14 04:25:54 +00001658 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' \
1659 -print ')' | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001660 fi
Reid Spencer12a3a052004-10-24 07:53:21 +00001661
Reid Spencer12a3a052004-10-24 07:53:21 +00001662endif
1663
Reid Spencerf206bd72004-10-22 21:01:56 +00001664#------------------------------------------------------------------------
1665# Print out the directories used for building
Reid Spencerf88808a2004-10-30 09:19:36 +00001666#------------------------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001667printvars::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001668 $(Echo) "BuildMode : " '$(BuildMode)'
1669 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1670 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1671 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1672 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1673 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1674 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1675 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1676 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1677 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1678 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
Reid Spencerfe0a01e2005-02-16 16:13:02 +00001679 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
Reid Spencerba6a3db2005-01-16 02:20:54 +00001680 $(Echo) "UserTargets : " '$(UserTargets)'
1681 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1682 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1683 $(Echo) "ObjDir : " '$(ObjDir)'
1684 $(Echo) "LibDir : " '$(LibDir)'
1685 $(Echo) "ToolDir : " '$(ToolDir)'
1686 $(Echo) "ExmplDir : " '$(ExmplDir)'
1687 $(Echo) "Sources : " '$(Sources)'
1688 $(Echo) "TDFiles : " '$(TDFiles)'
1689 $(Echo) "INCFiles : " '$(INCFiles)'
1690 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
Reid Spencerfefb9ea2005-03-01 16:27:06 +00001691 $(Echo) "PreConditions: " '$(PreConditions)'
Reid Spencerba6a3db2005-01-16 02:20:54 +00001692 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1693 $(Echo) "Compile.C : " '$(Compile.C)'
1694 $(Echo) "Archive : " '$(Archive)'
1695 $(Echo) "YaccFiles : " '$(YaccFiles)'
1696 $(Echo) "LexFiles : " '$(LexFiles)'
1697 $(Echo) "Module : " '$(Module)'
Reid Spencerb48e3f82005-08-24 10:43:10 +00001698 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'