blob: acc4403e0834c4d543d7548dd6a9bdd97b6ef806 [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
Reid Spencercc2d1e22004-10-30 09:19:36 +000015################################################################################
Reid Spencer3a561f52004-10-23 20:04:14 +000016# TARGETS: Define standard targets that can be invoked
Reid Spencercc2d1e22004-10-30 09:19:36 +000017################################################################################
John Criswell7a73b802003-06-30 21:59:07 +000018
Chris Lattner00950542001-06-06 20:29:01 +000019#--------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +000020# Define the various target sets
21#--------------------------------------------------------------------
Chris Lattner7dc02822004-12-03 21:05:57 +000022RecursiveTargets := all clean clean-all install uninstall install-bytecode
Reid Spencer9e8d54a2004-12-06 05:35:13 +000023LocalTargets := all-local clean-local clean-all-local check-local \
Reid Spencer44cb1b32004-12-03 20:08:48 +000024 install-local printvars uninstall-local \
25 install-bytecode-local
Reid Spencer9e8d54a2004-12-06 05:35:13 +000026TopLevelTargets := check dist dist-check dist-clean tags dist-gzip dist-bzip2 \
Reid Spencercc2d1e22004-10-30 09:19:36 +000027 dist-zip
28UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
29InternalTargets := preconditions distdir dist-hook
Reid Spencer3a561f52004-10-23 20:04:14 +000030
Reid Spencercc2d1e22004-10-30 09:19:36 +000031################################################################################
Reid Spencer9411c642004-10-26 22:26:33 +000032# INITIALIZATION: Basic things the makefile needs
Reid Spencercc2d1e22004-10-30 09:19:36 +000033################################################################################
34
35#--------------------------------------------------------------------
36# Set the VPATH so that we can find source files.
37#--------------------------------------------------------------------
38VPATH=$(BUILD_SRC_DIR)
Reid Spencer9411c642004-10-26 22:26:33 +000039
40#--------------------------------------------------------------------
41# Reset the list of suffixes we know how to build
42#--------------------------------------------------------------------
43.SUFFIXES:
Reid Spencercc2d1e22004-10-30 09:19:36 +000044.SUFFIXES: .c .cpp .h .hpp .y .l .lo .o .a .bc .td .ps .dot
45.SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
Reid Spencer9411c642004-10-26 22:26:33 +000046
Reid Spencer3a561f52004-10-23 20:04:14 +000047#--------------------------------------------------------------------
48# Mark all of these targets as phony to avoid implicit rule search
49#--------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000050.PHONY: $(UserTargets) $(InternalTargets)
Reid Spencer3a561f52004-10-23 20:04:14 +000051
52#--------------------------------------------------------------------
Reid Spencer9411c642004-10-26 22:26:33 +000053# Make sure all the user-target rules are double colon rules and
54# they are defined first.
Reid Spencer3a561f52004-10-23 20:04:14 +000055#--------------------------------------------------------------------
56
Reid Spencercc2d1e22004-10-30 09:19:36 +000057$(UserTargets)::
Reid Spencer151f8ba2004-10-25 08:27:37 +000058
Reid Spencer9411c642004-10-26 22:26:33 +000059################################################################################
60# PRECONDITIONS: that which must be built/checked first
61################################################################################
62
Reid Spencer44cb1b32004-12-03 20:08:48 +000063SrcMakefiles := $(filter %Makefile %Makefile.tests,\
Reid Spencer023c4462004-11-17 19:08:44 +000064 $(wildcard $(BUILD_SRC_DIR)/Makefile*))
Reid Spencercc2d1e22004-10-30 09:19:36 +000065ObjMakefiles := $(subst $(BUILD_SRC_DIR),$(BUILD_OBJ_DIR),$(SrcMakefiles))
66ConfigureScript := $(LLVM_SRC_ROOT)/configure
67ConfigStatusScript := $(LLVM_OBJ_ROOT)/config.status
68MakefileConfigIn := $(LLVM_SRC_ROOT)/Makefile.config.in
69MakefileConfig := $(LLVM_OBJ_ROOT)/Makefile.config
70PreConditions := $(ConfigStatusScript) $(MakefileConfig) $(ObjMakefiles)
Reid Spencer9411c642004-10-26 22:26:33 +000071
Reid Spencercc2d1e22004-10-30 09:19:36 +000072preconditions : $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +000073
74#------------------------------------------------------------------------
75# Make sure the BUILT_SOURCES are built first
76#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000077$(filter-out clean clean-local,UserTargets):: $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000078
79clean-local::
80ifneq ($(strip $(BUILT_SOURCES)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +000081 -$(Verb) $(RM) -f $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000082endif
83
Reid Spencercc2d1e22004-10-30 09:19:36 +000084$(BUILT_SOURCES) : $(ObjMakefiles)
Reid Spencer80f0ef72004-10-28 00:41:43 +000085
Reid Spencer9411c642004-10-26 22:26:33 +000086#------------------------------------------------------------------------
87# Make sure we're not using a stale configuration
88#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000089.PRECIOUS: $(ConfigStatusScript)
90$(ConfigStatusScript): $(ConfigureScript)
91 $(Echo) Reconfiguring with $<
Reid Spencer7d277002004-11-29 12:37:44 +000092 $(Verb) cd $(BUILD_OBJ_ROOT) && \
93 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
94 $(ConfigStatusScript)
Reid Spencer9411c642004-10-26 22:26:33 +000095
96#------------------------------------------------------------------------
97# Make sure the configuration makefile is up to date
98#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000099$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
100 $(Echo) Regenerating $@
101 $(Verb) cd $(LLVM_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
Reid Spencer9411c642004-10-26 22:26:33 +0000102
103#------------------------------------------------------------------------
104# If the Makefile in the source tree has been updated, copy it over into the
105# build tree. But, only do this if the source and object makefiles differ
106#------------------------------------------------------------------------
107ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
108
Reid Spencer023c4462004-11-17 19:08:44 +0000109Makefile: $(BUILD_SRC_DIR)/Makefile
Reid Spencercc2d1e22004-10-30 09:19:36 +0000110 $(Echo) "Updating Makefile"
111 $(Verb) $(MKDIR) $(@D)
112 $(Verb) cp -f $< $@
Reid Spencer9411c642004-10-26 22:26:33 +0000113
114# Copy the Makefile.* files unless we're in the root directory which avoids
115# the copying of Makefile.config.in or other things that should be explicitly
116# taken care of.
Reid Spencer9411c642004-10-26 22:26:33 +0000117$(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
Reid Spencer86606782004-10-26 23:10:00 +0000118 @case '$?' in \
119 *Makefile.rules) ;; \
120 *.in) ;; \
Reid Spencercc2d1e22004-10-30 09:19:36 +0000121 *) $(Echo) "Updating $(@F)" ; \
Reid Spencer86606782004-10-26 23:10:00 +0000122 $(MKDIR) $(@D) ; \
123 cp -f $< $@ ;; \
124 esac
125
Reid Spencer9411c642004-10-26 22:26:33 +0000126endif
127
128#------------------------------------------------------------------------
129# Set up the basic dependencies
130#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000131$(UserTargets):: $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +0000132
133all:: all-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000134clean:: clean-local
Reid Spencer3d659492004-11-02 16:36:03 +0000135clean-all:: clean-local clean-all-local
Reid Spencer9411c642004-10-26 22:26:33 +0000136install:: install-local
137uninstall:: uninstall-local
Reid Spencer9411c642004-10-26 22:26:33 +0000138install-local:: all-local
Reid Spencer44cb1b32004-12-03 20:08:48 +0000139install-bytecode:: install-bytecode-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000140
141###############################################################################
142# VARIABLES: Set up various variables based on configuration data
143###############################################################################
144
145#--------------------------------------------------------------------
146# Variables derived from configuration we are building
Chris Lattner00950542001-06-06 20:29:01 +0000147#--------------------------------------------------------------------
148
Chris Lattner760da062003-03-14 20:25:22 +0000149ifdef ENABLE_PROFILING
Reid Spencer9af3b292004-11-01 07:50:27 +0000150 BuildMode := Profile
Reid Spencer519799e2004-12-08 04:34:51 +0000151 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
Reid Spencercc2d1e22004-10-30 09:19:36 +0000152 C.Flags := -O3 -DNDEBUG -pg
153 LD.Flags := -O3 -DNDEBUG -pg
Chris Lattner760da062003-03-14 20:25:22 +0000154else
155 ifdef ENABLE_OPTIMIZED
Reid Spencer9af3b292004-11-01 07:50:27 +0000156 BuildMode := Release
Reid Spencer519799e2004-12-08 04:34:51 +0000157 CXX.Flags := -O3 -DNDEBUG -finline-functions \
Reid Spencer2e2035b2004-12-08 04:26:23 +0000158 -felide-constructors -fomit-frame-pointer
Reid Spencercc2d1e22004-10-30 09:19:36 +0000159 C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
160 LD.Flags := -O3 -DNDEBUG
Chris Lattner760da062003-03-14 20:25:22 +0000161 else
Reid Spencer9af3b292004-11-01 07:50:27 +0000162 BuildMode := Debug
Reid Spencer519799e2004-12-08 04:34:51 +0000163 CXX.Flags := -g -D_DEBUG
Reid Spencercc2d1e22004-10-30 09:19:36 +0000164 C.Flags := -g -D_DEBUG
165 LD.Flags := -g -D_DEBUG
Reid Spencer4d71b662004-10-22 21:01:56 +0000166 KEEP_SYMBOLS := 1
Chris Lattner760da062003-03-14 20:25:22 +0000167 endif
168endif
169
Reid Spencercc2d1e22004-10-30 09:19:36 +0000170CXX.Flags += $(CXXFLAGS)
171C.Flags += $(CFLAGS)
172CPP.Flags += $(CPPFLAGS)
173LD.Flags += $(LDFLAGS)
174AR.Flags := cru
175LibTool.Flags := --tag=CXX
Reid Spencer3a561f52004-10-23 20:04:14 +0000176
177#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000178# Directory locations
Reid Spencer3a561f52004-10-23 20:04:14 +0000179#--------------------------------------------------------------------
Reid Spencer9af3b292004-11-01 07:50:27 +0000180ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000181LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer9a5acaf2004-11-18 20:04:39 +0000182ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer815cbcf2004-11-18 10:03:46 +0000183ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
184LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer9a5acaf2004-11-18 20:04:39 +0000185LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer815cbcf2004-11-18 10:03:46 +0000186LExmplDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
John Criswell7a73b802003-06-30 21:59:07 +0000187
Reid Spencer3a561f52004-10-23 20:04:14 +0000188#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000189# Full Paths To Compiled Tools and Utilities
Reid Spencer3a561f52004-10-23 20:04:14 +0000190#--------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000191EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
192Echo := @$(EchoCmd)
193ifndef LIBTOOL
Reid Spencer4d71b662004-10-22 21:01:56 +0000194LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencercc2d1e22004-10-30 09:19:36 +0000195endif
196ifndef LLVMAS
197LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
198endif
199ifndef BURG
200BURG := $(LLVMToolDir)/burg$(EXEEXT)
201endif
202ifndef TBLGEN
203TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
204endif
Chris Lattner478b3b42004-11-29 19:47:58 +0000205ifndef GCCAS
206GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
207endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000208ifndef GCCLD
209GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
210endif
211ifndef LLVMGCC
212LLVMGCC := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/gcc
213endif
214ifndef LLVMGXX
215LLVMGXX := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/g++
216endif
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000217
Reid Spencer3a561f52004-10-23 20:04:14 +0000218#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000219# Adjust to user's request
Reid Spencer3a561f52004-10-23 20:04:14 +0000220#--------------------------------------------------------------------
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000221
Reid Spencercc2d1e22004-10-30 09:19:36 +0000222# Adjust LIBTOOL flags for shared libraries, or not.
John Criswell82f4a5a2003-07-31 20:58:51 +0000223ifndef SHARED_LIBRARY
Reid Spencercc2d1e22004-10-30 09:19:36 +0000224 LibTool.Flags += --tag=disable-shared
Reid Spencer4d71b662004-10-22 21:01:56 +0000225else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000226 LD.Flags += -rpath $(LibDir)
John Criswell82f4a5a2003-07-31 20:58:51 +0000227endif
228
Reid Spencercceed9f2004-11-08 17:32:12 +0000229ifdef TOOL_VERBOSE
230 C.Flags += -v
231 CXX.Flags += -v
232 LD.Flags += -v
Reid Spencercceed9f2004-11-08 17:32:12 +0000233 VERBOSE := 1
234endif
235
Reid Spencer3a561f52004-10-23 20:04:14 +0000236# Adjust settings for verbose mode
Chris Lattner760da062003-03-14 20:25:22 +0000237ifndef VERBOSE
Reid Spencercc2d1e22004-10-30 09:19:36 +0000238 Verb := @
239 LibTool.Flags += --silent
240 AR.Flags += >/dev/null 2>/dev/null
241 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
Reid Spencer151f8ba2004-10-25 08:27:37 +0000242else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000243 ConfigureScriptFLAGS :=
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000244endif
245
Vikram S. Advefeeae582002-09-18 11:55:13 +0000246# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000247ifndef KEEP_SYMBOLS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000248 Strip := $(PLATFORMSTRIPOPTS)
249 StripWarnMsg := "(without symbols)"
Vikram S. Advefeeae582002-09-18 11:55:13 +0000250endif
251
Reid Spencer3a561f52004-10-23 20:04:14 +0000252# Adjust linker flags for building an executable
Reid Spencer4d71b662004-10-22 21:01:56 +0000253ifdef TOOLNAME
Reid Spencer815cbcf2004-11-18 10:03:46 +0000254ifdef EXAMPLE_TOOL
255 LD.Flags += -rpath $(ExmplDir) -export-dynamic
256else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000257 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000258endif
Reid Spencer815cbcf2004-11-18 10:03:46 +0000259endif
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000260
Reid Spencer3a561f52004-10-23 20:04:14 +0000261#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000262# Options To Invoke Tools
Reid Spencer3a561f52004-10-23 20:04:14 +0000263#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000264
265CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
266
Reid Spencercc2d1e22004-10-30 09:19:36 +0000267LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
268CPP.Flags += -I$(BUILD_OBJ_DIR) \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000269 -I$(BUILD_SRC_DIR) \
270 -I$(BUILD_SRC_ROOT)/include \
271 -I$(BUILD_OBJ_ROOT)/include \
272 -I$(LLVM_OBJ_ROOT)/include \
273 -I$(LLVM_SRC_ROOT)/include \
274 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
Reid Spencer4d71b662004-10-22 21:01:56 +0000275
Reid Spencercc2d1e22004-10-30 09:19:36 +0000276Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
277LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
278BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
279Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
280LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
281BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
282Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
283 $(CompileCommonOpts) $(LD.Flags) $(Strip)
284Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencera69b1ea2004-10-28 09:15:28 +0000285 $(CompileCommonOpts)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000286LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
Reid Spencer3a561f52004-10-23 20:04:14 +0000287Burg = $(BURG) -I $(BUILD_SRC_DIR)
288TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000289Archive = $(AR) $(AR.Flags)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000290LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencer4d71b662004-10-22 21:01:56 +0000291ifdef RANLIB
Reid Spencer3a561f52004-10-23 20:04:14 +0000292Ranlib = $(RANLIB)
Reid Spencer4d71b662004-10-22 21:01:56 +0000293else
Reid Spencer3a561f52004-10-23 20:04:14 +0000294Ranlib = ranlib
John Criswell7a73b802003-06-30 21:59:07 +0000295endif
296
Chris Lattner00950542001-06-06 20:29:01 +0000297#----------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +0000298# Get the list of source files and compute object file
299# names from them.
Reid Spencer3a561f52004-10-23 20:04:14 +0000300#----------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +0000301ifdef FAKE_SOURCES
302 Sources :=
303 FakeSources := $(FAKE_SOURCES)
304 ifdef BUILT_SOURCES
305 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
306 endif
307 BaseNameSources := $(sort $(basename $(FakeSources)))
308 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
309 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
310 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000311else
Reid Spencer345235ca2004-12-04 22:34:09 +0000312 ifndef SOURCES
313 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
314 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
315 $(BUILD_SRC_DIR)/*.l))
316 else
317 Sources := $(SOURCES)
318 endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000319
Reid Spencer345235ca2004-12-04 22:34:09 +0000320 ifdef BUILT_SOURCES
321 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
322 endif
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000323
Reid Spencer345235ca2004-12-04 22:34:09 +0000324 BaseNameSources := $(sort $(basename $(Sources)))
325 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
326 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
327 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
328endif
Reid Spencer3a561f52004-10-23 20:04:14 +0000329
330###############################################################################
331# DIRECTORIES: Handle recursive descent of directory structure
332###############################################################################
John Criswell82f4a5a2003-07-31 20:58:51 +0000333
Chris Lattner00950542001-06-06 20:29:01 +0000334#---------------------------------------------------------
Reid Spencera69b1ea2004-10-28 09:15:28 +0000335# Provide rules to make install dirs. This must be early
336# in the file so they get built before dependencies
337#---------------------------------------------------------
338
339$(bindir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000340 $(Verb) $(MKDIR) $(bindir)
Chris Lattnere4cb90f2004-11-01 06:14:59 +0000341
Reid Spencera69b1ea2004-10-28 09:15:28 +0000342$(libdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000343 $(Verb) $(MKDIR) $(libdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000344
Reid Spencerab3690b2004-12-13 07:38:07 +0000345$(includedir):
346 $(Verb) $(MKDIR) $(includedir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000347
348$(sysconfdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000349 $(Verb) $(MKDIR) $(sysconfdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000350
Reid Spencercc2d1e22004-10-30 09:19:36 +0000351# To create other directories, as needed, and timestamp their creation
352%/.dir:
353 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfbbf3072004-11-29 05:00:33 +0000354 $(Verb) $(DATE) > $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000355
Reid Spencer815cbcf2004-11-18 10:03:46 +0000356.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
357.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000358
359#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000360# Handle the DIRS options for sequential construction
Chris Lattner00950542001-06-06 20:29:01 +0000361#---------------------------------------------------------
362
Reid Spencercc2d1e22004-10-30 09:19:36 +0000363SubDirs :=
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000364ifdef DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000365SubDirs += $(DIRS)
366$(RecursiveTargets)::
367 $(Verb) for dir in $(DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000368 if [ ! -f $$dir/Makefile ]; then \
369 $(MKDIR) $$dir; \
370 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
371 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000372 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
373 ($(MAKE) -C $$dir $@ ) || exit 1; \
374 fi ; \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000375 done
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000376endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000377
Reid Spencer3a561f52004-10-23 20:04:14 +0000378#---------------------------------------------------------
379# Handle the EXPERIMENTAL_DIRS options ensuring success
380# after each directory is built.
381#---------------------------------------------------------
382ifdef EXPERIMENTAL_DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000383$(RecursiveTargets)::
384 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer3a561f52004-10-23 20:04:14 +0000385 if [ ! -f $$dir/Makefile ]; then \
386 $(MKDIR) $$dir; \
387 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
388 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000389 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
390 ($(MAKE) -C $$dir $@ ) || exit 0; \
391 fi ; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000392 done
393endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000394
Reid Spencer3a561f52004-10-23 20:04:14 +0000395#---------------------------------------------------------
396# Handle the PARALLEL_DIRS options for parallel construction
397#---------------------------------------------------------
398ifdef PARALLEL_DIRS
399
Reid Spencercc2d1e22004-10-30 09:19:36 +0000400SubDirs += $(PARALLEL_DIRS)
401
Reid Spencer44cb1b32004-12-03 20:08:48 +0000402# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencercc2d1e22004-10-30 09:19:36 +0000403all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
404clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000405clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000406install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000407uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencer44cb1b32004-12-03 20:08:48 +0000408install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000409
Reid Spencer345235ca2004-12-04 22:34:09 +0000410ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer3a561f52004-10-23 20:04:14 +0000411
Reid Spencer345235ca2004-12-04 22:34:09 +0000412$(ParallelTargets) :
Reid Spencercc2d1e22004-10-30 09:19:36 +0000413 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencer4d71b662004-10-22 21:01:56 +0000414 $(MKDIR) $(@D); \
415 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswellb3866b62003-11-25 19:32:22 +0000416 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000417 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
418 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
419 fi
Chris Lattner00950542001-06-06 20:29:01 +0000420endif
421
Reid Spencer3a561f52004-10-23 20:04:14 +0000422#---------------------------------------------------------
423# Handle the OPTIONAL_DIRS options for directores that may
424# or may not exist.
425#---------------------------------------------------------
John Criswell2a6530f2003-06-27 16:58:44 +0000426ifdef OPTIONAL_DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000427
Reid Spencercc2d1e22004-10-30 09:19:36 +0000428SubDirs += $(OPTIONAL_DIRS)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000429
Reid Spencercc2d1e22004-10-30 09:19:36 +0000430$(RecursiveTargets)::
431 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000432 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
433 if [ ! -f $$dir/Makefile ]; then \
434 $(MKDIR) $$dir; \
435 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
436 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000437 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
438 ($(MAKE) -C$$dir $@ ) || exit 1; \
439 fi ; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000440 fi \
John Criswell2a6530f2003-06-27 16:58:44 +0000441 done
442endif
443
Reid Spencerfc945082004-08-20 09:20:05 +0000444#---------------------------------------------------------
445# Handle the CONFIG_FILES options
446#---------------------------------------------------------
447ifdef CONFIG_FILES
Reid Spencerfc945082004-08-20 09:20:05 +0000448
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000449install-local:: $(sysconfdir) $(CONFIG_FILES)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000450 $(Echo) Installing Configuration Files To $(sysconfdir)
451 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer1b426ab2004-11-23 05:59:53 +0000452 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
453 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
454 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
455 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
456 else \
457 $(ECHO) Error: cannot find config file $${file}. ; \
458 fi \
Reid Spencerfc945082004-08-20 09:20:05 +0000459 done
Reid Spencer3a561f52004-10-23 20:04:14 +0000460
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000461uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000462 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
463 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000464 $(RM) -f $(sysconfdir)/$${file} ; \
Reid Spencere5487ba2004-10-24 07:53:21 +0000465 done
466
Reid Spencerfc945082004-08-20 09:20:05 +0000467endif
468
Reid Spencer3a561f52004-10-23 20:04:14 +0000469###############################################################################
470# Library Build Rules: Four ways to build a library
471###############################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000472
Reid Spencer7980ea42004-12-05 05:17:22 +0000473#---------------------------------------------------------
474# Bytecode Module Targets:
475# If the user set MODULE_NAME then they want to build a
476# bytecode module from the sources. We compile all the
477# sources and link it together into a single bytecode
478# module.
479#---------------------------------------------------------
480
481ifdef MODULE_NAME
482
483Module := $(LibDir)/$(MODULE_NAME).bc
484LinkModule := $(LLVMGCC) -shared -nostdlib
485
486ifdef EXPORTED_SYMBOL_FILE
487LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
488endif
489
490$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
491 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
492 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
493
494all-local:: $(Module)
495
496clean-local::
497ifneq ($(strip $(Module)),)
498 -$(Verb) $(RM) -f $(Module)
499endif
500
Reid Spencerab3690b2004-12-13 07:38:07 +0000501ifdef BYTECODE_DESTINATION
502ModuleDestDir := $(BYTECODE_DESTINATION)
503else
504ModuleDestDir := $(BYTECODE_DESTINATION)
505endif
Reid Spencer7980ea42004-12-05 05:17:22 +0000506
Reid Spencerab3690b2004-12-13 07:38:07 +0000507DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
508
509install-module:: $(DestModule)
Reid Spencer7980ea42004-12-05 05:17:22 +0000510install-local:: $(DestModule)
511
Reid Spencerab3690b2004-12-13 07:38:07 +0000512$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencer7980ea42004-12-05 05:17:22 +0000513 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
514 $(Verb) $(INSTALL) $(Module) $@
515
516uninstall-local::
517 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
518 -$(Verb) $(RM) -f $(DestModule)
519
520endif
Brian Gaeke8abff792004-01-22 22:53:48 +0000521
Reid Spencer3a561f52004-10-23 20:04:14 +0000522# if we're building a library ...
Chris Lattner00950542001-06-06 20:29:01 +0000523ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000524
Chris Lattner2a548c52002-09-16 22:36:42 +0000525# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000526LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000527LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
528LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
529LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer9a2f1372004-12-02 09:28:21 +0000530LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000531
Reid Spencer3a561f52004-10-23 20:04:14 +0000532#---------------------------------------------------------
533# Shared Library Targets:
534# If the user asked for a shared library to be built
535# with the SHARED_LIBRARY variable, then we provide
536# targets for building them.
537#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000538ifdef SHARED_LIBRARY
539
Reid Spencercc2d1e22004-10-30 09:19:36 +0000540all-local:: $(LibName.LA)
Reid Spencer4d71b662004-10-22 21:01:56 +0000541
Reid Spencercc2d1e22004-10-30 09:19:36 +0000542$(LibName.LA): $(BUILT_SOURCES) $(ObjectsLO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000543 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000544 $(Verb) $(Link) -o $@ $(ObjectsLO)
545 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencer3a561f52004-10-23 20:04:14 +0000546
547clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000548ifneq ($(strip $(LibName.LA)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000549 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000550endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000551
Reid Spencere5487ba2004-10-24 07:53:21 +0000552DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencer4d71b662004-10-22 21:01:56 +0000553
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000554install-local:: $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000555
Reid Spencercc2d1e22004-10-30 09:19:36 +0000556$(DestSharedLib): $(libdir) $(LibName.LA)
Reid Spencer9af3b292004-11-01 07:50:27 +0000557 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000558 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
559 $(Verb) $(LIBTOOL) --finish $(libdir)
Reid Spencere5487ba2004-10-24 07:53:21 +0000560
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000561uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000562 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencer12d79512004-11-12 02:27:36 +0000563 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
Reid Spencere5487ba2004-10-24 07:53:21 +0000564
Reid Spencer4d71b662004-10-22 21:01:56 +0000565endif
566
Reid Spencer3a561f52004-10-23 20:04:14 +0000567#---------------------------------------------------------
568# Bytecode Library Targets:
569# If the user asked for a bytecode library to be built
570# with the BYTECODE_LIBRARY variable, then we provide
571# targets for building them.
572#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000573ifdef BYTECODE_LIBRARY
574
Reid Spencer776b8052004-12-03 06:04:35 +0000575# make the C and C++ compilers strip debug info out of bytecode libraries.
576BCCompile.C += -Wa,-strip-debug
577BCCompile.CXX += -Wa,-strip-debug
578
Reid Spencer9a2f1372004-12-02 09:28:21 +0000579all-local:: $(LibName.BCA)
580
581ifdef EXPORTED_SYMBOL_FILE
582BCLinkLib = $(LLVMGCC) -shared -nostdlib -Xlinker \
583 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
584
585$(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
586 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
587 "(internalize)"
Chris Lattnerb0ea8642004-12-02 21:23:43 +0000588 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencerefd6bb32004-12-13 03:59:35 +0000589 $(Verb) $(RM) -f $@
Reid Spencer9a2f1372004-12-02 09:28:21 +0000590 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencer4d71b662004-10-22 21:01:56 +0000591else
Reid Spencer345235ca2004-12-04 22:34:09 +0000592$(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir
Reid Spencer9a2f1372004-12-02 09:28:21 +0000593 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencerefd6bb32004-12-13 03:59:35 +0000594 $(Verb) $(RM) -f $@
Reid Spencer9a2f1372004-12-02 09:28:21 +0000595 $(Verb) $(LArchive) $@ $(ObjectsBC)
596
Reid Spencer4d71b662004-10-22 21:01:56 +0000597endif
598
Reid Spencer3a561f52004-10-23 20:04:14 +0000599clean-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000600ifneq ($(strip $(LibName.BCA)),)
601 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000602endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000603
Reid Spencer8f094f32004-12-13 07:28:21 +0000604ifdef BYTECODE_DESTINATION
605BytecodeDestDir := $(BYTECODE_DESTINATION)
606else
607BytecodeDestDir := $(libdir)
608endif
609
610DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
Reid Spencer9a2f1372004-12-02 09:28:21 +0000611
Reid Spencer44cb1b32004-12-03 20:08:48 +0000612install-bytecode-local:: $(DestBytecodeLib)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000613
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000614install-local:: $(DestBytecodeLib)
Chris Lattner481cc7c2003-08-15 02:18:35 +0000615
Reid Spencer8f094f32004-12-13 07:28:21 +0000616$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000617 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
618 $(Verb) $(INSTALL) $(LibName.BCA) $@
Reid Spencere5487ba2004-10-24 07:53:21 +0000619
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000620uninstall-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000621 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000622 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000623
624endif
Vikram S. Adve60f56062002-08-02 18:34:12 +0000625
Reid Spencercc2d1e22004-10-30 09:19:36 +0000626#---------------------------------------------------------
627# ReLinked Library Targets:
628# If the user didn't explicitly forbid building a
629# relinked then we provide targets for building them.
630#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000631ifndef DONT_BUILD_RELINKED
Reid Spencer4d71b662004-10-22 21:01:56 +0000632
Reid Spencercc2d1e22004-10-30 09:19:36 +0000633all-local:: $(LibName.O)
634
635$(LibName.O): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000636 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000637 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencer4d71b662004-10-22 21:01:56 +0000638
Reid Spencer3a561f52004-10-23 20:04:14 +0000639clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000640ifneq ($(strip $(LibName.O)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000641 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencere5487ba2004-10-24 07:53:21 +0000642endif
643
644DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
645
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000646install-local:: $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000647
Reid Spencercc2d1e22004-10-30 09:19:36 +0000648$(DestRelinkedLib): $(libdir) $(LibName.O)
Reid Spencer9af3b292004-11-01 07:50:27 +0000649 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000650 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000651
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000652uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000653 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000654 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000655
Chris Lattnere62dbe92002-07-23 17:56:16 +0000656endif
Chris Lattner760da062003-03-14 20:25:22 +0000657
Reid Spencercc2d1e22004-10-30 09:19:36 +0000658#---------------------------------------------------------
659# Archive Library Targets:
660# If the user wanted a regular archive library built,
661# then we provide targets for building them.
662#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000663ifdef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000664
Reid Spencercc2d1e22004-10-30 09:19:36 +0000665all-local:: $(LibName.A)
666
667$(LibName.A): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000668 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000669 -$(Verb) $(RM) -f $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000670 $(Verb) $(Archive) $@ $(ObjectsO)
671 $(Verb) $(Ranlib) $@
Vikram S. Adve41e78912002-09-20 14:03:13 +0000672
Reid Spencer3a561f52004-10-23 20:04:14 +0000673clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000674ifneq ($(strip $(LibName.A)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000675 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner00950542001-06-06 20:29:01 +0000676endif
677
Reid Spencere5487ba2004-10-24 07:53:21 +0000678DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
679
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000680install-local:: $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000681
Reid Spencercc2d1e22004-10-30 09:19:36 +0000682$(DestArchiveLib): $(libdir) $(LibName.A)
Reid Spencer9af3b292004-11-01 07:50:27 +0000683 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000684 $(Verb) $(MKDIR) $(libdir)
685 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000686
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000687uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000688 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000689 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000690
691endif
692
693# endif LIBRARYNAME
Reid Spencer4d71b662004-10-22 21:01:56 +0000694endif
695
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000696###############################################################################
697# Tool Build Rules: Build executable tool based on TOOLNAME option
698###############################################################################
699
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000700ifdef TOOLNAME
701
Reid Spencercc2d1e22004-10-30 09:19:36 +0000702#---------------------------------------------------------
Reid Spencer7c787c92004-11-29 07:17:07 +0000703# Handle the special "JIT" value for LLVM_LIBS which is a
704# shorthand for a bunch of libraries that get the correct
705# JIT support for a tool that runs JIT.
706#---------------------------------------------------------
707ifeq ($(LLVMLIBS),JIT)
708
709# Make sure we can get our own symbols in the tool
710Link += -dlopen self
711
712# Generic JIT libraries
713JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
714
715# You can enable the X86 JIT on a non-X86 host by setting the flag
716# ENABLE_X86_JIT on the make command line. If not, it will still be
717# enabled automagically on an X86 host.
718ifeq ($(ARCH), x86)
719 ENABLE_X86_JIT = 1
720endif
721
722# What the X86 JIT requires
723ifdef ENABLE_X86_JIT
724 JIT_LIBS += LLVMX86 LLVMSelectionDAG
725endif
726
727# You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
728# ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
729# enabled automagically on an SparcV9 host.
730ifeq ($(ARCH), Sparc)
731 ENABLE_SPARCV9_JIT = 1
732endif
733
734# What the Sparc JIT requires
735ifdef ENABLE_SPARCV9_JIT
736 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
737 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
738 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
739 LLVMDataStructure.a LLVMSparcV9RegAlloc
740endif
741
742# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
743# ENABLE_PPC_JIT on the make command line. If not, it will still be
744# enabled automagically on an PowerPC host.
745ifeq ($(ARCH), PowerPC)
746 ENABLE_PPC_JIT = 1
747endif
748
749# What the PowerPC JIT requires
750ifdef ENABLE_PPC_JIT
751 JIT_LIBS += LLVMPowerPC
752endif
753
754LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
755 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
756 LLVMSystem.a $(PLATFORMLIBDL)
757endif
758
759#---------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000760# Set up variables for building a tool.
761#---------------------------------------------------------
Reid Spencer815cbcf2004-11-18 10:03:46 +0000762ifdef EXAMPLE_TOOL
763ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
764else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000765ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000766endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000767ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
768ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
769LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
770LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
771ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
772LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
773ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
774LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000775
Reid Spencercc2d1e22004-10-30 09:19:36 +0000776#---------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000777# Tell make that we need to rebuild subdirectories before
778# we can link the tool. This affects things like LLI which
779# has library subdirectories.
780#---------------------------------------------------------
781$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000782
Reid Spencercc2d1e22004-10-30 09:19:36 +0000783#---------------------------------------------------------
784# Provide targets for building the tools
785#---------------------------------------------------------
786all-local:: $(ToolBuildPath)
John Criswell2a6530f2003-06-27 16:58:44 +0000787
Reid Spencer3a561f52004-10-23 20:04:14 +0000788clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000789ifneq ($(strip $(ToolBuildPath)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000790 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencere5487ba2004-10-24 07:53:21 +0000791endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000792
Reid Spencer815cbcf2004-11-18 10:03:46 +0000793ifdef EXAMPLE_TOOL
794$(ToolBuildPath): $(ExmplDir)/.dir
795else
796$(ToolBuildPath): $(ToolDir)/.dir
797endif
798
799$(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencer9af3b292004-11-01 07:50:27 +0000800 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000801 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
802 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
Reid Spencer9af3b292004-11-01 07:50:27 +0000803 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencere5487ba2004-10-24 07:53:21 +0000804
805DestTool = $(bindir)/$(TOOLNAME)
806
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000807install-local:: $(DestTool)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000808
Reid Spencercc2d1e22004-10-30 09:19:36 +0000809$(DestTool): $(bindir) $(ToolBuildPath)
Reid Spencer9af3b292004-11-01 07:50:27 +0000810 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000811 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000812
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000813uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000814 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000815 -$(Verb) $(RM) -f $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000816
Reid Spencer4d71b662004-10-22 21:01:56 +0000817endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000818
Reid Spencercc2d1e22004-10-30 09:19:36 +0000819###############################################################################
820# Object Build Rules: Build object files based on sources
821###############################################################################
822
823# Provide rule sets for when dependency generation is enabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000824ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve41e78912002-09-20 14:03:13 +0000825
Reid Spencercc2d1e22004-10-30 09:19:36 +0000826#---------------------------------------------------------
827# Create .lo files in the ObjDir directory from the .cpp and .c files...
828#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000829ifdef SHARED_LIBRARY
830
Reid Spencercc2d1e22004-10-30 09:19:36 +0000831$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000832 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000833 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
834 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
835 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000836
Reid Spencercc2d1e22004-10-30 09:19:36 +0000837$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000838 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000839 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
840 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
841 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000842
Reid Spencercc2d1e22004-10-30 09:19:36 +0000843#---------------------------------------------------------
844# Create .o files in the ObjDir directory from the .cpp and .c files...
845#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000846else
Reid Spencer4d71b662004-10-22 21:01:56 +0000847
Reid Spencercc2d1e22004-10-30 09:19:36 +0000848$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000849 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000850 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
851 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
852 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000853
Reid Spencercc2d1e22004-10-30 09:19:36 +0000854$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000855 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000856 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
857 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
858 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000859
860endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000861
Reid Spencercc2d1e22004-10-30 09:19:36 +0000862#---------------------------------------------------------
863# Create .bc files in the ObjDir directory from .cpp and .c files...
864#---------------------------------------------------------
Chris Lattner478b3b42004-11-29 19:47:58 +0000865$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000866 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000867 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
868 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
869 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000870
Chris Lattner478b3b42004-11-29 19:47:58 +0000871$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000872 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000873 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
874 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
875 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000876
Reid Spencercc2d1e22004-10-30 09:19:36 +0000877# Provide alternate rule sets if dependencies are disabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000878else
879
Reid Spencer3a561f52004-10-23 20:04:14 +0000880ifdef SHARED_LIBRARY
881
Reid Spencercc2d1e22004-10-30 09:19:36 +0000882$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000883 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000884 $(LTCompile.CXX) $< -o $@
885
Reid Spencercc2d1e22004-10-30 09:19:36 +0000886$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000887 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000888 $(LTCompile.C) $< -o $@
889
890else
Reid Spencer4d71b662004-10-22 21:01:56 +0000891
Reid Spencercc2d1e22004-10-30 09:19:36 +0000892$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000893 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +0000894 $(Compile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000895
Reid Spencercc2d1e22004-10-30 09:19:36 +0000896$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000897 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +0000898 $(Compile.C) $< -o $@
899endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000900
Chris Lattner478b3b42004-11-29 19:47:58 +0000901$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000902 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencer8676b7e2004-10-31 18:52:15 +0000903 $(BCCompile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000904
Chris Lattner478b3b42004-11-29 19:47:58 +0000905$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000906 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencer8676b7e2004-10-31 18:52:15 +0000907 $(BCCompile.C) $< -o $@
Brian Gaeke44909cf2003-12-10 00:26:28 +0000908
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000909endif
910
Reid Spencercc2d1e22004-10-30 09:19:36 +0000911#---------------------------------------------------------
912# Provide rule to build .bc files from .ll sources,
913# regardless of dependencies
914#---------------------------------------------------------
915$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000916 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000917 $(Verb) $(LLVMAS) $< -f -o $@
918
919###############################################################################
920# TABLEGEN: Provide rules for running tblgen to produce *.inc files
921###############################################################################
Chris Lattner481cc7c2003-08-15 02:18:35 +0000922
Reid Spencer4d71b662004-10-22 21:01:56 +0000923ifdef TARGET
924
Reid Spencercc2d1e22004-10-30 09:19:36 +0000925TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
926INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Reid Spencer4d71b662004-10-22 21:01:56 +0000927
Reid Spencercc2d1e22004-10-30 09:19:36 +0000928$(INCFiles) : $(TBLGEN) $(TDFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +0000929
Reid Spencer16544482004-10-27 04:34:35 +0000930%GenRegisterNames.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000931 $(Echo) "Building $(<F) register names with tblgen"
932 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000933
Reid Spencer16544482004-10-27 04:34:35 +0000934%GenRegisterInfo.h.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000935 $(Echo) "Building $(<F) register information header with tblgen"
936 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000937
938%GenRegisterInfo.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000939 $(Echo) "Building $(<F) register info implementation with tblgen"
940 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000941
942%GenInstrNames.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000943 $(Echo) "Building $(<F) instruction names with tblgen"
944 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000945
946%GenInstrInfo.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000947 $(Echo) "Building $(<F) instruction information with tblgen"
948 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000949
950%GenAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000951 $(Echo) "Building $(<F) assembly writer with tblgen"
952 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000953
954%GenATTAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000955 $(Echo) "Building $(<F) AT&T assembly writer with tblgen"
956 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000957
958%GenIntelAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000959 $(Echo) "Building $(<F) Intel assembly writer with tblgen"
960 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000961
962%GenInstrSelector.inc: %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000963 $(Echo) "Building $(<F) instruction selector with tblgen"
964 $(Verb) $(TableGen) -gen-instr-selector -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000965
966%GenCodeEmitter.inc:: %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000967 $(Echo) "Building $(<F) code emitter with tblgen"
968 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000969
Reid Spencer3a561f52004-10-23 20:04:14 +0000970clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000971 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +0000972
973endif
Chris Lattner481cc7c2003-08-15 02:18:35 +0000974
Reid Spencercc2d1e22004-10-30 09:19:36 +0000975###############################################################################
976# LEX AND YACC: Provide rules for generating sources with lex and yacc
977###############################################################################
Chris Lattnere8996782003-01-16 22:44:19 +0000978
Reid Spencercc2d1e22004-10-30 09:19:36 +0000979#---------------------------------------------------------
980# Provide rules for generating a .cpp source file from
981# (f)lex input sources.
982#---------------------------------------------------------
983
Reid Spencer3d659492004-11-02 16:36:03 +0000984LexFiles := $(filter %.l,$(Sources))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000985
Reid Spencer3d659492004-11-02 16:36:03 +0000986ifneq ($(LexFiles),)
987
988LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000989
990.PRECIOUS: $(LexOutput)
991
992# Note the extra sed filtering here, used to cut down on the warnings emited
993# by GCC. The last line is a gross hack to work around flex aparently not
994# being able to resize the buffer on a large token input. Currently, for
995# uninitialized string buffers in LLVM we can generate very long tokens, so
996# this is a hack around it.
Chris Lattnerb7dc2b92003-08-15 20:00:47 +0000997# FIXME. (f.e. char Buffer[10000] )
Chris Lattner00950542001-06-06 20:29:01 +0000998%.cpp: %.l
Reid Spencerc2ef8cd2004-12-10 19:44:16 +0000999 $(Echo) Flexing $*.l
Reid Spencercc2d1e22004-10-30 09:19:36 +00001000 $(Verb) $(FLEX) -t $< | \
Reid Spencer4d71b662004-10-22 21:01:56 +00001001 $(SED) 's/void yyunput/inline void yyunput/' | \
1002 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1003 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencer80f0ef72004-10-28 00:41:43 +00001004 > $@
Chris Lattner00950542001-06-06 20:29:01 +00001005
Reid Spencer9af3b292004-11-01 07:50:27 +00001006clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001007 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencer3d659492004-11-02 16:36:03 +00001008 $(Verb) $(RM) -f $(LexOutput)
Reid Spencer9af3b292004-11-01 07:50:27 +00001009
Reid Spencercc2d1e22004-10-30 09:19:36 +00001010endif
1011
1012#---------------------------------------------------------
1013# Provide rules for generating a .cpp and .h source files
1014# from yacc (bison) input sources.
1015#---------------------------------------------------------
1016
Reid Spencer3d659492004-11-02 16:36:03 +00001017YaccFiles := $(filter %.y,$(Sources))
1018ifneq ($(YaccFiles),)
1019YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001020
1021.PRECIOUS: $(YaccOutput)
1022
1023# Cancel built-in rules for yacc
1024%.c: %.y
1025%.cpp: %.y
1026%.h: %.y
1027
Chris Lattner00950542001-06-06 20:29:01 +00001028# Rule for building the bison parsers...
Chris Lattner00950542001-06-06 20:29:01 +00001029%.cpp %.h : %.y
Reid Spencercc2d1e22004-10-30 09:19:36 +00001030 $(Echo) "Bisoning $*.y"
1031 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1032 $(Verb) $(MV) -f $*.tab.c $*.cpp
1033 $(Verb) $(MV) -f $*.tab.h $*.h
Chris Lattner00950542001-06-06 20:29:01 +00001034
Reid Spencer9af3b292004-11-01 07:50:27 +00001035clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001036 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencer3d659492004-11-02 16:36:03 +00001037 $(Verb) $(RM) -f $(YaccOutput)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001038endif
Chris Lattner00950542001-06-06 20:29:01 +00001039
Reid Spencercc2d1e22004-10-30 09:19:36 +00001040###############################################################################
1041# OTHER RULES: Other rules needed
1042###############################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +00001043
Chris Lattner30440c62003-01-16 21:06:18 +00001044# To create postscript files from dot files...
John Criswelle0f9ac62003-10-02 19:02:02 +00001045ifneq ($(DOT),false)
Chris Lattner30440c62003-01-16 21:06:18 +00001046%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +00001047 $(DOT) -Tps < $< > $@
John Criswell7a73b802003-06-30 21:59:07 +00001048else
1049%.ps: %.dot
Reid Spencercc2d1e22004-10-30 09:19:36 +00001050 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell7a73b802003-06-30 21:59:07 +00001051endif
Chris Lattner30440c62003-01-16 21:06:18 +00001052
John Criswell7f336952003-09-06 14:44:17 +00001053# This rules ensures that header files that are removed still have a rule for
1054# which they can be "generated." This allows make to ignore them and
1055# reproduce the dependency lists.
John Criswell4b6e5d12003-09-18 18:37:08 +00001056%.h:: ;
John Criswell7f336952003-09-06 14:44:17 +00001057
Reid Spencercc2d1e22004-10-30 09:19:36 +00001058# Define clean-local to clean the current directory. Note that this uses a
1059# very conservative approach ensuring that empty variables do not cause
1060# errors or disastrous removal.
Reid Spencer3a561f52004-10-23 20:04:14 +00001061clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001062ifneq ($(strip $(ObjDir)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001063 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencere5487ba2004-10-24 07:53:21 +00001064endif
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001065 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001066ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001067 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001068endif
John Criswell7a73b802003-06-30 21:59:07 +00001069
Reid Spencer3d659492004-11-02 16:36:03 +00001070clean-all-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001071 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer3d659492004-11-02 16:36:03 +00001072
Reid Spencercc2d1e22004-10-30 09:19:36 +00001073# Build tags database for Emacs/Xemacs:
Reid Spencer12d79512004-11-12 02:27:36 +00001074tags:: TAGS CTAGS
1075
Reid Spencercc2d1e22004-10-30 09:19:36 +00001076TAGS:
Reid Spencer12d79512004-11-12 02:27:36 +00001077 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1078 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1079 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1080 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1081 -name '*.cpp' -o -name '*.h' | \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001082 $(ETAGS) $(ETAGSFLAGS) -
1083
Reid Spencer12d79512004-11-12 02:27:36 +00001084CTAGS:
1085 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1086 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1087 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1088 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1089 \( -name '*.cpp' -o -name '*.h' \) -print | \
1090 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1091
1092
Reid Spencer3a561f52004-10-23 20:04:14 +00001093###############################################################################
1094# DEPENDENCIES: Include the dependency files if we should
1095###############################################################################
Chris Lattner33ad24a2003-08-22 14:10:16 +00001096ifndef DISABLE_AUTO_DEPENDENCIES
1097
Reid Spencer3a561f52004-10-23 20:04:14 +00001098# If its not one of the cleaning targets
Reid Spencercc2d1e22004-10-30 09:19:36 +00001099ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencer4d71b662004-10-22 21:01:56 +00001100
Reid Spencer3a561f52004-10-23 20:04:14 +00001101# Get the list of dependency files
Reid Spencercc2d1e22004-10-30 09:19:36 +00001102DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Reid Spencer9af3b292004-11-01 07:50:27 +00001103DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
Misha Brukman4f7a8cf2003-11-09 21:36:19 +00001104
Reid Spencer3a561f52004-10-23 20:04:14 +00001105-include /dev/null $(DependFiles)
1106
John Criswelld741bcf2003-08-12 18:51:51 +00001107endif
Chris Lattner1ddb6b62003-08-18 17:27:40 +00001108
Reid Spencercc2d1e22004-10-30 09:19:36 +00001109endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001110
Reid Spencer151f8ba2004-10-25 08:27:37 +00001111###############################################################################
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001112# CHECK: Running the test suite
1113###############################################################################
1114
1115check::
1116 $(Verb) if test -d "$(BUILD_OBJ_ROOT)/test" ; then \
1117 if test -f "$(BUILD_OBJ_ROOT)/test/Makefile" ; then \
1118 $(EchoCmd) Running test suite ; \
1119 $(MAKE) -C $(BUILD_OBJ_ROOT)/test check-local \
1120 TESTSUITE=$(TESTSUITE) ; \
1121 else \
1122 $(EchoCmd) No Makefile in test directory ; \
1123 fi ; \
1124 else \
1125 $(EchoCmd) No test directory ; \
1126 fi
1127
1128###############################################################################
Reid Spencercc2d1e22004-10-30 09:19:36 +00001129# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer151f8ba2004-10-25 08:27:37 +00001130###############################################################################
1131
Reid Spencere45ebfa2004-10-26 07:09:33 +00001132#------------------------------------------------------------------------
1133# Define distribution related variables
1134#------------------------------------------------------------------------
Reid Spencer151f8ba2004-10-25 08:27:37 +00001135DistName := $(LLVM_TARBALL_NAME)
1136DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001137TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer151f8ba2004-10-25 08:27:37 +00001138DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1139DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1140DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1141DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1142 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001143 Makefile.config.in configure autoconf
1144DistOther := $(notdir $(wildcard \
1145 $(BUILD_SRC_DIR)/*.h \
1146 $(BUILD_SRC_DIR)/*.td \
1147 $(BUILD_SRC_DIR)/*.def \
1148 $(BUILD_SRC_DIR)/*.ll \
1149 $(BUILD_SRC_DIR)/*.in))
Reid Spencercc2d1e22004-10-30 09:19:36 +00001150DistSubDirs := $(SubDirs)
Reid Spencerfbbf3072004-11-29 05:00:33 +00001151DistSources = $(Sources) $(EXTRA_DIST)
1152DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer151f8ba2004-10-25 08:27:37 +00001153
Reid Spencere45ebfa2004-10-26 07:09:33 +00001154#------------------------------------------------------------------------
1155# We MUST build distribution with OBJ_DIR != SRC_DIR
1156#------------------------------------------------------------------------
1157ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1158dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001159 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencere45ebfa2004-10-26 07:09:33 +00001160
Reid Spencere45ebfa2004-10-26 07:09:33 +00001161else
1162
Reid Spencere45ebfa2004-10-26 07:09:33 +00001163#------------------------------------------------------------------------
1164# Prevent catastrophic remove
1165#------------------------------------------------------------------------
1166ifeq ($(LLVM_TARBALL_NAME),)
1167$(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1168endif
1169
1170#------------------------------------------------------------------------
1171# Prevent attempt to run dist targets from anywhere but the top level
1172#------------------------------------------------------------------------
1173ifneq ($(LEVEL),.)
1174
1175dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001176 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001177
1178else
1179
1180#------------------------------------------------------------------------
1181# Provide the top level targets
1182#------------------------------------------------------------------------
1183
Reid Spencercc2d1e22004-10-30 09:19:36 +00001184dist-gzip:: $(DistTarGZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001185
Reid Spencer345235ca2004-12-04 22:34:09 +00001186$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001187 $(Echo) Packing gzipped distribution tar file.
Reid Spencerfbbf3072004-11-29 05:00:33 +00001188 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1189 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencere45ebfa2004-10-26 07:09:33 +00001190
Reid Spencercc2d1e22004-10-30 09:19:36 +00001191dist-bzip2:: $(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001192
Reid Spencer345235ca2004-12-04 22:34:09 +00001193$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001194 $(Echo) Packing bzipped distribution tar file.
Reid Spencerfbbf3072004-11-29 05:00:33 +00001195 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1196 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001197
Reid Spencercc2d1e22004-10-30 09:19:36 +00001198dist-zip:: $(DistZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001199
Reid Spencer345235ca2004-12-04 22:34:09 +00001200$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001201 $(Echo) Packing zipped distribution file.
1202 $(Verb) rm -f $(DistZip)
1203 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001204
1205dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001206 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001207
1208DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1209
Reid Spencer345235ca2004-12-04 22:34:09 +00001210dist-check:: $(DistTarGZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001211 $(Echo) Checking distribution tar file.
1212 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001213 $(RM) -rf $(DistCheckDir) ; \
1214 fi
Reid Spencercc2d1e22004-10-30 09:19:36 +00001215 $(Verb) $(MKDIR) $(DistCheckDir)
1216 $(Verb) cd $(DistCheckDir) && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001217 $(MKDIR) $(DistCheckDir)/build && \
1218 $(MKDIR) $(DistCheckDir)/install && \
1219 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1220 cd build && \
1221 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1222 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
Reid Spencer345235ca2004-12-04 22:34:09 +00001223 $(MAKE) all && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001224 $(MAKE) check && \
1225 $(MAKE) install && \
1226 $(MAKE) uninstall && \
1227 $(MAKE) dist && \
1228 $(MAKE) clean && \
1229 $(MAKE) dist-clean && \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001230 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001231
1232dist-clean::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001233 $(Echo) Cleaning distribution files
Reid Spencer345235ca2004-12-04 22:34:09 +00001234 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1235 $(DistCheckDir)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001236
1237endif
1238
1239#------------------------------------------------------------------------
1240# Provide the recursive distdir target for building the distribution directory
1241#------------------------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +00001242distdir: $(DistDir)/.makedistdir
1243$(DistDir)/.makedistdir: $(DistSources)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001244 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001245 if test -d "$(DistDir)" ; then \
1246 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1247 exit 1 ; \
1248 fi ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001249 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001250 $(RM) -rf $(DistDir); \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001251 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001252 $(MAKE) all ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001253 fi
Reid Spencerfbbf3072004-11-29 05:00:33 +00001254 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001255 $(Verb) $(MKDIR) $(DistDir)
1256 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001257 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1258 for file in $(DistFiles) ; do \
1259 case "$$file" in \
Reid Spencer345235ca2004-12-04 22:34:09 +00001260 $(BUILD_SRC_DIR)/*) \
1261 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1262 ;; \
1263 $(BUILD_SRC_ROOT)/*) \
1264 file=`echo "$$file" | \
1265 sed "s#^$$srcrootstrip/##"` \
1266 ;; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001267 esac; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001268 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1269 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1270 from_dir="$(BUILD_SRC_DIR)" ; \
1271 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001272 from_dir=. ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001273 fi ; \
1274 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001275 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1276 to_dir="$(DistDir)/$$dir"; \
1277 $(MKDIR) "$$to_dir" ; \
1278 else \
1279 to_dir="$(DistDir)"; \
1280 fi; \
1281 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1282 if test -n "$$mid_dir" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001283 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001284 fi ; \
1285 if test -d "$$from_dir/$$file"; then \
1286 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1287 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1288 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1289 fi; \
1290 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1291 elif test -f "$$from_dir/$$file" ; then \
1292 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1293 elif test -L "$$from_dir/$$file" ; then \
1294 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1295 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer345235ca2004-12-04 22:34:09 +00001296 $(EchoCmd) "===== WARNING: Distribution Source " \
1297 "$$from_dir/$$file Not Found!" ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001298 elif test "$(Verb)" != '@' ; then \
1299 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001300 fi; \
1301 done
Reid Spencercc2d1e22004-10-30 09:19:36 +00001302 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001303 if test "$$subdir" \!= "." ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001304 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001305 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001306 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1307 exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001308 fi; \
1309 done
Reid Spencer345235ca2004-12-04 22:34:09 +00001310 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1311 $(EchoCmd) Eliminating CVS directories from distribution ; \
1312 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1313 $(MAKE) dist-hook ; \
1314 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1315 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1316 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1317 -o ! -type d ! -perm -444 -exec \
1318 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1319 || chmod -R a+r $(DistDir) ; \
1320 fi
Reid Spencer151f8ba2004-10-25 08:27:37 +00001321
Reid Spencercc2d1e22004-10-30 09:19:36 +00001322# This is invoked by distdir target, define it as a no-op to avoid errors if not
1323# defined by user.
Reid Spencer151f8ba2004-10-25 08:27:37 +00001324dist-hook::
1325
Reid Spencere53e3972004-10-22 23:06:30 +00001326endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001327
1328###############################################################################
Reid Spencere5487ba2004-10-24 07:53:21 +00001329# TOP LEVEL - targets only to apply at the top level directory
1330###############################################################################
1331
1332ifeq ($(LEVEL),.)
1333
1334#------------------------------------------------------------------------
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001335# Install support for the project's include files:
Reid Spencere5487ba2004-10-24 07:53:21 +00001336#------------------------------------------------------------------------
1337install-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001338 $(Echo) Installing include files
1339 $(Verb) $(MKDIR) $(includedir)
1340 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencere5487ba2004-10-24 07:53:21 +00001341 cd $(BUILD_SRC_ROOT)/include && \
1342 find . -path '*/Internal' -prune -o '(' -type f \
1343 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1344 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1345 fi
1346
1347uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001348 $(Echo) Uninstalling include files
1349 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencere5487ba2004-10-24 07:53:21 +00001350 cd $(BUILD_SRC_ROOT)/include && \
1351 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1352 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1353 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1354 fi
1355
Reid Spencere5487ba2004-10-24 07:53:21 +00001356endif
1357
Reid Spencer4d71b662004-10-22 21:01:56 +00001358#------------------------------------------------------------------------
1359# Print out the directories used for building
Reid Spencercc2d1e22004-10-30 09:19:36 +00001360#------------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001361printvars::
Reid Spencer9af3b292004-11-01 07:50:27 +00001362 $(Echo) "BuildMode : " '$(BuildMode)'
Reid Spencercc2d1e22004-10-30 09:19:36 +00001363 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1364 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1365 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1366 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1367 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1368 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1369 $(Echo) "libdir : " '$(libdir)'
1370 $(Echo) "bindir : " '$(bindir)'
1371 $(Echo) "sysconfdir : " '$(sysconfdir)'
Reid Spencercc2d1e22004-10-30 09:19:36 +00001372 $(Echo) "UserTargets : " '$(UserTargets)'
1373 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1374 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1375 $(Echo) "ObjDir : " '$(ObjDir)'
1376 $(Echo) "LibDir : " '$(LibDir)'
1377 $(Echo) "ToolDir : " '$(ToolDir)'
Reid Spencer815cbcf2004-11-18 10:03:46 +00001378 $(Echo) "ExmplDir : " '$(ExmplDir)'
Reid Spencer7980ea42004-12-05 05:17:22 +00001379 $(Echo) "Sources : " '$(Sources)'
Reid Spencercc2d1e22004-10-30 09:19:36 +00001380 $(Echo) "TDFiles : " '$(TDFiles)'
1381 $(Echo) "INCFiles : " '$(INCFiles)'
1382 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1383 $(Echo) "Compile.C : " '$(Compile.C)'
1384 $(Echo) "Archive : " '$(Archive)'
Reid Spencer3d659492004-11-02 16:36:03 +00001385 $(Echo) "YaccFiles : " '$(YaccFiles)'
1386 $(Echo) "LexFiles : " '$(LexFiles)'
Reid Spencer7980ea42004-12-05 05:17:22 +00001387 $(Echo) "Module : " '$(Module)'