blob: 89f28b84e0b322c6104606d4f5fb34b727051d9a [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
John Criswell2a6530f2003-06-27 16:58:44 +000015#
John Criswell7f336952003-09-06 14:44:17 +000016# Set the VPATH so that we can find source files.
John Criswell8bff5092003-06-11 13:55:44 +000017#
Reid Spencer4d71b662004-10-22 21:01:56 +000018VPATH=$(BUILD_SRC_DIR)
John Criswell8bff5092003-06-11 13:55:44 +000019
Reid Spencer3a561f52004-10-23 20:04:14 +000020###############################################################################
21# TARGETS: Define standard targets that can be invoked
22###############################################################################
John Criswell7a73b802003-06-30 21:59:07 +000023
Chris Lattner00950542001-06-06 20:29:01 +000024#--------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +000025# Define the various target sets
26#--------------------------------------------------------------------
27RECURSIVE_TARGETS := all clean check install uninstall
28LOCAL_TARGETS := all-local clean-local check-local install-local printvars\
Reid Spencer151f8ba2004-10-25 08:27:37 +000029 uninstall-local
Reid Spencere5487ba2004-10-24 07:53:21 +000030TOPLEV_TARGETS := dist dist-check dist-clean tags
Reid Spencer151f8ba2004-10-25 08:27:37 +000031USER_TARGETS := $(RECURSIVE_TARGETS) $(LOCAL_TARGETS) $(TOPLEV_TARGETS)
Reid Spencere5487ba2004-10-24 07:53:21 +000032INTERNAL_TARGETS := preconditions \
33 install-config-dir install-shared-library install-bytecode-library \
34 install-archive-library install-relinked-library install-tool \
35 uninstall-config-dir uninstall-shared-library uninstall-bytecode-library \
36 uninstall-archive-library uninstall-relinked-library uninstall-tool
Reid Spencer3a561f52004-10-23 20:04:14 +000037
38#--------------------------------------------------------------------
39# Mark all of these targets as phony to avoid implicit rule search
40#--------------------------------------------------------------------
Reid Spencer151f8ba2004-10-25 08:27:37 +000041.PHONY: $(USER_TARGETS) $(INTERNAL_TARGETS)
Reid Spencer3a561f52004-10-23 20:04:14 +000042
43#--------------------------------------------------------------------
44# Make sure all the user-target rules are double colon rules and that
45# the preconditions are run first.
46#--------------------------------------------------------------------
47
Reid Spencer151f8ba2004-10-25 08:27:37 +000048$(USER_TARGETS) :: preconditions
49
Reid Spencer3a561f52004-10-23 20:04:14 +000050all :: all-local
51check:: check-local
52clean:: clean-local
53install :: install-local
54uninstall :: uninstall-local
Reid Spencer3a561f52004-10-23 20:04:14 +000055check-local :: all-local
56install-local :: all-local
Reid Spencer3a561f52004-10-23 20:04:14 +000057
Reid Spencer3a561f52004-10-23 20:04:14 +000058###############################################################################
59# SUFFIXES: Reset the list of suffixes we know how to build
60###############################################################################
61.SUFFIXES:
62.SUFFIXES: .c .cpp .h .hpp .y .l .lo .o .a $(SHLIBEXT) .bc .td .ps .dot $(SUFFIXES)
63
64###############################################################################
65# VARIABLES: Set up various variables based on configuration data
66###############################################################################
67
68#--------------------------------------------------------------------
69# Variables derived from configuration we are building
Chris Lattner00950542001-06-06 20:29:01 +000070#--------------------------------------------------------------------
71
Chris Lattner760da062003-03-14 20:25:22 +000072ifdef ENABLE_PROFILING
Chris Lattner760da062003-03-14 20:25:22 +000073 CONFIGURATION := Profile
Reid Spencer4d71b662004-10-22 21:01:56 +000074 CXXFLAGS += -O3 -DNDEBUG -felide-constructors -finline-functions -pg
75 CFLAGS += -O3 -DNDEBUG -pg
76 LDFLAGS += -O3 -DNDEBUG -pg
Chris Lattner760da062003-03-14 20:25:22 +000077else
78 ifdef ENABLE_OPTIMIZED
79 CONFIGURATION := Release
Reid Spencer4d71b662004-10-22 21:01:56 +000080 CXXFLAGS += -O3 -DNDEBUG -finline-functions -felide-constructors -fomit-frame-pointer
81 CFLAGS += -O3 -DNDEBUG -fomit-frame-pointer
82 LDFLAGS += -O3 -DNDEBUG
Chris Lattner760da062003-03-14 20:25:22 +000083 else
84 CONFIGURATION := Debug
Reid Spencer4d71b662004-10-22 21:01:56 +000085 CXXFLAGS += -g -D_DEBUG
86 CFLAGS += -g -D_DEBUG
87 LDFLAGS += -g -D_DEBUG
88 KEEP_SYMBOLS := 1
Chris Lattner760da062003-03-14 20:25:22 +000089 endif
90endif
91
Reid Spencer4d71b662004-10-22 21:01:56 +000092ARFLAGS := cru
Reid Spencer3a561f52004-10-23 20:04:14 +000093
94#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +000095# Directory locations
Reid Spencer3a561f52004-10-23 20:04:14 +000096#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +000097OBJDIR := $(BUILD_OBJ_DIR)/$(CONFIGURATION)
98LIBDIR := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
99TOOLDIR := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
100LLVMLIBDIR := $(LLVM_OBJ_ROOT)/lib/$(CONFIGURATION)
101LLVMTOOLDIR := $(LLVM_OBJ_ROOT)/tools/$(CONFIGURATION)
John Criswell7a73b802003-06-30 21:59:07 +0000102
Reid Spencer3a561f52004-10-23 20:04:14 +0000103#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000104# Full Paths To Compiled Tools and Utilities
Reid Spencer3a561f52004-10-23 20:04:14 +0000105#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000106LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
107LLVMAS := $(LLVMTOOLDIR)/llvm-as$(EXEEXT)
108BURG := $(LLVMTOOLDIR)/burg$(EXEEXT)
109TBLGEN := $(LLVMTOOLDIR)/tblgen$(EXEEXT)
110GCCLD := $(LLVMTOOLDIR)/gccld$(EXEEXT)
111LLVMGCC := PATH=$(LLVMTOOLDIR):$(PATH) $(LLVMGCCDIR)/bin/gcc
112LLVMGXX := PATH=$(LLVMTOOLDIR):$(PATH) $(LLVMGCCDIR)/bin/g++
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000113
Reid Spencer4d71b662004-10-22 21:01:56 +0000114# Need a better way to compute this.
115LLVMGCCLIBDIR := $(dir $(shell $(LLVMGCC) -print-file-name=libgcc.a))/
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000116
Reid Spencer3a561f52004-10-23 20:04:14 +0000117#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000118# Adjust to user's request
Reid Spencer3a561f52004-10-23 20:04:14 +0000119#--------------------------------------------------------------------
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000120
Reid Spencer3a561f52004-10-23 20:04:14 +0000121# Adjust LIBTOOL options for shared libraries, or not.
John Criswell82f4a5a2003-07-31 20:58:51 +0000122ifndef SHARED_LIBRARY
Reid Spencer4d71b662004-10-22 21:01:56 +0000123 LIBTOOL += --tag=disable-shared
124else
125 LDFLAGS += -rpath $(LIBDIR)
John Criswell82f4a5a2003-07-31 20:58:51 +0000126endif
127
Reid Spencer3a561f52004-10-23 20:04:14 +0000128# Adjust settings for verbose mode
Chris Lattner760da062003-03-14 20:25:22 +0000129ifndef VERBOSE
Reid Spencer4d71b662004-10-22 21:01:56 +0000130 VERB := @
131 LIBTOOL += --silent
132 AR += >/dev/null 2>/dev/null
Reid Spencer151f8ba2004-10-25 08:27:37 +0000133 CONFIGUREFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
134else
135 CONFIGUREFLAGS :=
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000136endif
137
Vikram S. Advefeeae582002-09-18 11:55:13 +0000138# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000139ifndef KEEP_SYMBOLS
Reid Spencer4d71b662004-10-22 21:01:56 +0000140 STRIP = $(PLATFORMSTRIPOPTS)
141 STRIP_WARN_MSG = "(without symbols)"
Vikram S. Advefeeae582002-09-18 11:55:13 +0000142endif
143
Reid Spencer3a561f52004-10-23 20:04:14 +0000144# Adjust linker flags for building an executable
Reid Spencer4d71b662004-10-22 21:01:56 +0000145ifdef TOOLNAME
146 LDFLAGS += -rpath $(TOOLDIR) -export-dynamic $(TOOLLINKOPTS)
147endif
Chris Lattner00950542001-06-06 20:29:01 +0000148
Reid Spencer3a561f52004-10-23 20:04:14 +0000149# Use TOOLLINKOPTSB to pass options to the linker like library search
150# path etc.
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000151# Note that this is different from TOOLLINKOPTS, these options
152# are passed to the linker *before* the USEDLIBS options are passed.
153# e.g. usage TOOLLINKOPTSB = -L/home/xxx/lib
154ifdef TOOLLINKOPTSB
Reid Spencer4d71b662004-10-22 21:01:56 +0000155LDFLAGS += $(TOOLLINKOPTSB)
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000156endif
157
Reid Spencer3a561f52004-10-23 20:04:14 +0000158#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000159# Options To Invoke Tools
Reid Spencer3a561f52004-10-23 20:04:14 +0000160#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000161
162CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
163
Reid Spencer3a561f52004-10-23 20:04:14 +0000164LDFLAGS += -L$(LIBDIR) -L$(LLVMLIBDIR)
Reid Spencer4d71b662004-10-22 21:01:56 +0000165CPPFLAGS += -I$(BUILD_OBJ_DIR) \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000166 -I$(BUILD_SRC_DIR) \
167 -I$(BUILD_SRC_ROOT)/include \
168 -I$(BUILD_OBJ_ROOT)/include \
169 -I$(LLVM_OBJ_ROOT)/include \
170 -I$(LLVM_SRC_ROOT)/include \
171 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
Reid Spencer4d71b662004-10-22 21:01:56 +0000172
Reid Spencer3a561f52004-10-23 20:04:14 +0000173Compile.C = $(CC) $(CPPFLAGS) $(CompileCommonOpts) -c $(CFLAGS)
174Compile.CXX = $(CXX) $(CPPFLAGS) $(CompileCommonOpts) $(CXXFLAGS) -c
175LTCompile.C = $(LIBTOOL) --mode=compile $(Compile.C)
176LTCompile.CXX = $(LIBTOOL) --tag=CXX --mode=compile $(Compile.CXX)
177BCCompile.CXX = $(LLVMGXX) $(CPPFLAGS) $(CompileCommonOpts) $(CXXFLAGS) -c
178BCCompile.C = $(LLVMGCC) $(CPPFLAGS) $(CompileCommonOpts) $(CFLAGS) -c
179Link = $(LIBTOOL) --tag=CXX --mode=link $(CXX) $(CPPFLAGS) \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000180 $(CompileCommonOpts) $(LDFLAGS) $(STRIP)
Reid Spencer3a561f52004-10-23 20:04:14 +0000181Relink = $(LIBTOOL) --tag=CXX --mode=link $(CXX)
182BCLinkLib = $(LLVMGCC) -shared -nostdlib
183Burg = $(BURG) -I $(BUILD_SRC_DIR)
184TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
185Archive = $(AR) $(ARFLAGS)
Reid Spencer4d71b662004-10-22 21:01:56 +0000186ifdef RANLIB
Reid Spencer3a561f52004-10-23 20:04:14 +0000187Ranlib = $(RANLIB)
Reid Spencer4d71b662004-10-22 21:01:56 +0000188else
Reid Spencer3a561f52004-10-23 20:04:14 +0000189Ranlib = ranlib
John Criswell7a73b802003-06-30 21:59:07 +0000190endif
191
Chris Lattner00950542001-06-06 20:29:01 +0000192#----------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000193# Get the list of source files
194#----------------------------------------------------------
195ifndef SOURCES
196SOURCES := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000197 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
198 $(BUILD_SRC_DIR)/*.l))
Reid Spencer4d71b662004-10-22 21:01:56 +0000199endif
200
201ifdef BUILT_SOURCES
Reid Spencer3a561f52004-10-23 20:04:14 +0000202SOURCES += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Vikram S. Advead9ea7e2002-10-14 16:40:04 +0000203endif
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000204
Reid Spencer3a561f52004-10-23 20:04:14 +0000205#----------------------------------------------------------
206# Types of objects that can be built from sources
207#----------------------------------------------------------
208BASENAME_SOURCES := $(sort $(basename $(SOURCES)))
209ObjectsO := $(BASENAME_SOURCES:%=$(OBJDIR)/%.o)
210ObjectsLO := $(BASENAME_SOURCES:%=$(OBJDIR)/%.lo)
211ObjectsBC := $(BASENAME_SOURCES:%=$(OBJDIR)/%.bc)
212
213
214###############################################################################
215# DIRECTORIES: Handle recursive descent of directory structure
216###############################################################################
John Criswell82f4a5a2003-07-31 20:58:51 +0000217
Chris Lattner00950542001-06-06 20:29:01 +0000218#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000219# Handle the DIRS options for sequential construction
Chris Lattner00950542001-06-06 20:29:01 +0000220#---------------------------------------------------------
221
Reid Spencer151f8ba2004-10-25 08:27:37 +0000222SUBDIRS :=
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000223ifdef DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000224SUBDIRS += $(DIRS)
Reid Spencer3a561f52004-10-23 20:04:14 +0000225$(RECURSIVE_TARGETS)::
Reid Spencer4d71b662004-10-22 21:01:56 +0000226 $(VERB) for dir in $(DIRS); do \
227 if [ ! -f $$dir/Makefile ]; then \
228 $(MKDIR) $$dir; \
229 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
230 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000231 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000232 done
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000233endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000234
Reid Spencer3a561f52004-10-23 20:04:14 +0000235#---------------------------------------------------------
236# Handle the EXPERIMENTAL_DIRS options ensuring success
237# after each directory is built.
238#---------------------------------------------------------
239ifdef EXPERIMENTAL_DIRS
240$(RECURSIVE_TARGETS)::
241 $(VERB) for dir in $(EXPERIMENTAL_DIRS); do \
242 if [ ! -f $$dir/Makefile ]; then \
243 $(MKDIR) $$dir; \
244 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
245 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000246 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000247 done
248endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000249
Reid Spencer3a561f52004-10-23 20:04:14 +0000250#---------------------------------------------------------
251# Handle the PARALLEL_DIRS options for parallel construction
252#---------------------------------------------------------
253ifdef PARALLEL_DIRS
254
Reid Spencer151f8ba2004-10-25 08:27:37 +0000255SUBDIRS += $(PARALLEL_DIRS)
Reid Spencer3a561f52004-10-23 20:04:14 +0000256# Unfortunately, this list must be maintained if new
257# recursive targets are added.
258all :: $(addsuffix /.makeall , $(PARALLEL_DIRS))
259clean :: $(addsuffix /.makeclean , $(PARALLEL_DIRS))
260check :: $(addsuffix /.makecheck , $(PARALLEL_DIRS))
261install :: $(addsuffix /.makeinstall , $(PARALLEL_DIRS))
262uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
263
264Parallel_Targets := $(foreach T,$(RECURSIVE_TARGETS),%/.make$(T))
265
266$(Parallel_Targets) :
Reid Spencer4d71b662004-10-22 21:01:56 +0000267 $(VERB) if [ ! -f $(@D)/Makefile ]; then \
268 $(MKDIR) $(@D); \
269 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswellb3866b62003-11-25 19:32:22 +0000270 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000271 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
Chris Lattner00950542001-06-06 20:29:01 +0000272endif
273
Reid Spencer3a561f52004-10-23 20:04:14 +0000274#---------------------------------------------------------
275# Handle the OPTIONAL_DIRS options for directores that may
276# or may not exist.
277#---------------------------------------------------------
John Criswell2a6530f2003-06-27 16:58:44 +0000278ifdef OPTIONAL_DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000279
280SUBDIRS += $(OPTIONAL_DIRS)
281
Reid Spencer3a561f52004-10-23 20:04:14 +0000282$(RECURSIVE_TARGETS)::
Reid Spencer4d71b662004-10-22 21:01:56 +0000283 $(VERB) for dir in $(OPTIONAL_DIRS); do \
284 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
285 if [ ! -f $$dir/Makefile ]; then \
286 $(MKDIR) $$dir; \
287 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
288 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000289 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000290 fi \
John Criswell2a6530f2003-06-27 16:58:44 +0000291 done
292endif
293
Reid Spencerfc945082004-08-20 09:20:05 +0000294#---------------------------------------------------------
295# Handle the CONFIG_FILES options
296#---------------------------------------------------------
297ifdef CONFIG_FILES
Reid Spencerfc945082004-08-20 09:20:05 +0000298
Reid Spencere5487ba2004-10-24 07:53:21 +0000299install-local:: install-config-dir
Reid Spencer3a561f52004-10-23 20:04:14 +0000300
301install-config-dir: $(sysconfdir) $(CONFIG_FILES)
Reid Spencer37130d22004-10-04 07:05:07 +0000302 $(VERB)$(ECHO) Installing Configuration Files To $(sysconfdir)
303 $(VERB)for file in $(CONFIG_FILES); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000304 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
Reid Spencerfc945082004-08-20 09:20:05 +0000305 done
Reid Spencer3a561f52004-10-23 20:04:14 +0000306
Reid Spencere5487ba2004-10-24 07:53:21 +0000307uninstall-local:: uninstall-config-dir
308
309uninstall-config-dir:
310 $(VERB)$(ECHO) Uninstalling Configuration Files From $(sysconfdir)
311 $(VERB)for file in $(CONFIG_FILES); do \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000312 $(RM) -f $(sysconfdir)/$${file} ; \
Reid Spencere5487ba2004-10-24 07:53:21 +0000313 done
314
Reid Spencer3a561f52004-10-23 20:04:14 +0000315$(sysconfdir):
316 $(MKDIR) $(sysconfdir)
317
Reid Spencerfc945082004-08-20 09:20:05 +0000318endif
319
Reid Spencer3a561f52004-10-23 20:04:14 +0000320###############################################################################
321# Library Build Rules: Four ways to build a library
322###############################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000323
Reid Spencere45ebfa2004-10-26 07:09:33 +0000324$(libdir):
325 $(VERB) $(MKDIR) $(libdir)
326
327$(bytecode_libdir):
328 $(VERB) $(MKDIR) $(bytecode_libdir)
329
330
Brian Gaeke8abff792004-01-22 22:53:48 +0000331
Reid Spencer3a561f52004-10-23 20:04:14 +0000332# if we're building a library ...
Chris Lattner00950542001-06-06 20:29:01 +0000333ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000334
Chris Lattner2a548c52002-09-16 22:36:42 +0000335# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000336LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencer4d71b662004-10-22 21:01:56 +0000337LIBNAME_LA := $(LIBDIR)/lib$(LIBRARYNAME).la
338LIBNAME_A := $(LIBDIR)/lib$(LIBRARYNAME).a
339LIBNAME_O := $(LIBDIR)/$(LIBRARYNAME).o
340LIBNAME_BC := $(LIBDIR)/lib$(LIBRARYNAME).bc
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000341
Reid Spencer3a561f52004-10-23 20:04:14 +0000342#---------------------------------------------------------
343# Shared Library Targets:
344# If the user asked for a shared library to be built
345# with the SHARED_LIBRARY variable, then we provide
346# targets for building them.
347#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000348ifdef SHARED_LIBRARY
349
Reid Spencer3a561f52004-10-23 20:04:14 +0000350all-local:: $(LIBNAME_LA)
Reid Spencer4d71b662004-10-22 21:01:56 +0000351
352$(LIBNAME_LA): $(BUILT_SOURCES) $(ObjectsLO) $(LIBDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000353 @$(ECHO) Linking $(CONFIGURATION) Shared Library $(notdir $@)
Reid Spencer4d71b662004-10-22 21:01:56 +0000354 $(VERB) $(Link) -o $@ $(ObjectsLO)
355 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $@ $(LIBDIR)
Reid Spencer3a561f52004-10-23 20:04:14 +0000356
357clean-local::
Reid Spencere5487ba2004-10-24 07:53:21 +0000358ifneq ($(strip $(LIBNAME_LA)),)
Reid Spencer4d71b662004-10-22 21:01:56 +0000359 $(VERB) $(RM) -f $(LIBNAME_LA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000360endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000361
Reid Spencere5487ba2004-10-24 07:53:21 +0000362DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
363install-local:: install-shared-library
Reid Spencer4d71b662004-10-22 21:01:56 +0000364
Reid Spencere45ebfa2004-10-26 07:09:33 +0000365install-shared-library: $(libdir) $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000366
367$(DestSharedLib): $(LIBNAME_LA)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000368 @$(ECHO) Installing $(CONFIGURATION) Shared Library $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000369 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_LA) $(DestSharedLib)
370 $(VERB) $(LIBTOOL) --finish $(libdir)
371
372uninstall-local:: uninstall-shared-library
373
374uninstall-shared-library:
Reid Spencere45ebfa2004-10-26 07:09:33 +0000375 @$(ECHO) Uninstalling $(CONFIGURATION) Shared Library $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000376 $(VERB) $(RM) -f $(DestSharedLib)
377
Reid Spencer4d71b662004-10-22 21:01:56 +0000378endif
379
Reid Spencer3a561f52004-10-23 20:04:14 +0000380#---------------------------------------------------------
381# Bytecode Library Targets:
382# If the user asked for a bytecode library to be built
383# with the BYTECODE_LIBRARY variable, then we provide
384# targets for building them.
385#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000386ifdef BYTECODE_LIBRARY
387
388ifdef EXPORTED_SYMBOL_LIST
389 BCLinkLib += -Xlinker -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
390else
391 ifdef EXPORTED_SYMBOL_FILE
392 BCLinkLib += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
393 else
394 BCLinkLib += -Xlinker -disable-internalize
395 endif
396endif
397
Reid Spencer3a561f52004-10-23 20:04:14 +0000398all-local:: $(LIBNAME_BC)
Reid Spencer4d71b662004-10-22 21:01:56 +0000399
400$(LIBNAME_BC): $(BUILT_SOURCES) $(ObjectsBC) $(LIBDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000401 @$(ECHO) Linking $(CONFIGURATION) Bytecode Library $(notdir $@)
Reid Spencer4d71b662004-10-22 21:01:56 +0000402 $(VERB) $(BCLinkLib) -o $@ $(ObjectsBC)
403
Reid Spencer3a561f52004-10-23 20:04:14 +0000404clean-local::
Reid Spencere5487ba2004-10-24 07:53:21 +0000405ifneq ($(strip $(LIBNAME_BC)),)
Reid Spencer4d71b662004-10-22 21:01:56 +0000406 $(VERB) $(RM) -f $(LIBNAME_BC)
Reid Spencere5487ba2004-10-24 07:53:21 +0000407endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000408
Reid Spencere5487ba2004-10-24 07:53:21 +0000409DestBytecodeLib = $(bytecode_libdir)/lib$(LIBRARYNAME).bc
Reid Spencere45ebfa2004-10-26 07:09:33 +0000410
Reid Spencere5487ba2004-10-24 07:53:21 +0000411install-local:: install-bytecode-library
Chris Lattner481cc7c2003-08-15 02:18:35 +0000412
Reid Spencere45ebfa2004-10-26 07:09:33 +0000413install-bytecode-library: $(bytecode_libdir) $(DestBytecodeLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000414
415$(DestBytecodeLib): $(LIBNAME_BC) $(bytecode_libdir)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000416 @$(ECHO) Installing $(CONFIGURATION) Bytecode Library $(DestBytecodeLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000417 $(VERB) $(INSTALL) $< $@
418
419uninstall-local:: uninstall-bytecode-library
420
421uninstall-bytecode-library:
Reid Spencere45ebfa2004-10-26 07:09:33 +0000422 @$(ECHO) Uninstalling $(CONFIGURATION) Bytecode Library $(DestBytecodeLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000423 $(VERB) $(RM) -f $(DestBytecodeLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000424
425endif
Vikram S. Adve60f56062002-08-02 18:34:12 +0000426
Chris Lattner760da062003-03-14 20:25:22 +0000427# Does the library want a .o version built?
Chris Lattnere62dbe92002-07-23 17:56:16 +0000428ifndef DONT_BUILD_RELINKED
Reid Spencer3a561f52004-10-23 20:04:14 +0000429all-local:: $(LIBNAME_O)
Reid Spencer4d71b662004-10-22 21:01:56 +0000430
431$(LIBNAME_O): $(BUILT_SOURCES) $(ObjectsO) $(LIBDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000432 @$(ECHO) Linking $(CONFIGURATION) Object Library $(notdir $@)
Reid Spencer4d71b662004-10-22 21:01:56 +0000433 $(VERB) $(Relink) -o $@ $(ObjectsO)
434
Reid Spencer3a561f52004-10-23 20:04:14 +0000435clean-local::
Reid Spencere5487ba2004-10-24 07:53:21 +0000436ifneq ($(strip $(LIBNAME_O)),)
Reid Spencer4d71b662004-10-22 21:01:56 +0000437 $(VERB) $(RM) -f $(LIBNAME_O)
Reid Spencere5487ba2004-10-24 07:53:21 +0000438endif
439
440DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
441
442install-local:: install-relinked-library
443
Reid Spencere45ebfa2004-10-26 07:09:33 +0000444install-relinked-library: $(libdir) $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000445
446$(DestRelinkedLib): $(LIBNAME_O)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000447 @$(ECHO) Installing $(CONFIGURATION) Object Library $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000448 $(VERB) $(MKDIR) $(libdir)
449 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_O) $(DestRelinkedLib)
450
451uninstall-local:: uninstall-relinked-library
452
453uninstall-relinked-library:
Reid Spencere45ebfa2004-10-26 07:09:33 +0000454 @$(ECHO) Uninstalling $(CONFIGURATION) Object Library $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000455 $(VERB) $(RM) -f $(DestRelinkedLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000456
Chris Lattnere62dbe92002-07-23 17:56:16 +0000457endif
Chris Lattner760da062003-03-14 20:25:22 +0000458
459# Does the library want an archive version built?
Chris Lattnere62dbe92002-07-23 17:56:16 +0000460ifdef BUILD_ARCHIVE
Reid Spencer3a561f52004-10-23 20:04:14 +0000461all-local:: $(LIBNAME_A)
Chris Lattnere62dbe92002-07-23 17:56:16 +0000462
Reid Spencer4d71b662004-10-22 21:01:56 +0000463$(LIBNAME_A): $(BUILT_SOURCES) $(ObjectsO) $(LIBDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000464 @$(ECHO) Building $(CONFIGURATION) Archive Library $(notdir $@)
Reid Spencer37130d22004-10-04 07:05:07 +0000465 $(VERB)$(RM) -f $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000466 $(VERB) $(Archive) $@ $(ObjectsO)
467 $(VERB) $(Ranlib) $@
Vikram S. Adve41e78912002-09-20 14:03:13 +0000468
Reid Spencer3a561f52004-10-23 20:04:14 +0000469clean-local::
Reid Spencere5487ba2004-10-24 07:53:21 +0000470ifneq ($(strip $(LIBNAME_A)),)
Reid Spencer4d71b662004-10-22 21:01:56 +0000471 $(VERB) $(RM) -f $(LIBNAME_A)
Chris Lattner00950542001-06-06 20:29:01 +0000472endif
473
Reid Spencere5487ba2004-10-24 07:53:21 +0000474DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
475
476install-local:: install-archive-library
477
Reid Spencere45ebfa2004-10-26 07:09:33 +0000478install-archive-library: $(libdir) $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000479
480$(DestArchiveLib): $(LIBNAME_A)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000481 @$(ECHO) Installing $(CONFIGURATION) Archive Library $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000482 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_A) $(DestArchiveLib)
483
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000484uninstall-local:: uninstall-archive-library
Reid Spencere5487ba2004-10-24 07:53:21 +0000485
486uninstall-archive-library:
Reid Spencere45ebfa2004-10-26 07:09:33 +0000487 @$(ECHO) Uninstalling $(CONFIGURATION) Archive Library $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000488 $(VERB) $(RM) -f $(DestArchiveLib)
489
490endif
491
492# endif LIBRARYNAME
Reid Spencer4d71b662004-10-22 21:01:56 +0000493endif
494
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000495###############################################################################
496# Tool Build Rules: Build executable tool based on TOOLNAME option
497###############################################################################
498
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000499ifdef TOOLNAME
500
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000501#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000502# TOOLLINKOPTSB to pass options to the linker like library search path etc
503# Note that this is different from TOOLLINKOPTS, these options
504# are passed to the linker *before* the USEDLIBS options are passed.
505# e.g. usage TOOLLINKOPTSB = -L/home/xxx/lib
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000506#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000507ifdef TOOLLINKOPTSB
508Link += $(TOOLLINKOPTSB)
Reid Spencer37130d22004-10-04 07:05:07 +0000509endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000510
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000511# TOOLEXENAME - This is the output filenames to generate
Reid Spencer4d71b662004-10-22 21:01:56 +0000512TOOLEXENAME := $(TOOLDIR)/$(TOOLNAME)
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000513
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000514# LIBS_OPTIONS - Compute the options lines that add -llib1 -llib2, etc.
Reid Spencer4d71b662004-10-22 21:01:56 +0000515PROJ_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
516PROJ_LIBS_OPTIONS := $(patsubst %.o, $(LIBDIR)/%.o, $(PROJ_LIBS_OPTIONS))
517LLVM_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
518LLVM_LIBS_OPTIONS := $(patsubst %.o, $(LLVMLIBDIR)/%.o, $(LLVM_LIBS_OPTIONS))
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000519
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000520# USED_LIBS/LIBS_PATHS - Compute dependent library file paths
Reid Spencer4d71b662004-10-22 21:01:56 +0000521PROJ_USED_LIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
522LLVM_USED_LIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
523PROJ_LIBS_PATHS := $(addprefix $(LIBDIR)/,$(PROJ_USED_LIBS))
524LLVM_LIBS_PATHS := $(addprefix $(LLVMLIBDIR)/,$(LLVM_USED_LIBS))
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000525
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000526# Concatenate all the optoins
Reid Spencer4d71b662004-10-22 21:01:56 +0000527LINK_OPTS := $(TOOLLINKOPTS) $(PROJ_LIBS_OPTIONS) $(LLVM_LIBS_OPTIONS)
John Criswellfe785bd2004-09-16 14:11:25 +0000528
Reid Spencer4d71b662004-10-22 21:01:56 +0000529# Handle compression libraries automatically
530ifeq ($(HAVE_BZIP2),1)
531LIBS += -lbz2
532endif
533ifeq ($(HAVE_ZLIB),1)
534LIBS += -lz
535endif
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000536
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000537# Tell make that we need to rebuild subdirectories before we can link the tool.
538# This affects things like LLI which has library subdirectories.
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000539$(TOOLEXENAME): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000540
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000541all-local:: $(TOOLEXENAME)
John Criswell2a6530f2003-06-27 16:58:44 +0000542
Reid Spencer3a561f52004-10-23 20:04:14 +0000543clean-local::
Reid Spencere5487ba2004-10-24 07:53:21 +0000544ifneq ($(strip $(TOOLEXENAME)),)
Reid Spencer4d71b662004-10-22 21:01:56 +0000545 $(VERB) $(RM) -f $(TOOLEXENAME)
Reid Spencere5487ba2004-10-24 07:53:21 +0000546endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000547
Reid Spencer4d71b662004-10-22 21:01:56 +0000548$(TOOLEXENAME): $(BUILT_SOURCES) $(ObjectsO) $(PROJ_LIBS_PATHS) $(LLVM_LIBS_PATHS) $(TOOLDIR)/.dir
549 @$(ECHO) Linking $(CONFIGURATION) executable $(TOOLNAME) $(STRIP_WARN_MSG)
550 $(VERB) $(Link) -o $@ $(ObjectsO) $(PROJ_LIBS_OPTIONS) $(LLVM_LIBS_OPTIONS) $(LIBS)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000551 @$(ECHO) ======= Finished Linking $(CONFIGURATION) Executable $(TOOLNAME) $(STRIP_WARN_MSG)
Reid Spencere5487ba2004-10-24 07:53:21 +0000552
553DestTool = $(bindir)/$(TOOLNAME)
554
Reid Spencere45ebfa2004-10-26 07:09:33 +0000555install-local:: install-tool
556
557install-tool: $(bindir) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000558
559$(DestTool): $(TOOLEXENAME)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000560 @$(ECHO) Installing $(CONFIGURATION) $(DestTool)
561 $(VERB) $(INSTALL) $(TOOLEXENAME) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000562
Reid Spencere45ebfa2004-10-26 07:09:33 +0000563$(bindir):
564 $(VERB) $(MKDIR) $(bindir)
565
Reid Spencere5487ba2004-10-24 07:53:21 +0000566uninstall-local:: uninstall-tool
567
568uninstall-tool:
Reid Spencere45ebfa2004-10-26 07:09:33 +0000569 @$(ECHO) Uninstalling $(CONFIGURATION) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000570 $(VERB) $(RM) -f $(DestTool)
571
Reid Spencer4d71b662004-10-22 21:01:56 +0000572endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000573
Reid Spencer4d71b662004-10-22 21:01:56 +0000574ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve41e78912002-09-20 14:03:13 +0000575
Reid Spencer4d71b662004-10-22 21:01:56 +0000576# Create .lo files in the OBJDIR directory from the .cpp and .c files...
Reid Spencer3a561f52004-10-23 20:04:14 +0000577ifdef SHARED_LIBRARY
578
579$(OBJDIR)/%.lo $(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000580 @$(ECHO) "Compiling $*.cpp (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000581 $(VERB) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(OBJDIR)/$*.LACXXd $< -o $@ ; \
582 then $(MV) -f "$(OBJDIR)/$*.LACXXd" "$(OBJDIR)/$*.d"; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000583 else $(RM) -f "$(OBJDIR)/$*.LACXXd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000584
585$(OBJDIR)/%.lo $(OBJDIR)/%.o: %.c $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000586 @$(ECHO) "Compiling $*.c (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000587 $(VERB) if $(LTCompile.C) -MD -MT $@ -MP -MF $(OBJDIR)/$*.LACd $< -o $@ ; \
588 then $(MV) -f "$(OBJDIR)/$*.LACd" "$(OBJDIR)/$*.d"; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000589 else $(RM) -f "$(OBJDIR)/$*.LACd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000590
591else
Reid Spencer4d71b662004-10-22 21:01:56 +0000592
593$(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000594 @$(ECHO) "Compiling $*.cpp"
Reid Spencer3a561f52004-10-23 20:04:14 +0000595 $(VERB) if $(Compile.CXX) -MD -MT $@ -MP -MF $(OBJDIR)/$*.CXXd $< -o $@ ; \
596 then $(MV) -f "$(OBJDIR)/$*.CXXd" "$(OBJDIR)/$*.d"; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000597 else $(RM) -f "$(OBJDIR)/$*.CXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000598
599$(OBJDIR)/%.o: %.c $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000600 @$(ECHO) "Compiling $*.c"
Reid Spencer3a561f52004-10-23 20:04:14 +0000601 $(VERB) if $(Compile.C) -MD -MT $@ -MP -MF $(OBJDIR)/$*.Cd $< -o $@ ; \
602 then $(MV) -f "$(OBJDIR)/$*.Cd" "$(OBJDIR)/$*.d"; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000603 else $(RM) -f "$(OBJDIR)/$*.Cd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000604
605endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000606
607# Create .bc files in the OBJDIR directory from .cpp and .c files...
608$(OBJDIR)/%.bc: %.cpp $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000609 @$(ECHO) "Compiling $*.cpp (bytecode)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000610 $(VERB) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(OBJDIR)/$*.BCCXXd" $< -o $@ ; \
611 then $(MV) -f "$(OBJDIR)/$*.BCCXXd" "$(OBJDIR)/$*.d"; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000612 else $(RM) -f "$(OBJDIR)/$*.BCCXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000613
614$(OBJDIR)/%.bc: %.c $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000615 @$(ECHO) "Compiling $*.c (bytecode)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000616 $(VERB) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(OBJDIR)/$*.BCCd" $< -o $@ ; \
617 then $(MV) -f "$(OBJDIR)/$*.BCCd" "$(OBJDIR)/$*.d"; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000618 else $(RM) -f "$(OBJDIR)/$*.BCCd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000619
620else
621
Reid Spencer3a561f52004-10-23 20:04:14 +0000622ifdef SHARED_LIBRARY
623
624$(OBJDIR)/%.lo $(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000625 @$(ECHO) "Compiling $*.cpp (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000626 $(LTCompile.CXX) $< -o $@
627
628$(OBJDIR)/%.lo $(OBJDIR)/%.o: %.c $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000629 @$(ECHO) "Compiling $*.cpp (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000630 $(LTCompile.C) $< -o $@
631
632else
Reid Spencer4d71b662004-10-22 21:01:56 +0000633
634$(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000635 @$(ECHO) "Compiling $*.cpp"
Reid Spencer3a561f52004-10-23 20:04:14 +0000636 $(Compile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000637
638$(OBJDIR)/%.o: %.c $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000639 @$(ECHO) "Compiling $*.cpp"
Reid Spencer3a561f52004-10-23 20:04:14 +0000640 $(Compile.C) $< -o $@
641endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000642
643# Create .bc files in the OBJDIR directory from .cpp and .c files...
644$(OBJDIR)/%.bc: %.cpp $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000645 @$(ECHO) "Compiling $*.cpp (bytecode)"
Reid Spencer4d71b662004-10-22 21:01:56 +0000646 $(BCCompileCPP) $< -o $@
647
648$(OBJDIR)/%.bc: %.c $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000649 @$(ECHO) "Compiling $*.c (bytecode)"
Reid Spencer4d71b662004-10-22 21:01:56 +0000650 $(BCCompileC) $< -o $@
Brian Gaeke44909cf2003-12-10 00:26:28 +0000651
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000652endif
653
Reid Spencer4d71b662004-10-22 21:01:56 +0000654$(OBJDIR)/%.bc: %.ll $(OBJDIR)/.dir $(LLVMAS)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000655 @$(ECHO) "Compiling $*.ll"
Chris Lattner481cc7c2003-08-15 02:18:35 +0000656 $(VERB) $(LLVMAS) $< -f -o $@
657
Reid Spencer4d71b662004-10-22 21:01:56 +0000658ifdef TARGET
659
Reid Spencerc64b2b32004-10-23 08:19:37 +0000660TDFILES := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
Reid Spencer4d71b662004-10-22 21:01:56 +0000661
662$(BUILT_SOURCES): $(TDFILES)
663
664%GenRegisterNames.inc : %.td
665 @echo "Building $(<F) register names with tblgen"
666 $(VERB) $(TableGen) -gen-register-enums -o $@ $<
667
668%GenRegisterInfo.h.inc : %.td
669 @echo "Building $(<F) register information header with tblgen"
670 $(VERB) $(TableGen) -gen-register-desc-header -o $@ $<
671
672%GenRegisterInfo.inc : %.td
673 @echo "Building $(<F) register info implementation with tblgen"
674 $(VERB) $(TableGen) -gen-register-desc -o $@ $<
675
676%GenInstrNames.inc : %.td
677 @echo "Building $(<F) instruction names with tblgen"
678 $(VERB) $(TableGen) -gen-instr-enums -o $@ $<
679
680%GenInstrInfo.inc : %.td
681 @echo "Building $(<F) instruction information with tblgen"
682 $(VERB) $(TableGen) -gen-instr-desc -o $@ $<
683
684%GenAsmWriter.inc : %.td
685 @echo "Building $(<F) assembly writer with tblgen"
686 $(VERB) $(TableGen) -gen-asm-writer -o $@ $<
687
688%GenATTAsmWriter.inc : %.td
689 @echo "Building $(<F) AT&T assembly writer with tblgen"
690 $(VERB) $(TableGen) -gen-asm-writer -o $@ $<
691
692%GenIntelAsmWriter.inc : %.td
693 @echo "Building $(<F) Intel assembly writer with tblgen"
694 $(VERB) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
695
696%GenInstrSelector.inc: %.td
697 @echo "Building $(<F) instruction selector with tblgen"
698 $(VERB) $(TableGen) -gen-instr-selector -o $@ $<
699
700%GenCodeEmitter.inc:: %.td
701 @echo "Building $(<F) code emitter with tblgen"
702 $(VERB) $(TableGen) -gen-emitter -o $@ $<
703
Reid Spencer3a561f52004-10-23 20:04:14 +0000704clean-local::
Reid Spencer4d71b662004-10-22 21:01:56 +0000705 $(VERB) rm -f *.inc
706
707endif
Chris Lattner481cc7c2003-08-15 02:18:35 +0000708
Chris Lattnere8996782003-01-16 22:44:19 +0000709#
710# Rules for building lex/yacc files
711#
Reid Spencer3a561f52004-10-23 20:04:14 +0000712LEX_FILES = $(filter %.l, $(SOURCES))
Chris Lattnere8996782003-01-16 22:44:19 +0000713LEX_OUTPUT = $(LEX_FILES:%.l=%.cpp)
Reid Spencer3a561f52004-10-23 20:04:14 +0000714YACC_FILES = $(filter %.y, $(SOURCES))
Chris Lattnere8996782003-01-16 22:44:19 +0000715YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output)
716.PRECIOUS: $(LEX_OUTPUT) $(YACC_OUTPUT)
717
Chris Lattner00950542001-06-06 20:29:01 +0000718# Create a .cpp source file from a flex input file... this uses sed to cut down
719# on the warnings emited by GCC...
Chris Lattner6d131b42003-01-23 16:33:10 +0000720#
721# The last line is a gross hack to work around flex aparently not being able to
722# resize the buffer on a large token input. Currently, for uninitialized string
723# buffers in LLVM we can generate very long tokens, so this is a hack around it.
Chris Lattnerb7dc2b92003-08-15 20:00:47 +0000724# FIXME. (f.e. char Buffer[10000] )
Chris Lattner6d131b42003-01-23 16:33:10 +0000725#
Chris Lattner00950542001-06-06 20:29:01 +0000726%.cpp: %.l
Reid Spencer4d71b662004-10-22 21:01:56 +0000727 @$(ECHO) Flexing $<
Chris Lattner7bb107d2003-08-04 19:48:10 +0000728 $(VERB) $(FLEX) -t $< | \
Reid Spencer4d71b662004-10-22 21:01:56 +0000729 $(SED) '/^find_rule/d' | \
730 $(SED) 's/void yyunput/inline void yyunput/' | \
731 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
732 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
733 > $@.tmp
734 $(VERB) cmp -s $@ $@.tmp > /dev/null || $(MV) -f $@.tmp $@
Chris Lattnera328f882003-08-04 19:47:06 +0000735 @# remove the output of flex if it didn't get moved over...
736 @rm -f $@.tmp
Chris Lattner00950542001-06-06 20:29:01 +0000737
738# Rule for building the bison parsers...
Chris Lattner694c5df2003-05-15 21:28:55 +0000739%.c: %.y # Cancel built-in rules for yacc
740%.h: %.y # Cancel built-in rules for yacc
Chris Lattner00950542001-06-06 20:29:01 +0000741%.cpp %.h : %.y
Reid Spencer4d71b662004-10-22 21:01:56 +0000742 @$(ECHO) "Bisoning $*.y"
John Criswell410d1b52003-09-09 20:57:03 +0000743 $(VERB) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000744 $(VERB) cmp -s $*.tab.c $*.cpp > /dev/null || $(MV) -f $*.tab.c $*.cpp
745 $(VERB) cmp -s $*.tab.h $*.h > /dev/null || $(MV) -f $*.tab.h $*.h
Chris Lattnera328f882003-08-04 19:47:06 +0000746 @# If the files were not updated, don't leave them lying around...
747 @rm -f $*.tab.c $*.tab.h
Chris Lattner00950542001-06-06 20:29:01 +0000748
749# To create the directories...
750%/.dir:
Reid Spencer4d71b662004-10-22 21:01:56 +0000751 $(VERB) $(MKDIR) $* > /dev/null
John Criswell7a73b802003-06-30 21:59:07 +0000752 @$(DATE) > $@
Chris Lattner00950542001-06-06 20:29:01 +0000753
Reid Spencer4d71b662004-10-22 21:01:56 +0000754.PRECIOUS: $(OBJDIR)/.dir $(LIBDIR)/.dir $(TOOLDIR)/.dir $(LLVMLIBDIR)/.dir
755.PRECIOUS: $(LLVMTOOLDIR)/.dir
756
Chris Lattner30440c62003-01-16 21:06:18 +0000757# To create postscript files from dot files...
John Criswelle0f9ac62003-10-02 19:02:02 +0000758ifneq ($(DOT),false)
Chris Lattner30440c62003-01-16 21:06:18 +0000759%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +0000760 $(DOT) -Tps < $< > $@
John Criswell7a73b802003-06-30 21:59:07 +0000761else
762%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +0000763 $(ECHO) "Cannot build $@: The program dot is not installed"
John Criswell7a73b802003-06-30 21:59:07 +0000764endif
Chris Lattner30440c62003-01-16 21:06:18 +0000765
John Criswell7f336952003-09-06 14:44:17 +0000766#
767# This rules ensures that header files that are removed still have a rule for
768# which they can be "generated." This allows make to ignore them and
769# reproduce the dependency lists.
770#
John Criswell4b6e5d12003-09-18 18:37:08 +0000771%.h:: ;
John Criswell7f336952003-09-06 14:44:17 +0000772
Chris Lattner172b6482002-09-22 02:47:15 +0000773# 'make clean' nukes the tree
Reid Spencer3a561f52004-10-23 20:04:14 +0000774clean-local::
Reid Spencere5487ba2004-10-24 07:53:21 +0000775ifneq ($(strip $(OBJDIR)),)
Reid Spencer83cbcb92004-10-24 02:26:09 +0000776 $(VERB) $(RM) -rf $(OBJDIR)
Reid Spencere5487ba2004-10-24 07:53:21 +0000777endif
Brian Gaeke9d3cd402004-01-21 19:53:11 +0000778 $(VERB) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
779ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
780 $(VERB) $(RM) -f *$(SHLIBEXT)
781endif
Reid Spencere5487ba2004-10-24 07:53:21 +0000782ifneq ($(strip $(LEX_OUTPUT)),)
783 $(VERB) $(RM) -f $(LEX_OUTPUT)
784endif
785ifneq ($(strip $(YACC_OUTPUT)),)
786 $(VERB) $(RM) -f $(YACC_OUTPUT)
787endif
John Criswell7a73b802003-06-30 21:59:07 +0000788
Reid Spencer3a561f52004-10-23 20:04:14 +0000789###############################################################################
790# DEPENDENCIES: Include the dependency files if we should
791###############################################################################
Chris Lattner33ad24a2003-08-22 14:10:16 +0000792ifndef DISABLE_AUTO_DEPENDENCIES
793
Reid Spencer3a561f52004-10-23 20:04:14 +0000794# If its not one of the cleaning targets
795ifneq ($strip($(filter-out clean clean-local dist-clean, $(MAKECMDGOALS))),)
Reid Spencer4d71b662004-10-22 21:01:56 +0000796
Reid Spencer3a561f52004-10-23 20:04:14 +0000797# Get the list of dependency files
798DependFiles := $(basename $(filter %.cpp %.c %.cc, $(SOURCES)))
799DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(CONFIGURATION)/%.d,$(DependFiles))
Misha Brukman4f7a8cf2003-11-09 21:36:19 +0000800
Reid Spencer3a561f52004-10-23 20:04:14 +0000801-include /dev/null $(DependFiles)
802
John Criswelld741bcf2003-08-12 18:51:51 +0000803endif
Chris Lattner1ddb6b62003-08-18 17:27:40 +0000804
Chris Lattner33ad24a2003-08-22 14:10:16 +0000805endif # ifndef DISABLE_AUTO_DEPENDENCIES
Reid Spencer4d71b662004-10-22 21:01:56 +0000806
Reid Spencer3a561f52004-10-23 20:04:14 +0000807################################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +0000808# PRECONDITIONS - that which must be built/checked first
Reid Spencer3a561f52004-10-23 20:04:14 +0000809################################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +0000810
811OBJMKFILE := $(BUILD_OBJ_DIR)/Makefile
812SRCMKFILE := $(BUILD_SRC_DIR)/Makefile
813CONFIGURE := $(LLVM_SRC_ROOT)/configure
814CONFIG_STATUS := $(LLVM_OBJ_ROOT)/config.status
815MAKE_CONFIG_IN := $(LLVM_SRC_ROOT)/Makefile.config.in
816MAKE_CONFIG := $(LLVM_OBJ_ROOT)/Makefile.config
817
818#------------------------------------------------------------------------
819# List of the preconditions
Reid Spencer3a561f52004-10-23 20:04:14 +0000820#------------------------------------------------------------------------
Reid Spencer151f8ba2004-10-25 08:27:37 +0000821
Reid Spencer4d71b662004-10-22 21:01:56 +0000822preconditions: $(CONFIG_STATUS) $(MAKE_CONFIG) $(OBJMKFILE)
823
Reid Spencer151f8ba2004-10-25 08:27:37 +0000824$(filter-out clean clean-local,USER_TARGETS):: $(BUILT_SOURCES)
Reid Spencer4d71b662004-10-22 21:01:56 +0000825
Reid Spencer3a561f52004-10-23 20:04:14 +0000826clean-local::
Reid Spencere5487ba2004-10-24 07:53:21 +0000827ifneq ($(strip $(BUILT_SOURCES)),)
Reid Spencer4d71b662004-10-22 21:01:56 +0000828 $(VERB) $(RM) -f $(BUILT_SOURCES)
Reid Spencere5487ba2004-10-24 07:53:21 +0000829endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000830
831#------------------------------------------------------------------------
832# Make sure we're not using a stale configuration
Reid Spencer3a561f52004-10-23 20:04:14 +0000833#------------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000834.PRECIOUS: $(CONFIG_STATUS)
835$(CONFIG_STATUS): $(CONFIGURE)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000836 @$(ECHO) Reconfiguring with $<
837 $(VERB) $(CONFIG_STATUS) --recheck $(CONFIGUREFLAGS)
Reid Spencer4d71b662004-10-22 21:01:56 +0000838
839#------------------------------------------------------------------------
840# Make sure the configuration makefile is up to date
Reid Spencer3a561f52004-10-23 20:04:14 +0000841#------------------------------------------------------------------------
Reid Spencer151f8ba2004-10-25 08:27:37 +0000842$(MAKE_CONFIG): $(MAKE_CONFIG_IN) $(CONFIG_STATUS)
Reid Spencer4d71b662004-10-22 21:01:56 +0000843 @$(ECHO) Regenerating $@
844 $(VERB) cd $(LLVM_OBJ_ROOT) ; $(CONFIG_STATUS) Makefile.config
Reid Spencere5487ba2004-10-24 07:53:21 +0000845
Reid Spencer4d71b662004-10-22 21:01:56 +0000846#------------------------------------------------------------------------
847# If the Makefile in the source tree has been updated, copy it over into the
Reid Spencer3a561f52004-10-23 20:04:14 +0000848# build tree. But, only do this if the source and object makefiles differ
849#------------------------------------------------------------------------
Reid Spencere53e3972004-10-22 23:06:30 +0000850ifneq ($(OBJMKFILE),$(SRCMKFILE))
Reid Spencer4d71b662004-10-22 21:01:56 +0000851.PRECIOUS: $(OBJMKFILE)
852$(OBJMKFILE): $(SRCMKFILE)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000853 @$(ECHO) "Updating Makefile from: $(dir $<)"
Reid Spencer4d71b662004-10-22 21:01:56 +0000854 $(VERB) $(MKDIR) $(@D)
855 $(VERB) cp -f $< $@
Reid Spencer151f8ba2004-10-25 08:27:37 +0000856endif
857
858###############################################################################
859# Handle construction of a distribution tarball
860###############################################################################
861
862.PHONY: dist dist-chck dist-clean distdir dist-gzip dist-bzip2 dist-zip
863
Reid Spencere45ebfa2004-10-26 07:09:33 +0000864#------------------------------------------------------------------------
865# Define distribution related variables
866#------------------------------------------------------------------------
Reid Spencer151f8ba2004-10-25 08:27:37 +0000867DistName := $(LLVM_TARBALL_NAME)
868DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000869TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000870DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
871DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
872DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
873DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
874 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencere45ebfa2004-10-26 07:09:33 +0000875 Makefile.config.in configure autoconf
876DistOther := $(notdir $(wildcard \
877 $(BUILD_SRC_DIR)/*.h \
878 $(BUILD_SRC_DIR)/*.td \
879 $(BUILD_SRC_DIR)/*.def \
880 $(BUILD_SRC_DIR)/*.ll \
881 $(BUILD_SRC_DIR)/*.in))
882DistSources := $(SOURCES) $(EXTRA_DIST)
883DistSubDirs := $(SUBDIRS)
884DistFiles := $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000885
Reid Spencere45ebfa2004-10-26 07:09:33 +0000886
887#------------------------------------------------------------------------
888# We MUST build distribution with OBJ_DIR != SRC_DIR
889#------------------------------------------------------------------------
890ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
891dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
892 @$(ECHO) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
893
894DistCheckTop :=
895else
896
897DistCheckTop := check
898#------------------------------------------------------------------------
899# Prevent catastrophic remove
900#------------------------------------------------------------------------
901ifeq ($(LLVM_TARBALL_NAME),)
902$(error LLVM_TARBALL_NAME is empty. Please rerun configure)
903endif
904
905#------------------------------------------------------------------------
906# Prevent attempt to run dist targets from anywhere but the top level
907#------------------------------------------------------------------------
908ifneq ($(LEVEL),.)
909
910dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
911 @$(ECHO) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
912
913else
914
915#------------------------------------------------------------------------
916# Provide the top level targets
917#------------------------------------------------------------------------
918
919dist-gzip: $(DistTarGZip)
920
921$(DistTarGZip) : distdir
922 @$(ECHO) Packing gzipped distribution tar file.
923 $(VERB) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | gzip -c > "$(DistTarGZip)"
924
925dist-bzip2: $(DistTarBZ2)
926
927$(DistTarBZ2) : distdir
928 @$(ECHO) Packing bzipped distribution tar file.
929 $(VERB) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | $(BZIP2) -c >$(DistTarBZ2)
930
931dist-zip: $(DistZip)
932
933$(DistZip) : distdir
934 @$(ECHO) Packing zipped distribution file.
935 $(VERB) rm -f $(DistZip)
936 $(VERB) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
937
938dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
939 @$(ECHO) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
940
941DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
942
943dist-check:: $(DistTopDir) $(DistTarGZip)
944 @$(ECHO) Checking distribution tar file.
945 $(VERB) if test -d $(DistCheckDir) ; then \
946 $(RM) -rf $(DistCheckDir) ; \
947 fi
948 $(VERB) $(MKDIR) $(DistCheckDir)
949 $(VERB) cd $(DistCheckDir) && \
950 $(MKDIR) $(DistCheckDir)/build && \
951 $(MKDIR) $(DistCheckDir)/install && \
952 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
953 cd build && \
954 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
955 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
956 $(MAKE) check && \
957 $(MAKE) install && \
958 $(MAKE) uninstall && \
959 $(MAKE) dist && \
960 $(MAKE) clean && \
961 $(MAKE) dist-clean && \
962 $(ECHO) ===== $(DistTarGZip) Ready For Distribution =====
963
964dist-clean::
965 @$(ECHO) Cleaning distribution files
966 $(VERB) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) $(DistCheckDir)
967
968endif
969
970#------------------------------------------------------------------------
971# Provide the recursive distdir target for building the distribution directory
972#------------------------------------------------------------------------
973distdir : $(DistCheckTop) $(DistSources)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000974 @$(ECHO) Building Distribution Directory $(DistDir)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000975 $(VERB) if test "$(DistDir)" = "$(TopDistDir)" ; then \
976 if test -d "$(DistDir)" ; then \
977 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
978 exit 1 ; \
979 fi ; \
980 echo Removing $(DistDir) ; \
981 $(RM) -rf $(DistDir); \
982 fi
Reid Spencer151f8ba2004-10-25 08:27:37 +0000983 $(VERB) $(MKDIR) $(DistDir)
984 $(VERB) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
985 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
986 for file in $(DistFiles) ; do \
987 case "$$file" in \
988 $(BUILD_SRC_DIR)/*) file=`echo "$$file" | sed "s#^$$srcdirstrip/##"`;; \
Reid Spencere45ebfa2004-10-26 07:09:33 +0000989 $(BUILD_SRC_ROOT)/*) file=`echo "$$file" | sed "s#^$$srcrootstrip/#$(BUILD_OBJ_ROOT)/#"`;; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000990 esac; \
991 if test -f "$$file" || test -d "$$file" ; then \
992 from_dir=. ; \
993 else \
994 from_dir=$(BUILD_SRC_DIR); \
995 fi; \
996 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'`; \
997 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
998 to_dir="$(DistDir)/$$dir"; \
999 $(MKDIR) "$$to_dir" ; \
1000 else \
1001 to_dir="$(DistDir)"; \
1002 fi; \
1003 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1004 if test -n "$$mid_dir" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001005 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001006 fi ; \
1007 if test -d "$$from_dir/$$file"; then \
1008 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1009 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1010 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1011 fi; \
1012 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1013 elif test -f "$$from_dir/$$file" ; then \
1014 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1015 elif test -L "$$from_dir/$$file" ; then \
1016 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1017 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1018 $(ECHO) "===== WARNING: Distribution Source $$from_dir/$$file Not Found!" ; \
1019 elif test "$(VERB)" != '@' ; then \
1020 $(ECHO) "Skipping non-existent $$from_dir/$$file" ; \
1021 fi; \
1022 done
Reid Spencere45ebfa2004-10-26 07:09:33 +00001023 $(VERB) for subdir in $(DistSubDirs) ; do \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001024 if test "$$subdir" \!= "." ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001025 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001026 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1027 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001028 fi; \
1029 done
Reid Spencere45ebfa2004-10-26 07:09:33 +00001030 $(VERB) $(MAKE) DistDir="$(DistDir)" dist-hook || exit 1
Reid Spencer151f8ba2004-10-25 08:27:37 +00001031 -$(VERB) find $(DistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
1032 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
1033 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
1034 ! -type d ! -perm -444 -exec $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1035 || chmod -R a+r $(DistDir)
1036
1037dist-hook::
1038
1039
Reid Spencere53e3972004-10-22 23:06:30 +00001040endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001041
1042###############################################################################
Reid Spencere5487ba2004-10-24 07:53:21 +00001043# TOP LEVEL - targets only to apply at the top level directory
1044###############################################################################
1045
1046ifeq ($(LEVEL),.)
1047
1048#------------------------------------------------------------------------
Reid Spencere5487ba2004-10-24 07:53:21 +00001049# Install support for project's include files:
1050#------------------------------------------------------------------------
1051install-local::
1052 @$(ECHO) Installing include files
1053 $(VERB) $(MKDIR) $(includedir)
1054 $(VERB) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1055 cd $(BUILD_SRC_ROOT)/include && \
1056 find . -path '*/Internal' -prune -o '(' -type f \
1057 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1058 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1059 fi
1060
1061uninstall-local::
1062 @$(ECHO) Uninstalling include files
1063 $(VERB) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1064 cd $(BUILD_SRC_ROOT)/include && \
1065 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1066 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1067 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1068 fi
1069
1070#------------------------------------------------------------------------
1071# Build tags database for Emacs/Xemacs:
1072#------------------------------------------------------------------------
Reid Spencer151f8ba2004-10-25 08:27:37 +00001073tags:: TAGS
Reid Spencere5487ba2004-10-24 07:53:21 +00001074
Reid Spencer151f8ba2004-10-25 08:27:37 +00001075TAGS:
Reid Spencere5487ba2004-10-24 07:53:21 +00001076 find include lib tools examples -name '*.cpp' -o -name '*.h' | $(ETAGS) $(ETAGSFLAGS) -
1077
Reid Spencere5487ba2004-10-24 07:53:21 +00001078endif
1079
1080###############################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +00001081# MISCELLANEOUS - utility targets
1082###############################################################################
1083
1084#------------------------------------------------------------------------
1085# Print out the directories used for building
Reid Spencer3a561f52004-10-23 20:04:14 +00001086printvars::
Reid Spencer4d71b662004-10-22 21:01:56 +00001087 @$(ECHO) "BUILD_SRC_ROOT: " $(BUILD_SRC_ROOT)
1088 @$(ECHO) "BUILD_SRC_DIR : " $(BUILD_SRC_DIR)
1089 @$(ECHO) "BUILD_OBJ_ROOT: " $(BUILD_OBJ_ROOT)
1090 @$(ECHO) "BUILD_OBJ_DIR : " $(BUILD_OBJ_DIR)
1091 @$(ECHO) "LLVM_SRC_ROOT : " $(LLVM_SRC_ROOT)
1092 @$(ECHO) "LLVM_OBJ_ROOT : " $(LLVM_OBJ_ROOT)
1093 @$(ECHO) "CONFIGURATION : " $(CONFIGURATION)
1094 @$(ECHO) "OBJDIR: " $(OBJDIR)
1095 @$(ECHO) "LIBDIR: " $(LIBDIR)
1096 @$(ECHO) "TOOLDIR: " $(TOOLDIR)
1097 @$(ECHO) "TDFILES:" '$(TDFILES)'
Reid Spencer3a561f52004-10-23 20:04:14 +00001098 @$(ECHO) "Compile.CXX: " '$(Compile.CXX)'
1099 @$(ECHO) "Compile.C: " '$(Compile.C)'
Reid Spencere5487ba2004-10-24 07:53:21 +00001100
1101# This frivolous target provided for Resistor who requested that the makefiles
1102# be hardened and that he get a "pony" after the makefiles (accidentally)
1103# deleted his unix kernel.
1104pony::
1105 @wget -q \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001106 http://search.cpan.org/src/ASAVIGE/Acme-EyeDrops-1.40/lib/Acme/EyeDrops/pony2.eye \
1107 -O /tmp/resistor.pony
Reid Spencere5487ba2004-10-24 07:53:21 +00001108 @cat /tmp/resistor.pony