blob: 81bb53719a3288f7451eca66fedebb2dcbaec1f9 [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 Spencercc2d1e22004-10-30 09:19:36 +000022RecursiveTargets := all clean check install uninstall
23LocalTargets := all-local clean-local check-local install-local printvars \
24 uninstall-local
25TopLevelTargets := 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 Spencercc2d1e22004-10-30 09:19:36 +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 Spencer9411c642004-10-26 22:26:33 +0000134install:: install-local
135uninstall:: uninstall-local
136check-local:: all-local
137install-local:: all-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000138
139###############################################################################
140# VARIABLES: Set up various variables based on configuration data
141###############################################################################
142
143#--------------------------------------------------------------------
144# Variables derived from configuration we are building
Chris Lattner00950542001-06-06 20:29:01 +0000145#--------------------------------------------------------------------
146
Chris Lattner760da062003-03-14 20:25:22 +0000147ifdef ENABLE_PROFILING
Reid Spencer9af3b292004-11-01 07:50:27 +0000148 BuildMode := Profile
Reid Spencercc2d1e22004-10-30 09:19:36 +0000149 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
150 C.Flags := -O3 -DNDEBUG -pg
151 LD.Flags := -O3 -DNDEBUG -pg
Chris Lattner760da062003-03-14 20:25:22 +0000152else
153 ifdef ENABLE_OPTIMIZED
Reid Spencer9af3b292004-11-01 07:50:27 +0000154 BuildMode := Release
Reid Spencercc2d1e22004-10-30 09:19:36 +0000155 CXX.Flags := -O3 -DNDEBUG -finline-functions -felide-constructors -fomit-frame-pointer
156 C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
157 LD.Flags := -O3 -DNDEBUG
Chris Lattner760da062003-03-14 20:25:22 +0000158 else
Reid Spencer9af3b292004-11-01 07:50:27 +0000159 BuildMode := Debug
Reid Spencercc2d1e22004-10-30 09:19:36 +0000160 CXX.Flags := -g -D_DEBUG
161 C.Flags := -g -D_DEBUG
162 LD.Flags := -g -D_DEBUG
Reid Spencer4d71b662004-10-22 21:01:56 +0000163 KEEP_SYMBOLS := 1
Chris Lattner760da062003-03-14 20:25:22 +0000164 endif
165endif
166
Reid Spencercc2d1e22004-10-30 09:19:36 +0000167CXX.Flags += $(CXXFLAGS)
168C.Flags += $(CFLAGS)
169CPP.Flags += $(CPPFLAGS)
170LD.Flags += $(LDFLAGS)
171AR.Flags := cru
172LibTool.Flags := --tag=CXX
Reid Spencer3a561f52004-10-23 20:04:14 +0000173
174#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000175# Directory locations
Reid Spencer3a561f52004-10-23 20:04:14 +0000176#--------------------------------------------------------------------
Reid Spencer9af3b292004-11-01 07:50:27 +0000177ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
178LibDir := $(BUILD_OBJ_ROOT)/lib/$(BuildMode)
179ToolDir := $(BUILD_OBJ_ROOT)/tools/$(BuildMode)
180LLVMLibDir := $(LLVM_OBJ_ROOT)/lib/$(BuildMode)
181LLVMToolDir := $(LLVM_OBJ_ROOT)/tools/$(BuildMode)
John Criswell7a73b802003-06-30 21:59:07 +0000182
Reid Spencer3a561f52004-10-23 20:04:14 +0000183#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000184# Full Paths To Compiled Tools and Utilities
Reid Spencer3a561f52004-10-23 20:04:14 +0000185#--------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000186EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
187Echo := @$(EchoCmd)
188ifndef LIBTOOL
Reid Spencer4d71b662004-10-22 21:01:56 +0000189LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencercc2d1e22004-10-30 09:19:36 +0000190endif
191ifndef LLVMAS
192LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
193endif
194ifndef BURG
195BURG := $(LLVMToolDir)/burg$(EXEEXT)
196endif
197ifndef TBLGEN
198TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
199endif
200ifndef GCCLD
201GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
202endif
203ifndef LLVMGCC
204LLVMGCC := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/gcc
205endif
206ifndef LLVMGXX
207LLVMGXX := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/g++
208endif
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000209
Reid Spencer4d71b662004-10-22 21:01:56 +0000210# Need a better way to compute this.
Reid Spencercc2d1e22004-10-30 09:19:36 +0000211LLVMGCCLibDir := $(dir $(shell $(LLVMGCC) -print-file-name=libgcc.a))/
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000212
Reid Spencer3a561f52004-10-23 20:04:14 +0000213#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000214# Adjust to user's request
Reid Spencer3a561f52004-10-23 20:04:14 +0000215#--------------------------------------------------------------------
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000216
Reid Spencercc2d1e22004-10-30 09:19:36 +0000217# Adjust LIBTOOL flags for shared libraries, or not.
John Criswell82f4a5a2003-07-31 20:58:51 +0000218ifndef SHARED_LIBRARY
Reid Spencercc2d1e22004-10-30 09:19:36 +0000219 LibTool.Flags += --tag=disable-shared
Reid Spencer4d71b662004-10-22 21:01:56 +0000220else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000221 LD.Flags += -rpath $(LibDir)
John Criswell82f4a5a2003-07-31 20:58:51 +0000222endif
223
Reid Spencer3a561f52004-10-23 20:04:14 +0000224# Adjust settings for verbose mode
Chris Lattner760da062003-03-14 20:25:22 +0000225ifndef VERBOSE
Reid Spencercc2d1e22004-10-30 09:19:36 +0000226 Verb := @
227 LibTool.Flags += --silent
228 AR.Flags += >/dev/null 2>/dev/null
229 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
Reid Spencer151f8ba2004-10-25 08:27:37 +0000230else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000231 ConfigureScriptFLAGS :=
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000232endif
233
Vikram S. Advefeeae582002-09-18 11:55:13 +0000234# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000235ifndef KEEP_SYMBOLS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000236 Strip := $(PLATFORMSTRIPOPTS)
237 StripWarnMsg := "(without symbols)"
Vikram S. Advefeeae582002-09-18 11:55:13 +0000238endif
239
Reid Spencer3a561f52004-10-23 20:04:14 +0000240# Adjust linker flags for building an executable
Reid Spencer4d71b662004-10-22 21:01:56 +0000241ifdef TOOLNAME
Reid Spencercc2d1e22004-10-30 09:19:36 +0000242 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000243endif
244
Reid Spencer3a561f52004-10-23 20:04:14 +0000245#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000246# Options To Invoke Tools
Reid Spencer3a561f52004-10-23 20:04:14 +0000247#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000248
249CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
250
Reid Spencercc2d1e22004-10-30 09:19:36 +0000251LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
252CPP.Flags += -I$(BUILD_OBJ_DIR) \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000253 -I$(BUILD_SRC_DIR) \
254 -I$(BUILD_SRC_ROOT)/include \
255 -I$(BUILD_OBJ_ROOT)/include \
256 -I$(LLVM_OBJ_ROOT)/include \
257 -I$(LLVM_SRC_ROOT)/include \
258 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
Reid Spencer4d71b662004-10-22 21:01:56 +0000259
Reid Spencercc2d1e22004-10-30 09:19:36 +0000260Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
261LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
262BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
263Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
264LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
265BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
266Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
267 $(CompileCommonOpts) $(LD.Flags) $(Strip)
268Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencera69b1ea2004-10-28 09:15:28 +0000269 $(CompileCommonOpts)
Reid Spencer3a561f52004-10-23 20:04:14 +0000270BCLinkLib = $(LLVMGCC) -shared -nostdlib
Reid Spencercc2d1e22004-10-30 09:19:36 +0000271LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
Reid Spencer3a561f52004-10-23 20:04:14 +0000272Burg = $(BURG) -I $(BUILD_SRC_DIR)
273TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000274Archive = $(AR) $(AR.Flags)
Reid Spencer4d71b662004-10-22 21:01:56 +0000275ifdef RANLIB
Reid Spencer3a561f52004-10-23 20:04:14 +0000276Ranlib = $(RANLIB)
Reid Spencer4d71b662004-10-22 21:01:56 +0000277else
Reid Spencer3a561f52004-10-23 20:04:14 +0000278Ranlib = ranlib
John Criswell7a73b802003-06-30 21:59:07 +0000279endif
280
Chris Lattner00950542001-06-06 20:29:01 +0000281#----------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000282# Get the list of source files
283#----------------------------------------------------------
284ifndef SOURCES
Reid Spencercc2d1e22004-10-30 09:19:36 +0000285 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
286 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
287 $(BUILD_SRC_DIR)/*.l))
288else
289 Sources := $(SOURCES)
Reid Spencer4d71b662004-10-22 21:01:56 +0000290endif
291
292ifdef BUILT_SOURCES
Reid Spencercc2d1e22004-10-30 09:19:36 +0000293Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Vikram S. Advead9ea7e2002-10-14 16:40:04 +0000294endif
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000295
Reid Spencer3a561f52004-10-23 20:04:14 +0000296#----------------------------------------------------------
297# Types of objects that can be built from sources
298#----------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000299BaseNameSources := $(sort $(basename $(Sources)))
300ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
301ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
302ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
Reid Spencer3a561f52004-10-23 20:04:14 +0000303
304###############################################################################
305# DIRECTORIES: Handle recursive descent of directory structure
306###############################################################################
John Criswell82f4a5a2003-07-31 20:58:51 +0000307
Chris Lattner00950542001-06-06 20:29:01 +0000308#---------------------------------------------------------
Reid Spencera69b1ea2004-10-28 09:15:28 +0000309# Provide rules to make install dirs. This must be early
310# in the file so they get built before dependencies
311#---------------------------------------------------------
312
313$(bindir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000314 $(Verb) $(MKDIR) $(bindir)
Chris Lattnere4cb90f2004-11-01 06:14:59 +0000315
Reid Spencera69b1ea2004-10-28 09:15:28 +0000316$(libdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000317 $(Verb) $(MKDIR) $(libdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000318
319$(bytecode_libdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000320 $(Verb) $(MKDIR) $(bytecode_libdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000321
322$(sysconfdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000323 $(Verb) $(MKDIR) $(sysconfdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000324
Reid Spencercc2d1e22004-10-30 09:19:36 +0000325# To create other directories, as needed, and timestamp their creation
326%/.dir:
327 $(Verb) $(MKDIR) $* > /dev/null
328 @$(DATE) > $@
329
330.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(LLVMLibDir)/.dir
331.PRECIOUS: $(LLVMToolDir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000332
333#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000334# Handle the DIRS options for sequential construction
Chris Lattner00950542001-06-06 20:29:01 +0000335#---------------------------------------------------------
336
Reid Spencercc2d1e22004-10-30 09:19:36 +0000337SubDirs :=
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000338ifdef DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000339SubDirs += $(DIRS)
340$(RecursiveTargets)::
341 $(Verb) for dir in $(DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000342 if [ ! -f $$dir/Makefile ]; then \
343 $(MKDIR) $$dir; \
344 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
345 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000346 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000347 done
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000348endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000349
Reid Spencer3a561f52004-10-23 20:04:14 +0000350#---------------------------------------------------------
351# Handle the EXPERIMENTAL_DIRS options ensuring success
352# after each directory is built.
353#---------------------------------------------------------
354ifdef EXPERIMENTAL_DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000355$(RecursiveTargets)::
356 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer3a561f52004-10-23 20:04:14 +0000357 if [ ! -f $$dir/Makefile ]; then \
358 $(MKDIR) $$dir; \
359 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
360 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000361 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000362 done
363endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000364
Reid Spencer3a561f52004-10-23 20:04:14 +0000365#---------------------------------------------------------
366# Handle the PARALLEL_DIRS options for parallel construction
367#---------------------------------------------------------
368ifdef PARALLEL_DIRS
369
Reid Spencercc2d1e22004-10-30 09:19:36 +0000370SubDirs += $(PARALLEL_DIRS)
371
Reid Spencer3a561f52004-10-23 20:04:14 +0000372# Unfortunately, this list must be maintained if new
373# recursive targets are added.
Reid Spencercc2d1e22004-10-30 09:19:36 +0000374all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
375clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
376check :: $(addsuffix /.makecheck ,$(PARALLEL_DIRS))
377install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000378uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
379
Reid Spencercc2d1e22004-10-30 09:19:36 +0000380Parallel_Targets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer3a561f52004-10-23 20:04:14 +0000381
382$(Parallel_Targets) :
Reid Spencercc2d1e22004-10-30 09:19:36 +0000383 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencer4d71b662004-10-22 21:01:56 +0000384 $(MKDIR) $(@D); \
385 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswellb3866b62003-11-25 19:32:22 +0000386 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000387 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
Chris Lattner00950542001-06-06 20:29:01 +0000388endif
389
Reid Spencer3a561f52004-10-23 20:04:14 +0000390#---------------------------------------------------------
391# Handle the OPTIONAL_DIRS options for directores that may
392# or may not exist.
393#---------------------------------------------------------
John Criswell2a6530f2003-06-27 16:58:44 +0000394ifdef OPTIONAL_DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000395
Reid Spencercc2d1e22004-10-30 09:19:36 +0000396SubDirs += $(OPTIONAL_DIRS)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000397
Reid Spencercc2d1e22004-10-30 09:19:36 +0000398$(RecursiveTargets)::
399 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000400 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
401 if [ ! -f $$dir/Makefile ]; then \
402 $(MKDIR) $$dir; \
403 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
404 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000405 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000406 fi \
John Criswell2a6530f2003-06-27 16:58:44 +0000407 done
408endif
409
Reid Spencerfc945082004-08-20 09:20:05 +0000410#---------------------------------------------------------
411# Handle the CONFIG_FILES options
412#---------------------------------------------------------
413ifdef CONFIG_FILES
Reid Spencerfc945082004-08-20 09:20:05 +0000414
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000415install-local:: $(sysconfdir) $(CONFIG_FILES)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000416 $(Echo) Installing Configuration Files To $(sysconfdir)
417 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000418 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
Reid Spencerfc945082004-08-20 09:20:05 +0000419 done
Reid Spencer3a561f52004-10-23 20:04:14 +0000420
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000421uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000422 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
423 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000424 $(RM) -f $(sysconfdir)/$${file} ; \
Reid Spencere5487ba2004-10-24 07:53:21 +0000425 done
426
Reid Spencerfc945082004-08-20 09:20:05 +0000427endif
428
Reid Spencer3a561f52004-10-23 20:04:14 +0000429###############################################################################
430# Library Build Rules: Four ways to build a library
431###############################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000432
Brian Gaeke8abff792004-01-22 22:53:48 +0000433
Reid Spencer3a561f52004-10-23 20:04:14 +0000434# if we're building a library ...
Chris Lattner00950542001-06-06 20:29:01 +0000435ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000436
Chris Lattner2a548c52002-09-16 22:36:42 +0000437# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000438LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000439LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
440LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
441LibName.O := $(LibDir)/$(LIBRARYNAME).o
442LibName.BC := $(LibDir)/lib$(LIBRARYNAME).bc
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000443
Reid Spencer3a561f52004-10-23 20:04:14 +0000444#---------------------------------------------------------
445# Shared Library Targets:
446# If the user asked for a shared library to be built
447# with the SHARED_LIBRARY variable, then we provide
448# targets for building them.
449#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000450ifdef SHARED_LIBRARY
451
Reid Spencercc2d1e22004-10-30 09:19:36 +0000452all-local:: $(LibName.LA)
Reid Spencer4d71b662004-10-22 21:01:56 +0000453
Reid Spencercc2d1e22004-10-30 09:19:36 +0000454$(LibName.LA): $(BUILT_SOURCES) $(ObjectsLO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000455 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000456 $(Verb) $(Link) -o $@ $(ObjectsLO)
457 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencer3a561f52004-10-23 20:04:14 +0000458
459clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000460ifneq ($(strip $(LibName.LA)),)
461 $(Verb) $(RM) -f $(LibName.LA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000462endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000463
Reid Spencere5487ba2004-10-24 07:53:21 +0000464DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencer4d71b662004-10-22 21:01:56 +0000465
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000466install-local:: $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000467
Reid Spencercc2d1e22004-10-30 09:19:36 +0000468$(DestSharedLib): $(libdir) $(LibName.LA)
Reid Spencer9af3b292004-11-01 07:50:27 +0000469 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000470 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
471 $(Verb) $(LIBTOOL) --finish $(libdir)
Reid Spencere5487ba2004-10-24 07:53:21 +0000472
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000473uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000474 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000475 $(Verb) $(RM) -f $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000476
Reid Spencer4d71b662004-10-22 21:01:56 +0000477endif
478
Reid Spencer3a561f52004-10-23 20:04:14 +0000479#---------------------------------------------------------
480# Bytecode Library Targets:
481# If the user asked for a bytecode library to be built
482# with the BYTECODE_LIBRARY variable, then we provide
483# targets for building them.
484#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000485ifdef BYTECODE_LIBRARY
486
487ifdef EXPORTED_SYMBOL_LIST
488 BCLinkLib += -Xlinker -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
489else
490 ifdef EXPORTED_SYMBOL_FILE
491 BCLinkLib += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
492 else
493 BCLinkLib += -Xlinker -disable-internalize
494 endif
495endif
496
Reid Spencercc2d1e22004-10-30 09:19:36 +0000497all-local:: $(LibName.BC)
Reid Spencer4d71b662004-10-22 21:01:56 +0000498
Reid Spencercc2d1e22004-10-30 09:19:36 +0000499$(LibName.BC): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000500 $(Echo) Linking $(BuildMode) Bytecode Library $(notdir $@)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000501 $(Verb) $(BCLinkLib) -o $@ $(ObjectsBC)
Reid Spencer4d71b662004-10-22 21:01:56 +0000502
Reid Spencer3a561f52004-10-23 20:04:14 +0000503clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000504ifneq ($(strip $(LibName.BC)),)
505 $(Verb) $(RM) -f $(LibName.BC)
Reid Spencere5487ba2004-10-24 07:53:21 +0000506endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000507
Reid Spencere5487ba2004-10-24 07:53:21 +0000508DestBytecodeLib = $(bytecode_libdir)/lib$(LIBRARYNAME).bc
Reid Spencere45ebfa2004-10-26 07:09:33 +0000509
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000510install-local:: $(DestBytecodeLib)
Chris Lattner481cc7c2003-08-15 02:18:35 +0000511
Reid Spencercc2d1e22004-10-30 09:19:36 +0000512$(DestBytecodeLib): $(bytecode_libdir) $(LibName.BC)
Reid Spencer9af3b292004-11-01 07:50:27 +0000513 $(Echo) Installing $(BuildMode) Bytecode Library $(DestBytecodeLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000514 $(Verb) $(INSTALL) $(LibName.BC) $@
Reid Spencere5487ba2004-10-24 07:53:21 +0000515
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000516uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000517 $(Echo) Uninstalling $(BuildMode) Bytecode Library $(DestBytecodeLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000518 $(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000519
520endif
Vikram S. Adve60f56062002-08-02 18:34:12 +0000521
Reid Spencercc2d1e22004-10-30 09:19:36 +0000522#---------------------------------------------------------
523# ReLinked Library Targets:
524# If the user didn't explicitly forbid building a
525# relinked then we provide targets for building them.
526#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000527ifndef DONT_BUILD_RELINKED
Reid Spencer4d71b662004-10-22 21:01:56 +0000528
Reid Spencercc2d1e22004-10-30 09:19:36 +0000529all-local:: $(LibName.O)
530
531$(LibName.O): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000532 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000533 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencer4d71b662004-10-22 21:01:56 +0000534
Reid Spencer3a561f52004-10-23 20:04:14 +0000535clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000536ifneq ($(strip $(LibName.O)),)
537 $(Verb) $(RM) -f $(LibName.O)
Reid Spencere5487ba2004-10-24 07:53:21 +0000538endif
539
540DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
541
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000542install-local:: $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000543
Reid Spencercc2d1e22004-10-30 09:19:36 +0000544$(DestRelinkedLib): $(libdir) $(LibName.O)
Reid Spencer9af3b292004-11-01 07:50:27 +0000545 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000546 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000547
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000548uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000549 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000550 $(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000551
Chris Lattnere62dbe92002-07-23 17:56:16 +0000552endif
Chris Lattner760da062003-03-14 20:25:22 +0000553
Reid Spencercc2d1e22004-10-30 09:19:36 +0000554#---------------------------------------------------------
555# Archive Library Targets:
556# If the user wanted a regular archive library built,
557# then we provide targets for building them.
558#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000559ifdef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000560
Reid Spencercc2d1e22004-10-30 09:19:36 +0000561all-local:: $(LibName.A)
562
563$(LibName.A): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000564 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000565 $(Verb)$(RM) -f $@
566 $(Verb) $(Archive) $@ $(ObjectsO)
567 $(Verb) $(Ranlib) $@
Vikram S. Adve41e78912002-09-20 14:03:13 +0000568
Reid Spencer3a561f52004-10-23 20:04:14 +0000569clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000570ifneq ($(strip $(LibName.A)),)
571 $(Verb) $(RM) -f $(LibName.A)
Chris Lattner00950542001-06-06 20:29:01 +0000572endif
573
Reid Spencere5487ba2004-10-24 07:53:21 +0000574DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
575
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000576install-local:: $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000577
Reid Spencercc2d1e22004-10-30 09:19:36 +0000578$(DestArchiveLib): $(libdir) $(LibName.A)
Reid Spencer9af3b292004-11-01 07:50:27 +0000579 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000580 $(Verb) $(MKDIR) $(libdir)
581 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000582
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000583uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000584 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000585 $(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000586
587endif
588
589# endif LIBRARYNAME
Reid Spencer4d71b662004-10-22 21:01:56 +0000590endif
591
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000592###############################################################################
593# Tool Build Rules: Build executable tool based on TOOLNAME option
594###############################################################################
595
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000596ifdef TOOLNAME
597
Reid Spencercc2d1e22004-10-30 09:19:36 +0000598#---------------------------------------------------------
599# Set up variables for building a tool.
600#---------------------------------------------------------
601ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
602ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
603ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
604LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
605LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
606ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
607LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
608ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
609LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000610
Reid Spencercc2d1e22004-10-30 09:19:36 +0000611#---------------------------------------------------------
612# Handle optional compression libraries automatically
613#---------------------------------------------------------
614ExtraLibs := $(LIBS)
Reid Spencer4d71b662004-10-22 21:01:56 +0000615ifeq ($(HAVE_BZIP2),1)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000616ExtraLibs += -lbz2
Reid Spencer4d71b662004-10-22 21:01:56 +0000617endif
618ifeq ($(HAVE_ZLIB),1)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000619ExtraLibs += -lz
Reid Spencer4d71b662004-10-22 21:01:56 +0000620endif
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000621
Reid Spencercc2d1e22004-10-30 09:19:36 +0000622#---------------------------------------------------------
623# Tell make that we need to rebuild subdirectories before
624# we can link the tool. This affects things like LLI which
625# has library subdirectories.
626#---------------------------------------------------------
627$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000628
Reid Spencercc2d1e22004-10-30 09:19:36 +0000629#---------------------------------------------------------
630# Provide targets for building the tools
631#---------------------------------------------------------
632all-local:: $(ToolBuildPath)
John Criswell2a6530f2003-06-27 16:58:44 +0000633
Reid Spencer3a561f52004-10-23 20:04:14 +0000634clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000635ifneq ($(strip $(ToolBuildPath)),)
636 $(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencere5487ba2004-10-24 07:53:21 +0000637endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000638
Reid Spencercc2d1e22004-10-30 09:19:36 +0000639$(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)\
640 $(ToolDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000641 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000642 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
643 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
Reid Spencer9af3b292004-11-01 07:50:27 +0000644 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencere5487ba2004-10-24 07:53:21 +0000645
646DestTool = $(bindir)/$(TOOLNAME)
647
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000648install-local:: $(DestTool)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000649
Reid Spencercc2d1e22004-10-30 09:19:36 +0000650$(DestTool): $(bindir) $(ToolBuildPath)
Reid Spencer9af3b292004-11-01 07:50:27 +0000651 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000652 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000653
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000654uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000655 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000656 $(Verb) $(RM) -f $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000657
Reid Spencer4d71b662004-10-22 21:01:56 +0000658endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000659
Reid Spencercc2d1e22004-10-30 09:19:36 +0000660###############################################################################
661# Object Build Rules: Build object files based on sources
662###############################################################################
663
664# Provide rule sets for when dependency generation is enabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000665ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve41e78912002-09-20 14:03:13 +0000666
Reid Spencercc2d1e22004-10-30 09:19:36 +0000667#---------------------------------------------------------
668# Create .lo files in the ObjDir directory from the .cpp and .c files...
669#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000670ifdef SHARED_LIBRARY
671
Reid Spencercc2d1e22004-10-30 09:19:36 +0000672$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000673 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000674 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
675 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
676 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000677
Reid Spencercc2d1e22004-10-30 09:19:36 +0000678$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000679 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000680 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
681 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
682 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000683
Reid Spencercc2d1e22004-10-30 09:19:36 +0000684#---------------------------------------------------------
685# Create .o files in the ObjDir directory from the .cpp and .c files...
686#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000687else
Reid Spencer4d71b662004-10-22 21:01:56 +0000688
Reid Spencercc2d1e22004-10-30 09:19:36 +0000689$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000690 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000691 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
692 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
693 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000694
Reid Spencercc2d1e22004-10-30 09:19:36 +0000695$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000696 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000697 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
698 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
699 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000700
701endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000702
Reid Spencercc2d1e22004-10-30 09:19:36 +0000703#---------------------------------------------------------
704# Create .bc files in the ObjDir directory from .cpp and .c files...
705#---------------------------------------------------------
706$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000707 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000708 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
709 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
710 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000711
Reid Spencercc2d1e22004-10-30 09:19:36 +0000712$(ObjDir)/%.bc: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000713 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000714 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
715 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
716 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000717
Reid Spencercc2d1e22004-10-30 09:19:36 +0000718# Provide alternate rule sets if dependencies are disabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000719else
720
Reid Spencer3a561f52004-10-23 20:04:14 +0000721ifdef SHARED_LIBRARY
722
Reid Spencercc2d1e22004-10-30 09:19:36 +0000723$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000724 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000725 $(LTCompile.CXX) $< -o $@
726
Reid Spencercc2d1e22004-10-30 09:19:36 +0000727$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000728 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000729 $(LTCompile.C) $< -o $@
730
731else
Reid Spencer4d71b662004-10-22 21:01:56 +0000732
Reid Spencercc2d1e22004-10-30 09:19:36 +0000733$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000734 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +0000735 $(Compile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000736
Reid Spencercc2d1e22004-10-30 09:19:36 +0000737$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000738 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +0000739 $(Compile.C) $< -o $@
740endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000741
Reid Spencercc2d1e22004-10-30 09:19:36 +0000742$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000743 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencer8676b7e2004-10-31 18:52:15 +0000744 $(BCCompile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000745
Reid Spencercc2d1e22004-10-30 09:19:36 +0000746$(ObjDir)/%.bc: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000747 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencer8676b7e2004-10-31 18:52:15 +0000748 $(BCCompile.C) $< -o $@
Brian Gaeke44909cf2003-12-10 00:26:28 +0000749
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000750endif
751
Reid Spencercc2d1e22004-10-30 09:19:36 +0000752#---------------------------------------------------------
753# Provide rule to build .bc files from .ll sources,
754# regardless of dependencies
755#---------------------------------------------------------
756$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000757 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000758 $(Verb) $(LLVMAS) $< -f -o $@
759
760###############################################################################
761# TABLEGEN: Provide rules for running tblgen to produce *.inc files
762###############################################################################
Chris Lattner481cc7c2003-08-15 02:18:35 +0000763
Reid Spencer4d71b662004-10-22 21:01:56 +0000764ifdef TARGET
765
Reid Spencercc2d1e22004-10-30 09:19:36 +0000766TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
767INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Reid Spencer4d71b662004-10-22 21:01:56 +0000768
Reid Spencercc2d1e22004-10-30 09:19:36 +0000769$(INCFiles) : $(TBLGEN) $(TDFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +0000770
Reid Spencer16544482004-10-27 04:34:35 +0000771%GenRegisterNames.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000772 $(Echo) "Building $(<F) register names with tblgen"
773 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000774
Reid Spencer16544482004-10-27 04:34:35 +0000775%GenRegisterInfo.h.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000776 $(Echo) "Building $(<F) register information header with tblgen"
777 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000778
779%GenRegisterInfo.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000780 $(Echo) "Building $(<F) register info implementation with tblgen"
781 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000782
783%GenInstrNames.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000784 $(Echo) "Building $(<F) instruction names with tblgen"
785 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000786
787%GenInstrInfo.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000788 $(Echo) "Building $(<F) instruction information with tblgen"
789 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000790
791%GenAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000792 $(Echo) "Building $(<F) assembly writer with tblgen"
793 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000794
795%GenATTAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000796 $(Echo) "Building $(<F) AT&T assembly writer with tblgen"
797 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000798
799%GenIntelAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000800 $(Echo) "Building $(<F) Intel assembly writer with tblgen"
801 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000802
803%GenInstrSelector.inc: %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000804 $(Echo) "Building $(<F) instruction selector with tblgen"
805 $(Verb) $(TableGen) -gen-instr-selector -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000806
807%GenCodeEmitter.inc:: %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000808 $(Echo) "Building $(<F) code emitter with tblgen"
809 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000810
Reid Spencer3a561f52004-10-23 20:04:14 +0000811clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000812 $(Verb) $(RM) -f $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +0000813
814endif
Chris Lattner481cc7c2003-08-15 02:18:35 +0000815
Reid Spencercc2d1e22004-10-30 09:19:36 +0000816###############################################################################
817# LEX AND YACC: Provide rules for generating sources with lex and yacc
818###############################################################################
Chris Lattnere8996782003-01-16 22:44:19 +0000819
Reid Spencercc2d1e22004-10-30 09:19:36 +0000820#---------------------------------------------------------
821# Provide rules for generating a .cpp source file from
822# (f)lex input sources.
823#---------------------------------------------------------
824
825LexOutput := $(strip $(subst %.l,%.cpp,$(filter %.l,$(Sources))))
826
827ifneq ($(LexOutput),)
828
829.PRECIOUS: $(LexOutput)
830
831# Note the extra sed filtering here, used to cut down on the warnings emited
832# by GCC. The last line is a gross hack to work around flex aparently not
833# being able to resize the buffer on a large token input. Currently, for
834# uninitialized string buffers in LLVM we can generate very long tokens, so
835# this is a hack around it.
Chris Lattnerb7dc2b92003-08-15 20:00:47 +0000836# FIXME. (f.e. char Buffer[10000] )
Chris Lattner00950542001-06-06 20:29:01 +0000837%.cpp: %.l
Reid Spencercc2d1e22004-10-30 09:19:36 +0000838 $(Echo) Flexing $<
839 $(Verb) $(FLEX) -t $< | \
Reid Spencer4d71b662004-10-22 21:01:56 +0000840 $(SED) 's/void yyunput/inline void yyunput/' | \
841 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
842 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencer80f0ef72004-10-28 00:41:43 +0000843 > $@
Chris Lattner00950542001-06-06 20:29:01 +0000844
Reid Spencer9af3b292004-11-01 07:50:27 +0000845clean-local::
846 $(RM) -f $(LexOutput)
847
Reid Spencercc2d1e22004-10-30 09:19:36 +0000848endif
849
850#---------------------------------------------------------
851# Provide rules for generating a .cpp and .h source files
852# from yacc (bison) input sources.
853#---------------------------------------------------------
854
855YaccOutput := $(strip $(addprefix $(subst %.y,%,$(filter %.y,$(Sources))),\
856 .h .cpp .output))
857
858ifneq ($(YaccOutput),)
859
860.PRECIOUS: $(YaccOutput)
861
862# Cancel built-in rules for yacc
863%.c: %.y
864%.cpp: %.y
865%.h: %.y
866
Chris Lattner00950542001-06-06 20:29:01 +0000867# Rule for building the bison parsers...
Chris Lattner00950542001-06-06 20:29:01 +0000868%.cpp %.h : %.y
Reid Spencercc2d1e22004-10-30 09:19:36 +0000869 $(Echo) "Bisoning $*.y"
870 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
871 $(Verb) $(MV) -f $*.tab.c $*.cpp
872 $(Verb) $(MV) -f $*.tab.h $*.h
Chris Lattner00950542001-06-06 20:29:01 +0000873
Reid Spencer9af3b292004-11-01 07:50:27 +0000874clean-local::
875 $(RM) -f $(YaccOutput)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000876endif
Chris Lattner00950542001-06-06 20:29:01 +0000877
Reid Spencercc2d1e22004-10-30 09:19:36 +0000878###############################################################################
879# OTHER RULES: Other rules needed
880###############################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +0000881
Chris Lattner30440c62003-01-16 21:06:18 +0000882# To create postscript files from dot files...
John Criswelle0f9ac62003-10-02 19:02:02 +0000883ifneq ($(DOT),false)
Chris Lattner30440c62003-01-16 21:06:18 +0000884%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +0000885 $(DOT) -Tps < $< > $@
John Criswell7a73b802003-06-30 21:59:07 +0000886else
887%.ps: %.dot
Reid Spencercc2d1e22004-10-30 09:19:36 +0000888 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell7a73b802003-06-30 21:59:07 +0000889endif
Chris Lattner30440c62003-01-16 21:06:18 +0000890
John Criswell7f336952003-09-06 14:44:17 +0000891# This rules ensures that header files that are removed still have a rule for
892# which they can be "generated." This allows make to ignore them and
893# reproduce the dependency lists.
John Criswell4b6e5d12003-09-18 18:37:08 +0000894%.h:: ;
John Criswell7f336952003-09-06 14:44:17 +0000895
Reid Spencercc2d1e22004-10-30 09:19:36 +0000896# Define clean-local to clean the current directory. Note that this uses a
897# very conservative approach ensuring that empty variables do not cause
898# errors or disastrous removal.
Reid Spencer3a561f52004-10-23 20:04:14 +0000899clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000900ifneq ($(strip $(ObjDir)),)
901 $(Verb) $(RM) -rf $(ObjDir)
Reid Spencere5487ba2004-10-24 07:53:21 +0000902endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000903 $(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke9d3cd402004-01-21 19:53:11 +0000904ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencercc2d1e22004-10-30 09:19:36 +0000905 $(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke9d3cd402004-01-21 19:53:11 +0000906endif
John Criswell7a73b802003-06-30 21:59:07 +0000907
Reid Spencercc2d1e22004-10-30 09:19:36 +0000908# Build tags database for Emacs/Xemacs:
909tags:: TAGS
910TAGS:
911 find include lib tools examples -name '*.cpp' -o -name '*.h' | \
912 $(ETAGS) $(ETAGSFLAGS) -
913
Reid Spencer3a561f52004-10-23 20:04:14 +0000914###############################################################################
915# DEPENDENCIES: Include the dependency files if we should
916###############################################################################
Chris Lattner33ad24a2003-08-22 14:10:16 +0000917ifndef DISABLE_AUTO_DEPENDENCIES
918
Reid Spencer3a561f52004-10-23 20:04:14 +0000919# If its not one of the cleaning targets
Reid Spencercc2d1e22004-10-30 09:19:36 +0000920ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencer4d71b662004-10-22 21:01:56 +0000921
Reid Spencer3a561f52004-10-23 20:04:14 +0000922# Get the list of dependency files
Reid Spencercc2d1e22004-10-30 09:19:36 +0000923DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Reid Spencer9af3b292004-11-01 07:50:27 +0000924DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
Misha Brukman4f7a8cf2003-11-09 21:36:19 +0000925
Reid Spencer3a561f52004-10-23 20:04:14 +0000926-include /dev/null $(DependFiles)
927
John Criswelld741bcf2003-08-12 18:51:51 +0000928endif
Chris Lattner1ddb6b62003-08-18 17:27:40 +0000929
Reid Spencercc2d1e22004-10-30 09:19:36 +0000930endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000931
Reid Spencer151f8ba2004-10-25 08:27:37 +0000932###############################################################################
Reid Spencercc2d1e22004-10-30 09:19:36 +0000933# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer151f8ba2004-10-25 08:27:37 +0000934###############################################################################
935
Reid Spencere45ebfa2004-10-26 07:09:33 +0000936#------------------------------------------------------------------------
937# Define distribution related variables
938#------------------------------------------------------------------------
Reid Spencer151f8ba2004-10-25 08:27:37 +0000939DistName := $(LLVM_TARBALL_NAME)
940DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000941TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000942DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
943DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
944DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
945DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
946 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencere45ebfa2004-10-26 07:09:33 +0000947 Makefile.config.in configure autoconf
948DistOther := $(notdir $(wildcard \
949 $(BUILD_SRC_DIR)/*.h \
950 $(BUILD_SRC_DIR)/*.td \
951 $(BUILD_SRC_DIR)/*.def \
952 $(BUILD_SRC_DIR)/*.ll \
953 $(BUILD_SRC_DIR)/*.in))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000954DistSources := $(Sources) $(EXTRA_DIST)
955DistSubDirs := $(SubDirs)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000956DistFiles := $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000957
Reid Spencere45ebfa2004-10-26 07:09:33 +0000958#------------------------------------------------------------------------
959# We MUST build distribution with OBJ_DIR != SRC_DIR
960#------------------------------------------------------------------------
961ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
962dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000963 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencere45ebfa2004-10-26 07:09:33 +0000964
965DistCheckTop :=
966else
967
968DistCheckTop := check
Reid Spencercc2d1e22004-10-30 09:19:36 +0000969
Reid Spencere45ebfa2004-10-26 07:09:33 +0000970#------------------------------------------------------------------------
971# Prevent catastrophic remove
972#------------------------------------------------------------------------
973ifeq ($(LLVM_TARBALL_NAME),)
974$(error LLVM_TARBALL_NAME is empty. Please rerun configure)
975endif
976
977#------------------------------------------------------------------------
978# Prevent attempt to run dist targets from anywhere but the top level
979#------------------------------------------------------------------------
980ifneq ($(LEVEL),.)
981
982dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000983 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000984
985else
986
987#------------------------------------------------------------------------
988# Provide the top level targets
989#------------------------------------------------------------------------
990
Reid Spencercc2d1e22004-10-30 09:19:36 +0000991dist-gzip:: $(DistTarGZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000992
993$(DistTarGZip) : distdir
Reid Spencercc2d1e22004-10-30 09:19:36 +0000994 $(Echo) Packing gzipped distribution tar file.
995 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | gzip -c > "$(DistTarGZip)"
Reid Spencere45ebfa2004-10-26 07:09:33 +0000996
Reid Spencercc2d1e22004-10-30 09:19:36 +0000997dist-bzip2:: $(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000998
999$(DistTarBZ2) : distdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001000 $(Echo) Packing bzipped distribution tar file.
1001 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | $(BZIP2) -c >$(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001002
Reid Spencercc2d1e22004-10-30 09:19:36 +00001003dist-zip:: $(DistZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001004
1005$(DistZip) : distdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001006 $(Echo) Packing zipped distribution file.
1007 $(Verb) rm -f $(DistZip)
1008 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001009
1010dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001011 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001012
1013DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1014
Reid Spencer9411c642004-10-26 22:26:33 +00001015dist-check:: $(DistCheckTop) $(DistTarGZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001016 $(Echo) Checking distribution tar file.
1017 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001018 $(RM) -rf $(DistCheckDir) ; \
1019 fi
Reid Spencercc2d1e22004-10-30 09:19:36 +00001020 $(Verb) $(MKDIR) $(DistCheckDir)
1021 $(Verb) cd $(DistCheckDir) && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001022 $(MKDIR) $(DistCheckDir)/build && \
1023 $(MKDIR) $(DistCheckDir)/install && \
1024 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1025 cd build && \
1026 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1027 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
1028 $(MAKE) check && \
1029 $(MAKE) install && \
1030 $(MAKE) uninstall && \
1031 $(MAKE) dist && \
1032 $(MAKE) clean && \
1033 $(MAKE) dist-clean && \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001034 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001035
1036dist-clean::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001037 $(Echo) Cleaning distribution files
1038 $(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) $(DistCheckDir)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001039
1040endif
1041
1042#------------------------------------------------------------------------
1043# Provide the recursive distdir target for building the distribution directory
1044#------------------------------------------------------------------------
Reid Spencer9411c642004-10-26 22:26:33 +00001045distdir : $(DistSources)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001046 $(Echo) Building Distribution Directory $(DistDir)
1047 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001048 if test -d "$(DistDir)" ; then \
1049 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1050 exit 1 ; \
1051 fi ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001052 $(EchoCmd) Removing $(DistDir) ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001053 $(RM) -rf $(DistDir); \
1054 fi
Reid Spencercc2d1e22004-10-30 09:19:36 +00001055 $(Verb) $(MKDIR) $(DistDir)
1056 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001057 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1058 for file in $(DistFiles) ; do \
1059 case "$$file" in \
1060 $(BUILD_SRC_DIR)/*) file=`echo "$$file" | sed "s#^$$srcdirstrip/##"`;; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001061 $(BUILD_SRC_ROOT)/*) file=`echo "$$file" | sed "s#^$$srcrootstrip/#$(BUILD_OBJ_ROOT)/#"`;; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001062 esac; \
1063 if test -f "$$file" || test -d "$$file" ; then \
1064 from_dir=. ; \
1065 else \
1066 from_dir=$(BUILD_SRC_DIR); \
1067 fi; \
1068 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'`; \
1069 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1070 to_dir="$(DistDir)/$$dir"; \
1071 $(MKDIR) "$$to_dir" ; \
1072 else \
1073 to_dir="$(DistDir)"; \
1074 fi; \
1075 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1076 if test -n "$$mid_dir" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001077 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001078 fi ; \
1079 if test -d "$$from_dir/$$file"; then \
1080 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1081 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1082 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1083 fi; \
1084 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1085 elif test -f "$$from_dir/$$file" ; then \
1086 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1087 elif test -L "$$from_dir/$$file" ; then \
1088 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1089 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001090 $(EchoCmd) "===== WARNING: Distribution Source $$from_dir/$$file Not Found!" ; \
1091 elif test "$(Verb)" != '@' ; then \
1092 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001093 fi; \
1094 done
Reid Spencercc2d1e22004-10-30 09:19:36 +00001095 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001096 if test "$$subdir" \!= "." ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001097 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001098 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1099 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001100 fi; \
1101 done
Reid Spencercc2d1e22004-10-30 09:19:36 +00001102 $(Verb) $(MAKE) DistDir="$(DistDir)" dist-hook || exit 1
1103 -$(Verb) find $(DistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001104 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
1105 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
1106 ! -type d ! -perm -444 -exec $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1107 || chmod -R a+r $(DistDir)
1108
Reid Spencercc2d1e22004-10-30 09:19:36 +00001109# This is invoked by distdir target, define it as a no-op to avoid errors if not
1110# defined by user.
Reid Spencer151f8ba2004-10-25 08:27:37 +00001111dist-hook::
1112
Reid Spencere53e3972004-10-22 23:06:30 +00001113endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001114
1115###############################################################################
Reid Spencere5487ba2004-10-24 07:53:21 +00001116# TOP LEVEL - targets only to apply at the top level directory
1117###############################################################################
1118
1119ifeq ($(LEVEL),.)
1120
1121#------------------------------------------------------------------------
Reid Spencere5487ba2004-10-24 07:53:21 +00001122# Install support for project's include files:
1123#------------------------------------------------------------------------
1124install-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001125 $(Echo) Installing include files
1126 $(Verb) $(MKDIR) $(includedir)
1127 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencere5487ba2004-10-24 07:53:21 +00001128 cd $(BUILD_SRC_ROOT)/include && \
1129 find . -path '*/Internal' -prune -o '(' -type f \
1130 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1131 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1132 fi
1133
1134uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001135 $(Echo) Uninstalling include files
1136 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencere5487ba2004-10-24 07:53:21 +00001137 cd $(BUILD_SRC_ROOT)/include && \
1138 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1139 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1140 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1141 fi
1142
Reid Spencere5487ba2004-10-24 07:53:21 +00001143endif
1144
Reid Spencer4d71b662004-10-22 21:01:56 +00001145#------------------------------------------------------------------------
1146# Print out the directories used for building
Reid Spencercc2d1e22004-10-30 09:19:36 +00001147#------------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001148printvars::
Reid Spencer9af3b292004-11-01 07:50:27 +00001149 $(Echo) "BuildMode : " '$(BuildMode)'
Reid Spencercc2d1e22004-10-30 09:19:36 +00001150 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1151 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1152 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1153 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1154 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1155 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1156 $(Echo) "libdir : " '$(libdir)'
1157 $(Echo) "bindir : " '$(bindir)'
1158 $(Echo) "sysconfdir : " '$(sysconfdir)'
1159 $(Echo) "bytecode_libdir: " '$(bytecode_libdir)'
1160 $(Echo) "UserTargets : " '$(UserTargets)'
1161 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1162 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1163 $(Echo) "ObjDir : " '$(ObjDir)'
1164 $(Echo) "LibDir : " '$(LibDir)'
1165 $(Echo) "ToolDir : " '$(ToolDir)'
1166 $(Echo) "TDFiles : " '$(TDFiles)'
1167 $(Echo) "INCFiles : " '$(INCFiles)'
1168 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1169 $(Echo) "Compile.C : " '$(Compile.C)'
1170 $(Echo) "Archive : " '$(Archive)'