blob: d0505643e316ab2f0a476943ce3e413360514514 [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#
10# This file is included by all of the LLVM makefiles. This file defines common
Misha Brukman36bc6422003-08-21 22:02:18 +000011# rules to do things like compile a .cpp file or generate dependency info.
12# These are platform dependent, so this is the file used to specify these
13# system dependent operations.
Chris Lattner00950542001-06-06 20:29:01 +000014#
Vikram S. Advec214e712002-08-29 23:28:46 +000015# The following functionality can be set by setting incoming variables.
16# The variable $(LEVEL) *must* be set:
Chris Lattner00950542001-06-06 20:29:01 +000017#
18# 1. LEVEL - The level of the current subdirectory from the top of the
19# MagicStats view. This level should be expressed as a path, for
20# example, ../.. for two levels deep.
21#
22# 2. DIRS - A list of subdirectories to be built. Fake targets are set up
Chris Lattnera8abc222002-09-18 03:22:27 +000023# so that each of the targets "all", "install", and "clean" each build
24# the subdirectories before the local target. DIRS are guaranteed to be
25# built in order.
Chris Lattner00950542001-06-06 20:29:01 +000026#
Chris Lattnera8abc222002-09-18 03:22:27 +000027# 3. PARALLEL_DIRS - A list of subdirectories to be built, but that may be
28# built in any order. All DIRS are built in order before PARALLEL_DIRS are
29# built, which are then built in any order.
30#
31# 4. Source - If specified, this sets the source code filenames. If this
Chris Lattner00950542001-06-06 20:29:01 +000032# is not set, it defaults to be all of the .cpp, .c, .y, and .l files
Chris Lattnere0010592001-10-18 01:48:09 +000033# in the current directory. Also, if you want to build files in addition
34# to the local files, you can use the ExtraSource variable
Chris Lattner00950542001-06-06 20:29:01 +000035#
Chris Lattner694c5df2003-05-15 21:28:55 +000036# 5. SourceDir - If specified, this specifies a directory that the source files
37# are in, if they are not in the current directory. This should include a
38# trailing / character.
39#
John Criswell7a73b802003-06-30 21:59:07 +000040# 6. LLVM_SRC_ROOT - If specified, points to the top of the LLVM source tree.
Dinakar Dhurjati584dd182003-05-29 21:49:00 +000041#
John Criswell7a73b802003-06-30 21:59:07 +000042# 8. BUILD_SRC_DIR - The directory which contains the current set of Makefiles
43# and usually the source code too (unless SourceDir is set).
44#
45# 9. BUILD_SRC_ROOT - The root directory of the source code being compiled.
46#
47# 10. BUILD_OBJ_DIR - The directory where object code should be placed.
48#
49# 11. BUILD_OBJ_ROOT - The root directory for where object code should be
50# placed.
51#
52# For building,
Chris Lattnere430a1e2003-08-21 22:23:49 +000053# LLVM, LLVM_SRC_ROOT = BUILD_SRC_ROOT
Chris Lattneraf06a082003-08-15 03:02:52 +000054#
Vikram S. Adved60aede2002-07-09 12:04:21 +000055#===-----------------------------------------------------------------------====
Chris Lattner00950542001-06-06 20:29:01 +000056
John Criswell2a6530f2003-06-27 16:58:44 +000057#
John Criswell7f336952003-09-06 14:44:17 +000058# Set the VPATH so that we can find source files.
John Criswell8bff5092003-06-11 13:55:44 +000059#
John Criswell613758d2003-09-11 18:03:50 +000060VPATH=$(SourceDir)
John Criswell8bff5092003-06-11 13:55:44 +000061
John Criswell7a73b802003-06-30 21:59:07 +000062###########################################################################
63# Default Targets:
64# The following targets are the standard top level targets for
65# building.
66###########################################################################
Chris Lattner4bb13b82002-09-13 22:14:47 +000067
John Criswellbd082802003-10-07 14:16:44 +000068# Ensure people re-run configure when it gets updated
Misha Brukman94fe1f92003-10-07 15:24:23 +000069all::$(LLVM_OBJ_ROOT)/config.status
John Criswellbd082802003-10-07 14:16:44 +000070
Chris Lattneredf1f232002-07-23 19:21:31 +000071ifdef SHARED_LIBRARY
72# if SHARED_LIBRARY is specified, the default is to build the dynamic lib
John Criswell7a73b802003-06-30 21:59:07 +000073all:: dynamic
Brian Gaeke7976e972004-01-16 21:12:34 +000074install:: install-dynamic-library
Chris Lattneredf1f232002-07-23 19:21:31 +000075endif
76
Chris Lattner95cc1b32003-08-14 21:10:25 +000077ifdef BYTECODE_LIBRARY
78# if BYTECODE_LIBRARY is specified, the default is to build the bytecode lib
79all:: bytecodelib
Brian Gaeke78cb3f22003-12-18 20:57:48 +000080install:: install-bytecode-library
Brian Gaekef313ea72004-03-10 17:38:01 +000081install-bytecode:: install-bytecode-library
Chris Lattner95cc1b32003-08-14 21:10:25 +000082endif
83
Chris Lattnerb19e59c2001-06-29 05:20:16 +000084# Default Rule: Make sure it's also a :: rule
Chris Lattner00950542001-06-06 20:29:01 +000085all ::
86
87# Default for install is to at least build everything...
88install ::
89
John Criswell8bff5092003-06-11 13:55:44 +000090# Default rule for test. It ensures everything has a test rule
91test::
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +000092
Vikram S. Adve6edfe272003-07-10 19:25:29 +000093# Default rule for building only bytecode.
94bytecode::
95
Brian Gaekef313ea72004-03-10 17:38:01 +000096# Default rule for installing only bytecode.
97install-bytecode::
98
John Criswell7a73b802003-06-30 21:59:07 +000099# Print out the directories used for building
100prdirs::
John Criswell7ec78aa2003-10-16 01:49:00 +0000101 @${ECHO} "Build Source Root: " $(BUILD_SRC_ROOT)
102 @${ECHO} "Build Source Dir : " $(BUILD_SRC_DIR)
103 @${ECHO} "Build Object Root: " $(BUILD_OBJ_ROOT)
104 @${ECHO} "Build Object Dir : " $(BUILD_OBJ_DIR)
105 @${ECHO} "LLVM Source Root: " $(LLVM_SRC_ROOT)
106 @${ECHO} "LLVM Object Root: " $(LLVM_OBJ_ROOT)
John Criswell7a73b802003-06-30 21:59:07 +0000107
John Criswell9621a2b2003-08-20 15:18:41 +0000108###########################################################################
109# Suffixes and implicit rules:
110# Empty out the list of suffixes, generate a list that is only
111# used by this Makefile, and cancel useless implicit rules. This
112# will hopefully speed up compilation a little bit.
113###########################################################################
114.SUFFIXES:
115.SUFFIXES: .c .cpp .h .hpp .y .l
Brian Gaeked65ed3f2004-01-21 19:59:19 +0000116.SUFFIXES: .lo .o .a $(SHLIBEXT) .bc .td
John Criswell9621a2b2003-08-20 15:18:41 +0000117.SUFFIXES: .ps .dot .d
118
John Criswell96914392003-07-16 20:26:06 +0000119#
120# Mark all of these targets as phony. This will hopefully speed up builds
121# slightly since GNU Make will not try to find implicit rules for targets
122# which are marked as Phony.
123#
Brian Gaeke78cb3f22003-12-18 20:57:48 +0000124.PHONY: all dynamic bytecodelib install-bytecode-library
Chris Lattnerfbb574d2003-08-21 20:39:08 +0000125.PHONY: clean distclean install test bytecode prdirs
John Criswell96914392003-07-16 20:26:06 +0000126
John Criswell7a73b802003-06-30 21:59:07 +0000127###########################################################################
128# Miscellaneous paths and commands:
129# This section defines various configuration macros, such as where
130# to find burg, tblgen, and libtool.
131###########################################################################
132
Chris Lattner00950542001-06-06 20:29:01 +0000133#--------------------------------------------------------------------
Vikram S. Advec214e712002-08-29 23:28:46 +0000134# Variables derived from configuration options...
Chris Lattner00950542001-06-06 20:29:01 +0000135#--------------------------------------------------------------------
136
Vikram S. Advedba59ef2001-08-06 19:01:20 +0000137BURG_OPTS = -I
138
Chris Lattner760da062003-03-14 20:25:22 +0000139ifdef ENABLE_PROFILING
140 ENABLE_OPTIMIZED = 1
141 CONFIGURATION := Profile
142else
143 ifdef ENABLE_OPTIMIZED
144 CONFIGURATION := Release
145 else
146 CONFIGURATION := Debug
147 endif
148endif
149
John Criswell7a73b802003-06-30 21:59:07 +0000150#
151# Enable this for profiling support with 'gprof'
152# This automatically enables optimized builds.
153#
154ifdef ENABLE_PROFILING
155 PROFILE = -pg
156endif
157
John Criswell8bff5092003-06-11 13:55:44 +0000158###########################################################################
John Criswell7a73b802003-06-30 21:59:07 +0000159# Library Locations:
John Criswell8bff5092003-06-11 13:55:44 +0000160# These variables describe various library locations:
161#
162# DEST* = Location of where libraries that are built will be placed.
163# LLVM* = Location of LLVM libraries used for linking.
164# PROJ* = Location of previously built libraries used for linking.
165###########################################################################
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000166
John Criswell8bff5092003-06-11 13:55:44 +0000167# Libraries that are being built
168DESTLIBDEBUG := $(BUILD_OBJ_ROOT)/lib/Debug
169DESTLIBRELEASE := $(BUILD_OBJ_ROOT)/lib/Release
170DESTLIBPROFILE := $(BUILD_OBJ_ROOT)/lib/Profile
Chris Lattnerad2be6c2003-09-10 19:37:51 +0000171DESTLIBBYTECODE := $(BUILD_OBJ_ROOT)/lib/BytecodeLibs
John Criswell8bff5092003-06-11 13:55:44 +0000172DESTLIBCURRENT := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000173
John Criswell8bff5092003-06-11 13:55:44 +0000174# LLVM libraries used for linking
175LLVMLIBDEBUGSOURCE := $(LLVM_OBJ_ROOT)/lib/Debug
176LLVMLIBRELEASESOURCE := $(LLVM_OBJ_ROOT)/lib/Release
177LLVMLIBPROFILESOURCE := $(LLVM_OBJ_ROOT)/lib/Profile
178LLVMLIBCURRENTSOURCE := $(LLVM_OBJ_ROOT)/lib/$(CONFIGURATION)
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000179
John Criswell8bff5092003-06-11 13:55:44 +0000180# Libraries that were built that will now be used for linking
181PROJLIBDEBUGSOURCE := $(BUILD_OBJ_ROOT)/lib/Debug
182PROJLIBRELEASESOURCE := $(BUILD_OBJ_ROOT)/lib/Release
183PROJLIBPROFILESOURCE := $(BUILD_OBJ_ROOT)/lib/Profile
184PROJLIBCURRENTSOURCE := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000185
John Criswell8bff5092003-06-11 13:55:44 +0000186###########################################################################
187# Tool Locations
188# These variables describe various tool locations:
189#
190# DEST* = Location of where tools that are built will be placed.
191# LLVM* = Location of LLVM tools used for building.
192# PROJ* = Location of previously built tools used for linking.
193###########################################################################
Chris Lattner760da062003-03-14 20:25:22 +0000194
John Criswell8bff5092003-06-11 13:55:44 +0000195DESTTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug
196DESTTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release
197DESTTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile
198DESTTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
199
200LLVMTOOLDEBUG := $(LLVM_OBJ_ROOT)/tools/Debug
201LLVMTOOLRELEASE := $(LLVM_OBJ_ROOT)/tools/Release
202LLVMTOOLPROFILE := $(LLVM_OBJ_ROOT)/tools/Profile
203LLVMTOOLCURRENT := $(LLVM_OBJ_ROOT)/tools/$(CONFIGURATION)
204
205PROJTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug
206PROJTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release
207PROJTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile
208PROJTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
Chris Lattnere62dbe92002-07-23 17:56:16 +0000209
John Criswell7a73b802003-06-30 21:59:07 +0000210#
211# Libtool is found in the current directory.
212#
Reid Spencer9c96c722004-09-20 01:43:00 +0000213LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
John Criswell7a73b802003-06-30 21:59:07 +0000214
215#
John Criswell82f4a5a2003-07-31 20:58:51 +0000216# If we're not building a shared library, use the disable-shared tag with
217# libtool. This will disable the building of objects for shared libraries and
218# only generate static library objects.
219#
220# For dynamic libraries, we'll take the performance hit for now, since we
221# almost never build them.
222#
223# This should speed up compilation and require no modifications to future
224# versions of libtool.
225#
226ifndef SHARED_LIBRARY
Chris Lattner95cc1b32003-08-14 21:10:25 +0000227LIBTOOL += --tag=disable-shared
John Criswell82f4a5a2003-07-31 20:58:51 +0000228endif
229
230#
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000231# Verbosity levels
John Criswell7a73b802003-06-30 21:59:07 +0000232#
Chris Lattner760da062003-03-14 20:25:22 +0000233ifndef VERBOSE
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000234VERB := @
Chris Lattner95cc1b32003-08-14 21:10:25 +0000235LIBTOOL += --silent
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000236endif
237
John Criswell7a73b802003-06-30 21:59:07 +0000238###########################################################################
239# Miscellaneous paths and commands (part deux):
240# This section defines various configuration macros, such as where
241# to find burg, tblgen, and libtool.
242###########################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000243
John Criswell7a73b802003-06-30 21:59:07 +0000244#--------------------------------------------------------------------------
Chris Lattner481cc7c2003-08-15 02:18:35 +0000245# Utilities used while building the LLVM tree, which live in the utils dir
246#
Chris Lattner396d96b2004-06-01 19:06:43 +0000247BURG := $(LLVMTOOLCURRENT)/burg$(EXEEXT)
Chris Lattnereefa3d32003-11-29 09:50:15 +0000248RunBurg := $(BURG) $(BURG_OPTS)
Chris Lattner396d96b2004-06-01 19:06:43 +0000249TBLGEN := $(LLVMTOOLCURRENT)/tblgen$(EXEEXT)
250LGCCLDPROG := $(LLVMTOOLCURRENT)/gccld$(EXEEXT)
Vikram S. Advedba59ef2001-08-06 19:01:20 +0000251
Chris Lattner481cc7c2003-08-15 02:18:35 +0000252#--------------------------------------------------------------------------
253# The LLVM GCC front-end in C and C++ flavors
254#
Chris Lattner9a86a012003-08-15 15:20:52 +0000255LLVMGCC := PATH=$(LLVMTOOLCURRENT):$(PATH) $(LLVMGCCDIR)/bin/gcc
Chris Lattner9a86a012003-08-15 15:20:52 +0000256LLVMGXX := PATH=$(LLVMTOOLCURRENT):$(PATH) $(LLVMGCCDIR)/bin/g++
Chris Lattner481cc7c2003-08-15 02:18:35 +0000257
258#--------------------------------------------------------------------------
Brian Gaeke0b441222004-07-21 01:31:47 +0000259# The compiled LLVM tools
Chris Lattner481cc7c2003-08-15 02:18:35 +0000260#
Brian Gaeke0b441222004-07-21 01:31:47 +0000261
Chris Lattner396d96b2004-06-01 19:06:43 +0000262LLVMAS := $(LLVMTOOLCURRENT)/llvm-as$(EXEEXT)
Brian Gaeke0b441222004-07-21 01:31:47 +0000263# Find the location of the platform specific LLVM GCC libraries
264LLVMGCCLIBDIR=$(dir $(shell $(LLVMGCC) -print-file-name=libgcc.a))
265# LLVM Tool Definitions (LLVMGCC, LLVMGXX, LLVMAS are provided by
Misha Brukman712c0e22004-07-21 12:47:40 +0000266# Makefile.rules)
267LLI = $(LLVMTOOLCURRENT)/lli$(EXEEXT)
268LLC = $(LLVMTOOLCURRENT)/llc$(EXEEXT)
269LGCCAS = $(LLVMTOOLCURRENT)/gccas$(EXEEXT)
270LGCCLD = $(LGCCLDPROG) -L$(LLVMGCCLIBDIR) -L$(LLVMGCCDIR)/lib
271LDIS = $(LLVMTOOLCURRENT)/llvm-dis$(EXEEXT)
272LOPT = $(LLVMTOOLCURRENT)/opt$(EXEEXT)
273LLINK = $(LLVMTOOLCURRENT)/llvm-link$(EXEEXT)
274LPROF = $(LLVMTOOLCURRENT)/llvm-prof$(EXEEXT)
275LANALYZE = $(LLVMTOOLCURRENT)/analyze$(EXEEXT)
276LBUGPOINT = $(LLVMTOOLCURRENT)/bugpoint$(EXEEXT)
Reid Spencer5f8c6b22004-09-05 16:39:01 +0000277LLVMC = $(LLVMTOOLCURRENT)/llvmc$(EXEEXT)
Chris Lattner481cc7c2003-08-15 02:18:35 +0000278
Chris Lattner00950542001-06-06 20:29:01 +0000279
John Criswell8bff5092003-06-11 13:55:44 +0000280###########################################################################
281# Compile Time Flags
282###########################################################################
283
284#
John Criswell7a73b802003-06-30 21:59:07 +0000285# Include both the project headers and the LLVM headers for compilation and
286# dependency computation.
John Criswell8bff5092003-06-11 13:55:44 +0000287#
John Criswell7f336952003-09-06 14:44:17 +0000288# BUILD_OBJ_DIR : Files local to the particular object directory
289# (locallly generated header files).
290# BUILD_SRC_DIR : Files local to the particular source directory.
291# BUILD_SRC_ROOT/include : Files global to the project.
Chris Lattner00e730a2003-09-15 01:07:32 +0000292# LLVM_OBJ_ROOT/include : config.h files generated by autoconf
John Criswell7f336952003-09-06 14:44:17 +0000293# LEVEL/include : config.h files for the project
294# LLVM_SRC_ROOT/include : Files global to LLVM.
John Criswell7f336952003-09-06 14:44:17 +0000295#
Chris Lattner069f9302003-09-15 01:12:04 +0000296CPPFLAGS += -I$(BUILD_OBJ_DIR) -I$(BUILD_SRC_DIR) -I$(LLVM_OBJ_ROOT)/include \
297 -I$(BUILD_SRC_ROOT)/include -I$(LEVEL)/include \
298 -I$(LLVM_SRC_ROOT)/include
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000299
Vikram S. Advefeeae582002-09-18 11:55:13 +0000300# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000301ifndef KEEP_SYMBOLS
Chris Lattner527002c2003-01-31 19:00:26 +0000302STRIP = $(PLATFORMSTRIPOPTS)
Misha Brukman9b51b6f2003-07-10 16:52:41 +0000303STRIP_WARN_MSG = "(without symbols)"
Vikram S. Advefeeae582002-09-18 11:55:13 +0000304endif
305
Brian Gaeke90eca552003-10-28 19:09:28 +0000306# Allow GNU extensions:
Chris Lattner73e1d0f2002-09-13 16:02:26 +0000307CPPFLAGS += -D_GNU_SOURCE
Brian Gaeke90eca552003-10-28 19:09:28 +0000308# Pull in limit macros from stdint.h, even in C++:
309CPPFLAGS += -D__STDC_LIMIT_MACROS
Chris Lattner73e1d0f2002-09-13 16:02:26 +0000310
Chris Lattnerd1803002003-12-06 20:59:45 +0000311CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
Chris Lattnerbb3dd472003-08-27 18:26:44 +0000312CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions
Chris Lattner00950542001-06-06 20:29:01 +0000313
John Criswell7a73b802003-06-30 21:59:07 +0000314#
315# Compile commands with libtool.
316#
Brian Gaeke10c508b2004-06-08 18:52:45 +0000317Compile := $(LIBTOOL) --tag=CXX --mode=compile $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
Chris Lattner72987ee2003-08-23 15:56:38 +0000318CompileC := $(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(CompileCommonOpts)
John Criswell7a73b802003-06-30 21:59:07 +0000319
Chris Lattner172b6482002-09-22 02:47:15 +0000320# Compile a cpp file, don't link...
Chris Lattner285af382002-08-12 21:19:28 +0000321CompileG := $(Compile) -g -D_DEBUG
Chris Lattner1d1e5b52003-02-13 16:56:30 +0000322CompileO := $(Compile) $(CompileOptimizeOpts) -felide-constructors -fomit-frame-pointer
323CompileP := $(Compile) $(CompileOptimizeOpts) -felide-constructors $(PROFILE)
Chris Lattner00950542001-06-06 20:29:01 +0000324
Chris Lattner172b6482002-09-22 02:47:15 +0000325# Compile a c file, don't link...
Chris Lattner172b6482002-09-22 02:47:15 +0000326CompileCG := $(CompileC) -g -D_DEBUG
Chris Lattnerfe95dae2003-02-19 22:12:20 +0000327CompileCO := $(CompileC) $(CompileOptimizeOpts) -fomit-frame-pointer
328CompileCP := $(CompileC) $(CompileOptimizeOpts) $(PROFILE)
Chris Lattner172b6482002-09-22 02:47:15 +0000329
John Criswell7a73b802003-06-30 21:59:07 +0000330###########################################################################
331# Link Time Options
332###########################################################################
Chris Lattner172b6482002-09-22 02:47:15 +0000333
John Criswell7a73b802003-06-30 21:59:07 +0000334#
Chris Lattner00950542001-06-06 20:29:01 +0000335# Link final executable
John Criswell7a73b802003-06-30 21:59:07 +0000336# (Note that we always link with the C++ compiler).
337#
Brian Gaeke10c508b2004-06-08 18:52:45 +0000338Link := $(LIBTOOL) --tag=CXX --mode=link $(CXX)
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000339
John Criswell7a73b802003-06-30 21:59:07 +0000340# link both projlib and llvmlib libraries
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000341LinkG := $(Link) -g -L$(PROJLIBDEBUGSOURCE) -L$(LLVMLIBDEBUGSOURCE) $(STRIP)
342LinkO := $(Link) -O3 -L$(PROJLIBRELEASESOURCE) -L$(LLVMLIBRELEASESOURCE)
343LinkP := $(Link) -O3 -L$(PROJLIBPROFILESOURCE) -L$(LLVMLIBPROFILESOURCE) $(PROFILE)
Chris Lattner00950542001-06-06 20:29:01 +0000344
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000345# TOOLLINKOPTSB to pass options to the linker like library search path etc
346# Note that this is different from TOOLLINKOPTS, these options
347# are passed to the linker *before* the USEDLIBS options are passed.
348# e.g. usage TOOLLINKOPTSB = -L/home/xxx/lib
349ifdef TOOLLINKOPTSB
350LinkG := $(LinkG) $(TOOLLINKOPTSB)
Dinakar Dhurjati79903c82003-10-29 20:34:13 +0000351LinkO := $(LinkO) $(TOOLLINKOPTSB)
352LinkP := $(LinkP) $(TOOLLINKOPTSB)
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000353endif
354
Chris Lattnere62dbe92002-07-23 17:56:16 +0000355# Create one .o file from a bunch of .o files...
Brian Gaeke10c508b2004-06-08 18:52:45 +0000356Relink := ${LIBTOOL} --tag=CXX --mode=link $(CXX)
John Criswell7a73b802003-06-30 21:59:07 +0000357
358#
359# Configure where the item being compiled should go.
360#
361ifdef SHARED_LIBRARY
Chris Lattner95cc1b32003-08-14 21:10:25 +0000362Link += -rpath $(DESTLIBCURRENT)
John Criswell7a73b802003-06-30 21:59:07 +0000363endif
364
365ifdef TOOLNAME
Chris Lattner95cc1b32003-08-14 21:10:25 +0000366Link += -rpath $(DESTTOOLCURRENT)
John Criswell7a73b802003-06-30 21:59:07 +0000367endif
Chris Lattner4bb13b82002-09-13 22:14:47 +0000368
Misha Brukman36bc6422003-08-21 22:02:18 +0000369# Create dependency file from CPP file, send to stdout.
John Criswell8bff5092003-06-11 13:55:44 +0000370Depend := $(CXX) -MM -I$(LEVEL)/include $(CPPFLAGS)
371DependC := $(CC) -MM -I$(LEVEL)/include $(CPPFLAGS)
Chris Lattner00950542001-06-06 20:29:01 +0000372
373# Archive a bunch of .o files into a .a file...
Brian Gaeke7a45c492004-02-04 21:41:23 +0000374AR = $(AR_PATH) cr
Chris Lattner00950542001-06-06 20:29:01 +0000375
376#----------------------------------------------------------
377
378# Source includes all of the cpp files, and objects are derived from the
379# source files...
Chris Lattnere0010592001-10-18 01:48:09 +0000380# The local Makefile can list other Source files via ExtraSource = ...
Vikram S. Advec4bed342001-10-17 12:33:55 +0000381#
Vikram S. Advead9ea7e2002-10-14 16:40:04 +0000382ifndef Source
Chris Lattner069f9302003-09-15 01:12:04 +0000383Source := $(notdir $(ExtraSource) $(wildcard $(SourceDir)/*.cpp \
John Criswellb1f5cfe2003-12-29 22:02:12 +0000384 $(SourceDir)/*.cc $(SourceDir)/*.c $(SourceDir)/*.y \
385 $(SourceDir)/*.l))
Vikram S. Advead9ea7e2002-10-14 16:40:04 +0000386endif
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000387
John Criswell82f4a5a2003-07-31 20:58:51 +0000388#
389# Libtool Objects
390#
John Criswell410d1b52003-09-09 20:57:03 +0000391Srcs := $(sort $(basename $(Source)))
Chris Lattnereefa3d32003-11-29 09:50:15 +0000392ObjectsO := $(Srcs:%=$(BUILD_OBJ_DIR)/Release/%.lo)
393ObjectsP := $(Srcs:%=$(BUILD_OBJ_DIR)/Profile/%.lo)
394ObjectsG := $(Srcs:%=$(BUILD_OBJ_DIR)/Debug/%.lo)
395ObjectsBC := $(Srcs:%=$(BUILD_OBJ_DIR)/BytecodeObj/%.bc)
Chris Lattnere62dbe92002-07-23 17:56:16 +0000396
John Criswell82f4a5a2003-07-31 20:58:51 +0000397#
398# The real objects underlying the libtool objects
399#
John Criswell410d1b52003-09-09 20:57:03 +0000400RObjs := $(sort $(patsubst Debug/%.o, %.o, $(addsuffix .o,$(basename $(Source)))))
John Criswell82f4a5a2003-07-31 20:58:51 +0000401RObjectsO := $(addprefix $(BUILD_OBJ_DIR)/Release/,$(RObjs))
402RObjectsP := $(addprefix $(BUILD_OBJ_DIR)/Profile/,$(RObjs))
403RObjectsG := $(addprefix $(BUILD_OBJ_DIR)/Debug/,$(RObjs))
404
Chris Lattner00950542001-06-06 20:29:01 +0000405#---------------------------------------------------------
Chris Lattnera8abc222002-09-18 03:22:27 +0000406# Handle the DIRS and PARALLEL_DIRS options
Chris Lattner00950542001-06-06 20:29:01 +0000407#---------------------------------------------------------
408
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000409ifdef DIRS
Brian Gaekef313ea72004-03-10 17:38:01 +0000410all install clean test bytecode stripped-bytecode install-bytecode::
Chris Lattner16d1f732002-09-17 23:45:34 +0000411 $(VERB) for dir in ${DIRS}; do \
John Criswell60577602003-11-25 17:49:22 +0000412 if [ ! -f $$dir/Makefile ]; \
413 then \
John Criswellb3866b62003-11-25 19:32:22 +0000414 $(MKDIR) $$dir; \
John Criswell60577602003-11-25 17:49:22 +0000415 cp $(SourceDir)/$$dir/Makefile $$dir/Makefile; \
416 fi; \
Misha Brukmanc2fb0062004-05-21 00:09:21 +0000417 ($(MAKE) -C $$dir $@ $(MFLAGS)) || exit 1; \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000418 done
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000419endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000420
421# Handle PARALLEL_DIRS
422ifdef PARALLEL_DIRS
Vikram S. Adve6edfe272003-07-10 19:25:29 +0000423all :: $(addsuffix /.makeall , $(PARALLEL_DIRS))
424install :: $(addsuffix /.makeinstall , $(PARALLEL_DIRS))
425clean :: $(addsuffix /.makeclean , $(PARALLEL_DIRS))
426test :: $(addsuffix /.maketest , $(PARALLEL_DIRS))
427bytecode :: $(addsuffix /.makebytecode, $(PARALLEL_DIRS))
Chris Lattnera8df7bd2003-12-01 07:28:25 +0000428stripped-bytecode :: $(addsuffix /.makestripped-bytecode, $(PARALLEL_DIRS))
Brian Gaekef313ea72004-03-10 17:38:01 +0000429install-bytecode :: $(addsuffix /.makeinstall-bytecode, $(PARALLEL_DIRS))
Chris Lattnera8abc222002-09-18 03:22:27 +0000430
Brian Gaekef313ea72004-03-10 17:38:01 +0000431%/.makeall %/.makeinstall %/.makeclean %/.maketest %/.makebytecode %/.makestripped-bytecode %/.makeinstall-bytecode:
John Criswellb3866b62003-11-25 19:32:22 +0000432 $(VERB) if [ ! -f $(@D)/Makefile ]; \
433 then \
434 $(MKDIR) $(@D); \
435 cp $(SourceDir)/$(@D)/Makefile $(@D)/Makefile; \
436 fi; \
Misha Brukman694b3ff2004-05-21 23:21:11 +0000437 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) $(MFLAGS)
Chris Lattner00950542001-06-06 20:29:01 +0000438endif
439
John Criswell7a73b802003-06-30 21:59:07 +0000440# Handle directories that may or may not exist
John Criswell2a6530f2003-06-27 16:58:44 +0000441ifdef OPTIONAL_DIRS
Brian Gaekef313ea72004-03-10 17:38:01 +0000442all install clean test bytecode stripped-bytecode install-bytecode::
John Criswell2a6530f2003-06-27 16:58:44 +0000443 $(VERB) for dir in ${OPTIONAL_DIRS}; do \
John Criswell60577602003-11-25 17:49:22 +0000444 if [ -d $(SourceDir)/$$dir ]; \
John Criswell2a6530f2003-06-27 16:58:44 +0000445 then\
John Criswell60577602003-11-25 17:49:22 +0000446 if [ ! -f $$dir/Makefile ]; \
447 then \
John Criswellb3866b62003-11-25 19:32:22 +0000448 $(MKDIR) $$dir; \
John Criswell60577602003-11-25 17:49:22 +0000449 cp $(SourceDir)/$$dir/Makefile $$dir/Makefile; \
450 fi; \
Misha Brukman694b3ff2004-05-21 23:21:11 +0000451 ($(MAKE) -C$$dir $@ $(MFLAGS)) || exit 1; \
John Criswell2a6530f2003-06-27 16:58:44 +0000452 fi \
453 done
454endif
455
Reid Spencerfc945082004-08-20 09:20:05 +0000456#---------------------------------------------------------
457# Handle the CONFIG_FILES options
458#---------------------------------------------------------
459ifdef CONFIG_FILES
Reid Spencer05e90a02004-08-20 09:32:32 +0000460install:: install-config-files
Reid Spencerfc945082004-08-20 09:20:05 +0000461
462$(sysconfdir):
463 $(MKDIR) $(sysconfdir)
464
Reid Spencer05e90a02004-08-20 09:32:32 +0000465install-config-files: $(sysconfdir) $(CONFIG_FILES)
Reid Spencerfc945082004-08-20 09:20:05 +0000466 $(VERB) echo Installing Configuration Files To $(sysconfdir)
467 $(VERB) for file in $(CONFIG_FILES); do \
468 $(INSTALL) $(SourceDir)/$${file} $(sysconfdir) ; \
469 done
470endif
471
John Criswell7a73b802003-06-30 21:59:07 +0000472###########################################################################
473# Library Build Rules:
474#
Chris Lattner00950542001-06-06 20:29:01 +0000475#---------------------------------------------------------
476# Handle the LIBRARYNAME option - used when building libs...
477#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000478#
479# When libraries are built, they are allowed to optionally define the
480# DONT_BUILD_RELINKED make variable, which, when defined, prevents a .o file
481# from being built for the library. This .o files may then be linked to by a
482# tool if the tool does not need (or want) the semantics a .a file provides
483# (linking in only object files that are "needed"). If a library is never to
484# be used in this way, it is better to define DONT_BUILD_RELINKED, and define
485# BUILD_ARCHIVE instead.
486#
487# Some libraries must be built as .a files (libscalar for example) because if
Chris Lattner1917e952002-07-31 21:32:05 +0000488# it's built as a .o file, then all of the constituent .o files in it will be
Chris Lattnere62dbe92002-07-23 17:56:16 +0000489# linked into tools (for example gccas) even if they only use one of the parts
490# of it. For this reason, sometimes it's useful to use libraries as .a files.
John Criswell7a73b802003-06-30 21:59:07 +0000491###########################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000492
Brian Gaeke8abff792004-01-22 22:53:48 +0000493# Install rule for making bytecode library directory if it does not exist.
494# Trigger this by making libraries that need to be installed here depend on it.
495$(DESTDIR)$(bytecode_libdir):
496 $(MKDIR) $@
497
Chris Lattner00950542001-06-06 20:29:01 +0000498ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000499
Chris Lattner2a548c52002-09-16 22:36:42 +0000500# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000501LIBRARYNAME := $(strip $(LIBRARYNAME))
502
Reid Spencer53a4b602004-09-23 00:58:06 +0000503LIBNAME_O := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).la
504LIBNAME_P := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).la
505LIBNAME_G := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).la
506LIBNAME_CUR := $(DESTLIBCURRENT)/lib$(LIBRARYNAME).la
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000507LIBNAME_AO := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).a
508LIBNAME_AP := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).a
509LIBNAME_AG := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).a
Brian Gaeke78cb3f22003-12-18 20:57:48 +0000510LIBNAME_ACUR := $(DESTLIBCURRENT)/lib$(LIBRARYNAME).a
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000511LIBNAME_OBJO := $(DESTLIBRELEASE)/$(LIBRARYNAME).o
512LIBNAME_OBJP := $(DESTLIBPROFILE)/$(LIBRARYNAME).o
513LIBNAME_OBJG := $(DESTLIBDEBUG)/$(LIBRARYNAME).o
Brian Gaeke78cb3f22003-12-18 20:57:48 +0000514LIBNAME_OBJCUR := $(DESTLIBCURRENT)/$(LIBRARYNAME).o
Chris Lattner481cc7c2003-08-15 02:18:35 +0000515LIBNAME_BC := $(DESTLIBBYTECODE)/lib$(LIBRARYNAME).bc
Chris Lattner00950542001-06-06 20:29:01 +0000516
Brian Gaeke78cb3f22003-12-18 20:57:48 +0000517
John Criswell7a73b802003-06-30 21:59:07 +0000518#--------------------------------------------------------------------
519# Library Targets
520# Modify the top level targets to build the desired libraries.
521#--------------------------------------------------------------------
522
Chris Lattner760da062003-03-14 20:25:22 +0000523# dynamic target builds a shared object version of the library...
Brian Gaeke78cb3f22003-12-18 20:57:48 +0000524dynamic:: $(LIBNAME_CUR)
Chris Lattner481cc7c2003-08-15 02:18:35 +0000525bytecodelib:: $(LIBNAME_BC)
Brian Gaeke13f99322004-01-21 23:57:21 +0000526install-bytecode-library:: $(DESTDIR)$(bytecode_libdir)/lib$(LIBRARYNAME).bc
Chris Lattner481cc7c2003-08-15 02:18:35 +0000527
Brian Gaeke13f99322004-01-21 23:57:21 +0000528$(DESTDIR)$(bytecode_libdir)/lib$(LIBRARYNAME).bc: $(LIBNAME_BC) $(DESTDIR)$(bytecode_libdir)
John Criswell7ec78aa2003-10-16 01:49:00 +0000529 @${ECHO} ======= Installing $(LIBRARYNAME) bytecode library =======
Chris Lattner481cc7c2003-08-15 02:18:35 +0000530 cp $< $@
Vikram S. Adve60f56062002-08-02 18:34:12 +0000531
Chris Lattner760da062003-03-14 20:25:22 +0000532# Does the library want a .o version built?
Chris Lattnere62dbe92002-07-23 17:56:16 +0000533ifndef DONT_BUILD_RELINKED
Brian Gaeke78cb3f22003-12-18 20:57:48 +0000534all:: $(LIBNAME_OBJCUR)
535install:: install-single-object-library
Chris Lattnere62dbe92002-07-23 17:56:16 +0000536endif
Chris Lattner760da062003-03-14 20:25:22 +0000537
538# Does the library want an archive version built?
Chris Lattnere62dbe92002-07-23 17:56:16 +0000539ifdef BUILD_ARCHIVE
Brian Gaeke78cb3f22003-12-18 20:57:48 +0000540all:: $(LIBNAME_ACUR)
541install:: install-archive-library
Chris Lattnere62dbe92002-07-23 17:56:16 +0000542endif
Chris Lattnere62dbe92002-07-23 17:56:16 +0000543
John Criswell7a73b802003-06-30 21:59:07 +0000544#--------------------------------------------------------------------
545# Rules for building libraries
546#--------------------------------------------------------------------
Chris Lattner00950542001-06-06 20:29:01 +0000547
Chris Lattner771ed152003-10-21 18:00:37 +0000548LinkBCLib := $(LLVMGCC) -shared -nostdlib
Chris Lattner481cc7c2003-08-15 02:18:35 +0000549ifdef EXPORTED_SYMBOL_LIST
550LinkBCLib += -Xlinker -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
551else
Chris Lattner22c83282003-09-15 15:06:54 +0000552 ifdef EXPORTED_SYMBOL_FILE
553LinkBCLib += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
554 else
Chris Lattner481cc7c2003-08-15 02:18:35 +0000555LinkBCLib += -Xlinker -disable-internalize
Chris Lattner22c83282003-09-15 15:06:54 +0000556 endif
Chris Lattner481cc7c2003-08-15 02:18:35 +0000557endif
558
559
560# Rule for building bytecode libraries.
Chris Lattneraf06a082003-08-15 03:02:52 +0000561$(LIBNAME_BC): $(ObjectsBC) $(LibSubDirs) $(DESTLIBBYTECODE)/.dir
John Criswella4c53522003-11-03 21:12:49 +0000562 @${ECHO} Linking $(LIBRARYNAME) bytecode library
Chris Lattner481cc7c2003-08-15 02:18:35 +0000563 $(VERB) $(LinkBCLib) -o $@ $(ObjectsBC) $(LibSubDirs) $(LibLinkOpts)
John Criswella4c53522003-11-03 21:12:49 +0000564 @${ECHO} ======= Finished building $(LIBRARYNAME) bytecode library =======
John Criswell7a73b802003-06-30 21:59:07 +0000565#
566# Rules for building dynamically linked libraries.
567#
John Criswellf4ccd992003-07-01 14:52:28 +0000568$(LIBNAME_O): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
John Criswella4c53522003-11-03 21:12:49 +0000569 @${ECHO} Linking $(LIBRARYNAME) dynamic release library
Reid Spencer53a4b602004-09-23 00:58:06 +0000570 $(VERB) $(Link) -o $@ $(ObjectsO) $(LibSubDirs) $(LibLinkOpts)
Chris Lattnerb7dc2b92003-08-15 20:00:47 +0000571 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $*.la $(DESTLIBCURRENT)
John Criswella4c53522003-11-03 21:12:49 +0000572 @${ECHO} ======= Finished building $(LIBRARYNAME) dynamic release library =======
Vikram S. Adve41e78912002-09-20 14:03:13 +0000573
John Criswellf4ccd992003-07-01 14:52:28 +0000574$(LIBNAME_P): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
John Criswella4c53522003-11-03 21:12:49 +0000575 @${ECHO} Linking $(LIBRARYNAME) dynamic profile library
Reid Spencer53a4b602004-09-23 00:58:06 +0000576 $(VERB) $(Link) -o $@ $(ObjectsP) $(LibSubDirs) $(LibLinkOpts)
577 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $@ $(DESTLIBCURRENT)
John Criswella4c53522003-11-03 21:12:49 +0000578 @${ECHO} ======= Finished building $(LIBRARYNAME) dynamic profile library =======
Chris Lattner00950542001-06-06 20:29:01 +0000579
John Criswellf4ccd992003-07-01 14:52:28 +0000580$(LIBNAME_G): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
John Criswella4c53522003-11-03 21:12:49 +0000581 @${ECHO} Linking $(LIBRARYNAME) dynamic debug library
Reid Spencer53a4b602004-09-23 00:58:06 +0000582 $(VERB) $(Link) -o $@ $(ObjectsG) $(LibSubDirs) $(LibLinkOpts)
583 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $@ $(DESTLIBCURRENT)
John Criswella4c53522003-11-03 21:12:49 +0000584 @${ECHO} ======= Finished building $(LIBRARYNAME) dynamic debug library =======
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000585
Brian Gaeke78cb3f22003-12-18 20:57:48 +0000586install-dynamic-library: $(LIBNAME_CUR)
Brian Gaeke6c096962004-02-09 17:38:52 +0000587 $(MKDIR) $(DESTDIR)$(libdir)
Brian Gaeke819567d2004-01-21 21:20:44 +0000588 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_CUR) $(DESTDIR)$(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencer53a4b602004-09-23 00:58:06 +0000589 $(VERB) $(LIBTOOL) --finish $(DESTDIR)$(libdir)
Brian Gaeke78cb3f22003-12-18 20:57:48 +0000590
John Criswell7a73b802003-06-30 21:59:07 +0000591#
592# Rules for building static archive libraries.
593#
John Criswellf4ccd992003-07-01 14:52:28 +0000594$(LIBNAME_AO): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
John Criswella4c53522003-11-03 21:12:49 +0000595 @${ECHO} Linking $(LIBRARYNAME) archive release library
John Criswell7a73b802003-06-30 21:59:07 +0000596 @$(RM) -f $@
John Criswellf4ccd992003-07-01 14:52:28 +0000597 $(VERB) $(Link) -03 -o $@ $(ObjectsO) $(LibSubDirs) -static
John Criswella4c53522003-11-03 21:12:49 +0000598 @${ECHO} Finished building $(LIBRARYNAME) archive release library =======
Vikram S. Adve41e78912002-09-20 14:03:13 +0000599
John Criswellf4ccd992003-07-01 14:52:28 +0000600$(LIBNAME_AP): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
John Criswella4c53522003-11-03 21:12:49 +0000601 @${ECHO} Linking $(LIBRARYNAME) archive profile library
John Criswell7a73b802003-06-30 21:59:07 +0000602 @$(RM) -f $@
John Criswellf4ccd992003-07-01 14:52:28 +0000603 $(VERB) $(Link) -03 $(PROFILE) -o $@ $(ObjectsP) $(LibSubDirs) -static
John Criswella4c53522003-11-03 21:12:49 +0000604 @${ECHO} ======= Finished building $(LIBRARYNAME) archive profile library =======
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000605
John Criswellf4ccd992003-07-01 14:52:28 +0000606$(LIBNAME_AG): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
John Criswella4c53522003-11-03 21:12:49 +0000607 @${ECHO} Linking $(LIBRARYNAME) archive debug library
John Criswell7a73b802003-06-30 21:59:07 +0000608 @$(RM) -f $@
John Criswellf4ccd992003-07-01 14:52:28 +0000609 $(VERB) $(Link) -g $(STRIP) -o $@ $(ObjectsG) $(LibSubDirs) -static
John Criswella4c53522003-11-03 21:12:49 +0000610 @${ECHO} ======= Finished building $(LIBRARYNAME) archive debug library =======
John Criswell7a73b802003-06-30 21:59:07 +0000611
Brian Gaeke78cb3f22003-12-18 20:57:48 +0000612install-archive-library: $(LIBNAME_ACUR)
Brian Gaeke6c096962004-02-09 17:38:52 +0000613 $(MKDIR) $(DESTDIR)$(libdir)
Brian Gaeke819567d2004-01-21 21:20:44 +0000614 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_ACUR) $(DESTDIR)$(libdir)/lib$(LIBRARYNAME).a
Chris Lattner481cc7c2003-08-15 02:18:35 +0000615
John Criswell7a73b802003-06-30 21:59:07 +0000616#
617# Rules for building .o libraries.
618#
John Criswell82f4a5a2003-07-31 20:58:51 +0000619# JTC:
620# Note that for this special case, we specify the actual object files
621# instead of their libtool counterparts. This is because libtool
622# doesn't want to generate a reloadable object file unless it is given
623# .o files explicitly.
624#
625# Note that we're making an assumption here: If we build a .lo file,
626# it's corresponding .o file will be placed in the same directory.
627#
628# I think that is safe.
629#
John Criswellf4ccd992003-07-01 14:52:28 +0000630$(LIBNAME_OBJO): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
John Criswell7ec78aa2003-10-16 01:49:00 +0000631 @${ECHO} "Linking `basename $@`"
John Criswell82f4a5a2003-07-31 20:58:51 +0000632 $(VERB) $(Relink) -o $@ $(RObjectsO) $(LibSubDirs)
Chris Lattnere62dbe92002-07-23 17:56:16 +0000633
John Criswellf4ccd992003-07-01 14:52:28 +0000634$(LIBNAME_OBJP): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
John Criswell7ec78aa2003-10-16 01:49:00 +0000635 @${ECHO} "Linking `basename $@`"
John Criswell82f4a5a2003-07-31 20:58:51 +0000636 $(VERB) $(Relink) -o $@ $(RObjectsP) $(LibSubDirs)
Vikram S. Adve41e78912002-09-20 14:03:13 +0000637
John Criswellf4ccd992003-07-01 14:52:28 +0000638$(LIBNAME_OBJG): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
John Criswell7ec78aa2003-10-16 01:49:00 +0000639 @${ECHO} "Linking `basename $@`"
John Criswell82f4a5a2003-07-31 20:58:51 +0000640 $(VERB) $(Relink) -o $@ $(RObjectsG) $(LibSubDirs)
Chris Lattnere62dbe92002-07-23 17:56:16 +0000641
Brian Gaeke78cb3f22003-12-18 20:57:48 +0000642install-single-object-library: $(LIBNAME_OBJCUR)
Brian Gaeke6c096962004-02-09 17:38:52 +0000643 $(MKDIR) $(DESTDIR)$(libdir)
Brian Gaeke819567d2004-01-21 21:20:44 +0000644 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_OBJCUR) $(DESTDIR)$(libdir)/$(LIBRARYNAME).o
Brian Gaeke78cb3f22003-12-18 20:57:48 +0000645
Chris Lattner00950542001-06-06 20:29:01 +0000646endif
647
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000648#------------------------------------------------------------------------
649# Handle the TOOLNAME option - used when building tool executables...
650#------------------------------------------------------------------------
651#
652# The TOOLNAME option should be used with a USEDLIBS variable that tells the
Chris Lattnere62dbe92002-07-23 17:56:16 +0000653# libraries (and the order of the libs) that should be linked to the
654# tool. USEDLIBS should contain a list of library names (some with .a extension)
655# that are automatically linked in as .o files unless the .a suffix is added.
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000656#
657ifdef TOOLNAME
658
659# TOOLEXENAME* - These compute the output filenames to generate...
John Criswell8bff5092003-06-11 13:55:44 +0000660TOOLEXENAME_G := $(DESTTOOLDEBUG)/$(TOOLNAME)
661TOOLEXENAME_O := $(DESTTOOLRELEASE)/$(TOOLNAME)
662TOOLEXENAME_P := $(DESTTOOLPROFILE)/$(TOOLNAME)
663TOOLEXENAMES := $(DESTTOOLCURRENT)/$(TOOLNAME)
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000664
665# USED_LIBS_OPTIONS - Compute the options line that add -llib1 -llib2, etc.
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000666PROJ_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
667PROJ_LIBS_OPTIONS_G := $(patsubst %.o, $(PROJLIBDEBUGSOURCE)/%.o, $(PROJ_LIBS_OPTIONS))
668PROJ_LIBS_OPTIONS_O := $(patsubst %.o, $(PROJLIBRELEASESOURCE)/%.o,$(PROJ_LIBS_OPTIONS))
669PROJ_LIBS_OPTIONS_P := $(patsubst %.o, $(PROJLIBPROFILESOURCE)/%.o,$(PROJ_LIBS_OPTIONS))
670
671LLVM_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
672LLVM_LIBS_OPTIONS_G := $(patsubst %.o, $(LLVMLIBDEBUGSOURCE)/%.o, $(LLVM_LIBS_OPTIONS))
673LLVM_LIBS_OPTIONS_O := $(patsubst %.o, $(LLVMLIBRELEASESOURCE)/%.o,$(LLVM_LIBS_OPTIONS))
674LLVM_LIBS_OPTIONS_P := $(patsubst %.o, $(LLVMLIBPROFILESOURCE)/%.o,$(LLVM_LIBS_OPTIONS))
675
676LIB_OPTS_G := $(LLVM_LIBS_OPTIONS_G) $(PROJ_LIBS_OPTIONS_G)
Chris Lattnere3ba95e2003-06-20 15:41:57 +0000677LIB_OPTS_O := $(LLVM_LIBS_OPTIONS_O) $(PROJ_LIBS_OPTIONS_O)
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000678LIB_OPTS_P := $(LLVM_LIBS_OPTIONS_P) $(PROJ_LIBS_OPTIONS_P)
679
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000680# USED_LIB_PATHS - Compute the path of the libraries used so that tools are
Chris Lattnere62dbe92002-07-23 17:56:16 +0000681# rebuilt if libraries change. This has to make sure to handle .a/.so and .o
Misha Brukman1ba31382003-07-14 17:26:34 +0000682# files separately.
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000683#
Chris Lattnere62dbe92002-07-23 17:56:16 +0000684STATICUSEDLIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000685USED_LIB_PATHS_G := $(addprefix $(DESTLIBDEBUG)/, $(STATICUSEDLIBS))
686USED_LIB_PATHS_O := $(addprefix $(DESTLIBRELEASE)/, $(STATICUSEDLIBS))
687USED_LIB_PATHS_P := $(addprefix $(DESTLIBPROFILE)/, $(STATICUSEDLIBS))
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000688
John Criswellfe785bd2004-09-16 14:11:25 +0000689LLVMSTATICUSEDLIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
690LLVM_LIB_PATHS_G := $(addprefix $(LLVMLIBDEBUGSOURCE)/, $(LLVMSTATICUSEDLIBS))
691LLVM_LIB_PATHS_O := $(addprefix $(LLVMLIBRELEASESOURCE)/, $(LLVMSTATICUSEDLIBS))
692LLVM_LIB_PATHS_P := $(addprefix $(LLVMLIBPROFILEOURCE)/, $(LLVMSTATICUSEDLIBS))
693
John Criswell7a73b802003-06-30 21:59:07 +0000694#
695# Libtool link options:
696# Ensure that all binaries have their symbols exported so that they can
697# by dlsym'ed.
698#
699LINK_OPTS := -export-dynamic $(TOOLLINKOPTS)
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000700
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000701
702
703
704
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000705# Tell make that we need to rebuild subdirectories before we can link the tool.
706# This affects things like LLI which has library subdirectories.
707$(USED_LIB_PATHS_G) $(USED_LIB_PATHS_O) $(USED_LIB_PATHS_P): \
708 $(addsuffix /.makeall, $(PARALLEL_DIRS))
709
Chris Lattner669bd7c2001-10-13 05:10:29 +0000710all:: $(TOOLEXENAMES)
John Criswell2a6530f2003-06-27 16:58:44 +0000711
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000712clean::
John Criswell7a73b802003-06-30 21:59:07 +0000713 $(VERB) $(RM) -f $(TOOLEXENAMES)
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000714
John Criswellfe785bd2004-09-16 14:11:25 +0000715$(TOOLEXENAME_G): $(ObjectsG) $(USED_LIB_PATHS_G) $(LLVM_LIB_PATHS_G) $(DESTTOOLDEBUG)/.dir
John Criswella4c53522003-11-03 21:12:49 +0000716 @${ECHO} Linking $(TOOLNAME) debug executable $(STRIP_WARN_MSG)
John Criswellf4ccd992003-07-01 14:52:28 +0000717 $(VERB) $(LinkG) -o $@ $(ObjectsG) $(LIB_OPTS_G) $(LINK_OPTS) $(LIBS)
John Criswella4c53522003-11-03 21:12:49 +0000718 @${ECHO} ======= Finished building $(TOOLNAME) debug executable $(STRIP_WARN_MSG) =======
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000719
John Criswellfe785bd2004-09-16 14:11:25 +0000720$(TOOLEXENAME_O): $(ObjectsO) $(USED_LIB_PATHS_O) $(LLVM_LIB_PATHS_O) $(DESTTOOLRELEASE)/.dir
John Criswella4c53522003-11-03 21:12:49 +0000721 @${ECHO} Linking $(TOOLNAME) release executable
John Criswellf4ccd992003-07-01 14:52:28 +0000722 $(VERB) $(LinkO) -o $@ $(ObjectsO) $(LIB_OPTS_O) $(LINK_OPTS) $(LIBS)
John Criswella4c53522003-11-03 21:12:49 +0000723 @${ECHO} ======= Finished building $(TOOLNAME) release executable =======
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000724
John Criswellfe785bd2004-09-16 14:11:25 +0000725$(TOOLEXENAME_P): $(ObjectsP) $(USED_LIB_PATHS_P) $(LLVM_LIB_PATHS_P) $(DESTTOOLPROFILE)/.dir
John Criswella4c53522003-11-03 21:12:49 +0000726 @${ECHO} Linking $(TOOLNAME) profile executable
John Criswellf4ccd992003-07-01 14:52:28 +0000727 $(VERB) $(LinkP) -o $@ $(ObjectsP) $(LIB_OPTS_P) $(LINK_OPTS) $(LIBS)
John Criswella4c53522003-11-03 21:12:49 +0000728 @${ECHO} ======= Finished building $(TOOLNAME) profile executable =======
Vikram S. Adve41e78912002-09-20 14:03:13 +0000729
Brian Gaeke44909cf2003-12-10 00:26:28 +0000730install:: $(TOOLEXENAMES)
Brian Gaeke6c096962004-02-09 17:38:52 +0000731 $(MKDIR) $(DESTDIR)$(bindir)
Brian Gaeke819567d2004-01-21 21:20:44 +0000732 $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) -c -m 0755 $(TOOLEXENAMES) $(DESTDIR)$(bindir)/$(TOOLNAME)
Brian Gaeke44909cf2003-12-10 00:26:28 +0000733
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000734endif
735
736
Chris Lattner00950542001-06-06 20:29:01 +0000737
738#---------------------------------------------------------
Chris Lattner0df847a2003-09-15 22:17:02 +0000739.PRECIOUS: $(BUILD_OBJ_DIR)/Depend/.dir $(BUILD_OBJ_DIR)/BytecodeObj/.dir
John Criswell8bff5092003-06-11 13:55:44 +0000740.PRECIOUS: $(BUILD_OBJ_DIR)/Debug/.dir $(BUILD_OBJ_DIR)/Release/.dir
Chris Lattnerd85b7a42004-07-08 03:42:20 +0000741.PRECIOUS: $(BUILD_OBJ_DIR)/Profile/.dir
Chris Lattner00950542001-06-06 20:29:01 +0000742
John Criswell7a73b802003-06-30 21:59:07 +0000743# Create .lo files in the ObjectFiles directory from the .cpp and .c files...
John Criswell410d1b52003-09-09 20:57:03 +0000744$(BUILD_OBJ_DIR)/Release/%.lo: %.cpp $(BUILD_OBJ_DIR)/Release/.dir
John Criswell7ec78aa2003-10-16 01:49:00 +0000745 @${ECHO} "Compiling `basename $<`"
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000746 $(VERB) $(CompileO) $< -o $@
Chris Lattner00950542001-06-06 20:29:01 +0000747
John Criswell410d1b52003-09-09 20:57:03 +0000748$(BUILD_OBJ_DIR)/Release/%.lo: %.c $(BUILD_OBJ_DIR)/Release/.dir
John Criswell7ec78aa2003-10-16 01:49:00 +0000749 @${ECHO} "Compiling `basename $<`"
Chris Lattner1eeac662002-10-22 23:28:23 +0000750 $(VERB) $(CompileCO) $< -o $@
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000751
John Criswell410d1b52003-09-09 20:57:03 +0000752$(BUILD_OBJ_DIR)/Profile/%.lo: %.cpp $(BUILD_OBJ_DIR)/Profile/.dir
John Criswell7ec78aa2003-10-16 01:49:00 +0000753 @${ECHO} "Compiling `basename $<`"
Vikram S. Adve41e78912002-09-20 14:03:13 +0000754 $(VERB) $(CompileP) $< -o $@
755
John Criswell410d1b52003-09-09 20:57:03 +0000756$(BUILD_OBJ_DIR)/Profile/%.lo: %.c $(BUILD_OBJ_DIR)/Profile/.dir
John Criswell7ec78aa2003-10-16 01:49:00 +0000757 @${ECHO} "Compiling `basename $<`"
Chris Lattner172b6482002-09-22 02:47:15 +0000758 $(VERB) $(CompileCP) $< -o $@
759
John Criswell410d1b52003-09-09 20:57:03 +0000760$(BUILD_OBJ_DIR)/Debug/%.lo: %.cpp $(BUILD_OBJ_DIR)/Debug/.dir
John Criswell7ec78aa2003-10-16 01:49:00 +0000761 @${ECHO} "Compiling `basename $<`"
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000762 $(VERB) $(CompileG) $< -o $@
Chris Lattner00950542001-06-06 20:29:01 +0000763
John Criswell410d1b52003-09-09 20:57:03 +0000764$(BUILD_OBJ_DIR)/Debug/%.lo: %.c $(BUILD_OBJ_DIR)/Debug/.dir
John Criswell7ec78aa2003-10-16 01:49:00 +0000765 @${ECHO} "Compiling `basename $<`"
John Criswell7a73b802003-06-30 21:59:07 +0000766 $(VERB) $(CompileCG) $< -o $@
767
Chris Lattner0df847a2003-09-15 22:17:02 +0000768$(BUILD_OBJ_DIR)/BytecodeObj/%.bc: %.cpp $(BUILD_OBJ_DIR)/BytecodeObj/.dir $(LCC1XX)
John Criswell7ec78aa2003-10-16 01:49:00 +0000769 @${ECHO} "Compiling `basename $<` to bytecode"
Chris Lattnerd1803002003-12-06 20:59:45 +0000770 $(VERB) $(LLVMGXX) $(CompileCommonOpts) $(CPPFLAGS) -c $< -o $@
Chris Lattner481cc7c2003-08-15 02:18:35 +0000771
Chris Lattner0df847a2003-09-15 22:17:02 +0000772$(BUILD_OBJ_DIR)/BytecodeObj/%.bc: %.c $(BUILD_OBJ_DIR)/BytecodeObj/.dir $(LCC1)
John Criswell7ec78aa2003-10-16 01:49:00 +0000773 @${ECHO} "Compiling `basename $<` to bytecode"
Chris Lattnerd1803002003-12-06 20:59:45 +0000774 $(VERB) $(LLVMGCC) $(CompileCommonOpts) $(CPPFLAGS) -c $< -o $@
Chris Lattner481cc7c2003-08-15 02:18:35 +0000775
Chris Lattner0df847a2003-09-15 22:17:02 +0000776$(BUILD_OBJ_DIR)/BytecodeObj/%.bc: %.ll $(BUILD_OBJ_DIR)/BytecodeObj/.dir $(LLVMAS)
John Criswell7ec78aa2003-10-16 01:49:00 +0000777 @${ECHO} "Compiling `basename $<` to bytecode"
Chris Lattner481cc7c2003-08-15 02:18:35 +0000778 $(VERB) $(LLVMAS) $< -f -o $@
779
780
Chris Lattnere8996782003-01-16 22:44:19 +0000781#
782# Rules for building lex/yacc files
783#
784LEX_FILES = $(filter %.l, $(Source))
785LEX_OUTPUT = $(LEX_FILES:%.l=%.cpp)
786YACC_FILES = $(filter %.y, $(Source))
787YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output)
788.PRECIOUS: $(LEX_OUTPUT) $(YACC_OUTPUT)
789
Chris Lattner00950542001-06-06 20:29:01 +0000790# Create a .cpp source file from a flex input file... this uses sed to cut down
791# on the warnings emited by GCC...
Chris Lattner6d131b42003-01-23 16:33:10 +0000792#
793# The last line is a gross hack to work around flex aparently not being able to
794# resize the buffer on a large token input. Currently, for uninitialized string
795# buffers in LLVM we can generate very long tokens, so this is a hack around it.
Chris Lattnerb7dc2b92003-08-15 20:00:47 +0000796# FIXME. (f.e. char Buffer[10000] )
Chris Lattner6d131b42003-01-23 16:33:10 +0000797#
Chris Lattner00950542001-06-06 20:29:01 +0000798%.cpp: %.l
John Criswell7ec78aa2003-10-16 01:49:00 +0000799 @${ECHO} Flexing $<
Chris Lattner7bb107d2003-08-04 19:48:10 +0000800 $(VERB) $(FLEX) -t $< | \
801 $(SED) '/^find_rule/d' | \
802 $(SED) 's/void yyunput/inline void yyunput/' | \
John Criswell7a73b802003-06-30 21:59:07 +0000803 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
Chris Lattnera328f882003-08-04 19:47:06 +0000804 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
805 > $@.tmp
John Criswelld741bcf2003-08-12 18:51:51 +0000806 $(VERB) cmp -s $@ $@.tmp > /dev/null || ${MV} -f $@.tmp $@
Chris Lattnera328f882003-08-04 19:47:06 +0000807 @# remove the output of flex if it didn't get moved over...
808 @rm -f $@.tmp
Chris Lattner00950542001-06-06 20:29:01 +0000809
810# Rule for building the bison parsers...
Chris Lattner694c5df2003-05-15 21:28:55 +0000811%.c: %.y # Cancel built-in rules for yacc
812%.h: %.y # Cancel built-in rules for yacc
Chris Lattner00950542001-06-06 20:29:01 +0000813%.cpp %.h : %.y
Misha Brukmanb6d59a22003-11-05 06:41:14 +0000814 @${ECHO} "Bisoning `basename $<`"
John Criswell410d1b52003-09-09 20:57:03 +0000815 $(VERB) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
John Criswelld741bcf2003-08-12 18:51:51 +0000816 $(VERB) cmp -s $*.tab.c $*.cpp > /dev/null || ${MV} -f $*.tab.c $*.cpp
817 $(VERB) cmp -s $*.tab.h $*.h > /dev/null || ${MV} -f $*.tab.h $*.h
Chris Lattnera328f882003-08-04 19:47:06 +0000818 @# If the files were not updated, don't leave them lying around...
819 @rm -f $*.tab.c $*.tab.h
Chris Lattner00950542001-06-06 20:29:01 +0000820
821# To create the directories...
822%/.dir:
John Criswell7a73b802003-06-30 21:59:07 +0000823 $(VERB) ${MKDIR} $* > /dev/null
824 @$(DATE) > $@
Chris Lattner00950542001-06-06 20:29:01 +0000825
Chris Lattner30440c62003-01-16 21:06:18 +0000826# To create postscript files from dot files...
John Criswelle0f9ac62003-10-02 19:02:02 +0000827ifneq ($(DOT),false)
Chris Lattner30440c62003-01-16 21:06:18 +0000828%.ps: %.dot
John Criswell7a73b802003-06-30 21:59:07 +0000829 ${DOT} -Tps < $< > $@
830else
831%.ps: %.dot
832 ${ECHO} "Cannot build $@: The program dot is not installed"
833endif
Chris Lattner30440c62003-01-16 21:06:18 +0000834
John Criswell7f336952003-09-06 14:44:17 +0000835#
836# This rules ensures that header files that are removed still have a rule for
837# which they can be "generated." This allows make to ignore them and
838# reproduce the dependency lists.
839#
John Criswell4b6e5d12003-09-18 18:37:08 +0000840%.h:: ;
John Criswell7f336952003-09-06 14:44:17 +0000841
Chris Lattner172b6482002-09-22 02:47:15 +0000842# 'make clean' nukes the tree
Chris Lattner00950542001-06-06 20:29:01 +0000843clean::
Chris Lattner481cc7c2003-08-15 02:18:35 +0000844 $(VERB) $(RM) -rf $(BUILD_OBJ_DIR)/Debug $(BUILD_OBJ_DIR)/Release
845 $(VERB) $(RM) -rf $(BUILD_OBJ_DIR)/Profile $(BUILD_OBJ_DIR)/Depend
Chris Lattner0df847a2003-09-15 22:17:02 +0000846 $(VERB) $(RM) -rf $(BUILD_OBJ_DIR)/BytecodeObj
Brian Gaeke9d3cd402004-01-21 19:53:11 +0000847 $(VERB) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
848ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
849 $(VERB) $(RM) -f *$(SHLIBEXT)
850endif
John Criswell7a73b802003-06-30 21:59:07 +0000851 $(VERB) $(RM) -f $(LEX_OUTPUT) $(YACC_OUTPUT)
852
John Criswell7a73b802003-06-30 21:59:07 +0000853###########################################################################
854# C/C++ Dependencies
855# Define variables and rules that generate header file dependencies
856# from C/C++ source files.
857###########################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000858
Chris Lattner33ad24a2003-08-22 14:10:16 +0000859ifndef DISABLE_AUTO_DEPENDENCIES
860
Chris Lattner694c5df2003-05-15 21:28:55 +0000861# If dependencies were generated for the file that included this file,
Misha Brukman36bc6422003-08-21 22:02:18 +0000862# include the dependencies now...
Chris Lattner00950542001-06-06 20:29:01 +0000863#
John Criswell410d1b52003-09-09 20:57:03 +0000864SourceBaseNames := $(basename $(Source))
John Criswell8bff5092003-06-11 13:55:44 +0000865SourceDepend := $(SourceBaseNames:%=$(BUILD_OBJ_DIR)/Depend/%.d)
Chris Lattner694c5df2003-05-15 21:28:55 +0000866
867# Create dependencies for the *.cpp files...
John Criswell410d1b52003-09-09 20:57:03 +0000868$(BUILD_OBJ_DIR)/Depend/%.d: %.cpp $(BUILD_OBJ_DIR)/Depend/.dir
Chris Lattner52d792c2003-11-08 21:23:06 +0000869 $(VERB) $(Depend) $< | $(SED) 's|\.o:|\.lo:|' | $(SED) 's|$*\.lo *|$(BUILD_OBJ_DIR)/Release/& $(BUILD_OBJ_DIR)/Profile/& $(BUILD_OBJ_DIR)/Debug/& $(BUILD_OBJ_DIR)/Depend/$(@F)|g' > $@
Chris Lattner694c5df2003-05-15 21:28:55 +0000870
871# Create dependencies for the *.c files...
John Criswell410d1b52003-09-09 20:57:03 +0000872$(BUILD_OBJ_DIR)/Depend/%.d: %.c $(BUILD_OBJ_DIR)/Depend/.dir
Chris Lattner52d792c2003-11-08 21:23:06 +0000873 $(VERB) $(DependC) -o $@ $< | $(SED) 's|\.o:|\.lo:|' | $(SED) 's|$*\.lo *|$(BUILD_OBJ_DIR)/Release/& $(BUILD_OBJ_DIR)/Profile/& $(BUILD_OBJ_DIR)/Debug/& $(BUILD_OBJ_DIR)/Depend/$(@F)|g' > $@
Chris Lattner694c5df2003-05-15 21:28:55 +0000874
John Criswell7a73b802003-06-30 21:59:07 +0000875#
John Criswellbd082802003-10-07 14:16:44 +0000876# Autoconf Dependencies.
877#
Misha Brukman94fe1f92003-10-07 15:24:23 +0000878$(LLVM_OBJ_ROOT)/config.status:: $(LLVM_SRC_ROOT)/configure
Chris Lattner4faf8602003-10-10 15:55:43 +0000879 @${ECHO} "****************************************************************"
880 @${ECHO} " You need to re-run $(LLVM_SRC_ROOT)/configure"
881 @${ECHO} " in directory $(LLVM_OBJ_ROOT)"
882 @${ECHO} "****************************************************************"
John Criswellbd082802003-10-07 14:16:44 +0000883 $(VERB) exit 1
884
Misha Brukman4f7a8cf2003-11-09 21:36:19 +0000885# If the Makefile in the source tree has been updated, copy it over into the
886# build tree.
887Makefile :: $(BUILD_SRC_DIR)/Makefile
Misha Brukman2fe69092003-11-11 00:05:29 +0000888 @${ECHO} "===== Updating Makefile from source dir: `dirname $<` ====="
John Criswellb3866b62003-11-25 19:32:22 +0000889 $(MKDIR) $(@D)
Misha Brukman4f7a8cf2003-11-09 21:36:19 +0000890 cp -f $< $@
891
John Criswellbd082802003-10-07 14:16:44 +0000892#
John Criswell7a73b802003-06-30 21:59:07 +0000893# Include dependencies generated from C/C++ source files, but not if we
894# are cleaning (this example taken from the GNU Make Manual).
895#
896ifneq ($(MAKECMDGOALS),clean)
John Criswelld741bcf2003-08-12 18:51:51 +0000897ifneq ($(MAKECMDGOALS),distclean)
Chris Lattner15444a92003-08-29 14:07:02 +0000898-include /dev/null $(SourceDepend)
John Criswell7a73b802003-06-30 21:59:07 +0000899endif
John Criswelld741bcf2003-08-12 18:51:51 +0000900endif
Chris Lattner1ddb6b62003-08-18 17:27:40 +0000901
Chris Lattner33ad24a2003-08-22 14:10:16 +0000902endif # ifndef DISABLE_AUTO_DEPENDENCIES