blob: bc893a4552e4343683283f88534769abb7aa0994 [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 Spencercceed9f2004-11-08 17:32:12 +0000225ifdef TOOL_VERBOSE
226 C.Flags += -v
227 CXX.Flags += -v
228 LD.Flags += -v
229 BCLinkLib.Flags += -v
230 VERBOSE := 1
231endif
232
Reid Spencer3a561f52004-10-23 20:04:14 +0000233# Adjust settings for verbose mode
Chris Lattner760da062003-03-14 20:25:22 +0000234ifndef VERBOSE
Reid Spencercc2d1e22004-10-30 09:19:36 +0000235 Verb := @
236 LibTool.Flags += --silent
237 AR.Flags += >/dev/null 2>/dev/null
238 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
Reid Spencer151f8ba2004-10-25 08:27:37 +0000239else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000240 ConfigureScriptFLAGS :=
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000241endif
242
Vikram S. Advefeeae582002-09-18 11:55:13 +0000243# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000244ifndef KEEP_SYMBOLS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000245 Strip := $(PLATFORMSTRIPOPTS)
246 StripWarnMsg := "(without symbols)"
Vikram S. Advefeeae582002-09-18 11:55:13 +0000247endif
248
Reid Spencer3a561f52004-10-23 20:04:14 +0000249# Adjust linker flags for building an executable
Reid Spencer4d71b662004-10-22 21:01:56 +0000250ifdef TOOLNAME
Reid Spencercc2d1e22004-10-30 09:19:36 +0000251 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000252endif
253
Reid Spencer3a561f52004-10-23 20:04:14 +0000254#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000255# Options To Invoke Tools
Reid Spencer3a561f52004-10-23 20:04:14 +0000256#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000257
258CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
259
Reid Spencercc2d1e22004-10-30 09:19:36 +0000260LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
261CPP.Flags += -I$(BUILD_OBJ_DIR) \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000262 -I$(BUILD_SRC_DIR) \
263 -I$(BUILD_SRC_ROOT)/include \
264 -I$(BUILD_OBJ_ROOT)/include \
265 -I$(LLVM_OBJ_ROOT)/include \
266 -I$(LLVM_SRC_ROOT)/include \
267 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
Reid Spencer4d71b662004-10-22 21:01:56 +0000268
Reid Spencercc2d1e22004-10-30 09:19:36 +0000269Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
270LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
271BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
272Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
273LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
274BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
275Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
276 $(CompileCommonOpts) $(LD.Flags) $(Strip)
277Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencera69b1ea2004-10-28 09:15:28 +0000278 $(CompileCommonOpts)
Reid Spencercceed9f2004-11-08 17:32:12 +0000279BCLinkLib = $(LLVMGCC) -shared -nostdlib $(BCLinkLib.Flags)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000280LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
Reid Spencer3a561f52004-10-23 20:04:14 +0000281Burg = $(BURG) -I $(BUILD_SRC_DIR)
282TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000283Archive = $(AR) $(AR.Flags)
Reid Spencer4d71b662004-10-22 21:01:56 +0000284ifdef RANLIB
Reid Spencer3a561f52004-10-23 20:04:14 +0000285Ranlib = $(RANLIB)
Reid Spencer4d71b662004-10-22 21:01:56 +0000286else
Reid Spencer3a561f52004-10-23 20:04:14 +0000287Ranlib = ranlib
John Criswell7a73b802003-06-30 21:59:07 +0000288endif
289
Chris Lattner00950542001-06-06 20:29:01 +0000290#----------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000291# Get the list of source files
292#----------------------------------------------------------
293ifndef SOURCES
Reid Spencercc2d1e22004-10-30 09:19:36 +0000294 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
295 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
296 $(BUILD_SRC_DIR)/*.l))
297else
298 Sources := $(SOURCES)
Reid Spencer4d71b662004-10-22 21:01:56 +0000299endif
300
301ifdef BUILT_SOURCES
Reid Spencercc2d1e22004-10-30 09:19:36 +0000302Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Vikram S. Advead9ea7e2002-10-14 16:40:04 +0000303endif
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000304
Reid Spencer3a561f52004-10-23 20:04:14 +0000305#----------------------------------------------------------
306# Types of objects that can be built from sources
307#----------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000308BaseNameSources := $(sort $(basename $(Sources)))
309ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
310ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
311ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
Reid Spencer3a561f52004-10-23 20:04:14 +0000312
313###############################################################################
314# DIRECTORIES: Handle recursive descent of directory structure
315###############################################################################
John Criswell82f4a5a2003-07-31 20:58:51 +0000316
Chris Lattner00950542001-06-06 20:29:01 +0000317#---------------------------------------------------------
Reid Spencera69b1ea2004-10-28 09:15:28 +0000318# Provide rules to make install dirs. This must be early
319# in the file so they get built before dependencies
320#---------------------------------------------------------
321
322$(bindir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000323 $(Verb) $(MKDIR) $(bindir)
Chris Lattnere4cb90f2004-11-01 06:14:59 +0000324
Reid Spencera69b1ea2004-10-28 09:15:28 +0000325$(libdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000326 $(Verb) $(MKDIR) $(libdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000327
328$(bytecode_libdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000329 $(Verb) $(MKDIR) $(bytecode_libdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000330
331$(sysconfdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000332 $(Verb) $(MKDIR) $(sysconfdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000333
Reid Spencercc2d1e22004-10-30 09:19:36 +0000334# To create other directories, as needed, and timestamp their creation
335%/.dir:
336 $(Verb) $(MKDIR) $* > /dev/null
337 @$(DATE) > $@
338
339.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(LLVMLibDir)/.dir
340.PRECIOUS: $(LLVMToolDir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000341
342#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000343# Handle the DIRS options for sequential construction
Chris Lattner00950542001-06-06 20:29:01 +0000344#---------------------------------------------------------
345
Reid Spencercc2d1e22004-10-30 09:19:36 +0000346SubDirs :=
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000347ifdef DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000348SubDirs += $(DIRS)
349$(RecursiveTargets)::
350 $(Verb) for dir in $(DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000351 if [ ! -f $$dir/Makefile ]; then \
352 $(MKDIR) $$dir; \
353 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
354 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000355 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000356 done
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000357endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000358
Reid Spencer3a561f52004-10-23 20:04:14 +0000359#---------------------------------------------------------
360# Handle the EXPERIMENTAL_DIRS options ensuring success
361# after each directory is built.
362#---------------------------------------------------------
363ifdef EXPERIMENTAL_DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000364$(RecursiveTargets)::
365 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer3a561f52004-10-23 20:04:14 +0000366 if [ ! -f $$dir/Makefile ]; then \
367 $(MKDIR) $$dir; \
368 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
369 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000370 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000371 done
372endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000373
Reid Spencer3a561f52004-10-23 20:04:14 +0000374#---------------------------------------------------------
375# Handle the PARALLEL_DIRS options for parallel construction
376#---------------------------------------------------------
377ifdef PARALLEL_DIRS
378
Reid Spencercc2d1e22004-10-30 09:19:36 +0000379SubDirs += $(PARALLEL_DIRS)
380
Reid Spencer3a561f52004-10-23 20:04:14 +0000381# Unfortunately, this list must be maintained if new
382# recursive targets are added.
Reid Spencercc2d1e22004-10-30 09:19:36 +0000383all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
384clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000385clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000386check :: $(addsuffix /.makecheck ,$(PARALLEL_DIRS))
387install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000388uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
389
Reid Spencercc2d1e22004-10-30 09:19:36 +0000390Parallel_Targets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer3a561f52004-10-23 20:04:14 +0000391
392$(Parallel_Targets) :
Reid Spencercc2d1e22004-10-30 09:19:36 +0000393 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencer4d71b662004-10-22 21:01:56 +0000394 $(MKDIR) $(@D); \
395 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswellb3866b62003-11-25 19:32:22 +0000396 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000397 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
Chris Lattner00950542001-06-06 20:29:01 +0000398endif
399
Reid Spencer3a561f52004-10-23 20:04:14 +0000400#---------------------------------------------------------
401# Handle the OPTIONAL_DIRS options for directores that may
402# or may not exist.
403#---------------------------------------------------------
John Criswell2a6530f2003-06-27 16:58:44 +0000404ifdef OPTIONAL_DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000405
Reid Spencercc2d1e22004-10-30 09:19:36 +0000406SubDirs += $(OPTIONAL_DIRS)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000407
Reid Spencercc2d1e22004-10-30 09:19:36 +0000408$(RecursiveTargets)::
409 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000410 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
411 if [ ! -f $$dir/Makefile ]; then \
412 $(MKDIR) $$dir; \
413 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
414 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000415 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000416 fi \
John Criswell2a6530f2003-06-27 16:58:44 +0000417 done
418endif
419
Reid Spencerfc945082004-08-20 09:20:05 +0000420#---------------------------------------------------------
421# Handle the CONFIG_FILES options
422#---------------------------------------------------------
423ifdef CONFIG_FILES
Reid Spencerfc945082004-08-20 09:20:05 +0000424
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000425install-local:: $(sysconfdir) $(CONFIG_FILES)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000426 $(Echo) Installing Configuration Files To $(sysconfdir)
427 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000428 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
Reid Spencerfc945082004-08-20 09:20:05 +0000429 done
Reid Spencer3a561f52004-10-23 20:04:14 +0000430
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000431uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000432 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
433 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000434 $(RM) -f $(sysconfdir)/$${file} ; \
Reid Spencere5487ba2004-10-24 07:53:21 +0000435 done
436
Reid Spencerfc945082004-08-20 09:20:05 +0000437endif
438
Reid Spencer3a561f52004-10-23 20:04:14 +0000439###############################################################################
440# Library Build Rules: Four ways to build a library
441###############################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000442
Brian Gaeke8abff792004-01-22 22:53:48 +0000443
Reid Spencer3a561f52004-10-23 20:04:14 +0000444# if we're building a library ...
Chris Lattner00950542001-06-06 20:29:01 +0000445ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000446
Chris Lattner2a548c52002-09-16 22:36:42 +0000447# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000448LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000449LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
450LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
451LibName.O := $(LibDir)/$(LIBRARYNAME).o
452LibName.BC := $(LibDir)/lib$(LIBRARYNAME).bc
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000453
Reid Spencer3a561f52004-10-23 20:04:14 +0000454#---------------------------------------------------------
455# Shared Library Targets:
456# If the user asked for a shared library to be built
457# with the SHARED_LIBRARY variable, then we provide
458# targets for building them.
459#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000460ifdef SHARED_LIBRARY
461
Reid Spencercc2d1e22004-10-30 09:19:36 +0000462all-local:: $(LibName.LA)
Reid Spencer4d71b662004-10-22 21:01:56 +0000463
Reid Spencercc2d1e22004-10-30 09:19:36 +0000464$(LibName.LA): $(BUILT_SOURCES) $(ObjectsLO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000465 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000466 $(Verb) $(Link) -o $@ $(ObjectsLO)
467 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencer3a561f52004-10-23 20:04:14 +0000468
469clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000470ifneq ($(strip $(LibName.LA)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000471 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000472endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000473
Reid Spencere5487ba2004-10-24 07:53:21 +0000474DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencer4d71b662004-10-22 21:01:56 +0000475
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000476install-local:: $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000477
Reid Spencercc2d1e22004-10-30 09:19:36 +0000478$(DestSharedLib): $(libdir) $(LibName.LA)
Reid Spencer9af3b292004-11-01 07:50:27 +0000479 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000480 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
481 $(Verb) $(LIBTOOL) --finish $(libdir)
Reid Spencere5487ba2004-10-24 07:53:21 +0000482
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000483uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000484 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencer12d79512004-11-12 02:27:36 +0000485 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
Reid Spencere5487ba2004-10-24 07:53:21 +0000486
Reid Spencer4d71b662004-10-22 21:01:56 +0000487endif
488
Reid Spencer3a561f52004-10-23 20:04:14 +0000489#---------------------------------------------------------
490# Bytecode Library Targets:
491# If the user asked for a bytecode library to be built
492# with the BYTECODE_LIBRARY variable, then we provide
493# targets for building them.
494#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000495ifdef BYTECODE_LIBRARY
496
497ifdef EXPORTED_SYMBOL_LIST
498 BCLinkLib += -Xlinker -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
499else
500 ifdef EXPORTED_SYMBOL_FILE
501 BCLinkLib += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
502 else
503 BCLinkLib += -Xlinker -disable-internalize
504 endif
505endif
506
Reid Spencercc2d1e22004-10-30 09:19:36 +0000507all-local:: $(LibName.BC)
Reid Spencer4d71b662004-10-22 21:01:56 +0000508
Reid Spencercc2d1e22004-10-30 09:19:36 +0000509$(LibName.BC): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000510 $(Echo) Linking $(BuildMode) Bytecode Library $(notdir $@)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000511 $(Verb) $(BCLinkLib) -o $@ $(ObjectsBC)
Reid Spencer4d71b662004-10-22 21:01:56 +0000512
Reid Spencer3a561f52004-10-23 20:04:14 +0000513clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000514ifneq ($(strip $(LibName.BC)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000515 -$(Verb) $(RM) -f $(LibName.BC)
Reid Spencere5487ba2004-10-24 07:53:21 +0000516endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000517
Reid Spencere5487ba2004-10-24 07:53:21 +0000518DestBytecodeLib = $(bytecode_libdir)/lib$(LIBRARYNAME).bc
Reid Spencere45ebfa2004-10-26 07:09:33 +0000519
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000520install-local:: $(DestBytecodeLib)
Chris Lattner481cc7c2003-08-15 02:18:35 +0000521
Reid Spencercc2d1e22004-10-30 09:19:36 +0000522$(DestBytecodeLib): $(bytecode_libdir) $(LibName.BC)
Reid Spencer9af3b292004-11-01 07:50:27 +0000523 $(Echo) Installing $(BuildMode) Bytecode Library $(DestBytecodeLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000524 $(Verb) $(INSTALL) $(LibName.BC) $@
Reid Spencere5487ba2004-10-24 07:53:21 +0000525
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000526uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000527 $(Echo) Uninstalling $(BuildMode) Bytecode Library $(DestBytecodeLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000528 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000529
530endif
Vikram S. Adve60f56062002-08-02 18:34:12 +0000531
Reid Spencercc2d1e22004-10-30 09:19:36 +0000532#---------------------------------------------------------
533# ReLinked Library Targets:
534# If the user didn't explicitly forbid building a
535# relinked then we provide targets for building them.
536#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000537ifndef DONT_BUILD_RELINKED
Reid Spencer4d71b662004-10-22 21:01:56 +0000538
Reid Spencercc2d1e22004-10-30 09:19:36 +0000539all-local:: $(LibName.O)
540
541$(LibName.O): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000542 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000543 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencer4d71b662004-10-22 21:01:56 +0000544
Reid Spencer3a561f52004-10-23 20:04:14 +0000545clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000546ifneq ($(strip $(LibName.O)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000547 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencere5487ba2004-10-24 07:53:21 +0000548endif
549
550DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
551
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000552install-local:: $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000553
Reid Spencercc2d1e22004-10-30 09:19:36 +0000554$(DestRelinkedLib): $(libdir) $(LibName.O)
Reid Spencer9af3b292004-11-01 07:50:27 +0000555 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000556 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000557
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000558uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000559 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000560 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000561
Chris Lattnere62dbe92002-07-23 17:56:16 +0000562endif
Chris Lattner760da062003-03-14 20:25:22 +0000563
Reid Spencercc2d1e22004-10-30 09:19:36 +0000564#---------------------------------------------------------
565# Archive Library Targets:
566# If the user wanted a regular archive library built,
567# then we provide targets for building them.
568#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000569ifdef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000570
Reid Spencercc2d1e22004-10-30 09:19:36 +0000571all-local:: $(LibName.A)
572
573$(LibName.A): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000574 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000575 -$(Verb) $(RM) -f $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000576 $(Verb) $(Archive) $@ $(ObjectsO)
577 $(Verb) $(Ranlib) $@
Vikram S. Adve41e78912002-09-20 14:03:13 +0000578
Reid Spencer3a561f52004-10-23 20:04:14 +0000579clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000580ifneq ($(strip $(LibName.A)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000581 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner00950542001-06-06 20:29:01 +0000582endif
583
Reid Spencere5487ba2004-10-24 07:53:21 +0000584DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
585
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000586install-local:: $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000587
Reid Spencercc2d1e22004-10-30 09:19:36 +0000588$(DestArchiveLib): $(libdir) $(LibName.A)
Reid Spencer9af3b292004-11-01 07:50:27 +0000589 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000590 $(Verb) $(MKDIR) $(libdir)
591 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000592
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000593uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000594 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000595 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000596
597endif
598
599# endif LIBRARYNAME
Reid Spencer4d71b662004-10-22 21:01:56 +0000600endif
601
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000602###############################################################################
603# Tool Build Rules: Build executable tool based on TOOLNAME option
604###############################################################################
605
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000606ifdef TOOLNAME
607
Reid Spencercc2d1e22004-10-30 09:19:36 +0000608#---------------------------------------------------------
609# Set up variables for building a tool.
610#---------------------------------------------------------
611ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
612ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
613ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
614LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
615LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
616ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
617LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
618ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
619LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000620
Reid Spencercc2d1e22004-10-30 09:19:36 +0000621#---------------------------------------------------------
622# Handle optional compression libraries automatically
623#---------------------------------------------------------
624ExtraLibs := $(LIBS)
Reid Spencer4d71b662004-10-22 21:01:56 +0000625ifeq ($(HAVE_BZIP2),1)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000626ExtraLibs += -lbz2
Reid Spencer4d71b662004-10-22 21:01:56 +0000627endif
628ifeq ($(HAVE_ZLIB),1)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000629ExtraLibs += -lz
Reid Spencer4d71b662004-10-22 21:01:56 +0000630endif
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000631
Reid Spencercc2d1e22004-10-30 09:19:36 +0000632#---------------------------------------------------------
633# Tell make that we need to rebuild subdirectories before
634# we can link the tool. This affects things like LLI which
635# has library subdirectories.
636#---------------------------------------------------------
637$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000638
Reid Spencercc2d1e22004-10-30 09:19:36 +0000639#---------------------------------------------------------
640# Provide targets for building the tools
641#---------------------------------------------------------
642all-local:: $(ToolBuildPath)
John Criswell2a6530f2003-06-27 16:58:44 +0000643
Reid Spencer3a561f52004-10-23 20:04:14 +0000644clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000645ifneq ($(strip $(ToolBuildPath)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000646 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencere5487ba2004-10-24 07:53:21 +0000647endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000648
Reid Spencercc2d1e22004-10-30 09:19:36 +0000649$(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)\
650 $(ToolDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000651 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000652 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
653 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
Reid Spencer9af3b292004-11-01 07:50:27 +0000654 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencere5487ba2004-10-24 07:53:21 +0000655
656DestTool = $(bindir)/$(TOOLNAME)
657
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000658install-local:: $(DestTool)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000659
Reid Spencercc2d1e22004-10-30 09:19:36 +0000660$(DestTool): $(bindir) $(ToolBuildPath)
Reid Spencer9af3b292004-11-01 07:50:27 +0000661 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000662 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000663
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000664uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000665 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000666 -$(Verb) $(RM) -f $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000667
Reid Spencer4d71b662004-10-22 21:01:56 +0000668endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000669
Reid Spencercc2d1e22004-10-30 09:19:36 +0000670###############################################################################
671# Object Build Rules: Build object files based on sources
672###############################################################################
673
674# Provide rule sets for when dependency generation is enabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000675ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve41e78912002-09-20 14:03:13 +0000676
Reid Spencercc2d1e22004-10-30 09:19:36 +0000677#---------------------------------------------------------
678# Create .lo files in the ObjDir directory from the .cpp and .c files...
679#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000680ifdef SHARED_LIBRARY
681
Reid Spencercc2d1e22004-10-30 09:19:36 +0000682$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000683 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000684 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
685 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
686 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000687
Reid Spencercc2d1e22004-10-30 09:19:36 +0000688$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000689 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000690 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
691 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
692 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000693
Reid Spencercc2d1e22004-10-30 09:19:36 +0000694#---------------------------------------------------------
695# Create .o files in the ObjDir directory from the .cpp and .c files...
696#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000697else
Reid Spencer4d71b662004-10-22 21:01:56 +0000698
Reid Spencercc2d1e22004-10-30 09:19:36 +0000699$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000700 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000701 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
702 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
703 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000704
Reid Spencercc2d1e22004-10-30 09:19:36 +0000705$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000706 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000707 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
708 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
709 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000710
711endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000712
Reid Spencercc2d1e22004-10-30 09:19:36 +0000713#---------------------------------------------------------
714# Create .bc files in the ObjDir directory from .cpp and .c files...
715#---------------------------------------------------------
716$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000717 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000718 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
719 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
720 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000721
Reid Spencercc2d1e22004-10-30 09:19:36 +0000722$(ObjDir)/%.bc: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000723 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000724 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
725 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
726 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000727
Reid Spencercc2d1e22004-10-30 09:19:36 +0000728# Provide alternate rule sets if dependencies are disabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000729else
730
Reid Spencer3a561f52004-10-23 20:04:14 +0000731ifdef SHARED_LIBRARY
732
Reid Spencercc2d1e22004-10-30 09:19:36 +0000733$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000734 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000735 $(LTCompile.CXX) $< -o $@
736
Reid Spencercc2d1e22004-10-30 09:19:36 +0000737$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000738 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000739 $(LTCompile.C) $< -o $@
740
741else
Reid Spencer4d71b662004-10-22 21:01:56 +0000742
Reid Spencercc2d1e22004-10-30 09:19:36 +0000743$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000744 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +0000745 $(Compile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000746
Reid Spencercc2d1e22004-10-30 09:19:36 +0000747$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000748 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +0000749 $(Compile.C) $< -o $@
750endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000751
Reid Spencercc2d1e22004-10-30 09:19:36 +0000752$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000753 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencer8676b7e2004-10-31 18:52:15 +0000754 $(BCCompile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000755
Reid Spencercc2d1e22004-10-30 09:19:36 +0000756$(ObjDir)/%.bc: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000757 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencer8676b7e2004-10-31 18:52:15 +0000758 $(BCCompile.C) $< -o $@
Brian Gaeke44909cf2003-12-10 00:26:28 +0000759
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000760endif
761
Reid Spencercc2d1e22004-10-30 09:19:36 +0000762#---------------------------------------------------------
763# Provide rule to build .bc files from .ll sources,
764# regardless of dependencies
765#---------------------------------------------------------
766$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000767 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000768 $(Verb) $(LLVMAS) $< -f -o $@
769
770###############################################################################
771# TABLEGEN: Provide rules for running tblgen to produce *.inc files
772###############################################################################
Chris Lattner481cc7c2003-08-15 02:18:35 +0000773
Reid Spencer4d71b662004-10-22 21:01:56 +0000774ifdef TARGET
775
Reid Spencercc2d1e22004-10-30 09:19:36 +0000776TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
777INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Reid Spencer4d71b662004-10-22 21:01:56 +0000778
Reid Spencercc2d1e22004-10-30 09:19:36 +0000779$(INCFiles) : $(TBLGEN) $(TDFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +0000780
Reid Spencer16544482004-10-27 04:34:35 +0000781%GenRegisterNames.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000782 $(Echo) "Building $(<F) register names with tblgen"
783 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000784
Reid Spencer16544482004-10-27 04:34:35 +0000785%GenRegisterInfo.h.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000786 $(Echo) "Building $(<F) register information header with tblgen"
787 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000788
789%GenRegisterInfo.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000790 $(Echo) "Building $(<F) register info implementation with tblgen"
791 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000792
793%GenInstrNames.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000794 $(Echo) "Building $(<F) instruction names with tblgen"
795 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000796
797%GenInstrInfo.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000798 $(Echo) "Building $(<F) instruction information with tblgen"
799 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000800
801%GenAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000802 $(Echo) "Building $(<F) assembly writer with tblgen"
803 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000804
805%GenATTAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000806 $(Echo) "Building $(<F) AT&T assembly writer with tblgen"
807 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000808
809%GenIntelAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000810 $(Echo) "Building $(<F) Intel assembly writer with tblgen"
811 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000812
813%GenInstrSelector.inc: %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000814 $(Echo) "Building $(<F) instruction selector with tblgen"
815 $(Verb) $(TableGen) -gen-instr-selector -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000816
817%GenCodeEmitter.inc:: %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000818 $(Echo) "Building $(<F) code emitter with tblgen"
819 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000820
Reid Spencer3a561f52004-10-23 20:04:14 +0000821clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000822 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +0000823
824endif
Chris Lattner481cc7c2003-08-15 02:18:35 +0000825
Reid Spencercc2d1e22004-10-30 09:19:36 +0000826###############################################################################
827# LEX AND YACC: Provide rules for generating sources with lex and yacc
828###############################################################################
Chris Lattnere8996782003-01-16 22:44:19 +0000829
Reid Spencercc2d1e22004-10-30 09:19:36 +0000830#---------------------------------------------------------
831# Provide rules for generating a .cpp source file from
832# (f)lex input sources.
833#---------------------------------------------------------
834
Reid Spencer3d659492004-11-02 16:36:03 +0000835LexFiles := $(filter %.l,$(Sources))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000836
Reid Spencer3d659492004-11-02 16:36:03 +0000837ifneq ($(LexFiles),)
838
839LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000840
841.PRECIOUS: $(LexOutput)
842
843# Note the extra sed filtering here, used to cut down on the warnings emited
844# by GCC. The last line is a gross hack to work around flex aparently not
845# being able to resize the buffer on a large token input. Currently, for
846# uninitialized string buffers in LLVM we can generate very long tokens, so
847# this is a hack around it.
Chris Lattnerb7dc2b92003-08-15 20:00:47 +0000848# FIXME. (f.e. char Buffer[10000] )
Chris Lattner00950542001-06-06 20:29:01 +0000849%.cpp: %.l
Reid Spencercc2d1e22004-10-30 09:19:36 +0000850 $(Echo) Flexing $<
851 $(Verb) $(FLEX) -t $< | \
Reid Spencer4d71b662004-10-22 21:01:56 +0000852 $(SED) 's/void yyunput/inline void yyunput/' | \
853 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
854 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencer80f0ef72004-10-28 00:41:43 +0000855 > $@
Chris Lattner00950542001-06-06 20:29:01 +0000856
Reid Spencer9af3b292004-11-01 07:50:27 +0000857clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000858 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencer3d659492004-11-02 16:36:03 +0000859 $(Verb) $(RM) -f $(LexOutput)
Reid Spencer9af3b292004-11-01 07:50:27 +0000860
Reid Spencercc2d1e22004-10-30 09:19:36 +0000861endif
862
863#---------------------------------------------------------
864# Provide rules for generating a .cpp and .h source files
865# from yacc (bison) input sources.
866#---------------------------------------------------------
867
Reid Spencer3d659492004-11-02 16:36:03 +0000868YaccFiles := $(filter %.y,$(Sources))
869ifneq ($(YaccFiles),)
870YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000871
872.PRECIOUS: $(YaccOutput)
873
874# Cancel built-in rules for yacc
875%.c: %.y
876%.cpp: %.y
877%.h: %.y
878
Chris Lattner00950542001-06-06 20:29:01 +0000879# Rule for building the bison parsers...
Chris Lattner00950542001-06-06 20:29:01 +0000880%.cpp %.h : %.y
Reid Spencercc2d1e22004-10-30 09:19:36 +0000881 $(Echo) "Bisoning $*.y"
882 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
883 $(Verb) $(MV) -f $*.tab.c $*.cpp
884 $(Verb) $(MV) -f $*.tab.h $*.h
Chris Lattner00950542001-06-06 20:29:01 +0000885
Reid Spencer9af3b292004-11-01 07:50:27 +0000886clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000887 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencer3d659492004-11-02 16:36:03 +0000888 $(Verb) $(RM) -f $(YaccOutput)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000889endif
Chris Lattner00950542001-06-06 20:29:01 +0000890
Reid Spencercc2d1e22004-10-30 09:19:36 +0000891###############################################################################
892# OTHER RULES: Other rules needed
893###############################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +0000894
Chris Lattner30440c62003-01-16 21:06:18 +0000895# To create postscript files from dot files...
John Criswelle0f9ac62003-10-02 19:02:02 +0000896ifneq ($(DOT),false)
Chris Lattner30440c62003-01-16 21:06:18 +0000897%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +0000898 $(DOT) -Tps < $< > $@
John Criswell7a73b802003-06-30 21:59:07 +0000899else
900%.ps: %.dot
Reid Spencercc2d1e22004-10-30 09:19:36 +0000901 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell7a73b802003-06-30 21:59:07 +0000902endif
Chris Lattner30440c62003-01-16 21:06:18 +0000903
John Criswell7f336952003-09-06 14:44:17 +0000904# This rules ensures that header files that are removed still have a rule for
905# which they can be "generated." This allows make to ignore them and
906# reproduce the dependency lists.
John Criswell4b6e5d12003-09-18 18:37:08 +0000907%.h:: ;
John Criswell7f336952003-09-06 14:44:17 +0000908
Reid Spencercc2d1e22004-10-30 09:19:36 +0000909# Define clean-local to clean the current directory. Note that this uses a
910# very conservative approach ensuring that empty variables do not cause
911# errors or disastrous removal.
Reid Spencer3a561f52004-10-23 20:04:14 +0000912clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000913ifneq ($(strip $(ObjDir)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000914 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencere5487ba2004-10-24 07:53:21 +0000915endif
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000916 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke9d3cd402004-01-21 19:53:11 +0000917ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000918 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke9d3cd402004-01-21 19:53:11 +0000919endif
John Criswell7a73b802003-06-30 21:59:07 +0000920
Reid Spencer3d659492004-11-02 16:36:03 +0000921clean-all-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000922 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer3d659492004-11-02 16:36:03 +0000923
Reid Spencercc2d1e22004-10-30 09:19:36 +0000924# Build tags database for Emacs/Xemacs:
Reid Spencer12d79512004-11-12 02:27:36 +0000925tags:: TAGS CTAGS
926
Reid Spencercc2d1e22004-10-30 09:19:36 +0000927TAGS:
Reid Spencer12d79512004-11-12 02:27:36 +0000928 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
929 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
930 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
931 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
932 -name '*.cpp' -o -name '*.h' | \
Reid Spencercc2d1e22004-10-30 09:19:36 +0000933 $(ETAGS) $(ETAGSFLAGS) -
934
Reid Spencer12d79512004-11-12 02:27:36 +0000935CTAGS:
936 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
937 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
938 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
939 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
940 \( -name '*.cpp' -o -name '*.h' \) -print | \
941 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
942
943
Reid Spencer3a561f52004-10-23 20:04:14 +0000944###############################################################################
945# DEPENDENCIES: Include the dependency files if we should
946###############################################################################
Chris Lattner33ad24a2003-08-22 14:10:16 +0000947ifndef DISABLE_AUTO_DEPENDENCIES
948
Reid Spencer3a561f52004-10-23 20:04:14 +0000949# If its not one of the cleaning targets
Reid Spencercc2d1e22004-10-30 09:19:36 +0000950ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencer4d71b662004-10-22 21:01:56 +0000951
Reid Spencer3a561f52004-10-23 20:04:14 +0000952# Get the list of dependency files
Reid Spencercc2d1e22004-10-30 09:19:36 +0000953DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Reid Spencer9af3b292004-11-01 07:50:27 +0000954DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
Misha Brukman4f7a8cf2003-11-09 21:36:19 +0000955
Reid Spencer3a561f52004-10-23 20:04:14 +0000956-include /dev/null $(DependFiles)
957
John Criswelld741bcf2003-08-12 18:51:51 +0000958endif
Chris Lattner1ddb6b62003-08-18 17:27:40 +0000959
Reid Spencercc2d1e22004-10-30 09:19:36 +0000960endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000961
Reid Spencer151f8ba2004-10-25 08:27:37 +0000962###############################################################################
Reid Spencercc2d1e22004-10-30 09:19:36 +0000963# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer151f8ba2004-10-25 08:27:37 +0000964###############################################################################
965
Reid Spencere45ebfa2004-10-26 07:09:33 +0000966#------------------------------------------------------------------------
967# Define distribution related variables
968#------------------------------------------------------------------------
Reid Spencer151f8ba2004-10-25 08:27:37 +0000969DistName := $(LLVM_TARBALL_NAME)
970DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000971TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000972DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
973DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
974DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
975DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
976 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencere45ebfa2004-10-26 07:09:33 +0000977 Makefile.config.in configure autoconf
978DistOther := $(notdir $(wildcard \
979 $(BUILD_SRC_DIR)/*.h \
980 $(BUILD_SRC_DIR)/*.td \
981 $(BUILD_SRC_DIR)/*.def \
982 $(BUILD_SRC_DIR)/*.ll \
983 $(BUILD_SRC_DIR)/*.in))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000984DistSources := $(Sources) $(EXTRA_DIST)
985DistSubDirs := $(SubDirs)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000986DistFiles := $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000987
Reid Spencere45ebfa2004-10-26 07:09:33 +0000988#------------------------------------------------------------------------
989# We MUST build distribution with OBJ_DIR != SRC_DIR
990#------------------------------------------------------------------------
991ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
992dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000993 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencere45ebfa2004-10-26 07:09:33 +0000994
995DistCheckTop :=
996else
997
998DistCheckTop := check
Reid Spencercc2d1e22004-10-30 09:19:36 +0000999
Reid Spencere45ebfa2004-10-26 07:09:33 +00001000#------------------------------------------------------------------------
1001# Prevent catastrophic remove
1002#------------------------------------------------------------------------
1003ifeq ($(LLVM_TARBALL_NAME),)
1004$(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1005endif
1006
1007#------------------------------------------------------------------------
1008# Prevent attempt to run dist targets from anywhere but the top level
1009#------------------------------------------------------------------------
1010ifneq ($(LEVEL),.)
1011
1012dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001013 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001014
1015else
1016
1017#------------------------------------------------------------------------
1018# Provide the top level targets
1019#------------------------------------------------------------------------
1020
Reid Spencercc2d1e22004-10-30 09:19:36 +00001021dist-gzip:: $(DistTarGZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001022
1023$(DistTarGZip) : distdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001024 $(Echo) Packing gzipped distribution tar file.
1025 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | gzip -c > "$(DistTarGZip)"
Reid Spencere45ebfa2004-10-26 07:09:33 +00001026
Reid Spencercc2d1e22004-10-30 09:19:36 +00001027dist-bzip2:: $(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001028
1029$(DistTarBZ2) : distdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001030 $(Echo) Packing bzipped distribution tar file.
1031 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | $(BZIP2) -c >$(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001032
Reid Spencercc2d1e22004-10-30 09:19:36 +00001033dist-zip:: $(DistZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001034
1035$(DistZip) : distdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001036 $(Echo) Packing zipped distribution file.
1037 $(Verb) rm -f $(DistZip)
1038 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001039
1040dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001041 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001042
1043DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1044
Reid Spencer9411c642004-10-26 22:26:33 +00001045dist-check:: $(DistCheckTop) $(DistTarGZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001046 $(Echo) Checking distribution tar file.
1047 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001048 $(RM) -rf $(DistCheckDir) ; \
1049 fi
Reid Spencercc2d1e22004-10-30 09:19:36 +00001050 $(Verb) $(MKDIR) $(DistCheckDir)
1051 $(Verb) cd $(DistCheckDir) && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001052 $(MKDIR) $(DistCheckDir)/build && \
1053 $(MKDIR) $(DistCheckDir)/install && \
1054 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1055 cd build && \
1056 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1057 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
1058 $(MAKE) check && \
1059 $(MAKE) install && \
1060 $(MAKE) uninstall && \
1061 $(MAKE) dist && \
1062 $(MAKE) clean && \
1063 $(MAKE) dist-clean && \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001064 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001065
1066dist-clean::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001067 $(Echo) Cleaning distribution files
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001068 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) $(DistCheckDir)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001069
1070endif
1071
1072#------------------------------------------------------------------------
1073# Provide the recursive distdir target for building the distribution directory
1074#------------------------------------------------------------------------
Reid Spencer9411c642004-10-26 22:26:33 +00001075distdir : $(DistSources)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001076 $(Echo) Building Distribution Directory $(DistDir)
1077 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001078 if test -d "$(DistDir)" ; then \
1079 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1080 exit 1 ; \
1081 fi ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001082 $(EchoCmd) Removing $(DistDir) ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001083 $(RM) -rf $(DistDir); \
1084 fi
Reid Spencercc2d1e22004-10-30 09:19:36 +00001085 $(Verb) $(MKDIR) $(DistDir)
1086 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001087 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1088 for file in $(DistFiles) ; do \
1089 case "$$file" in \
1090 $(BUILD_SRC_DIR)/*) file=`echo "$$file" | sed "s#^$$srcdirstrip/##"`;; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001091 $(BUILD_SRC_ROOT)/*) file=`echo "$$file" | sed "s#^$$srcrootstrip/#$(BUILD_OBJ_ROOT)/#"`;; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001092 esac; \
1093 if test -f "$$file" || test -d "$$file" ; then \
1094 from_dir=. ; \
1095 else \
1096 from_dir=$(BUILD_SRC_DIR); \
1097 fi; \
1098 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'`; \
1099 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1100 to_dir="$(DistDir)/$$dir"; \
1101 $(MKDIR) "$$to_dir" ; \
1102 else \
1103 to_dir="$(DistDir)"; \
1104 fi; \
1105 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1106 if test -n "$$mid_dir" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001107 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001108 fi ; \
1109 if test -d "$$from_dir/$$file"; then \
1110 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1111 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1112 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1113 fi; \
1114 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1115 elif test -f "$$from_dir/$$file" ; then \
1116 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1117 elif test -L "$$from_dir/$$file" ; then \
1118 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1119 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001120 $(EchoCmd) "===== WARNING: Distribution Source $$from_dir/$$file Not Found!" ; \
1121 elif test "$(Verb)" != '@' ; then \
1122 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001123 fi; \
1124 done
Reid Spencercc2d1e22004-10-30 09:19:36 +00001125 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001126 if test "$$subdir" \!= "." ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001127 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001128 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1129 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001130 fi; \
1131 done
Reid Spencercc2d1e22004-10-30 09:19:36 +00001132 $(Verb) $(MAKE) DistDir="$(DistDir)" dist-hook || exit 1
1133 -$(Verb) find $(DistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001134 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
1135 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
1136 ! -type d ! -perm -444 -exec $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1137 || chmod -R a+r $(DistDir)
1138
Reid Spencercc2d1e22004-10-30 09:19:36 +00001139# This is invoked by distdir target, define it as a no-op to avoid errors if not
1140# defined by user.
Reid Spencer151f8ba2004-10-25 08:27:37 +00001141dist-hook::
1142
Reid Spencere53e3972004-10-22 23:06:30 +00001143endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001144
1145###############################################################################
Reid Spencere5487ba2004-10-24 07:53:21 +00001146# TOP LEVEL - targets only to apply at the top level directory
1147###############################################################################
1148
1149ifeq ($(LEVEL),.)
1150
1151#------------------------------------------------------------------------
Reid Spencere5487ba2004-10-24 07:53:21 +00001152# Install support for project's include files:
1153#------------------------------------------------------------------------
1154install-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001155 $(Echo) Installing include files
1156 $(Verb) $(MKDIR) $(includedir)
1157 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencere5487ba2004-10-24 07:53:21 +00001158 cd $(BUILD_SRC_ROOT)/include && \
1159 find . -path '*/Internal' -prune -o '(' -type f \
1160 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1161 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1162 fi
1163
1164uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001165 $(Echo) Uninstalling include files
1166 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencere5487ba2004-10-24 07:53:21 +00001167 cd $(BUILD_SRC_ROOT)/include && \
1168 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1169 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1170 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1171 fi
1172
Reid Spencere5487ba2004-10-24 07:53:21 +00001173endif
1174
Reid Spencer4d71b662004-10-22 21:01:56 +00001175#------------------------------------------------------------------------
1176# Print out the directories used for building
Reid Spencercc2d1e22004-10-30 09:19:36 +00001177#------------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001178printvars::
Reid Spencer9af3b292004-11-01 07:50:27 +00001179 $(Echo) "BuildMode : " '$(BuildMode)'
Reid Spencercc2d1e22004-10-30 09:19:36 +00001180 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1181 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1182 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1183 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1184 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1185 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1186 $(Echo) "libdir : " '$(libdir)'
1187 $(Echo) "bindir : " '$(bindir)'
1188 $(Echo) "sysconfdir : " '$(sysconfdir)'
1189 $(Echo) "bytecode_libdir: " '$(bytecode_libdir)'
1190 $(Echo) "UserTargets : " '$(UserTargets)'
1191 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1192 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1193 $(Echo) "ObjDir : " '$(ObjDir)'
1194 $(Echo) "LibDir : " '$(LibDir)'
1195 $(Echo) "ToolDir : " '$(ToolDir)'
1196 $(Echo) "TDFiles : " '$(TDFiles)'
1197 $(Echo) "INCFiles : " '$(INCFiles)'
1198 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1199 $(Echo) "Compile.C : " '$(Compile.C)'
1200 $(Echo) "Archive : " '$(Archive)'
Reid Spencer3d659492004-11-02 16:36:03 +00001201 $(Echo) "YaccFiles : " '$(YaccFiles)'
1202 $(Echo) "LexFiles : " '$(LexFiles)'