blob: 897905f7ae078a18063f580908e117cd2cd61d31 [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#--------------------------------------------------------------------
38VPATH=$(BUILD_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:
Reid Spencercc2d1e22004-10-30 09:19:36 +000044.SUFFIXES: .c .cpp .h .hpp .y .l .lo .o .a .bc .td .ps .dot
45.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 Spencer023c4462004-11-17 19:08:44 +000064 $(wildcard $(BUILD_SRC_DIR)/Makefile*))
Reid Spencercc2d1e22004-10-30 09:19:36 +000065ObjMakefiles := $(subst $(BUILD_SRC_DIR),$(BUILD_OBJ_DIR),$(SrcMakefiles))
66ConfigureScript := $(LLVM_SRC_ROOT)/configure
67ConfigStatusScript := $(LLVM_OBJ_ROOT)/config.status
68MakefileConfigIn := $(LLVM_SRC_ROOT)/Makefile.config.in
69MakefileConfig := $(LLVM_OBJ_ROOT)/Makefile.config
70PreConditions := $(ConfigStatusScript) $(MakefileConfig) $(ObjMakefiles)
Reid Spencer9411c642004-10-26 22:26:33 +000071
Reid Spencercc2d1e22004-10-30 09:19:36 +000072preconditions : $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +000073
74#------------------------------------------------------------------------
75# Make sure the BUILT_SOURCES are built first
76#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000077$(filter-out clean clean-local,UserTargets):: $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000078
79clean-local::
80ifneq ($(strip $(BUILT_SOURCES)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +000081 -$(Verb) $(RM) -f $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000082endif
83
Reid Spencercc2d1e22004-10-30 09:19:36 +000084$(BUILT_SOURCES) : $(ObjMakefiles)
Reid Spencer80f0ef72004-10-28 00:41:43 +000085
Reid Spencer9411c642004-10-26 22:26:33 +000086#------------------------------------------------------------------------
87# Make sure we're not using a stale configuration
88#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000089.PRECIOUS: $(ConfigStatusScript)
90$(ConfigStatusScript): $(ConfigureScript)
91 $(Echo) Reconfiguring with $<
Reid Spencer7d277002004-11-29 12:37:44 +000092 $(Verb) cd $(BUILD_OBJ_ROOT) && \
93 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
94 $(ConfigStatusScript)
Reid Spencer9411c642004-10-26 22:26:33 +000095
96#------------------------------------------------------------------------
97# Make sure the configuration makefile is up to date
98#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000099$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
100 $(Echo) Regenerating $@
101 $(Verb) cd $(LLVM_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
Reid Spencer9411c642004-10-26 22:26:33 +0000102
103#------------------------------------------------------------------------
104# If the Makefile in the source tree has been updated, copy it over into the
105# build tree. But, only do this if the source and object makefiles differ
106#------------------------------------------------------------------------
107ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
108
Reid Spencer023c4462004-11-17 19:08:44 +0000109Makefile: $(BUILD_SRC_DIR)/Makefile
Reid Spencercc2d1e22004-10-30 09:19:36 +0000110 $(Echo) "Updating Makefile"
111 $(Verb) $(MKDIR) $(@D)
112 $(Verb) cp -f $< $@
Reid Spencer9411c642004-10-26 22:26:33 +0000113
114# Copy the Makefile.* files unless we're in the root directory which avoids
115# the copying of Makefile.config.in or other things that should be explicitly
116# taken care of.
Reid Spencer9411c642004-10-26 22:26:33 +0000117$(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
Reid Spencer86606782004-10-26 23:10:00 +0000118 @case '$?' in \
119 *Makefile.rules) ;; \
120 *.in) ;; \
Reid Spencercc2d1e22004-10-30 09:19:36 +0000121 *) $(Echo) "Updating $(@F)" ; \
Reid Spencer86606782004-10-26 23:10:00 +0000122 $(MKDIR) $(@D) ; \
123 cp -f $< $@ ;; \
124 esac
125
Reid Spencer9411c642004-10-26 22:26:33 +0000126endif
127
128#------------------------------------------------------------------------
129# Set up the basic dependencies
130#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000131$(UserTargets):: $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +0000132
133all:: all-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000134clean:: clean-local
Reid Spencer3d659492004-11-02 16:36:03 +0000135clean-all:: clean-local clean-all-local
Reid Spencer9411c642004-10-26 22:26:33 +0000136install:: install-local
137uninstall:: uninstall-local
Reid Spencer9411c642004-10-26 22:26:33 +0000138install-local:: all-local
Reid Spencer44cb1b32004-12-03 20:08:48 +0000139install-bytecode:: install-bytecode-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000140
141###############################################################################
142# VARIABLES: Set up various variables based on configuration data
143###############################################################################
144
145#--------------------------------------------------------------------
146# Variables derived from configuration we are building
Chris Lattner00950542001-06-06 20:29:01 +0000147#--------------------------------------------------------------------
148
Chris Lattner760da062003-03-14 20:25:22 +0000149ifdef ENABLE_PROFILING
Reid Spencer9af3b292004-11-01 07:50:27 +0000150 BuildMode := Profile
Reid Spencer519799e2004-12-08 04:34:51 +0000151 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
Reid Spencercc2d1e22004-10-30 09:19:36 +0000152 C.Flags := -O3 -DNDEBUG -pg
153 LD.Flags := -O3 -DNDEBUG -pg
Chris Lattner760da062003-03-14 20:25:22 +0000154else
155 ifdef ENABLE_OPTIMIZED
Reid Spencer9af3b292004-11-01 07:50:27 +0000156 BuildMode := Release
Reid Spencer519799e2004-12-08 04:34:51 +0000157 CXX.Flags := -O3 -DNDEBUG -finline-functions \
Reid Spencer2e2035b2004-12-08 04:26:23 +0000158 -felide-constructors -fomit-frame-pointer
Reid Spencercc2d1e22004-10-30 09:19:36 +0000159 C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
160 LD.Flags := -O3 -DNDEBUG
Chris Lattner760da062003-03-14 20:25:22 +0000161 else
Reid Spencer9af3b292004-11-01 07:50:27 +0000162 BuildMode := Debug
Reid Spencer519799e2004-12-08 04:34:51 +0000163 CXX.Flags := -g -D_DEBUG
Reid Spencercc2d1e22004-10-30 09:19:36 +0000164 C.Flags := -g -D_DEBUG
165 LD.Flags := -g -D_DEBUG
Reid Spencer4d71b662004-10-22 21:01:56 +0000166 KEEP_SYMBOLS := 1
Chris Lattner760da062003-03-14 20:25:22 +0000167 endif
168endif
169
Reid Spencercc2d1e22004-10-30 09:19:36 +0000170CXX.Flags += $(CXXFLAGS)
171C.Flags += $(CFLAGS)
172CPP.Flags += $(CPPFLAGS)
173LD.Flags += $(LDFLAGS)
174AR.Flags := cru
175LibTool.Flags := --tag=CXX
Reid Spencer3a561f52004-10-23 20:04:14 +0000176
177#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000178# Directory locations
Reid Spencer3a561f52004-10-23 20:04:14 +0000179#--------------------------------------------------------------------
Reid Spencer9af3b292004-11-01 07:50:27 +0000180ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000181LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer9a5acaf2004-11-18 20:04:39 +0000182ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer815cbcf2004-11-18 10:03:46 +0000183ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
184LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer9a5acaf2004-11-18 20:04:39 +0000185LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer815cbcf2004-11-18 10:03:46 +0000186LExmplDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
John Criswell7a73b802003-06-30 21:59:07 +0000187
Reid Spencer3a561f52004-10-23 20:04:14 +0000188#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000189# Full Paths To Compiled Tools and Utilities
Reid Spencer3a561f52004-10-23 20:04:14 +0000190#--------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000191EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
192Echo := @$(EchoCmd)
193ifndef LIBTOOL
Reid Spencer4d71b662004-10-22 21:01:56 +0000194LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencercc2d1e22004-10-30 09:19:36 +0000195endif
196ifndef LLVMAS
197LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
198endif
199ifndef BURG
200BURG := $(LLVMToolDir)/burg$(EXEEXT)
201endif
202ifndef TBLGEN
203TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
204endif
Chris Lattner478b3b42004-11-29 19:47:58 +0000205ifndef GCCAS
206GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
207endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000208ifndef GCCLD
209GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
210endif
211ifndef LLVMGCC
212LLVMGCC := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/gcc
213endif
214ifndef LLVMGXX
215LLVMGXX := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/g++
216endif
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000217ifndef LDIS
218LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
219endif
220ifndef LLI
221LLI := $(LLVMToolDir)/lli$(EXEEXT)
222endif
223ifndef LOPT
Alkis Evlogimenos20d793a2004-12-13 18:08:29 +0000224LOPT := $(LLVMToolDir)/opt$(EXEEXT)
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000225endif
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000226
Reid Spencer3a561f52004-10-23 20:04:14 +0000227#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000228# Adjust to user's request
Reid Spencer3a561f52004-10-23 20:04:14 +0000229#--------------------------------------------------------------------
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000230
Reid Spencercc2d1e22004-10-30 09:19:36 +0000231# Adjust LIBTOOL flags for shared libraries, or not.
John Criswell82f4a5a2003-07-31 20:58:51 +0000232ifndef SHARED_LIBRARY
Reid Spencercc2d1e22004-10-30 09:19:36 +0000233 LibTool.Flags += --tag=disable-shared
Reid Spencer4d71b662004-10-22 21:01:56 +0000234else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000235 LD.Flags += -rpath $(LibDir)
John Criswell82f4a5a2003-07-31 20:58:51 +0000236endif
237
Reid Spencercceed9f2004-11-08 17:32:12 +0000238ifdef TOOL_VERBOSE
239 C.Flags += -v
240 CXX.Flags += -v
241 LD.Flags += -v
Reid Spencercceed9f2004-11-08 17:32:12 +0000242 VERBOSE := 1
243endif
244
Reid Spencer3a561f52004-10-23 20:04:14 +0000245# Adjust settings for verbose mode
Chris Lattner760da062003-03-14 20:25:22 +0000246ifndef VERBOSE
Reid Spencercc2d1e22004-10-30 09:19:36 +0000247 Verb := @
248 LibTool.Flags += --silent
249 AR.Flags += >/dev/null 2>/dev/null
250 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
Reid Spencer151f8ba2004-10-25 08:27:37 +0000251else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000252 ConfigureScriptFLAGS :=
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000253endif
254
Vikram S. Advefeeae582002-09-18 11:55:13 +0000255# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000256ifndef KEEP_SYMBOLS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000257 Strip := $(PLATFORMSTRIPOPTS)
258 StripWarnMsg := "(without symbols)"
Vikram S. Advefeeae582002-09-18 11:55:13 +0000259endif
260
Reid Spencer3a561f52004-10-23 20:04:14 +0000261# Adjust linker flags for building an executable
Reid Spencer4d71b662004-10-22 21:01:56 +0000262ifdef TOOLNAME
Reid Spencer815cbcf2004-11-18 10:03:46 +0000263ifdef EXAMPLE_TOOL
264 LD.Flags += -rpath $(ExmplDir) -export-dynamic
265else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000266 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000267endif
Reid Spencer815cbcf2004-11-18 10:03:46 +0000268endif
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000269
Reid Spencer3a561f52004-10-23 20:04:14 +0000270#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000271# Options To Invoke Tools
Reid Spencer3a561f52004-10-23 20:04:14 +0000272#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000273
274CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
275
Reid Spencercc2d1e22004-10-30 09:19:36 +0000276LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
277CPP.Flags += -I$(BUILD_OBJ_DIR) \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000278 -I$(BUILD_SRC_DIR) \
279 -I$(BUILD_SRC_ROOT)/include \
280 -I$(BUILD_OBJ_ROOT)/include \
281 -I$(LLVM_OBJ_ROOT)/include \
282 -I$(LLVM_SRC_ROOT)/include \
283 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
Reid Spencer4d71b662004-10-22 21:01:56 +0000284
Reid Spencercc2d1e22004-10-30 09:19:36 +0000285Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
286LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
287BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
288Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
289LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
290BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
291Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
292 $(CompileCommonOpts) $(LD.Flags) $(Strip)
293Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencera69b1ea2004-10-28 09:15:28 +0000294 $(CompileCommonOpts)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000295LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
Reid Spencer3a561f52004-10-23 20:04:14 +0000296Burg = $(BURG) -I $(BUILD_SRC_DIR)
297TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000298Archive = $(AR) $(AR.Flags)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000299LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencer4d71b662004-10-22 21:01:56 +0000300ifdef RANLIB
Reid Spencer3a561f52004-10-23 20:04:14 +0000301Ranlib = $(RANLIB)
Reid Spencer4d71b662004-10-22 21:01:56 +0000302else
Reid Spencer3a561f52004-10-23 20:04:14 +0000303Ranlib = ranlib
John Criswell7a73b802003-06-30 21:59:07 +0000304endif
305
Chris Lattner00950542001-06-06 20:29:01 +0000306#----------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +0000307# Get the list of source files and compute object file
308# names from them.
Reid Spencer3a561f52004-10-23 20:04:14 +0000309#----------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +0000310ifdef FAKE_SOURCES
311 Sources :=
312 FakeSources := $(FAKE_SOURCES)
313 ifdef BUILT_SOURCES
314 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
315 endif
316 BaseNameSources := $(sort $(basename $(FakeSources)))
317 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
318 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
319 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000320else
Reid Spencer345235ca2004-12-04 22:34:09 +0000321 ifndef SOURCES
322 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
323 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
324 $(BUILD_SRC_DIR)/*.l))
325 else
326 Sources := $(SOURCES)
327 endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000328
Reid Spencer345235ca2004-12-04 22:34:09 +0000329 ifdef BUILT_SOURCES
330 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
331 endif
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000332
Reid Spencer345235ca2004-12-04 22:34:09 +0000333 BaseNameSources := $(sort $(basename $(Sources)))
334 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
335 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
336 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
337endif
Reid Spencer3a561f52004-10-23 20:04:14 +0000338
339###############################################################################
340# DIRECTORIES: Handle recursive descent of directory structure
341###############################################################################
John Criswell82f4a5a2003-07-31 20:58:51 +0000342
Chris Lattner00950542001-06-06 20:29:01 +0000343#---------------------------------------------------------
Reid Spencera69b1ea2004-10-28 09:15:28 +0000344# Provide rules to make install dirs. This must be early
345# in the file so they get built before dependencies
346#---------------------------------------------------------
347
348$(bindir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000349 $(Verb) $(MKDIR) $(bindir)
Chris Lattnere4cb90f2004-11-01 06:14:59 +0000350
Reid Spencera69b1ea2004-10-28 09:15:28 +0000351$(libdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000352 $(Verb) $(MKDIR) $(libdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000353
Reid Spencerab3690b2004-12-13 07:38:07 +0000354$(includedir):
355 $(Verb) $(MKDIR) $(includedir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000356
357$(sysconfdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000358 $(Verb) $(MKDIR) $(sysconfdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000359
Reid Spencercc2d1e22004-10-30 09:19:36 +0000360# To create other directories, as needed, and timestamp their creation
361%/.dir:
362 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfbbf3072004-11-29 05:00:33 +0000363 $(Verb) $(DATE) > $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000364
Reid Spencer815cbcf2004-11-18 10:03:46 +0000365.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
366.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000367
368#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000369# Handle the DIRS options for sequential construction
Chris Lattner00950542001-06-06 20:29:01 +0000370#---------------------------------------------------------
371
Reid Spencercc2d1e22004-10-30 09:19:36 +0000372SubDirs :=
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000373ifdef DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000374SubDirs += $(DIRS)
375$(RecursiveTargets)::
376 $(Verb) for dir in $(DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000377 if [ ! -f $$dir/Makefile ]; then \
378 $(MKDIR) $$dir; \
379 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
380 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000381 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
382 ($(MAKE) -C $$dir $@ ) || exit 1; \
383 fi ; \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000384 done
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000385endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000386
Reid Spencer3a561f52004-10-23 20:04:14 +0000387#---------------------------------------------------------
388# Handle the EXPERIMENTAL_DIRS options ensuring success
389# after each directory is built.
390#---------------------------------------------------------
391ifdef EXPERIMENTAL_DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000392$(RecursiveTargets)::
393 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer3a561f52004-10-23 20:04:14 +0000394 if [ ! -f $$dir/Makefile ]; then \
395 $(MKDIR) $$dir; \
396 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
397 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000398 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
399 ($(MAKE) -C $$dir $@ ) || exit 0; \
400 fi ; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000401 done
402endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000403
Reid Spencer3a561f52004-10-23 20:04:14 +0000404#---------------------------------------------------------
405# Handle the PARALLEL_DIRS options for parallel construction
406#---------------------------------------------------------
407ifdef PARALLEL_DIRS
408
Reid Spencercc2d1e22004-10-30 09:19:36 +0000409SubDirs += $(PARALLEL_DIRS)
410
Reid Spencer44cb1b32004-12-03 20:08:48 +0000411# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencercc2d1e22004-10-30 09:19:36 +0000412all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
413clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000414clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000415install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000416uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencer44cb1b32004-12-03 20:08:48 +0000417install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000418
Reid Spencer345235ca2004-12-04 22:34:09 +0000419ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer3a561f52004-10-23 20:04:14 +0000420
Reid Spencer345235ca2004-12-04 22:34:09 +0000421$(ParallelTargets) :
Reid Spencercc2d1e22004-10-30 09:19:36 +0000422 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencer4d71b662004-10-22 21:01:56 +0000423 $(MKDIR) $(@D); \
424 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswellb3866b62003-11-25 19:32:22 +0000425 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000426 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
427 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
428 fi
Chris Lattner00950542001-06-06 20:29:01 +0000429endif
430
Reid Spencer3a561f52004-10-23 20:04:14 +0000431#---------------------------------------------------------
432# Handle the OPTIONAL_DIRS options for directores that may
433# or may not exist.
434#---------------------------------------------------------
John Criswell2a6530f2003-06-27 16:58:44 +0000435ifdef OPTIONAL_DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000436
Reid Spencercc2d1e22004-10-30 09:19:36 +0000437SubDirs += $(OPTIONAL_DIRS)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000438
Reid Spencercc2d1e22004-10-30 09:19:36 +0000439$(RecursiveTargets)::
440 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000441 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
442 if [ ! -f $$dir/Makefile ]; then \
443 $(MKDIR) $$dir; \
444 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
445 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000446 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
447 ($(MAKE) -C$$dir $@ ) || exit 1; \
448 fi ; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000449 fi \
John Criswell2a6530f2003-06-27 16:58:44 +0000450 done
451endif
452
Reid Spencerfc945082004-08-20 09:20:05 +0000453#---------------------------------------------------------
454# Handle the CONFIG_FILES options
455#---------------------------------------------------------
456ifdef CONFIG_FILES
Reid Spencerfc945082004-08-20 09:20:05 +0000457
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000458install-local:: $(sysconfdir) $(CONFIG_FILES)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000459 $(Echo) Installing Configuration Files To $(sysconfdir)
460 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer1b426ab2004-11-23 05:59:53 +0000461 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
462 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
463 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
464 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
465 else \
466 $(ECHO) Error: cannot find config file $${file}. ; \
467 fi \
Reid Spencerfc945082004-08-20 09:20:05 +0000468 done
Reid Spencer3a561f52004-10-23 20:04:14 +0000469
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000470uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000471 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
472 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000473 $(RM) -f $(sysconfdir)/$${file} ; \
Reid Spencere5487ba2004-10-24 07:53:21 +0000474 done
475
Reid Spencerfc945082004-08-20 09:20:05 +0000476endif
477
Reid Spencer3a561f52004-10-23 20:04:14 +0000478###############################################################################
479# Library Build Rules: Four ways to build a library
480###############################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000481
Reid Spencer7980ea42004-12-05 05:17:22 +0000482#---------------------------------------------------------
483# Bytecode Module Targets:
484# If the user set MODULE_NAME then they want to build a
485# bytecode module from the sources. We compile all the
486# sources and link it together into a single bytecode
487# module.
488#---------------------------------------------------------
489
490ifdef MODULE_NAME
491
492Module := $(LibDir)/$(MODULE_NAME).bc
493LinkModule := $(LLVMGCC) -shared -nostdlib
494
495ifdef EXPORTED_SYMBOL_FILE
496LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
497endif
498
499$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
500 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
501 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
502
503all-local:: $(Module)
504
505clean-local::
506ifneq ($(strip $(Module)),)
507 -$(Verb) $(RM) -f $(Module)
508endif
509
Reid Spencerab3690b2004-12-13 07:38:07 +0000510ifdef BYTECODE_DESTINATION
511ModuleDestDir := $(BYTECODE_DESTINATION)
512else
513ModuleDestDir := $(BYTECODE_DESTINATION)
514endif
Reid Spencer7980ea42004-12-05 05:17:22 +0000515
Reid Spencerab3690b2004-12-13 07:38:07 +0000516DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
517
518install-module:: $(DestModule)
Reid Spencer7980ea42004-12-05 05:17:22 +0000519install-local:: $(DestModule)
520
Reid Spencerab3690b2004-12-13 07:38:07 +0000521$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencer7980ea42004-12-05 05:17:22 +0000522 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
523 $(Verb) $(INSTALL) $(Module) $@
524
525uninstall-local::
526 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
527 -$(Verb) $(RM) -f $(DestModule)
528
529endif
Brian Gaeke8abff792004-01-22 22:53:48 +0000530
Reid Spencer3a561f52004-10-23 20:04:14 +0000531# if we're building a library ...
Chris Lattner00950542001-06-06 20:29:01 +0000532ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000533
Chris Lattner2a548c52002-09-16 22:36:42 +0000534# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000535LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000536LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
537LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
538LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer9a2f1372004-12-02 09:28:21 +0000539LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000540
Reid Spencer3a561f52004-10-23 20:04:14 +0000541#---------------------------------------------------------
542# Shared Library Targets:
543# If the user asked for a shared library to be built
544# with the SHARED_LIBRARY variable, then we provide
545# targets for building them.
546#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000547ifdef SHARED_LIBRARY
548
Reid Spencercc2d1e22004-10-30 09:19:36 +0000549all-local:: $(LibName.LA)
Reid Spencer4d71b662004-10-22 21:01:56 +0000550
Reid Spencercc2d1e22004-10-30 09:19:36 +0000551$(LibName.LA): $(BUILT_SOURCES) $(ObjectsLO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000552 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000553 $(Verb) $(Link) -o $@ $(ObjectsLO)
554 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencer3a561f52004-10-23 20:04:14 +0000555
556clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000557ifneq ($(strip $(LibName.LA)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000558 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000559endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000560
Reid Spencere5487ba2004-10-24 07:53:21 +0000561DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencer4d71b662004-10-22 21:01:56 +0000562
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000563install-local:: $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000564
Reid Spencercc2d1e22004-10-30 09:19:36 +0000565$(DestSharedLib): $(libdir) $(LibName.LA)
Reid Spencer9af3b292004-11-01 07:50:27 +0000566 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000567 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
568 $(Verb) $(LIBTOOL) --finish $(libdir)
Reid Spencere5487ba2004-10-24 07:53:21 +0000569
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000570uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000571 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencer12d79512004-11-12 02:27:36 +0000572 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
Reid Spencere5487ba2004-10-24 07:53:21 +0000573
Reid Spencer4d71b662004-10-22 21:01:56 +0000574endif
575
Reid Spencer3a561f52004-10-23 20:04:14 +0000576#---------------------------------------------------------
577# Bytecode Library Targets:
578# If the user asked for a bytecode library to be built
579# with the BYTECODE_LIBRARY variable, then we provide
580# targets for building them.
581#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000582ifdef BYTECODE_LIBRARY
583
Reid Spencer776b8052004-12-03 06:04:35 +0000584# make the C and C++ compilers strip debug info out of bytecode libraries.
585BCCompile.C += -Wa,-strip-debug
586BCCompile.CXX += -Wa,-strip-debug
587
Reid Spencer9a2f1372004-12-02 09:28:21 +0000588all-local:: $(LibName.BCA)
589
590ifdef EXPORTED_SYMBOL_FILE
591BCLinkLib = $(LLVMGCC) -shared -nostdlib -Xlinker \
592 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
593
594$(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
595 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
596 "(internalize)"
Chris Lattnerb0ea8642004-12-02 21:23:43 +0000597 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencerefd6bb32004-12-13 03:59:35 +0000598 $(Verb) $(RM) -f $@
Reid Spencer9a2f1372004-12-02 09:28:21 +0000599 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencer4d71b662004-10-22 21:01:56 +0000600else
Reid Spencer345235ca2004-12-04 22:34:09 +0000601$(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir
Reid Spencer9a2f1372004-12-02 09:28:21 +0000602 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencerefd6bb32004-12-13 03:59:35 +0000603 $(Verb) $(RM) -f $@
Reid Spencer9a2f1372004-12-02 09:28:21 +0000604 $(Verb) $(LArchive) $@ $(ObjectsBC)
605
Reid Spencer4d71b662004-10-22 21:01:56 +0000606endif
607
Reid Spencer3a561f52004-10-23 20:04:14 +0000608clean-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000609ifneq ($(strip $(LibName.BCA)),)
610 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000611endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000612
Reid Spencer8f094f32004-12-13 07:28:21 +0000613ifdef BYTECODE_DESTINATION
614BytecodeDestDir := $(BYTECODE_DESTINATION)
615else
616BytecodeDestDir := $(libdir)
617endif
618
619DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
Reid Spencer9a2f1372004-12-02 09:28:21 +0000620
Reid Spencer44cb1b32004-12-03 20:08:48 +0000621install-bytecode-local:: $(DestBytecodeLib)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000622
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000623install-local:: $(DestBytecodeLib)
Chris Lattner481cc7c2003-08-15 02:18:35 +0000624
Reid Spencer8f094f32004-12-13 07:28:21 +0000625$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000626 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
627 $(Verb) $(INSTALL) $(LibName.BCA) $@
Reid Spencere5487ba2004-10-24 07:53:21 +0000628
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000629uninstall-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000630 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000631 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000632
633endif
Vikram S. Adve60f56062002-08-02 18:34:12 +0000634
Reid Spencercc2d1e22004-10-30 09:19:36 +0000635#---------------------------------------------------------
636# ReLinked Library Targets:
637# If the user didn't explicitly forbid building a
638# relinked then we provide targets for building them.
639#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000640ifndef DONT_BUILD_RELINKED
Reid Spencer4d71b662004-10-22 21:01:56 +0000641
Reid Spencercc2d1e22004-10-30 09:19:36 +0000642all-local:: $(LibName.O)
643
644$(LibName.O): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000645 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000646 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencer4d71b662004-10-22 21:01:56 +0000647
Reid Spencer3a561f52004-10-23 20:04:14 +0000648clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000649ifneq ($(strip $(LibName.O)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000650 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencere5487ba2004-10-24 07:53:21 +0000651endif
652
653DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
654
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000655install-local:: $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000656
Reid Spencercc2d1e22004-10-30 09:19:36 +0000657$(DestRelinkedLib): $(libdir) $(LibName.O)
Reid Spencer9af3b292004-11-01 07:50:27 +0000658 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000659 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000660
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000661uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000662 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000663 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000664
Chris Lattnere62dbe92002-07-23 17:56:16 +0000665endif
Chris Lattner760da062003-03-14 20:25:22 +0000666
Reid Spencercc2d1e22004-10-30 09:19:36 +0000667#---------------------------------------------------------
668# Archive Library Targets:
669# If the user wanted a regular archive library built,
670# then we provide targets for building them.
671#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000672ifdef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000673
Reid Spencercc2d1e22004-10-30 09:19:36 +0000674all-local:: $(LibName.A)
675
676$(LibName.A): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000677 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000678 -$(Verb) $(RM) -f $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000679 $(Verb) $(Archive) $@ $(ObjectsO)
680 $(Verb) $(Ranlib) $@
Vikram S. Adve41e78912002-09-20 14:03:13 +0000681
Reid Spencer3a561f52004-10-23 20:04:14 +0000682clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000683ifneq ($(strip $(LibName.A)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000684 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner00950542001-06-06 20:29:01 +0000685endif
686
Reid Spencere5487ba2004-10-24 07:53:21 +0000687DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
688
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000689install-local:: $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000690
Reid Spencercc2d1e22004-10-30 09:19:36 +0000691$(DestArchiveLib): $(libdir) $(LibName.A)
Reid Spencer9af3b292004-11-01 07:50:27 +0000692 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000693 $(Verb) $(MKDIR) $(libdir)
694 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000695
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000696uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000697 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000698 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000699
700endif
701
702# endif LIBRARYNAME
Reid Spencer4d71b662004-10-22 21:01:56 +0000703endif
704
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000705###############################################################################
706# Tool Build Rules: Build executable tool based on TOOLNAME option
707###############################################################################
708
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000709ifdef TOOLNAME
710
Reid Spencercc2d1e22004-10-30 09:19:36 +0000711#---------------------------------------------------------
Reid Spencer7c787c92004-11-29 07:17:07 +0000712# Handle the special "JIT" value for LLVM_LIBS which is a
713# shorthand for a bunch of libraries that get the correct
714# JIT support for a tool that runs JIT.
715#---------------------------------------------------------
716ifeq ($(LLVMLIBS),JIT)
717
718# Make sure we can get our own symbols in the tool
719Link += -dlopen self
720
721# Generic JIT libraries
722JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
723
724# You can enable the X86 JIT on a non-X86 host by setting the flag
725# ENABLE_X86_JIT on the make command line. If not, it will still be
726# enabled automagically on an X86 host.
727ifeq ($(ARCH), x86)
728 ENABLE_X86_JIT = 1
729endif
730
731# What the X86 JIT requires
732ifdef ENABLE_X86_JIT
733 JIT_LIBS += LLVMX86 LLVMSelectionDAG
734endif
735
736# You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
737# ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
738# enabled automagically on an SparcV9 host.
739ifeq ($(ARCH), Sparc)
740 ENABLE_SPARCV9_JIT = 1
741endif
742
743# What the Sparc JIT requires
744ifdef ENABLE_SPARCV9_JIT
745 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
746 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
747 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
748 LLVMDataStructure.a LLVMSparcV9RegAlloc
749endif
750
751# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
752# ENABLE_PPC_JIT on the make command line. If not, it will still be
753# enabled automagically on an PowerPC host.
754ifeq ($(ARCH), PowerPC)
755 ENABLE_PPC_JIT = 1
756endif
757
758# What the PowerPC JIT requires
759ifdef ENABLE_PPC_JIT
760 JIT_LIBS += LLVMPowerPC
761endif
762
763LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
764 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
765 LLVMSystem.a $(PLATFORMLIBDL)
766endif
767
768#---------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000769# Set up variables for building a tool.
770#---------------------------------------------------------
Reid Spencer815cbcf2004-11-18 10:03:46 +0000771ifdef EXAMPLE_TOOL
772ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
773else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000774ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000775endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000776ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
777ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
778LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
779LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
780ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
781LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
782ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
783LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000784
Reid Spencercc2d1e22004-10-30 09:19:36 +0000785#---------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000786# Tell make that we need to rebuild subdirectories before
787# we can link the tool. This affects things like LLI which
788# has library subdirectories.
789#---------------------------------------------------------
790$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000791
Reid Spencercc2d1e22004-10-30 09:19:36 +0000792#---------------------------------------------------------
793# Provide targets for building the tools
794#---------------------------------------------------------
795all-local:: $(ToolBuildPath)
John Criswell2a6530f2003-06-27 16:58:44 +0000796
Reid Spencer3a561f52004-10-23 20:04:14 +0000797clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000798ifneq ($(strip $(ToolBuildPath)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000799 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencere5487ba2004-10-24 07:53:21 +0000800endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000801
Reid Spencer815cbcf2004-11-18 10:03:46 +0000802ifdef EXAMPLE_TOOL
803$(ToolBuildPath): $(ExmplDir)/.dir
804else
805$(ToolBuildPath): $(ToolDir)/.dir
806endif
807
808$(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencer9af3b292004-11-01 07:50:27 +0000809 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000810 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
811 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
Reid Spencer9af3b292004-11-01 07:50:27 +0000812 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencere5487ba2004-10-24 07:53:21 +0000813
814DestTool = $(bindir)/$(TOOLNAME)
815
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000816install-local:: $(DestTool)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000817
Reid Spencercc2d1e22004-10-30 09:19:36 +0000818$(DestTool): $(bindir) $(ToolBuildPath)
Reid Spencer9af3b292004-11-01 07:50:27 +0000819 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000820 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000821
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000822uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000823 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000824 -$(Verb) $(RM) -f $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000825
Reid Spencer4d71b662004-10-22 21:01:56 +0000826endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000827
Reid Spencercc2d1e22004-10-30 09:19:36 +0000828###############################################################################
829# Object Build Rules: Build object files based on sources
830###############################################################################
831
832# Provide rule sets for when dependency generation is enabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000833ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve41e78912002-09-20 14:03:13 +0000834
Reid Spencercc2d1e22004-10-30 09:19:36 +0000835#---------------------------------------------------------
836# Create .lo files in the ObjDir directory from the .cpp and .c files...
837#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000838ifdef SHARED_LIBRARY
839
Reid Spencercc2d1e22004-10-30 09:19:36 +0000840$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000841 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000842 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
843 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
844 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000845
Reid Spencercc2d1e22004-10-30 09:19:36 +0000846$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000847 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000848 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
849 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
850 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000851
Reid Spencercc2d1e22004-10-30 09:19:36 +0000852#---------------------------------------------------------
853# Create .o files in the ObjDir directory from the .cpp and .c files...
854#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000855else
Reid Spencer4d71b662004-10-22 21:01:56 +0000856
Reid Spencercc2d1e22004-10-30 09:19:36 +0000857$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000858 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000859 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
860 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
861 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000862
Reid Spencercc2d1e22004-10-30 09:19:36 +0000863$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000864 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000865 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
866 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
867 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000868
869endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000870
Reid Spencercc2d1e22004-10-30 09:19:36 +0000871#---------------------------------------------------------
872# Create .bc files in the ObjDir directory from .cpp and .c files...
873#---------------------------------------------------------
Chris Lattner478b3b42004-11-29 19:47:58 +0000874$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000875 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000876 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
877 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
878 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000879
Chris Lattner478b3b42004-11-29 19:47:58 +0000880$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000881 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000882 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
883 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
884 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000885
Reid Spencercc2d1e22004-10-30 09:19:36 +0000886# Provide alternate rule sets if dependencies are disabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000887else
888
Reid Spencer3a561f52004-10-23 20:04:14 +0000889ifdef SHARED_LIBRARY
890
Reid Spencercc2d1e22004-10-30 09:19:36 +0000891$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000892 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000893 $(LTCompile.CXX) $< -o $@
894
Reid Spencercc2d1e22004-10-30 09:19:36 +0000895$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000896 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000897 $(LTCompile.C) $< -o $@
898
899else
Reid Spencer4d71b662004-10-22 21:01:56 +0000900
Reid Spencercc2d1e22004-10-30 09:19:36 +0000901$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000902 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +0000903 $(Compile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000904
Reid Spencercc2d1e22004-10-30 09:19:36 +0000905$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000906 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +0000907 $(Compile.C) $< -o $@
908endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000909
Chris Lattner478b3b42004-11-29 19:47:58 +0000910$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000911 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencer8676b7e2004-10-31 18:52:15 +0000912 $(BCCompile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000913
Chris Lattner478b3b42004-11-29 19:47:58 +0000914$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000915 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencer8676b7e2004-10-31 18:52:15 +0000916 $(BCCompile.C) $< -o $@
Brian Gaeke44909cf2003-12-10 00:26:28 +0000917
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000918endif
919
Reid Spencercc2d1e22004-10-30 09:19:36 +0000920#---------------------------------------------------------
921# Provide rule to build .bc files from .ll sources,
922# regardless of dependencies
923#---------------------------------------------------------
924$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000925 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000926 $(Verb) $(LLVMAS) $< -f -o $@
927
928###############################################################################
929# TABLEGEN: Provide rules for running tblgen to produce *.inc files
930###############################################################################
Chris Lattner481cc7c2003-08-15 02:18:35 +0000931
Reid Spencer4d71b662004-10-22 21:01:56 +0000932ifdef TARGET
933
Reid Spencercc2d1e22004-10-30 09:19:36 +0000934TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
935INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Reid Spencer4d71b662004-10-22 21:01:56 +0000936
Reid Spencercc2d1e22004-10-30 09:19:36 +0000937$(INCFiles) : $(TBLGEN) $(TDFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +0000938
Reid Spencer16544482004-10-27 04:34:35 +0000939%GenRegisterNames.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000940 $(Echo) "Building $(<F) register names with tblgen"
941 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000942
Reid Spencer16544482004-10-27 04:34:35 +0000943%GenRegisterInfo.h.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000944 $(Echo) "Building $(<F) register information header with tblgen"
945 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000946
947%GenRegisterInfo.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000948 $(Echo) "Building $(<F) register info implementation with tblgen"
949 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000950
951%GenInstrNames.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000952 $(Echo) "Building $(<F) instruction names with tblgen"
953 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000954
955%GenInstrInfo.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000956 $(Echo) "Building $(<F) instruction information with tblgen"
957 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000958
959%GenAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000960 $(Echo) "Building $(<F) assembly writer with tblgen"
961 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000962
963%GenATTAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000964 $(Echo) "Building $(<F) AT&T assembly writer with tblgen"
965 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000966
967%GenIntelAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000968 $(Echo) "Building $(<F) Intel assembly writer with tblgen"
969 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000970
971%GenInstrSelector.inc: %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000972 $(Echo) "Building $(<F) instruction selector with tblgen"
973 $(Verb) $(TableGen) -gen-instr-selector -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000974
975%GenCodeEmitter.inc:: %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000976 $(Echo) "Building $(<F) code emitter with tblgen"
977 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000978
Reid Spencer3a561f52004-10-23 20:04:14 +0000979clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000980 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +0000981
982endif
Chris Lattner481cc7c2003-08-15 02:18:35 +0000983
Reid Spencercc2d1e22004-10-30 09:19:36 +0000984###############################################################################
985# LEX AND YACC: Provide rules for generating sources with lex and yacc
986###############################################################################
Chris Lattnere8996782003-01-16 22:44:19 +0000987
Reid Spencercc2d1e22004-10-30 09:19:36 +0000988#---------------------------------------------------------
989# Provide rules for generating a .cpp source file from
990# (f)lex input sources.
991#---------------------------------------------------------
992
Reid Spencer3d659492004-11-02 16:36:03 +0000993LexFiles := $(filter %.l,$(Sources))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000994
Reid Spencer3d659492004-11-02 16:36:03 +0000995ifneq ($(LexFiles),)
996
997LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000998
999.PRECIOUS: $(LexOutput)
1000
1001# Note the extra sed filtering here, used to cut down on the warnings emited
1002# by GCC. The last line is a gross hack to work around flex aparently not
1003# being able to resize the buffer on a large token input. Currently, for
1004# uninitialized string buffers in LLVM we can generate very long tokens, so
1005# this is a hack around it.
Chris Lattnerb7dc2b92003-08-15 20:00:47 +00001006# FIXME. (f.e. char Buffer[10000] )
Chris Lattner00950542001-06-06 20:29:01 +00001007%.cpp: %.l
Reid Spencerc2ef8cd2004-12-10 19:44:16 +00001008 $(Echo) Flexing $*.l
Reid Spencercc2d1e22004-10-30 09:19:36 +00001009 $(Verb) $(FLEX) -t $< | \
Reid Spencer4d71b662004-10-22 21:01:56 +00001010 $(SED) 's/void yyunput/inline void yyunput/' | \
1011 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1012 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencer80f0ef72004-10-28 00:41:43 +00001013 > $@
Chris Lattner00950542001-06-06 20:29:01 +00001014
Reid Spencer9af3b292004-11-01 07:50:27 +00001015clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001016 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencer3d659492004-11-02 16:36:03 +00001017 $(Verb) $(RM) -f $(LexOutput)
Reid Spencer9af3b292004-11-01 07:50:27 +00001018
Reid Spencercc2d1e22004-10-30 09:19:36 +00001019endif
1020
1021#---------------------------------------------------------
1022# Provide rules for generating a .cpp and .h source files
1023# from yacc (bison) input sources.
1024#---------------------------------------------------------
1025
Reid Spencer3d659492004-11-02 16:36:03 +00001026YaccFiles := $(filter %.y,$(Sources))
1027ifneq ($(YaccFiles),)
1028YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001029
1030.PRECIOUS: $(YaccOutput)
1031
1032# Cancel built-in rules for yacc
1033%.c: %.y
1034%.cpp: %.y
1035%.h: %.y
1036
Chris Lattner00950542001-06-06 20:29:01 +00001037# Rule for building the bison parsers...
Chris Lattner00950542001-06-06 20:29:01 +00001038%.cpp %.h : %.y
Reid Spencercc2d1e22004-10-30 09:19:36 +00001039 $(Echo) "Bisoning $*.y"
1040 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1041 $(Verb) $(MV) -f $*.tab.c $*.cpp
1042 $(Verb) $(MV) -f $*.tab.h $*.h
Chris Lattner00950542001-06-06 20:29:01 +00001043
Reid Spencer9af3b292004-11-01 07:50:27 +00001044clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001045 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencer3d659492004-11-02 16:36:03 +00001046 $(Verb) $(RM) -f $(YaccOutput)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001047endif
Chris Lattner00950542001-06-06 20:29:01 +00001048
Reid Spencercc2d1e22004-10-30 09:19:36 +00001049###############################################################################
1050# OTHER RULES: Other rules needed
1051###############################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +00001052
Chris Lattner30440c62003-01-16 21:06:18 +00001053# To create postscript files from dot files...
John Criswelle0f9ac62003-10-02 19:02:02 +00001054ifneq ($(DOT),false)
Chris Lattner30440c62003-01-16 21:06:18 +00001055%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +00001056 $(DOT) -Tps < $< > $@
John Criswell7a73b802003-06-30 21:59:07 +00001057else
1058%.ps: %.dot
Reid Spencercc2d1e22004-10-30 09:19:36 +00001059 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell7a73b802003-06-30 21:59:07 +00001060endif
Chris Lattner30440c62003-01-16 21:06:18 +00001061
John Criswell7f336952003-09-06 14:44:17 +00001062# This rules ensures that header files that are removed still have a rule for
1063# which they can be "generated." This allows make to ignore them and
1064# reproduce the dependency lists.
John Criswell4b6e5d12003-09-18 18:37:08 +00001065%.h:: ;
John Criswell7f336952003-09-06 14:44:17 +00001066
Reid Spencercc2d1e22004-10-30 09:19:36 +00001067# Define clean-local to clean the current directory. Note that this uses a
1068# very conservative approach ensuring that empty variables do not cause
1069# errors or disastrous removal.
Reid Spencer3a561f52004-10-23 20:04:14 +00001070clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001071ifneq ($(strip $(ObjDir)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001072 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencere5487ba2004-10-24 07:53:21 +00001073endif
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001074 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001075ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001076 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001077endif
John Criswell7a73b802003-06-30 21:59:07 +00001078
Reid Spencer3d659492004-11-02 16:36:03 +00001079clean-all-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001080 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer3d659492004-11-02 16:36:03 +00001081
Reid Spencercc2d1e22004-10-30 09:19:36 +00001082# Build tags database for Emacs/Xemacs:
Reid Spencer12d79512004-11-12 02:27:36 +00001083tags:: TAGS CTAGS
1084
Reid Spencercc2d1e22004-10-30 09:19:36 +00001085TAGS:
Reid Spencer12d79512004-11-12 02:27:36 +00001086 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1087 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1088 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1089 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1090 -name '*.cpp' -o -name '*.h' | \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001091 $(ETAGS) $(ETAGSFLAGS) -
1092
Reid Spencer12d79512004-11-12 02:27:36 +00001093CTAGS:
1094 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1095 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1096 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1097 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1098 \( -name '*.cpp' -o -name '*.h' \) -print | \
1099 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1100
1101
Reid Spencer3a561f52004-10-23 20:04:14 +00001102###############################################################################
1103# DEPENDENCIES: Include the dependency files if we should
1104###############################################################################
Chris Lattner33ad24a2003-08-22 14:10:16 +00001105ifndef DISABLE_AUTO_DEPENDENCIES
1106
Reid Spencer3a561f52004-10-23 20:04:14 +00001107# If its not one of the cleaning targets
Reid Spencercc2d1e22004-10-30 09:19:36 +00001108ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencer4d71b662004-10-22 21:01:56 +00001109
Reid Spencer3a561f52004-10-23 20:04:14 +00001110# Get the list of dependency files
Reid Spencercc2d1e22004-10-30 09:19:36 +00001111DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Reid Spencer9af3b292004-11-01 07:50:27 +00001112DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
Misha Brukman4f7a8cf2003-11-09 21:36:19 +00001113
Reid Spencer3a561f52004-10-23 20:04:14 +00001114-include /dev/null $(DependFiles)
1115
John Criswelld741bcf2003-08-12 18:51:51 +00001116endif
Chris Lattner1ddb6b62003-08-18 17:27:40 +00001117
Reid Spencercc2d1e22004-10-30 09:19:36 +00001118endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001119
Reid Spencer151f8ba2004-10-25 08:27:37 +00001120###############################################################################
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001121# CHECK: Running the test suite
1122###############################################################################
1123
1124check::
1125 $(Verb) if test -d "$(BUILD_OBJ_ROOT)/test" ; then \
1126 if test -f "$(BUILD_OBJ_ROOT)/test/Makefile" ; then \
1127 $(EchoCmd) Running test suite ; \
1128 $(MAKE) -C $(BUILD_OBJ_ROOT)/test check-local \
1129 TESTSUITE=$(TESTSUITE) ; \
1130 else \
1131 $(EchoCmd) No Makefile in test directory ; \
1132 fi ; \
1133 else \
1134 $(EchoCmd) No test directory ; \
1135 fi
1136
1137###############################################################################
Reid Spencercc2d1e22004-10-30 09:19:36 +00001138# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer151f8ba2004-10-25 08:27:37 +00001139###############################################################################
1140
Reid Spencere45ebfa2004-10-26 07:09:33 +00001141#------------------------------------------------------------------------
1142# Define distribution related variables
1143#------------------------------------------------------------------------
Reid Spencer151f8ba2004-10-25 08:27:37 +00001144DistName := $(LLVM_TARBALL_NAME)
1145DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001146TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer151f8ba2004-10-25 08:27:37 +00001147DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1148DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1149DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1150DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1151 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001152 Makefile.config.in configure autoconf
1153DistOther := $(notdir $(wildcard \
1154 $(BUILD_SRC_DIR)/*.h \
1155 $(BUILD_SRC_DIR)/*.td \
1156 $(BUILD_SRC_DIR)/*.def \
1157 $(BUILD_SRC_DIR)/*.ll \
1158 $(BUILD_SRC_DIR)/*.in))
Reid Spencercc2d1e22004-10-30 09:19:36 +00001159DistSubDirs := $(SubDirs)
Reid Spencerfbbf3072004-11-29 05:00:33 +00001160DistSources = $(Sources) $(EXTRA_DIST)
1161DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer151f8ba2004-10-25 08:27:37 +00001162
Reid Spencere45ebfa2004-10-26 07:09:33 +00001163#------------------------------------------------------------------------
1164# We MUST build distribution with OBJ_DIR != SRC_DIR
1165#------------------------------------------------------------------------
1166ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1167dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001168 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencere45ebfa2004-10-26 07:09:33 +00001169
Reid Spencere45ebfa2004-10-26 07:09:33 +00001170else
1171
Reid Spencere45ebfa2004-10-26 07:09:33 +00001172#------------------------------------------------------------------------
1173# Prevent catastrophic remove
1174#------------------------------------------------------------------------
1175ifeq ($(LLVM_TARBALL_NAME),)
1176$(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1177endif
1178
1179#------------------------------------------------------------------------
1180# Prevent attempt to run dist targets from anywhere but the top level
1181#------------------------------------------------------------------------
1182ifneq ($(LEVEL),.)
1183
1184dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001185 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001186
1187else
1188
1189#------------------------------------------------------------------------
1190# Provide the top level targets
1191#------------------------------------------------------------------------
1192
Reid Spencercc2d1e22004-10-30 09:19:36 +00001193dist-gzip:: $(DistTarGZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001194
Reid Spencer345235ca2004-12-04 22:34:09 +00001195$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001196 $(Echo) Packing gzipped distribution tar file.
Reid Spencerfbbf3072004-11-29 05:00:33 +00001197 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1198 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencere45ebfa2004-10-26 07:09:33 +00001199
Reid Spencercc2d1e22004-10-30 09:19:36 +00001200dist-bzip2:: $(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001201
Reid Spencer345235ca2004-12-04 22:34:09 +00001202$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001203 $(Echo) Packing bzipped distribution tar file.
Reid Spencerfbbf3072004-11-29 05:00:33 +00001204 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1205 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001206
Reid Spencercc2d1e22004-10-30 09:19:36 +00001207dist-zip:: $(DistZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001208
Reid Spencer345235ca2004-12-04 22:34:09 +00001209$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001210 $(Echo) Packing zipped distribution file.
1211 $(Verb) rm -f $(DistZip)
1212 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001213
1214dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001215 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001216
1217DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1218
Reid Spencer345235ca2004-12-04 22:34:09 +00001219dist-check:: $(DistTarGZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001220 $(Echo) Checking distribution tar file.
1221 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001222 $(RM) -rf $(DistCheckDir) ; \
1223 fi
Reid Spencercc2d1e22004-10-30 09:19:36 +00001224 $(Verb) $(MKDIR) $(DistCheckDir)
1225 $(Verb) cd $(DistCheckDir) && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001226 $(MKDIR) $(DistCheckDir)/build && \
1227 $(MKDIR) $(DistCheckDir)/install && \
1228 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1229 cd build && \
1230 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1231 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
Reid Spencer345235ca2004-12-04 22:34:09 +00001232 $(MAKE) all && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001233 $(MAKE) check && \
1234 $(MAKE) install && \
1235 $(MAKE) uninstall && \
1236 $(MAKE) dist && \
1237 $(MAKE) clean && \
1238 $(MAKE) dist-clean && \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001239 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001240
1241dist-clean::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001242 $(Echo) Cleaning distribution files
Reid Spencer345235ca2004-12-04 22:34:09 +00001243 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1244 $(DistCheckDir)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001245
1246endif
1247
1248#------------------------------------------------------------------------
1249# Provide the recursive distdir target for building the distribution directory
1250#------------------------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +00001251distdir: $(DistDir)/.makedistdir
1252$(DistDir)/.makedistdir: $(DistSources)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001253 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001254 if test -d "$(DistDir)" ; then \
1255 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1256 exit 1 ; \
1257 fi ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001258 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001259 $(RM) -rf $(DistDir); \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001260 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001261 $(MAKE) all ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001262 fi
Reid Spencerfbbf3072004-11-29 05:00:33 +00001263 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001264 $(Verb) $(MKDIR) $(DistDir)
1265 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001266 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1267 for file in $(DistFiles) ; do \
1268 case "$$file" in \
Reid Spencer345235ca2004-12-04 22:34:09 +00001269 $(BUILD_SRC_DIR)/*) \
1270 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1271 ;; \
1272 $(BUILD_SRC_ROOT)/*) \
1273 file=`echo "$$file" | \
1274 sed "s#^$$srcrootstrip/##"` \
1275 ;; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001276 esac; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001277 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1278 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1279 from_dir="$(BUILD_SRC_DIR)" ; \
1280 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001281 from_dir=. ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001282 fi ; \
1283 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001284 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1285 to_dir="$(DistDir)/$$dir"; \
1286 $(MKDIR) "$$to_dir" ; \
1287 else \
1288 to_dir="$(DistDir)"; \
1289 fi; \
1290 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1291 if test -n "$$mid_dir" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001292 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001293 fi ; \
1294 if test -d "$$from_dir/$$file"; then \
1295 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1296 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1297 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1298 fi; \
1299 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1300 elif test -f "$$from_dir/$$file" ; then \
1301 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1302 elif test -L "$$from_dir/$$file" ; then \
1303 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1304 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer345235ca2004-12-04 22:34:09 +00001305 $(EchoCmd) "===== WARNING: Distribution Source " \
1306 "$$from_dir/$$file Not Found!" ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001307 elif test "$(Verb)" != '@' ; then \
1308 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001309 fi; \
1310 done
Reid Spencercc2d1e22004-10-30 09:19:36 +00001311 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001312 if test "$$subdir" \!= "." ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001313 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001314 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001315 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1316 exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001317 fi; \
1318 done
Reid Spencer345235ca2004-12-04 22:34:09 +00001319 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1320 $(EchoCmd) Eliminating CVS directories from distribution ; \
1321 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1322 $(MAKE) dist-hook ; \
1323 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1324 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1325 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1326 -o ! -type d ! -perm -444 -exec \
1327 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1328 || chmod -R a+r $(DistDir) ; \
1329 fi
Reid Spencer151f8ba2004-10-25 08:27:37 +00001330
Reid Spencercc2d1e22004-10-30 09:19:36 +00001331# This is invoked by distdir target, define it as a no-op to avoid errors if not
1332# defined by user.
Reid Spencer151f8ba2004-10-25 08:27:37 +00001333dist-hook::
1334
Reid Spencere53e3972004-10-22 23:06:30 +00001335endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001336
1337###############################################################################
Reid Spencere5487ba2004-10-24 07:53:21 +00001338# TOP LEVEL - targets only to apply at the top level directory
1339###############################################################################
1340
1341ifeq ($(LEVEL),.)
1342
1343#------------------------------------------------------------------------
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001344# Install support for the project's include files:
Reid Spencere5487ba2004-10-24 07:53:21 +00001345#------------------------------------------------------------------------
1346install-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001347 $(Echo) Installing include files
1348 $(Verb) $(MKDIR) $(includedir)
1349 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencere5487ba2004-10-24 07:53:21 +00001350 cd $(BUILD_SRC_ROOT)/include && \
1351 find . -path '*/Internal' -prune -o '(' -type f \
1352 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1353 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1354 fi
1355
1356uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001357 $(Echo) Uninstalling include files
1358 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencere5487ba2004-10-24 07:53:21 +00001359 cd $(BUILD_SRC_ROOT)/include && \
1360 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1361 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1362 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1363 fi
1364
Reid Spencere5487ba2004-10-24 07:53:21 +00001365endif
1366
Reid Spencer4d71b662004-10-22 21:01:56 +00001367#------------------------------------------------------------------------
1368# Print out the directories used for building
Reid Spencercc2d1e22004-10-30 09:19:36 +00001369#------------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001370printvars::
Reid Spencer9af3b292004-11-01 07:50:27 +00001371 $(Echo) "BuildMode : " '$(BuildMode)'
Reid Spencercc2d1e22004-10-30 09:19:36 +00001372 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1373 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1374 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1375 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1376 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1377 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1378 $(Echo) "libdir : " '$(libdir)'
1379 $(Echo) "bindir : " '$(bindir)'
1380 $(Echo) "sysconfdir : " '$(sysconfdir)'
Reid Spencercc2d1e22004-10-30 09:19:36 +00001381 $(Echo) "UserTargets : " '$(UserTargets)'
1382 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1383 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1384 $(Echo) "ObjDir : " '$(ObjDir)'
1385 $(Echo) "LibDir : " '$(LibDir)'
1386 $(Echo) "ToolDir : " '$(ToolDir)'
Reid Spencer815cbcf2004-11-18 10:03:46 +00001387 $(Echo) "ExmplDir : " '$(ExmplDir)'
Reid Spencer7980ea42004-12-05 05:17:22 +00001388 $(Echo) "Sources : " '$(Sources)'
Reid Spencercc2d1e22004-10-30 09:19:36 +00001389 $(Echo) "TDFiles : " '$(TDFiles)'
1390 $(Echo) "INCFiles : " '$(INCFiles)'
1391 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1392 $(Echo) "Compile.C : " '$(Compile.C)'
1393 $(Echo) "Archive : " '$(Archive)'
Reid Spencer3d659492004-11-02 16:36:03 +00001394 $(Echo) "YaccFiles : " '$(YaccFiles)'
1395 $(Echo) "LexFiles : " '$(LexFiles)'
Reid Spencer7980ea42004-12-05 05:17:22 +00001396 $(Echo) "Module : " '$(Module)'