blob: 33d4b7c08d731c89949d4463ce3aa6334652a8ff [file] [log] [blame]
Misha Brukman6d5ab862004-04-24 00:10:56 +00001#===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
2#
John Criswelld8846c12003-10-21 14:33:46 +00003# The LLVM Compiler Infrastructure
4#
5# This file was developed by the LLVM research group and is distributed under
6# the University of Illinois Open Source License. See LICENSE.TXT for details.
7#
Misha Brukman6d5ab862004-04-24 00:10:56 +00008#===------------------------------------------------------------------------===#
Chris Lattner00950542001-06-06 20:29:01 +00009#
Reid Spencer3a561f52004-10-23 20:04:14 +000010# This file is included by all of the LLVM makefiles. For details on how to use
11# it properly, please see the document MakefileGuide.html in the docs directory.
Chris Lattneraf06a082003-08-15 03:02:52 +000012#
Vikram S. Adved60aede2002-07-09 12:04:21 +000013#===-----------------------------------------------------------------------====
Chris Lattner00950542001-06-06 20:29:01 +000014
Reid Spencercc2d1e22004-10-30 09:19:36 +000015################################################################################
Reid Spencer3a561f52004-10-23 20:04:14 +000016# TARGETS: Define standard targets that can be invoked
Reid Spencercc2d1e22004-10-30 09:19:36 +000017################################################################################
John Criswell7a73b802003-06-30 21:59:07 +000018
Chris Lattner00950542001-06-06 20:29:01 +000019#--------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +000020# Define the various target sets
21#--------------------------------------------------------------------
Chris Lattner7dc02822004-12-03 21:05:57 +000022RecursiveTargets := all clean clean-all install uninstall install-bytecode
Reid Spencer9e8d54a2004-12-06 05:35:13 +000023LocalTargets := all-local clean-local clean-all-local check-local \
Reid Spencer44cb1b32004-12-03 20:08:48 +000024 install-local printvars uninstall-local \
25 install-bytecode-local
Reid Spencer9e8d54a2004-12-06 05:35:13 +000026TopLevelTargets := check dist dist-check dist-clean tags dist-gzip dist-bzip2 \
Reid Spencercc2d1e22004-10-30 09:19:36 +000027 dist-zip
28UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
29InternalTargets := preconditions distdir dist-hook
Reid Spencer3a561f52004-10-23 20:04:14 +000030
Reid Spencercc2d1e22004-10-30 09:19:36 +000031################################################################################
Reid Spencer9411c642004-10-26 22:26:33 +000032# INITIALIZATION: Basic things the makefile needs
Reid Spencercc2d1e22004-10-30 09:19:36 +000033################################################################################
34
35#--------------------------------------------------------------------
36# Set the VPATH so that we can find source files.
37#--------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +000038VPATH=$(PROJ_SRC_DIR)
Reid Spencer9411c642004-10-26 22:26:33 +000039
40#--------------------------------------------------------------------
41# Reset the list of suffixes we know how to build
42#--------------------------------------------------------------------
43.SUFFIXES:
Chris Lattner89681112006-01-27 22:13:12 +000044.SUFFIXES: .c .cpp .cc .h .hpp .y .l .lo .o .a .bc .td .ps .dot .ll
Reid Spencercc2d1e22004-10-30 09:19:36 +000045.SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
Reid Spencer9411c642004-10-26 22:26:33 +000046
Reid Spencer3a561f52004-10-23 20:04:14 +000047#--------------------------------------------------------------------
48# Mark all of these targets as phony to avoid implicit rule search
49#--------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000050.PHONY: $(UserTargets) $(InternalTargets)
Reid Spencer3a561f52004-10-23 20:04:14 +000051
52#--------------------------------------------------------------------
Reid Spencer9411c642004-10-26 22:26:33 +000053# Make sure all the user-target rules are double colon rules and
54# they are defined first.
Reid Spencer3a561f52004-10-23 20:04:14 +000055#--------------------------------------------------------------------
56
Reid Spencercc2d1e22004-10-30 09:19:36 +000057$(UserTargets)::
Reid Spencer151f8ba2004-10-25 08:27:37 +000058
Reid Spencer9411c642004-10-26 22:26:33 +000059################################################################################
60# PRECONDITIONS: that which must be built/checked first
61################################################################################
62
Reid Spencer44cb1b32004-12-03 20:08:48 +000063SrcMakefiles := $(filter %Makefile %Makefile.tests,\
Reid Spencer11fde542005-01-16 02:20:54 +000064 $(wildcard $(PROJ_SRC_DIR)/Makefile*))
65ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
66ConfigureScript := $(PROJ_SRC_ROOT)/configure
67ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
68MakefileConfigIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
69MakefileCommonIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
70MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
71MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
72PreConditions := $(ConfigStatusScript) $(ObjMakefiles)
73ifneq ($(MakefileCommonIn),)
74PreConditions += $(MakefileCommon)
75endif
76ifneq ($(MakefileConfigIn),)
77PreConditions += $(MakefileConfig)
78endif
Reid Spencer9411c642004-10-26 22:26:33 +000079
Reid Spencerca739c62005-08-25 04:59:49 +000080preconditions: $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +000081
82#------------------------------------------------------------------------
83# Make sure the BUILT_SOURCES are built first
84#------------------------------------------------------------------------
Reid Spencer07a549a2004-12-16 07:15:16 +000085$(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000086
87clean-local::
88ifneq ($(strip $(BUILT_SOURCES)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +000089 -$(Verb) $(RM) -f $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000090endif
91
Reid Spencer11fde542005-01-16 02:20:54 +000092ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
Reid Spencer31f95242004-12-16 08:00:46 +000093spotless:
Reid Spencer31f95242004-12-16 08:00:46 +000094 $(Verb) if test -x config.status ; then \
Reid Spencer11fde542005-01-16 02:20:54 +000095 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
Reid Spencer39b73632004-12-17 07:45:03 +000096 $(MKDIR) .spotless.save ; \
97 $(MV) config.status .spotless.save ; \
98 $(MV) mklib .spotless.save ; \
99 $(MV) projects .spotless.save ; \
Reid Spencer31f95242004-12-16 08:00:46 +0000100 $(RM) -rf * ; \
Reid Spencer39b73632004-12-17 07:45:03 +0000101 $(MV) .spotless.save/config.status . ; \
102 $(MV) .spotless.save/mklib . ; \
103 $(MV) .spotless.save/projects . ; \
104 $(RM) -rf .spotless.save ; \
Reid Spencer11fde542005-01-16 02:20:54 +0000105 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
Reid Spencer39b73632004-12-17 07:45:03 +0000106 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
107 $(ConfigStatusScript) ; \
Reid Spencer31f95242004-12-16 08:00:46 +0000108 else \
Reid Spencer11fde542005-01-16 02:20:54 +0000109 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
Reid Spencer31f95242004-12-16 08:00:46 +0000110 fi
Reid Spencer25e8a702005-12-21 23:17:06 +0000111else
112spotless:
113 $(EchoCmd) "spotless target not supported for objdir == srcdir"
Reid Spencer31f95242004-12-16 08:00:46 +0000114endif
115
Reid Spencercc2d1e22004-10-30 09:19:36 +0000116$(BUILT_SOURCES) : $(ObjMakefiles)
Reid Spencer80f0ef72004-10-28 00:41:43 +0000117
Reid Spencer9411c642004-10-26 22:26:33 +0000118#------------------------------------------------------------------------
119# Make sure we're not using a stale configuration
120#------------------------------------------------------------------------
Reid Spencerc3719842004-12-16 18:26:53 +0000121reconfigure:
Reid Spencer11fde542005-01-16 02:20:54 +0000122 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
123 $(Verb) cd $(PROJ_OBJ_ROOT) && \
124 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
125 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
Reid Spencer32924e02004-12-24 03:36:31 +0000126 fi ; \
Reid Spencerc3719842004-12-16 18:26:53 +0000127 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
128 $(ConfigStatusScript)
129
Reid Spencercc2d1e22004-10-30 09:19:36 +0000130.PRECIOUS: $(ConfigStatusScript)
131$(ConfigStatusScript): $(ConfigureScript)
132 $(Echo) Reconfiguring with $<
Reid Spencer11fde542005-01-16 02:20:54 +0000133 $(Verb) cd $(PROJ_OBJ_ROOT) && \
134 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
135 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
Reid Spencer32924e02004-12-24 03:36:31 +0000136 fi ; \
Reid Spencer7d277002004-11-29 12:37:44 +0000137 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
138 $(ConfigStatusScript)
Reid Spencer9411c642004-10-26 22:26:33 +0000139
Reid Spencer6f5f8b32005-08-25 04:44:18 +0000140#------------------------------------------------------------------------
Reid Spencer9411c642004-10-26 22:26:33 +0000141# Make sure the configuration makefile is up to date
142#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +0000143ifneq ($(MakefileConfigIn),)
144$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000145 $(Echo) Regenerating $@
Reid Spencer11fde542005-01-16 02:20:54 +0000146 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
147endif
148
149ifneq ($(MakefileCommonIn),)
150$(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
151 $(Echo) Regenerating $@
152 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
153endif
Reid Spencer9411c642004-10-26 22:26:33 +0000154
155#------------------------------------------------------------------------
156# If the Makefile in the source tree has been updated, copy it over into the
157# build tree. But, only do this if the source and object makefiles differ
158#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +0000159ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
Reid Spencer9411c642004-10-26 22:26:33 +0000160
Reid Spencer11fde542005-01-16 02:20:54 +0000161Makefile: $(PROJ_SRC_DIR)/Makefile
Reid Spencercc2d1e22004-10-30 09:19:36 +0000162 $(Echo) "Updating Makefile"
163 $(Verb) $(MKDIR) $(@D)
Reid Spencerc3719842004-12-16 18:26:53 +0000164 $(Verb) $(CP) -f $< $@
Reid Spencer9411c642004-10-26 22:26:33 +0000165
166# Copy the Makefile.* files unless we're in the root directory which avoids
167# the copying of Makefile.config.in or other things that should be explicitly
168# taken care of.
Reid Spencer11fde542005-01-16 02:20:54 +0000169$(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
Reid Spencer86606782004-10-26 23:10:00 +0000170 @case '$?' in \
171 *Makefile.rules) ;; \
172 *.in) ;; \
Reid Spencercc2d1e22004-10-30 09:19:36 +0000173 *) $(Echo) "Updating $(@F)" ; \
Reid Spencer86606782004-10-26 23:10:00 +0000174 $(MKDIR) $(@D) ; \
Reid Spencerc3719842004-12-16 18:26:53 +0000175 $(CP) -f $< $@ ;; \
Reid Spencer86606782004-10-26 23:10:00 +0000176 esac
177
Reid Spencer9411c642004-10-26 22:26:33 +0000178endif
179
180#------------------------------------------------------------------------
181# Set up the basic dependencies
182#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000183$(UserTargets):: $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +0000184
185all:: all-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000186clean:: clean-local
Reid Spencer3d659492004-11-02 16:36:03 +0000187clean-all:: clean-local clean-all-local
Reid Spencer9411c642004-10-26 22:26:33 +0000188install:: install-local
189uninstall:: uninstall-local
Reid Spencer9411c642004-10-26 22:26:33 +0000190install-local:: all-local
Reid Spencer44cb1b32004-12-03 20:08:48 +0000191install-bytecode:: install-bytecode-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000192
193###############################################################################
194# VARIABLES: Set up various variables based on configuration data
195###############################################################################
196
197#--------------------------------------------------------------------
198# Variables derived from configuration we are building
Chris Lattner00950542001-06-06 20:29:01 +0000199#--------------------------------------------------------------------
200
Reid Spencer325a87e2005-01-02 17:43:20 +0000201
Chris Lattner760da062003-03-14 20:25:22 +0000202ifdef ENABLE_PROFILING
Reid Spencer9af3b292004-11-01 07:50:27 +0000203 BuildMode := Profile
Reid Spencer519799e2004-12-08 04:34:51 +0000204 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
Reid Spencercc2d1e22004-10-30 09:19:36 +0000205 C.Flags := -O3 -DNDEBUG -pg
206 LD.Flags := -O3 -DNDEBUG -pg
Chris Lattner760da062003-03-14 20:25:22 +0000207else
208 ifdef ENABLE_OPTIMIZED
Reid Spencer9af3b292004-11-01 07:50:27 +0000209 BuildMode := Release
Reid Spencer325a87e2005-01-02 17:43:20 +0000210 # Don't use -fomit-frame-pointer on FreeBSD
211 ifneq ($(OS),FreeBSD)
212 OmitFramePointer := -fomit-frame-pointer
213 endif
214 CXX.Flags := -O3 -DNDEBUG -finline-functions -felide-constructors \
215 $(OmitFramePointer)
216 C.Flags := -O3 -DNDEBUG $(OmitFramePointer)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000217 LD.Flags := -O3 -DNDEBUG
Chris Lattner760da062003-03-14 20:25:22 +0000218 else
Reid Spencer9af3b292004-11-01 07:50:27 +0000219 BuildMode := Debug
Reid Spencer519799e2004-12-08 04:34:51 +0000220 CXX.Flags := -g -D_DEBUG
Reid Spencercc2d1e22004-10-30 09:19:36 +0000221 C.Flags := -g -D_DEBUG
222 LD.Flags := -g -D_DEBUG
Reid Spencer4d71b662004-10-22 21:01:56 +0000223 KEEP_SYMBOLS := 1
Chris Lattner760da062003-03-14 20:25:22 +0000224 endif
225endif
226
Jeff Cohen9dc33e52005-10-23 04:51:22 +0000227CXX.Flags += $(CXXFLAGS)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000228C.Flags += $(CFLAGS)
229CPP.Flags += $(CPPFLAGS)
230LD.Flags += $(LDFLAGS)
231AR.Flags := cru
232LibTool.Flags := --tag=CXX
Reid Spencer3a561f52004-10-23 20:04:14 +0000233
Andrew Lenharth39bcf5b2005-02-13 03:41:10 +0000234#Make Floating point ieee complient on alpha
235ifeq ($(ARCH),Alpha)
236 CXX.Flags += -mieee
237 CPP.Flags += -mieee
238endif
239
Reid Spencer3a561f52004-10-23 20:04:14 +0000240#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000241# Directory locations
Reid Spencer3a561f52004-10-23 20:04:14 +0000242#--------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +0000243ObjDir := $(PROJ_OBJ_DIR)/$(BuildMode)
244LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
245ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
246ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer815cbcf2004-11-18 10:03:46 +0000247LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer9a5acaf2004-11-18 20:04:39 +0000248LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer775bf892004-12-28 07:59:22 +0000249LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer2f138e72004-12-22 05:57:21 +0000250CFERuntimeLibDir := $(LLVMGCCDIR)/lib
John Criswell7a73b802003-06-30 21:59:07 +0000251
Reid Spencer3a561f52004-10-23 20:04:14 +0000252#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000253# Full Paths To Compiled Tools and Utilities
Reid Spencer3a561f52004-10-23 20:04:14 +0000254#--------------------------------------------------------------------
Reid Spencer3ca6d8b2005-01-14 16:33:36 +0000255EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
256Echo = @$(EchoCmd)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000257ifndef LIBTOOL
Reid Spencer4d71b662004-10-22 21:01:56 +0000258LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencercc2d1e22004-10-30 09:19:36 +0000259endif
260ifndef LLVMAS
261LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
262endif
263ifndef BURG
264BURG := $(LLVMToolDir)/burg$(EXEEXT)
265endif
266ifndef TBLGEN
267TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
268endif
Chris Lattner478b3b42004-11-29 19:47:58 +0000269ifndef GCCAS
270GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
271endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000272ifndef GCCLD
273GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
274endif
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000275ifndef LDIS
276LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
277endif
278ifndef LLI
279LLI := $(LLVMToolDir)/lli$(EXEEXT)
280endif
Alkis Evlogimenoseebaf332005-02-27 10:21:37 +0000281ifndef LLC
282LLC := $(LLVMToolDir)/llc$(EXEEXT)
283endif
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000284ifndef LOPT
Alkis Evlogimenos20d793a2004-12-13 18:08:29 +0000285LOPT := $(LLVMToolDir)/opt$(EXEEXT)
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000286endif
Alkis Evlogimenos270e8512005-02-02 00:40:15 +0000287ifndef LBUGPOINT
288LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
289endif
290
John Criswellf5629d02005-01-03 17:42:57 +0000291LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
292LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000293
Reid Spencer3a561f52004-10-23 20:04:14 +0000294#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000295# Adjust to user's request
Reid Spencer3a561f52004-10-23 20:04:14 +0000296#--------------------------------------------------------------------
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000297
Reid Spencer492c2932005-01-11 04:31:07 +0000298# Adjust LD.Flags and Libtool.Flags depending on the kind of library that is
299# to be built. Note that if LOADABLE_MODULE is specified then the resulting
300# shared library can be opened with dlopen
301ifdef SHARED_LIBRARY
Reid Spencercc2d1e22004-10-30 09:19:36 +0000302 LD.Flags += -rpath $(LibDir)
Reid Spencer492c2932005-01-11 04:31:07 +0000303 ifdef LOADABLE_MODULE
304 LD.Flags += -module
305 endif
306else
307 LibTool.Flags += --tag=disable-shared
John Criswell82f4a5a2003-07-31 20:58:51 +0000308endif
309
Reid Spencercceed9f2004-11-08 17:32:12 +0000310ifdef TOOL_VERBOSE
311 C.Flags += -v
312 CXX.Flags += -v
313 LD.Flags += -v
Reid Spencercceed9f2004-11-08 17:32:12 +0000314 VERBOSE := 1
315endif
316
Reid Spencer3a561f52004-10-23 20:04:14 +0000317# Adjust settings for verbose mode
Chris Lattner760da062003-03-14 20:25:22 +0000318ifndef VERBOSE
Reid Spencercc2d1e22004-10-30 09:19:36 +0000319 Verb := @
320 LibTool.Flags += --silent
321 AR.Flags += >/dev/null 2>/dev/null
Reid Spencer11fde542005-01-16 02:20:54 +0000322 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
Reid Spencer151f8ba2004-10-25 08:27:37 +0000323else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000324 ConfigureScriptFLAGS :=
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000325endif
326
Vikram S. Advefeeae582002-09-18 11:55:13 +0000327# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000328ifndef KEEP_SYMBOLS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000329 Strip := $(PLATFORMSTRIPOPTS)
330 StripWarnMsg := "(without symbols)"
Reid Spencer860598a2005-02-24 07:12:43 +0000331 Install.StripFlag += -s
Vikram S. Advefeeae582002-09-18 11:55:13 +0000332endif
333
Reid Spencer3a561f52004-10-23 20:04:14 +0000334# Adjust linker flags for building an executable
Reid Spencer4d71b662004-10-22 21:01:56 +0000335ifdef TOOLNAME
Reid Spencer815cbcf2004-11-18 10:03:46 +0000336ifdef EXAMPLE_TOOL
337 LD.Flags += -rpath $(ExmplDir) -export-dynamic
338else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000339 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000340endif
Reid Spencer815cbcf2004-11-18 10:03:46 +0000341endif
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000342
Reid Spencer3a561f52004-10-23 20:04:14 +0000343#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000344# Options To Invoke Tools
Reid Spencer3a561f52004-10-23 20:04:14 +0000345#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000346
347CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
348
Duraid Madina0ad8fcf2005-05-16 06:38:09 +0000349ifeq ($(OS),HP-UX)
350 CompileCommonOpts += -D_REENTRANT -D_HPUX_SOURCE
351endif
352
Reid Spencer9a8398e2005-02-14 21:54:08 +0000353LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
Reid Spencer11fde542005-01-16 02:20:54 +0000354CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
355 -I$(PROJ_OBJ_ROOT)/include \
356 -I$(PROJ_SRC_ROOT)/include \
357 -I$(LLVM_OBJ_ROOT)/include \
358 -I$(LLVM_SRC_ROOT)/include \
359 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
Reid Spencer4d71b662004-10-22 21:01:56 +0000360
Reid Spencercc2d1e22004-10-30 09:19:36 +0000361Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
362LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
Reid Spencer2f138e72004-12-22 05:57:21 +0000363BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattner89681112006-01-27 22:13:12 +0000364 $(C.Flags)
Chris Lattner0cb09f12005-10-05 00:28:41 +0000365Preprocess.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -E $(C.Flags)
366
Reid Spencercc2d1e22004-10-30 09:19:36 +0000367Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
368LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
Reid Spencerbc52ad72004-12-24 14:47:34 +0000369BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
Chris Lattner89681112006-01-27 22:13:12 +0000370 $(CXX.Flags)
Chris Lattner0cb09f12005-10-05 00:28:41 +0000371Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
Reid Spencercc2d1e22004-10-30 09:19:36 +0000372Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
373 $(CompileCommonOpts) $(LD.Flags) $(Strip)
374Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencera69b1ea2004-10-28 09:15:28 +0000375 $(CompileCommonOpts)
Reid Spencer1a9a69c2005-02-16 16:13:02 +0000376LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
377 $(Install.Flags)
Reid Spencer860598a2005-02-24 07:12:43 +0000378ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
379DataInstall = $(INSTALL) -m 0644
Reid Spencer11fde542005-01-16 02:20:54 +0000380Burg = $(BURG) -I $(PROJ_SRC_DIR)
381TableGen = $(TBLGEN) -I $(PROJ_SRC_DIR)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000382Archive = $(AR) $(AR.Flags)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000383LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencer4d71b662004-10-22 21:01:56 +0000384ifdef RANLIB
Reid Spencer3a561f52004-10-23 20:04:14 +0000385Ranlib = $(RANLIB)
Reid Spencer4d71b662004-10-22 21:01:56 +0000386else
Reid Spencer3a561f52004-10-23 20:04:14 +0000387Ranlib = ranlib
John Criswell7a73b802003-06-30 21:59:07 +0000388endif
389
Chris Lattner00950542001-06-06 20:29:01 +0000390#----------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +0000391# Get the list of source files and compute object file
392# names from them.
Reid Spencer3a561f52004-10-23 20:04:14 +0000393#----------------------------------------------------------
Chris Lattner89681112006-01-27 22:13:12 +0000394
395ifndef SOURCES
396 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
397 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
398 $(PROJ_SRC_DIR)/*.l))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000399else
Chris Lattner89681112006-01-27 22:13:12 +0000400 Sources := $(SOURCES)
401endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000402
Chris Lattner89681112006-01-27 22:13:12 +0000403ifdef BUILT_SOURCES
404Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Reid Spencer345235ca2004-12-04 22:34:09 +0000405endif
Reid Spencer3a561f52004-10-23 20:04:14 +0000406
Chris Lattner89681112006-01-27 22:13:12 +0000407BaseNameSources := $(sort $(basename $(Sources)))
408
409ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
410ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
411ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
412
Reid Spencer3a561f52004-10-23 20:04:14 +0000413###############################################################################
414# DIRECTORIES: Handle recursive descent of directory structure
415###############################################################################
John Criswell82f4a5a2003-07-31 20:58:51 +0000416
Chris Lattner00950542001-06-06 20:29:01 +0000417#---------------------------------------------------------
Reid Spencera69b1ea2004-10-28 09:15:28 +0000418# Provide rules to make install dirs. This must be early
419# in the file so they get built before dependencies
420#---------------------------------------------------------
421
Reid Spenceraa8bc432005-05-19 20:26:14 +0000422$(PROJ_bindir): $(PROJ_bindir)/.dir
423$(PROJ_libdir): $(PROJ_libdir)/.dir
424$(PROJ_includedir): $(PROJ_includedir)/.dir
425$(PROJ_etcdir): $(PROJ_etcdir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000426
Reid Spencercc2d1e22004-10-30 09:19:36 +0000427# To create other directories, as needed, and timestamp their creation
428%/.dir:
429 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfbbf3072004-11-29 05:00:33 +0000430 $(Verb) $(DATE) > $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000431
Reid Spencer815cbcf2004-11-18 10:03:46 +0000432.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
433.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000434
435#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000436# Handle the DIRS options for sequential construction
Chris Lattner00950542001-06-06 20:29:01 +0000437#---------------------------------------------------------
438
Reid Spencercc2d1e22004-10-30 09:19:36 +0000439SubDirs :=
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000440ifdef DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000441SubDirs += $(DIRS)
442$(RecursiveTargets)::
443 $(Verb) for dir in $(DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000444 if [ ! -f $$dir/Makefile ]; then \
445 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000446 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000447 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000448 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
449 ($(MAKE) -C $$dir $@ ) || exit 1; \
450 fi ; \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000451 done
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000452endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000453
Reid Spencer3a561f52004-10-23 20:04:14 +0000454#---------------------------------------------------------
455# Handle the EXPERIMENTAL_DIRS options ensuring success
456# after each directory is built.
457#---------------------------------------------------------
458ifdef EXPERIMENTAL_DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000459$(RecursiveTargets)::
460 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer3a561f52004-10-23 20:04:14 +0000461 if [ ! -f $$dir/Makefile ]; then \
462 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000463 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000464 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000465 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
466 ($(MAKE) -C $$dir $@ ) || exit 0; \
467 fi ; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000468 done
469endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000470
Reid Spencer25e8a702005-12-21 23:17:06 +0000471#-----------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000472# Handle the PARALLEL_DIRS options for parallel construction
Reid Spencer25e8a702005-12-21 23:17:06 +0000473#-----------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000474ifdef PARALLEL_DIRS
475
Reid Spencercc2d1e22004-10-30 09:19:36 +0000476SubDirs += $(PARALLEL_DIRS)
477
Reid Spencer44cb1b32004-12-03 20:08:48 +0000478# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencercc2d1e22004-10-30 09:19:36 +0000479all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
480clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000481clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000482install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000483uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencer44cb1b32004-12-03 20:08:48 +0000484install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000485
Reid Spencer345235ca2004-12-04 22:34:09 +0000486ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer3a561f52004-10-23 20:04:14 +0000487
Reid Spencer345235ca2004-12-04 22:34:09 +0000488$(ParallelTargets) :
Reid Spencercc2d1e22004-10-30 09:19:36 +0000489 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencer4d71b662004-10-22 21:01:56 +0000490 $(MKDIR) $(@D); \
Reid Spencer11fde542005-01-16 02:20:54 +0000491 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswellb3866b62003-11-25 19:32:22 +0000492 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000493 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
494 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
495 fi
Chris Lattner00950542001-06-06 20:29:01 +0000496endif
497
Reid Spencer3a561f52004-10-23 20:04:14 +0000498#---------------------------------------------------------
499# Handle the OPTIONAL_DIRS options for directores that may
500# or may not exist.
501#---------------------------------------------------------
John Criswell2a6530f2003-06-27 16:58:44 +0000502ifdef OPTIONAL_DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000503
Reid Spencercc2d1e22004-10-30 09:19:36 +0000504SubDirs += $(OPTIONAL_DIRS)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000505
Reid Spencercc2d1e22004-10-30 09:19:36 +0000506$(RecursiveTargets)::
507 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000508 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
Reid Spencer4d71b662004-10-22 21:01:56 +0000509 if [ ! -f $$dir/Makefile ]; then \
510 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000511 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000512 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000513 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
514 ($(MAKE) -C$$dir $@ ) || exit 1; \
515 fi ; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000516 fi \
John Criswell2a6530f2003-06-27 16:58:44 +0000517 done
518endif
519
Reid Spencerfc945082004-08-20 09:20:05 +0000520#---------------------------------------------------------
521# Handle the CONFIG_FILES options
522#---------------------------------------------------------
523ifdef CONFIG_FILES
Reid Spencerfc945082004-08-20 09:20:05 +0000524
Reid Spencer11fde542005-01-16 02:20:54 +0000525install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
526 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000527 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000528 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
Reid Spencer4a0aaea2005-02-24 03:56:32 +0000529 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer11fde542005-01-16 02:20:54 +0000530 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
Reid Spencer4a0aaea2005-02-24 03:56:32 +0000531 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer1b426ab2004-11-23 05:59:53 +0000532 else \
533 $(ECHO) Error: cannot find config file $${file}. ; \
534 fi \
Reid Spencerfc945082004-08-20 09:20:05 +0000535 done
Reid Spencer3a561f52004-10-23 20:04:14 +0000536
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000537uninstall-local::
Reid Spencer11fde542005-01-16 02:20:54 +0000538 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000539 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000540 $(RM) -f $(PROJ_etcdir)/$${file} ; \
Reid Spencere5487ba2004-10-24 07:53:21 +0000541 done
542
Reid Spencerfc945082004-08-20 09:20:05 +0000543endif
544
Reid Spencer3a561f52004-10-23 20:04:14 +0000545###############################################################################
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000546# Set up variables for building libararies
547###############################################################################
548
549#---------------------------------------------------------
550# Handle the special "JIT" value for LLVM_LIBS which is a
551# shorthand for a bunch of libraries that get the correct
552# JIT support for a library or a tool that runs JIT.
553#---------------------------------------------------------
554ifeq ($(LLVMLIBS),JIT)
555
556# Make sure we can get our own symbols in the tool
557Link += -dlopen self
558
559# Generic JIT libraries
560JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
561
562# You can enable the X86 JIT on a non-X86 host by setting the flag
563# ENABLE_X86_JIT on the make command line. If not, it will still be
564# enabled automagically on an X86 host.
565ifeq ($(ARCH), x86)
566 ENABLE_X86_JIT = 1
567endif
568
569# What the X86 JIT requires
570ifdef ENABLE_X86_JIT
571 JIT_LIBS += LLVMX86 LLVMSelectionDAG
572endif
573
574# You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
575# ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
576# enabled automagically on an SparcV9 host.
577ifeq ($(ARCH), Sparc)
578 ENABLE_SPARCV9_JIT = 1
579endif
580
581# What the Sparc JIT requires
582ifdef ENABLE_SPARCV9_JIT
583 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
John Criswelle96a1a52005-10-26 20:35:13 +0000584 LLVMSparcV9LiveVar LLVMInstrumentation.a \
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000585 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
John Criswelle96a1a52005-10-26 20:35:13 +0000586 LLVMDataStructure LLVMSparcV9RegAlloc
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000587endif
588
589# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
590# ENABLE_PPC_JIT on the make command line. If not, it will still be
591# enabled automagically on an PowerPC host.
592ifeq ($(ARCH), PowerPC)
593 ENABLE_PPC_JIT = 1
594endif
595
596# What the PowerPC JIT requires
597ifdef ENABLE_PPC_JIT
598 JIT_LIBS += LLVMPowerPC LLVMSelectionDAG
599endif
600
Andrew Lenharthddc31e82005-07-22 20:54:01 +0000601# You can enable the Alpha JIT on a non-Alpha host by setting the flag
602# ENABLE_ALPHA_JIT on the make command line. If not, it will still be
Misha Brukmanab25eda2005-07-22 22:43:40 +0000603# enabled automagically on an Alpha host.
Andrew Lenharthddc31e82005-07-22 20:54:01 +0000604ifeq ($(ARCH), Alpha)
605 ENABLE_ALPHA_JIT = 1
606endif
607
Andrew Lenharth22894e92005-07-22 22:00:24 +0000608# What the Alpha JIT requires
Andrew Lenharthddc31e82005-07-22 20:54:01 +0000609ifdef ENABLE_ALPHA_JIT
610 JIT_LIBS += LLVMAlpha LLVMSelectionDAG
611endif
612
John Criswella1156432005-10-27 15:54:34 +0000613LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts.a LLVMTransformUtils.a LLVMAnalysis.a \
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000614 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
615 LLVMSystem.a $(PLATFORMLIBDL)
616endif
617
618#---------------------------------------------------------
619# Define various command line options pertaining to the
620# libraries needed when linking. There are "Proj" libs
621# (defined by the user's project) and "LLVM" libs (defined
622# by the # LLVM project).
623#---------------------------------------------------------
Misha Brukman6c26da62005-08-17 02:38:56 +0000624# Some versions of gcc on Alpha produce too many symbols, so use a .a file
Andrew Lenharth7ac17522005-08-13 05:09:50 +0000625ifeq ($(ARCH),Alpha)
626USEDLIBS := $(subst LLVMCore, LLVMCore.a, $(USEDLIBS))
627LLVMLIBS := $(subst LLVMCore, LLVMCore.a, $(LLVMLIBS))
628endif
629
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000630ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
631ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
632LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
633LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
634ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
635LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
636ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
637LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
638
639###############################################################################
Reid Spencer3a561f52004-10-23 20:04:14 +0000640# Library Build Rules: Four ways to build a library
641###############################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000642
Reid Spencer7980ea42004-12-05 05:17:22 +0000643#---------------------------------------------------------
644# Bytecode Module Targets:
645# If the user set MODULE_NAME then they want to build a
646# bytecode module from the sources. We compile all the
647# sources and link it together into a single bytecode
648# module.
649#---------------------------------------------------------
650
651ifdef MODULE_NAME
Reid Spencer9a8398e2005-02-14 21:54:08 +0000652ifeq ($(strip $(LLVMGCC)),)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000653$(warning Modules require llvm-gcc but no llvm-gcc is available ****)
Reid Spencer9a8398e2005-02-14 21:54:08 +0000654else
Reid Spencer7980ea42004-12-05 05:17:22 +0000655
656Module := $(LibDir)/$(MODULE_NAME).bc
Chris Lattner89681112006-01-27 22:13:12 +0000657LinkModule := $(GCCLD)
Reid Spencer7980ea42004-12-05 05:17:22 +0000658
659ifdef EXPORTED_SYMBOL_FILE
Chris Lattner89681112006-01-27 22:13:12 +0000660LinkModule += -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer7980ea42004-12-05 05:17:22 +0000661endif
662
663$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000664 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
Reid Spencer7980ea42004-12-05 05:17:22 +0000665 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
666
667all-local:: $(Module)
668
669clean-local::
670ifneq ($(strip $(Module)),)
671 -$(Verb) $(RM) -f $(Module)
672endif
673
Reid Spencerab3690b2004-12-13 07:38:07 +0000674ifdef BYTECODE_DESTINATION
675ModuleDestDir := $(BYTECODE_DESTINATION)
676else
Reid Spencer11fde542005-01-16 02:20:54 +0000677ModuleDestDir := $(PROJ_libdir)
Reid Spencerab3690b2004-12-13 07:38:07 +0000678endif
Reid Spencer7980ea42004-12-05 05:17:22 +0000679
Reid Spencerab3690b2004-12-13 07:38:07 +0000680DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
681
682install-module:: $(DestModule)
Reid Spencer7980ea42004-12-05 05:17:22 +0000683install-local:: $(DestModule)
684
Reid Spencerab3690b2004-12-13 07:38:07 +0000685$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencer7980ea42004-12-05 05:17:22 +0000686 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
Reid Spencer151bbe42005-02-24 21:30:37 +0000687 $(Verb) $(DataInstall) $(Module) $(DestModule)
Reid Spencer7980ea42004-12-05 05:17:22 +0000688
689uninstall-local::
690 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
691 -$(Verb) $(RM) -f $(DestModule)
692
693endif
Reid Spencer9a8398e2005-02-14 21:54:08 +0000694endif
Brian Gaeke8abff792004-01-22 22:53:48 +0000695
Reid Spencer3a561f52004-10-23 20:04:14 +0000696# if we're building a library ...
Chris Lattner00950542001-06-06 20:29:01 +0000697ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000698
Chris Lattner2a548c52002-09-16 22:36:42 +0000699# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000700LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencer492c2932005-01-11 04:31:07 +0000701ifdef LOADABLE_MODULE
702LibName.LA := $(LibDir)/$(LIBRARYNAME).la
703else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000704LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
Reid Spencer492c2932005-01-11 04:31:07 +0000705endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000706LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
707LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer9a2f1372004-12-02 09:28:21 +0000708LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000709
Reid Spencer3a561f52004-10-23 20:04:14 +0000710#---------------------------------------------------------
711# Shared Library Targets:
712# If the user asked for a shared library to be built
713# with the SHARED_LIBRARY variable, then we provide
714# targets for building them.
715#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000716ifdef SHARED_LIBRARY
717
Reid Spencercc2d1e22004-10-30 09:19:36 +0000718all-local:: $(LibName.LA)
Reid Spencer4d71b662004-10-22 21:01:56 +0000719
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000720ifdef LINK_LIBS_IN_SHARED
721$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
722 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
723 $(Verb) $(Link) -o $@ $(ObjectsLO) \
724 $(ProjLibsOptions) $(LLVMLibsOptions)
725 $(Verb) $(LTInstall) $@ $(LibDir)
726else
Reid Spencerf2ac1892004-12-16 07:36:08 +0000727$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000728 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000729 $(Verb) $(Link) -o $@ $(ObjectsLO)
730 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000731endif
Reid Spencer3a561f52004-10-23 20:04:14 +0000732
733clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000734ifneq ($(strip $(LibName.LA)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000735 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000736endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000737
Reid Spencer11fde542005-01-16 02:20:54 +0000738DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencer4d71b662004-10-22 21:01:56 +0000739
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000740install-local:: $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000741
Reid Spencer11fde542005-01-16 02:20:54 +0000742$(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
Reid Spencer9af3b292004-11-01 07:50:27 +0000743 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000744 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
Reid Spencer11fde542005-01-16 02:20:54 +0000745 $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
Reid Spencere5487ba2004-10-24 07:53:21 +0000746
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000747uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000748 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencer11fde542005-01-16 02:20:54 +0000749 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
Reid Spencere5487ba2004-10-24 07:53:21 +0000750
Reid Spencer4d71b662004-10-22 21:01:56 +0000751endif
752
Reid Spencer3a561f52004-10-23 20:04:14 +0000753#---------------------------------------------------------
754# Bytecode Library Targets:
755# If the user asked for a bytecode library to be built
756# with the BYTECODE_LIBRARY variable, then we provide
757# targets for building them.
758#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000759ifdef BYTECODE_LIBRARY
Reid Spencer9a8398e2005-02-14 21:54:08 +0000760ifeq ($(strip $(LLVMGCC)),)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000761$(warning Bytecode libraries require llvm-gcc which could not be found ****)
Reid Spencer9a8398e2005-02-14 21:54:08 +0000762else
Reid Spencer4d71b662004-10-22 21:01:56 +0000763
Reid Spencer9a2f1372004-12-02 09:28:21 +0000764all-local:: $(LibName.BCA)
765
766ifdef EXPORTED_SYMBOL_FILE
Chris Lattner89681112006-01-27 22:13:12 +0000767BCLinkLib = $(GCCLD) -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000768
Reid Spencerf2ac1892004-12-16 07:36:08 +0000769$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
Chris Lattner264ccbe2004-12-15 17:14:06 +0000770 $(LLVMToolDir)/llvm-ar
Reid Spencer9a2f1372004-12-02 09:28:21 +0000771 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
772 "(internalize)"
Chris Lattnerb0ea8642004-12-02 21:23:43 +0000773 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencerefd6bb32004-12-13 03:59:35 +0000774 $(Verb) $(RM) -f $@
Reid Spencer9a2f1372004-12-02 09:28:21 +0000775 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencer4d71b662004-10-22 21:01:56 +0000776else
Reid Spencerf2ac1892004-12-16 07:36:08 +0000777$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
Chris Lattner264ccbe2004-12-15 17:14:06 +0000778 $(LLVMToolDir)/llvm-ar
Reid Spencer9a2f1372004-12-02 09:28:21 +0000779 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencerefd6bb32004-12-13 03:59:35 +0000780 $(Verb) $(RM) -f $@
Reid Spencer9a2f1372004-12-02 09:28:21 +0000781 $(Verb) $(LArchive) $@ $(ObjectsBC)
782
Reid Spencer4d71b662004-10-22 21:01:56 +0000783endif
784
Reid Spencer3a561f52004-10-23 20:04:14 +0000785clean-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000786ifneq ($(strip $(LibName.BCA)),)
787 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000788endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000789
Reid Spencer8f094f32004-12-13 07:28:21 +0000790ifdef BYTECODE_DESTINATION
791BytecodeDestDir := $(BYTECODE_DESTINATION)
792else
Reid Spencer11fde542005-01-16 02:20:54 +0000793BytecodeDestDir := $(PROJ_libdir)
Reid Spencer8f094f32004-12-13 07:28:21 +0000794endif
795
796DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
Reid Spencer9a2f1372004-12-02 09:28:21 +0000797
Reid Spencer44cb1b32004-12-03 20:08:48 +0000798install-bytecode-local:: $(DestBytecodeLib)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000799
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000800install-local:: $(DestBytecodeLib)
Chris Lattner481cc7c2003-08-15 02:18:35 +0000801
Reid Spencer8f094f32004-12-13 07:28:21 +0000802$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000803 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerb80621f2005-02-24 21:36:32 +0000804 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000805
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000806uninstall-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000807 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000808 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000809
810endif
Reid Spencer9a8398e2005-02-14 21:54:08 +0000811endif
Vikram S. Adve60f56062002-08-02 18:34:12 +0000812
Reid Spencercc2d1e22004-10-30 09:19:36 +0000813#---------------------------------------------------------
814# ReLinked Library Targets:
Chris Lattner89938082005-10-24 02:21:45 +0000815# If the user explicitly requests a relinked library with
816# BUILD_RELINKED, provide it. Otherwise, if they specify
817# neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
818# them one.
Reid Spencercc2d1e22004-10-30 09:19:36 +0000819#---------------------------------------------------------
Chris Lattner89938082005-10-24 02:21:45 +0000820ifndef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000821ifndef DONT_BUILD_RELINKED
Chris Lattner89938082005-10-24 02:21:45 +0000822BUILD_RELINKED = 1
823endif
824endif
825
826ifdef BUILD_RELINKED
Reid Spencer4d71b662004-10-22 21:01:56 +0000827
Reid Spencercc2d1e22004-10-30 09:19:36 +0000828all-local:: $(LibName.O)
829
Reid Spencerf2ac1892004-12-16 07:36:08 +0000830$(LibName.O): $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000831 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000832 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencer4d71b662004-10-22 21:01:56 +0000833
Reid Spencer3a561f52004-10-23 20:04:14 +0000834clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000835ifneq ($(strip $(LibName.O)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000836 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencere5487ba2004-10-24 07:53:21 +0000837endif
838
Reid Spencer11fde542005-01-16 02:20:54 +0000839DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
Reid Spencere5487ba2004-10-24 07:53:21 +0000840
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000841install-local:: $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000842
Reid Spencer11fde542005-01-16 02:20:54 +0000843$(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
Reid Spencer9af3b292004-11-01 07:50:27 +0000844 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000845 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000846
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000847uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000848 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000849 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000850
Chris Lattnere62dbe92002-07-23 17:56:16 +0000851endif
Chris Lattner760da062003-03-14 20:25:22 +0000852
Reid Spencercc2d1e22004-10-30 09:19:36 +0000853#---------------------------------------------------------
854# Archive Library Targets:
855# If the user wanted a regular archive library built,
856# then we provide targets for building them.
857#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000858ifdef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000859
Reid Spencercc2d1e22004-10-30 09:19:36 +0000860all-local:: $(LibName.A)
861
Reid Spencerf2ac1892004-12-16 07:36:08 +0000862$(LibName.A): $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000863 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000864 -$(Verb) $(RM) -f $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000865 $(Verb) $(Archive) $@ $(ObjectsO)
866 $(Verb) $(Ranlib) $@
Vikram S. Adve41e78912002-09-20 14:03:13 +0000867
Reid Spencer3a561f52004-10-23 20:04:14 +0000868clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000869ifneq ($(strip $(LibName.A)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000870 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner00950542001-06-06 20:29:01 +0000871endif
872
Reid Spencer11fde542005-01-16 02:20:54 +0000873DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
Reid Spencere5487ba2004-10-24 07:53:21 +0000874
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000875install-local:: $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000876
Reid Spencer11fde542005-01-16 02:20:54 +0000877$(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
Reid Spencer9af3b292004-11-01 07:50:27 +0000878 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencer11fde542005-01-16 02:20:54 +0000879 $(Verb) $(MKDIR) $(PROJ_libdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000880 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000881
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000882uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000883 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000884 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000885
886endif
887
888# endif LIBRARYNAME
Reid Spencer4d71b662004-10-22 21:01:56 +0000889endif
890
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000891###############################################################################
892# Tool Build Rules: Build executable tool based on TOOLNAME option
893###############################################################################
894
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000895ifdef TOOLNAME
896
Reid Spencercc2d1e22004-10-30 09:19:36 +0000897#---------------------------------------------------------
898# Set up variables for building a tool.
899#---------------------------------------------------------
Reid Spencer815cbcf2004-11-18 10:03:46 +0000900ifdef EXAMPLE_TOOL
Reid Spencer5da2d082005-05-19 21:03:11 +0000901ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000902else
Reid Spencer5da2d082005-05-19 21:03:11 +0000903ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000904endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000905
Reid Spencercc2d1e22004-10-30 09:19:36 +0000906#---------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000907# Tell make that we need to rebuild subdirectories before
908# we can link the tool. This affects things like LLI which
909# has library subdirectories.
910#---------------------------------------------------------
911$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000912
Reid Spencercc2d1e22004-10-30 09:19:36 +0000913#---------------------------------------------------------
914# Provide targets for building the tools
915#---------------------------------------------------------
916all-local:: $(ToolBuildPath)
John Criswell2a6530f2003-06-27 16:58:44 +0000917
Reid Spencer3a561f52004-10-23 20:04:14 +0000918clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000919ifneq ($(strip $(ToolBuildPath)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000920 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencere5487ba2004-10-24 07:53:21 +0000921endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000922
Reid Spencer815cbcf2004-11-18 10:03:46 +0000923ifdef EXAMPLE_TOOL
924$(ToolBuildPath): $(ExmplDir)/.dir
925else
926$(ToolBuildPath): $(ToolDir)/.dir
927endif
928
Reid Spencerf2ac1892004-12-16 07:36:08 +0000929$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencer9af3b292004-11-01 07:50:27 +0000930 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000931 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
Reid Spencer9a8398e2005-02-14 21:54:08 +0000932 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000933 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencere5487ba2004-10-24 07:53:21 +0000934
Reid Spencer11fde542005-01-16 02:20:54 +0000935DestTool = $(PROJ_bindir)/$(TOOLNAME)
Reid Spencere5487ba2004-10-24 07:53:21 +0000936
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000937install-local:: $(DestTool)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000938
Reid Spencer11fde542005-01-16 02:20:54 +0000939$(DestTool): $(PROJ_bindir) $(ToolBuildPath)
Reid Spencer9af3b292004-11-01 07:50:27 +0000940 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencer4a0aaea2005-02-24 03:56:32 +0000941 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000942
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000943uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000944 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000945 -$(Verb) $(RM) -f $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000946
Reid Spencer4d71b662004-10-22 21:01:56 +0000947endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000948
Reid Spencercc2d1e22004-10-30 09:19:36 +0000949###############################################################################
950# Object Build Rules: Build object files based on sources
951###############################################################################
952
953# Provide rule sets for when dependency generation is enabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000954ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve41e78912002-09-20 14:03:13 +0000955
Reid Spencercc2d1e22004-10-30 09:19:36 +0000956#---------------------------------------------------------
957# Create .lo files in the ObjDir directory from the .cpp and .c files...
958#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000959ifdef SHARED_LIBRARY
960
Chris Lattner3c473472004-12-16 17:28:50 +0000961$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +0000962 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000963 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
964 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
965 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000966
Chris Lattnerb05a76c2005-02-04 21:28:50 +0000967$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
968 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
969 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
970 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
971 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
972
Chris Lattner3c473472004-12-16 17:28:50 +0000973$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +0000974 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000975 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
976 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
977 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000978
Reid Spencercc2d1e22004-10-30 09:19:36 +0000979#---------------------------------------------------------
980# Create .o files in the ObjDir directory from the .cpp and .c files...
981#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000982else
Reid Spencer4d71b662004-10-22 21:01:56 +0000983
Chris Lattner3c473472004-12-16 17:28:50 +0000984$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +0000985 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000986 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
987 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
988 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000989
Chris Lattnerb05a76c2005-02-04 21:28:50 +0000990$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
991 $(Echo) "Compiling $*.cc for $(BuildMode) build"
992 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
993 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
994 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
995
Chris Lattner3c473472004-12-16 17:28:50 +0000996$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +0000997 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000998 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
999 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
1000 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +00001001
1002endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001003
Chris Lattner0cb09f12005-10-05 00:28:41 +00001004## Rules for building preprocessed (.i/.ii) outputs.
1005$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1006 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1007 $(Verb) $(Preprocess.CXX) $< -o $@
1008
1009$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1010 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1011 $(Verb) $(Preprocess.CXX) $< -o $@
1012
1013 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1014 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1015 $(Verb) $(Preprocess.C) $< -o $@
1016
1017
Reid Spencercc2d1e22004-10-30 09:19:36 +00001018#---------------------------------------------------------
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001019# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
Reid Spencercc2d1e22004-10-30 09:19:36 +00001020#---------------------------------------------------------
Chris Lattner89681112006-01-27 22:13:12 +00001021
1022$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001023 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001024 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ -S -emit-llvm ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001025 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1026 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +00001027
Chris Lattner89681112006-01-27 22:13:12 +00001028$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001029 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001030 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ -S -emit-llvm ; \
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001031 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1032 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1033
Chris Lattner89681112006-01-27 22:13:12 +00001034$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001035 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001036 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ -S -emit-llvm ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001037 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1038 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +00001039
Reid Spencercc2d1e22004-10-30 09:19:36 +00001040# Provide alternate rule sets if dependencies are disabled
Reid Spencer4d71b662004-10-22 21:01:56 +00001041else
1042
Reid Spencer3a561f52004-10-23 20:04:14 +00001043ifdef SHARED_LIBRARY
1044
Chris Lattner3c473472004-12-16 17:28:50 +00001045$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001046 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +00001047 $(LTCompile.CXX) $< -o $@
1048
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001049$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1050 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
1051 $(LTCompile.CXX) $< -o $@
1052
Chris Lattner3c473472004-12-16 17:28:50 +00001053$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerc3719842004-12-16 18:26:53 +00001054 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +00001055 $(LTCompile.C) $< -o $@
1056
1057else
Reid Spencer4d71b662004-10-22 21:01:56 +00001058
Chris Lattner3c473472004-12-16 17:28:50 +00001059$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001060 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +00001061 $(Compile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +00001062
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001063$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1064 $(Echo) "Compiling $*.cc for $(BuildMode) build"
1065 $(Compile.CXX) $< -o $@
1066
Chris Lattner3c473472004-12-16 17:28:50 +00001067$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerc3719842004-12-16 18:26:53 +00001068 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +00001069 $(Compile.C) $< -o $@
1070endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001071
Chris Lattner89681112006-01-27 22:13:12 +00001072$(ObjDir)/%.ll: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001073 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001074 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Reid Spencer4d71b662004-10-22 21:01:56 +00001075
Chris Lattner89681112006-01-27 22:13:12 +00001076$(ObjDir)/%.ll: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001077 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001078 $(BCCompile.CXX) $< -o $@ -S -emit-llvm
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001079
Chris Lattner89681112006-01-27 22:13:12 +00001080$(ObjDir)/%.ll: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001081 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Chris Lattner89681112006-01-27 22:13:12 +00001082 $(BCCompile.C) $< -o $@ -S -emit-llvm
Brian Gaeke44909cf2003-12-10 00:26:28 +00001083
Chris Lattner1cbc29f2001-09-07 22:57:58 +00001084endif
1085
Chris Lattner89681112006-01-27 22:13:12 +00001086# make the C and C++ compilers strip debug info out of bytecode libraries.
1087ifdef DEBUG_RUNTIME
1088$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1089 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1090 @$(GCCAS) $< -o $@
1091else
1092$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1093 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1094 @$(GCCAS) -strip-debug $< -o $@
1095endif
1096
1097
Reid Spencercc2d1e22004-10-30 09:19:36 +00001098#---------------------------------------------------------
1099# Provide rule to build .bc files from .ll sources,
1100# regardless of dependencies
1101#---------------------------------------------------------
1102$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencer9af3b292004-11-01 07:50:27 +00001103 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001104 $(Verb) $(LLVMAS) $< -f -o $@
1105
1106###############################################################################
1107# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1108###############################################################################
Chris Lattner481cc7c2003-08-15 02:18:35 +00001109
Reid Spencer4d71b662004-10-22 21:01:56 +00001110ifdef TARGET
1111
Chris Lattner0b616772005-10-14 06:31:58 +00001112TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001113INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Chris Lattner3c473472004-12-16 17:28:50 +00001114INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1115.PRECIOUS: $(INCTMPFiles) $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001116
Chris Lattner3c473472004-12-16 17:28:50 +00001117# All of these files depend on tblgen and the .td files.
1118$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001119
Chris Lattner23ee7952004-12-16 17:38:56 +00001120# INCFiles rule: All of the tblgen generated files are emitted to
1121# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1122# us to only "touch" the real file if the contents of it change. IOW, if
1123# tblgen is modified, all of the .inc.tmp files are regereated, but no
1124# dependencies of the .inc files are, unless the contents of the .inc file
1125# changes.
1126$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
Reid Spencerc3719842004-12-16 18:26:53 +00001127 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
Chris Lattner3c473472004-12-16 17:28:50 +00001128
1129$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1130$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001131 $(Echo) "Building $(<F) register names with tblgen"
1132 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001133
Chris Lattner3c473472004-12-16 17:28:50 +00001134$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1135$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001136 $(Echo) "Building $(<F) register information header with tblgen"
1137 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001138
Chris Lattner3c473472004-12-16 17:28:50 +00001139$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1140$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001141 $(Echo) "Building $(<F) register info implementation with tblgen"
1142 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001143
Chris Lattner3c473472004-12-16 17:28:50 +00001144$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1145$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001146 $(Echo) "Building $(<F) instruction names with tblgen"
1147 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001148
Chris Lattner3c473472004-12-16 17:28:50 +00001149$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1150$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001151 $(Echo) "Building $(<F) instruction information with tblgen"
1152 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001153
Chris Lattner3c473472004-12-16 17:28:50 +00001154$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1155$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001156 $(Echo) "Building $(<F) assembly writer with tblgen"
1157 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001158
Chris Lattner02a4f902004-12-16 17:34:04 +00001159$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1160$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1161 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001162 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001163
Chris Lattner3c473472004-12-16 17:28:50 +00001164$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1165$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001166 $(Echo) "Building $(<F) code emitter with tblgen"
1167 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001168
Chris Lattnerf31f09e2005-09-03 01:15:25 +00001169$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1170$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1171 $(Echo) "Building $(<F) instruction selector implementation with tblgen"
1172 $(Verb) $(TableGen) -gen-dag-isel -o $@ $<
1173
Jim Laskeyf5fc2cb2005-10-21 19:05:19 +00001174$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
1175$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
1176 $(Echo) "Building $(<F) subtarget information with tblgen"
1177 $(Verb) $(TableGen) -gen-subtarget -o $@ $<
Chris Lattnerf31f09e2005-09-03 01:15:25 +00001178
Reid Spencer3a561f52004-10-23 20:04:14 +00001179clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001180 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001181
1182endif
Chris Lattner481cc7c2003-08-15 02:18:35 +00001183
Reid Spencercc2d1e22004-10-30 09:19:36 +00001184###############################################################################
1185# LEX AND YACC: Provide rules for generating sources with lex and yacc
1186###############################################################################
Chris Lattnere8996782003-01-16 22:44:19 +00001187
Reid Spencercc2d1e22004-10-30 09:19:36 +00001188#---------------------------------------------------------
1189# Provide rules for generating a .cpp source file from
1190# (f)lex input sources.
1191#---------------------------------------------------------
1192
Reid Spencer3d659492004-11-02 16:36:03 +00001193LexFiles := $(filter %.l,$(Sources))
Reid Spencercc2d1e22004-10-30 09:19:36 +00001194
Reid Spencer3d659492004-11-02 16:36:03 +00001195ifneq ($(LexFiles),)
1196
Reid Spencer68a24bd2005-08-27 18:50:39 +00001197# Cancel built-in rules for lex
1198%.c: %.l
1199%.cpp: %.l
Reid Spencercc2d1e22004-10-30 09:19:36 +00001200
1201# Note the extra sed filtering here, used to cut down on the warnings emited
1202# by GCC. The last line is a gross hack to work around flex aparently not
1203# being able to resize the buffer on a large token input. Currently, for
1204# uninitialized string buffers in LLVM we can generate very long tokens, so
1205# this is a hack around it.
Chris Lattnerb7dc2b92003-08-15 20:00:47 +00001206# FIXME. (f.e. char Buffer[10000] )
Reid Spencer68a24bd2005-08-27 18:50:39 +00001207$(PROJ_SRC_DIR)/%.cpp: $(PROJ_SRC_DIR)/%.l
Reid Spencerc2ef8cd2004-12-10 19:44:16 +00001208 $(Echo) Flexing $*.l
Reid Spencer68a24bd2005-08-27 18:50:39 +00001209 $(Verb) $(FLEX) -t $(PROJ_SRC_DIR)/$*.l | \
Reid Spencer4d71b662004-10-22 21:01:56 +00001210 $(SED) 's/void yyunput/inline void yyunput/' | \
1211 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1212 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001213 > $(PROJ_SRC_DIR)/$*.cpp
1214 $(Echo) "*** DON'T FORGET TO CHECK IN $*.cpp (generated file)"
1215
1216LexObjs := $(patsubst %.l,$(ObjDir)/%.o,$(LexFiles))
1217$(LexObjs): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
Chris Lattner00950542001-06-06 20:29:01 +00001218
Reid Spencer9af3b292004-11-01 07:50:27 +00001219clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001220 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencer9af3b292004-11-01 07:50:27 +00001221
Reid Spencercc2d1e22004-10-30 09:19:36 +00001222endif
1223
1224#---------------------------------------------------------
1225# Provide rules for generating a .cpp and .h source files
1226# from yacc (bison) input sources.
1227#---------------------------------------------------------
1228
Reid Spencer3d659492004-11-02 16:36:03 +00001229YaccFiles := $(filter %.y,$(Sources))
1230ifneq ($(YaccFiles),)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001231
1232.PRECIOUS: $(YaccOutput)
1233
1234# Cancel built-in rules for yacc
1235%.c: %.y
1236%.cpp: %.y
1237%.h: %.y
1238
Reid Spencer25e8a702005-12-21 23:17:06 +00001239# Rule for building the bison based parsers...
Reid Spencer68a24bd2005-08-27 18:50:39 +00001240$(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
Reid Spencercc2d1e22004-10-30 09:19:36 +00001241 $(Echo) "Bisoning $*.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001242 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1243 $(Verb) $(MV) -f $*.tab.c $(PROJ_SRC_DIR)/$*.cpp
1244 $(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
1245 $(Echo) "*** DON'T FORGET TO CHECK IN $*.cpp and $*.h (generated files)"
Chris Lattner00950542001-06-06 20:29:01 +00001246
Reid Spencer25e8a702005-12-21 23:17:06 +00001247YaccObjs := $(patsubst %.y,$(ObjDir)/%.o,$(YaccFiles))
1248$(YaccObjs): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
1249
1250YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.output)
1251
Reid Spencer9af3b292004-11-01 07:50:27 +00001252clean-local::
Reid Spencer25e8a702005-12-21 23:17:06 +00001253 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001254endif
Chris Lattner00950542001-06-06 20:29:01 +00001255
Reid Spencercc2d1e22004-10-30 09:19:36 +00001256###############################################################################
1257# OTHER RULES: Other rules needed
1258###############################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +00001259
Chris Lattner30440c62003-01-16 21:06:18 +00001260# To create postscript files from dot files...
John Criswelle0f9ac62003-10-02 19:02:02 +00001261ifneq ($(DOT),false)
Chris Lattner30440c62003-01-16 21:06:18 +00001262%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +00001263 $(DOT) -Tps < $< > $@
John Criswell7a73b802003-06-30 21:59:07 +00001264else
1265%.ps: %.dot
Reid Spencercc2d1e22004-10-30 09:19:36 +00001266 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell7a73b802003-06-30 21:59:07 +00001267endif
Chris Lattner30440c62003-01-16 21:06:18 +00001268
John Criswell7f336952003-09-06 14:44:17 +00001269# This rules ensures that header files that are removed still have a rule for
1270# which they can be "generated." This allows make to ignore them and
1271# reproduce the dependency lists.
John Criswell4b6e5d12003-09-18 18:37:08 +00001272%.h:: ;
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001273%.hpp:: ;
John Criswell7f336952003-09-06 14:44:17 +00001274
Reid Spencercc2d1e22004-10-30 09:19:36 +00001275# Define clean-local to clean the current directory. Note that this uses a
1276# very conservative approach ensuring that empty variables do not cause
1277# errors or disastrous removal.
Reid Spencer3a561f52004-10-23 20:04:14 +00001278clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001279ifneq ($(strip $(ObjDir)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001280 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencere5487ba2004-10-24 07:53:21 +00001281endif
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001282 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001283ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001284 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001285endif
John Criswell7a73b802003-06-30 21:59:07 +00001286
Reid Spencer3d659492004-11-02 16:36:03 +00001287clean-all-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001288 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer3d659492004-11-02 16:36:03 +00001289
Reid Spencercc2d1e22004-10-30 09:19:36 +00001290# Build tags database for Emacs/Xemacs:
Reid Spencer12d79512004-11-12 02:27:36 +00001291tags:: TAGS CTAGS
1292
Reid Spencercc2d1e22004-10-30 09:19:36 +00001293TAGS:
Reid Spencer11fde542005-01-16 02:20:54 +00001294 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1295 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1296 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1297 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spencer12d79512004-11-12 02:27:36 +00001298 -name '*.cpp' -o -name '*.h' | \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001299 $(ETAGS) $(ETAGSFLAGS) -
1300
Reid Spencer12d79512004-11-12 02:27:36 +00001301CTAGS:
Reid Spencer11fde542005-01-16 02:20:54 +00001302 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1303 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1304 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1305 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spencer12d79512004-11-12 02:27:36 +00001306 \( -name '*.cpp' -o -name '*.h' \) -print | \
Reid Spencer11fde542005-01-16 02:20:54 +00001307 ctags -ImtT -o $(PROJ_OBJ_ROOT)/CTAGS -L -
Reid Spencer12d79512004-11-12 02:27:36 +00001308
1309
Reid Spencer3a561f52004-10-23 20:04:14 +00001310###############################################################################
1311# DEPENDENCIES: Include the dependency files if we should
1312###############################################################################
Chris Lattner33ad24a2003-08-22 14:10:16 +00001313ifndef DISABLE_AUTO_DEPENDENCIES
1314
Reid Spencer3a561f52004-10-23 20:04:14 +00001315# If its not one of the cleaning targets
Reid Spencercc2d1e22004-10-30 09:19:36 +00001316ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencer4d71b662004-10-22 21:01:56 +00001317
Reid Spencer3a561f52004-10-23 20:04:14 +00001318# Get the list of dependency files
Reid Spencercc2d1e22004-10-30 09:19:36 +00001319DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Reid Spencer11fde542005-01-16 02:20:54 +00001320DependFiles := $(patsubst %,$(PROJ_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
Misha Brukman4f7a8cf2003-11-09 21:36:19 +00001321
Reid Spencer3a561f52004-10-23 20:04:14 +00001322-include /dev/null $(DependFiles)
1323
John Criswelld741bcf2003-08-12 18:51:51 +00001324endif
Chris Lattner1ddb6b62003-08-18 17:27:40 +00001325
Reid Spencercc2d1e22004-10-30 09:19:36 +00001326endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001327
Reid Spencer151f8ba2004-10-25 08:27:37 +00001328###############################################################################
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001329# CHECK: Running the test suite
1330###############################################################################
1331
1332check::
Reid Spencer11fde542005-01-16 02:20:54 +00001333 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1334 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001335 $(EchoCmd) Running test suite ; \
Reid Spencer11fde542005-01-16 02:20:54 +00001336 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001337 TESTSUITE=$(TESTSUITE) ; \
1338 else \
1339 $(EchoCmd) No Makefile in test directory ; \
1340 fi ; \
1341 else \
1342 $(EchoCmd) No test directory ; \
1343 fi
1344
1345###############################################################################
Reid Spencercc2d1e22004-10-30 09:19:36 +00001346# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer151f8ba2004-10-25 08:27:37 +00001347###############################################################################
1348
Reid Spencere45ebfa2004-10-26 07:09:33 +00001349#------------------------------------------------------------------------
1350# Define distribution related variables
1351#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +00001352DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1353DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1354TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1355DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1356DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1357DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
Reid Spencer151f8ba2004-10-25 08:27:37 +00001358DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1359 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001360 Makefile.config.in configure autoconf
1361DistOther := $(notdir $(wildcard \
Reid Spencer11fde542005-01-16 02:20:54 +00001362 $(PROJ_SRC_DIR)/*.h \
1363 $(PROJ_SRC_DIR)/*.td \
1364 $(PROJ_SRC_DIR)/*.def \
1365 $(PROJ_SRC_DIR)/*.ll \
1366 $(PROJ_SRC_DIR)/*.in))
Reid Spencercc2d1e22004-10-30 09:19:36 +00001367DistSubDirs := $(SubDirs)
Reid Spencerfbbf3072004-11-29 05:00:33 +00001368DistSources = $(Sources) $(EXTRA_DIST)
1369DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer151f8ba2004-10-25 08:27:37 +00001370
Reid Spencere45ebfa2004-10-26 07:09:33 +00001371#------------------------------------------------------------------------
1372# We MUST build distribution with OBJ_DIR != SRC_DIR
1373#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +00001374ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
Reid Spencere45ebfa2004-10-26 07:09:33 +00001375dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001376 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencere45ebfa2004-10-26 07:09:33 +00001377
Reid Spencere45ebfa2004-10-26 07:09:33 +00001378else
1379
Reid Spencere45ebfa2004-10-26 07:09:33 +00001380#------------------------------------------------------------------------
Reid Spencere45ebfa2004-10-26 07:09:33 +00001381# Prevent attempt to run dist targets from anywhere but the top level
1382#------------------------------------------------------------------------
1383ifneq ($(LEVEL),.)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001384dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencer11fde542005-01-16 02:20:54 +00001385 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001386else
1387
1388#------------------------------------------------------------------------
1389# Provide the top level targets
1390#------------------------------------------------------------------------
1391
Reid Spencercc2d1e22004-10-30 09:19:36 +00001392dist-gzip:: $(DistTarGZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001393
Reid Spencer345235ca2004-12-04 22:34:09 +00001394$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001395 $(Echo) Packing gzipped distribution tar file.
Reid Spencer11fde542005-01-16 02:20:54 +00001396 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
Reid Spencerfbbf3072004-11-29 05:00:33 +00001397 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencere45ebfa2004-10-26 07:09:33 +00001398
Reid Spencercc2d1e22004-10-30 09:19:36 +00001399dist-bzip2:: $(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001400
Reid Spencer345235ca2004-12-04 22:34:09 +00001401$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001402 $(Echo) Packing bzipped distribution tar file.
Reid Spencer11fde542005-01-16 02:20:54 +00001403 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
Reid Spencerfbbf3072004-11-29 05:00:33 +00001404 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001405
Reid Spencercc2d1e22004-10-30 09:19:36 +00001406dist-zip:: $(DistZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001407
Reid Spencer345235ca2004-12-04 22:34:09 +00001408$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001409 $(Echo) Packing zipped distribution file.
1410 $(Verb) rm -f $(DistZip)
Reid Spencer11fde542005-01-16 02:20:54 +00001411 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001412
1413dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001414 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001415
Reid Spencerf8f57402005-01-28 19:52:32 +00001416DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
Reid Spencere45ebfa2004-10-26 07:09:33 +00001417
Reid Spencer345235ca2004-12-04 22:34:09 +00001418dist-check:: $(DistTarGZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001419 $(Echo) Checking distribution tar file.
1420 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001421 $(RM) -rf $(DistCheckDir) ; \
1422 fi
Reid Spencercc2d1e22004-10-30 09:19:36 +00001423 $(Verb) $(MKDIR) $(DistCheckDir)
1424 $(Verb) cd $(DistCheckDir) && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001425 $(MKDIR) $(DistCheckDir)/build && \
1426 $(MKDIR) $(DistCheckDir)/install && \
1427 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1428 cd build && \
1429 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
Reid Spencer45eeed92005-05-24 02:33:20 +00001430 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
Reid Spencer345235ca2004-12-04 22:34:09 +00001431 $(MAKE) all && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001432 $(MAKE) check && \
1433 $(MAKE) install && \
1434 $(MAKE) uninstall && \
1435 $(MAKE) dist && \
1436 $(MAKE) clean && \
1437 $(MAKE) dist-clean && \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001438 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001439
1440dist-clean::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001441 $(Echo) Cleaning distribution files
Reid Spencer345235ca2004-12-04 22:34:09 +00001442 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1443 $(DistCheckDir)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001444
1445endif
1446
1447#------------------------------------------------------------------------
1448# Provide the recursive distdir target for building the distribution directory
1449#------------------------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +00001450distdir: $(DistDir)/.makedistdir
1451$(DistDir)/.makedistdir: $(DistSources)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001452 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001453 if test -d "$(DistDir)" ; then \
1454 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1455 exit 1 ; \
1456 fi ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001457 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001458 $(RM) -rf $(DistDir); \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001459 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001460 $(MAKE) all ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001461 fi
Reid Spencerfbbf3072004-11-29 05:00:33 +00001462 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001463 $(Verb) $(MKDIR) $(DistDir)
Reid Spencer11fde542005-01-16 02:20:54 +00001464 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1465 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001466 for file in $(DistFiles) ; do \
1467 case "$$file" in \
Reid Spencer11fde542005-01-16 02:20:54 +00001468 $(PROJ_SRC_DIR)/*) \
Reid Spencer345235ca2004-12-04 22:34:09 +00001469 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1470 ;; \
Reid Spencer11fde542005-01-16 02:20:54 +00001471 $(PROJ_SRC_ROOT)/*) \
Reid Spencer345235ca2004-12-04 22:34:09 +00001472 file=`echo "$$file" | \
1473 sed "s#^$$srcrootstrip/##"` \
1474 ;; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001475 esac; \
Reid Spencer11fde542005-01-16 02:20:54 +00001476 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1477 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1478 from_dir="$(PROJ_SRC_DIR)" ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001479 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001480 from_dir=. ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001481 fi ; \
1482 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001483 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1484 to_dir="$(DistDir)/$$dir"; \
1485 $(MKDIR) "$$to_dir" ; \
1486 else \
1487 to_dir="$(DistDir)"; \
1488 fi; \
1489 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1490 if test -n "$$mid_dir" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001491 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001492 fi ; \
1493 if test -d "$$from_dir/$$file"; then \
Reid Spencer11fde542005-01-16 02:20:54 +00001494 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1495 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
Reid Spencer45eeed92005-05-24 02:33:20 +00001496 cd $(PROJ_SRC_DIR) ; \
1497 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1498 ( cd $$to_dir ; $(TAR) xf - ) ; \
1499 cd $(PROJ_OBJ_DIR) ; \
1500 else \
1501 cd $$from_dir ; \
1502 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1503 ( cd $$to_dir ; $(TAR) xf - ) ; \
1504 cd $(PROJ_OBJ_DIR) ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001505 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001506 elif test -f "$$from_dir/$$file" ; then \
Reid Spencerc3719842004-12-16 18:26:53 +00001507 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001508 elif test -L "$$from_dir/$$file" ; then \
Reid Spencerc3719842004-12-16 18:26:53 +00001509 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001510 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer345235ca2004-12-04 22:34:09 +00001511 $(EchoCmd) "===== WARNING: Distribution Source " \
1512 "$$from_dir/$$file Not Found!" ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001513 elif test "$(Verb)" != '@' ; then \
1514 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001515 fi; \
1516 done
Reid Spencercc2d1e22004-10-30 09:19:36 +00001517 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001518 if test "$$subdir" \!= "." ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001519 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001520 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001521 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1522 exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001523 fi; \
1524 done
Reid Spencer345235ca2004-12-04 22:34:09 +00001525 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer45eeed92005-05-24 02:33:20 +00001526 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1527 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o -name .svn \) -print` ;\
Reid Spencer345235ca2004-12-04 22:34:09 +00001528 $(MAKE) dist-hook ; \
1529 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1530 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1531 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1532 -o ! -type d ! -perm -444 -exec \
1533 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1534 || chmod -R a+r $(DistDir) ; \
1535 fi
Reid Spencer151f8ba2004-10-25 08:27:37 +00001536
Reid Spencercc2d1e22004-10-30 09:19:36 +00001537# This is invoked by distdir target, define it as a no-op to avoid errors if not
1538# defined by user.
Reid Spencer151f8ba2004-10-25 08:27:37 +00001539dist-hook::
1540
Reid Spencere53e3972004-10-22 23:06:30 +00001541endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001542
1543###############################################################################
Reid Spencere5487ba2004-10-24 07:53:21 +00001544# TOP LEVEL - targets only to apply at the top level directory
1545###############################################################################
1546
1547ifeq ($(LEVEL),.)
1548
1549#------------------------------------------------------------------------
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001550# Install support for the project's include files:
Reid Spencere5487ba2004-10-24 07:53:21 +00001551#------------------------------------------------------------------------
1552install-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001553 $(Echo) Installing include files
Reid Spencer11fde542005-01-16 02:20:54 +00001554 $(Verb) $(MKDIR) $(PROJ_includedir)
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001555 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
Reid Spencer11fde542005-01-16 02:20:54 +00001556 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer2edabc02005-02-16 15:54:03 +00001557 for hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
1558 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS ` ; do \
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001559 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1560 if test \! -d "$$instdir" ; then \
1561 $(EchoCmd) Making install directory $$instdir ; \
1562 $(MKDIR) $$instdir ;\
1563 fi ; \
1564 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer2edabc02005-02-16 15:54:03 +00001565 done ; \
Reid Spencere5487ba2004-10-24 07:53:21 +00001566 fi
Reid Spencer443045a2005-12-23 22:27:56 +00001567ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001568 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
Reid Spencer2edabc02005-02-16 15:54:03 +00001569 cd $(PROJ_OBJ_ROOT)/include && \
Reid Spencer443045a2005-12-23 22:27:56 +00001570 for hdr in `find . -type f -print | grep -v CVS` ; do \
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001571 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer2edabc02005-02-16 15:54:03 +00001572 done ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001573 fi
Reid Spencer443045a2005-12-23 22:27:56 +00001574endif
Reid Spencere5487ba2004-10-24 07:53:21 +00001575
1576uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001577 $(Echo) Uninstalling include files
Reid Spencer11fde542005-01-16 02:20:54 +00001578 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1579 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencere5487ba2004-10-24 07:53:21 +00001580 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001581 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' -o -name '*.in' ')' \
Reid Spencer11fde542005-01-16 02:20:54 +00001582 -print ')' | grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001583 cd $(PROJ_SRC_ROOT)/include && \
1584 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' -print ')' \
1585 | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1586 fi
Reid Spencere5487ba2004-10-24 07:53:21 +00001587
Reid Spencere5487ba2004-10-24 07:53:21 +00001588endif
1589
Reid Spencer4d71b662004-10-22 21:01:56 +00001590#------------------------------------------------------------------------
1591# Print out the directories used for building
Reid Spencercc2d1e22004-10-30 09:19:36 +00001592#------------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001593printvars::
Reid Spencer11fde542005-01-16 02:20:54 +00001594 $(Echo) "BuildMode : " '$(BuildMode)'
1595 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1596 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1597 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1598 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1599 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1600 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1601 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1602 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1603 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1604 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
Reid Spencer1a9a69c2005-02-16 16:13:02 +00001605 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
Reid Spencer11fde542005-01-16 02:20:54 +00001606 $(Echo) "UserTargets : " '$(UserTargets)'
1607 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1608 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1609 $(Echo) "ObjDir : " '$(ObjDir)'
1610 $(Echo) "LibDir : " '$(LibDir)'
1611 $(Echo) "ToolDir : " '$(ToolDir)'
1612 $(Echo) "ExmplDir : " '$(ExmplDir)'
1613 $(Echo) "Sources : " '$(Sources)'
1614 $(Echo) "TDFiles : " '$(TDFiles)'
1615 $(Echo) "INCFiles : " '$(INCFiles)'
1616 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
Reid Spencere0acb762005-03-01 16:27:06 +00001617 $(Echo) "PreConditions: " '$(PreConditions)'
Reid Spencer11fde542005-01-16 02:20:54 +00001618 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1619 $(Echo) "Compile.C : " '$(Compile.C)'
1620 $(Echo) "Archive : " '$(Archive)'
1621 $(Echo) "YaccFiles : " '$(YaccFiles)'
1622 $(Echo) "LexFiles : " '$(LexFiles)'
1623 $(Echo) "Module : " '$(Module)'
Reid Spencer755bcf02005-08-24 10:43:10 +00001624 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'