blob: b5f385386603914ba27c3afa2aec0c1e2f006e83 [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#--------------------------------------------------------------------
Reid Spencer3d659492004-11-02 16:36:03 +000022RecursiveTargets := all clean clean-all check install uninstall
23LocalTargets := all-local clean-local clean-all-local check-local \
24 install-local printvars uninstall-local
Reid Spencercc2d1e22004-10-30 09:19:36 +000025TopLevelTargets := dist dist-check dist-clean tags dist-gzip dist-bzip2 \
26 dist-zip
27UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
28InternalTargets := preconditions distdir dist-hook
Reid Spencer3a561f52004-10-23 20:04:14 +000029
Reid Spencercc2d1e22004-10-30 09:19:36 +000030################################################################################
Reid Spencer9411c642004-10-26 22:26:33 +000031# INITIALIZATION: Basic things the makefile needs
Reid Spencercc2d1e22004-10-30 09:19:36 +000032################################################################################
33
34#--------------------------------------------------------------------
35# Set the VPATH so that we can find source files.
36#--------------------------------------------------------------------
37VPATH=$(BUILD_SRC_DIR)
Reid Spencer9411c642004-10-26 22:26:33 +000038
39#--------------------------------------------------------------------
40# Reset the list of suffixes we know how to build
41#--------------------------------------------------------------------
42.SUFFIXES:
Reid Spencercc2d1e22004-10-30 09:19:36 +000043.SUFFIXES: .c .cpp .h .hpp .y .l .lo .o .a .bc .td .ps .dot
44.SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
Reid Spencer9411c642004-10-26 22:26:33 +000045
Reid Spencer3a561f52004-10-23 20:04:14 +000046#--------------------------------------------------------------------
47# Mark all of these targets as phony to avoid implicit rule search
48#--------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000049.PHONY: $(UserTargets) $(InternalTargets)
Reid Spencer3a561f52004-10-23 20:04:14 +000050
51#--------------------------------------------------------------------
Reid Spencer9411c642004-10-26 22:26:33 +000052# Make sure all the user-target rules are double colon rules and
53# they are defined first.
Reid Spencer3a561f52004-10-23 20:04:14 +000054#--------------------------------------------------------------------
55
Reid Spencercc2d1e22004-10-30 09:19:36 +000056$(UserTargets)::
Reid Spencer151f8ba2004-10-25 08:27:37 +000057
Reid Spencer9411c642004-10-26 22:26:33 +000058################################################################################
59# PRECONDITIONS: that which must be built/checked first
60################################################################################
61
Reid Spencercc2d1e22004-10-30 09:19:36 +000062SrcMakefiles := $(filter %Makefile %Makefile.rules %Makefile.tests \
63 %Makefile.JIT,$(wildcard $(BUILD_SRC_DIR)/Makefile*))
64ObjMakefiles := $(subst $(BUILD_SRC_DIR),$(BUILD_OBJ_DIR),$(SrcMakefiles))
65ConfigureScript := $(LLVM_SRC_ROOT)/configure
66ConfigStatusScript := $(LLVM_OBJ_ROOT)/config.status
67MakefileConfigIn := $(LLVM_SRC_ROOT)/Makefile.config.in
68MakefileConfig := $(LLVM_OBJ_ROOT)/Makefile.config
69PreConditions := $(ConfigStatusScript) $(MakefileConfig) $(ObjMakefiles)
Reid Spencer9411c642004-10-26 22:26:33 +000070
Reid Spencercc2d1e22004-10-30 09:19:36 +000071preconditions : $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +000072
73#------------------------------------------------------------------------
74# Make sure the BUILT_SOURCES are built first
75#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000076$(filter-out clean clean-local,UserTargets):: $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000077
78clean-local::
79ifneq ($(strip $(BUILT_SOURCES)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +000080 -$(Verb) $(RM) -f $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000081endif
82
Reid Spencercc2d1e22004-10-30 09:19:36 +000083$(BUILT_SOURCES) : $(ObjMakefiles)
Reid Spencer80f0ef72004-10-28 00:41:43 +000084
Reid Spencer9411c642004-10-26 22:26:33 +000085#------------------------------------------------------------------------
86# Make sure we're not using a stale configuration
87#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000088.PRECIOUS: $(ConfigStatusScript)
89$(ConfigStatusScript): $(ConfigureScript)
90 $(Echo) Reconfiguring with $<
91 $(Verb) $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS)
92 $(Verb) $(ConfigStatusScript)
Reid Spencer9411c642004-10-26 22:26:33 +000093
94#------------------------------------------------------------------------
95# Make sure the configuration makefile is up to date
96#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000097$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
98 $(Echo) Regenerating $@
99 $(Verb) cd $(LLVM_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
Reid Spencer9411c642004-10-26 22:26:33 +0000100
101#------------------------------------------------------------------------
102# If the Makefile in the source tree has been updated, copy it over into the
103# build tree. But, only do this if the source and object makefiles differ
104#------------------------------------------------------------------------
105ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
106
107$(BUILD_OBJ_DIR)/Makefile : $(BUILD_SRC_DIR)/Makefile
Reid Spencercc2d1e22004-10-30 09:19:36 +0000108 $(Echo) "Updating Makefile"
109 $(Verb) $(MKDIR) $(@D)
110 $(Verb) cp -f $< $@
Reid Spencer9411c642004-10-26 22:26:33 +0000111
112# Copy the Makefile.* files unless we're in the root directory which avoids
113# the copying of Makefile.config.in or other things that should be explicitly
114# taken care of.
Reid Spencer9411c642004-10-26 22:26:33 +0000115$(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
Reid Spencer86606782004-10-26 23:10:00 +0000116 @case '$?' in \
117 *Makefile.rules) ;; \
118 *.in) ;; \
Reid Spencercc2d1e22004-10-30 09:19:36 +0000119 *) $(Echo) "Updating $(@F)" ; \
Reid Spencer86606782004-10-26 23:10:00 +0000120 $(MKDIR) $(@D) ; \
121 cp -f $< $@ ;; \
122 esac
123
Reid Spencer9411c642004-10-26 22:26:33 +0000124endif
125
126#------------------------------------------------------------------------
127# Set up the basic dependencies
128#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000129$(UserTargets):: $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +0000130
131all:: all-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000132check:: check-local
133clean:: clean-local
Reid Spencer3d659492004-11-02 16:36:03 +0000134clean-all:: clean-local clean-all-local
Reid Spencer9411c642004-10-26 22:26:33 +0000135install:: install-local
136uninstall:: uninstall-local
137check-local:: all-local
138install-local:: all-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000139
140###############################################################################
141# VARIABLES: Set up various variables based on configuration data
142###############################################################################
143
144#--------------------------------------------------------------------
145# Variables derived from configuration we are building
Chris Lattner00950542001-06-06 20:29:01 +0000146#--------------------------------------------------------------------
147
Chris Lattner760da062003-03-14 20:25:22 +0000148ifdef ENABLE_PROFILING
Reid Spencer9af3b292004-11-01 07:50:27 +0000149 BuildMode := Profile
Reid Spencercc2d1e22004-10-30 09:19:36 +0000150 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
151 C.Flags := -O3 -DNDEBUG -pg
152 LD.Flags := -O3 -DNDEBUG -pg
Chris Lattner760da062003-03-14 20:25:22 +0000153else
154 ifdef ENABLE_OPTIMIZED
Reid Spencer9af3b292004-11-01 07:50:27 +0000155 BuildMode := Release
Reid Spencercc2d1e22004-10-30 09:19:36 +0000156 CXX.Flags := -O3 -DNDEBUG -finline-functions -felide-constructors -fomit-frame-pointer
157 C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
158 LD.Flags := -O3 -DNDEBUG
Chris Lattner760da062003-03-14 20:25:22 +0000159 else
Reid Spencer9af3b292004-11-01 07:50:27 +0000160 BuildMode := Debug
Reid Spencercc2d1e22004-10-30 09:19:36 +0000161 CXX.Flags := -g -D_DEBUG
162 C.Flags := -g -D_DEBUG
163 LD.Flags := -g -D_DEBUG
Reid Spencer4d71b662004-10-22 21:01:56 +0000164 KEEP_SYMBOLS := 1
Chris Lattner760da062003-03-14 20:25:22 +0000165 endif
166endif
167
Reid Spencercc2d1e22004-10-30 09:19:36 +0000168CXX.Flags += $(CXXFLAGS)
169C.Flags += $(CFLAGS)
170CPP.Flags += $(CPPFLAGS)
171LD.Flags += $(LDFLAGS)
172AR.Flags := cru
173LibTool.Flags := --tag=CXX
Reid Spencer3a561f52004-10-23 20:04:14 +0000174
175#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000176# Directory locations
Reid Spencer3a561f52004-10-23 20:04:14 +0000177#--------------------------------------------------------------------
Reid Spencer9af3b292004-11-01 07:50:27 +0000178ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
179LibDir := $(BUILD_OBJ_ROOT)/lib/$(BuildMode)
180ToolDir := $(BUILD_OBJ_ROOT)/tools/$(BuildMode)
181LLVMLibDir := $(LLVM_OBJ_ROOT)/lib/$(BuildMode)
182LLVMToolDir := $(LLVM_OBJ_ROOT)/tools/$(BuildMode)
John Criswell7a73b802003-06-30 21:59:07 +0000183
Reid Spencer3a561f52004-10-23 20:04:14 +0000184#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000185# Full Paths To Compiled Tools and Utilities
Reid Spencer3a561f52004-10-23 20:04:14 +0000186#--------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000187EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
188Echo := @$(EchoCmd)
189ifndef LIBTOOL
Reid Spencer4d71b662004-10-22 21:01:56 +0000190LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencercc2d1e22004-10-30 09:19:36 +0000191endif
192ifndef LLVMAS
193LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
194endif
195ifndef BURG
196BURG := $(LLVMToolDir)/burg$(EXEEXT)
197endif
198ifndef TBLGEN
199TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
200endif
201ifndef GCCLD
202GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
203endif
204ifndef LLVMGCC
205LLVMGCC := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/gcc
206endif
207ifndef LLVMGXX
208LLVMGXX := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/g++
209endif
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000210
Reid Spencer4d71b662004-10-22 21:01:56 +0000211# Need a better way to compute this.
Reid Spencercc2d1e22004-10-30 09:19:36 +0000212LLVMGCCLibDir := $(dir $(shell $(LLVMGCC) -print-file-name=libgcc.a))/
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000213
Reid Spencer3a561f52004-10-23 20:04:14 +0000214#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000215# Adjust to user's request
Reid Spencer3a561f52004-10-23 20:04:14 +0000216#--------------------------------------------------------------------
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000217
Reid Spencercc2d1e22004-10-30 09:19:36 +0000218# Adjust LIBTOOL flags for shared libraries, or not.
John Criswell82f4a5a2003-07-31 20:58:51 +0000219ifndef SHARED_LIBRARY
Reid Spencercc2d1e22004-10-30 09:19:36 +0000220 LibTool.Flags += --tag=disable-shared
Reid Spencer4d71b662004-10-22 21:01:56 +0000221else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000222 LD.Flags += -rpath $(LibDir)
John Criswell82f4a5a2003-07-31 20:58:51 +0000223endif
224
Reid Spencer3a561f52004-10-23 20:04:14 +0000225# Adjust settings for verbose mode
Chris Lattner760da062003-03-14 20:25:22 +0000226ifndef VERBOSE
Reid Spencercc2d1e22004-10-30 09:19:36 +0000227 Verb := @
228 LibTool.Flags += --silent
229 AR.Flags += >/dev/null 2>/dev/null
230 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
Reid Spencer151f8ba2004-10-25 08:27:37 +0000231else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000232 ConfigureScriptFLAGS :=
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000233endif
234
Vikram S. Advefeeae582002-09-18 11:55:13 +0000235# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000236ifndef KEEP_SYMBOLS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000237 Strip := $(PLATFORMSTRIPOPTS)
238 StripWarnMsg := "(without symbols)"
Vikram S. Advefeeae582002-09-18 11:55:13 +0000239endif
240
Reid Spencer3a561f52004-10-23 20:04:14 +0000241# Adjust linker flags for building an executable
Reid Spencer4d71b662004-10-22 21:01:56 +0000242ifdef TOOLNAME
Reid Spencercc2d1e22004-10-30 09:19:36 +0000243 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000244endif
245
Reid Spencer3a561f52004-10-23 20:04:14 +0000246#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000247# Options To Invoke Tools
Reid Spencer3a561f52004-10-23 20:04:14 +0000248#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000249
250CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
251
Reid Spencercc2d1e22004-10-30 09:19:36 +0000252LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
253CPP.Flags += -I$(BUILD_OBJ_DIR) \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000254 -I$(BUILD_SRC_DIR) \
255 -I$(BUILD_SRC_ROOT)/include \
256 -I$(BUILD_OBJ_ROOT)/include \
257 -I$(LLVM_OBJ_ROOT)/include \
258 -I$(LLVM_SRC_ROOT)/include \
259 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
Reid Spencer4d71b662004-10-22 21:01:56 +0000260
Reid Spencercc2d1e22004-10-30 09:19:36 +0000261Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
262LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
263BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
264Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
265LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
266BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
267Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
268 $(CompileCommonOpts) $(LD.Flags) $(Strip)
269Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencera69b1ea2004-10-28 09:15:28 +0000270 $(CompileCommonOpts)
Reid Spencer3a561f52004-10-23 20:04:14 +0000271BCLinkLib = $(LLVMGCC) -shared -nostdlib
Reid Spencercc2d1e22004-10-30 09:19:36 +0000272LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
Reid Spencer3a561f52004-10-23 20:04:14 +0000273Burg = $(BURG) -I $(BUILD_SRC_DIR)
274TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000275Archive = $(AR) $(AR.Flags)
Reid Spencer4d71b662004-10-22 21:01:56 +0000276ifdef RANLIB
Reid Spencer3a561f52004-10-23 20:04:14 +0000277Ranlib = $(RANLIB)
Reid Spencer4d71b662004-10-22 21:01:56 +0000278else
Reid Spencer3a561f52004-10-23 20:04:14 +0000279Ranlib = ranlib
John Criswell7a73b802003-06-30 21:59:07 +0000280endif
281
Chris Lattner00950542001-06-06 20:29:01 +0000282#----------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000283# Get the list of source files
284#----------------------------------------------------------
285ifndef SOURCES
Reid Spencercc2d1e22004-10-30 09:19:36 +0000286 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
287 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
288 $(BUILD_SRC_DIR)/*.l))
289else
290 Sources := $(SOURCES)
Reid Spencer4d71b662004-10-22 21:01:56 +0000291endif
292
293ifdef BUILT_SOURCES
Reid Spencercc2d1e22004-10-30 09:19:36 +0000294Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Vikram S. Advead9ea7e2002-10-14 16:40:04 +0000295endif
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000296
Reid Spencer3a561f52004-10-23 20:04:14 +0000297#----------------------------------------------------------
298# Types of objects that can be built from sources
299#----------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000300BaseNameSources := $(sort $(basename $(Sources)))
301ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
302ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
303ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
Reid Spencer3a561f52004-10-23 20:04:14 +0000304
305###############################################################################
306# DIRECTORIES: Handle recursive descent of directory structure
307###############################################################################
John Criswell82f4a5a2003-07-31 20:58:51 +0000308
Chris Lattner00950542001-06-06 20:29:01 +0000309#---------------------------------------------------------
Reid Spencera69b1ea2004-10-28 09:15:28 +0000310# Provide rules to make install dirs. This must be early
311# in the file so they get built before dependencies
312#---------------------------------------------------------
313
314$(bindir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000315 $(Verb) $(MKDIR) $(bindir)
Chris Lattnere4cb90f2004-11-01 06:14:59 +0000316
Reid Spencera69b1ea2004-10-28 09:15:28 +0000317$(libdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000318 $(Verb) $(MKDIR) $(libdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000319
320$(bytecode_libdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000321 $(Verb) $(MKDIR) $(bytecode_libdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000322
323$(sysconfdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000324 $(Verb) $(MKDIR) $(sysconfdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000325
Reid Spencercc2d1e22004-10-30 09:19:36 +0000326# To create other directories, as needed, and timestamp their creation
327%/.dir:
328 $(Verb) $(MKDIR) $* > /dev/null
329 @$(DATE) > $@
330
331.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(LLVMLibDir)/.dir
332.PRECIOUS: $(LLVMToolDir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000333
334#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000335# Handle the DIRS options for sequential construction
Chris Lattner00950542001-06-06 20:29:01 +0000336#---------------------------------------------------------
337
Reid Spencercc2d1e22004-10-30 09:19:36 +0000338SubDirs :=
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000339ifdef DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000340SubDirs += $(DIRS)
341$(RecursiveTargets)::
342 $(Verb) for dir in $(DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000343 if [ ! -f $$dir/Makefile ]; then \
344 $(MKDIR) $$dir; \
345 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
346 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000347 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000348 done
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000349endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000350
Reid Spencer3a561f52004-10-23 20:04:14 +0000351#---------------------------------------------------------
352# Handle the EXPERIMENTAL_DIRS options ensuring success
353# after each directory is built.
354#---------------------------------------------------------
355ifdef EXPERIMENTAL_DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000356$(RecursiveTargets)::
357 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer3a561f52004-10-23 20:04:14 +0000358 if [ ! -f $$dir/Makefile ]; then \
359 $(MKDIR) $$dir; \
360 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
361 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000362 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000363 done
364endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000365
Reid Spencer3a561f52004-10-23 20:04:14 +0000366#---------------------------------------------------------
367# Handle the PARALLEL_DIRS options for parallel construction
368#---------------------------------------------------------
369ifdef PARALLEL_DIRS
370
Reid Spencercc2d1e22004-10-30 09:19:36 +0000371SubDirs += $(PARALLEL_DIRS)
372
Reid Spencer3a561f52004-10-23 20:04:14 +0000373# Unfortunately, this list must be maintained if new
374# recursive targets are added.
Reid Spencercc2d1e22004-10-30 09:19:36 +0000375all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
376clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000377clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000378check :: $(addsuffix /.makecheck ,$(PARALLEL_DIRS))
379install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000380uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
381
Reid Spencercc2d1e22004-10-30 09:19:36 +0000382Parallel_Targets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer3a561f52004-10-23 20:04:14 +0000383
384$(Parallel_Targets) :
Reid Spencercc2d1e22004-10-30 09:19:36 +0000385 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencer4d71b662004-10-22 21:01:56 +0000386 $(MKDIR) $(@D); \
387 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswellb3866b62003-11-25 19:32:22 +0000388 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000389 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
Chris Lattner00950542001-06-06 20:29:01 +0000390endif
391
Reid Spencer3a561f52004-10-23 20:04:14 +0000392#---------------------------------------------------------
393# Handle the OPTIONAL_DIRS options for directores that may
394# or may not exist.
395#---------------------------------------------------------
John Criswell2a6530f2003-06-27 16:58:44 +0000396ifdef OPTIONAL_DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000397
Reid Spencercc2d1e22004-10-30 09:19:36 +0000398SubDirs += $(OPTIONAL_DIRS)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000399
Reid Spencercc2d1e22004-10-30 09:19:36 +0000400$(RecursiveTargets)::
401 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000402 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
403 if [ ! -f $$dir/Makefile ]; then \
404 $(MKDIR) $$dir; \
405 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
406 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000407 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000408 fi \
John Criswell2a6530f2003-06-27 16:58:44 +0000409 done
410endif
411
Reid Spencerfc945082004-08-20 09:20:05 +0000412#---------------------------------------------------------
413# Handle the CONFIG_FILES options
414#---------------------------------------------------------
415ifdef CONFIG_FILES
Reid Spencerfc945082004-08-20 09:20:05 +0000416
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000417install-local:: $(sysconfdir) $(CONFIG_FILES)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000418 $(Echo) Installing Configuration Files To $(sysconfdir)
419 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000420 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
Reid Spencerfc945082004-08-20 09:20:05 +0000421 done
Reid Spencer3a561f52004-10-23 20:04:14 +0000422
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000423uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000424 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
425 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000426 $(RM) -f $(sysconfdir)/$${file} ; \
Reid Spencere5487ba2004-10-24 07:53:21 +0000427 done
428
Reid Spencerfc945082004-08-20 09:20:05 +0000429endif
430
Reid Spencer3a561f52004-10-23 20:04:14 +0000431###############################################################################
432# Library Build Rules: Four ways to build a library
433###############################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000434
Brian Gaeke8abff792004-01-22 22:53:48 +0000435
Reid Spencer3a561f52004-10-23 20:04:14 +0000436# if we're building a library ...
Chris Lattner00950542001-06-06 20:29:01 +0000437ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000438
Chris Lattner2a548c52002-09-16 22:36:42 +0000439# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000440LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000441LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
442LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
443LibName.O := $(LibDir)/$(LIBRARYNAME).o
444LibName.BC := $(LibDir)/lib$(LIBRARYNAME).bc
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000445
Reid Spencer3a561f52004-10-23 20:04:14 +0000446#---------------------------------------------------------
447# Shared Library Targets:
448# If the user asked for a shared library to be built
449# with the SHARED_LIBRARY variable, then we provide
450# targets for building them.
451#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000452ifdef SHARED_LIBRARY
453
Reid Spencercc2d1e22004-10-30 09:19:36 +0000454all-local:: $(LibName.LA)
Reid Spencer4d71b662004-10-22 21:01:56 +0000455
Reid Spencercc2d1e22004-10-30 09:19:36 +0000456$(LibName.LA): $(BUILT_SOURCES) $(ObjectsLO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000457 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000458 $(Verb) $(Link) -o $@ $(ObjectsLO)
459 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencer3a561f52004-10-23 20:04:14 +0000460
461clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000462ifneq ($(strip $(LibName.LA)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000463 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000464endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000465
Reid Spencere5487ba2004-10-24 07:53:21 +0000466DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencer4d71b662004-10-22 21:01:56 +0000467
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000468install-local:: $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000469
Reid Spencercc2d1e22004-10-30 09:19:36 +0000470$(DestSharedLib): $(libdir) $(LibName.LA)
Reid Spencer9af3b292004-11-01 07:50:27 +0000471 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000472 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
473 $(Verb) $(LIBTOOL) --finish $(libdir)
Reid Spencere5487ba2004-10-24 07:53:21 +0000474
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000475uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000476 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000477 -$(Verb) $(RM) -f $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000478
Reid Spencer4d71b662004-10-22 21:01:56 +0000479endif
480
Reid Spencer3a561f52004-10-23 20:04:14 +0000481#---------------------------------------------------------
482# Bytecode Library Targets:
483# If the user asked for a bytecode library to be built
484# with the BYTECODE_LIBRARY variable, then we provide
485# targets for building them.
486#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000487ifdef BYTECODE_LIBRARY
488
489ifdef EXPORTED_SYMBOL_LIST
490 BCLinkLib += -Xlinker -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
491else
492 ifdef EXPORTED_SYMBOL_FILE
493 BCLinkLib += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
494 else
495 BCLinkLib += -Xlinker -disable-internalize
496 endif
497endif
498
Reid Spencercc2d1e22004-10-30 09:19:36 +0000499all-local:: $(LibName.BC)
Reid Spencer4d71b662004-10-22 21:01:56 +0000500
Reid Spencercc2d1e22004-10-30 09:19:36 +0000501$(LibName.BC): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000502 $(Echo) Linking $(BuildMode) Bytecode Library $(notdir $@)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000503 $(Verb) $(BCLinkLib) -o $@ $(ObjectsBC)
Reid Spencer4d71b662004-10-22 21:01:56 +0000504
Reid Spencer3a561f52004-10-23 20:04:14 +0000505clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000506ifneq ($(strip $(LibName.BC)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000507 -$(Verb) $(RM) -f $(LibName.BC)
Reid Spencere5487ba2004-10-24 07:53:21 +0000508endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000509
Reid Spencere5487ba2004-10-24 07:53:21 +0000510DestBytecodeLib = $(bytecode_libdir)/lib$(LIBRARYNAME).bc
Reid Spencere45ebfa2004-10-26 07:09:33 +0000511
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000512install-local:: $(DestBytecodeLib)
Chris Lattner481cc7c2003-08-15 02:18:35 +0000513
Reid Spencercc2d1e22004-10-30 09:19:36 +0000514$(DestBytecodeLib): $(bytecode_libdir) $(LibName.BC)
Reid Spencer9af3b292004-11-01 07:50:27 +0000515 $(Echo) Installing $(BuildMode) Bytecode Library $(DestBytecodeLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000516 $(Verb) $(INSTALL) $(LibName.BC) $@
Reid Spencere5487ba2004-10-24 07:53:21 +0000517
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000518uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000519 $(Echo) Uninstalling $(BuildMode) Bytecode Library $(DestBytecodeLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000520 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000521
522endif
Vikram S. Adve60f56062002-08-02 18:34:12 +0000523
Reid Spencercc2d1e22004-10-30 09:19:36 +0000524#---------------------------------------------------------
525# ReLinked Library Targets:
526# If the user didn't explicitly forbid building a
527# relinked then we provide targets for building them.
528#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000529ifndef DONT_BUILD_RELINKED
Reid Spencer4d71b662004-10-22 21:01:56 +0000530
Reid Spencercc2d1e22004-10-30 09:19:36 +0000531all-local:: $(LibName.O)
532
533$(LibName.O): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000534 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000535 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencer4d71b662004-10-22 21:01:56 +0000536
Reid Spencer3a561f52004-10-23 20:04:14 +0000537clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000538ifneq ($(strip $(LibName.O)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000539 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencere5487ba2004-10-24 07:53:21 +0000540endif
541
542DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
543
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000544install-local:: $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000545
Reid Spencercc2d1e22004-10-30 09:19:36 +0000546$(DestRelinkedLib): $(libdir) $(LibName.O)
Reid Spencer9af3b292004-11-01 07:50:27 +0000547 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000548 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000549
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000550uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000551 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000552 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000553
Chris Lattnere62dbe92002-07-23 17:56:16 +0000554endif
Chris Lattner760da062003-03-14 20:25:22 +0000555
Reid Spencercc2d1e22004-10-30 09:19:36 +0000556#---------------------------------------------------------
557# Archive Library Targets:
558# If the user wanted a regular archive library built,
559# then we provide targets for building them.
560#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000561ifdef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000562
Reid Spencercc2d1e22004-10-30 09:19:36 +0000563all-local:: $(LibName.A)
564
565$(LibName.A): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000566 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000567 -$(Verb) $(RM) -f $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000568 $(Verb) $(Archive) $@ $(ObjectsO)
569 $(Verb) $(Ranlib) $@
Vikram S. Adve41e78912002-09-20 14:03:13 +0000570
Reid Spencer3a561f52004-10-23 20:04:14 +0000571clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000572ifneq ($(strip $(LibName.A)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000573 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner00950542001-06-06 20:29:01 +0000574endif
575
Reid Spencere5487ba2004-10-24 07:53:21 +0000576DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
577
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000578install-local:: $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000579
Reid Spencercc2d1e22004-10-30 09:19:36 +0000580$(DestArchiveLib): $(libdir) $(LibName.A)
Reid Spencer9af3b292004-11-01 07:50:27 +0000581 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000582 $(Verb) $(MKDIR) $(libdir)
583 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000584
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000585uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000586 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000587 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000588
589endif
590
591# endif LIBRARYNAME
Reid Spencer4d71b662004-10-22 21:01:56 +0000592endif
593
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000594###############################################################################
595# Tool Build Rules: Build executable tool based on TOOLNAME option
596###############################################################################
597
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000598ifdef TOOLNAME
599
Reid Spencercc2d1e22004-10-30 09:19:36 +0000600#---------------------------------------------------------
601# Set up variables for building a tool.
602#---------------------------------------------------------
603ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
604ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
605ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
606LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
607LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
608ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
609LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
610ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
611LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000612
Reid Spencercc2d1e22004-10-30 09:19:36 +0000613#---------------------------------------------------------
614# Handle optional compression libraries automatically
615#---------------------------------------------------------
616ExtraLibs := $(LIBS)
Reid Spencer4d71b662004-10-22 21:01:56 +0000617ifeq ($(HAVE_BZIP2),1)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000618ExtraLibs += -lbz2
Reid Spencer4d71b662004-10-22 21:01:56 +0000619endif
620ifeq ($(HAVE_ZLIB),1)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000621ExtraLibs += -lz
Reid Spencer4d71b662004-10-22 21:01:56 +0000622endif
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000623
Reid Spencercc2d1e22004-10-30 09:19:36 +0000624#---------------------------------------------------------
625# Tell make that we need to rebuild subdirectories before
626# we can link the tool. This affects things like LLI which
627# has library subdirectories.
628#---------------------------------------------------------
629$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000630
Reid Spencercc2d1e22004-10-30 09:19:36 +0000631#---------------------------------------------------------
632# Provide targets for building the tools
633#---------------------------------------------------------
634all-local:: $(ToolBuildPath)
John Criswell2a6530f2003-06-27 16:58:44 +0000635
Reid Spencer3a561f52004-10-23 20:04:14 +0000636clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000637ifneq ($(strip $(ToolBuildPath)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000638 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencere5487ba2004-10-24 07:53:21 +0000639endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000640
Reid Spencercc2d1e22004-10-30 09:19:36 +0000641$(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)\
642 $(ToolDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000643 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000644 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
645 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
Reid Spencer9af3b292004-11-01 07:50:27 +0000646 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencere5487ba2004-10-24 07:53:21 +0000647
648DestTool = $(bindir)/$(TOOLNAME)
649
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000650install-local:: $(DestTool)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000651
Reid Spencercc2d1e22004-10-30 09:19:36 +0000652$(DestTool): $(bindir) $(ToolBuildPath)
Reid Spencer9af3b292004-11-01 07:50:27 +0000653 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000654 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000655
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000656uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000657 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000658 -$(Verb) $(RM) -f $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000659
Reid Spencer4d71b662004-10-22 21:01:56 +0000660endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000661
Reid Spencercc2d1e22004-10-30 09:19:36 +0000662###############################################################################
663# Object Build Rules: Build object files based on sources
664###############################################################################
665
666# Provide rule sets for when dependency generation is enabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000667ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve41e78912002-09-20 14:03:13 +0000668
Reid Spencercc2d1e22004-10-30 09:19:36 +0000669#---------------------------------------------------------
670# Create .lo files in the ObjDir directory from the .cpp and .c files...
671#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000672ifdef SHARED_LIBRARY
673
Reid Spencercc2d1e22004-10-30 09:19:36 +0000674$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000675 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000676 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
677 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
678 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000679
Reid Spencercc2d1e22004-10-30 09:19:36 +0000680$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000681 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000682 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
683 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
684 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000685
Reid Spencercc2d1e22004-10-30 09:19:36 +0000686#---------------------------------------------------------
687# Create .o files in the ObjDir directory from the .cpp and .c files...
688#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000689else
Reid Spencer4d71b662004-10-22 21:01:56 +0000690
Reid Spencercc2d1e22004-10-30 09:19:36 +0000691$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000692 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000693 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
694 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
695 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000696
Reid Spencercc2d1e22004-10-30 09:19:36 +0000697$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000698 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000699 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
700 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
701 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000702
703endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000704
Reid Spencercc2d1e22004-10-30 09:19:36 +0000705#---------------------------------------------------------
706# Create .bc files in the ObjDir directory from .cpp and .c files...
707#---------------------------------------------------------
708$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000709 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000710 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
711 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
712 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000713
Reid Spencercc2d1e22004-10-30 09:19:36 +0000714$(ObjDir)/%.bc: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000715 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000716 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
717 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
718 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000719
Reid Spencercc2d1e22004-10-30 09:19:36 +0000720# Provide alternate rule sets if dependencies are disabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000721else
722
Reid Spencer3a561f52004-10-23 20:04:14 +0000723ifdef SHARED_LIBRARY
724
Reid Spencercc2d1e22004-10-30 09:19:36 +0000725$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000726 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000727 $(LTCompile.CXX) $< -o $@
728
Reid Spencercc2d1e22004-10-30 09:19:36 +0000729$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000730 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000731 $(LTCompile.C) $< -o $@
732
733else
Reid Spencer4d71b662004-10-22 21:01:56 +0000734
Reid Spencercc2d1e22004-10-30 09:19:36 +0000735$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000736 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +0000737 $(Compile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000738
Reid Spencercc2d1e22004-10-30 09:19:36 +0000739$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000740 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +0000741 $(Compile.C) $< -o $@
742endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000743
Reid Spencercc2d1e22004-10-30 09:19:36 +0000744$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000745 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencer8676b7e2004-10-31 18:52:15 +0000746 $(BCCompile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000747
Reid Spencercc2d1e22004-10-30 09:19:36 +0000748$(ObjDir)/%.bc: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000749 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencer8676b7e2004-10-31 18:52:15 +0000750 $(BCCompile.C) $< -o $@
Brian Gaeke44909cf2003-12-10 00:26:28 +0000751
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000752endif
753
Reid Spencercc2d1e22004-10-30 09:19:36 +0000754#---------------------------------------------------------
755# Provide rule to build .bc files from .ll sources,
756# regardless of dependencies
757#---------------------------------------------------------
758$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000759 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000760 $(Verb) $(LLVMAS) $< -f -o $@
761
762###############################################################################
763# TABLEGEN: Provide rules for running tblgen to produce *.inc files
764###############################################################################
Chris Lattner481cc7c2003-08-15 02:18:35 +0000765
Reid Spencer4d71b662004-10-22 21:01:56 +0000766ifdef TARGET
767
Reid Spencercc2d1e22004-10-30 09:19:36 +0000768TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
769INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Reid Spencer4d71b662004-10-22 21:01:56 +0000770
Reid Spencercc2d1e22004-10-30 09:19:36 +0000771$(INCFiles) : $(TBLGEN) $(TDFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +0000772
Reid Spencer16544482004-10-27 04:34:35 +0000773%GenRegisterNames.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000774 $(Echo) "Building $(<F) register names with tblgen"
775 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000776
Reid Spencer16544482004-10-27 04:34:35 +0000777%GenRegisterInfo.h.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000778 $(Echo) "Building $(<F) register information header with tblgen"
779 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000780
781%GenRegisterInfo.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000782 $(Echo) "Building $(<F) register info implementation with tblgen"
783 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000784
785%GenInstrNames.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000786 $(Echo) "Building $(<F) instruction names with tblgen"
787 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000788
789%GenInstrInfo.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000790 $(Echo) "Building $(<F) instruction information with tblgen"
791 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000792
793%GenAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000794 $(Echo) "Building $(<F) assembly writer with tblgen"
795 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000796
797%GenATTAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000798 $(Echo) "Building $(<F) AT&T assembly writer with tblgen"
799 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000800
801%GenIntelAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000802 $(Echo) "Building $(<F) Intel assembly writer with tblgen"
803 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000804
805%GenInstrSelector.inc: %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000806 $(Echo) "Building $(<F) instruction selector with tblgen"
807 $(Verb) $(TableGen) -gen-instr-selector -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000808
809%GenCodeEmitter.inc:: %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000810 $(Echo) "Building $(<F) code emitter with tblgen"
811 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000812
Reid Spencer3a561f52004-10-23 20:04:14 +0000813clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000814 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +0000815
816endif
Chris Lattner481cc7c2003-08-15 02:18:35 +0000817
Reid Spencercc2d1e22004-10-30 09:19:36 +0000818###############################################################################
819# LEX AND YACC: Provide rules for generating sources with lex and yacc
820###############################################################################
Chris Lattnere8996782003-01-16 22:44:19 +0000821
Reid Spencercc2d1e22004-10-30 09:19:36 +0000822#---------------------------------------------------------
823# Provide rules for generating a .cpp source file from
824# (f)lex input sources.
825#---------------------------------------------------------
826
Reid Spencer3d659492004-11-02 16:36:03 +0000827LexFiles := $(filter %.l,$(Sources))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000828
Reid Spencer3d659492004-11-02 16:36:03 +0000829ifneq ($(LexFiles),)
830
831LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000832
833.PRECIOUS: $(LexOutput)
834
835# Note the extra sed filtering here, used to cut down on the warnings emited
836# by GCC. The last line is a gross hack to work around flex aparently not
837# being able to resize the buffer on a large token input. Currently, for
838# uninitialized string buffers in LLVM we can generate very long tokens, so
839# this is a hack around it.
Chris Lattnerb7dc2b92003-08-15 20:00:47 +0000840# FIXME. (f.e. char Buffer[10000] )
Chris Lattner00950542001-06-06 20:29:01 +0000841%.cpp: %.l
Reid Spencercc2d1e22004-10-30 09:19:36 +0000842 $(Echo) Flexing $<
843 $(Verb) $(FLEX) -t $< | \
Reid Spencer4d71b662004-10-22 21:01:56 +0000844 $(SED) 's/void yyunput/inline void yyunput/' | \
845 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
846 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencer80f0ef72004-10-28 00:41:43 +0000847 > $@
Chris Lattner00950542001-06-06 20:29:01 +0000848
Reid Spencer9af3b292004-11-01 07:50:27 +0000849clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000850 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencer3d659492004-11-02 16:36:03 +0000851 $(Verb) $(RM) -f $(LexOutput)
Reid Spencer9af3b292004-11-01 07:50:27 +0000852
Reid Spencercc2d1e22004-10-30 09:19:36 +0000853endif
854
855#---------------------------------------------------------
856# Provide rules for generating a .cpp and .h source files
857# from yacc (bison) input sources.
858#---------------------------------------------------------
859
Reid Spencer3d659492004-11-02 16:36:03 +0000860YaccFiles := $(filter %.y,$(Sources))
861ifneq ($(YaccFiles),)
862YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000863
864.PRECIOUS: $(YaccOutput)
865
866# Cancel built-in rules for yacc
867%.c: %.y
868%.cpp: %.y
869%.h: %.y
870
Chris Lattner00950542001-06-06 20:29:01 +0000871# Rule for building the bison parsers...
Chris Lattner00950542001-06-06 20:29:01 +0000872%.cpp %.h : %.y
Reid Spencercc2d1e22004-10-30 09:19:36 +0000873 $(Echo) "Bisoning $*.y"
874 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
875 $(Verb) $(MV) -f $*.tab.c $*.cpp
876 $(Verb) $(MV) -f $*.tab.h $*.h
Chris Lattner00950542001-06-06 20:29:01 +0000877
Reid Spencer9af3b292004-11-01 07:50:27 +0000878clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000879 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencer3d659492004-11-02 16:36:03 +0000880 $(Verb) $(RM) -f $(YaccOutput)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000881endif
Chris Lattner00950542001-06-06 20:29:01 +0000882
Reid Spencercc2d1e22004-10-30 09:19:36 +0000883###############################################################################
884# OTHER RULES: Other rules needed
885###############################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +0000886
Chris Lattner30440c62003-01-16 21:06:18 +0000887# To create postscript files from dot files...
John Criswelle0f9ac62003-10-02 19:02:02 +0000888ifneq ($(DOT),false)
Chris Lattner30440c62003-01-16 21:06:18 +0000889%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +0000890 $(DOT) -Tps < $< > $@
John Criswell7a73b802003-06-30 21:59:07 +0000891else
892%.ps: %.dot
Reid Spencercc2d1e22004-10-30 09:19:36 +0000893 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell7a73b802003-06-30 21:59:07 +0000894endif
Chris Lattner30440c62003-01-16 21:06:18 +0000895
John Criswell7f336952003-09-06 14:44:17 +0000896# This rules ensures that header files that are removed still have a rule for
897# which they can be "generated." This allows make to ignore them and
898# reproduce the dependency lists.
John Criswell4b6e5d12003-09-18 18:37:08 +0000899%.h:: ;
John Criswell7f336952003-09-06 14:44:17 +0000900
Reid Spencercc2d1e22004-10-30 09:19:36 +0000901# Define clean-local to clean the current directory. Note that this uses a
902# very conservative approach ensuring that empty variables do not cause
903# errors or disastrous removal.
Reid Spencer3a561f52004-10-23 20:04:14 +0000904clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000905ifneq ($(strip $(ObjDir)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000906 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencere5487ba2004-10-24 07:53:21 +0000907endif
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000908 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke9d3cd402004-01-21 19:53:11 +0000909ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000910 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke9d3cd402004-01-21 19:53:11 +0000911endif
John Criswell7a73b802003-06-30 21:59:07 +0000912
Reid Spencer3d659492004-11-02 16:36:03 +0000913clean-all-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000914 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer3d659492004-11-02 16:36:03 +0000915
Reid Spencercc2d1e22004-10-30 09:19:36 +0000916# Build tags database for Emacs/Xemacs:
917tags:: TAGS
918TAGS:
919 find include lib tools examples -name '*.cpp' -o -name '*.h' | \
920 $(ETAGS) $(ETAGSFLAGS) -
921
Reid Spencer3a561f52004-10-23 20:04:14 +0000922###############################################################################
923# DEPENDENCIES: Include the dependency files if we should
924###############################################################################
Chris Lattner33ad24a2003-08-22 14:10:16 +0000925ifndef DISABLE_AUTO_DEPENDENCIES
926
Reid Spencer3a561f52004-10-23 20:04:14 +0000927# If its not one of the cleaning targets
Reid Spencercc2d1e22004-10-30 09:19:36 +0000928ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencer4d71b662004-10-22 21:01:56 +0000929
Reid Spencer3a561f52004-10-23 20:04:14 +0000930# Get the list of dependency files
Reid Spencercc2d1e22004-10-30 09:19:36 +0000931DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Reid Spencer9af3b292004-11-01 07:50:27 +0000932DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
Misha Brukman4f7a8cf2003-11-09 21:36:19 +0000933
Reid Spencer3a561f52004-10-23 20:04:14 +0000934-include /dev/null $(DependFiles)
935
John Criswelld741bcf2003-08-12 18:51:51 +0000936endif
Chris Lattner1ddb6b62003-08-18 17:27:40 +0000937
Reid Spencercc2d1e22004-10-30 09:19:36 +0000938endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000939
Reid Spencer151f8ba2004-10-25 08:27:37 +0000940###############################################################################
Reid Spencercc2d1e22004-10-30 09:19:36 +0000941# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer151f8ba2004-10-25 08:27:37 +0000942###############################################################################
943
Reid Spencere45ebfa2004-10-26 07:09:33 +0000944#------------------------------------------------------------------------
945# Define distribution related variables
946#------------------------------------------------------------------------
Reid Spencer151f8ba2004-10-25 08:27:37 +0000947DistName := $(LLVM_TARBALL_NAME)
948DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000949TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000950DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
951DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
952DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
953DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
954 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencere45ebfa2004-10-26 07:09:33 +0000955 Makefile.config.in configure autoconf
956DistOther := $(notdir $(wildcard \
957 $(BUILD_SRC_DIR)/*.h \
958 $(BUILD_SRC_DIR)/*.td \
959 $(BUILD_SRC_DIR)/*.def \
960 $(BUILD_SRC_DIR)/*.ll \
961 $(BUILD_SRC_DIR)/*.in))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000962DistSources := $(Sources) $(EXTRA_DIST)
963DistSubDirs := $(SubDirs)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000964DistFiles := $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000965
Reid Spencere45ebfa2004-10-26 07:09:33 +0000966#------------------------------------------------------------------------
967# We MUST build distribution with OBJ_DIR != SRC_DIR
968#------------------------------------------------------------------------
969ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
970dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000971 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencere45ebfa2004-10-26 07:09:33 +0000972
973DistCheckTop :=
974else
975
976DistCheckTop := check
Reid Spencercc2d1e22004-10-30 09:19:36 +0000977
Reid Spencere45ebfa2004-10-26 07:09:33 +0000978#------------------------------------------------------------------------
979# Prevent catastrophic remove
980#------------------------------------------------------------------------
981ifeq ($(LLVM_TARBALL_NAME),)
982$(error LLVM_TARBALL_NAME is empty. Please rerun configure)
983endif
984
985#------------------------------------------------------------------------
986# Prevent attempt to run dist targets from anywhere but the top level
987#------------------------------------------------------------------------
988ifneq ($(LEVEL),.)
989
990dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000991 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000992
993else
994
995#------------------------------------------------------------------------
996# Provide the top level targets
997#------------------------------------------------------------------------
998
Reid Spencercc2d1e22004-10-30 09:19:36 +0000999dist-gzip:: $(DistTarGZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001000
1001$(DistTarGZip) : distdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001002 $(Echo) Packing gzipped distribution tar file.
1003 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | gzip -c > "$(DistTarGZip)"
Reid Spencere45ebfa2004-10-26 07:09:33 +00001004
Reid Spencercc2d1e22004-10-30 09:19:36 +00001005dist-bzip2:: $(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001006
1007$(DistTarBZ2) : distdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001008 $(Echo) Packing bzipped distribution tar file.
1009 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | $(BZIP2) -c >$(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001010
Reid Spencercc2d1e22004-10-30 09:19:36 +00001011dist-zip:: $(DistZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001012
1013$(DistZip) : distdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001014 $(Echo) Packing zipped distribution file.
1015 $(Verb) rm -f $(DistZip)
1016 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001017
1018dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001019 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001020
1021DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1022
Reid Spencer9411c642004-10-26 22:26:33 +00001023dist-check:: $(DistCheckTop) $(DistTarGZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001024 $(Echo) Checking distribution tar file.
1025 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001026 $(RM) -rf $(DistCheckDir) ; \
1027 fi
Reid Spencercc2d1e22004-10-30 09:19:36 +00001028 $(Verb) $(MKDIR) $(DistCheckDir)
1029 $(Verb) cd $(DistCheckDir) && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001030 $(MKDIR) $(DistCheckDir)/build && \
1031 $(MKDIR) $(DistCheckDir)/install && \
1032 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1033 cd build && \
1034 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1035 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
1036 $(MAKE) check && \
1037 $(MAKE) install && \
1038 $(MAKE) uninstall && \
1039 $(MAKE) dist && \
1040 $(MAKE) clean && \
1041 $(MAKE) dist-clean && \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001042 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001043
1044dist-clean::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001045 $(Echo) Cleaning distribution files
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001046 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) $(DistCheckDir)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001047
1048endif
1049
1050#------------------------------------------------------------------------
1051# Provide the recursive distdir target for building the distribution directory
1052#------------------------------------------------------------------------
Reid Spencer9411c642004-10-26 22:26:33 +00001053distdir : $(DistSources)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001054 $(Echo) Building Distribution Directory $(DistDir)
1055 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001056 if test -d "$(DistDir)" ; then \
1057 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1058 exit 1 ; \
1059 fi ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001060 $(EchoCmd) Removing $(DistDir) ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001061 $(RM) -rf $(DistDir); \
1062 fi
Reid Spencercc2d1e22004-10-30 09:19:36 +00001063 $(Verb) $(MKDIR) $(DistDir)
1064 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001065 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1066 for file in $(DistFiles) ; do \
1067 case "$$file" in \
1068 $(BUILD_SRC_DIR)/*) file=`echo "$$file" | sed "s#^$$srcdirstrip/##"`;; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001069 $(BUILD_SRC_ROOT)/*) file=`echo "$$file" | sed "s#^$$srcrootstrip/#$(BUILD_OBJ_ROOT)/#"`;; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001070 esac; \
1071 if test -f "$$file" || test -d "$$file" ; then \
1072 from_dir=. ; \
1073 else \
1074 from_dir=$(BUILD_SRC_DIR); \
1075 fi; \
1076 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'`; \
1077 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1078 to_dir="$(DistDir)/$$dir"; \
1079 $(MKDIR) "$$to_dir" ; \
1080 else \
1081 to_dir="$(DistDir)"; \
1082 fi; \
1083 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1084 if test -n "$$mid_dir" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001085 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001086 fi ; \
1087 if test -d "$$from_dir/$$file"; then \
1088 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1089 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1090 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1091 fi; \
1092 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1093 elif test -f "$$from_dir/$$file" ; then \
1094 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1095 elif test -L "$$from_dir/$$file" ; then \
1096 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1097 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001098 $(EchoCmd) "===== WARNING: Distribution Source $$from_dir/$$file Not Found!" ; \
1099 elif test "$(Verb)" != '@' ; then \
1100 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001101 fi; \
1102 done
Reid Spencercc2d1e22004-10-30 09:19:36 +00001103 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001104 if test "$$subdir" \!= "." ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001105 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001106 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1107 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001108 fi; \
1109 done
Reid Spencercc2d1e22004-10-30 09:19:36 +00001110 $(Verb) $(MAKE) DistDir="$(DistDir)" dist-hook || exit 1
1111 -$(Verb) find $(DistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001112 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
1113 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
1114 ! -type d ! -perm -444 -exec $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1115 || chmod -R a+r $(DistDir)
1116
Reid Spencercc2d1e22004-10-30 09:19:36 +00001117# This is invoked by distdir target, define it as a no-op to avoid errors if not
1118# defined by user.
Reid Spencer151f8ba2004-10-25 08:27:37 +00001119dist-hook::
1120
Reid Spencere53e3972004-10-22 23:06:30 +00001121endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001122
1123###############################################################################
Reid Spencere5487ba2004-10-24 07:53:21 +00001124# TOP LEVEL - targets only to apply at the top level directory
1125###############################################################################
1126
1127ifeq ($(LEVEL),.)
1128
1129#------------------------------------------------------------------------
Reid Spencere5487ba2004-10-24 07:53:21 +00001130# Install support for project's include files:
1131#------------------------------------------------------------------------
1132install-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001133 $(Echo) Installing include files
1134 $(Verb) $(MKDIR) $(includedir)
1135 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencere5487ba2004-10-24 07:53:21 +00001136 cd $(BUILD_SRC_ROOT)/include && \
1137 find . -path '*/Internal' -prune -o '(' -type f \
1138 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1139 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1140 fi
1141
1142uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001143 $(Echo) Uninstalling include files
1144 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencere5487ba2004-10-24 07:53:21 +00001145 cd $(BUILD_SRC_ROOT)/include && \
1146 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1147 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1148 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1149 fi
1150
Reid Spencere5487ba2004-10-24 07:53:21 +00001151endif
1152
Reid Spencer4d71b662004-10-22 21:01:56 +00001153#------------------------------------------------------------------------
1154# Print out the directories used for building
Reid Spencercc2d1e22004-10-30 09:19:36 +00001155#------------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001156printvars::
Reid Spencer9af3b292004-11-01 07:50:27 +00001157 $(Echo) "BuildMode : " '$(BuildMode)'
Reid Spencercc2d1e22004-10-30 09:19:36 +00001158 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1159 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1160 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1161 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1162 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1163 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1164 $(Echo) "libdir : " '$(libdir)'
1165 $(Echo) "bindir : " '$(bindir)'
1166 $(Echo) "sysconfdir : " '$(sysconfdir)'
1167 $(Echo) "bytecode_libdir: " '$(bytecode_libdir)'
1168 $(Echo) "UserTargets : " '$(UserTargets)'
1169 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1170 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1171 $(Echo) "ObjDir : " '$(ObjDir)'
1172 $(Echo) "LibDir : " '$(LibDir)'
1173 $(Echo) "ToolDir : " '$(ToolDir)'
1174 $(Echo) "TDFiles : " '$(TDFiles)'
1175 $(Echo) "INCFiles : " '$(INCFiles)'
1176 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1177 $(Echo) "Compile.C : " '$(Compile.C)'
1178 $(Echo) "Archive : " '$(Archive)'
Reid Spencer3d659492004-11-02 16:36:03 +00001179 $(Echo) "YaccFiles : " '$(YaccFiles)'
1180 $(Echo) "LexFiles : " '$(LexFiles)'