blob: 68d870b7a97f794da09d26659cd9c070fb92b9eb [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 Spencer12a3a052004-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 Spencer81cd0492004-10-23 20:04:14 +000037
Reid Spencer77a46d22004-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 Spencer81cd0492004-10-23 20:04:14 +000048#--------------------------------------------------------------------
49# Mark all of these targets as phony to avoid implicit rule search
50#--------------------------------------------------------------------
Reid Spencer100080c2004-10-25 08:27:37 +000051.PHONY: $(USER_TARGETS) $(INTERNAL_TARGETS)
Reid Spencer81cd0492004-10-23 20:04:14 +000052
53#--------------------------------------------------------------------
Reid Spencer77a46d22004-10-26 22:26:33 +000054# Make sure all the user-target rules are double colon rules and
55# they are defined first.
Reid Spencer81cd0492004-10-23 20:04:14 +000056#--------------------------------------------------------------------
57
Reid Spencer77a46d22004-10-26 22:26:33 +000058$(USER_TARGETS)::
Reid Spencer100080c2004-10-25 08:27:37 +000059
Reid Spencer77a46d22004-10-26 22:26:33 +000060################################################################################
61# PRECONDITIONS: that which must be built/checked first
62################################################################################
63
Reid Spencerd94bb332004-10-26 23:10:00 +000064SRCMKFILES := $(filter-out Makefile.rules %.in,\
65 $(wildcard $(BUILD_SRC_DIR)/Makefile.*))
Reid Spencer77a46d22004-10-26 22:26:33 +000066OBJMKFILES := $(subst $(BUILD_SRC_DIR),$(BUILD_OBJ_DIR),$(SRCMKFILES))
67CONFIGURE := $(LLVM_SRC_ROOT)/configure
68CONFIG_STATUS := $(LLVM_OBJ_ROOT)/config.status
69MAKE_CONFIG_IN:= $(LLVM_SRC_ROOT)/Makefile.config.in
70MAKE_CONFIG := $(LLVM_OBJ_ROOT)/Makefile.config
71PRECONDITIONS := $(CONFIG_STATUS) $(MAKE_CONFIG) $(OBJMKFILES)
72
73preconditions : $(PRECONDITIONS)
74
75#------------------------------------------------------------------------
76# Make sure the BUILT_SOURCES are built first
77#------------------------------------------------------------------------
78$(filter-out clean clean-local,USER_TARGETS):: $(BUILT_SOURCES)
79
80clean-local::
81ifneq ($(strip $(BUILT_SOURCES)),)
82 $(VERB) $(RM) -f $(BUILT_SOURCES)
83endif
84
85#------------------------------------------------------------------------
86# Make sure we're not using a stale configuration
87#------------------------------------------------------------------------
88.PRECIOUS: $(CONFIG_STATUS)
89$(CONFIG_STATUS): $(CONFIGURE)
90 @$(ECHO) Reconfiguring with $<
91 $(VERB) $(CONFIG_STATUS) --recheck $(CONFIGUREFLAGS)
92
93#------------------------------------------------------------------------
94# Make sure the configuration makefile is up to date
95#------------------------------------------------------------------------
96$(MAKE_CONFIG): $(MAKE_CONFIG_IN) $(CONFIG_STATUS)
97 @$(ECHO) Regenerating $@
98 $(VERB) cd $(LLVM_OBJ_ROOT) ; $(CONFIG_STATUS) Makefile.config
99
100#------------------------------------------------------------------------
101# If the Makefile in the source tree has been updated, copy it over into the
102# build tree. But, only do this if the source and object makefiles differ
103#------------------------------------------------------------------------
104ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
105
106$(BUILD_OBJ_DIR)/Makefile : $(BUILD_SRC_DIR)/Makefile
107 @$(ECHO) "Updating Makefile"
108 $(VERB) $(MKDIR) $(@D)
109 $(VERB) cp -f $< $@
Reid Spencer77a46d22004-10-26 22:26:33 +0000110
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.
Reid Spencer77a46d22004-10-26 22:26:33 +0000114$(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
Reid Spencerd94bb332004-10-26 23:10:00 +0000115 @case '$?' in \
116 *Makefile.rules) ;; \
117 *.in) ;; \
118 *) $(ECHO) "Updating $(@F)" ; \
119 $(MKDIR) $(@D) ; \
120 cp -f $< $@ ;; \
121 esac
122
Reid Spencer77a46d22004-10-26 22:26:33 +0000123endif
124
125#------------------------------------------------------------------------
126# Set up the basic dependencies
127#------------------------------------------------------------------------
128$(USER_TARGETS):: $(PRECONDITIONS)
129
130all:: all-local
Reid Spencer81cd0492004-10-23 20:04:14 +0000131check:: check-local
132clean:: clean-local
Reid Spencer77a46d22004-10-26 22:26:33 +0000133install:: install-local
134uninstall:: uninstall-local
135check-local:: all-local
136install-local:: all-local
Reid Spencer81cd0492004-10-23 20:04:14 +0000137
138###############################################################################
139# VARIABLES: Set up various variables based on configuration data
140###############################################################################
141
142#--------------------------------------------------------------------
143# Variables derived from configuration we are building
Chris Lattner2f7c9632001-06-06 20:29:01 +0000144#--------------------------------------------------------------------
145
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000146ifdef ENABLE_PROFILING
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000147 CONFIGURATION := Profile
Reid Spencerf206bd72004-10-22 21:01:56 +0000148 CXXFLAGS += -O3 -DNDEBUG -felide-constructors -finline-functions -pg
149 CFLAGS += -O3 -DNDEBUG -pg
150 LDFLAGS += -O3 -DNDEBUG -pg
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000151else
152 ifdef ENABLE_OPTIMIZED
153 CONFIGURATION := Release
Reid Spencerf206bd72004-10-22 21:01:56 +0000154 CXXFLAGS += -O3 -DNDEBUG -finline-functions -felide-constructors -fomit-frame-pointer
155 CFLAGS += -O3 -DNDEBUG -fomit-frame-pointer
156 LDFLAGS += -O3 -DNDEBUG
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000157 else
158 CONFIGURATION := Debug
Reid Spencerf206bd72004-10-22 21:01:56 +0000159 CXXFLAGS += -g -D_DEBUG
160 CFLAGS += -g -D_DEBUG
161 LDFLAGS += -g -D_DEBUG
162 KEEP_SYMBOLS := 1
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000163 endif
164endif
165
Reid Spencerf206bd72004-10-22 21:01:56 +0000166ARFLAGS := cru
Reid Spencer81cd0492004-10-23 20:04:14 +0000167
168#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000169# Directory locations
Reid Spencer81cd0492004-10-23 20:04:14 +0000170#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000171OBJDIR := $(BUILD_OBJ_DIR)/$(CONFIGURATION)
172LIBDIR := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
173TOOLDIR := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
174LLVMLIBDIR := $(LLVM_OBJ_ROOT)/lib/$(CONFIGURATION)
175LLVMTOOLDIR := $(LLVM_OBJ_ROOT)/tools/$(CONFIGURATION)
John Criswell3ef61af2003-06-30 21:59:07 +0000176
Reid Spencer81cd0492004-10-23 20:04:14 +0000177#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000178# Full Paths To Compiled Tools and Utilities
Reid Spencer81cd0492004-10-23 20:04:14 +0000179#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000180LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
181LLVMAS := $(LLVMTOOLDIR)/llvm-as$(EXEEXT)
182BURG := $(LLVMTOOLDIR)/burg$(EXEEXT)
183TBLGEN := $(LLVMTOOLDIR)/tblgen$(EXEEXT)
184GCCLD := $(LLVMTOOLDIR)/gccld$(EXEEXT)
185LLVMGCC := PATH=$(LLVMTOOLDIR):$(PATH) $(LLVMGCCDIR)/bin/gcc
186LLVMGXX := PATH=$(LLVMTOOLDIR):$(PATH) $(LLVMGCCDIR)/bin/g++
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000187
Reid Spencerf206bd72004-10-22 21:01:56 +0000188# Need a better way to compute this.
189LLVMGCCLIBDIR := $(dir $(shell $(LLVMGCC) -print-file-name=libgcc.a))/
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000190
Reid Spencer81cd0492004-10-23 20:04:14 +0000191#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000192# Adjust to user's request
Reid Spencer81cd0492004-10-23 20:04:14 +0000193#--------------------------------------------------------------------
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000194
Reid Spencer81cd0492004-10-23 20:04:14 +0000195# Adjust LIBTOOL options for shared libraries, or not.
John Criswell3601f372003-07-31 20:58:51 +0000196ifndef SHARED_LIBRARY
Reid Spencerf206bd72004-10-22 21:01:56 +0000197 LIBTOOL += --tag=disable-shared
198else
199 LDFLAGS += -rpath $(LIBDIR)
John Criswell3601f372003-07-31 20:58:51 +0000200endif
201
Reid Spencer81cd0492004-10-23 20:04:14 +0000202# Adjust settings for verbose mode
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000203ifndef VERBOSE
Reid Spencerf206bd72004-10-22 21:01:56 +0000204 VERB := @
205 LIBTOOL += --silent
206 AR += >/dev/null 2>/dev/null
Reid Spencer100080c2004-10-25 08:27:37 +0000207 CONFIGUREFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
208else
209 CONFIGUREFLAGS :=
Misha Brukman1326a7c2002-09-12 16:05:39 +0000210endif
211
Vikram S. Adved141c282002-09-18 11:55:13 +0000212# By default, strip symbol information from executable
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000213ifndef KEEP_SYMBOLS
Reid Spencerf206bd72004-10-22 21:01:56 +0000214 STRIP = $(PLATFORMSTRIPOPTS)
215 STRIP_WARN_MSG = "(without symbols)"
Vikram S. Adved141c282002-09-18 11:55:13 +0000216endif
217
Reid Spencer81cd0492004-10-23 20:04:14 +0000218# Adjust linker flags for building an executable
Reid Spencerf206bd72004-10-22 21:01:56 +0000219ifdef TOOLNAME
220 LDFLAGS += -rpath $(TOOLDIR) -export-dynamic $(TOOLLINKOPTS)
221endif
Chris Lattner2f7c9632001-06-06 20:29:01 +0000222
Reid Spencer81cd0492004-10-23 20:04:14 +0000223# Use TOOLLINKOPTSB to pass options to the linker like library search
224# path etc.
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000225# Note that this is different from TOOLLINKOPTS, these options
226# are passed to the linker *before* the USEDLIBS options are passed.
227# e.g. usage TOOLLINKOPTSB = -L/home/xxx/lib
228ifdef TOOLLINKOPTSB
Reid Spencerf206bd72004-10-22 21:01:56 +0000229LDFLAGS += $(TOOLLINKOPTSB)
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000230endif
231
Reid Spencer81cd0492004-10-23 20:04:14 +0000232#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000233# Options To Invoke Tools
Reid Spencer81cd0492004-10-23 20:04:14 +0000234#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000235
236CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
237
Reid Spencer81cd0492004-10-23 20:04:14 +0000238LDFLAGS += -L$(LIBDIR) -L$(LLVMLIBDIR)
Reid Spencerf206bd72004-10-22 21:01:56 +0000239CPPFLAGS += -I$(BUILD_OBJ_DIR) \
Reid Spencer100080c2004-10-25 08:27:37 +0000240 -I$(BUILD_SRC_DIR) \
241 -I$(BUILD_SRC_ROOT)/include \
242 -I$(BUILD_OBJ_ROOT)/include \
243 -I$(LLVM_OBJ_ROOT)/include \
244 -I$(LLVM_SRC_ROOT)/include \
245 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
Reid Spencerf206bd72004-10-22 21:01:56 +0000246
Reid Spencer81cd0492004-10-23 20:04:14 +0000247Compile.C = $(CC) $(CPPFLAGS) $(CompileCommonOpts) -c $(CFLAGS)
248Compile.CXX = $(CXX) $(CPPFLAGS) $(CompileCommonOpts) $(CXXFLAGS) -c
249LTCompile.C = $(LIBTOOL) --mode=compile $(Compile.C)
250LTCompile.CXX = $(LIBTOOL) --tag=CXX --mode=compile $(Compile.CXX)
251BCCompile.CXX = $(LLVMGXX) $(CPPFLAGS) $(CompileCommonOpts) $(CXXFLAGS) -c
252BCCompile.C = $(LLVMGCC) $(CPPFLAGS) $(CompileCommonOpts) $(CFLAGS) -c
253Link = $(LIBTOOL) --tag=CXX --mode=link $(CXX) $(CPPFLAGS) \
Reid Spencer100080c2004-10-25 08:27:37 +0000254 $(CompileCommonOpts) $(LDFLAGS) $(STRIP)
Reid Spencer81cd0492004-10-23 20:04:14 +0000255Relink = $(LIBTOOL) --tag=CXX --mode=link $(CXX)
256BCLinkLib = $(LLVMGCC) -shared -nostdlib
257Burg = $(BURG) -I $(BUILD_SRC_DIR)
258TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
259Archive = $(AR) $(ARFLAGS)
Reid Spencerf206bd72004-10-22 21:01:56 +0000260ifdef RANLIB
Reid Spencer81cd0492004-10-23 20:04:14 +0000261Ranlib = $(RANLIB)
Reid Spencerf206bd72004-10-22 21:01:56 +0000262else
Reid Spencer81cd0492004-10-23 20:04:14 +0000263Ranlib = ranlib
John Criswell3ef61af2003-06-30 21:59:07 +0000264endif
265
Chris Lattner2f7c9632001-06-06 20:29:01 +0000266#----------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000267# Get the list of source files
268#----------------------------------------------------------
269ifndef SOURCES
270SOURCES := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
Reid Spencer100080c2004-10-25 08:27:37 +0000271 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
272 $(BUILD_SRC_DIR)/*.l))
Reid Spencerf206bd72004-10-22 21:01:56 +0000273endif
274
275ifdef BUILT_SOURCES
Reid Spencer81cd0492004-10-23 20:04:14 +0000276SOURCES += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
Vikram S. Adve53738842002-10-14 16:40:04 +0000277endif
Vikram S. Advefe346892001-07-15 13:16:47 +0000278
Reid Spencer81cd0492004-10-23 20:04:14 +0000279#----------------------------------------------------------
280# Types of objects that can be built from sources
281#----------------------------------------------------------
282BASENAME_SOURCES := $(sort $(basename $(SOURCES)))
283ObjectsO := $(BASENAME_SOURCES:%=$(OBJDIR)/%.o)
284ObjectsLO := $(BASENAME_SOURCES:%=$(OBJDIR)/%.lo)
285ObjectsBC := $(BASENAME_SOURCES:%=$(OBJDIR)/%.bc)
286
287
288###############################################################################
289# DIRECTORIES: Handle recursive descent of directory structure
290###############################################################################
John Criswell3601f372003-07-31 20:58:51 +0000291
Chris Lattner2f7c9632001-06-06 20:29:01 +0000292#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000293# Handle the DIRS options for sequential construction
Chris Lattner2f7c9632001-06-06 20:29:01 +0000294#---------------------------------------------------------
295
Reid Spencer100080c2004-10-25 08:27:37 +0000296SUBDIRS :=
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000297ifdef DIRS
Reid Spencer100080c2004-10-25 08:27:37 +0000298SUBDIRS += $(DIRS)
Reid Spencer81cd0492004-10-23 20:04:14 +0000299$(RECURSIVE_TARGETS)::
Reid Spencerf206bd72004-10-22 21:01:56 +0000300 $(VERB) for dir in $(DIRS); do \
301 if [ ! -f $$dir/Makefile ]; then \
302 $(MKDIR) $$dir; \
303 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
304 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +0000305 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattner539a23c2002-09-17 23:35:02 +0000306 done
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000307endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000308
Reid Spencer81cd0492004-10-23 20:04:14 +0000309#---------------------------------------------------------
310# Handle the EXPERIMENTAL_DIRS options ensuring success
311# after each directory is built.
312#---------------------------------------------------------
313ifdef EXPERIMENTAL_DIRS
314$(RECURSIVE_TARGETS)::
315 $(VERB) for dir in $(EXPERIMENTAL_DIRS); do \
316 if [ ! -f $$dir/Makefile ]; then \
317 $(MKDIR) $$dir; \
318 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
319 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +0000320 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000321 done
322endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000323
Reid Spencer81cd0492004-10-23 20:04:14 +0000324#---------------------------------------------------------
325# Handle the PARALLEL_DIRS options for parallel construction
326#---------------------------------------------------------
327ifdef PARALLEL_DIRS
328
Reid Spencer100080c2004-10-25 08:27:37 +0000329SUBDIRS += $(PARALLEL_DIRS)
Reid Spencer81cd0492004-10-23 20:04:14 +0000330# Unfortunately, this list must be maintained if new
331# recursive targets are added.
332all :: $(addsuffix /.makeall , $(PARALLEL_DIRS))
333clean :: $(addsuffix /.makeclean , $(PARALLEL_DIRS))
334check :: $(addsuffix /.makecheck , $(PARALLEL_DIRS))
335install :: $(addsuffix /.makeinstall , $(PARALLEL_DIRS))
336uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
337
338Parallel_Targets := $(foreach T,$(RECURSIVE_TARGETS),%/.make$(T))
339
340$(Parallel_Targets) :
Reid Spencerf206bd72004-10-22 21:01:56 +0000341 $(VERB) if [ ! -f $(@D)/Makefile ]; then \
342 $(MKDIR) $(@D); \
343 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswell6df35dd2003-11-25 19:32:22 +0000344 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +0000345 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000346endif
347
Reid Spencer81cd0492004-10-23 20:04:14 +0000348#---------------------------------------------------------
349# Handle the OPTIONAL_DIRS options for directores that may
350# or may not exist.
351#---------------------------------------------------------
John Criswell8224df92003-06-27 16:58:44 +0000352ifdef OPTIONAL_DIRS
Reid Spencer100080c2004-10-25 08:27:37 +0000353
354SUBDIRS += $(OPTIONAL_DIRS)
355
Reid Spencer81cd0492004-10-23 20:04:14 +0000356$(RECURSIVE_TARGETS)::
Reid Spencerf206bd72004-10-22 21:01:56 +0000357 $(VERB) for dir in $(OPTIONAL_DIRS); do \
358 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
359 if [ ! -f $$dir/Makefile ]; then \
360 $(MKDIR) $$dir; \
361 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
362 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +0000363 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000364 fi \
John Criswell8224df92003-06-27 16:58:44 +0000365 done
366endif
367
Reid Spencercc51e7b2004-08-20 09:20:05 +0000368#---------------------------------------------------------
369# Handle the CONFIG_FILES options
370#---------------------------------------------------------
371ifdef CONFIG_FILES
Reid Spencercc51e7b2004-08-20 09:20:05 +0000372
Reid Spencer12a3a052004-10-24 07:53:21 +0000373install-local:: install-config-dir
Reid Spencer81cd0492004-10-23 20:04:14 +0000374
375install-config-dir: $(sysconfdir) $(CONFIG_FILES)
Reid Spencer4e181e72004-10-04 07:05:07 +0000376 $(VERB)$(ECHO) Installing Configuration Files To $(sysconfdir)
377 $(VERB)for file in $(CONFIG_FILES); do \
Reid Spencerf206bd72004-10-22 21:01:56 +0000378 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
Reid Spencercc51e7b2004-08-20 09:20:05 +0000379 done
Reid Spencer81cd0492004-10-23 20:04:14 +0000380
Reid Spencer12a3a052004-10-24 07:53:21 +0000381uninstall-local:: uninstall-config-dir
382
383uninstall-config-dir:
384 $(VERB)$(ECHO) Uninstalling Configuration Files From $(sysconfdir)
385 $(VERB)for file in $(CONFIG_FILES); do \
Reid Spencer100080c2004-10-25 08:27:37 +0000386 $(RM) -f $(sysconfdir)/$${file} ; \
Reid Spencer12a3a052004-10-24 07:53:21 +0000387 done
388
Reid Spencer81cd0492004-10-23 20:04:14 +0000389$(sysconfdir):
Reid Spencer77a46d22004-10-26 22:26:33 +0000390 $(VERB) $(MKDIR) $(sysconfdir)
Reid Spencer81cd0492004-10-23 20:04:14 +0000391
Reid Spencercc51e7b2004-08-20 09:20:05 +0000392endif
393
Reid Spencer81cd0492004-10-23 20:04:14 +0000394###############################################################################
395# Library Build Rules: Four ways to build a library
396###############################################################################
Chris Lattner2f7c9632001-06-06 20:29:01 +0000397
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000398$(libdir):
399 $(VERB) $(MKDIR) $(libdir)
400
401$(bytecode_libdir):
402 $(VERB) $(MKDIR) $(bytecode_libdir)
403
404
Brian Gaekeecc92bf2004-01-22 22:53:48 +0000405
Reid Spencer81cd0492004-10-23 20:04:14 +0000406# if we're building a library ...
Chris Lattner2f7c9632001-06-06 20:29:01 +0000407ifdef LIBRARYNAME
Vikram S. Advefe346892001-07-15 13:16:47 +0000408
Chris Lattner0100eab2002-09-16 22:36:42 +0000409# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000410LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencerf206bd72004-10-22 21:01:56 +0000411LIBNAME_LA := $(LIBDIR)/lib$(LIBRARYNAME).la
412LIBNAME_A := $(LIBDIR)/lib$(LIBRARYNAME).a
413LIBNAME_O := $(LIBDIR)/$(LIBRARYNAME).o
414LIBNAME_BC := $(LIBDIR)/lib$(LIBRARYNAME).bc
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000415
Reid Spencer81cd0492004-10-23 20:04:14 +0000416#---------------------------------------------------------
417# Shared Library Targets:
418# If the user asked for a shared library to be built
419# with the SHARED_LIBRARY variable, then we provide
420# targets for building them.
421#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000422ifdef SHARED_LIBRARY
423
Reid Spencer81cd0492004-10-23 20:04:14 +0000424all-local:: $(LIBNAME_LA)
Reid Spencerf206bd72004-10-22 21:01:56 +0000425
426$(LIBNAME_LA): $(BUILT_SOURCES) $(ObjectsLO) $(LIBDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000427 @$(ECHO) Linking $(CONFIGURATION) Shared Library $(notdir $@)
Reid Spencerf206bd72004-10-22 21:01:56 +0000428 $(VERB) $(Link) -o $@ $(ObjectsLO)
429 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $@ $(LIBDIR)
Reid Spencer81cd0492004-10-23 20:04:14 +0000430
431clean-local::
Reid Spencer12a3a052004-10-24 07:53:21 +0000432ifneq ($(strip $(LIBNAME_LA)),)
Reid Spencerf206bd72004-10-22 21:01:56 +0000433 $(VERB) $(RM) -f $(LIBNAME_LA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000434endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000435
Reid Spencer12a3a052004-10-24 07:53:21 +0000436DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
437install-local:: install-shared-library
Reid Spencerf206bd72004-10-22 21:01:56 +0000438
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000439install-shared-library: $(libdir) $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000440
441$(DestSharedLib): $(LIBNAME_LA)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000442 @$(ECHO) Installing $(CONFIGURATION) Shared Library $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000443 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_LA) $(DestSharedLib)
444 $(VERB) $(LIBTOOL) --finish $(libdir)
445
446uninstall-local:: uninstall-shared-library
447
448uninstall-shared-library:
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000449 @$(ECHO) Uninstalling $(CONFIGURATION) Shared Library $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000450 $(VERB) $(RM) -f $(DestSharedLib)
451
Reid Spencerf206bd72004-10-22 21:01:56 +0000452endif
453
Reid Spencer81cd0492004-10-23 20:04:14 +0000454#---------------------------------------------------------
455# Bytecode Library Targets:
456# If the user asked for a bytecode library to be built
457# with the BYTECODE_LIBRARY variable, then we provide
458# targets for building them.
459#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000460ifdef BYTECODE_LIBRARY
461
462ifdef EXPORTED_SYMBOL_LIST
463 BCLinkLib += -Xlinker -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
464else
465 ifdef EXPORTED_SYMBOL_FILE
466 BCLinkLib += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
467 else
468 BCLinkLib += -Xlinker -disable-internalize
469 endif
470endif
471
Reid Spencer81cd0492004-10-23 20:04:14 +0000472all-local:: $(LIBNAME_BC)
Reid Spencerf206bd72004-10-22 21:01:56 +0000473
474$(LIBNAME_BC): $(BUILT_SOURCES) $(ObjectsBC) $(LIBDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000475 @$(ECHO) Linking $(CONFIGURATION) Bytecode Library $(notdir $@)
Reid Spencerf206bd72004-10-22 21:01:56 +0000476 $(VERB) $(BCLinkLib) -o $@ $(ObjectsBC)
477
Reid Spencer81cd0492004-10-23 20:04:14 +0000478clean-local::
Reid Spencer12a3a052004-10-24 07:53:21 +0000479ifneq ($(strip $(LIBNAME_BC)),)
Reid Spencerf206bd72004-10-22 21:01:56 +0000480 $(VERB) $(RM) -f $(LIBNAME_BC)
Reid Spencer12a3a052004-10-24 07:53:21 +0000481endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000482
Reid Spencer12a3a052004-10-24 07:53:21 +0000483DestBytecodeLib = $(bytecode_libdir)/lib$(LIBRARYNAME).bc
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000484
Reid Spencer12a3a052004-10-24 07:53:21 +0000485install-local:: install-bytecode-library
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000486
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000487install-bytecode-library: $(bytecode_libdir) $(DestBytecodeLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000488
489$(DestBytecodeLib): $(LIBNAME_BC) $(bytecode_libdir)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000490 @$(ECHO) Installing $(CONFIGURATION) Bytecode Library $(DestBytecodeLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000491 $(VERB) $(INSTALL) $< $@
492
493uninstall-local:: uninstall-bytecode-library
494
495uninstall-bytecode-library:
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000496 @$(ECHO) Uninstalling $(CONFIGURATION) Bytecode Library $(DestBytecodeLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000497 $(VERB) $(RM) -f $(DestBytecodeLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000498
499endif
Vikram S. Adve15bd3ad2002-08-02 18:34:12 +0000500
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000501# Does the library want a .o version built?
Chris Lattner76d98ba2002-07-23 17:56:16 +0000502ifndef DONT_BUILD_RELINKED
Reid Spencer81cd0492004-10-23 20:04:14 +0000503all-local:: $(LIBNAME_O)
Reid Spencerf206bd72004-10-22 21:01:56 +0000504
505$(LIBNAME_O): $(BUILT_SOURCES) $(ObjectsO) $(LIBDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000506 @$(ECHO) Linking $(CONFIGURATION) Object Library $(notdir $@)
Reid Spencerf206bd72004-10-22 21:01:56 +0000507 $(VERB) $(Relink) -o $@ $(ObjectsO)
508
Reid Spencer81cd0492004-10-23 20:04:14 +0000509clean-local::
Reid Spencer12a3a052004-10-24 07:53:21 +0000510ifneq ($(strip $(LIBNAME_O)),)
Reid Spencerf206bd72004-10-22 21:01:56 +0000511 $(VERB) $(RM) -f $(LIBNAME_O)
Reid Spencer12a3a052004-10-24 07:53:21 +0000512endif
513
514DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
515
516install-local:: install-relinked-library
517
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000518install-relinked-library: $(libdir) $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000519
520$(DestRelinkedLib): $(LIBNAME_O)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000521 @$(ECHO) Installing $(CONFIGURATION) Object Library $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000522 $(VERB) $(MKDIR) $(libdir)
523 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_O) $(DestRelinkedLib)
524
525uninstall-local:: uninstall-relinked-library
526
527uninstall-relinked-library:
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000528 @$(ECHO) Uninstalling $(CONFIGURATION) Object Library $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000529 $(VERB) $(RM) -f $(DestRelinkedLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000530
Chris Lattner76d98ba2002-07-23 17:56:16 +0000531endif
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000532
533# Does the library want an archive version built?
Chris Lattner76d98ba2002-07-23 17:56:16 +0000534ifdef BUILD_ARCHIVE
Reid Spencer81cd0492004-10-23 20:04:14 +0000535all-local:: $(LIBNAME_A)
Chris Lattner76d98ba2002-07-23 17:56:16 +0000536
Reid Spencerf206bd72004-10-22 21:01:56 +0000537$(LIBNAME_A): $(BUILT_SOURCES) $(ObjectsO) $(LIBDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000538 @$(ECHO) Building $(CONFIGURATION) Archive Library $(notdir $@)
Reid Spencer4e181e72004-10-04 07:05:07 +0000539 $(VERB)$(RM) -f $@
Reid Spencerf206bd72004-10-22 21:01:56 +0000540 $(VERB) $(Archive) $@ $(ObjectsO)
541 $(VERB) $(Ranlib) $@
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000542
Reid Spencer81cd0492004-10-23 20:04:14 +0000543clean-local::
Reid Spencer12a3a052004-10-24 07:53:21 +0000544ifneq ($(strip $(LIBNAME_A)),)
Reid Spencerf206bd72004-10-22 21:01:56 +0000545 $(VERB) $(RM) -f $(LIBNAME_A)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000546endif
547
Reid Spencer12a3a052004-10-24 07:53:21 +0000548DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
549
550install-local:: install-archive-library
551
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000552install-archive-library: $(libdir) $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000553
554$(DestArchiveLib): $(LIBNAME_A)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000555 @$(ECHO) Installing $(CONFIGURATION) Archive Library $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000556 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_A) $(DestArchiveLib)
557
Reid Spencerdcba7782004-10-24 08:21:04 +0000558uninstall-local:: uninstall-archive-library
Reid Spencer12a3a052004-10-24 07:53:21 +0000559
560uninstall-archive-library:
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000561 @$(ECHO) Uninstalling $(CONFIGURATION) Archive Library $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000562 $(VERB) $(RM) -f $(DestArchiveLib)
563
564endif
565
566# endif LIBRARYNAME
Reid Spencerf206bd72004-10-22 21:01:56 +0000567endif
568
Reid Spencerdcba7782004-10-24 08:21:04 +0000569###############################################################################
570# Tool Build Rules: Build executable tool based on TOOLNAME option
571###############################################################################
572
Chris Lattner07c7c192001-09-07 22:57:58 +0000573ifdef TOOLNAME
574
Reid Spencerdcba7782004-10-24 08:21:04 +0000575#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000576# TOOLLINKOPTSB to pass options to the linker like library search path etc
577# Note that this is different from TOOLLINKOPTS, these options
578# are passed to the linker *before* the USEDLIBS options are passed.
579# e.g. usage TOOLLINKOPTSB = -L/home/xxx/lib
Reid Spencerdcba7782004-10-24 08:21:04 +0000580#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000581ifdef TOOLLINKOPTSB
582Link += $(TOOLLINKOPTSB)
Reid Spencer4e181e72004-10-04 07:05:07 +0000583endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000584
Reid Spencerdcba7782004-10-24 08:21:04 +0000585# TOOLEXENAME - This is the output filenames to generate
Reid Spencerf206bd72004-10-22 21:01:56 +0000586TOOLEXENAME := $(TOOLDIR)/$(TOOLNAME)
Chris Lattner07c7c192001-09-07 22:57:58 +0000587
Reid Spencerdcba7782004-10-24 08:21:04 +0000588# LIBS_OPTIONS - Compute the options lines that add -llib1 -llib2, etc.
Reid Spencerf206bd72004-10-22 21:01:56 +0000589PROJ_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
590PROJ_LIBS_OPTIONS := $(patsubst %.o, $(LIBDIR)/%.o, $(PROJ_LIBS_OPTIONS))
591LLVM_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
592LLVM_LIBS_OPTIONS := $(patsubst %.o, $(LLVMLIBDIR)/%.o, $(LLVM_LIBS_OPTIONS))
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000593
Reid Spencerdcba7782004-10-24 08:21:04 +0000594# USED_LIBS/LIBS_PATHS - Compute dependent library file paths
Reid Spencerf206bd72004-10-22 21:01:56 +0000595PROJ_USED_LIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
596LLVM_USED_LIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
597PROJ_LIBS_PATHS := $(addprefix $(LIBDIR)/,$(PROJ_USED_LIBS))
598LLVM_LIBS_PATHS := $(addprefix $(LLVMLIBDIR)/,$(LLVM_USED_LIBS))
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000599
Reid Spencerdcba7782004-10-24 08:21:04 +0000600# Concatenate all the optoins
Reid Spencerf206bd72004-10-22 21:01:56 +0000601LINK_OPTS := $(TOOLLINKOPTS) $(PROJ_LIBS_OPTIONS) $(LLVM_LIBS_OPTIONS)
John Criswell30a0c102004-09-16 14:11:25 +0000602
Reid Spencerf206bd72004-10-22 21:01:56 +0000603# Handle compression libraries automatically
604ifeq ($(HAVE_BZIP2),1)
605LIBS += -lbz2
606endif
607ifeq ($(HAVE_ZLIB),1)
608LIBS += -lz
609endif
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000610
Chris Lattner3ecb7762003-01-22 16:13:31 +0000611# Tell make that we need to rebuild subdirectories before we can link the tool.
612# This affects things like LLI which has library subdirectories.
Reid Spencerdcba7782004-10-24 08:21:04 +0000613$(TOOLEXENAME): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner3ecb7762003-01-22 16:13:31 +0000614
Reid Spencerdcba7782004-10-24 08:21:04 +0000615all-local:: $(TOOLEXENAME)
John Criswell8224df92003-06-27 16:58:44 +0000616
Reid Spencer81cd0492004-10-23 20:04:14 +0000617clean-local::
Reid Spencer12a3a052004-10-24 07:53:21 +0000618ifneq ($(strip $(TOOLEXENAME)),)
Reid Spencerf206bd72004-10-22 21:01:56 +0000619 $(VERB) $(RM) -f $(TOOLEXENAME)
Reid Spencer12a3a052004-10-24 07:53:21 +0000620endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000621
Reid Spencerf206bd72004-10-22 21:01:56 +0000622$(TOOLEXENAME): $(BUILT_SOURCES) $(ObjectsO) $(PROJ_LIBS_PATHS) $(LLVM_LIBS_PATHS) $(TOOLDIR)/.dir
623 @$(ECHO) Linking $(CONFIGURATION) executable $(TOOLNAME) $(STRIP_WARN_MSG)
624 $(VERB) $(Link) -o $@ $(ObjectsO) $(PROJ_LIBS_OPTIONS) $(LLVM_LIBS_OPTIONS) $(LIBS)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000625 @$(ECHO) ======= Finished Linking $(CONFIGURATION) Executable $(TOOLNAME) $(STRIP_WARN_MSG)
Reid Spencer12a3a052004-10-24 07:53:21 +0000626
627DestTool = $(bindir)/$(TOOLNAME)
628
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000629install-local:: install-tool
630
631install-tool: $(bindir) $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000632
633$(DestTool): $(TOOLEXENAME)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000634 @$(ECHO) Installing $(CONFIGURATION) $(DestTool)
635 $(VERB) $(INSTALL) $(TOOLEXENAME) $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000636
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000637$(bindir):
638 $(VERB) $(MKDIR) $(bindir)
639
Reid Spencer12a3a052004-10-24 07:53:21 +0000640uninstall-local:: uninstall-tool
641
642uninstall-tool:
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000643 @$(ECHO) Uninstalling $(CONFIGURATION) $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000644 $(VERB) $(RM) -f $(DestTool)
645
Reid Spencerf206bd72004-10-22 21:01:56 +0000646endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000647
Reid Spencerf206bd72004-10-22 21:01:56 +0000648ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000649
Reid Spencerf206bd72004-10-22 21:01:56 +0000650# Create .lo files in the OBJDIR directory from the .cpp and .c files...
Reid Spencer81cd0492004-10-23 20:04:14 +0000651ifdef SHARED_LIBRARY
652
653$(OBJDIR)/%.lo $(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000654 @$(ECHO) "Compiling $*.cpp (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000655 $(VERB) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(OBJDIR)/$*.LACXXd $< -o $@ ; \
656 then $(MV) -f "$(OBJDIR)/$*.LACXXd" "$(OBJDIR)/$*.d"; \
Reid Spencer100080c2004-10-25 08:27:37 +0000657 else $(RM) -f "$(OBJDIR)/$*.LACXXd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000658
659$(OBJDIR)/%.lo $(OBJDIR)/%.o: %.c $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000660 @$(ECHO) "Compiling $*.c (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000661 $(VERB) if $(LTCompile.C) -MD -MT $@ -MP -MF $(OBJDIR)/$*.LACd $< -o $@ ; \
662 then $(MV) -f "$(OBJDIR)/$*.LACd" "$(OBJDIR)/$*.d"; \
Reid Spencer100080c2004-10-25 08:27:37 +0000663 else $(RM) -f "$(OBJDIR)/$*.LACd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000664
665else
Reid Spencerf206bd72004-10-22 21:01:56 +0000666
667$(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000668 @$(ECHO) "Compiling $*.cpp"
Reid Spencer81cd0492004-10-23 20:04:14 +0000669 $(VERB) if $(Compile.CXX) -MD -MT $@ -MP -MF $(OBJDIR)/$*.CXXd $< -o $@ ; \
670 then $(MV) -f "$(OBJDIR)/$*.CXXd" "$(OBJDIR)/$*.d"; \
Reid Spencer100080c2004-10-25 08:27:37 +0000671 else $(RM) -f "$(OBJDIR)/$*.CXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +0000672
673$(OBJDIR)/%.o: %.c $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000674 @$(ECHO) "Compiling $*.c"
Reid Spencer81cd0492004-10-23 20:04:14 +0000675 $(VERB) if $(Compile.C) -MD -MT $@ -MP -MF $(OBJDIR)/$*.Cd $< -o $@ ; \
676 then $(MV) -f "$(OBJDIR)/$*.Cd" "$(OBJDIR)/$*.d"; \
Reid Spencer100080c2004-10-25 08:27:37 +0000677 else $(RM) -f "$(OBJDIR)/$*.Cd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000678
679endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000680
681# Create .bc files in the OBJDIR directory from .cpp and .c files...
682$(OBJDIR)/%.bc: %.cpp $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000683 @$(ECHO) "Compiling $*.cpp (bytecode)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000684 $(VERB) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(OBJDIR)/$*.BCCXXd" $< -o $@ ; \
685 then $(MV) -f "$(OBJDIR)/$*.BCCXXd" "$(OBJDIR)/$*.d"; \
Reid Spencer100080c2004-10-25 08:27:37 +0000686 else $(RM) -f "$(OBJDIR)/$*.BCCXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +0000687
688$(OBJDIR)/%.bc: %.c $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000689 @$(ECHO) "Compiling $*.c (bytecode)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000690 $(VERB) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(OBJDIR)/$*.BCCd" $< -o $@ ; \
691 then $(MV) -f "$(OBJDIR)/$*.BCCd" "$(OBJDIR)/$*.d"; \
Reid Spencer100080c2004-10-25 08:27:37 +0000692 else $(RM) -f "$(OBJDIR)/$*.BCCd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +0000693
694else
695
Reid Spencer81cd0492004-10-23 20:04:14 +0000696ifdef SHARED_LIBRARY
697
698$(OBJDIR)/%.lo $(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000699 @$(ECHO) "Compiling $*.cpp (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000700 $(LTCompile.CXX) $< -o $@
701
702$(OBJDIR)/%.lo $(OBJDIR)/%.o: %.c $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000703 @$(ECHO) "Compiling $*.cpp (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000704 $(LTCompile.C) $< -o $@
705
706else
Reid Spencerf206bd72004-10-22 21:01:56 +0000707
708$(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000709 @$(ECHO) "Compiling $*.cpp"
Reid Spencer81cd0492004-10-23 20:04:14 +0000710 $(Compile.CXX) $< -o $@
Reid Spencerf206bd72004-10-22 21:01:56 +0000711
712$(OBJDIR)/%.o: %.c $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000713 @$(ECHO) "Compiling $*.cpp"
Reid Spencer81cd0492004-10-23 20:04:14 +0000714 $(Compile.C) $< -o $@
715endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000716
717# Create .bc files in the OBJDIR directory from .cpp and .c files...
718$(OBJDIR)/%.bc: %.cpp $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000719 @$(ECHO) "Compiling $*.cpp (bytecode)"
Reid Spencerf206bd72004-10-22 21:01:56 +0000720 $(BCCompileCPP) $< -o $@
721
722$(OBJDIR)/%.bc: %.c $(OBJDIR)/.dir
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000723 @$(ECHO) "Compiling $*.c (bytecode)"
Reid Spencerf206bd72004-10-22 21:01:56 +0000724 $(BCCompileC) $< -o $@
Brian Gaeke0f148bc2003-12-10 00:26:28 +0000725
Chris Lattner07c7c192001-09-07 22:57:58 +0000726endif
727
Reid Spencerf206bd72004-10-22 21:01:56 +0000728$(OBJDIR)/%.bc: %.ll $(OBJDIR)/.dir $(LLVMAS)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000729 @$(ECHO) "Compiling $*.ll"
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000730 $(VERB) $(LLVMAS) $< -f -o $@
731
Reid Spencerf206bd72004-10-22 21:01:56 +0000732ifdef TARGET
733
Reid Spencer282e13c2004-10-23 08:19:37 +0000734TDFILES := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
Reid Spencer94105c72004-10-27 04:34:35 +0000735INCFILES := $(filter %.inc,$(BUILT_SOURCES))
Reid Spencerf206bd72004-10-22 21:01:56 +0000736
Reid Spencer94105c72004-10-27 04:34:35 +0000737$(INCFILES) : $(TBLGEN) $(TDFILES)
Reid Spencerf206bd72004-10-22 21:01:56 +0000738
Reid Spencer94105c72004-10-27 04:34:35 +0000739%GenRegisterNames.inc : %.td
Reid Spencerf206bd72004-10-22 21:01:56 +0000740 @echo "Building $(<F) register names with tblgen"
741 $(VERB) $(TableGen) -gen-register-enums -o $@ $<
742
Reid Spencer94105c72004-10-27 04:34:35 +0000743%GenRegisterInfo.h.inc : %.td
Reid Spencerf206bd72004-10-22 21:01:56 +0000744 @echo "Building $(<F) register information header with tblgen"
745 $(VERB) $(TableGen) -gen-register-desc-header -o $@ $<
746
747%GenRegisterInfo.inc : %.td
748 @echo "Building $(<F) register info implementation with tblgen"
749 $(VERB) $(TableGen) -gen-register-desc -o $@ $<
750
751%GenInstrNames.inc : %.td
752 @echo "Building $(<F) instruction names with tblgen"
753 $(VERB) $(TableGen) -gen-instr-enums -o $@ $<
754
755%GenInstrInfo.inc : %.td
756 @echo "Building $(<F) instruction information with tblgen"
757 $(VERB) $(TableGen) -gen-instr-desc -o $@ $<
758
759%GenAsmWriter.inc : %.td
760 @echo "Building $(<F) assembly writer with tblgen"
761 $(VERB) $(TableGen) -gen-asm-writer -o $@ $<
762
763%GenATTAsmWriter.inc : %.td
764 @echo "Building $(<F) AT&T assembly writer with tblgen"
765 $(VERB) $(TableGen) -gen-asm-writer -o $@ $<
766
767%GenIntelAsmWriter.inc : %.td
768 @echo "Building $(<F) Intel assembly writer with tblgen"
769 $(VERB) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
770
771%GenInstrSelector.inc: %.td
772 @echo "Building $(<F) instruction selector with tblgen"
773 $(VERB) $(TableGen) -gen-instr-selector -o $@ $<
774
775%GenCodeEmitter.inc:: %.td
776 @echo "Building $(<F) code emitter with tblgen"
777 $(VERB) $(TableGen) -gen-emitter -o $@ $<
778
Reid Spencer81cd0492004-10-23 20:04:14 +0000779clean-local::
Reid Spencerf206bd72004-10-22 21:01:56 +0000780 $(VERB) rm -f *.inc
781
782endif
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000783
Chris Lattnerdb644dd2003-01-16 22:44:19 +0000784#
785# Rules for building lex/yacc files
786#
Reid Spencer81cd0492004-10-23 20:04:14 +0000787LEX_FILES = $(filter %.l, $(SOURCES))
Chris Lattnerdb644dd2003-01-16 22:44:19 +0000788LEX_OUTPUT = $(LEX_FILES:%.l=%.cpp)
Reid Spencer81cd0492004-10-23 20:04:14 +0000789YACC_FILES = $(filter %.y, $(SOURCES))
Chris Lattnerdb644dd2003-01-16 22:44:19 +0000790YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output)
791.PRECIOUS: $(LEX_OUTPUT) $(YACC_OUTPUT)
792
Chris Lattner2f7c9632001-06-06 20:29:01 +0000793# Create a .cpp source file from a flex input file... this uses sed to cut down
794# on the warnings emited by GCC...
Chris Lattner9e461662003-01-23 16:33:10 +0000795#
796# The last line is a gross hack to work around flex aparently not being able to
797# resize the buffer on a large token input. Currently, for uninitialized string
798# buffers in LLVM we can generate very long tokens, so this is a hack around it.
Chris Lattner92fc9b02003-08-15 20:00:47 +0000799# FIXME. (f.e. char Buffer[10000] )
Chris Lattner9e461662003-01-23 16:33:10 +0000800#
Chris Lattner2f7c9632001-06-06 20:29:01 +0000801%.cpp: %.l
Reid Spencerf206bd72004-10-22 21:01:56 +0000802 @$(ECHO) Flexing $<
Chris Lattnerb3aae612003-08-04 19:48:10 +0000803 $(VERB) $(FLEX) -t $< | \
Reid Spencerf206bd72004-10-22 21:01:56 +0000804 $(SED) '/^find_rule/d' | \
805 $(SED) 's/void yyunput/inline void yyunput/' | \
806 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
807 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
808 > $@.tmp
809 $(VERB) cmp -s $@ $@.tmp > /dev/null || $(MV) -f $@.tmp $@
Chris Lattner7d0adf72003-08-04 19:47:06 +0000810 @# remove the output of flex if it didn't get moved over...
811 @rm -f $@.tmp
Chris Lattner2f7c9632001-06-06 20:29:01 +0000812
813# Rule for building the bison parsers...
Chris Lattner021249f2003-05-15 21:28:55 +0000814%.c: %.y # Cancel built-in rules for yacc
815%.h: %.y # Cancel built-in rules for yacc
Chris Lattner2f7c9632001-06-06 20:29:01 +0000816%.cpp %.h : %.y
Reid Spencerf206bd72004-10-22 21:01:56 +0000817 @$(ECHO) "Bisoning $*.y"
John Criswellded98992003-09-09 20:57:03 +0000818 $(VERB) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000819 $(VERB) cmp -s $*.tab.c $*.cpp > /dev/null || $(MV) -f $*.tab.c $*.cpp
820 $(VERB) cmp -s $*.tab.h $*.h > /dev/null || $(MV) -f $*.tab.h $*.h
Chris Lattner7d0adf72003-08-04 19:47:06 +0000821 @# If the files were not updated, don't leave them lying around...
822 @rm -f $*.tab.c $*.tab.h
Chris Lattner2f7c9632001-06-06 20:29:01 +0000823
824# To create the directories...
825%/.dir:
Reid Spencerf206bd72004-10-22 21:01:56 +0000826 $(VERB) $(MKDIR) $* > /dev/null
John Criswell3ef61af2003-06-30 21:59:07 +0000827 @$(DATE) > $@
Chris Lattner2f7c9632001-06-06 20:29:01 +0000828
Reid Spencerf206bd72004-10-22 21:01:56 +0000829.PRECIOUS: $(OBJDIR)/.dir $(LIBDIR)/.dir $(TOOLDIR)/.dir $(LLVMLIBDIR)/.dir
830.PRECIOUS: $(LLVMTOOLDIR)/.dir
831
Chris Lattner23d47392003-01-16 21:06:18 +0000832# To create postscript files from dot files...
John Criswell4ffb8442003-10-02 19:02:02 +0000833ifneq ($(DOT),false)
Chris Lattner23d47392003-01-16 21:06:18 +0000834%.ps: %.dot
Reid Spencerf206bd72004-10-22 21:01:56 +0000835 $(DOT) -Tps < $< > $@
John Criswell3ef61af2003-06-30 21:59:07 +0000836else
837%.ps: %.dot
Reid Spencerf206bd72004-10-22 21:01:56 +0000838 $(ECHO) "Cannot build $@: The program dot is not installed"
John Criswell3ef61af2003-06-30 21:59:07 +0000839endif
Chris Lattner23d47392003-01-16 21:06:18 +0000840
John Criswell0a6e6aa2003-09-06 14:44:17 +0000841#
842# This rules ensures that header files that are removed still have a rule for
843# which they can be "generated." This allows make to ignore them and
844# reproduce the dependency lists.
845#
John Criswella8391af2003-09-18 18:37:08 +0000846%.h:: ;
John Criswell0a6e6aa2003-09-06 14:44:17 +0000847
Chris Lattnera8ce09e2002-09-22 02:47:15 +0000848# 'make clean' nukes the tree
Reid Spencer81cd0492004-10-23 20:04:14 +0000849clean-local::
Reid Spencer12a3a052004-10-24 07:53:21 +0000850ifneq ($(strip $(OBJDIR)),)
Reid Spencere0578112004-10-24 02:26:09 +0000851 $(VERB) $(RM) -rf $(OBJDIR)
Reid Spencer12a3a052004-10-24 07:53:21 +0000852endif
Brian Gaeke8625f682004-01-21 19:53:11 +0000853 $(VERB) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
854ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
855 $(VERB) $(RM) -f *$(SHLIBEXT)
856endif
Reid Spencer12a3a052004-10-24 07:53:21 +0000857ifneq ($(strip $(LEX_OUTPUT)),)
858 $(VERB) $(RM) -f $(LEX_OUTPUT)
859endif
860ifneq ($(strip $(YACC_OUTPUT)),)
861 $(VERB) $(RM) -f $(YACC_OUTPUT)
862endif
John Criswell3ef61af2003-06-30 21:59:07 +0000863
Reid Spencer81cd0492004-10-23 20:04:14 +0000864###############################################################################
865# DEPENDENCIES: Include the dependency files if we should
866###############################################################################
Chris Lattnere9d7d702003-08-22 14:10:16 +0000867ifndef DISABLE_AUTO_DEPENDENCIES
868
Reid Spencer81cd0492004-10-23 20:04:14 +0000869# If its not one of the cleaning targets
870ifneq ($strip($(filter-out clean clean-local dist-clean, $(MAKECMDGOALS))),)
Reid Spencerf206bd72004-10-22 21:01:56 +0000871
Reid Spencer81cd0492004-10-23 20:04:14 +0000872# Get the list of dependency files
873DependFiles := $(basename $(filter %.cpp %.c %.cc, $(SOURCES)))
874DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(CONFIGURATION)/%.d,$(DependFiles))
Misha Brukmanb891ffb2003-11-09 21:36:19 +0000875
Reid Spencer81cd0492004-10-23 20:04:14 +0000876-include /dev/null $(DependFiles)
877
John Criswell48ecca62003-08-12 18:51:51 +0000878endif
Chris Lattner598222b2003-08-18 17:27:40 +0000879
Chris Lattnere9d7d702003-08-22 14:10:16 +0000880endif # ifndef DISABLE_AUTO_DEPENDENCIES
Reid Spencerf206bd72004-10-22 21:01:56 +0000881
Reid Spencer100080c2004-10-25 08:27:37 +0000882###############################################################################
883# Handle construction of a distribution tarball
884###############################################################################
885
886.PHONY: dist dist-chck dist-clean distdir dist-gzip dist-bzip2 dist-zip
887
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000888#------------------------------------------------------------------------
889# Define distribution related variables
890#------------------------------------------------------------------------
Reid Spencer100080c2004-10-25 08:27:37 +0000891DistName := $(LLVM_TARBALL_NAME)
892DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000893TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer100080c2004-10-25 08:27:37 +0000894DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
895DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
896DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
897DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
898 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000899 Makefile.config.in configure autoconf
900DistOther := $(notdir $(wildcard \
901 $(BUILD_SRC_DIR)/*.h \
902 $(BUILD_SRC_DIR)/*.td \
903 $(BUILD_SRC_DIR)/*.def \
904 $(BUILD_SRC_DIR)/*.ll \
905 $(BUILD_SRC_DIR)/*.in))
906DistSources := $(SOURCES) $(EXTRA_DIST)
907DistSubDirs := $(SUBDIRS)
908DistFiles := $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer100080c2004-10-25 08:27:37 +0000909
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000910
911#------------------------------------------------------------------------
912# We MUST build distribution with OBJ_DIR != SRC_DIR
913#------------------------------------------------------------------------
914ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
915dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
916 @$(ECHO) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
917
918DistCheckTop :=
919else
920
921DistCheckTop := check
922#------------------------------------------------------------------------
923# Prevent catastrophic remove
924#------------------------------------------------------------------------
925ifeq ($(LLVM_TARBALL_NAME),)
926$(error LLVM_TARBALL_NAME is empty. Please rerun configure)
927endif
928
929#------------------------------------------------------------------------
930# Prevent attempt to run dist targets from anywhere but the top level
931#------------------------------------------------------------------------
932ifneq ($(LEVEL),.)
933
934dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
935 @$(ECHO) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
936
937else
938
939#------------------------------------------------------------------------
940# Provide the top level targets
941#------------------------------------------------------------------------
942
943dist-gzip: $(DistTarGZip)
944
945$(DistTarGZip) : distdir
946 @$(ECHO) Packing gzipped distribution tar file.
947 $(VERB) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | gzip -c > "$(DistTarGZip)"
948
949dist-bzip2: $(DistTarBZ2)
950
951$(DistTarBZ2) : distdir
952 @$(ECHO) Packing bzipped distribution tar file.
953 $(VERB) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | $(BZIP2) -c >$(DistTarBZ2)
954
955dist-zip: $(DistZip)
956
957$(DistZip) : distdir
958 @$(ECHO) Packing zipped distribution file.
959 $(VERB) rm -f $(DistZip)
960 $(VERB) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
961
962dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
963 @$(ECHO) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
964
965DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
966
Reid Spencer77a46d22004-10-26 22:26:33 +0000967dist-check:: $(DistCheckTop) $(DistTarGZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000968 @$(ECHO) Checking distribution tar file.
969 $(VERB) if test -d $(DistCheckDir) ; then \
970 $(RM) -rf $(DistCheckDir) ; \
971 fi
972 $(VERB) $(MKDIR) $(DistCheckDir)
973 $(VERB) cd $(DistCheckDir) && \
974 $(MKDIR) $(DistCheckDir)/build && \
975 $(MKDIR) $(DistCheckDir)/install && \
976 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
977 cd build && \
978 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
979 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
980 $(MAKE) check && \
981 $(MAKE) install && \
982 $(MAKE) uninstall && \
983 $(MAKE) dist && \
984 $(MAKE) clean && \
985 $(MAKE) dist-clean && \
986 $(ECHO) ===== $(DistTarGZip) Ready For Distribution =====
987
988dist-clean::
989 @$(ECHO) Cleaning distribution files
990 $(VERB) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) $(DistCheckDir)
991
992endif
993
994#------------------------------------------------------------------------
995# Provide the recursive distdir target for building the distribution directory
996#------------------------------------------------------------------------
Reid Spencer77a46d22004-10-26 22:26:33 +0000997distdir : $(DistSources)
Reid Spencer100080c2004-10-25 08:27:37 +0000998 @$(ECHO) Building Distribution Directory $(DistDir)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000999 $(VERB) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1000 if test -d "$(DistDir)" ; then \
1001 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1002 exit 1 ; \
1003 fi ; \
1004 echo Removing $(DistDir) ; \
1005 $(RM) -rf $(DistDir); \
1006 fi
Reid Spencer100080c2004-10-25 08:27:37 +00001007 $(VERB) $(MKDIR) $(DistDir)
1008 $(VERB) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
1009 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1010 for file in $(DistFiles) ; do \
1011 case "$$file" in \
1012 $(BUILD_SRC_DIR)/*) file=`echo "$$file" | sed "s#^$$srcdirstrip/##"`;; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001013 $(BUILD_SRC_ROOT)/*) file=`echo "$$file" | sed "s#^$$srcrootstrip/#$(BUILD_OBJ_ROOT)/#"`;; \
Reid Spencer100080c2004-10-25 08:27:37 +00001014 esac; \
1015 if test -f "$$file" || test -d "$$file" ; then \
1016 from_dir=. ; \
1017 else \
1018 from_dir=$(BUILD_SRC_DIR); \
1019 fi; \
1020 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'`; \
1021 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1022 to_dir="$(DistDir)/$$dir"; \
1023 $(MKDIR) "$$to_dir" ; \
1024 else \
1025 to_dir="$(DistDir)"; \
1026 fi; \
1027 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1028 if test -n "$$mid_dir" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001029 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001030 fi ; \
1031 if test -d "$$from_dir/$$file"; then \
1032 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1033 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1034 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1035 fi; \
1036 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1037 elif test -f "$$from_dir/$$file" ; then \
1038 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1039 elif test -L "$$from_dir/$$file" ; then \
1040 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1041 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
1042 $(ECHO) "===== WARNING: Distribution Source $$from_dir/$$file Not Found!" ; \
1043 elif test "$(VERB)" != '@' ; then \
1044 $(ECHO) "Skipping non-existent $$from_dir/$$file" ; \
1045 fi; \
1046 done
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001047 $(VERB) for subdir in $(DistSubDirs) ; do \
Reid Spencer100080c2004-10-25 08:27:37 +00001048 if test "$$subdir" \!= "." ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001049 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001050 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
1051 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001052 fi; \
1053 done
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001054 $(VERB) $(MAKE) DistDir="$(DistDir)" dist-hook || exit 1
Reid Spencer100080c2004-10-25 08:27:37 +00001055 -$(VERB) find $(DistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
1056 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
1057 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
1058 ! -type d ! -perm -444 -exec $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1059 || chmod -R a+r $(DistDir)
1060
1061dist-hook::
1062
1063
Reid Spencer23a70372004-10-22 23:06:30 +00001064endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001065
1066###############################################################################
Reid Spencer12a3a052004-10-24 07:53:21 +00001067# TOP LEVEL - targets only to apply at the top level directory
1068###############################################################################
1069
1070ifeq ($(LEVEL),.)
1071
1072#------------------------------------------------------------------------
Reid Spencer12a3a052004-10-24 07:53:21 +00001073# Install support for project's include files:
1074#------------------------------------------------------------------------
1075install-local::
1076 @$(ECHO) Installing include files
1077 $(VERB) $(MKDIR) $(includedir)
1078 $(VERB) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1079 cd $(BUILD_SRC_ROOT)/include && \
1080 find . -path '*/Internal' -prune -o '(' -type f \
1081 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1082 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1083 fi
1084
1085uninstall-local::
1086 @$(ECHO) Uninstalling include files
1087 $(VERB) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
1088 cd $(BUILD_SRC_ROOT)/include && \
1089 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1090 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1091 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1092 fi
1093
1094#------------------------------------------------------------------------
1095# Build tags database for Emacs/Xemacs:
1096#------------------------------------------------------------------------
Reid Spencer100080c2004-10-25 08:27:37 +00001097tags:: TAGS
Reid Spencer12a3a052004-10-24 07:53:21 +00001098
Reid Spencer100080c2004-10-25 08:27:37 +00001099TAGS:
Reid Spencer12a3a052004-10-24 07:53:21 +00001100 find include lib tools examples -name '*.cpp' -o -name '*.h' | $(ETAGS) $(ETAGSFLAGS) -
1101
Reid Spencer12a3a052004-10-24 07:53:21 +00001102endif
1103
1104###############################################################################
Reid Spencerf206bd72004-10-22 21:01:56 +00001105# MISCELLANEOUS - utility targets
1106###############################################################################
1107
1108#------------------------------------------------------------------------
1109# Print out the directories used for building
Reid Spencer81cd0492004-10-23 20:04:14 +00001110printvars::
Reid Spencer77a46d22004-10-26 22:26:33 +00001111 @$(ECHO) "CONFIGURATION : " $(CONFIGURATION)
Reid Spencerf206bd72004-10-22 21:01:56 +00001112 @$(ECHO) "BUILD_SRC_ROOT: " $(BUILD_SRC_ROOT)
1113 @$(ECHO) "BUILD_SRC_DIR : " $(BUILD_SRC_DIR)
1114 @$(ECHO) "BUILD_OBJ_ROOT: " $(BUILD_OBJ_ROOT)
1115 @$(ECHO) "BUILD_OBJ_DIR : " $(BUILD_OBJ_DIR)
1116 @$(ECHO) "LLVM_SRC_ROOT : " $(LLVM_SRC_ROOT)
1117 @$(ECHO) "LLVM_OBJ_ROOT : " $(LLVM_OBJ_ROOT)
Reid Spencer77a46d22004-10-26 22:26:33 +00001118 @$(ECHO) "libdir : " $(libdir)
1119 @$(ECHO) "bindir : " $(bindir)
1120 @$(ECHO) "sysconfdir : " $(sysconfdir)
1121 @$(ECHO) "bytecode_libdir : " $(bytecode_libdir)
1122 @$(ECHO) "USER_TARGETS : " $(USER_TARGETS)
1123 @$(ECHO) "OBJMKFILES: $(OBJMKFILES)"
1124 @$(ECHO) "SRCMKFILES: $(SRCMKFILES)"
Reid Spencerf206bd72004-10-22 21:01:56 +00001125 @$(ECHO) "OBJDIR: " $(OBJDIR)
1126 @$(ECHO) "LIBDIR: " $(LIBDIR)
1127 @$(ECHO) "TOOLDIR: " $(TOOLDIR)
1128 @$(ECHO) "TDFILES:" '$(TDFILES)'
Reid Spencer81cd0492004-10-23 20:04:14 +00001129 @$(ECHO) "Compile.CXX: " '$(Compile.CXX)'
1130 @$(ECHO) "Compile.C: " '$(Compile.C)'
Reid Spencer12a3a052004-10-24 07:53:21 +00001131