blob: c564703eddd52111f6f228b2691c16cc8963f357 [file] [log] [blame]
Misha Brukman7426c892004-04-24 00:10:56 +00001#===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
2#
John Criswell23e43fb2003-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 Brukman7426c892004-04-24 00:10:56 +00008#===------------------------------------------------------------------------===#
Chris Lattner2f7c9632001-06-06 20:29:01 +00009#
Reid Spencer81cd0492004-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 Lattner2e9fc94a2003-08-15 03:02:52 +000012#
Vikram S. Adve24132e82002-07-09 12:04:21 +000013#===-----------------------------------------------------------------------====
Chris Lattner2f7c9632001-06-06 20:29:01 +000014
John Criswell8224df92003-06-27 16:58:44 +000015#
John Criswell0a6e6aa2003-09-06 14:44:17 +000016# Set the VPATH so that we can find source files.
John Criswell0607d882003-06-11 13:55:44 +000017#
Reid Spencerf206bd72004-10-22 21:01:56 +000018VPATH=$(BUILD_SRC_DIR)
John Criswell0607d882003-06-11 13:55:44 +000019
Reid Spencer81cd0492004-10-23 20:04:14 +000020###############################################################################
21# TARGETS: Define standard targets that can be invoked
22###############################################################################
John Criswell3ef61af2003-06-30 21:59:07 +000023
Chris Lattner2f7c9632001-06-06 20:29:01 +000024#--------------------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +000025# Define the various target sets
26#--------------------------------------------------------------------
27RECURSIVE_TARGETS := all clean check install uninstall
Reid Spencer77a46d22004-10-26 22:26:33 +000028LOCAL_TARGETS := all-local clean-local check-local install-local \
29 printvars uninstall-local
Reid Spencer12a3a052004-10-24 07:53:21 +000030TOPLEV_TARGETS := dist dist-check dist-clean tags
Reid Spencer100080c2004-10-25 08:27:37 +000031USER_TARGETS := $(RECURSIVE_TARGETS) $(LOCAL_TARGETS) $(TOPLEV_TARGETS)
Reid Spencerbe6a4e92004-10-28 07:57:28 +000032INTERNAL_TARGETS := preconditions
Reid Spencer81cd0492004-10-23 20:04:14 +000033
Reid Spencer77a46d22004-10-26 22:26:33 +000034###############################################################################
35# INITIALIZATION: Basic things the makefile needs
36###############################################################################
37
38#--------------------------------------------------------------------
39# Reset the list of suffixes we know how to build
40#--------------------------------------------------------------------
41.SUFFIXES:
42.SUFFIXES: .c .cpp .h .hpp .y .l .lo .o .a $(SHLIBEXT) .bc .td .ps .dot $(SUFFIXES)
43
Reid Spencer81cd0492004-10-23 20:04:14 +000044#--------------------------------------------------------------------
45# Mark all of these targets as phony to avoid implicit rule search
46#--------------------------------------------------------------------
Reid Spencer100080c2004-10-25 08:27:37 +000047.PHONY: $(USER_TARGETS) $(INTERNAL_TARGETS)
Reid Spencer81cd0492004-10-23 20:04:14 +000048
49#--------------------------------------------------------------------
Reid Spencer77a46d22004-10-26 22:26:33 +000050# Make sure all the user-target rules are double colon rules and
51# they are defined first.
Reid Spencer81cd0492004-10-23 20:04:14 +000052#--------------------------------------------------------------------
53
Reid Spencer77a46d22004-10-26 22:26:33 +000054$(USER_TARGETS)::
Reid Spencer100080c2004-10-25 08:27:37 +000055
Reid Spencer77a46d22004-10-26 22:26:33 +000056################################################################################
57# PRECONDITIONS: that which must be built/checked first
58################################################################################
59
Reid Spencerb7f710a2004-10-28 00:41:43 +000060SRCMKFILES := $(BUILD_SRC_DIR)/Makefile $(filter-out Makefile.rules %.in,\
Reid Spencerd94bb332004-10-26 23:10:00 +000061 $(wildcard $(BUILD_SRC_DIR)/Makefile.*))
Reid Spencer77a46d22004-10-26 22:26:33 +000062OBJMKFILES := $(subst $(BUILD_SRC_DIR),$(BUILD_OBJ_DIR),$(SRCMKFILES))
63CONFIGURE := $(LLVM_SRC_ROOT)/configure
64CONFIG_STATUS := $(LLVM_OBJ_ROOT)/config.status
65MAKE_CONFIG_IN:= $(LLVM_SRC_ROOT)/Makefile.config.in
66MAKE_CONFIG := $(LLVM_OBJ_ROOT)/Makefile.config
67PRECONDITIONS := $(CONFIG_STATUS) $(MAKE_CONFIG) $(OBJMKFILES)
68
69preconditions : $(PRECONDITIONS)
70
71#------------------------------------------------------------------------
72# Make sure the BUILT_SOURCES are built first
73#------------------------------------------------------------------------
74$(filter-out clean clean-local,USER_TARGETS):: $(BUILT_SOURCES)
75
76clean-local::
77ifneq ($(strip $(BUILT_SOURCES)),)
78 $(VERB) $(RM) -f $(BUILT_SOURCES)
79endif
80
Reid Spencerb7f710a2004-10-28 00:41:43 +000081$(BUILT_SOURCES) : $(BUILD_OBJ_ROOT)/Makefile
82
Reid Spencer77a46d22004-10-26 22:26:33 +000083#------------------------------------------------------------------------
84# Make sure we're not using a stale configuration
85#------------------------------------------------------------------------
86.PRECIOUS: $(CONFIG_STATUS)
87$(CONFIG_STATUS): $(CONFIGURE)
88 @$(ECHO) Reconfiguring with $<
89 $(VERB) $(CONFIG_STATUS) --recheck $(CONFIGUREFLAGS)
Reid Spencerc8c272f2004-10-27 22:48:58 +000090 $(VERB) $(CONFIG_STATUS)
Reid Spencer77a46d22004-10-26 22:26:33 +000091
92#------------------------------------------------------------------------
93# Make sure the configuration makefile is up to date
94#------------------------------------------------------------------------
95$(MAKE_CONFIG): $(MAKE_CONFIG_IN) $(CONFIG_STATUS)
96 @$(ECHO) Regenerating $@
97 $(VERB) cd $(LLVM_OBJ_ROOT) ; $(CONFIG_STATUS) Makefile.config
98
99#------------------------------------------------------------------------
100# If the Makefile in the source tree has been updated, copy it over into the
101# build tree. But, only do this if the source and object makefiles differ
102#------------------------------------------------------------------------
103ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
104
105$(BUILD_OBJ_DIR)/Makefile : $(BUILD_SRC_DIR)/Makefile
106 @$(ECHO) "Updating Makefile"
107 $(VERB) $(MKDIR) $(@D)
108 $(VERB) cp -f $< $@
Reid Spencer77a46d22004-10-26 22:26:33 +0000109
110# Copy the Makefile.* files unless we're in the root directory which avoids
111# the copying of Makefile.config.in or other things that should be explicitly
112# taken care of.
Reid Spencer77a46d22004-10-26 22:26:33 +0000113$(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
Reid Spencerd94bb332004-10-26 23:10:00 +0000114 @case '$?' in \
115 *Makefile.rules) ;; \
116 *.in) ;; \
117 *) $(ECHO) "Updating $(@F)" ; \
118 $(MKDIR) $(@D) ; \
119 cp -f $< $@ ;; \
120 esac
121
Reid Spencer77a46d22004-10-26 22:26:33 +0000122endif
123
124#------------------------------------------------------------------------
125# Set up the basic dependencies
126#------------------------------------------------------------------------
127$(USER_TARGETS):: $(PRECONDITIONS)
128
129all:: all-local
Reid Spencer81cd0492004-10-23 20:04:14 +0000130check:: check-local
131clean:: clean-local
Reid Spencer77a46d22004-10-26 22:26:33 +0000132install:: install-local
133uninstall:: uninstall-local
134check-local:: all-local
135install-local:: all-local
Reid Spencer81cd0492004-10-23 20:04:14 +0000136
137###############################################################################
138# VARIABLES: Set up various variables based on configuration data
139###############################################################################
140
141#--------------------------------------------------------------------
142# Variables derived from configuration we are building
Chris Lattner2f7c9632001-06-06 20:29:01 +0000143#--------------------------------------------------------------------
144
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000145ifdef ENABLE_PROFILING
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000146 CONFIGURATION := Profile
Reid Spencerf206bd72004-10-22 21:01:56 +0000147 CXXFLAGS += -O3 -DNDEBUG -felide-constructors -finline-functions -pg
148 CFLAGS += -O3 -DNDEBUG -pg
149 LDFLAGS += -O3 -DNDEBUG -pg
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000150else
151 ifdef ENABLE_OPTIMIZED
152 CONFIGURATION := Release
Reid Spencerf206bd72004-10-22 21:01:56 +0000153 CXXFLAGS += -O3 -DNDEBUG -finline-functions -felide-constructors -fomit-frame-pointer
154 CFLAGS += -O3 -DNDEBUG -fomit-frame-pointer
155 LDFLAGS += -O3 -DNDEBUG
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000156 else
157 CONFIGURATION := Debug
Reid Spencerf206bd72004-10-22 21:01:56 +0000158 CXXFLAGS += -g -D_DEBUG
159 CFLAGS += -g -D_DEBUG
160 LDFLAGS += -g -D_DEBUG
161 KEEP_SYMBOLS := 1
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000162 endif
163endif
164
Reid Spencerf206bd72004-10-22 21:01:56 +0000165ARFLAGS := cru
Reid Spencer81cd0492004-10-23 20:04:14 +0000166
167#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000168# Directory locations
Reid Spencer81cd0492004-10-23 20:04:14 +0000169#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000170OBJDIR := $(BUILD_OBJ_DIR)/$(CONFIGURATION)
171LIBDIR := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
172TOOLDIR := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
173LLVMLIBDIR := $(LLVM_OBJ_ROOT)/lib/$(CONFIGURATION)
174LLVMTOOLDIR := $(LLVM_OBJ_ROOT)/tools/$(CONFIGURATION)
John Criswell3ef61af2003-06-30 21:59:07 +0000175
Reid Spencer81cd0492004-10-23 20:04:14 +0000176#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000177# Full Paths To Compiled Tools and Utilities
Reid Spencer81cd0492004-10-23 20:04:14 +0000178#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000179LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
180LLVMAS := $(LLVMTOOLDIR)/llvm-as$(EXEEXT)
181BURG := $(LLVMTOOLDIR)/burg$(EXEEXT)
182TBLGEN := $(LLVMTOOLDIR)/tblgen$(EXEEXT)
183GCCLD := $(LLVMTOOLDIR)/gccld$(EXEEXT)
184LLVMGCC := PATH=$(LLVMTOOLDIR):$(PATH) $(LLVMGCCDIR)/bin/gcc
185LLVMGXX := PATH=$(LLVMTOOLDIR):$(PATH) $(LLVMGCCDIR)/bin/g++
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000186
Reid Spencerf206bd72004-10-22 21:01:56 +0000187# Need a better way to compute this.
188LLVMGCCLIBDIR := $(dir $(shell $(LLVMGCC) -print-file-name=libgcc.a))/
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000189
Reid Spencer81cd0492004-10-23 20:04:14 +0000190#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000191# Adjust to user's request
Reid Spencer81cd0492004-10-23 20:04:14 +0000192#--------------------------------------------------------------------
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000193
Reid Spencer81cd0492004-10-23 20:04:14 +0000194# Adjust LIBTOOL options for shared libraries, or not.
John Criswell3601f372003-07-31 20:58:51 +0000195ifndef SHARED_LIBRARY
Reid Spencerf206bd72004-10-22 21:01:56 +0000196 LIBTOOL += --tag=disable-shared
197else
198 LDFLAGS += -rpath $(LIBDIR)
John Criswell3601f372003-07-31 20:58:51 +0000199endif
200
Reid Spencer81cd0492004-10-23 20:04:14 +0000201# Adjust settings for verbose mode
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000202ifndef VERBOSE
Reid Spencerf206bd72004-10-22 21:01:56 +0000203 VERB := @
204 LIBTOOL += --silent
205 AR += >/dev/null 2>/dev/null
Reid Spencer100080c2004-10-25 08:27:37 +0000206 CONFIGUREFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
207else
208 CONFIGUREFLAGS :=
Misha Brukman1326a7c2002-09-12 16:05:39 +0000209endif
210
Vikram S. Adved141c282002-09-18 11:55:13 +0000211# By default, strip symbol information from executable
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000212ifndef KEEP_SYMBOLS
Reid Spencerf206bd72004-10-22 21:01:56 +0000213 STRIP = $(PLATFORMSTRIPOPTS)
214 STRIP_WARN_MSG = "(without symbols)"
Vikram S. Adved141c282002-09-18 11:55:13 +0000215endif
216
Reid Spencer81cd0492004-10-23 20:04:14 +0000217# Adjust linker flags for building an executable
Reid Spencerf206bd72004-10-22 21:01:56 +0000218ifdef TOOLNAME
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000219 LDFLAGS += -rpath $(TOOLDIR) -export-dynamic
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000220endif
221
Reid Spencer81cd0492004-10-23 20:04:14 +0000222#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000223# Options To Invoke Tools
Reid Spencer81cd0492004-10-23 20:04:14 +0000224#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000225
226CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
227
Reid Spencer81cd0492004-10-23 20:04:14 +0000228LDFLAGS += -L$(LIBDIR) -L$(LLVMLIBDIR)
Reid Spencerf206bd72004-10-22 21:01:56 +0000229CPPFLAGS += -I$(BUILD_OBJ_DIR) \
Reid Spencer100080c2004-10-25 08:27:37 +0000230 -I$(BUILD_SRC_DIR) \
231 -I$(BUILD_SRC_ROOT)/include \
232 -I$(BUILD_OBJ_ROOT)/include \
233 -I$(LLVM_OBJ_ROOT)/include \
234 -I$(LLVM_SRC_ROOT)/include \
235 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
Reid Spencerf206bd72004-10-22 21:01:56 +0000236
Reid Spencer81cd0492004-10-23 20:04:14 +0000237Compile.C = $(CC) $(CPPFLAGS) $(CompileCommonOpts) -c $(CFLAGS)
238Compile.CXX = $(CXX) $(CPPFLAGS) $(CompileCommonOpts) $(CXXFLAGS) -c
239LTCompile.C = $(LIBTOOL) --mode=compile $(Compile.C)
240LTCompile.CXX = $(LIBTOOL) --tag=CXX --mode=compile $(Compile.CXX)
241BCCompile.CXX = $(LLVMGXX) $(CPPFLAGS) $(CompileCommonOpts) $(CXXFLAGS) -c
242BCCompile.C = $(LLVMGCC) $(CPPFLAGS) $(CompileCommonOpts) $(CFLAGS) -c
243Link = $(LIBTOOL) --tag=CXX --mode=link $(CXX) $(CPPFLAGS) \
Reid Spencer100080c2004-10-25 08:27:37 +0000244 $(CompileCommonOpts) $(LDFLAGS) $(STRIP)
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000245Relink = $(LIBTOOL) --tag=CXX --mode=link $(CXX) $(CPPFLAGS) \
246 $(CompileCommonOpts)
Reid Spencer81cd0492004-10-23 20:04:14 +0000247BCLinkLib = $(LLVMGCC) -shared -nostdlib
248Burg = $(BURG) -I $(BUILD_SRC_DIR)
249TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
250Archive = $(AR) $(ARFLAGS)
Reid Spencerf206bd72004-10-22 21:01:56 +0000251ifdef RANLIB
Reid Spencer81cd0492004-10-23 20:04:14 +0000252Ranlib = $(RANLIB)
Reid Spencerf206bd72004-10-22 21:01:56 +0000253else
Reid Spencer81cd0492004-10-23 20:04:14 +0000254Ranlib = ranlib
John Criswell3ef61af2003-06-30 21:59:07 +0000255endif
256
Chris Lattner2f7c9632001-06-06 20:29:01 +0000257#----------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000258# Get the list of source files
259#----------------------------------------------------------
260ifndef SOURCES
261SOURCES := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
Reid Spencer100080c2004-10-25 08:27:37 +0000262 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
263 $(BUILD_SRC_DIR)/*.l))
Reid Spencerf206bd72004-10-22 21:01:56 +0000264endif
265
266ifdef BUILT_SOURCES
Reid Spencer81cd0492004-10-23 20:04:14 +0000267SOURCES += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Vikram S. Adve53738842002-10-14 16:40:04 +0000268endif
Vikram S. Advefe346892001-07-15 13:16:47 +0000269
Reid Spencer81cd0492004-10-23 20:04:14 +0000270#----------------------------------------------------------
271# Types of objects that can be built from sources
272#----------------------------------------------------------
273BASENAME_SOURCES := $(sort $(basename $(SOURCES)))
274ObjectsO := $(BASENAME_SOURCES:%=$(OBJDIR)/%.o)
275ObjectsLO := $(BASENAME_SOURCES:%=$(OBJDIR)/%.lo)
276ObjectsBC := $(BASENAME_SOURCES:%=$(OBJDIR)/%.bc)
277
278
279###############################################################################
280# DIRECTORIES: Handle recursive descent of directory structure
281###############################################################################
John Criswell3601f372003-07-31 20:58:51 +0000282
Chris Lattner2f7c9632001-06-06 20:29:01 +0000283#---------------------------------------------------------
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000284# Provide rules to make install dirs. This must be early
285# in the file so they get built before dependencies
286#---------------------------------------------------------
287
288$(bindir):
289 $(VERB) $(MKDIR) $(bindir)
290
291$(libdir):
292 $(VERB) $(MKDIR) $(libdir)
293
294$(bytecode_libdir):
295 $(VERB) $(MKDIR) $(bytecode_libdir)
296
297$(sysconfdir):
298 $(VERB) $(MKDIR) $(sysconfdir)
299
300
301#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000302# Handle the DIRS options for sequential construction
Chris Lattner2f7c9632001-06-06 20:29:01 +0000303#---------------------------------------------------------
304
Reid Spencer100080c2004-10-25 08:27:37 +0000305SUBDIRS :=
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000306ifdef DIRS
Reid Spencer100080c2004-10-25 08:27:37 +0000307SUBDIRS += $(DIRS)
Reid Spencer81cd0492004-10-23 20:04:14 +0000308$(RECURSIVE_TARGETS)::
Reid Spencerf206bd72004-10-22 21:01:56 +0000309 $(VERB) for dir in $(DIRS); do \
310 if [ ! -f $$dir/Makefile ]; then \
311 $(MKDIR) $$dir; \
312 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
313 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +0000314 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattner539a23c2002-09-17 23:35:02 +0000315 done
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000316endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000317
Reid Spencer81cd0492004-10-23 20:04:14 +0000318#---------------------------------------------------------
319# Handle the EXPERIMENTAL_DIRS options ensuring success
320# after each directory is built.
321#---------------------------------------------------------
322ifdef EXPERIMENTAL_DIRS
323$(RECURSIVE_TARGETS)::
324 $(VERB) for dir in $(EXPERIMENTAL_DIRS); do \
325 if [ ! -f $$dir/Makefile ]; then \
326 $(MKDIR) $$dir; \
327 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
328 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +0000329 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000330 done
331endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000332
Reid Spencer81cd0492004-10-23 20:04:14 +0000333#---------------------------------------------------------
334# Handle the PARALLEL_DIRS options for parallel construction
335#---------------------------------------------------------
336ifdef PARALLEL_DIRS
337
Reid Spencer100080c2004-10-25 08:27:37 +0000338SUBDIRS += $(PARALLEL_DIRS)
Reid Spencer81cd0492004-10-23 20:04:14 +0000339# Unfortunately, this list must be maintained if new
340# recursive targets are added.
341all :: $(addsuffix /.makeall , $(PARALLEL_DIRS))
342clean :: $(addsuffix /.makeclean , $(PARALLEL_DIRS))
343check :: $(addsuffix /.makecheck , $(PARALLEL_DIRS))
344install :: $(addsuffix /.makeinstall , $(PARALLEL_DIRS))
345uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
346
347Parallel_Targets := $(foreach T,$(RECURSIVE_TARGETS),%/.make$(T))
348
349$(Parallel_Targets) :
Reid Spencerf206bd72004-10-22 21:01:56 +0000350 $(VERB) if [ ! -f $(@D)/Makefile ]; then \
351 $(MKDIR) $(@D); \
352 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswell6df35dd2003-11-25 19:32:22 +0000353 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +0000354 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000355endif
356
Reid Spencer81cd0492004-10-23 20:04:14 +0000357#---------------------------------------------------------
358# Handle the OPTIONAL_DIRS options for directores that may
359# or may not exist.
360#---------------------------------------------------------
John Criswell8224df92003-06-27 16:58:44 +0000361ifdef OPTIONAL_DIRS
Reid Spencer100080c2004-10-25 08:27:37 +0000362
363SUBDIRS += $(OPTIONAL_DIRS)
364
Reid Spencer81cd0492004-10-23 20:04:14 +0000365$(RECURSIVE_TARGETS)::
Reid Spencerf206bd72004-10-22 21:01:56 +0000366 $(VERB) for dir in $(OPTIONAL_DIRS); do \
367 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
368 if [ ! -f $$dir/Makefile ]; then \
369 $(MKDIR) $$dir; \
370 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
371 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +0000372 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000373 fi \
John Criswell8224df92003-06-27 16:58:44 +0000374 done
375endif
376
Reid Spencercc51e7b2004-08-20 09:20:05 +0000377#---------------------------------------------------------
378# Handle the CONFIG_FILES options
379#---------------------------------------------------------
380ifdef CONFIG_FILES
Reid Spencercc51e7b2004-08-20 09:20:05 +0000381
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000382install-local:: $(sysconfdir) $(CONFIG_FILES)
Reid Spencer4e181e72004-10-04 07:05:07 +0000383 $(VERB)$(ECHO) Installing Configuration Files To $(sysconfdir)
384 $(VERB)for file in $(CONFIG_FILES); do \
Reid Spencerf206bd72004-10-22 21:01:56 +0000385 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
Reid Spencercc51e7b2004-08-20 09:20:05 +0000386 done
Reid Spencer81cd0492004-10-23 20:04:14 +0000387
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000388uninstall-local::
Reid Spencer12a3a052004-10-24 07:53:21 +0000389 $(VERB)$(ECHO) Uninstalling Configuration Files From $(sysconfdir)
390 $(VERB)for file in $(CONFIG_FILES); do \
Reid Spencer100080c2004-10-25 08:27:37 +0000391 $(RM) -f $(sysconfdir)/$${file} ; \
Reid Spencer12a3a052004-10-24 07:53:21 +0000392 done
393
Reid Spencercc51e7b2004-08-20 09:20:05 +0000394endif
395
Reid Spencer81cd0492004-10-23 20:04:14 +0000396###############################################################################
397# Library Build Rules: Four ways to build a library
398###############################################################################
Chris Lattner2f7c9632001-06-06 20:29:01 +0000399
Brian Gaekeecc92bf2004-01-22 22:53:48 +0000400
Reid Spencer81cd0492004-10-23 20:04:14 +0000401# if we're building a library ...
Chris Lattner2f7c9632001-06-06 20:29:01 +0000402ifdef LIBRARYNAME
Vikram S. Advefe346892001-07-15 13:16:47 +0000403
Chris Lattner0100eab2002-09-16 22:36:42 +0000404# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000405LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencerf206bd72004-10-22 21:01:56 +0000406LIBNAME_LA := $(LIBDIR)/lib$(LIBRARYNAME).la
407LIBNAME_A := $(LIBDIR)/lib$(LIBRARYNAME).a
408LIBNAME_O := $(LIBDIR)/$(LIBRARYNAME).o
409LIBNAME_BC := $(LIBDIR)/lib$(LIBRARYNAME).bc
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000410
Reid Spencer81cd0492004-10-23 20:04:14 +0000411#---------------------------------------------------------
412# Shared Library Targets:
413# If the user asked for a shared library to be built
414# with the SHARED_LIBRARY variable, then we provide
415# targets for building them.
416#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000417ifdef SHARED_LIBRARY
418
Reid Spencer81cd0492004-10-23 20:04:14 +0000419all-local:: $(LIBNAME_LA)
Reid Spencerf206bd72004-10-22 21:01:56 +0000420
421$(LIBNAME_LA): $(BUILT_SOURCES) $(ObjectsLO) $(LIBDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000422 @$(ECHO) Linking $(CONFIGURATION) Shared Library $(notdir $@)
Reid Spencerf206bd72004-10-22 21:01:56 +0000423 $(VERB) $(Link) -o $@ $(ObjectsLO)
424 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $@ $(LIBDIR)
Reid Spencer81cd0492004-10-23 20:04:14 +0000425
426clean-local::
Reid Spencer12a3a052004-10-24 07:53:21 +0000427ifneq ($(strip $(LIBNAME_LA)),)
Reid Spencerf206bd72004-10-22 21:01:56 +0000428 $(VERB) $(RM) -f $(LIBNAME_LA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000429endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000430
Reid Spencer12a3a052004-10-24 07:53:21 +0000431DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf206bd72004-10-22 21:01:56 +0000432
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000433install-local:: $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000434
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000435$(DestSharedLib): $(libdir) $(LIBNAME_LA)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000436 @$(ECHO) Installing $(CONFIGURATION) Shared Library $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000437 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_LA) $(DestSharedLib)
438 $(VERB) $(LIBTOOL) --finish $(libdir)
439
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000440uninstall-local::
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000441 @$(ECHO) Uninstalling $(CONFIGURATION) Shared Library $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000442 $(VERB) $(RM) -f $(DestSharedLib)
443
Reid Spencerf206bd72004-10-22 21:01:56 +0000444endif
445
Reid Spencer81cd0492004-10-23 20:04:14 +0000446#---------------------------------------------------------
447# Bytecode Library Targets:
448# If the user asked for a bytecode library to be built
449# with the BYTECODE_LIBRARY variable, then we provide
450# targets for building them.
451#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000452ifdef BYTECODE_LIBRARY
453
454ifdef EXPORTED_SYMBOL_LIST
455 BCLinkLib += -Xlinker -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
456else
457 ifdef EXPORTED_SYMBOL_FILE
458 BCLinkLib += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
459 else
460 BCLinkLib += -Xlinker -disable-internalize
461 endif
462endif
463
Reid Spencer81cd0492004-10-23 20:04:14 +0000464all-local:: $(LIBNAME_BC)
Reid Spencerf206bd72004-10-22 21:01:56 +0000465
466$(LIBNAME_BC): $(BUILT_SOURCES) $(ObjectsBC) $(LIBDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000467 @$(ECHO) Linking $(CONFIGURATION) Bytecode Library $(notdir $@)
Reid Spencerf206bd72004-10-22 21:01:56 +0000468 $(VERB) $(BCLinkLib) -o $@ $(ObjectsBC)
469
Reid Spencer81cd0492004-10-23 20:04:14 +0000470clean-local::
Reid Spencer12a3a052004-10-24 07:53:21 +0000471ifneq ($(strip $(LIBNAME_BC)),)
Reid Spencerf206bd72004-10-22 21:01:56 +0000472 $(VERB) $(RM) -f $(LIBNAME_BC)
Reid Spencer12a3a052004-10-24 07:53:21 +0000473endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000474
Reid Spencer12a3a052004-10-24 07:53:21 +0000475DestBytecodeLib = $(bytecode_libdir)/lib$(LIBRARYNAME).bc
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000476
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000477install-local:: $(DestBytecodeLib)
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000478
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000479$(DestBytecodeLib): $(bytecode_libdir) $(LIBNAME_BC)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000480 @$(ECHO) Installing $(CONFIGURATION) Bytecode Library $(DestBytecodeLib)
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000481 $(VERB) $(INSTALL) $(LIBNAME_BC) $@
Reid Spencer12a3a052004-10-24 07:53:21 +0000482
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000483uninstall-local::
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000484 @$(ECHO) Uninstalling $(CONFIGURATION) Bytecode Library $(DestBytecodeLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000485 $(VERB) $(RM) -f $(DestBytecodeLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000486
487endif
Vikram S. Adve15bd3ad2002-08-02 18:34:12 +0000488
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000489# Does the library want a .o version built?
Chris Lattner76d98ba2002-07-23 17:56:16 +0000490ifndef DONT_BUILD_RELINKED
Reid Spencer81cd0492004-10-23 20:04:14 +0000491all-local:: $(LIBNAME_O)
Reid Spencerf206bd72004-10-22 21:01:56 +0000492
493$(LIBNAME_O): $(BUILT_SOURCES) $(ObjectsO) $(LIBDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000494 @$(ECHO) Linking $(CONFIGURATION) Object Library $(notdir $@)
Reid Spencerf206bd72004-10-22 21:01:56 +0000495 $(VERB) $(Relink) -o $@ $(ObjectsO)
496
Reid Spencer81cd0492004-10-23 20:04:14 +0000497clean-local::
Reid Spencer12a3a052004-10-24 07:53:21 +0000498ifneq ($(strip $(LIBNAME_O)),)
Reid Spencerf206bd72004-10-22 21:01:56 +0000499 $(VERB) $(RM) -f $(LIBNAME_O)
Reid Spencer12a3a052004-10-24 07:53:21 +0000500endif
501
502DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
503
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000504install-local:: $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000505
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000506$(DestRelinkedLib): $(libdir) $(LIBNAME_O)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000507 @$(ECHO) Installing $(CONFIGURATION) Object Library $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000508 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_O) $(DestRelinkedLib)
509
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000510uninstall-local::
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000511 @$(ECHO) Uninstalling $(CONFIGURATION) Object Library $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000512 $(VERB) $(RM) -f $(DestRelinkedLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000513
Chris Lattner76d98ba2002-07-23 17:56:16 +0000514endif
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000515
516# Does the library want an archive version built?
Chris Lattner76d98ba2002-07-23 17:56:16 +0000517ifdef BUILD_ARCHIVE
Reid Spencer81cd0492004-10-23 20:04:14 +0000518all-local:: $(LIBNAME_A)
Chris Lattner76d98ba2002-07-23 17:56:16 +0000519
Reid Spencerf206bd72004-10-22 21:01:56 +0000520$(LIBNAME_A): $(BUILT_SOURCES) $(ObjectsO) $(LIBDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000521 @$(ECHO) Building $(CONFIGURATION) Archive Library $(notdir $@)
Reid Spencer4e181e72004-10-04 07:05:07 +0000522 $(VERB)$(RM) -f $@
Reid Spencerf206bd72004-10-22 21:01:56 +0000523 $(VERB) $(Archive) $@ $(ObjectsO)
524 $(VERB) $(Ranlib) $@
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000525
Reid Spencer81cd0492004-10-23 20:04:14 +0000526clean-local::
Reid Spencer12a3a052004-10-24 07:53:21 +0000527ifneq ($(strip $(LIBNAME_A)),)
Reid Spencerf206bd72004-10-22 21:01:56 +0000528 $(VERB) $(RM) -f $(LIBNAME_A)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000529endif
530
Reid Spencer12a3a052004-10-24 07:53:21 +0000531DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
532
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000533install-local:: $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000534
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000535$(DestArchiveLib): $(libdir) $(LIBNAME_A)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000536 @$(ECHO) Installing $(CONFIGURATION) Archive Library $(DestArchiveLib)
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000537 $(VERB) $(MKDIR) $(libdir)
Reid Spencer12a3a052004-10-24 07:53:21 +0000538 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_A) $(DestArchiveLib)
539
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000540uninstall-local::
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000541 @$(ECHO) Uninstalling $(CONFIGURATION) Archive Library $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000542 $(VERB) $(RM) -f $(DestArchiveLib)
543
544endif
545
546# endif LIBRARYNAME
Reid Spencerf206bd72004-10-22 21:01:56 +0000547endif
548
Reid Spencerdcba7782004-10-24 08:21:04 +0000549###############################################################################
550# Tool Build Rules: Build executable tool based on TOOLNAME option
551###############################################################################
552
Chris Lattner07c7c192001-09-07 22:57:58 +0000553ifdef TOOLNAME
554
Reid Spencerdcba7782004-10-24 08:21:04 +0000555# TOOLEXENAME - This is the output filenames to generate
Reid Spencerf206bd72004-10-22 21:01:56 +0000556TOOLEXENAME := $(TOOLDIR)/$(TOOLNAME)
Chris Lattner07c7c192001-09-07 22:57:58 +0000557
Reid Spencerdcba7782004-10-24 08:21:04 +0000558# LIBS_OPTIONS - Compute the options lines that add -llib1 -llib2, etc.
Reid Spencerf206bd72004-10-22 21:01:56 +0000559PROJ_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
560PROJ_LIBS_OPTIONS := $(patsubst %.o, $(LIBDIR)/%.o, $(PROJ_LIBS_OPTIONS))
561LLVM_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
562LLVM_LIBS_OPTIONS := $(patsubst %.o, $(LLVMLIBDIR)/%.o, $(LLVM_LIBS_OPTIONS))
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000563
Reid Spencerdcba7782004-10-24 08:21:04 +0000564# USED_LIBS/LIBS_PATHS - Compute dependent library file paths
Reid Spencerf206bd72004-10-22 21:01:56 +0000565PROJ_USED_LIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
566LLVM_USED_LIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
567PROJ_LIBS_PATHS := $(addprefix $(LIBDIR)/,$(PROJ_USED_LIBS))
568LLVM_LIBS_PATHS := $(addprefix $(LLVMLIBDIR)/,$(LLVM_USED_LIBS))
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000569
Reid Spencerf206bd72004-10-22 21:01:56 +0000570# Handle compression libraries automatically
571ifeq ($(HAVE_BZIP2),1)
572LIBS += -lbz2
573endif
574ifeq ($(HAVE_ZLIB),1)
575LIBS += -lz
576endif
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000577
Chris Lattner3ecb7762003-01-22 16:13:31 +0000578# Tell make that we need to rebuild subdirectories before we can link the tool.
579# This affects things like LLI which has library subdirectories.
Reid Spencerdcba7782004-10-24 08:21:04 +0000580$(TOOLEXENAME): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner3ecb7762003-01-22 16:13:31 +0000581
Reid Spencerdcba7782004-10-24 08:21:04 +0000582all-local:: $(TOOLEXENAME)
John Criswell8224df92003-06-27 16:58:44 +0000583
Reid Spencer81cd0492004-10-23 20:04:14 +0000584clean-local::
Reid Spencer12a3a052004-10-24 07:53:21 +0000585ifneq ($(strip $(TOOLEXENAME)),)
Reid Spencerf206bd72004-10-22 21:01:56 +0000586 $(VERB) $(RM) -f $(TOOLEXENAME)
Reid Spencer12a3a052004-10-24 07:53:21 +0000587endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000588
Reid Spencerf206bd72004-10-22 21:01:56 +0000589$(TOOLEXENAME): $(BUILT_SOURCES) $(ObjectsO) $(PROJ_LIBS_PATHS) $(LLVM_LIBS_PATHS) $(TOOLDIR)/.dir
590 @$(ECHO) Linking $(CONFIGURATION) executable $(TOOLNAME) $(STRIP_WARN_MSG)
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000591 $(VERB) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(PROJ_LIBS_OPTIONS) \
592 $(LLVM_LIBS_OPTIONS) $(LIBS) $(TOOLLINKOPTSB)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000593 @$(ECHO) ======= Finished Linking $(CONFIGURATION) Executable $(TOOLNAME) $(STRIP_WARN_MSG)
Reid Spencer12a3a052004-10-24 07:53:21 +0000594
595DestTool = $(bindir)/$(TOOLNAME)
596
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000597install-local:: $(DestTool)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000598
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000599$(DestTool): $(bindir) $(TOOLEXENAME)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000600 @$(ECHO) Installing $(CONFIGURATION) $(DestTool)
601 $(VERB) $(INSTALL) $(TOOLEXENAME) $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000602
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000603uninstall-local::
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000604 @$(ECHO) Uninstalling $(CONFIGURATION) $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000605 $(VERB) $(RM) -f $(DestTool)
606
Reid Spencerf206bd72004-10-22 21:01:56 +0000607endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000608
Reid Spencerf206bd72004-10-22 21:01:56 +0000609ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000610
Reid Spencerf206bd72004-10-22 21:01:56 +0000611# Create .lo files in the OBJDIR directory from the .cpp and .c files...
Reid Spencer81cd0492004-10-23 20:04:14 +0000612ifdef SHARED_LIBRARY
613
614$(OBJDIR)/%.lo $(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000615 @$(ECHO) "Compiling $*.cpp (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000616 $(VERB) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(OBJDIR)/$*.LACXXd $< -o $@ ; \
617 then $(MV) -f "$(OBJDIR)/$*.LACXXd" "$(OBJDIR)/$*.d"; \
Reid Spencer100080c2004-10-25 08:27:37 +0000618 else $(RM) -f "$(OBJDIR)/$*.LACXXd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000619
620$(OBJDIR)/%.lo $(OBJDIR)/%.o: %.c $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000621 @$(ECHO) "Compiling $*.c (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000622 $(VERB) if $(LTCompile.C) -MD -MT $@ -MP -MF $(OBJDIR)/$*.LACd $< -o $@ ; \
623 then $(MV) -f "$(OBJDIR)/$*.LACd" "$(OBJDIR)/$*.d"; \
Reid Spencer100080c2004-10-25 08:27:37 +0000624 else $(RM) -f "$(OBJDIR)/$*.LACd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000625
626else
Reid Spencerf206bd72004-10-22 21:01:56 +0000627
628$(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000629 @$(ECHO) "Compiling $*.cpp"
Reid Spencer81cd0492004-10-23 20:04:14 +0000630 $(VERB) if $(Compile.CXX) -MD -MT $@ -MP -MF $(OBJDIR)/$*.CXXd $< -o $@ ; \
631 then $(MV) -f "$(OBJDIR)/$*.CXXd" "$(OBJDIR)/$*.d"; \
Reid Spencer100080c2004-10-25 08:27:37 +0000632 else $(RM) -f "$(OBJDIR)/$*.CXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +0000633
634$(OBJDIR)/%.o: %.c $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000635 @$(ECHO) "Compiling $*.c"
Reid Spencer81cd0492004-10-23 20:04:14 +0000636 $(VERB) if $(Compile.C) -MD -MT $@ -MP -MF $(OBJDIR)/$*.Cd $< -o $@ ; \
637 then $(MV) -f "$(OBJDIR)/$*.Cd" "$(OBJDIR)/$*.d"; \
Reid Spencer100080c2004-10-25 08:27:37 +0000638 else $(RM) -f "$(OBJDIR)/$*.Cd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000639
640endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000641
642# Create .bc files in the OBJDIR directory from .cpp and .c files...
643$(OBJDIR)/%.bc: %.cpp $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000644 @$(ECHO) "Compiling $*.cpp (bytecode)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000645 $(VERB) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(OBJDIR)/$*.BCCXXd" $< -o $@ ; \
646 then $(MV) -f "$(OBJDIR)/$*.BCCXXd" "$(OBJDIR)/$*.d"; \
Reid Spencer100080c2004-10-25 08:27:37 +0000647 else $(RM) -f "$(OBJDIR)/$*.BCCXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +0000648
649$(OBJDIR)/%.bc: %.c $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000650 @$(ECHO) "Compiling $*.c (bytecode)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000651 $(VERB) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(OBJDIR)/$*.BCCd" $< -o $@ ; \
652 then $(MV) -f "$(OBJDIR)/$*.BCCd" "$(OBJDIR)/$*.d"; \
Reid Spencer100080c2004-10-25 08:27:37 +0000653 else $(RM) -f "$(OBJDIR)/$*.BCCd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +0000654
655else
656
Reid Spencer81cd0492004-10-23 20:04:14 +0000657ifdef SHARED_LIBRARY
658
659$(OBJDIR)/%.lo $(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000660 @$(ECHO) "Compiling $*.cpp (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000661 $(LTCompile.CXX) $< -o $@
662
663$(OBJDIR)/%.lo $(OBJDIR)/%.o: %.c $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000664 @$(ECHO) "Compiling $*.cpp (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000665 $(LTCompile.C) $< -o $@
666
667else
Reid Spencerf206bd72004-10-22 21:01:56 +0000668
669$(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000670 @$(ECHO) "Compiling $*.cpp"
Reid Spencer81cd0492004-10-23 20:04:14 +0000671 $(Compile.CXX) $< -o $@
Reid Spencerf206bd72004-10-22 21:01:56 +0000672
673$(OBJDIR)/%.o: %.c $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000674 @$(ECHO) "Compiling $*.cpp"
Reid Spencer81cd0492004-10-23 20:04:14 +0000675 $(Compile.C) $< -o $@
676endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000677
678# Create .bc files in the OBJDIR directory from .cpp and .c files...
679$(OBJDIR)/%.bc: %.cpp $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000680 @$(ECHO) "Compiling $*.cpp (bytecode)"
Reid Spencerf206bd72004-10-22 21:01:56 +0000681 $(BCCompileCPP) $< -o $@
682
683$(OBJDIR)/%.bc: %.c $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000684 @$(ECHO) "Compiling $*.c (bytecode)"
Reid Spencerf206bd72004-10-22 21:01:56 +0000685 $(BCCompileC) $< -o $@
Brian Gaeke0f148bc2003-12-10 00:26:28 +0000686
Chris Lattner07c7c192001-09-07 22:57:58 +0000687endif
688
Reid Spencerf206bd72004-10-22 21:01:56 +0000689$(OBJDIR)/%.bc: %.ll $(OBJDIR)/.dir $(LLVMAS)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000690 @$(ECHO) "Compiling $*.ll"
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000691 $(VERB) $(LLVMAS) $< -f -o $@
692
Reid Spencerf206bd72004-10-22 21:01:56 +0000693ifdef TARGET
694
Reid Spencer282e13c2004-10-23 08:19:37 +0000695TDFILES := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
Reid Spencer94105c72004-10-27 04:34:35 +0000696INCFILES := $(filter %.inc,$(BUILT_SOURCES))
Reid Spencerf206bd72004-10-22 21:01:56 +0000697
Reid Spencer94105c72004-10-27 04:34:35 +0000698$(INCFILES) : $(TBLGEN) $(TDFILES)
Reid Spencerf206bd72004-10-22 21:01:56 +0000699
Reid Spencer94105c72004-10-27 04:34:35 +0000700%GenRegisterNames.inc : %.td
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000701 @$(ECHO) "Building $(<F) register names with tblgen"
Reid Spencerf206bd72004-10-22 21:01:56 +0000702 $(VERB) $(TableGen) -gen-register-enums -o $@ $<
703
Reid Spencer94105c72004-10-27 04:34:35 +0000704%GenRegisterInfo.h.inc : %.td
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000705 @$(ECHO) "Building $(<F) register information header with tblgen"
Reid Spencerf206bd72004-10-22 21:01:56 +0000706 $(VERB) $(TableGen) -gen-register-desc-header -o $@ $<
707
708%GenRegisterInfo.inc : %.td
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000709 @$(ECHO) "Building $(<F) register info implementation with tblgen"
Reid Spencerf206bd72004-10-22 21:01:56 +0000710 $(VERB) $(TableGen) -gen-register-desc -o $@ $<
711
712%GenInstrNames.inc : %.td
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000713 @$(ECHO) "Building $(<F) instruction names with tblgen"
Reid Spencerf206bd72004-10-22 21:01:56 +0000714 $(VERB) $(TableGen) -gen-instr-enums -o $@ $<
715
716%GenInstrInfo.inc : %.td
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000717 @$(ECHO) "Building $(<F) instruction information with tblgen"
Reid Spencerf206bd72004-10-22 21:01:56 +0000718 $(VERB) $(TableGen) -gen-instr-desc -o $@ $<
719
720%GenAsmWriter.inc : %.td
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000721 @$(ECHO) "Building $(<F) assembly writer with tblgen"
Reid Spencerf206bd72004-10-22 21:01:56 +0000722 $(VERB) $(TableGen) -gen-asm-writer -o $@ $<
723
724%GenATTAsmWriter.inc : %.td
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000725 @$(ECHO) "Building $(<F) AT&T assembly writer with tblgen"
Reid Spencerf206bd72004-10-22 21:01:56 +0000726 $(VERB) $(TableGen) -gen-asm-writer -o $@ $<
727
728%GenIntelAsmWriter.inc : %.td
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000729 @$(ECHO) "Building $(<F) Intel assembly writer with tblgen"
Reid Spencerf206bd72004-10-22 21:01:56 +0000730 $(VERB) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
731
732%GenInstrSelector.inc: %.td
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000733 @$(ECHO) "Building $(<F) instruction selector with tblgen"
Reid Spencerf206bd72004-10-22 21:01:56 +0000734 $(VERB) $(TableGen) -gen-instr-selector -o $@ $<
735
736%GenCodeEmitter.inc:: %.td
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000737 @$(ECHO) "Building $(<F) code emitter with tblgen"
Reid Spencerf206bd72004-10-22 21:01:56 +0000738 $(VERB) $(TableGen) -gen-emitter -o $@ $<
739
Reid Spencer81cd0492004-10-23 20:04:14 +0000740clean-local::
Reid Spencerf206bd72004-10-22 21:01:56 +0000741 $(VERB) rm -f *.inc
742
743endif
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000744
Chris Lattnerdb644dd2003-01-16 22:44:19 +0000745#
746# Rules for building lex/yacc files
747#
Reid Spencer81cd0492004-10-23 20:04:14 +0000748LEX_FILES = $(filter %.l, $(SOURCES))
Chris Lattnerdb644dd2003-01-16 22:44:19 +0000749LEX_OUTPUT = $(LEX_FILES:%.l=%.cpp)
Reid Spencer81cd0492004-10-23 20:04:14 +0000750YACC_FILES = $(filter %.y, $(SOURCES))
Chris Lattnerdb644dd2003-01-16 22:44:19 +0000751YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output)
752.PRECIOUS: $(LEX_OUTPUT) $(YACC_OUTPUT)
753
Chris Lattner2f7c9632001-06-06 20:29:01 +0000754# Create a .cpp source file from a flex input file... this uses sed to cut down
755# on the warnings emited by GCC...
Chris Lattner9e461662003-01-23 16:33:10 +0000756#
757# The last line is a gross hack to work around flex aparently not being able to
758# resize the buffer on a large token input. Currently, for uninitialized string
759# buffers in LLVM we can generate very long tokens, so this is a hack around it.
Chris Lattner92fc9b02003-08-15 20:00:47 +0000760# FIXME. (f.e. char Buffer[10000] )
Chris Lattner9e461662003-01-23 16:33:10 +0000761#
Chris Lattner2f7c9632001-06-06 20:29:01 +0000762%.cpp: %.l
Reid Spencerf206bd72004-10-22 21:01:56 +0000763 @$(ECHO) Flexing $<
Chris Lattnerb3aae612003-08-04 19:48:10 +0000764 $(VERB) $(FLEX) -t $< | \
Reid Spencerf206bd72004-10-22 21:01:56 +0000765 $(SED) '/^find_rule/d' | \
766 $(SED) 's/void yyunput/inline void yyunput/' | \
767 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
768 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencerb7f710a2004-10-28 00:41:43 +0000769 > $@
Chris Lattner2f7c9632001-06-06 20:29:01 +0000770
771# Rule for building the bison parsers...
Chris Lattner021249f2003-05-15 21:28:55 +0000772%.c: %.y # Cancel built-in rules for yacc
Reid Spencerb7f710a2004-10-28 00:41:43 +0000773%.cpp: %.y # Cancel built-in rules for yacc
Chris Lattner021249f2003-05-15 21:28:55 +0000774%.h: %.y # Cancel built-in rules for yacc
Chris Lattner2f7c9632001-06-06 20:29:01 +0000775%.cpp %.h : %.y
Reid Spencerf206bd72004-10-22 21:01:56 +0000776 @$(ECHO) "Bisoning $*.y"
John Criswellded98992003-09-09 20:57:03 +0000777 $(VERB) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
Reid Spencerb7f710a2004-10-28 00:41:43 +0000778 $(VERB) $(MV) -f $*.tab.c $*.cpp
779 $(VERB) $(MV) -f $*.tab.h $*.h
Chris Lattner2f7c9632001-06-06 20:29:01 +0000780
781# To create the directories...
782%/.dir:
Reid Spencerf206bd72004-10-22 21:01:56 +0000783 $(VERB) $(MKDIR) $* > /dev/null
John Criswell3ef61af2003-06-30 21:59:07 +0000784 @$(DATE) > $@
Chris Lattner2f7c9632001-06-06 20:29:01 +0000785
Reid Spencerf206bd72004-10-22 21:01:56 +0000786.PRECIOUS: $(OBJDIR)/.dir $(LIBDIR)/.dir $(TOOLDIR)/.dir $(LLVMLIBDIR)/.dir
787.PRECIOUS: $(LLVMTOOLDIR)/.dir
788
Chris Lattner23d47392003-01-16 21:06:18 +0000789# To create postscript files from dot files...
John Criswell4ffb8442003-10-02 19:02:02 +0000790ifneq ($(DOT),false)
Chris Lattner23d47392003-01-16 21:06:18 +0000791%.ps: %.dot
Reid Spencerf206bd72004-10-22 21:01:56 +0000792 $(DOT) -Tps < $< > $@
John Criswell3ef61af2003-06-30 21:59:07 +0000793else
794%.ps: %.dot
Reid Spencerf206bd72004-10-22 21:01:56 +0000795 $(ECHO) "Cannot build $@: The program dot is not installed"
John Criswell3ef61af2003-06-30 21:59:07 +0000796endif
Chris Lattner23d47392003-01-16 21:06:18 +0000797
John Criswell0a6e6aa2003-09-06 14:44:17 +0000798#
799# This rules ensures that header files that are removed still have a rule for
800# which they can be "generated." This allows make to ignore them and
801# reproduce the dependency lists.
802#
John Criswella8391af2003-09-18 18:37:08 +0000803%.h:: ;
John Criswell0a6e6aa2003-09-06 14:44:17 +0000804
Chris Lattnera8ce09e2002-09-22 02:47:15 +0000805# 'make clean' nukes the tree
Reid Spencer81cd0492004-10-23 20:04:14 +0000806clean-local::
Reid Spencer12a3a052004-10-24 07:53:21 +0000807ifneq ($(strip $(OBJDIR)),)
Reid Spencere0578112004-10-24 02:26:09 +0000808 $(VERB) $(RM) -rf $(OBJDIR)
Reid Spencer12a3a052004-10-24 07:53:21 +0000809endif
Brian Gaeke8625f682004-01-21 19:53:11 +0000810 $(VERB) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
811ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
812 $(VERB) $(RM) -f *$(SHLIBEXT)
813endif
Reid Spencer12a3a052004-10-24 07:53:21 +0000814ifneq ($(strip $(LEX_OUTPUT)),)
815 $(VERB) $(RM) -f $(LEX_OUTPUT)
816endif
817ifneq ($(strip $(YACC_OUTPUT)),)
818 $(VERB) $(RM) -f $(YACC_OUTPUT)
819endif
John Criswell3ef61af2003-06-30 21:59:07 +0000820
Reid Spencer81cd0492004-10-23 20:04:14 +0000821###############################################################################
822# DEPENDENCIES: Include the dependency files if we should
823###############################################################################
Chris Lattnere9d7d702003-08-22 14:10:16 +0000824ifndef DISABLE_AUTO_DEPENDENCIES
825
Reid Spencer81cd0492004-10-23 20:04:14 +0000826# If its not one of the cleaning targets
827ifneq ($strip($(filter-out clean clean-local dist-clean, $(MAKECMDGOALS))),)
Reid Spencerf206bd72004-10-22 21:01:56 +0000828
Reid Spencer81cd0492004-10-23 20:04:14 +0000829# Get the list of dependency files
830DependFiles := $(basename $(filter %.cpp %.c %.cc, $(SOURCES)))
831DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(CONFIGURATION)/%.d,$(DependFiles))
Misha Brukmanb891ffb2003-11-09 21:36:19 +0000832
Reid Spencer81cd0492004-10-23 20:04:14 +0000833-include /dev/null $(DependFiles)
834
John Criswell48ecca62003-08-12 18:51:51 +0000835endif
Chris Lattner598222b2003-08-18 17:27:40 +0000836
Chris Lattnere9d7d702003-08-22 14:10:16 +0000837endif # ifndef DISABLE_AUTO_DEPENDENCIES
Reid Spencerf206bd72004-10-22 21:01:56 +0000838
Reid Spencer100080c2004-10-25 08:27:37 +0000839###############################################################################
840# Handle construction of a distribution tarball
841###############################################################################
842
843.PHONY: dist dist-chck dist-clean distdir dist-gzip dist-bzip2 dist-zip
844
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000845#------------------------------------------------------------------------
846# Define distribution related variables
847#------------------------------------------------------------------------
Reid Spencer100080c2004-10-25 08:27:37 +0000848DistName := $(LLVM_TARBALL_NAME)
849DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000850TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer100080c2004-10-25 08:27:37 +0000851DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
852DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
853DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
854DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
855 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000856 Makefile.config.in configure autoconf
857DistOther := $(notdir $(wildcard \
858 $(BUILD_SRC_DIR)/*.h \
859 $(BUILD_SRC_DIR)/*.td \
860 $(BUILD_SRC_DIR)/*.def \
861 $(BUILD_SRC_DIR)/*.ll \
862 $(BUILD_SRC_DIR)/*.in))
863DistSources := $(SOURCES) $(EXTRA_DIST)
864DistSubDirs := $(SUBDIRS)
865DistFiles := $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer100080c2004-10-25 08:27:37 +0000866
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000867
868#------------------------------------------------------------------------
869# We MUST build distribution with OBJ_DIR != SRC_DIR
870#------------------------------------------------------------------------
871ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
872dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
873 @$(ECHO) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
874
875DistCheckTop :=
876else
877
878DistCheckTop := check
879#------------------------------------------------------------------------
880# Prevent catastrophic remove
881#------------------------------------------------------------------------
882ifeq ($(LLVM_TARBALL_NAME),)
883$(error LLVM_TARBALL_NAME is empty. Please rerun configure)
884endif
885
886#------------------------------------------------------------------------
887# Prevent attempt to run dist targets from anywhere but the top level
888#------------------------------------------------------------------------
889ifneq ($(LEVEL),.)
890
891dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
892 @$(ECHO) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
893
894else
895
896#------------------------------------------------------------------------
897# Provide the top level targets
898#------------------------------------------------------------------------
899
900dist-gzip: $(DistTarGZip)
901
902$(DistTarGZip) : distdir
903 @$(ECHO) Packing gzipped distribution tar file.
904 $(VERB) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | gzip -c > "$(DistTarGZip)"
905
906dist-bzip2: $(DistTarBZ2)
907
908$(DistTarBZ2) : distdir
909 @$(ECHO) Packing bzipped distribution tar file.
910 $(VERB) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | $(BZIP2) -c >$(DistTarBZ2)
911
912dist-zip: $(DistZip)
913
914$(DistZip) : distdir
915 @$(ECHO) Packing zipped distribution file.
916 $(VERB) rm -f $(DistZip)
917 $(VERB) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
918
919dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
920 @$(ECHO) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
921
922DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
923
Reid Spencer77a46d22004-10-26 22:26:33 +0000924dist-check:: $(DistCheckTop) $(DistTarGZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000925 @$(ECHO) Checking distribution tar file.
926 $(VERB) if test -d $(DistCheckDir) ; then \
927 $(RM) -rf $(DistCheckDir) ; \
928 fi
929 $(VERB) $(MKDIR) $(DistCheckDir)
930 $(VERB) cd $(DistCheckDir) && \
931 $(MKDIR) $(DistCheckDir)/build && \
932 $(MKDIR) $(DistCheckDir)/install && \
933 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
934 cd build && \
935 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
936 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
937 $(MAKE) check && \
938 $(MAKE) install && \
939 $(MAKE) uninstall && \
940 $(MAKE) dist && \
941 $(MAKE) clean && \
942 $(MAKE) dist-clean && \
943 $(ECHO) ===== $(DistTarGZip) Ready For Distribution =====
944
945dist-clean::
946 @$(ECHO) Cleaning distribution files
947 $(VERB) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) $(DistCheckDir)
948
949endif
950
951#------------------------------------------------------------------------
952# Provide the recursive distdir target for building the distribution directory
953#------------------------------------------------------------------------
Reid Spencer77a46d22004-10-26 22:26:33 +0000954distdir : $(DistSources)
Reid Spencer100080c2004-10-25 08:27:37 +0000955 @$(ECHO) Building Distribution Directory $(DistDir)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000956 $(VERB) if test "$(DistDir)" = "$(TopDistDir)" ; then \
957 if test -d "$(DistDir)" ; then \
958 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
959 exit 1 ; \
960 fi ; \
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000961 $(ECHO) Removing $(DistDir) ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000962 $(RM) -rf $(DistDir); \
963 fi
Reid Spencer100080c2004-10-25 08:27:37 +0000964 $(VERB) $(MKDIR) $(DistDir)
965 $(VERB) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
966 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
967 for file in $(DistFiles) ; do \
968 case "$$file" in \
969 $(BUILD_SRC_DIR)/*) file=`echo "$$file" | sed "s#^$$srcdirstrip/##"`;; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000970 $(BUILD_SRC_ROOT)/*) file=`echo "$$file" | sed "s#^$$srcrootstrip/#$(BUILD_OBJ_ROOT)/#"`;; \
Reid Spencer100080c2004-10-25 08:27:37 +0000971 esac; \
972 if test -f "$$file" || test -d "$$file" ; then \
973 from_dir=. ; \
974 else \
975 from_dir=$(BUILD_SRC_DIR); \
976 fi; \
977 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'`; \
978 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
979 to_dir="$(DistDir)/$$dir"; \
980 $(MKDIR) "$$to_dir" ; \
981 else \
982 to_dir="$(DistDir)"; \
983 fi; \
984 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
985 if test -n "$$mid_dir" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000986 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +0000987 fi ; \
988 if test -d "$$from_dir/$$file"; then \
989 if test -d "$(BUILD_SRC_DIR)/$$file" && \
990 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
991 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
992 fi; \
993 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
994 elif test -f "$$from_dir/$$file" ; then \
995 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
996 elif test -L "$$from_dir/$$file" ; then \
997 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
998 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
999 $(ECHO) "===== WARNING: Distribution Source $$from_dir/$$file Not Found!" ; \
1000 elif test "$(VERB)" != '@' ; then \
1001 $(ECHO) "Skipping non-existent $$from_dir/$$file" ; \
1002 fi; \
1003 done
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001004 $(VERB) for subdir in $(DistSubDirs) ; do \
Reid Spencer100080c2004-10-25 08:27:37 +00001005 if test "$$subdir" \!= "." ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001006 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001007 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1008 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001009 fi; \
1010 done
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001011 $(VERB) $(MAKE) DistDir="$(DistDir)" dist-hook || exit 1
Reid Spencer100080c2004-10-25 08:27:37 +00001012 -$(VERB) find $(DistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
1013 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
1014 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
1015 ! -type d ! -perm -444 -exec $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1016 || chmod -R a+r $(DistDir)
1017
1018dist-hook::
1019
1020
Reid Spencer23a70372004-10-22 23:06:30 +00001021endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001022
1023###############################################################################
Reid Spencer12a3a052004-10-24 07:53:21 +00001024# TOP LEVEL - targets only to apply at the top level directory
1025###############################################################################
1026
1027ifeq ($(LEVEL),.)
1028
1029#------------------------------------------------------------------------
Reid Spencer12a3a052004-10-24 07:53:21 +00001030# Install support for project's include files:
1031#------------------------------------------------------------------------
1032install-local::
1033 @$(ECHO) Installing include files
1034 $(VERB) $(MKDIR) $(includedir)
1035 $(VERB) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1036 cd $(BUILD_SRC_ROOT)/include && \
1037 find . -path '*/Internal' -prune -o '(' -type f \
1038 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1039 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1040 fi
1041
1042uninstall-local::
1043 @$(ECHO) Uninstalling include files
1044 $(VERB) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1045 cd $(BUILD_SRC_ROOT)/include && \
1046 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1047 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1048 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1049 fi
1050
1051#------------------------------------------------------------------------
1052# Build tags database for Emacs/Xemacs:
1053#------------------------------------------------------------------------
Reid Spencer100080c2004-10-25 08:27:37 +00001054tags:: TAGS
Reid Spencer12a3a052004-10-24 07:53:21 +00001055
Reid Spencer100080c2004-10-25 08:27:37 +00001056TAGS:
Reid Spencer12a3a052004-10-24 07:53:21 +00001057 find include lib tools examples -name '*.cpp' -o -name '*.h' | $(ETAGS) $(ETAGSFLAGS) -
1058
Reid Spencer12a3a052004-10-24 07:53:21 +00001059endif
1060
1061###############################################################################
Reid Spencerf206bd72004-10-22 21:01:56 +00001062# MISCELLANEOUS - utility targets
1063###############################################################################
1064
1065#------------------------------------------------------------------------
1066# Print out the directories used for building
Reid Spencer81cd0492004-10-23 20:04:14 +00001067printvars::
Reid Spencer77a46d22004-10-26 22:26:33 +00001068 @$(ECHO) "CONFIGURATION : " $(CONFIGURATION)
Reid Spencerf206bd72004-10-22 21:01:56 +00001069 @$(ECHO) "BUILD_SRC_ROOT: " $(BUILD_SRC_ROOT)
1070 @$(ECHO) "BUILD_SRC_DIR : " $(BUILD_SRC_DIR)
1071 @$(ECHO) "BUILD_OBJ_ROOT: " $(BUILD_OBJ_ROOT)
1072 @$(ECHO) "BUILD_OBJ_DIR : " $(BUILD_OBJ_DIR)
1073 @$(ECHO) "LLVM_SRC_ROOT : " $(LLVM_SRC_ROOT)
1074 @$(ECHO) "LLVM_OBJ_ROOT : " $(LLVM_OBJ_ROOT)
Reid Spencer77a46d22004-10-26 22:26:33 +00001075 @$(ECHO) "libdir : " $(libdir)
1076 @$(ECHO) "bindir : " $(bindir)
1077 @$(ECHO) "sysconfdir : " $(sysconfdir)
1078 @$(ECHO) "bytecode_libdir : " $(bytecode_libdir)
1079 @$(ECHO) "USER_TARGETS : " $(USER_TARGETS)
1080 @$(ECHO) "OBJMKFILES: $(OBJMKFILES)"
1081 @$(ECHO) "SRCMKFILES: $(SRCMKFILES)"
Reid Spencerf206bd72004-10-22 21:01:56 +00001082 @$(ECHO) "OBJDIR: " $(OBJDIR)
1083 @$(ECHO) "LIBDIR: " $(LIBDIR)
1084 @$(ECHO) "TOOLDIR: " $(TOOLDIR)
1085 @$(ECHO) "TDFILES:" '$(TDFILES)'
Reid Spencer81cd0492004-10-23 20:04:14 +00001086 @$(ECHO) "Compile.CXX: " '$(Compile.CXX)'
1087 @$(ECHO) "Compile.C: " '$(Compile.C)'
Reid Spencer12a3a052004-10-24 07:53:21 +00001088