blob: 0e90ed760f10bd9389160887ff6c7936678856fb [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
Reid Spencer9411c642004-10-26 22:26:33 +000028LOCAL_TARGETS := all-local clean-local check-local install-local \
29 printvars 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
Reid Spencer9411c642004-10-26 22:26:33 +000038###############################################################################
39# INITIALIZATION: Basic things the makefile needs
40###############################################################################
41
42#--------------------------------------------------------------------
43# Reset the list of suffixes we know how to build
44#--------------------------------------------------------------------
45.SUFFIXES:
46.SUFFIXES: .c .cpp .h .hpp .y .l .lo .o .a $(SHLIBEXT) .bc .td .ps .dot $(SUFFIXES)
47
Reid Spencer3a561f52004-10-23 20:04:14 +000048#--------------------------------------------------------------------
49# Mark all of these targets as phony to avoid implicit rule search
50#--------------------------------------------------------------------
Reid Spencer151f8ba2004-10-25 08:27:37 +000051.PHONY: $(USER_TARGETS) $(INTERNAL_TARGETS)
Reid Spencer3a561f52004-10-23 20:04:14 +000052
53#--------------------------------------------------------------------
Reid Spencer9411c642004-10-26 22:26:33 +000054# Make sure all the user-target rules are double colon rules and
55# they are defined first.
Reid Spencer3a561f52004-10-23 20:04:14 +000056#--------------------------------------------------------------------
57
Reid Spencer9411c642004-10-26 22:26:33 +000058$(USER_TARGETS)::
Reid Spencer151f8ba2004-10-25 08:27:37 +000059
Reid Spencer9411c642004-10-26 22:26:33 +000060################################################################################
61# PRECONDITIONS: that which must be built/checked first
62################################################################################
63
64SRCMKFILES := $(wildcard $(BUILD_SRC_DIR)/Makefile*)
65OBJMKFILES := $(subst $(BUILD_SRC_DIR),$(BUILD_OBJ_DIR),$(SRCMKFILES))
66CONFIGURE := $(LLVM_SRC_ROOT)/configure
67CONFIG_STATUS := $(LLVM_OBJ_ROOT)/config.status
68MAKE_CONFIG_IN:= $(LLVM_SRC_ROOT)/Makefile.config.in
69MAKE_CONFIG := $(LLVM_OBJ_ROOT)/Makefile.config
70PRECONDITIONS := $(CONFIG_STATUS) $(MAKE_CONFIG) $(OBJMKFILES)
71
72preconditions : $(PRECONDITIONS)
73
74#------------------------------------------------------------------------
75# Make sure the BUILT_SOURCES are built first
76#------------------------------------------------------------------------
77$(filter-out clean clean-local,USER_TARGETS):: $(BUILT_SOURCES)
78
79clean-local::
80ifneq ($(strip $(BUILT_SOURCES)),)
81 $(VERB) $(RM) -f $(BUILT_SOURCES)
82endif
83
84#------------------------------------------------------------------------
85# Make sure we're not using a stale configuration
86#------------------------------------------------------------------------
87.PRECIOUS: $(CONFIG_STATUS)
88$(CONFIG_STATUS): $(CONFIGURE)
89 @$(ECHO) Reconfiguring with $<
90 $(VERB) $(CONFIG_STATUS) --recheck $(CONFIGUREFLAGS)
91
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 $< $@
109 $(VERB) $(MAKE) $(MAKECMDGOALS)
110
111# Copy the Makefile.* files unless we're in the root directory which avoids
112# the copying of Makefile.config.in or other things that should be explicitly
113# taken care of.
114ifneq ($(BUILD_OBJ_DIR),$(BUILD_OBJ_ROOT))
115$(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
116 @$(ECHO) "Updating $(@F)"
117 $(VERB) $(MKDIR) $(@D)
118 $(VERB) cp -f $< $@
119 $(VERB) $(MAKE) $(MAKECMDGOALS)
120endif
121endif
122
123#------------------------------------------------------------------------
124# Set up the basic dependencies
125#------------------------------------------------------------------------
126$(USER_TARGETS):: $(PRECONDITIONS)
127
128all:: all-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000129check:: check-local
130clean:: clean-local
Reid Spencer9411c642004-10-26 22:26:33 +0000131install:: install-local
132uninstall:: uninstall-local
133check-local:: all-local
134install-local:: all-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000135
136###############################################################################
137# VARIABLES: Set up various variables based on configuration data
138###############################################################################
139
140#--------------------------------------------------------------------
141# Variables derived from configuration we are building
Chris Lattner00950542001-06-06 20:29:01 +0000142#--------------------------------------------------------------------
143
Chris Lattner760da062003-03-14 20:25:22 +0000144ifdef ENABLE_PROFILING
Chris Lattner760da062003-03-14 20:25:22 +0000145 CONFIGURATION := Profile
Reid Spencer4d71b662004-10-22 21:01:56 +0000146 CXXFLAGS += -O3 -DNDEBUG -felide-constructors -finline-functions -pg
147 CFLAGS += -O3 -DNDEBUG -pg
148 LDFLAGS += -O3 -DNDEBUG -pg
Chris Lattner760da062003-03-14 20:25:22 +0000149else
150 ifdef ENABLE_OPTIMIZED
151 CONFIGURATION := Release
Reid Spencer4d71b662004-10-22 21:01:56 +0000152 CXXFLAGS += -O3 -DNDEBUG -finline-functions -felide-constructors -fomit-frame-pointer
153 CFLAGS += -O3 -DNDEBUG -fomit-frame-pointer
154 LDFLAGS += -O3 -DNDEBUG
Chris Lattner760da062003-03-14 20:25:22 +0000155 else
156 CONFIGURATION := Debug
Reid Spencer4d71b662004-10-22 21:01:56 +0000157 CXXFLAGS += -g -D_DEBUG
158 CFLAGS += -g -D_DEBUG
159 LDFLAGS += -g -D_DEBUG
160 KEEP_SYMBOLS := 1
Chris Lattner760da062003-03-14 20:25:22 +0000161 endif
162endif
163
Reid Spencer4d71b662004-10-22 21:01:56 +0000164ARFLAGS := cru
Reid Spencer3a561f52004-10-23 20:04:14 +0000165
166#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000167# Directory locations
Reid Spencer3a561f52004-10-23 20:04:14 +0000168#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000169OBJDIR := $(BUILD_OBJ_DIR)/$(CONFIGURATION)
170LIBDIR := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
171TOOLDIR := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
172LLVMLIBDIR := $(LLVM_OBJ_ROOT)/lib/$(CONFIGURATION)
173LLVMTOOLDIR := $(LLVM_OBJ_ROOT)/tools/$(CONFIGURATION)
John Criswell7a73b802003-06-30 21:59:07 +0000174
Reid Spencer3a561f52004-10-23 20:04:14 +0000175#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000176# Full Paths To Compiled Tools and Utilities
Reid Spencer3a561f52004-10-23 20:04:14 +0000177#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000178LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
179LLVMAS := $(LLVMTOOLDIR)/llvm-as$(EXEEXT)
180BURG := $(LLVMTOOLDIR)/burg$(EXEEXT)
181TBLGEN := $(LLVMTOOLDIR)/tblgen$(EXEEXT)
182GCCLD := $(LLVMTOOLDIR)/gccld$(EXEEXT)
183LLVMGCC := PATH=$(LLVMTOOLDIR):$(PATH) $(LLVMGCCDIR)/bin/gcc
184LLVMGXX := PATH=$(LLVMTOOLDIR):$(PATH) $(LLVMGCCDIR)/bin/g++
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000185
Reid Spencer4d71b662004-10-22 21:01:56 +0000186# Need a better way to compute this.
187LLVMGCCLIBDIR := $(dir $(shell $(LLVMGCC) -print-file-name=libgcc.a))/
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000188
Reid Spencer3a561f52004-10-23 20:04:14 +0000189#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000190# Adjust to user's request
Reid Spencer3a561f52004-10-23 20:04:14 +0000191#--------------------------------------------------------------------
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000192
Reid Spencer3a561f52004-10-23 20:04:14 +0000193# Adjust LIBTOOL options for shared libraries, or not.
John Criswell82f4a5a2003-07-31 20:58:51 +0000194ifndef SHARED_LIBRARY
Reid Spencer4d71b662004-10-22 21:01:56 +0000195 LIBTOOL += --tag=disable-shared
196else
197 LDFLAGS += -rpath $(LIBDIR)
John Criswell82f4a5a2003-07-31 20:58:51 +0000198endif
199
Reid Spencer3a561f52004-10-23 20:04:14 +0000200# Adjust settings for verbose mode
Chris Lattner760da062003-03-14 20:25:22 +0000201ifndef VERBOSE
Reid Spencer4d71b662004-10-22 21:01:56 +0000202 VERB := @
203 LIBTOOL += --silent
204 AR += >/dev/null 2>/dev/null
Reid Spencer151f8ba2004-10-25 08:27:37 +0000205 CONFIGUREFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
206else
207 CONFIGUREFLAGS :=
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000208endif
209
Vikram S. Advefeeae582002-09-18 11:55:13 +0000210# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000211ifndef KEEP_SYMBOLS
Reid Spencer4d71b662004-10-22 21:01:56 +0000212 STRIP = $(PLATFORMSTRIPOPTS)
213 STRIP_WARN_MSG = "(without symbols)"
Vikram S. Advefeeae582002-09-18 11:55:13 +0000214endif
215
Reid Spencer3a561f52004-10-23 20:04:14 +0000216# Adjust linker flags for building an executable
Reid Spencer4d71b662004-10-22 21:01:56 +0000217ifdef TOOLNAME
218 LDFLAGS += -rpath $(TOOLDIR) -export-dynamic $(TOOLLINKOPTS)
219endif
Chris Lattner00950542001-06-06 20:29:01 +0000220
Reid Spencer3a561f52004-10-23 20:04:14 +0000221# Use TOOLLINKOPTSB to pass options to the linker like library search
222# path etc.
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000223# Note that this is different from TOOLLINKOPTS, these options
224# are passed to the linker *before* the USEDLIBS options are passed.
225# e.g. usage TOOLLINKOPTSB = -L/home/xxx/lib
226ifdef TOOLLINKOPTSB
Reid Spencer4d71b662004-10-22 21:01:56 +0000227LDFLAGS += $(TOOLLINKOPTSB)
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000228endif
229
Reid Spencer3a561f52004-10-23 20:04:14 +0000230#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000231# Options To Invoke Tools
Reid Spencer3a561f52004-10-23 20:04:14 +0000232#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000233
234CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
235
Reid Spencer3a561f52004-10-23 20:04:14 +0000236LDFLAGS += -L$(LIBDIR) -L$(LLVMLIBDIR)
Reid Spencer4d71b662004-10-22 21:01:56 +0000237CPPFLAGS += -I$(BUILD_OBJ_DIR) \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000238 -I$(BUILD_SRC_DIR) \
239 -I$(BUILD_SRC_ROOT)/include \
240 -I$(BUILD_OBJ_ROOT)/include \
241 -I$(LLVM_OBJ_ROOT)/include \
242 -I$(LLVM_SRC_ROOT)/include \
243 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
Reid Spencer4d71b662004-10-22 21:01:56 +0000244
Reid Spencer3a561f52004-10-23 20:04:14 +0000245Compile.C = $(CC) $(CPPFLAGS) $(CompileCommonOpts) -c $(CFLAGS)
246Compile.CXX = $(CXX) $(CPPFLAGS) $(CompileCommonOpts) $(CXXFLAGS) -c
247LTCompile.C = $(LIBTOOL) --mode=compile $(Compile.C)
248LTCompile.CXX = $(LIBTOOL) --tag=CXX --mode=compile $(Compile.CXX)
249BCCompile.CXX = $(LLVMGXX) $(CPPFLAGS) $(CompileCommonOpts) $(CXXFLAGS) -c
250BCCompile.C = $(LLVMGCC) $(CPPFLAGS) $(CompileCommonOpts) $(CFLAGS) -c
251Link = $(LIBTOOL) --tag=CXX --mode=link $(CXX) $(CPPFLAGS) \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000252 $(CompileCommonOpts) $(LDFLAGS) $(STRIP)
Reid Spencer3a561f52004-10-23 20:04:14 +0000253Relink = $(LIBTOOL) --tag=CXX --mode=link $(CXX)
254BCLinkLib = $(LLVMGCC) -shared -nostdlib
255Burg = $(BURG) -I $(BUILD_SRC_DIR)
256TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
257Archive = $(AR) $(ARFLAGS)
Reid Spencer4d71b662004-10-22 21:01:56 +0000258ifdef RANLIB
Reid Spencer3a561f52004-10-23 20:04:14 +0000259Ranlib = $(RANLIB)
Reid Spencer4d71b662004-10-22 21:01:56 +0000260else
Reid Spencer3a561f52004-10-23 20:04:14 +0000261Ranlib = ranlib
John Criswell7a73b802003-06-30 21:59:07 +0000262endif
263
Chris Lattner00950542001-06-06 20:29:01 +0000264#----------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000265# Get the list of source files
266#----------------------------------------------------------
267ifndef SOURCES
268SOURCES := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000269 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
270 $(BUILD_SRC_DIR)/*.l))
Reid Spencer4d71b662004-10-22 21:01:56 +0000271endif
272
273ifdef BUILT_SOURCES
Reid Spencer3a561f52004-10-23 20:04:14 +0000274SOURCES += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Vikram S. Advead9ea7e2002-10-14 16:40:04 +0000275endif
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000276
Reid Spencer3a561f52004-10-23 20:04:14 +0000277#----------------------------------------------------------
278# Types of objects that can be built from sources
279#----------------------------------------------------------
280BASENAME_SOURCES := $(sort $(basename $(SOURCES)))
281ObjectsO := $(BASENAME_SOURCES:%=$(OBJDIR)/%.o)
282ObjectsLO := $(BASENAME_SOURCES:%=$(OBJDIR)/%.lo)
283ObjectsBC := $(BASENAME_SOURCES:%=$(OBJDIR)/%.bc)
284
285
286###############################################################################
287# DIRECTORIES: Handle recursive descent of directory structure
288###############################################################################
John Criswell82f4a5a2003-07-31 20:58:51 +0000289
Chris Lattner00950542001-06-06 20:29:01 +0000290#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000291# Handle the DIRS options for sequential construction
Chris Lattner00950542001-06-06 20:29:01 +0000292#---------------------------------------------------------
293
Reid Spencer151f8ba2004-10-25 08:27:37 +0000294SUBDIRS :=
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000295ifdef DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000296SUBDIRS += $(DIRS)
Reid Spencer3a561f52004-10-23 20:04:14 +0000297$(RECURSIVE_TARGETS)::
Reid Spencer4d71b662004-10-22 21:01:56 +0000298 $(VERB) for dir in $(DIRS); do \
299 if [ ! -f $$dir/Makefile ]; then \
300 $(MKDIR) $$dir; \
301 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
302 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000303 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000304 done
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000305endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000306
Reid Spencer3a561f52004-10-23 20:04:14 +0000307#---------------------------------------------------------
308# Handle the EXPERIMENTAL_DIRS options ensuring success
309# after each directory is built.
310#---------------------------------------------------------
311ifdef EXPERIMENTAL_DIRS
312$(RECURSIVE_TARGETS)::
313 $(VERB) for dir in $(EXPERIMENTAL_DIRS); do \
314 if [ ! -f $$dir/Makefile ]; then \
315 $(MKDIR) $$dir; \
316 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
317 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000318 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000319 done
320endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000321
Reid Spencer3a561f52004-10-23 20:04:14 +0000322#---------------------------------------------------------
323# Handle the PARALLEL_DIRS options for parallel construction
324#---------------------------------------------------------
325ifdef PARALLEL_DIRS
326
Reid Spencer151f8ba2004-10-25 08:27:37 +0000327SUBDIRS += $(PARALLEL_DIRS)
Reid Spencer3a561f52004-10-23 20:04:14 +0000328# Unfortunately, this list must be maintained if new
329# recursive targets are added.
330all :: $(addsuffix /.makeall , $(PARALLEL_DIRS))
331clean :: $(addsuffix /.makeclean , $(PARALLEL_DIRS))
332check :: $(addsuffix /.makecheck , $(PARALLEL_DIRS))
333install :: $(addsuffix /.makeinstall , $(PARALLEL_DIRS))
334uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
335
336Parallel_Targets := $(foreach T,$(RECURSIVE_TARGETS),%/.make$(T))
337
338$(Parallel_Targets) :
Reid Spencer4d71b662004-10-22 21:01:56 +0000339 $(VERB) if [ ! -f $(@D)/Makefile ]; then \
340 $(MKDIR) $(@D); \
341 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswellb3866b62003-11-25 19:32:22 +0000342 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000343 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
Chris Lattner00950542001-06-06 20:29:01 +0000344endif
345
Reid Spencer3a561f52004-10-23 20:04:14 +0000346#---------------------------------------------------------
347# Handle the OPTIONAL_DIRS options for directores that may
348# or may not exist.
349#---------------------------------------------------------
John Criswell2a6530f2003-06-27 16:58:44 +0000350ifdef OPTIONAL_DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000351
352SUBDIRS += $(OPTIONAL_DIRS)
353
Reid Spencer3a561f52004-10-23 20:04:14 +0000354$(RECURSIVE_TARGETS)::
Reid Spencer4d71b662004-10-22 21:01:56 +0000355 $(VERB) for dir in $(OPTIONAL_DIRS); do \
356 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
357 if [ ! -f $$dir/Makefile ]; then \
358 $(MKDIR) $$dir; \
359 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
360 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000361 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000362 fi \
John Criswell2a6530f2003-06-27 16:58:44 +0000363 done
364endif
365
Reid Spencerfc945082004-08-20 09:20:05 +0000366#---------------------------------------------------------
367# Handle the CONFIG_FILES options
368#---------------------------------------------------------
369ifdef CONFIG_FILES
Reid Spencerfc945082004-08-20 09:20:05 +0000370
Reid Spencere5487ba2004-10-24 07:53:21 +0000371install-local:: install-config-dir
Reid Spencer3a561f52004-10-23 20:04:14 +0000372
373install-config-dir: $(sysconfdir) $(CONFIG_FILES)
Reid Spencer37130d22004-10-04 07:05:07 +0000374 $(VERB)$(ECHO) Installing Configuration Files To $(sysconfdir)
375 $(VERB)for file in $(CONFIG_FILES); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000376 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
Reid Spencerfc945082004-08-20 09:20:05 +0000377 done
Reid Spencer3a561f52004-10-23 20:04:14 +0000378
Reid Spencere5487ba2004-10-24 07:53:21 +0000379uninstall-local:: uninstall-config-dir
380
381uninstall-config-dir:
382 $(VERB)$(ECHO) Uninstalling Configuration Files From $(sysconfdir)
383 $(VERB)for file in $(CONFIG_FILES); do \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000384 $(RM) -f $(sysconfdir)/$${file} ; \
Reid Spencere5487ba2004-10-24 07:53:21 +0000385 done
386
Reid Spencer3a561f52004-10-23 20:04:14 +0000387$(sysconfdir):
Reid Spencer9411c642004-10-26 22:26:33 +0000388 $(VERB) $(MKDIR) $(sysconfdir)
Reid Spencer3a561f52004-10-23 20:04:14 +0000389
Reid Spencerfc945082004-08-20 09:20:05 +0000390endif
391
Reid Spencer3a561f52004-10-23 20:04:14 +0000392###############################################################################
393# Library Build Rules: Four ways to build a library
394###############################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000395
Reid Spencere45ebfa2004-10-26 07:09:33 +0000396$(libdir):
397 $(VERB) $(MKDIR) $(libdir)
398
399$(bytecode_libdir):
400 $(VERB) $(MKDIR) $(bytecode_libdir)
401
402
Brian Gaeke8abff792004-01-22 22:53:48 +0000403
Reid Spencer3a561f52004-10-23 20:04:14 +0000404# if we're building a library ...
Chris Lattner00950542001-06-06 20:29:01 +0000405ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000406
Chris Lattner2a548c52002-09-16 22:36:42 +0000407# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000408LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencer4d71b662004-10-22 21:01:56 +0000409LIBNAME_LA := $(LIBDIR)/lib$(LIBRARYNAME).la
410LIBNAME_A := $(LIBDIR)/lib$(LIBRARYNAME).a
411LIBNAME_O := $(LIBDIR)/$(LIBRARYNAME).o
412LIBNAME_BC := $(LIBDIR)/lib$(LIBRARYNAME).bc
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000413
Reid Spencer3a561f52004-10-23 20:04:14 +0000414#---------------------------------------------------------
415# Shared Library Targets:
416# If the user asked for a shared library to be built
417# with the SHARED_LIBRARY variable, then we provide
418# targets for building them.
419#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000420ifdef SHARED_LIBRARY
421
Reid Spencer3a561f52004-10-23 20:04:14 +0000422all-local:: $(LIBNAME_LA)
Reid Spencer4d71b662004-10-22 21:01:56 +0000423
424$(LIBNAME_LA): $(BUILT_SOURCES) $(ObjectsLO) $(LIBDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000425 @$(ECHO) Linking $(CONFIGURATION) Shared Library $(notdir $@)
Reid Spencer4d71b662004-10-22 21:01:56 +0000426 $(VERB) $(Link) -o $@ $(ObjectsLO)
427 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $@ $(LIBDIR)
Reid Spencer3a561f52004-10-23 20:04:14 +0000428
429clean-local::
Reid Spencere5487ba2004-10-24 07:53:21 +0000430ifneq ($(strip $(LIBNAME_LA)),)
Reid Spencer4d71b662004-10-22 21:01:56 +0000431 $(VERB) $(RM) -f $(LIBNAME_LA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000432endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000433
Reid Spencere5487ba2004-10-24 07:53:21 +0000434DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
435install-local:: install-shared-library
Reid Spencer4d71b662004-10-22 21:01:56 +0000436
Reid Spencere45ebfa2004-10-26 07:09:33 +0000437install-shared-library: $(libdir) $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000438
439$(DestSharedLib): $(LIBNAME_LA)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000440 @$(ECHO) Installing $(CONFIGURATION) Shared Library $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000441 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_LA) $(DestSharedLib)
442 $(VERB) $(LIBTOOL) --finish $(libdir)
443
444uninstall-local:: uninstall-shared-library
445
446uninstall-shared-library:
Reid Spencere45ebfa2004-10-26 07:09:33 +0000447 @$(ECHO) Uninstalling $(CONFIGURATION) Shared Library $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000448 $(VERB) $(RM) -f $(DestSharedLib)
449
Reid Spencer4d71b662004-10-22 21:01:56 +0000450endif
451
Reid Spencer3a561f52004-10-23 20:04:14 +0000452#---------------------------------------------------------
453# Bytecode Library Targets:
454# If the user asked for a bytecode library to be built
455# with the BYTECODE_LIBRARY variable, then we provide
456# targets for building them.
457#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000458ifdef BYTECODE_LIBRARY
459
460ifdef EXPORTED_SYMBOL_LIST
461 BCLinkLib += -Xlinker -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
462else
463 ifdef EXPORTED_SYMBOL_FILE
464 BCLinkLib += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
465 else
466 BCLinkLib += -Xlinker -disable-internalize
467 endif
468endif
469
Reid Spencer3a561f52004-10-23 20:04:14 +0000470all-local:: $(LIBNAME_BC)
Reid Spencer4d71b662004-10-22 21:01:56 +0000471
472$(LIBNAME_BC): $(BUILT_SOURCES) $(ObjectsBC) $(LIBDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000473 @$(ECHO) Linking $(CONFIGURATION) Bytecode Library $(notdir $@)
Reid Spencer4d71b662004-10-22 21:01:56 +0000474 $(VERB) $(BCLinkLib) -o $@ $(ObjectsBC)
475
Reid Spencer3a561f52004-10-23 20:04:14 +0000476clean-local::
Reid Spencere5487ba2004-10-24 07:53:21 +0000477ifneq ($(strip $(LIBNAME_BC)),)
Reid Spencer4d71b662004-10-22 21:01:56 +0000478 $(VERB) $(RM) -f $(LIBNAME_BC)
Reid Spencere5487ba2004-10-24 07:53:21 +0000479endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000480
Reid Spencere5487ba2004-10-24 07:53:21 +0000481DestBytecodeLib = $(bytecode_libdir)/lib$(LIBRARYNAME).bc
Reid Spencere45ebfa2004-10-26 07:09:33 +0000482
Reid Spencere5487ba2004-10-24 07:53:21 +0000483install-local:: install-bytecode-library
Chris Lattner481cc7c2003-08-15 02:18:35 +0000484
Reid Spencere45ebfa2004-10-26 07:09:33 +0000485install-bytecode-library: $(bytecode_libdir) $(DestBytecodeLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000486
487$(DestBytecodeLib): $(LIBNAME_BC) $(bytecode_libdir)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000488 @$(ECHO) Installing $(CONFIGURATION) Bytecode Library $(DestBytecodeLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000489 $(VERB) $(INSTALL) $< $@
490
491uninstall-local:: uninstall-bytecode-library
492
493uninstall-bytecode-library:
Reid Spencere45ebfa2004-10-26 07:09:33 +0000494 @$(ECHO) Uninstalling $(CONFIGURATION) Bytecode Library $(DestBytecodeLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000495 $(VERB) $(RM) -f $(DestBytecodeLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000496
497endif
Vikram S. Adve60f56062002-08-02 18:34:12 +0000498
Chris Lattner760da062003-03-14 20:25:22 +0000499# Does the library want a .o version built?
Chris Lattnere62dbe92002-07-23 17:56:16 +0000500ifndef DONT_BUILD_RELINKED
Reid Spencer3a561f52004-10-23 20:04:14 +0000501all-local:: $(LIBNAME_O)
Reid Spencer4d71b662004-10-22 21:01:56 +0000502
503$(LIBNAME_O): $(BUILT_SOURCES) $(ObjectsO) $(LIBDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000504 @$(ECHO) Linking $(CONFIGURATION) Object Library $(notdir $@)
Reid Spencer4d71b662004-10-22 21:01:56 +0000505 $(VERB) $(Relink) -o $@ $(ObjectsO)
506
Reid Spencer3a561f52004-10-23 20:04:14 +0000507clean-local::
Reid Spencere5487ba2004-10-24 07:53:21 +0000508ifneq ($(strip $(LIBNAME_O)),)
Reid Spencer4d71b662004-10-22 21:01:56 +0000509 $(VERB) $(RM) -f $(LIBNAME_O)
Reid Spencere5487ba2004-10-24 07:53:21 +0000510endif
511
512DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
513
514install-local:: install-relinked-library
515
Reid Spencere45ebfa2004-10-26 07:09:33 +0000516install-relinked-library: $(libdir) $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000517
518$(DestRelinkedLib): $(LIBNAME_O)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000519 @$(ECHO) Installing $(CONFIGURATION) Object Library $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000520 $(VERB) $(MKDIR) $(libdir)
521 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_O) $(DestRelinkedLib)
522
523uninstall-local:: uninstall-relinked-library
524
525uninstall-relinked-library:
Reid Spencere45ebfa2004-10-26 07:09:33 +0000526 @$(ECHO) Uninstalling $(CONFIGURATION) Object Library $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000527 $(VERB) $(RM) -f $(DestRelinkedLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000528
Chris Lattnere62dbe92002-07-23 17:56:16 +0000529endif
Chris Lattner760da062003-03-14 20:25:22 +0000530
531# Does the library want an archive version built?
Chris Lattnere62dbe92002-07-23 17:56:16 +0000532ifdef BUILD_ARCHIVE
Reid Spencer3a561f52004-10-23 20:04:14 +0000533all-local:: $(LIBNAME_A)
Chris Lattnere62dbe92002-07-23 17:56:16 +0000534
Reid Spencer4d71b662004-10-22 21:01:56 +0000535$(LIBNAME_A): $(BUILT_SOURCES) $(ObjectsO) $(LIBDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000536 @$(ECHO) Building $(CONFIGURATION) Archive Library $(notdir $@)
Reid Spencer37130d22004-10-04 07:05:07 +0000537 $(VERB)$(RM) -f $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000538 $(VERB) $(Archive) $@ $(ObjectsO)
539 $(VERB) $(Ranlib) $@
Vikram S. Adve41e78912002-09-20 14:03:13 +0000540
Reid Spencer3a561f52004-10-23 20:04:14 +0000541clean-local::
Reid Spencere5487ba2004-10-24 07:53:21 +0000542ifneq ($(strip $(LIBNAME_A)),)
Reid Spencer4d71b662004-10-22 21:01:56 +0000543 $(VERB) $(RM) -f $(LIBNAME_A)
Chris Lattner00950542001-06-06 20:29:01 +0000544endif
545
Reid Spencere5487ba2004-10-24 07:53:21 +0000546DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
547
548install-local:: install-archive-library
549
Reid Spencere45ebfa2004-10-26 07:09:33 +0000550install-archive-library: $(libdir) $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000551
552$(DestArchiveLib): $(LIBNAME_A)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000553 @$(ECHO) Installing $(CONFIGURATION) Archive Library $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000554 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_A) $(DestArchiveLib)
555
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000556uninstall-local:: uninstall-archive-library
Reid Spencere5487ba2004-10-24 07:53:21 +0000557
558uninstall-archive-library:
Reid Spencere45ebfa2004-10-26 07:09:33 +0000559 @$(ECHO) Uninstalling $(CONFIGURATION) Archive Library $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000560 $(VERB) $(RM) -f $(DestArchiveLib)
561
562endif
563
564# endif LIBRARYNAME
Reid Spencer4d71b662004-10-22 21:01:56 +0000565endif
566
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000567###############################################################################
568# Tool Build Rules: Build executable tool based on TOOLNAME option
569###############################################################################
570
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000571ifdef TOOLNAME
572
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000573#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000574# TOOLLINKOPTSB to pass options to the linker like library search path etc
575# Note that this is different from TOOLLINKOPTS, these options
576# are passed to the linker *before* the USEDLIBS options are passed.
577# e.g. usage TOOLLINKOPTSB = -L/home/xxx/lib
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000578#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000579ifdef TOOLLINKOPTSB
580Link += $(TOOLLINKOPTSB)
Reid Spencer37130d22004-10-04 07:05:07 +0000581endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000582
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000583# TOOLEXENAME - This is the output filenames to generate
Reid Spencer4d71b662004-10-22 21:01:56 +0000584TOOLEXENAME := $(TOOLDIR)/$(TOOLNAME)
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000585
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000586# LIBS_OPTIONS - Compute the options lines that add -llib1 -llib2, etc.
Reid Spencer4d71b662004-10-22 21:01:56 +0000587PROJ_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
588PROJ_LIBS_OPTIONS := $(patsubst %.o, $(LIBDIR)/%.o, $(PROJ_LIBS_OPTIONS))
589LLVM_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
590LLVM_LIBS_OPTIONS := $(patsubst %.o, $(LLVMLIBDIR)/%.o, $(LLVM_LIBS_OPTIONS))
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000591
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000592# USED_LIBS/LIBS_PATHS - Compute dependent library file paths
Reid Spencer4d71b662004-10-22 21:01:56 +0000593PROJ_USED_LIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
594LLVM_USED_LIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
595PROJ_LIBS_PATHS := $(addprefix $(LIBDIR)/,$(PROJ_USED_LIBS))
596LLVM_LIBS_PATHS := $(addprefix $(LLVMLIBDIR)/,$(LLVM_USED_LIBS))
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000597
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000598# Concatenate all the optoins
Reid Spencer4d71b662004-10-22 21:01:56 +0000599LINK_OPTS := $(TOOLLINKOPTS) $(PROJ_LIBS_OPTIONS) $(LLVM_LIBS_OPTIONS)
John Criswellfe785bd2004-09-16 14:11:25 +0000600
Reid Spencer4d71b662004-10-22 21:01:56 +0000601# Handle compression libraries automatically
602ifeq ($(HAVE_BZIP2),1)
603LIBS += -lbz2
604endif
605ifeq ($(HAVE_ZLIB),1)
606LIBS += -lz
607endif
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000608
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000609# Tell make that we need to rebuild subdirectories before we can link the tool.
610# This affects things like LLI which has library subdirectories.
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000611$(TOOLEXENAME): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000612
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000613all-local:: $(TOOLEXENAME)
John Criswell2a6530f2003-06-27 16:58:44 +0000614
Reid Spencer3a561f52004-10-23 20:04:14 +0000615clean-local::
Reid Spencere5487ba2004-10-24 07:53:21 +0000616ifneq ($(strip $(TOOLEXENAME)),)
Reid Spencer4d71b662004-10-22 21:01:56 +0000617 $(VERB) $(RM) -f $(TOOLEXENAME)
Reid Spencere5487ba2004-10-24 07:53:21 +0000618endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000619
Reid Spencer4d71b662004-10-22 21:01:56 +0000620$(TOOLEXENAME): $(BUILT_SOURCES) $(ObjectsO) $(PROJ_LIBS_PATHS) $(LLVM_LIBS_PATHS) $(TOOLDIR)/.dir
621 @$(ECHO) Linking $(CONFIGURATION) executable $(TOOLNAME) $(STRIP_WARN_MSG)
622 $(VERB) $(Link) -o $@ $(ObjectsO) $(PROJ_LIBS_OPTIONS) $(LLVM_LIBS_OPTIONS) $(LIBS)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000623 @$(ECHO) ======= Finished Linking $(CONFIGURATION) Executable $(TOOLNAME) $(STRIP_WARN_MSG)
Reid Spencere5487ba2004-10-24 07:53:21 +0000624
625DestTool = $(bindir)/$(TOOLNAME)
626
Reid Spencere45ebfa2004-10-26 07:09:33 +0000627install-local:: install-tool
628
629install-tool: $(bindir) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000630
631$(DestTool): $(TOOLEXENAME)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000632 @$(ECHO) Installing $(CONFIGURATION) $(DestTool)
633 $(VERB) $(INSTALL) $(TOOLEXENAME) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000634
Reid Spencere45ebfa2004-10-26 07:09:33 +0000635$(bindir):
636 $(VERB) $(MKDIR) $(bindir)
637
Reid Spencere5487ba2004-10-24 07:53:21 +0000638uninstall-local:: uninstall-tool
639
640uninstall-tool:
Reid Spencere45ebfa2004-10-26 07:09:33 +0000641 @$(ECHO) Uninstalling $(CONFIGURATION) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000642 $(VERB) $(RM) -f $(DestTool)
643
Reid Spencer4d71b662004-10-22 21:01:56 +0000644endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000645
Reid Spencer4d71b662004-10-22 21:01:56 +0000646ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve41e78912002-09-20 14:03:13 +0000647
Reid Spencer4d71b662004-10-22 21:01:56 +0000648# Create .lo files in the OBJDIR directory from the .cpp and .c files...
Reid Spencer3a561f52004-10-23 20:04:14 +0000649ifdef SHARED_LIBRARY
650
651$(OBJDIR)/%.lo $(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000652 @$(ECHO) "Compiling $*.cpp (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000653 $(VERB) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(OBJDIR)/$*.LACXXd $< -o $@ ; \
654 then $(MV) -f "$(OBJDIR)/$*.LACXXd" "$(OBJDIR)/$*.d"; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000655 else $(RM) -f "$(OBJDIR)/$*.LACXXd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000656
657$(OBJDIR)/%.lo $(OBJDIR)/%.o: %.c $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000658 @$(ECHO) "Compiling $*.c (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000659 $(VERB) if $(LTCompile.C) -MD -MT $@ -MP -MF $(OBJDIR)/$*.LACd $< -o $@ ; \
660 then $(MV) -f "$(OBJDIR)/$*.LACd" "$(OBJDIR)/$*.d"; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000661 else $(RM) -f "$(OBJDIR)/$*.LACd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000662
663else
Reid Spencer4d71b662004-10-22 21:01:56 +0000664
665$(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000666 @$(ECHO) "Compiling $*.cpp"
Reid Spencer3a561f52004-10-23 20:04:14 +0000667 $(VERB) if $(Compile.CXX) -MD -MT $@ -MP -MF $(OBJDIR)/$*.CXXd $< -o $@ ; \
668 then $(MV) -f "$(OBJDIR)/$*.CXXd" "$(OBJDIR)/$*.d"; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000669 else $(RM) -f "$(OBJDIR)/$*.CXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000670
671$(OBJDIR)/%.o: %.c $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000672 @$(ECHO) "Compiling $*.c"
Reid Spencer3a561f52004-10-23 20:04:14 +0000673 $(VERB) if $(Compile.C) -MD -MT $@ -MP -MF $(OBJDIR)/$*.Cd $< -o $@ ; \
674 then $(MV) -f "$(OBJDIR)/$*.Cd" "$(OBJDIR)/$*.d"; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000675 else $(RM) -f "$(OBJDIR)/$*.Cd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000676
677endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000678
679# Create .bc files in the OBJDIR directory from .cpp and .c files...
680$(OBJDIR)/%.bc: %.cpp $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000681 @$(ECHO) "Compiling $*.cpp (bytecode)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000682 $(VERB) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(OBJDIR)/$*.BCCXXd" $< -o $@ ; \
683 then $(MV) -f "$(OBJDIR)/$*.BCCXXd" "$(OBJDIR)/$*.d"; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000684 else $(RM) -f "$(OBJDIR)/$*.BCCXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000685
686$(OBJDIR)/%.bc: %.c $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000687 @$(ECHO) "Compiling $*.c (bytecode)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000688 $(VERB) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(OBJDIR)/$*.BCCd" $< -o $@ ; \
689 then $(MV) -f "$(OBJDIR)/$*.BCCd" "$(OBJDIR)/$*.d"; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000690 else $(RM) -f "$(OBJDIR)/$*.BCCd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000691
692else
693
Reid Spencer3a561f52004-10-23 20:04:14 +0000694ifdef SHARED_LIBRARY
695
696$(OBJDIR)/%.lo $(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000697 @$(ECHO) "Compiling $*.cpp (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000698 $(LTCompile.CXX) $< -o $@
699
700$(OBJDIR)/%.lo $(OBJDIR)/%.o: %.c $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000701 @$(ECHO) "Compiling $*.cpp (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000702 $(LTCompile.C) $< -o $@
703
704else
Reid Spencer4d71b662004-10-22 21:01:56 +0000705
706$(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000707 @$(ECHO) "Compiling $*.cpp"
Reid Spencer3a561f52004-10-23 20:04:14 +0000708 $(Compile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000709
710$(OBJDIR)/%.o: %.c $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000711 @$(ECHO) "Compiling $*.cpp"
Reid Spencer3a561f52004-10-23 20:04:14 +0000712 $(Compile.C) $< -o $@
713endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000714
715# Create .bc files in the OBJDIR directory from .cpp and .c files...
716$(OBJDIR)/%.bc: %.cpp $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000717 @$(ECHO) "Compiling $*.cpp (bytecode)"
Reid Spencer4d71b662004-10-22 21:01:56 +0000718 $(BCCompileCPP) $< -o $@
719
720$(OBJDIR)/%.bc: %.c $(OBJDIR)/.dir
Reid Spencere45ebfa2004-10-26 07:09:33 +0000721 @$(ECHO) "Compiling $*.c (bytecode)"
Reid Spencer4d71b662004-10-22 21:01:56 +0000722 $(BCCompileC) $< -o $@
Brian Gaeke44909cf2003-12-10 00:26:28 +0000723
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000724endif
725
Reid Spencer4d71b662004-10-22 21:01:56 +0000726$(OBJDIR)/%.bc: %.ll $(OBJDIR)/.dir $(LLVMAS)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000727 @$(ECHO) "Compiling $*.ll"
Chris Lattner481cc7c2003-08-15 02:18:35 +0000728 $(VERB) $(LLVMAS) $< -f -o $@
729
Reid Spencer4d71b662004-10-22 21:01:56 +0000730ifdef TARGET
731
Reid Spencerc64b2b32004-10-23 08:19:37 +0000732TDFILES := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
Reid Spencer4d71b662004-10-22 21:01:56 +0000733
734$(BUILT_SOURCES): $(TDFILES)
735
736%GenRegisterNames.inc : %.td
737 @echo "Building $(<F) register names with tblgen"
738 $(VERB) $(TableGen) -gen-register-enums -o $@ $<
739
740%GenRegisterInfo.h.inc : %.td
741 @echo "Building $(<F) register information header with tblgen"
742 $(VERB) $(TableGen) -gen-register-desc-header -o $@ $<
743
744%GenRegisterInfo.inc : %.td
745 @echo "Building $(<F) register info implementation with tblgen"
746 $(VERB) $(TableGen) -gen-register-desc -o $@ $<
747
748%GenInstrNames.inc : %.td
749 @echo "Building $(<F) instruction names with tblgen"
750 $(VERB) $(TableGen) -gen-instr-enums -o $@ $<
751
752%GenInstrInfo.inc : %.td
753 @echo "Building $(<F) instruction information with tblgen"
754 $(VERB) $(TableGen) -gen-instr-desc -o $@ $<
755
756%GenAsmWriter.inc : %.td
757 @echo "Building $(<F) assembly writer with tblgen"
758 $(VERB) $(TableGen) -gen-asm-writer -o $@ $<
759
760%GenATTAsmWriter.inc : %.td
761 @echo "Building $(<F) AT&T assembly writer with tblgen"
762 $(VERB) $(TableGen) -gen-asm-writer -o $@ $<
763
764%GenIntelAsmWriter.inc : %.td
765 @echo "Building $(<F) Intel assembly writer with tblgen"
766 $(VERB) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
767
768%GenInstrSelector.inc: %.td
769 @echo "Building $(<F) instruction selector with tblgen"
770 $(VERB) $(TableGen) -gen-instr-selector -o $@ $<
771
772%GenCodeEmitter.inc:: %.td
773 @echo "Building $(<F) code emitter with tblgen"
774 $(VERB) $(TableGen) -gen-emitter -o $@ $<
775
Reid Spencer3a561f52004-10-23 20:04:14 +0000776clean-local::
Reid Spencer4d71b662004-10-22 21:01:56 +0000777 $(VERB) rm -f *.inc
778
779endif
Chris Lattner481cc7c2003-08-15 02:18:35 +0000780
Chris Lattnere8996782003-01-16 22:44:19 +0000781#
782# Rules for building lex/yacc files
783#
Reid Spencer3a561f52004-10-23 20:04:14 +0000784LEX_FILES = $(filter %.l, $(SOURCES))
Chris Lattnere8996782003-01-16 22:44:19 +0000785LEX_OUTPUT = $(LEX_FILES:%.l=%.cpp)
Reid Spencer3a561f52004-10-23 20:04:14 +0000786YACC_FILES = $(filter %.y, $(SOURCES))
Chris Lattnere8996782003-01-16 22:44:19 +0000787YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output)
788.PRECIOUS: $(LEX_OUTPUT) $(YACC_OUTPUT)
789
Chris Lattner00950542001-06-06 20:29:01 +0000790# Create a .cpp source file from a flex input file... this uses sed to cut down
791# on the warnings emited by GCC...
Chris Lattner6d131b42003-01-23 16:33:10 +0000792#
793# The last line is a gross hack to work around flex aparently not being able to
794# resize the buffer on a large token input. Currently, for uninitialized string
795# buffers in LLVM we can generate very long tokens, so this is a hack around it.
Chris Lattnerb7dc2b92003-08-15 20:00:47 +0000796# FIXME. (f.e. char Buffer[10000] )
Chris Lattner6d131b42003-01-23 16:33:10 +0000797#
Chris Lattner00950542001-06-06 20:29:01 +0000798%.cpp: %.l
Reid Spencer4d71b662004-10-22 21:01:56 +0000799 @$(ECHO) Flexing $<
Chris Lattner7bb107d2003-08-04 19:48:10 +0000800 $(VERB) $(FLEX) -t $< | \
Reid Spencer4d71b662004-10-22 21:01:56 +0000801 $(SED) '/^find_rule/d' | \
802 $(SED) 's/void yyunput/inline void yyunput/' | \
803 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
804 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
805 > $@.tmp
806 $(VERB) cmp -s $@ $@.tmp > /dev/null || $(MV) -f $@.tmp $@
Chris Lattnera328f882003-08-04 19:47:06 +0000807 @# remove the output of flex if it didn't get moved over...
808 @rm -f $@.tmp
Chris Lattner00950542001-06-06 20:29:01 +0000809
810# Rule for building the bison parsers...
Chris Lattner694c5df2003-05-15 21:28:55 +0000811%.c: %.y # Cancel built-in rules for yacc
812%.h: %.y # Cancel built-in rules for yacc
Chris Lattner00950542001-06-06 20:29:01 +0000813%.cpp %.h : %.y
Reid Spencer4d71b662004-10-22 21:01:56 +0000814 @$(ECHO) "Bisoning $*.y"
John Criswell410d1b52003-09-09 20:57:03 +0000815 $(VERB) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000816 $(VERB) cmp -s $*.tab.c $*.cpp > /dev/null || $(MV) -f $*.tab.c $*.cpp
817 $(VERB) cmp -s $*.tab.h $*.h > /dev/null || $(MV) -f $*.tab.h $*.h
Chris Lattnera328f882003-08-04 19:47:06 +0000818 @# If the files were not updated, don't leave them lying around...
819 @rm -f $*.tab.c $*.tab.h
Chris Lattner00950542001-06-06 20:29:01 +0000820
821# To create the directories...
822%/.dir:
Reid Spencer4d71b662004-10-22 21:01:56 +0000823 $(VERB) $(MKDIR) $* > /dev/null
John Criswell7a73b802003-06-30 21:59:07 +0000824 @$(DATE) > $@
Chris Lattner00950542001-06-06 20:29:01 +0000825
Reid Spencer4d71b662004-10-22 21:01:56 +0000826.PRECIOUS: $(OBJDIR)/.dir $(LIBDIR)/.dir $(TOOLDIR)/.dir $(LLVMLIBDIR)/.dir
827.PRECIOUS: $(LLVMTOOLDIR)/.dir
828
Chris Lattner30440c62003-01-16 21:06:18 +0000829# To create postscript files from dot files...
John Criswelle0f9ac62003-10-02 19:02:02 +0000830ifneq ($(DOT),false)
Chris Lattner30440c62003-01-16 21:06:18 +0000831%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +0000832 $(DOT) -Tps < $< > $@
John Criswell7a73b802003-06-30 21:59:07 +0000833else
834%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +0000835 $(ECHO) "Cannot build $@: The program dot is not installed"
John Criswell7a73b802003-06-30 21:59:07 +0000836endif
Chris Lattner30440c62003-01-16 21:06:18 +0000837
John Criswell7f336952003-09-06 14:44:17 +0000838#
839# This rules ensures that header files that are removed still have a rule for
840# which they can be "generated." This allows make to ignore them and
841# reproduce the dependency lists.
842#
John Criswell4b6e5d12003-09-18 18:37:08 +0000843%.h:: ;
John Criswell7f336952003-09-06 14:44:17 +0000844
Chris Lattner172b6482002-09-22 02:47:15 +0000845# 'make clean' nukes the tree
Reid Spencer3a561f52004-10-23 20:04:14 +0000846clean-local::
Reid Spencere5487ba2004-10-24 07:53:21 +0000847ifneq ($(strip $(OBJDIR)),)
Reid Spencer83cbcb92004-10-24 02:26:09 +0000848 $(VERB) $(RM) -rf $(OBJDIR)
Reid Spencere5487ba2004-10-24 07:53:21 +0000849endif
Brian Gaeke9d3cd402004-01-21 19:53:11 +0000850 $(VERB) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
851ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
852 $(VERB) $(RM) -f *$(SHLIBEXT)
853endif
Reid Spencere5487ba2004-10-24 07:53:21 +0000854ifneq ($(strip $(LEX_OUTPUT)),)
855 $(VERB) $(RM) -f $(LEX_OUTPUT)
856endif
857ifneq ($(strip $(YACC_OUTPUT)),)
858 $(VERB) $(RM) -f $(YACC_OUTPUT)
859endif
John Criswell7a73b802003-06-30 21:59:07 +0000860
Reid Spencer3a561f52004-10-23 20:04:14 +0000861###############################################################################
862# DEPENDENCIES: Include the dependency files if we should
863###############################################################################
Chris Lattner33ad24a2003-08-22 14:10:16 +0000864ifndef DISABLE_AUTO_DEPENDENCIES
865
Reid Spencer3a561f52004-10-23 20:04:14 +0000866# If its not one of the cleaning targets
867ifneq ($strip($(filter-out clean clean-local dist-clean, $(MAKECMDGOALS))),)
Reid Spencer4d71b662004-10-22 21:01:56 +0000868
Reid Spencer3a561f52004-10-23 20:04:14 +0000869# Get the list of dependency files
870DependFiles := $(basename $(filter %.cpp %.c %.cc, $(SOURCES)))
871DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(CONFIGURATION)/%.d,$(DependFiles))
Misha Brukman4f7a8cf2003-11-09 21:36:19 +0000872
Reid Spencer3a561f52004-10-23 20:04:14 +0000873-include /dev/null $(DependFiles)
874
John Criswelld741bcf2003-08-12 18:51:51 +0000875endif
Chris Lattner1ddb6b62003-08-18 17:27:40 +0000876
Chris Lattner33ad24a2003-08-22 14:10:16 +0000877endif # ifndef DISABLE_AUTO_DEPENDENCIES
Reid Spencer4d71b662004-10-22 21:01:56 +0000878
Reid Spencer151f8ba2004-10-25 08:27:37 +0000879###############################################################################
880# Handle construction of a distribution tarball
881###############################################################################
882
883.PHONY: dist dist-chck dist-clean distdir dist-gzip dist-bzip2 dist-zip
884
Reid Spencere45ebfa2004-10-26 07:09:33 +0000885#------------------------------------------------------------------------
886# Define distribution related variables
887#------------------------------------------------------------------------
Reid Spencer151f8ba2004-10-25 08:27:37 +0000888DistName := $(LLVM_TARBALL_NAME)
889DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000890TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000891DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
892DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
893DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
894DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
895 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencere45ebfa2004-10-26 07:09:33 +0000896 Makefile.config.in configure autoconf
897DistOther := $(notdir $(wildcard \
898 $(BUILD_SRC_DIR)/*.h \
899 $(BUILD_SRC_DIR)/*.td \
900 $(BUILD_SRC_DIR)/*.def \
901 $(BUILD_SRC_DIR)/*.ll \
902 $(BUILD_SRC_DIR)/*.in))
903DistSources := $(SOURCES) $(EXTRA_DIST)
904DistSubDirs := $(SUBDIRS)
905DistFiles := $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000906
Reid Spencere45ebfa2004-10-26 07:09:33 +0000907
908#------------------------------------------------------------------------
909# We MUST build distribution with OBJ_DIR != SRC_DIR
910#------------------------------------------------------------------------
911ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
912dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
913 @$(ECHO) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
914
915DistCheckTop :=
916else
917
918DistCheckTop := check
919#------------------------------------------------------------------------
920# Prevent catastrophic remove
921#------------------------------------------------------------------------
922ifeq ($(LLVM_TARBALL_NAME),)
923$(error LLVM_TARBALL_NAME is empty. Please rerun configure)
924endif
925
926#------------------------------------------------------------------------
927# Prevent attempt to run dist targets from anywhere but the top level
928#------------------------------------------------------------------------
929ifneq ($(LEVEL),.)
930
931dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
932 @$(ECHO) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
933
934else
935
936#------------------------------------------------------------------------
937# Provide the top level targets
938#------------------------------------------------------------------------
939
940dist-gzip: $(DistTarGZip)
941
942$(DistTarGZip) : distdir
943 @$(ECHO) Packing gzipped distribution tar file.
944 $(VERB) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | gzip -c > "$(DistTarGZip)"
945
946dist-bzip2: $(DistTarBZ2)
947
948$(DistTarBZ2) : distdir
949 @$(ECHO) Packing bzipped distribution tar file.
950 $(VERB) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | $(BZIP2) -c >$(DistTarBZ2)
951
952dist-zip: $(DistZip)
953
954$(DistZip) : distdir
955 @$(ECHO) Packing zipped distribution file.
956 $(VERB) rm -f $(DistZip)
957 $(VERB) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
958
959dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
960 @$(ECHO) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
961
962DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
963
Reid Spencer9411c642004-10-26 22:26:33 +0000964dist-check:: $(DistCheckTop) $(DistTarGZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000965 @$(ECHO) Checking distribution tar file.
966 $(VERB) if test -d $(DistCheckDir) ; then \
967 $(RM) -rf $(DistCheckDir) ; \
968 fi
969 $(VERB) $(MKDIR) $(DistCheckDir)
970 $(VERB) cd $(DistCheckDir) && \
971 $(MKDIR) $(DistCheckDir)/build && \
972 $(MKDIR) $(DistCheckDir)/install && \
973 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
974 cd build && \
975 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
976 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
977 $(MAKE) check && \
978 $(MAKE) install && \
979 $(MAKE) uninstall && \
980 $(MAKE) dist && \
981 $(MAKE) clean && \
982 $(MAKE) dist-clean && \
983 $(ECHO) ===== $(DistTarGZip) Ready For Distribution =====
984
985dist-clean::
986 @$(ECHO) Cleaning distribution files
987 $(VERB) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) $(DistCheckDir)
988
989endif
990
991#------------------------------------------------------------------------
992# Provide the recursive distdir target for building the distribution directory
993#------------------------------------------------------------------------
Reid Spencer9411c642004-10-26 22:26:33 +0000994distdir : $(DistSources)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000995 @$(ECHO) Building Distribution Directory $(DistDir)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000996 $(VERB) if test "$(DistDir)" = "$(TopDistDir)" ; then \
997 if test -d "$(DistDir)" ; then \
998 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
999 exit 1 ; \
1000 fi ; \
1001 echo Removing $(DistDir) ; \
1002 $(RM) -rf $(DistDir); \
1003 fi
Reid Spencer151f8ba2004-10-25 08:27:37 +00001004 $(VERB) $(MKDIR) $(DistDir)
1005 $(VERB) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
1006 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1007 for file in $(DistFiles) ; do \
1008 case "$$file" in \
1009 $(BUILD_SRC_DIR)/*) file=`echo "$$file" | sed "s#^$$srcdirstrip/##"`;; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001010 $(BUILD_SRC_ROOT)/*) file=`echo "$$file" | sed "s#^$$srcrootstrip/#$(BUILD_OBJ_ROOT)/#"`;; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001011 esac; \
1012 if test -f "$$file" || test -d "$$file" ; then \
1013 from_dir=. ; \
1014 else \
1015 from_dir=$(BUILD_SRC_DIR); \
1016 fi; \
1017 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'`; \
1018 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1019 to_dir="$(DistDir)/$$dir"; \
1020 $(MKDIR) "$$to_dir" ; \
1021 else \
1022 to_dir="$(DistDir)"; \
1023 fi; \
1024 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1025 if test -n "$$mid_dir" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001026 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001027 fi ; \
1028 if test -d "$$from_dir/$$file"; then \
1029 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1030 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1031 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1032 fi; \
1033 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1034 elif test -f "$$from_dir/$$file" ; then \
1035 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1036 elif test -L "$$from_dir/$$file" ; then \
1037 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1038 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1039 $(ECHO) "===== WARNING: Distribution Source $$from_dir/$$file Not Found!" ; \
1040 elif test "$(VERB)" != '@' ; then \
1041 $(ECHO) "Skipping non-existent $$from_dir/$$file" ; \
1042 fi; \
1043 done
Reid Spencere45ebfa2004-10-26 07:09:33 +00001044 $(VERB) for subdir in $(DistSubDirs) ; do \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001045 if test "$$subdir" \!= "." ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001046 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001047 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1048 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001049 fi; \
1050 done
Reid Spencere45ebfa2004-10-26 07:09:33 +00001051 $(VERB) $(MAKE) DistDir="$(DistDir)" dist-hook || exit 1
Reid Spencer151f8ba2004-10-25 08:27:37 +00001052 -$(VERB) find $(DistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
1053 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
1054 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
1055 ! -type d ! -perm -444 -exec $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1056 || chmod -R a+r $(DistDir)
1057
1058dist-hook::
1059
1060
Reid Spencere53e3972004-10-22 23:06:30 +00001061endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001062
1063###############################################################################
Reid Spencere5487ba2004-10-24 07:53:21 +00001064# TOP LEVEL - targets only to apply at the top level directory
1065###############################################################################
1066
1067ifeq ($(LEVEL),.)
1068
1069#------------------------------------------------------------------------
Reid Spencere5487ba2004-10-24 07:53:21 +00001070# Install support for project's include files:
1071#------------------------------------------------------------------------
1072install-local::
1073 @$(ECHO) Installing include files
1074 $(VERB) $(MKDIR) $(includedir)
1075 $(VERB) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1076 cd $(BUILD_SRC_ROOT)/include && \
1077 find . -path '*/Internal' -prune -o '(' -type f \
1078 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1079 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1080 fi
1081
1082uninstall-local::
1083 @$(ECHO) Uninstalling include files
1084 $(VERB) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1085 cd $(BUILD_SRC_ROOT)/include && \
1086 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1087 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1088 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1089 fi
1090
1091#------------------------------------------------------------------------
1092# Build tags database for Emacs/Xemacs:
1093#------------------------------------------------------------------------
Reid Spencer151f8ba2004-10-25 08:27:37 +00001094tags:: TAGS
Reid Spencere5487ba2004-10-24 07:53:21 +00001095
Reid Spencer151f8ba2004-10-25 08:27:37 +00001096TAGS:
Reid Spencere5487ba2004-10-24 07:53:21 +00001097 find include lib tools examples -name '*.cpp' -o -name '*.h' | $(ETAGS) $(ETAGSFLAGS) -
1098
Reid Spencere5487ba2004-10-24 07:53:21 +00001099endif
1100
1101###############################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +00001102# MISCELLANEOUS - utility targets
1103###############################################################################
1104
1105#------------------------------------------------------------------------
1106# Print out the directories used for building
Reid Spencer3a561f52004-10-23 20:04:14 +00001107printvars::
Reid Spencer9411c642004-10-26 22:26:33 +00001108 @$(ECHO) "CONFIGURATION : " $(CONFIGURATION)
Reid Spencer4d71b662004-10-22 21:01:56 +00001109 @$(ECHO) "BUILD_SRC_ROOT: " $(BUILD_SRC_ROOT)
1110 @$(ECHO) "BUILD_SRC_DIR : " $(BUILD_SRC_DIR)
1111 @$(ECHO) "BUILD_OBJ_ROOT: " $(BUILD_OBJ_ROOT)
1112 @$(ECHO) "BUILD_OBJ_DIR : " $(BUILD_OBJ_DIR)
1113 @$(ECHO) "LLVM_SRC_ROOT : " $(LLVM_SRC_ROOT)
1114 @$(ECHO) "LLVM_OBJ_ROOT : " $(LLVM_OBJ_ROOT)
Reid Spencer9411c642004-10-26 22:26:33 +00001115 @$(ECHO) "libdir : " $(libdir)
1116 @$(ECHO) "bindir : " $(bindir)
1117 @$(ECHO) "sysconfdir : " $(sysconfdir)
1118 @$(ECHO) "bytecode_libdir : " $(bytecode_libdir)
1119 @$(ECHO) "USER_TARGETS : " $(USER_TARGETS)
1120 @$(ECHO) "OBJMKFILES: $(OBJMKFILES)"
1121 @$(ECHO) "SRCMKFILES: $(SRCMKFILES)"
Reid Spencer4d71b662004-10-22 21:01:56 +00001122 @$(ECHO) "OBJDIR: " $(OBJDIR)
1123 @$(ECHO) "LIBDIR: " $(LIBDIR)
1124 @$(ECHO) "TOOLDIR: " $(TOOLDIR)
1125 @$(ECHO) "TDFILES:" '$(TDFILES)'
Reid Spencer3a561f52004-10-23 20:04:14 +00001126 @$(ECHO) "Compile.CXX: " '$(Compile.CXX)'
1127 @$(ECHO) "Compile.C: " '$(Compile.C)'
Reid Spencere5487ba2004-10-24 07:53:21 +00001128