blob: 9abc4afc23549bfdaae33c4f3c07fb70bbf7c685 [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
Reid Spencerf88808a2004-10-30 09:19:36 +000015################################################################################
Reid Spencer81cd0492004-10-23 20:04:14 +000016# TARGETS: Define standard targets that can be invoked
Reid Spencerf88808a2004-10-30 09:19:36 +000017################################################################################
John Criswell3ef61af2003-06-30 21:59:07 +000018
Chris Lattner2f7c9632001-06-06 20:29:01 +000019#--------------------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +000020# Define the various target sets
21#--------------------------------------------------------------------
Chris Lattner661a7142004-12-03 21:05:57 +000022RecursiveTargets := all clean clean-all install uninstall install-bytecode
Reid Spencer8b5ebe52004-12-06 05:35:13 +000023LocalTargets := all-local clean-local clean-all-local check-local \
Reid Spencerd4bd3752004-12-03 20:08:48 +000024 install-local printvars uninstall-local \
25 install-bytecode-local
Reid Spencer8b5ebe52004-12-06 05:35:13 +000026TopLevelTargets := check dist dist-check dist-clean tags dist-gzip dist-bzip2 \
Reid Spencerf88808a2004-10-30 09:19:36 +000027 dist-zip
28UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
29InternalTargets := preconditions distdir dist-hook
Reid Spencer81cd0492004-10-23 20:04:14 +000030
Reid Spencerf88808a2004-10-30 09:19:36 +000031################################################################################
Reid Spencer77a46d22004-10-26 22:26:33 +000032# INITIALIZATION: Basic things the makefile needs
Reid Spencerf88808a2004-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 Spencer77a46d22004-10-26 22:26:33 +000039
40#--------------------------------------------------------------------
41# Reset the list of suffixes we know how to build
42#--------------------------------------------------------------------
43.SUFFIXES:
Reid Spencerf88808a2004-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 Spencer77a46d22004-10-26 22:26:33 +000046
Reid Spencer81cd0492004-10-23 20:04:14 +000047#--------------------------------------------------------------------
48# Mark all of these targets as phony to avoid implicit rule search
49#--------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +000050.PHONY: $(UserTargets) $(InternalTargets)
Reid Spencer81cd0492004-10-23 20:04:14 +000051
52#--------------------------------------------------------------------
Reid Spencer77a46d22004-10-26 22:26:33 +000053# Make sure all the user-target rules are double colon rules and
54# they are defined first.
Reid Spencer81cd0492004-10-23 20:04:14 +000055#--------------------------------------------------------------------
56
Reid Spencerf88808a2004-10-30 09:19:36 +000057$(UserTargets)::
Reid Spencer100080c2004-10-25 08:27:37 +000058
Reid Spencer77a46d22004-10-26 22:26:33 +000059################################################################################
60# PRECONDITIONS: that which must be built/checked first
61################################################################################
62
Reid Spencerd4bd3752004-12-03 20:08:48 +000063SrcMakefiles := $(filter %Makefile %Makefile.tests,\
Reid Spencer91234ff2004-11-17 19:08:44 +000064 $(wildcard $(BUILD_SRC_DIR)/Makefile*))
Reid Spencerf88808a2004-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 Spencer77a46d22004-10-26 22:26:33 +000071
Reid Spencerf88808a2004-10-30 09:19:36 +000072preconditions : $(PreConditions)
Reid Spencer77a46d22004-10-26 22:26:33 +000073
74#------------------------------------------------------------------------
75# Make sure the BUILT_SOURCES are built first
76#------------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +000077$(filter-out clean clean-local,UserTargets):: $(BUILT_SOURCES)
Reid Spencer77a46d22004-10-26 22:26:33 +000078
79clean-local::
80ifneq ($(strip $(BUILT_SOURCES)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +000081 -$(Verb) $(RM) -f $(BUILT_SOURCES)
Reid Spencer77a46d22004-10-26 22:26:33 +000082endif
83
Reid Spencerf88808a2004-10-30 09:19:36 +000084$(BUILT_SOURCES) : $(ObjMakefiles)
Reid Spencerb7f710a2004-10-28 00:41:43 +000085
Reid Spencer77a46d22004-10-26 22:26:33 +000086#------------------------------------------------------------------------
87# Make sure we're not using a stale configuration
88#------------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +000089.PRECIOUS: $(ConfigStatusScript)
90$(ConfigStatusScript): $(ConfigureScript)
91 $(Echo) Reconfiguring with $<
Reid Spencer50f34872004-11-29 12:37:44 +000092 $(Verb) cd $(BUILD_OBJ_ROOT) && \
93 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
94 $(ConfigStatusScript)
Reid Spencer77a46d22004-10-26 22:26:33 +000095
96#------------------------------------------------------------------------
97# Make sure the configuration makefile is up to date
98#------------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +000099$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
100 $(Echo) Regenerating $@
101 $(Verb) cd $(LLVM_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
Reid Spencer77a46d22004-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 Spencer91234ff2004-11-17 19:08:44 +0000109Makefile: $(BUILD_SRC_DIR)/Makefile
Reid Spencerf88808a2004-10-30 09:19:36 +0000110 $(Echo) "Updating Makefile"
111 $(Verb) $(MKDIR) $(@D)
112 $(Verb) cp -f $< $@
Reid Spencer77a46d22004-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 Spencer77a46d22004-10-26 22:26:33 +0000117$(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
Reid Spencerd94bb332004-10-26 23:10:00 +0000118 @case '$?' in \
119 *Makefile.rules) ;; \
120 *.in) ;; \
Reid Spencerf88808a2004-10-30 09:19:36 +0000121 *) $(Echo) "Updating $(@F)" ; \
Reid Spencerd94bb332004-10-26 23:10:00 +0000122 $(MKDIR) $(@D) ; \
123 cp -f $< $@ ;; \
124 esac
125
Reid Spencer77a46d22004-10-26 22:26:33 +0000126endif
127
128#------------------------------------------------------------------------
129# Set up the basic dependencies
130#------------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000131$(UserTargets):: $(PreConditions)
Reid Spencer77a46d22004-10-26 22:26:33 +0000132
133all:: all-local
Reid Spencer81cd0492004-10-23 20:04:14 +0000134clean:: clean-local
Reid Spencer9d0c1e02004-11-02 16:36:03 +0000135clean-all:: clean-local clean-all-local
Reid Spencer77a46d22004-10-26 22:26:33 +0000136install:: install-local
137uninstall:: uninstall-local
Reid Spencer77a46d22004-10-26 22:26:33 +0000138install-local:: all-local
Reid Spencerd4bd3752004-12-03 20:08:48 +0000139install-bytecode:: install-bytecode-local
Reid Spencer81cd0492004-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 Lattner2f7c9632001-06-06 20:29:01 +0000147#--------------------------------------------------------------------
148
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000149ifdef ENABLE_PROFILING
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000150 BuildMode := Profile
Reid Spencercd7d6cf2004-12-08 04:34:51 +0000151 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
Reid Spencerf88808a2004-10-30 09:19:36 +0000152 C.Flags := -O3 -DNDEBUG -pg
153 LD.Flags := -O3 -DNDEBUG -pg
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000154else
155 ifdef ENABLE_OPTIMIZED
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000156 BuildMode := Release
Reid Spencercd7d6cf2004-12-08 04:34:51 +0000157 CXX.Flags := -O3 -DNDEBUG -finline-functions \
Reid Spencercc52c2c2004-12-08 04:26:23 +0000158 -felide-constructors -fomit-frame-pointer
Reid Spencerf88808a2004-10-30 09:19:36 +0000159 C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
160 LD.Flags := -O3 -DNDEBUG
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000161 else
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000162 BuildMode := Debug
Reid Spencercd7d6cf2004-12-08 04:34:51 +0000163 CXX.Flags := -g -D_DEBUG
Reid Spencerf88808a2004-10-30 09:19:36 +0000164 C.Flags := -g -D_DEBUG
165 LD.Flags := -g -D_DEBUG
Reid Spencerf206bd72004-10-22 21:01:56 +0000166 KEEP_SYMBOLS := 1
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000167 endif
168endif
169
Reid Spencerf88808a2004-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 Spencer81cd0492004-10-23 20:04:14 +0000176
177#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000178# Directory locations
Reid Spencer81cd0492004-10-23 20:04:14 +0000179#--------------------------------------------------------------------
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000180ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000181LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer0dbf1012004-11-18 20:04:39 +0000182ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000183ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
184LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer0dbf1012004-11-18 20:04:39 +0000185LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000186LExmplDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
John Criswell3ef61af2003-06-30 21:59:07 +0000187
Reid Spencer81cd0492004-10-23 20:04:14 +0000188#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000189# Full Paths To Compiled Tools and Utilities
Reid Spencer81cd0492004-10-23 20:04:14 +0000190#--------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000191EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
192Echo := @$(EchoCmd)
193ifndef LIBTOOL
Reid Spencerf206bd72004-10-22 21:01:56 +0000194LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencerf88808a2004-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 Lattner0ea40c92004-11-29 19:47:58 +0000205ifndef GCCAS
206GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
207endif
Reid Spencerf88808a2004-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 Dhurjati41f77482003-05-29 16:18:20 +0000217
Reid Spencer81cd0492004-10-23 20:04:14 +0000218#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000219# Adjust to user's request
Reid Spencer81cd0492004-10-23 20:04:14 +0000220#--------------------------------------------------------------------
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000221
Reid Spencerf88808a2004-10-30 09:19:36 +0000222# Adjust LIBTOOL flags for shared libraries, or not.
John Criswell3601f372003-07-31 20:58:51 +0000223ifndef SHARED_LIBRARY
Reid Spencerf88808a2004-10-30 09:19:36 +0000224 LibTool.Flags += --tag=disable-shared
Reid Spencerf206bd72004-10-22 21:01:56 +0000225else
Reid Spencerf88808a2004-10-30 09:19:36 +0000226 LD.Flags += -rpath $(LibDir)
John Criswell3601f372003-07-31 20:58:51 +0000227endif
228
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000229ifdef TOOL_VERBOSE
230 C.Flags += -v
231 CXX.Flags += -v
232 LD.Flags += -v
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000233 VERBOSE := 1
Reid Spencer32f7e422004-12-02 09:28:21 +0000234else
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000235endif
236
Reid Spencer81cd0492004-10-23 20:04:14 +0000237# Adjust settings for verbose mode
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000238ifndef VERBOSE
Reid Spencerf88808a2004-10-30 09:19:36 +0000239 Verb := @
240 LibTool.Flags += --silent
241 AR.Flags += >/dev/null 2>/dev/null
242 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
Reid Spencer100080c2004-10-25 08:27:37 +0000243else
Reid Spencerf88808a2004-10-30 09:19:36 +0000244 ConfigureScriptFLAGS :=
Misha Brukman1326a7c2002-09-12 16:05:39 +0000245endif
246
Vikram S. Adved141c282002-09-18 11:55:13 +0000247# By default, strip symbol information from executable
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000248ifndef KEEP_SYMBOLS
Reid Spencerf88808a2004-10-30 09:19:36 +0000249 Strip := $(PLATFORMSTRIPOPTS)
250 StripWarnMsg := "(without symbols)"
Vikram S. Adved141c282002-09-18 11:55:13 +0000251endif
252
Reid Spencer81cd0492004-10-23 20:04:14 +0000253# Adjust linker flags for building an executable
Reid Spencerf206bd72004-10-22 21:01:56 +0000254ifdef TOOLNAME
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000255ifdef EXAMPLE_TOOL
256 LD.Flags += -rpath $(ExmplDir) -export-dynamic
257else
Reid Spencerf88808a2004-10-30 09:19:36 +0000258 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000259endif
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000260endif
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000261
Reid Spencer81cd0492004-10-23 20:04:14 +0000262#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000263# Options To Invoke Tools
Reid Spencer81cd0492004-10-23 20:04:14 +0000264#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000265
266CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
267
Reid Spencerf88808a2004-10-30 09:19:36 +0000268LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
269CPP.Flags += -I$(BUILD_OBJ_DIR) \
Reid Spencer100080c2004-10-25 08:27:37 +0000270 -I$(BUILD_SRC_DIR) \
271 -I$(BUILD_SRC_ROOT)/include \
272 -I$(BUILD_OBJ_ROOT)/include \
273 -I$(LLVM_OBJ_ROOT)/include \
274 -I$(LLVM_SRC_ROOT)/include \
275 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
Reid Spencerf206bd72004-10-22 21:01:56 +0000276
Reid Spencerf88808a2004-10-30 09:19:36 +0000277Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
278LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
279BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
280Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
281LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
282BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
283Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
284 $(CompileCommonOpts) $(LD.Flags) $(Strip)
285Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000286 $(CompileCommonOpts)
Reid Spencerf88808a2004-10-30 09:19:36 +0000287LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
Reid Spencer81cd0492004-10-23 20:04:14 +0000288Burg = $(BURG) -I $(BUILD_SRC_DIR)
289TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
Reid Spencerf88808a2004-10-30 09:19:36 +0000290Archive = $(AR) $(AR.Flags)
Reid Spencer32f7e422004-12-02 09:28:21 +0000291LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencerf206bd72004-10-22 21:01:56 +0000292ifdef RANLIB
Reid Spencer81cd0492004-10-23 20:04:14 +0000293Ranlib = $(RANLIB)
Reid Spencerf206bd72004-10-22 21:01:56 +0000294else
Reid Spencer81cd0492004-10-23 20:04:14 +0000295Ranlib = ranlib
John Criswell3ef61af2003-06-30 21:59:07 +0000296endif
297
Chris Lattner2f7c9632001-06-06 20:29:01 +0000298#----------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +0000299# Get the list of source files and compute object file
300# names from them.
Reid Spencer81cd0492004-10-23 20:04:14 +0000301#----------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +0000302ifdef FAKE_SOURCES
303 Sources :=
304 FakeSources := $(FAKE_SOURCES)
305 ifdef BUILT_SOURCES
306 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
307 endif
308 BaseNameSources := $(sort $(basename $(FakeSources)))
309 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
310 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
311 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
Reid Spencerf88808a2004-10-30 09:19:36 +0000312else
Reid Spencer81546582004-12-04 22:34:09 +0000313 ifndef SOURCES
314 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
315 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
316 $(BUILD_SRC_DIR)/*.l))
317 else
318 Sources := $(SOURCES)
319 endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000320
Reid Spencer81546582004-12-04 22:34:09 +0000321 ifdef BUILT_SOURCES
322 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
323 endif
Vikram S. Advefe346892001-07-15 13:16:47 +0000324
Reid Spencer81546582004-12-04 22:34:09 +0000325 BaseNameSources := $(sort $(basename $(Sources)))
326 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
327 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
328 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
329endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000330
331###############################################################################
332# DIRECTORIES: Handle recursive descent of directory structure
333###############################################################################
John Criswell3601f372003-07-31 20:58:51 +0000334
Chris Lattner2f7c9632001-06-06 20:29:01 +0000335#---------------------------------------------------------
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000336# Provide rules to make install dirs. This must be early
337# in the file so they get built before dependencies
338#---------------------------------------------------------
339
340$(bindir):
Reid Spencerf88808a2004-10-30 09:19:36 +0000341 $(Verb) $(MKDIR) $(bindir)
Chris Lattner615e7fb2004-11-01 06:14:59 +0000342
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000343$(libdir):
Reid Spencerf88808a2004-10-30 09:19:36 +0000344 $(Verb) $(MKDIR) $(libdir)
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000345
346$(bytecode_libdir):
Reid Spencerf88808a2004-10-30 09:19:36 +0000347 $(Verb) $(MKDIR) $(bytecode_libdir)
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000348
349$(sysconfdir):
Reid Spencerf88808a2004-10-30 09:19:36 +0000350 $(Verb) $(MKDIR) $(sysconfdir)
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000351
Reid Spencerf88808a2004-10-30 09:19:36 +0000352# To create other directories, as needed, and timestamp their creation
353%/.dir:
354 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfc66af42004-11-29 05:00:33 +0000355 $(Verb) $(DATE) > $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000356
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000357.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
358.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000359
360#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000361# Handle the DIRS options for sequential construction
Chris Lattner2f7c9632001-06-06 20:29:01 +0000362#---------------------------------------------------------
363
Reid Spencerf88808a2004-10-30 09:19:36 +0000364SubDirs :=
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000365ifdef DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000366SubDirs += $(DIRS)
367$(RecursiveTargets)::
368 $(Verb) for dir in $(DIRS); do \
Reid Spencerf206bd72004-10-22 21:01:56 +0000369 if [ ! -f $$dir/Makefile ]; then \
370 $(MKDIR) $$dir; \
371 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
372 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +0000373 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattner539a23c2002-09-17 23:35:02 +0000374 done
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000375endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000376
Reid Spencer81cd0492004-10-23 20:04:14 +0000377#---------------------------------------------------------
378# Handle the EXPERIMENTAL_DIRS options ensuring success
379# after each directory is built.
380#---------------------------------------------------------
381ifdef EXPERIMENTAL_DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000382$(RecursiveTargets)::
383 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer81cd0492004-10-23 20:04:14 +0000384 if [ ! -f $$dir/Makefile ]; then \
385 $(MKDIR) $$dir; \
386 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
387 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +0000388 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000389 done
390endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000391
Reid Spencer81cd0492004-10-23 20:04:14 +0000392#---------------------------------------------------------
393# Handle the PARALLEL_DIRS options for parallel construction
394#---------------------------------------------------------
395ifdef PARALLEL_DIRS
396
Reid Spencerf88808a2004-10-30 09:19:36 +0000397SubDirs += $(PARALLEL_DIRS)
398
Reid Spencerd4bd3752004-12-03 20:08:48 +0000399# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencerf88808a2004-10-30 09:19:36 +0000400all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
401clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000402clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencerf88808a2004-10-30 09:19:36 +0000403install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000404uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencerd4bd3752004-12-03 20:08:48 +0000405install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000406
Reid Spencer81546582004-12-04 22:34:09 +0000407ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer81cd0492004-10-23 20:04:14 +0000408
Reid Spencer81546582004-12-04 22:34:09 +0000409$(ParallelTargets) :
Reid Spencerf88808a2004-10-30 09:19:36 +0000410 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencerf206bd72004-10-22 21:01:56 +0000411 $(MKDIR) $(@D); \
412 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswell6df35dd2003-11-25 19:32:22 +0000413 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +0000414 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000415endif
416
Reid Spencer81cd0492004-10-23 20:04:14 +0000417#---------------------------------------------------------
418# Handle the OPTIONAL_DIRS options for directores that may
419# or may not exist.
420#---------------------------------------------------------
John Criswell8224df92003-06-27 16:58:44 +0000421ifdef OPTIONAL_DIRS
Reid Spencer100080c2004-10-25 08:27:37 +0000422
Reid Spencerf88808a2004-10-30 09:19:36 +0000423SubDirs += $(OPTIONAL_DIRS)
Reid Spencer100080c2004-10-25 08:27:37 +0000424
Reid Spencerf88808a2004-10-30 09:19:36 +0000425$(RecursiveTargets)::
426 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencerf206bd72004-10-22 21:01:56 +0000427 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
428 if [ ! -f $$dir/Makefile ]; then \
429 $(MKDIR) $$dir; \
430 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
431 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +0000432 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000433 fi \
John Criswell8224df92003-06-27 16:58:44 +0000434 done
435endif
436
Reid Spencercc51e7b2004-08-20 09:20:05 +0000437#---------------------------------------------------------
438# Handle the CONFIG_FILES options
439#---------------------------------------------------------
440ifdef CONFIG_FILES
Reid Spencercc51e7b2004-08-20 09:20:05 +0000441
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000442install-local:: $(sysconfdir) $(CONFIG_FILES)
Reid Spencerf88808a2004-10-30 09:19:36 +0000443 $(Echo) Installing Configuration Files To $(sysconfdir)
444 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer39d6a612004-11-23 05:59:53 +0000445 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
446 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
447 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
448 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
449 else \
450 $(ECHO) Error: cannot find config file $${file}. ; \
451 fi \
Reid Spencercc51e7b2004-08-20 09:20:05 +0000452 done
Reid Spencer81cd0492004-10-23 20:04:14 +0000453
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000454uninstall-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000455 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
456 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer100080c2004-10-25 08:27:37 +0000457 $(RM) -f $(sysconfdir)/$${file} ; \
Reid Spencer12a3a052004-10-24 07:53:21 +0000458 done
459
Reid Spencercc51e7b2004-08-20 09:20:05 +0000460endif
461
Reid Spencer81cd0492004-10-23 20:04:14 +0000462###############################################################################
463# Library Build Rules: Four ways to build a library
464###############################################################################
Chris Lattner2f7c9632001-06-06 20:29:01 +0000465
Reid Spencerd78077d2004-12-05 05:17:22 +0000466#---------------------------------------------------------
467# Bytecode Module Targets:
468# If the user set MODULE_NAME then they want to build a
469# bytecode module from the sources. We compile all the
470# sources and link it together into a single bytecode
471# module.
472#---------------------------------------------------------
473
474ifdef MODULE_NAME
475
476Module := $(LibDir)/$(MODULE_NAME).bc
477LinkModule := $(LLVMGCC) -shared -nostdlib
478
479ifdef EXPORTED_SYMBOL_FILE
480LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
481endif
482
483$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
484 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
485 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
486
487all-local:: $(Module)
488
489clean-local::
490ifneq ($(strip $(Module)),)
491 -$(Verb) $(RM) -f $(Module)
492endif
493
494DestModule := $(bytecode_libdir)/$(MODULE_NAME).bc
495
496install-local:: $(DestModule)
497
498$(DestModule): $(bytecode_libdir) $(Module)
499 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
500 $(Verb) $(INSTALL) $(Module) $@
501
502uninstall-local::
503 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
504 -$(Verb) $(RM) -f $(DestModule)
505
506endif
Brian Gaekeecc92bf2004-01-22 22:53:48 +0000507
Reid Spencer81cd0492004-10-23 20:04:14 +0000508# if we're building a library ...
Chris Lattner2f7c9632001-06-06 20:29:01 +0000509ifdef LIBRARYNAME
Vikram S. Advefe346892001-07-15 13:16:47 +0000510
Chris Lattner0100eab2002-09-16 22:36:42 +0000511# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000512LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencerf88808a2004-10-30 09:19:36 +0000513LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
514LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
515LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer32f7e422004-12-02 09:28:21 +0000516LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000517
Reid Spencer81cd0492004-10-23 20:04:14 +0000518#---------------------------------------------------------
519# Shared Library Targets:
520# If the user asked for a shared library to be built
521# with the SHARED_LIBRARY variable, then we provide
522# targets for building them.
523#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000524ifdef SHARED_LIBRARY
525
Reid Spencerf88808a2004-10-30 09:19:36 +0000526all-local:: $(LibName.LA)
Reid Spencerf206bd72004-10-22 21:01:56 +0000527
Reid Spencerf88808a2004-10-30 09:19:36 +0000528$(LibName.LA): $(BUILT_SOURCES) $(ObjectsLO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000529 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf88808a2004-10-30 09:19:36 +0000530 $(Verb) $(Link) -o $@ $(ObjectsLO)
531 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencer81cd0492004-10-23 20:04:14 +0000532
533clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000534ifneq ($(strip $(LibName.LA)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000535 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000536endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000537
Reid Spencer12a3a052004-10-24 07:53:21 +0000538DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf206bd72004-10-22 21:01:56 +0000539
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000540install-local:: $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000541
Reid Spencerf88808a2004-10-30 09:19:36 +0000542$(DestSharedLib): $(libdir) $(LibName.LA)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000543 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000544 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
545 $(Verb) $(LIBTOOL) --finish $(libdir)
Reid Spencer12a3a052004-10-24 07:53:21 +0000546
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000547uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000548 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spenceraee67e62004-11-12 02:27:36 +0000549 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
Reid Spencer12a3a052004-10-24 07:53:21 +0000550
Reid Spencerf206bd72004-10-22 21:01:56 +0000551endif
552
Reid Spencer81cd0492004-10-23 20:04:14 +0000553#---------------------------------------------------------
554# Bytecode Library Targets:
555# If the user asked for a bytecode library to be built
556# with the BYTECODE_LIBRARY variable, then we provide
557# targets for building them.
558#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000559ifdef BYTECODE_LIBRARY
560
Reid Spencer2b1b83a2004-12-03 06:04:35 +0000561# make the C and C++ compilers strip debug info out of bytecode libraries.
562BCCompile.C += -Wa,-strip-debug
563BCCompile.CXX += -Wa,-strip-debug
564
Reid Spencer32f7e422004-12-02 09:28:21 +0000565all-local:: $(LibName.BCA)
566
567ifdef EXPORTED_SYMBOL_FILE
568BCLinkLib = $(LLVMGCC) -shared -nostdlib -Xlinker \
569 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
570
571$(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
572 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
573 "(internalize)"
Chris Lattnere3d98f12004-12-02 21:23:43 +0000574 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencer32f7e422004-12-02 09:28:21 +0000575 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencerf206bd72004-10-22 21:01:56 +0000576else
Reid Spencer81546582004-12-04 22:34:09 +0000577$(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir
Reid Spencer32f7e422004-12-02 09:28:21 +0000578 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
579 $(Verb) $(LArchive) $@ $(ObjectsBC)
580
Reid Spencerf206bd72004-10-22 21:01:56 +0000581endif
582
Reid Spencer81cd0492004-10-23 20:04:14 +0000583clean-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000584ifneq ($(strip $(LibName.BCA)),)
585 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000586endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000587
Reid Spencer32f7e422004-12-02 09:28:21 +0000588DestBytecodeLib = $(bytecode_libdir)/lib$(LIBRARYNAME).a
589
Reid Spencerd4bd3752004-12-03 20:08:48 +0000590install-bytecode-local:: $(DestBytecodeLib)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000591
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000592install-local:: $(DestBytecodeLib)
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000593
Reid Spencer32f7e422004-12-02 09:28:21 +0000594$(DestBytecodeLib): $(bytecode_libdir) $(LibName.BCA)
595 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
596 $(Verb) $(INSTALL) $(LibName.BCA) $@
Reid Spencer12a3a052004-10-24 07:53:21 +0000597
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000598uninstall-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000599 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000600 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000601
602endif
Vikram S. Adve15bd3ad2002-08-02 18:34:12 +0000603
Reid Spencerf88808a2004-10-30 09:19:36 +0000604#---------------------------------------------------------
605# ReLinked Library Targets:
606# If the user didn't explicitly forbid building a
607# relinked then we provide targets for building them.
608#---------------------------------------------------------
Chris Lattner76d98ba2002-07-23 17:56:16 +0000609ifndef DONT_BUILD_RELINKED
Reid Spencerf206bd72004-10-22 21:01:56 +0000610
Reid Spencerf88808a2004-10-30 09:19:36 +0000611all-local:: $(LibName.O)
612
613$(LibName.O): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000614 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencerf88808a2004-10-30 09:19:36 +0000615 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencerf206bd72004-10-22 21:01:56 +0000616
Reid Spencer81cd0492004-10-23 20:04:14 +0000617clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000618ifneq ($(strip $(LibName.O)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000619 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencer12a3a052004-10-24 07:53:21 +0000620endif
621
622DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
623
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000624install-local:: $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000625
Reid Spencerf88808a2004-10-30 09:19:36 +0000626$(DestRelinkedLib): $(libdir) $(LibName.O)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000627 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000628 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000629
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000630uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000631 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000632 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000633
Chris Lattner76d98ba2002-07-23 17:56:16 +0000634endif
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000635
Reid Spencerf88808a2004-10-30 09:19:36 +0000636#---------------------------------------------------------
637# Archive Library Targets:
638# If the user wanted a regular archive library built,
639# then we provide targets for building them.
640#---------------------------------------------------------
Chris Lattner76d98ba2002-07-23 17:56:16 +0000641ifdef BUILD_ARCHIVE
Chris Lattner76d98ba2002-07-23 17:56:16 +0000642
Reid Spencerf88808a2004-10-30 09:19:36 +0000643all-local:: $(LibName.A)
644
645$(LibName.A): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000646 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000647 -$(Verb) $(RM) -f $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000648 $(Verb) $(Archive) $@ $(ObjectsO)
649 $(Verb) $(Ranlib) $@
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000650
Reid Spencer81cd0492004-10-23 20:04:14 +0000651clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000652ifneq ($(strip $(LibName.A)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000653 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000654endif
655
Reid Spencer12a3a052004-10-24 07:53:21 +0000656DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
657
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000658install-local:: $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000659
Reid Spencerf88808a2004-10-30 09:19:36 +0000660$(DestArchiveLib): $(libdir) $(LibName.A)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000661 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000662 $(Verb) $(MKDIR) $(libdir)
663 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000664
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000665uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000666 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000667 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000668
669endif
670
671# endif LIBRARYNAME
Reid Spencerf206bd72004-10-22 21:01:56 +0000672endif
673
Reid Spencerdcba7782004-10-24 08:21:04 +0000674###############################################################################
675# Tool Build Rules: Build executable tool based on TOOLNAME option
676###############################################################################
677
Chris Lattner07c7c192001-09-07 22:57:58 +0000678ifdef TOOLNAME
679
Reid Spencerf88808a2004-10-30 09:19:36 +0000680#---------------------------------------------------------
Reid Spenceraf4495a2004-11-29 07:17:07 +0000681# Handle the special "JIT" value for LLVM_LIBS which is a
682# shorthand for a bunch of libraries that get the correct
683# JIT support for a tool that runs JIT.
684#---------------------------------------------------------
685ifeq ($(LLVMLIBS),JIT)
686
687# Make sure we can get our own symbols in the tool
688Link += -dlopen self
689
690# Generic JIT libraries
691JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
692
693# You can enable the X86 JIT on a non-X86 host by setting the flag
694# ENABLE_X86_JIT on the make command line. If not, it will still be
695# enabled automagically on an X86 host.
696ifeq ($(ARCH), x86)
697 ENABLE_X86_JIT = 1
698endif
699
700# What the X86 JIT requires
701ifdef ENABLE_X86_JIT
702 JIT_LIBS += LLVMX86 LLVMSelectionDAG
703endif
704
705# You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
706# ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
707# enabled automagically on an SparcV9 host.
708ifeq ($(ARCH), Sparc)
709 ENABLE_SPARCV9_JIT = 1
710endif
711
712# What the Sparc JIT requires
713ifdef ENABLE_SPARCV9_JIT
714 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
715 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
716 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
717 LLVMDataStructure.a LLVMSparcV9RegAlloc
718endif
719
720# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
721# ENABLE_PPC_JIT on the make command line. If not, it will still be
722# enabled automagically on an PowerPC host.
723ifeq ($(ARCH), PowerPC)
724 ENABLE_PPC_JIT = 1
725endif
726
727# What the PowerPC JIT requires
728ifdef ENABLE_PPC_JIT
729 JIT_LIBS += LLVMPowerPC
730endif
731
732LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
733 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
734 LLVMSystem.a $(PLATFORMLIBDL)
735endif
736
737#---------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000738# Set up variables for building a tool.
739#---------------------------------------------------------
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000740ifdef EXAMPLE_TOOL
741ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
742else
Reid Spencerf88808a2004-10-30 09:19:36 +0000743ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000744endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000745ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
746ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
747LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
748LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
749ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
750LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
751ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
752LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
Chris Lattner07c7c192001-09-07 22:57:58 +0000753
Reid Spencerf88808a2004-10-30 09:19:36 +0000754#---------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000755# Tell make that we need to rebuild subdirectories before
756# we can link the tool. This affects things like LLI which
757# has library subdirectories.
758#---------------------------------------------------------
759$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner3ecb7762003-01-22 16:13:31 +0000760
Reid Spencerf88808a2004-10-30 09:19:36 +0000761#---------------------------------------------------------
762# Provide targets for building the tools
763#---------------------------------------------------------
764all-local:: $(ToolBuildPath)
John Criswell8224df92003-06-27 16:58:44 +0000765
Reid Spencer81cd0492004-10-23 20:04:14 +0000766clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000767ifneq ($(strip $(ToolBuildPath)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000768 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencer12a3a052004-10-24 07:53:21 +0000769endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000770
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000771ifdef EXAMPLE_TOOL
772$(ToolBuildPath): $(ExmplDir)/.dir
773else
774$(ToolBuildPath): $(ToolDir)/.dir
775endif
776
777$(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000778 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencerf88808a2004-10-30 09:19:36 +0000779 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
780 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000781 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencer12a3a052004-10-24 07:53:21 +0000782
783DestTool = $(bindir)/$(TOOLNAME)
784
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000785install-local:: $(DestTool)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000786
Reid Spencerf88808a2004-10-30 09:19:36 +0000787$(DestTool): $(bindir) $(ToolBuildPath)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000788 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencerf88808a2004-10-30 09:19:36 +0000789 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000790
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000791uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000792 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000793 -$(Verb) $(RM) -f $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000794
Reid Spencerf206bd72004-10-22 21:01:56 +0000795endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000796
Reid Spencerf88808a2004-10-30 09:19:36 +0000797###############################################################################
798# Object Build Rules: Build object files based on sources
799###############################################################################
800
801# Provide rule sets for when dependency generation is enabled
Reid Spencerf206bd72004-10-22 21:01:56 +0000802ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000803
Reid Spencerf88808a2004-10-30 09:19:36 +0000804#---------------------------------------------------------
805# Create .lo files in the ObjDir directory from the .cpp and .c files...
806#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000807ifdef SHARED_LIBRARY
808
Reid Spencerf88808a2004-10-30 09:19:36 +0000809$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000810 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencerf88808a2004-10-30 09:19:36 +0000811 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
812 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
813 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000814
Reid Spencerf88808a2004-10-30 09:19:36 +0000815$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000816 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencerf88808a2004-10-30 09:19:36 +0000817 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
818 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
819 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000820
Reid Spencerf88808a2004-10-30 09:19:36 +0000821#---------------------------------------------------------
822# Create .o files in the ObjDir directory from the .cpp and .c files...
823#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000824else
Reid Spencerf206bd72004-10-22 21:01:56 +0000825
Reid Spencerf88808a2004-10-30 09:19:36 +0000826$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000827 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +0000828 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
829 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
830 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +0000831
Reid Spencerf88808a2004-10-30 09:19:36 +0000832$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000833 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +0000834 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
835 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
836 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000837
838endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000839
Reid Spencerf88808a2004-10-30 09:19:36 +0000840#---------------------------------------------------------
841# Create .bc files in the ObjDir directory from .cpp and .c files...
842#---------------------------------------------------------
Chris Lattner0ea40c92004-11-29 19:47:58 +0000843$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000844 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencerf88808a2004-10-30 09:19:36 +0000845 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
846 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
847 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +0000848
Chris Lattner0ea40c92004-11-29 19:47:58 +0000849$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000850 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencerf88808a2004-10-30 09:19:36 +0000851 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
852 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
853 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +0000854
Reid Spencerf88808a2004-10-30 09:19:36 +0000855# Provide alternate rule sets if dependencies are disabled
Reid Spencerf206bd72004-10-22 21:01:56 +0000856else
857
Reid Spencer81cd0492004-10-23 20:04:14 +0000858ifdef SHARED_LIBRARY
859
Reid Spencerf88808a2004-10-30 09:19:36 +0000860$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000861 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000862 $(LTCompile.CXX) $< -o $@
863
Reid Spencerf88808a2004-10-30 09:19:36 +0000864$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000865 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000866 $(LTCompile.C) $< -o $@
867
868else
Reid Spencerf206bd72004-10-22 21:01:56 +0000869
Reid Spencerf88808a2004-10-30 09:19:36 +0000870$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000871 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer81cd0492004-10-23 20:04:14 +0000872 $(Compile.CXX) $< -o $@
Reid Spencerf206bd72004-10-22 21:01:56 +0000873
Reid Spencerf88808a2004-10-30 09:19:36 +0000874$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000875 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer81cd0492004-10-23 20:04:14 +0000876 $(Compile.C) $< -o $@
877endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000878
Chris Lattner0ea40c92004-11-29 19:47:58 +0000879$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000880 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencer991f66a2004-10-31 18:52:15 +0000881 $(BCCompile.CXX) $< -o $@
Reid Spencerf206bd72004-10-22 21:01:56 +0000882
Chris Lattner0ea40c92004-11-29 19:47:58 +0000883$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000884 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencer991f66a2004-10-31 18:52:15 +0000885 $(BCCompile.C) $< -o $@
Brian Gaeke0f148bc2003-12-10 00:26:28 +0000886
Chris Lattner07c7c192001-09-07 22:57:58 +0000887endif
888
Reid Spencerf88808a2004-10-30 09:19:36 +0000889#---------------------------------------------------------
890# Provide rule to build .bc files from .ll sources,
891# regardless of dependencies
892#---------------------------------------------------------
893$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000894 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +0000895 $(Verb) $(LLVMAS) $< -f -o $@
896
897###############################################################################
898# TABLEGEN: Provide rules for running tblgen to produce *.inc files
899###############################################################################
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000900
Reid Spencerf206bd72004-10-22 21:01:56 +0000901ifdef TARGET
902
Reid Spencerf88808a2004-10-30 09:19:36 +0000903TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
904INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Reid Spencerf206bd72004-10-22 21:01:56 +0000905
Reid Spencerf88808a2004-10-30 09:19:36 +0000906$(INCFiles) : $(TBLGEN) $(TDFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +0000907
Reid Spencer94105c72004-10-27 04:34:35 +0000908%GenRegisterNames.inc : %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000909 $(Echo) "Building $(<F) register names with tblgen"
910 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000911
Reid Spencer94105c72004-10-27 04:34:35 +0000912%GenRegisterInfo.h.inc : %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000913 $(Echo) "Building $(<F) register information header with tblgen"
914 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000915
916%GenRegisterInfo.inc : %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000917 $(Echo) "Building $(<F) register info implementation with tblgen"
918 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000919
920%GenInstrNames.inc : %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000921 $(Echo) "Building $(<F) instruction names with tblgen"
922 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000923
924%GenInstrInfo.inc : %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000925 $(Echo) "Building $(<F) instruction information with tblgen"
926 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000927
928%GenAsmWriter.inc : %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000929 $(Echo) "Building $(<F) assembly writer with tblgen"
930 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000931
932%GenATTAsmWriter.inc : %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000933 $(Echo) "Building $(<F) AT&T assembly writer with tblgen"
934 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000935
936%GenIntelAsmWriter.inc : %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000937 $(Echo) "Building $(<F) Intel assembly writer with tblgen"
938 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000939
940%GenInstrSelector.inc: %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000941 $(Echo) "Building $(<F) instruction selector with tblgen"
942 $(Verb) $(TableGen) -gen-instr-selector -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000943
944%GenCodeEmitter.inc:: %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000945 $(Echo) "Building $(<F) code emitter with tblgen"
946 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000947
Reid Spencer81cd0492004-10-23 20:04:14 +0000948clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000949 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +0000950
951endif
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000952
Reid Spencerf88808a2004-10-30 09:19:36 +0000953###############################################################################
954# LEX AND YACC: Provide rules for generating sources with lex and yacc
955###############################################################################
Chris Lattnerdb644dd2003-01-16 22:44:19 +0000956
Reid Spencerf88808a2004-10-30 09:19:36 +0000957#---------------------------------------------------------
958# Provide rules for generating a .cpp source file from
959# (f)lex input sources.
960#---------------------------------------------------------
961
Reid Spencer9d0c1e02004-11-02 16:36:03 +0000962LexFiles := $(filter %.l,$(Sources))
Reid Spencerf88808a2004-10-30 09:19:36 +0000963
Reid Spencer9d0c1e02004-11-02 16:36:03 +0000964ifneq ($(LexFiles),)
965
966LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
Reid Spencerf88808a2004-10-30 09:19:36 +0000967
968.PRECIOUS: $(LexOutput)
969
970# Note the extra sed filtering here, used to cut down on the warnings emited
971# by GCC. The last line is a gross hack to work around flex aparently not
972# being able to resize the buffer on a large token input. Currently, for
973# uninitialized string buffers in LLVM we can generate very long tokens, so
974# this is a hack around it.
Chris Lattner92fc9b02003-08-15 20:00:47 +0000975# FIXME. (f.e. char Buffer[10000] )
Chris Lattner2f7c9632001-06-06 20:29:01 +0000976%.cpp: %.l
Reid Spencerf88808a2004-10-30 09:19:36 +0000977 $(Echo) Flexing $<
978 $(Verb) $(FLEX) -t $< | \
Reid Spencerf206bd72004-10-22 21:01:56 +0000979 $(SED) 's/void yyunput/inline void yyunput/' | \
980 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
981 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencerb7f710a2004-10-28 00:41:43 +0000982 > $@
Chris Lattner2f7c9632001-06-06 20:29:01 +0000983
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000984clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000985 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencer9d0c1e02004-11-02 16:36:03 +0000986 $(Verb) $(RM) -f $(LexOutput)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000987
Reid Spencerf88808a2004-10-30 09:19:36 +0000988endif
989
990#---------------------------------------------------------
991# Provide rules for generating a .cpp and .h source files
992# from yacc (bison) input sources.
993#---------------------------------------------------------
994
Reid Spencer9d0c1e02004-11-02 16:36:03 +0000995YaccFiles := $(filter %.y,$(Sources))
996ifneq ($(YaccFiles),)
997YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
Reid Spencerf88808a2004-10-30 09:19:36 +0000998
999.PRECIOUS: $(YaccOutput)
1000
1001# Cancel built-in rules for yacc
1002%.c: %.y
1003%.cpp: %.y
1004%.h: %.y
1005
Chris Lattner2f7c9632001-06-06 20:29:01 +00001006# Rule for building the bison parsers...
Chris Lattner2f7c9632001-06-06 20:29:01 +00001007%.cpp %.h : %.y
Reid Spencerf88808a2004-10-30 09:19:36 +00001008 $(Echo) "Bisoning $*.y"
1009 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1010 $(Verb) $(MV) -f $*.tab.c $*.cpp
1011 $(Verb) $(MV) -f $*.tab.h $*.h
Chris Lattner2f7c9632001-06-06 20:29:01 +00001012
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001013clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001014 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001015 $(Verb) $(RM) -f $(YaccOutput)
Reid Spencerf88808a2004-10-30 09:19:36 +00001016endif
Chris Lattner2f7c9632001-06-06 20:29:01 +00001017
Reid Spencerf88808a2004-10-30 09:19:36 +00001018###############################################################################
1019# OTHER RULES: Other rules needed
1020###############################################################################
Reid Spencerf206bd72004-10-22 21:01:56 +00001021
Chris Lattner23d47392003-01-16 21:06:18 +00001022# To create postscript files from dot files...
John Criswell4ffb8442003-10-02 19:02:02 +00001023ifneq ($(DOT),false)
Chris Lattner23d47392003-01-16 21:06:18 +00001024%.ps: %.dot
Reid Spencerf206bd72004-10-22 21:01:56 +00001025 $(DOT) -Tps < $< > $@
John Criswell3ef61af2003-06-30 21:59:07 +00001026else
1027%.ps: %.dot
Reid Spencerf88808a2004-10-30 09:19:36 +00001028 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell3ef61af2003-06-30 21:59:07 +00001029endif
Chris Lattner23d47392003-01-16 21:06:18 +00001030
John Criswell0a6e6aa2003-09-06 14:44:17 +00001031# This rules ensures that header files that are removed still have a rule for
1032# which they can be "generated." This allows make to ignore them and
1033# reproduce the dependency lists.
John Criswella8391af2003-09-18 18:37:08 +00001034%.h:: ;
John Criswell0a6e6aa2003-09-06 14:44:17 +00001035
Reid Spencerf88808a2004-10-30 09:19:36 +00001036# Define clean-local to clean the current directory. Note that this uses a
1037# very conservative approach ensuring that empty variables do not cause
1038# errors or disastrous removal.
Reid Spencer81cd0492004-10-23 20:04:14 +00001039clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001040ifneq ($(strip $(ObjDir)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001041 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencer12a3a052004-10-24 07:53:21 +00001042endif
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001043 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke8625f682004-01-21 19:53:11 +00001044ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001045 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke8625f682004-01-21 19:53:11 +00001046endif
John Criswell3ef61af2003-06-30 21:59:07 +00001047
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001048clean-all-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001049 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001050
Reid Spencerf88808a2004-10-30 09:19:36 +00001051# Build tags database for Emacs/Xemacs:
Reid Spenceraee67e62004-11-12 02:27:36 +00001052tags:: TAGS CTAGS
1053
Reid Spencerf88808a2004-10-30 09:19:36 +00001054TAGS:
Reid Spenceraee67e62004-11-12 02:27:36 +00001055 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1056 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1057 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1058 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1059 -name '*.cpp' -o -name '*.h' | \
Reid Spencerf88808a2004-10-30 09:19:36 +00001060 $(ETAGS) $(ETAGSFLAGS) -
1061
Reid Spenceraee67e62004-11-12 02:27:36 +00001062CTAGS:
1063 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1064 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1065 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1066 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1067 \( -name '*.cpp' -o -name '*.h' \) -print | \
1068 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1069
1070
Reid Spencer81cd0492004-10-23 20:04:14 +00001071###############################################################################
1072# DEPENDENCIES: Include the dependency files if we should
1073###############################################################################
Chris Lattnere9d7d702003-08-22 14:10:16 +00001074ifndef DISABLE_AUTO_DEPENDENCIES
1075
Reid Spencer81cd0492004-10-23 20:04:14 +00001076# If its not one of the cleaning targets
Reid Spencerf88808a2004-10-30 09:19:36 +00001077ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencerf206bd72004-10-22 21:01:56 +00001078
Reid Spencer81cd0492004-10-23 20:04:14 +00001079# Get the list of dependency files
Reid Spencerf88808a2004-10-30 09:19:36 +00001080DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001081DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
Misha Brukmanb891ffb2003-11-09 21:36:19 +00001082
Reid Spencer81cd0492004-10-23 20:04:14 +00001083-include /dev/null $(DependFiles)
1084
John Criswell48ecca62003-08-12 18:51:51 +00001085endif
Chris Lattner598222b2003-08-18 17:27:40 +00001086
Reid Spencerf88808a2004-10-30 09:19:36 +00001087endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001088
Reid Spencer100080c2004-10-25 08:27:37 +00001089###############################################################################
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001090# CHECK: Running the test suite
1091###############################################################################
1092
1093check::
1094 $(Verb) if test -d "$(BUILD_OBJ_ROOT)/test" ; then \
1095 if test -f "$(BUILD_OBJ_ROOT)/test/Makefile" ; then \
1096 $(EchoCmd) Running test suite ; \
1097 $(MAKE) -C $(BUILD_OBJ_ROOT)/test check-local \
1098 TESTSUITE=$(TESTSUITE) ; \
1099 else \
1100 $(EchoCmd) No Makefile in test directory ; \
1101 fi ; \
1102 else \
1103 $(EchoCmd) No test directory ; \
1104 fi
1105
1106###############################################################################
Reid Spencerf88808a2004-10-30 09:19:36 +00001107# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer100080c2004-10-25 08:27:37 +00001108###############################################################################
1109
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001110#------------------------------------------------------------------------
1111# Define distribution related variables
1112#------------------------------------------------------------------------
Reid Spencer100080c2004-10-25 08:27:37 +00001113DistName := $(LLVM_TARBALL_NAME)
1114DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001115TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer100080c2004-10-25 08:27:37 +00001116DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1117DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1118DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1119DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1120 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001121 Makefile.config.in configure autoconf
1122DistOther := $(notdir $(wildcard \
1123 $(BUILD_SRC_DIR)/*.h \
1124 $(BUILD_SRC_DIR)/*.td \
1125 $(BUILD_SRC_DIR)/*.def \
1126 $(BUILD_SRC_DIR)/*.ll \
1127 $(BUILD_SRC_DIR)/*.in))
Reid Spencerf88808a2004-10-30 09:19:36 +00001128DistSubDirs := $(SubDirs)
Reid Spencerfc66af42004-11-29 05:00:33 +00001129DistSources = $(Sources) $(EXTRA_DIST)
1130DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer100080c2004-10-25 08:27:37 +00001131
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001132#------------------------------------------------------------------------
1133# We MUST build distribution with OBJ_DIR != SRC_DIR
1134#------------------------------------------------------------------------
1135ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1136dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerf88808a2004-10-30 09:19:36 +00001137 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001138
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001139else
1140
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001141#------------------------------------------------------------------------
1142# Prevent catastrophic remove
1143#------------------------------------------------------------------------
1144ifeq ($(LLVM_TARBALL_NAME),)
1145$(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1146endif
1147
1148#------------------------------------------------------------------------
1149# Prevent attempt to run dist targets from anywhere but the top level
1150#------------------------------------------------------------------------
1151ifneq ($(LEVEL),.)
1152
1153dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerf88808a2004-10-30 09:19:36 +00001154 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001155
1156else
1157
1158#------------------------------------------------------------------------
1159# Provide the top level targets
1160#------------------------------------------------------------------------
1161
Reid Spencerf88808a2004-10-30 09:19:36 +00001162dist-gzip:: $(DistTarGZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001163
Reid Spencer81546582004-12-04 22:34:09 +00001164$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001165 $(Echo) Packing gzipped distribution tar file.
Reid Spencerfc66af42004-11-29 05:00:33 +00001166 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1167 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001168
Reid Spencerf88808a2004-10-30 09:19:36 +00001169dist-bzip2:: $(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001170
Reid Spencer81546582004-12-04 22:34:09 +00001171$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001172 $(Echo) Packing bzipped distribution tar file.
Reid Spencerfc66af42004-11-29 05:00:33 +00001173 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1174 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001175
Reid Spencerf88808a2004-10-30 09:19:36 +00001176dist-zip:: $(DistZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001177
Reid Spencer81546582004-12-04 22:34:09 +00001178$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001179 $(Echo) Packing zipped distribution file.
1180 $(Verb) rm -f $(DistZip)
1181 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001182
1183dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001184 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001185
1186DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1187
Reid Spencer81546582004-12-04 22:34:09 +00001188dist-check:: $(DistTarGZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001189 $(Echo) Checking distribution tar file.
1190 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001191 $(RM) -rf $(DistCheckDir) ; \
1192 fi
Reid Spencerf88808a2004-10-30 09:19:36 +00001193 $(Verb) $(MKDIR) $(DistCheckDir)
1194 $(Verb) cd $(DistCheckDir) && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001195 $(MKDIR) $(DistCheckDir)/build && \
1196 $(MKDIR) $(DistCheckDir)/install && \
1197 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1198 cd build && \
1199 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1200 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
Reid Spencer81546582004-12-04 22:34:09 +00001201 $(MAKE) all && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001202 $(MAKE) check && \
1203 $(MAKE) install && \
1204 $(MAKE) uninstall && \
1205 $(MAKE) dist && \
1206 $(MAKE) clean && \
1207 $(MAKE) dist-clean && \
Reid Spencerf88808a2004-10-30 09:19:36 +00001208 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001209
1210dist-clean::
Reid Spencerf88808a2004-10-30 09:19:36 +00001211 $(Echo) Cleaning distribution files
Reid Spencer81546582004-12-04 22:34:09 +00001212 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1213 $(DistCheckDir)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001214
1215endif
1216
1217#------------------------------------------------------------------------
1218# Provide the recursive distdir target for building the distribution directory
1219#------------------------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +00001220distdir: $(DistDir)/.makedistdir
1221$(DistDir)/.makedistdir: $(DistSources)
Reid Spencerf88808a2004-10-30 09:19:36 +00001222 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001223 if test -d "$(DistDir)" ; then \
1224 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1225 exit 1 ; \
1226 fi ; \
Reid Spencer81546582004-12-04 22:34:09 +00001227 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001228 $(RM) -rf $(DistDir); \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001229 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer81546582004-12-04 22:34:09 +00001230 $(MAKE) all ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001231 fi
Reid Spencerfc66af42004-11-29 05:00:33 +00001232 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencerf88808a2004-10-30 09:19:36 +00001233 $(Verb) $(MKDIR) $(DistDir)
1234 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
Reid Spencer100080c2004-10-25 08:27:37 +00001235 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1236 for file in $(DistFiles) ; do \
1237 case "$$file" in \
Reid Spencer81546582004-12-04 22:34:09 +00001238 $(BUILD_SRC_DIR)/*) \
1239 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1240 ;; \
1241 $(BUILD_SRC_ROOT)/*) \
1242 file=`echo "$$file" | \
1243 sed "s#^$$srcrootstrip/##"` \
1244 ;; \
Reid Spencer100080c2004-10-25 08:27:37 +00001245 esac; \
Reid Spencer81546582004-12-04 22:34:09 +00001246 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1247 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1248 from_dir="$(BUILD_SRC_DIR)" ; \
1249 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001250 from_dir=. ; \
Reid Spencer81546582004-12-04 22:34:09 +00001251 fi ; \
1252 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001253 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1254 to_dir="$(DistDir)/$$dir"; \
1255 $(MKDIR) "$$to_dir" ; \
1256 else \
1257 to_dir="$(DistDir)"; \
1258 fi; \
1259 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1260 if test -n "$$mid_dir" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001261 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001262 fi ; \
1263 if test -d "$$from_dir/$$file"; then \
1264 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1265 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1266 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1267 fi; \
1268 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1269 elif test -f "$$from_dir/$$file" ; then \
1270 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1271 elif test -L "$$from_dir/$$file" ; then \
1272 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1273 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer81546582004-12-04 22:34:09 +00001274 $(EchoCmd) "===== WARNING: Distribution Source " \
1275 "$$from_dir/$$file Not Found!" ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001276 elif test "$(Verb)" != '@' ; then \
1277 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001278 fi; \
1279 done
Reid Spencerf88808a2004-10-30 09:19:36 +00001280 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer100080c2004-10-25 08:27:37 +00001281 if test "$$subdir" \!= "." ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001282 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001283 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer81546582004-12-04 22:34:09 +00001284 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1285 exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001286 fi; \
1287 done
Reid Spencer81546582004-12-04 22:34:09 +00001288 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1289 $(EchoCmd) Eliminating CVS directories from distribution ; \
1290 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1291 $(MAKE) dist-hook ; \
1292 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1293 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1294 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1295 -o ! -type d ! -perm -444 -exec \
1296 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1297 || chmod -R a+r $(DistDir) ; \
1298 fi
Reid Spencer100080c2004-10-25 08:27:37 +00001299
Reid Spencerf88808a2004-10-30 09:19:36 +00001300# This is invoked by distdir target, define it as a no-op to avoid errors if not
1301# defined by user.
Reid Spencer100080c2004-10-25 08:27:37 +00001302dist-hook::
1303
Reid Spencer23a70372004-10-22 23:06:30 +00001304endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001305
1306###############################################################################
Reid Spencer12a3a052004-10-24 07:53:21 +00001307# TOP LEVEL - targets only to apply at the top level directory
1308###############################################################################
1309
1310ifeq ($(LEVEL),.)
1311
1312#------------------------------------------------------------------------
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001313# Install support for the project's include files:
Reid Spencer12a3a052004-10-24 07:53:21 +00001314#------------------------------------------------------------------------
1315install-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001316 $(Echo) Installing include files
1317 $(Verb) $(MKDIR) $(includedir)
1318 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencer12a3a052004-10-24 07:53:21 +00001319 cd $(BUILD_SRC_ROOT)/include && \
1320 find . -path '*/Internal' -prune -o '(' -type f \
1321 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1322 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1323 fi
1324
1325uninstall-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001326 $(Echo) Uninstalling include files
1327 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencer12a3a052004-10-24 07:53:21 +00001328 cd $(BUILD_SRC_ROOT)/include && \
1329 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1330 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1331 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1332 fi
1333
Reid Spencer12a3a052004-10-24 07:53:21 +00001334endif
1335
Reid Spencerf206bd72004-10-22 21:01:56 +00001336#------------------------------------------------------------------------
1337# Print out the directories used for building
Reid Spencerf88808a2004-10-30 09:19:36 +00001338#------------------------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001339printvars::
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001340 $(Echo) "BuildMode : " '$(BuildMode)'
Reid Spencerf88808a2004-10-30 09:19:36 +00001341 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1342 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1343 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1344 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1345 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1346 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1347 $(Echo) "libdir : " '$(libdir)'
1348 $(Echo) "bindir : " '$(bindir)'
1349 $(Echo) "sysconfdir : " '$(sysconfdir)'
1350 $(Echo) "bytecode_libdir: " '$(bytecode_libdir)'
1351 $(Echo) "UserTargets : " '$(UserTargets)'
1352 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1353 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1354 $(Echo) "ObjDir : " '$(ObjDir)'
1355 $(Echo) "LibDir : " '$(LibDir)'
1356 $(Echo) "ToolDir : " '$(ToolDir)'
Reid Spencer7e9e0b02004-11-18 10:03:46 +00001357 $(Echo) "ExmplDir : " '$(ExmplDir)'
Reid Spencerd78077d2004-12-05 05:17:22 +00001358 $(Echo) "Sources : " '$(Sources)'
Reid Spencerf88808a2004-10-30 09:19:36 +00001359 $(Echo) "TDFiles : " '$(TDFiles)'
1360 $(Echo) "INCFiles : " '$(INCFiles)'
1361 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1362 $(Echo) "Compile.C : " '$(Compile.C)'
1363 $(Echo) "Archive : " '$(Archive)'
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001364 $(Echo) "YaccFiles : " '$(YaccFiles)'
1365 $(Echo) "LexFiles : " '$(LexFiles)'
Reid Spencerd78077d2004-12-05 05:17:22 +00001366 $(Echo) "Module : " '$(Module)'