blob: a160c02d30b7e548c2300c6047695868453e9a49 [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 Spencercc2d1e22004-10-30 09:19:36 +0000151 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
152 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 Spencercc2d1e22004-10-30 09:19:36 +0000157 CXX.Flags := -O3 -DNDEBUG -finline-functions -felide-constructors -fomit-frame-pointer
158 C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
159 LD.Flags := -O3 -DNDEBUG
Chris Lattner760da062003-03-14 20:25:22 +0000160 else
Reid Spencer9af3b292004-11-01 07:50:27 +0000161 BuildMode := Debug
Reid Spencercc2d1e22004-10-30 09:19:36 +0000162 CXX.Flags := -g -D_DEBUG
163 C.Flags := -g -D_DEBUG
164 LD.Flags := -g -D_DEBUG
Reid Spencer4d71b662004-10-22 21:01:56 +0000165 KEEP_SYMBOLS := 1
Chris Lattner760da062003-03-14 20:25:22 +0000166 endif
167endif
168
Reid Spencercc2d1e22004-10-30 09:19:36 +0000169CXX.Flags += $(CXXFLAGS)
170C.Flags += $(CFLAGS)
171CPP.Flags += $(CPPFLAGS)
172LD.Flags += $(LDFLAGS)
173AR.Flags := cru
174LibTool.Flags := --tag=CXX
Reid Spencer3a561f52004-10-23 20:04:14 +0000175
176#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000177# Directory locations
Reid Spencer3a561f52004-10-23 20:04:14 +0000178#--------------------------------------------------------------------
Reid Spencer9af3b292004-11-01 07:50:27 +0000179ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000180LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer9a5acaf2004-11-18 20:04:39 +0000181ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer815cbcf2004-11-18 10:03:46 +0000182ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
183LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer9a5acaf2004-11-18 20:04:39 +0000184LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer815cbcf2004-11-18 10:03:46 +0000185LExmplDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
John Criswell7a73b802003-06-30 21:59:07 +0000186
Reid Spencer3a561f52004-10-23 20:04:14 +0000187#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000188# Full Paths To Compiled Tools and Utilities
Reid Spencer3a561f52004-10-23 20:04:14 +0000189#--------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000190EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
191Echo := @$(EchoCmd)
192ifndef LIBTOOL
Reid Spencer4d71b662004-10-22 21:01:56 +0000193LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencercc2d1e22004-10-30 09:19:36 +0000194endif
195ifndef LLVMAS
196LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
197endif
198ifndef BURG
199BURG := $(LLVMToolDir)/burg$(EXEEXT)
200endif
201ifndef TBLGEN
202TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
203endif
Chris Lattner478b3b42004-11-29 19:47:58 +0000204ifndef GCCAS
205GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
206endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000207ifndef GCCLD
208GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
209endif
210ifndef LLVMGCC
211LLVMGCC := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/gcc
212endif
213ifndef LLVMGXX
214LLVMGXX := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/g++
215endif
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000216
Reid Spencer4d71b662004-10-22 21:01:56 +0000217# Need a better way to compute this.
Reid Spencercc2d1e22004-10-30 09:19:36 +0000218LLVMGCCLibDir := $(dir $(shell $(LLVMGCC) -print-file-name=libgcc.a))/
Reid Spencer43620032004-12-05 19:14:19 +0000219LLVMGCCStdCXXLibDir := $(dir $(shell $(LLVMGCC) -print-file-name=libstdc++.a))/
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000220
Reid Spencer3a561f52004-10-23 20:04:14 +0000221#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000222# Adjust to user's request
Reid Spencer3a561f52004-10-23 20:04:14 +0000223#--------------------------------------------------------------------
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000224
Reid Spencercc2d1e22004-10-30 09:19:36 +0000225# Adjust LIBTOOL flags for shared libraries, or not.
John Criswell82f4a5a2003-07-31 20:58:51 +0000226ifndef SHARED_LIBRARY
Reid Spencercc2d1e22004-10-30 09:19:36 +0000227 LibTool.Flags += --tag=disable-shared
Reid Spencer4d71b662004-10-22 21:01:56 +0000228else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000229 LD.Flags += -rpath $(LibDir)
John Criswell82f4a5a2003-07-31 20:58:51 +0000230endif
231
Reid Spencercceed9f2004-11-08 17:32:12 +0000232ifdef TOOL_VERBOSE
233 C.Flags += -v
234 CXX.Flags += -v
235 LD.Flags += -v
Reid Spencercceed9f2004-11-08 17:32:12 +0000236 VERBOSE := 1
Reid Spencer9a2f1372004-12-02 09:28:21 +0000237else
Reid Spencercceed9f2004-11-08 17:32:12 +0000238endif
239
Reid Spencer3a561f52004-10-23 20:04:14 +0000240# Adjust settings for verbose mode
Chris Lattner760da062003-03-14 20:25:22 +0000241ifndef VERBOSE
Reid Spencercc2d1e22004-10-30 09:19:36 +0000242 Verb := @
243 LibTool.Flags += --silent
244 AR.Flags += >/dev/null 2>/dev/null
245 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
Reid Spencer151f8ba2004-10-25 08:27:37 +0000246else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000247 ConfigureScriptFLAGS :=
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000248endif
249
Vikram S. Advefeeae582002-09-18 11:55:13 +0000250# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000251ifndef KEEP_SYMBOLS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000252 Strip := $(PLATFORMSTRIPOPTS)
253 StripWarnMsg := "(without symbols)"
Vikram S. Advefeeae582002-09-18 11:55:13 +0000254endif
255
Reid Spencer3a561f52004-10-23 20:04:14 +0000256# Adjust linker flags for building an executable
Reid Spencer4d71b662004-10-22 21:01:56 +0000257ifdef TOOLNAME
Reid Spencer815cbcf2004-11-18 10:03:46 +0000258ifdef EXAMPLE_TOOL
259 LD.Flags += -rpath $(ExmplDir) -export-dynamic
260else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000261 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000262endif
Reid Spencer815cbcf2004-11-18 10:03:46 +0000263endif
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000264
Reid Spencer3a561f52004-10-23 20:04:14 +0000265#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000266# Options To Invoke Tools
Reid Spencer3a561f52004-10-23 20:04:14 +0000267#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000268
269CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
270
Reid Spencercc2d1e22004-10-30 09:19:36 +0000271LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
272CPP.Flags += -I$(BUILD_OBJ_DIR) \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000273 -I$(BUILD_SRC_DIR) \
274 -I$(BUILD_SRC_ROOT)/include \
275 -I$(BUILD_OBJ_ROOT)/include \
276 -I$(LLVM_OBJ_ROOT)/include \
277 -I$(LLVM_SRC_ROOT)/include \
278 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
Reid Spencer4d71b662004-10-22 21:01:56 +0000279
Reid Spencercc2d1e22004-10-30 09:19:36 +0000280Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
281LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
282BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
283Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
284LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
285BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
286Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
287 $(CompileCommonOpts) $(LD.Flags) $(Strip)
288Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencera69b1ea2004-10-28 09:15:28 +0000289 $(CompileCommonOpts)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000290LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
Reid Spencer3a561f52004-10-23 20:04:14 +0000291Burg = $(BURG) -I $(BUILD_SRC_DIR)
292TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000293Archive = $(AR) $(AR.Flags)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000294LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencer4d71b662004-10-22 21:01:56 +0000295ifdef RANLIB
Reid Spencer3a561f52004-10-23 20:04:14 +0000296Ranlib = $(RANLIB)
Reid Spencer4d71b662004-10-22 21:01:56 +0000297else
Reid Spencer3a561f52004-10-23 20:04:14 +0000298Ranlib = ranlib
John Criswell7a73b802003-06-30 21:59:07 +0000299endif
300
Chris Lattner00950542001-06-06 20:29:01 +0000301#----------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +0000302# Get the list of source files and compute object file
303# names from them.
Reid Spencer3a561f52004-10-23 20:04:14 +0000304#----------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +0000305ifdef FAKE_SOURCES
306 Sources :=
307 FakeSources := $(FAKE_SOURCES)
308 ifdef BUILT_SOURCES
309 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
310 endif
311 BaseNameSources := $(sort $(basename $(FakeSources)))
312 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
313 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
314 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000315else
Reid Spencer345235ca2004-12-04 22:34:09 +0000316 ifndef SOURCES
317 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
318 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
319 $(BUILD_SRC_DIR)/*.l))
320 else
321 Sources := $(SOURCES)
322 endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000323
Reid Spencer345235ca2004-12-04 22:34:09 +0000324 ifdef BUILT_SOURCES
325 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
326 endif
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000327
Reid Spencer345235ca2004-12-04 22:34:09 +0000328 BaseNameSources := $(sort $(basename $(Sources)))
329 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
330 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
331 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
332endif
Reid Spencer3a561f52004-10-23 20:04:14 +0000333
334###############################################################################
335# DIRECTORIES: Handle recursive descent of directory structure
336###############################################################################
John Criswell82f4a5a2003-07-31 20:58:51 +0000337
Chris Lattner00950542001-06-06 20:29:01 +0000338#---------------------------------------------------------
Reid Spencera69b1ea2004-10-28 09:15:28 +0000339# Provide rules to make install dirs. This must be early
340# in the file so they get built before dependencies
341#---------------------------------------------------------
342
343$(bindir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000344 $(Verb) $(MKDIR) $(bindir)
Chris Lattnere4cb90f2004-11-01 06:14:59 +0000345
Reid Spencera69b1ea2004-10-28 09:15:28 +0000346$(libdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000347 $(Verb) $(MKDIR) $(libdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000348
349$(bytecode_libdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000350 $(Verb) $(MKDIR) $(bytecode_libdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000351
352$(sysconfdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000353 $(Verb) $(MKDIR) $(sysconfdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000354
Reid Spencercc2d1e22004-10-30 09:19:36 +0000355# To create other directories, as needed, and timestamp their creation
356%/.dir:
357 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfbbf3072004-11-29 05:00:33 +0000358 $(Verb) $(DATE) > $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000359
Reid Spencer815cbcf2004-11-18 10:03:46 +0000360.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
361.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000362
363#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000364# Handle the DIRS options for sequential construction
Chris Lattner00950542001-06-06 20:29:01 +0000365#---------------------------------------------------------
366
Reid Spencercc2d1e22004-10-30 09:19:36 +0000367SubDirs :=
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000368ifdef DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000369SubDirs += $(DIRS)
370$(RecursiveTargets)::
371 $(Verb) for dir in $(DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000372 if [ ! -f $$dir/Makefile ]; then \
373 $(MKDIR) $$dir; \
374 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
375 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000376 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000377 done
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000378endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000379
Reid Spencer3a561f52004-10-23 20:04:14 +0000380#---------------------------------------------------------
381# Handle the EXPERIMENTAL_DIRS options ensuring success
382# after each directory is built.
383#---------------------------------------------------------
384ifdef EXPERIMENTAL_DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000385$(RecursiveTargets)::
386 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer3a561f52004-10-23 20:04:14 +0000387 if [ ! -f $$dir/Makefile ]; then \
388 $(MKDIR) $$dir; \
389 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
390 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000391 ($(MAKE) -C $$dir $@ ) || exit 0; \
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 Spencer151f8ba2004-10-25 08:27:37 +0000417 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
Chris Lattner00950542001-06-06 20:29:01 +0000418endif
419
Reid Spencer3a561f52004-10-23 20:04:14 +0000420#---------------------------------------------------------
421# Handle the OPTIONAL_DIRS options for directores that may
422# or may not exist.
423#---------------------------------------------------------
John Criswell2a6530f2003-06-27 16:58:44 +0000424ifdef OPTIONAL_DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000425
Reid Spencercc2d1e22004-10-30 09:19:36 +0000426SubDirs += $(OPTIONAL_DIRS)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000427
Reid Spencercc2d1e22004-10-30 09:19:36 +0000428$(RecursiveTargets)::
429 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000430 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
431 if [ ! -f $$dir/Makefile ]; then \
432 $(MKDIR) $$dir; \
433 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
434 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000435 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000436 fi \
John Criswell2a6530f2003-06-27 16:58:44 +0000437 done
438endif
439
Reid Spencerfc945082004-08-20 09:20:05 +0000440#---------------------------------------------------------
441# Handle the CONFIG_FILES options
442#---------------------------------------------------------
443ifdef CONFIG_FILES
Reid Spencerfc945082004-08-20 09:20:05 +0000444
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000445install-local:: $(sysconfdir) $(CONFIG_FILES)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000446 $(Echo) Installing Configuration Files To $(sysconfdir)
447 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer1b426ab2004-11-23 05:59:53 +0000448 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
449 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
450 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
451 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
452 else \
453 $(ECHO) Error: cannot find config file $${file}. ; \
454 fi \
Reid Spencerfc945082004-08-20 09:20:05 +0000455 done
Reid Spencer3a561f52004-10-23 20:04:14 +0000456
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000457uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000458 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
459 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000460 $(RM) -f $(sysconfdir)/$${file} ; \
Reid Spencere5487ba2004-10-24 07:53:21 +0000461 done
462
Reid Spencerfc945082004-08-20 09:20:05 +0000463endif
464
Reid Spencer3a561f52004-10-23 20:04:14 +0000465###############################################################################
466# Library Build Rules: Four ways to build a library
467###############################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000468
Reid Spencer7980ea42004-12-05 05:17:22 +0000469#---------------------------------------------------------
470# Bytecode Module Targets:
471# If the user set MODULE_NAME then they want to build a
472# bytecode module from the sources. We compile all the
473# sources and link it together into a single bytecode
474# module.
475#---------------------------------------------------------
476
477ifdef MODULE_NAME
478
479Module := $(LibDir)/$(MODULE_NAME).bc
480LinkModule := $(LLVMGCC) -shared -nostdlib
481
482ifdef EXPORTED_SYMBOL_FILE
483LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
484endif
485
486$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
487 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
488 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
489
490all-local:: $(Module)
491
492clean-local::
493ifneq ($(strip $(Module)),)
494 -$(Verb) $(RM) -f $(Module)
495endif
496
497DestModule := $(bytecode_libdir)/$(MODULE_NAME).bc
498
499install-local:: $(DestModule)
500
501$(DestModule): $(bytecode_libdir) $(Module)
502 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
503 $(Verb) $(INSTALL) $(Module) $@
504
505uninstall-local::
506 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
507 -$(Verb) $(RM) -f $(DestModule)
508
509endif
Brian Gaeke8abff792004-01-22 22:53:48 +0000510
Reid Spencer3a561f52004-10-23 20:04:14 +0000511# if we're building a library ...
Chris Lattner00950542001-06-06 20:29:01 +0000512ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000513
Chris Lattner2a548c52002-09-16 22:36:42 +0000514# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000515LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000516LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
517LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
518LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer9a2f1372004-12-02 09:28:21 +0000519LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000520
Reid Spencer3a561f52004-10-23 20:04:14 +0000521#---------------------------------------------------------
522# Shared Library Targets:
523# If the user asked for a shared library to be built
524# with the SHARED_LIBRARY variable, then we provide
525# targets for building them.
526#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000527ifdef SHARED_LIBRARY
528
Reid Spencercc2d1e22004-10-30 09:19:36 +0000529all-local:: $(LibName.LA)
Reid Spencer4d71b662004-10-22 21:01:56 +0000530
Reid Spencercc2d1e22004-10-30 09:19:36 +0000531$(LibName.LA): $(BUILT_SOURCES) $(ObjectsLO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000532 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000533 $(Verb) $(Link) -o $@ $(ObjectsLO)
534 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencer3a561f52004-10-23 20:04:14 +0000535
536clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000537ifneq ($(strip $(LibName.LA)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000538 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000539endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000540
Reid Spencere5487ba2004-10-24 07:53:21 +0000541DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencer4d71b662004-10-22 21:01:56 +0000542
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000543install-local:: $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000544
Reid Spencercc2d1e22004-10-30 09:19:36 +0000545$(DestSharedLib): $(libdir) $(LibName.LA)
Reid Spencer9af3b292004-11-01 07:50:27 +0000546 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000547 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
548 $(Verb) $(LIBTOOL) --finish $(libdir)
Reid Spencere5487ba2004-10-24 07:53:21 +0000549
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000550uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000551 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencer12d79512004-11-12 02:27:36 +0000552 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
Reid Spencere5487ba2004-10-24 07:53:21 +0000553
Reid Spencer4d71b662004-10-22 21:01:56 +0000554endif
555
Reid Spencer3a561f52004-10-23 20:04:14 +0000556#---------------------------------------------------------
557# Bytecode Library Targets:
558# If the user asked for a bytecode library to be built
559# with the BYTECODE_LIBRARY variable, then we provide
560# targets for building them.
561#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000562ifdef BYTECODE_LIBRARY
563
Reid Spencer776b8052004-12-03 06:04:35 +0000564# make the C and C++ compilers strip debug info out of bytecode libraries.
565BCCompile.C += -Wa,-strip-debug
566BCCompile.CXX += -Wa,-strip-debug
567
Reid Spencer9a2f1372004-12-02 09:28:21 +0000568all-local:: $(LibName.BCA)
569
570ifdef EXPORTED_SYMBOL_FILE
571BCLinkLib = $(LLVMGCC) -shared -nostdlib -Xlinker \
572 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
573
574$(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
575 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
576 "(internalize)"
Chris Lattnerb0ea8642004-12-02 21:23:43 +0000577 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000578 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencer4d71b662004-10-22 21:01:56 +0000579else
Reid Spencer345235ca2004-12-04 22:34:09 +0000580$(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir
Reid Spencer9a2f1372004-12-02 09:28:21 +0000581 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
582 $(Verb) $(LArchive) $@ $(ObjectsBC)
583
Reid Spencer4d71b662004-10-22 21:01:56 +0000584endif
585
Reid Spencer3a561f52004-10-23 20:04:14 +0000586clean-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000587ifneq ($(strip $(LibName.BCA)),)
588 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000589endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000590
Reid Spencer9a2f1372004-12-02 09:28:21 +0000591DestBytecodeLib = $(bytecode_libdir)/lib$(LIBRARYNAME).a
592
Reid Spencer44cb1b32004-12-03 20:08:48 +0000593install-bytecode-local:: $(DestBytecodeLib)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000594
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000595install-local:: $(DestBytecodeLib)
Chris Lattner481cc7c2003-08-15 02:18:35 +0000596
Reid Spencer9a2f1372004-12-02 09:28:21 +0000597$(DestBytecodeLib): $(bytecode_libdir) $(LibName.BCA)
598 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
599 $(Verb) $(INSTALL) $(LibName.BCA) $@
Reid Spencere5487ba2004-10-24 07:53:21 +0000600
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000601uninstall-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000602 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000603 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000604
605endif
Vikram S. Adve60f56062002-08-02 18:34:12 +0000606
Reid Spencercc2d1e22004-10-30 09:19:36 +0000607#---------------------------------------------------------
608# ReLinked Library Targets:
609# If the user didn't explicitly forbid building a
610# relinked then we provide targets for building them.
611#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000612ifndef DONT_BUILD_RELINKED
Reid Spencer4d71b662004-10-22 21:01:56 +0000613
Reid Spencercc2d1e22004-10-30 09:19:36 +0000614all-local:: $(LibName.O)
615
616$(LibName.O): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000617 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000618 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencer4d71b662004-10-22 21:01:56 +0000619
Reid Spencer3a561f52004-10-23 20:04:14 +0000620clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000621ifneq ($(strip $(LibName.O)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000622 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencere5487ba2004-10-24 07:53:21 +0000623endif
624
625DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
626
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000627install-local:: $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000628
Reid Spencercc2d1e22004-10-30 09:19:36 +0000629$(DestRelinkedLib): $(libdir) $(LibName.O)
Reid Spencer9af3b292004-11-01 07:50:27 +0000630 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000631 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000632
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000633uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000634 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000635 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000636
Chris Lattnere62dbe92002-07-23 17:56:16 +0000637endif
Chris Lattner760da062003-03-14 20:25:22 +0000638
Reid Spencercc2d1e22004-10-30 09:19:36 +0000639#---------------------------------------------------------
640# Archive Library Targets:
641# If the user wanted a regular archive library built,
642# then we provide targets for building them.
643#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000644ifdef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000645
Reid Spencercc2d1e22004-10-30 09:19:36 +0000646all-local:: $(LibName.A)
647
648$(LibName.A): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000649 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000650 -$(Verb) $(RM) -f $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000651 $(Verb) $(Archive) $@ $(ObjectsO)
652 $(Verb) $(Ranlib) $@
Vikram S. Adve41e78912002-09-20 14:03:13 +0000653
Reid Spencer3a561f52004-10-23 20:04:14 +0000654clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000655ifneq ($(strip $(LibName.A)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000656 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner00950542001-06-06 20:29:01 +0000657endif
658
Reid Spencere5487ba2004-10-24 07:53:21 +0000659DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
660
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000661install-local:: $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000662
Reid Spencercc2d1e22004-10-30 09:19:36 +0000663$(DestArchiveLib): $(libdir) $(LibName.A)
Reid Spencer9af3b292004-11-01 07:50:27 +0000664 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000665 $(Verb) $(MKDIR) $(libdir)
666 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000667
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000668uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000669 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000670 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000671
672endif
673
674# endif LIBRARYNAME
Reid Spencer4d71b662004-10-22 21:01:56 +0000675endif
676
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000677###############################################################################
678# Tool Build Rules: Build executable tool based on TOOLNAME option
679###############################################################################
680
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000681ifdef TOOLNAME
682
Reid Spencercc2d1e22004-10-30 09:19:36 +0000683#---------------------------------------------------------
Reid Spencer7c787c92004-11-29 07:17:07 +0000684# Handle the special "JIT" value for LLVM_LIBS which is a
685# shorthand for a bunch of libraries that get the correct
686# JIT support for a tool that runs JIT.
687#---------------------------------------------------------
688ifeq ($(LLVMLIBS),JIT)
689
690# Make sure we can get our own symbols in the tool
691Link += -dlopen self
692
693# Generic JIT libraries
694JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
695
696# You can enable the X86 JIT on a non-X86 host by setting the flag
697# ENABLE_X86_JIT on the make command line. If not, it will still be
698# enabled automagically on an X86 host.
699ifeq ($(ARCH), x86)
700 ENABLE_X86_JIT = 1
701endif
702
703# What the X86 JIT requires
704ifdef ENABLE_X86_JIT
705 JIT_LIBS += LLVMX86 LLVMSelectionDAG
706endif
707
708# You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
709# ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
710# enabled automagically on an SparcV9 host.
711ifeq ($(ARCH), Sparc)
712 ENABLE_SPARCV9_JIT = 1
713endif
714
715# What the Sparc JIT requires
716ifdef ENABLE_SPARCV9_JIT
717 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
718 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
719 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
720 LLVMDataStructure.a LLVMSparcV9RegAlloc
721endif
722
723# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
724# ENABLE_PPC_JIT on the make command line. If not, it will still be
725# enabled automagically on an PowerPC host.
726ifeq ($(ARCH), PowerPC)
727 ENABLE_PPC_JIT = 1
728endif
729
730# What the PowerPC JIT requires
731ifdef ENABLE_PPC_JIT
732 JIT_LIBS += LLVMPowerPC
733endif
734
735LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
736 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
737 LLVMSystem.a $(PLATFORMLIBDL)
738endif
739
740#---------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000741# Set up variables for building a tool.
742#---------------------------------------------------------
Reid Spencer815cbcf2004-11-18 10:03:46 +0000743ifdef EXAMPLE_TOOL
744ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
745else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000746ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000747endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000748ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
749ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
750LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
751LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
752ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
753LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
754ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
755LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000756
Reid Spencercc2d1e22004-10-30 09:19:36 +0000757#---------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000758# Tell make that we need to rebuild subdirectories before
759# we can link the tool. This affects things like LLI which
760# has library subdirectories.
761#---------------------------------------------------------
762$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000763
Reid Spencercc2d1e22004-10-30 09:19:36 +0000764#---------------------------------------------------------
765# Provide targets for building the tools
766#---------------------------------------------------------
767all-local:: $(ToolBuildPath)
John Criswell2a6530f2003-06-27 16:58:44 +0000768
Reid Spencer3a561f52004-10-23 20:04:14 +0000769clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000770ifneq ($(strip $(ToolBuildPath)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000771 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencere5487ba2004-10-24 07:53:21 +0000772endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000773
Reid Spencer815cbcf2004-11-18 10:03:46 +0000774ifdef EXAMPLE_TOOL
775$(ToolBuildPath): $(ExmplDir)/.dir
776else
777$(ToolBuildPath): $(ToolDir)/.dir
778endif
779
780$(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencer9af3b292004-11-01 07:50:27 +0000781 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000782 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
783 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
Reid Spencer9af3b292004-11-01 07:50:27 +0000784 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencere5487ba2004-10-24 07:53:21 +0000785
786DestTool = $(bindir)/$(TOOLNAME)
787
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000788install-local:: $(DestTool)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000789
Reid Spencercc2d1e22004-10-30 09:19:36 +0000790$(DestTool): $(bindir) $(ToolBuildPath)
Reid Spencer9af3b292004-11-01 07:50:27 +0000791 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000792 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000793
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000794uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000795 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000796 -$(Verb) $(RM) -f $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000797
Reid Spencer4d71b662004-10-22 21:01:56 +0000798endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000799
Reid Spencercc2d1e22004-10-30 09:19:36 +0000800###############################################################################
801# Object Build Rules: Build object files based on sources
802###############################################################################
803
804# Provide rule sets for when dependency generation is enabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000805ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve41e78912002-09-20 14:03:13 +0000806
Reid Spencercc2d1e22004-10-30 09:19:36 +0000807#---------------------------------------------------------
808# Create .lo files in the ObjDir directory from the .cpp and .c files...
809#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000810ifdef SHARED_LIBRARY
811
Reid Spencercc2d1e22004-10-30 09:19:36 +0000812$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000813 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000814 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
815 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
816 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000817
Reid Spencercc2d1e22004-10-30 09:19:36 +0000818$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000819 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000820 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
821 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
822 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000823
Reid Spencercc2d1e22004-10-30 09:19:36 +0000824#---------------------------------------------------------
825# Create .o files in the ObjDir directory from the .cpp and .c files...
826#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000827else
Reid Spencer4d71b662004-10-22 21:01:56 +0000828
Reid Spencercc2d1e22004-10-30 09:19:36 +0000829$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000830 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000831 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
832 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
833 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000834
Reid Spencercc2d1e22004-10-30 09:19:36 +0000835$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000836 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000837 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
838 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
839 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000840
841endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000842
Reid Spencercc2d1e22004-10-30 09:19:36 +0000843#---------------------------------------------------------
844# Create .bc files in the ObjDir directory from .cpp and .c files...
845#---------------------------------------------------------
Chris Lattner478b3b42004-11-29 19:47:58 +0000846$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000847 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000848 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
849 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
850 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000851
Chris Lattner478b3b42004-11-29 19:47:58 +0000852$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000853 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000854 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
855 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
856 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000857
Reid Spencercc2d1e22004-10-30 09:19:36 +0000858# Provide alternate rule sets if dependencies are disabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000859else
860
Reid Spencer3a561f52004-10-23 20:04:14 +0000861ifdef SHARED_LIBRARY
862
Reid Spencercc2d1e22004-10-30 09:19:36 +0000863$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000864 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000865 $(LTCompile.CXX) $< -o $@
866
Reid Spencercc2d1e22004-10-30 09:19:36 +0000867$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000868 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000869 $(LTCompile.C) $< -o $@
870
871else
Reid Spencer4d71b662004-10-22 21:01:56 +0000872
Reid Spencercc2d1e22004-10-30 09:19:36 +0000873$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000874 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +0000875 $(Compile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000876
Reid Spencercc2d1e22004-10-30 09:19:36 +0000877$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000878 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +0000879 $(Compile.C) $< -o $@
880endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000881
Chris Lattner478b3b42004-11-29 19:47:58 +0000882$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000883 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencer8676b7e2004-10-31 18:52:15 +0000884 $(BCCompile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000885
Chris Lattner478b3b42004-11-29 19:47:58 +0000886$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000887 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencer8676b7e2004-10-31 18:52:15 +0000888 $(BCCompile.C) $< -o $@
Brian Gaeke44909cf2003-12-10 00:26:28 +0000889
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000890endif
891
Reid Spencercc2d1e22004-10-30 09:19:36 +0000892#---------------------------------------------------------
893# Provide rule to build .bc files from .ll sources,
894# regardless of dependencies
895#---------------------------------------------------------
896$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000897 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000898 $(Verb) $(LLVMAS) $< -f -o $@
899
900###############################################################################
901# TABLEGEN: Provide rules for running tblgen to produce *.inc files
902###############################################################################
Chris Lattner481cc7c2003-08-15 02:18:35 +0000903
Reid Spencer4d71b662004-10-22 21:01:56 +0000904ifdef TARGET
905
Reid Spencercc2d1e22004-10-30 09:19:36 +0000906TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
907INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Reid Spencer4d71b662004-10-22 21:01:56 +0000908
Reid Spencercc2d1e22004-10-30 09:19:36 +0000909$(INCFiles) : $(TBLGEN) $(TDFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +0000910
Reid Spencer16544482004-10-27 04:34:35 +0000911%GenRegisterNames.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000912 $(Echo) "Building $(<F) register names with tblgen"
913 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000914
Reid Spencer16544482004-10-27 04:34:35 +0000915%GenRegisterInfo.h.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000916 $(Echo) "Building $(<F) register information header with tblgen"
917 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000918
919%GenRegisterInfo.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000920 $(Echo) "Building $(<F) register info implementation with tblgen"
921 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000922
923%GenInstrNames.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000924 $(Echo) "Building $(<F) instruction names with tblgen"
925 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000926
927%GenInstrInfo.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000928 $(Echo) "Building $(<F) instruction information with tblgen"
929 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000930
931%GenAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000932 $(Echo) "Building $(<F) assembly writer with tblgen"
933 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000934
935%GenATTAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000936 $(Echo) "Building $(<F) AT&T assembly writer with tblgen"
937 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000938
939%GenIntelAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000940 $(Echo) "Building $(<F) Intel assembly writer with tblgen"
941 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000942
943%GenInstrSelector.inc: %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000944 $(Echo) "Building $(<F) instruction selector with tblgen"
945 $(Verb) $(TableGen) -gen-instr-selector -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000946
947%GenCodeEmitter.inc:: %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000948 $(Echo) "Building $(<F) code emitter with tblgen"
949 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000950
Reid Spencer3a561f52004-10-23 20:04:14 +0000951clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000952 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +0000953
954endif
Chris Lattner481cc7c2003-08-15 02:18:35 +0000955
Reid Spencercc2d1e22004-10-30 09:19:36 +0000956###############################################################################
957# LEX AND YACC: Provide rules for generating sources with lex and yacc
958###############################################################################
Chris Lattnere8996782003-01-16 22:44:19 +0000959
Reid Spencercc2d1e22004-10-30 09:19:36 +0000960#---------------------------------------------------------
961# Provide rules for generating a .cpp source file from
962# (f)lex input sources.
963#---------------------------------------------------------
964
Reid Spencer3d659492004-11-02 16:36:03 +0000965LexFiles := $(filter %.l,$(Sources))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000966
Reid Spencer3d659492004-11-02 16:36:03 +0000967ifneq ($(LexFiles),)
968
969LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000970
971.PRECIOUS: $(LexOutput)
972
973# Note the extra sed filtering here, used to cut down on the warnings emited
974# by GCC. The last line is a gross hack to work around flex aparently not
975# being able to resize the buffer on a large token input. Currently, for
976# uninitialized string buffers in LLVM we can generate very long tokens, so
977# this is a hack around it.
Chris Lattnerb7dc2b92003-08-15 20:00:47 +0000978# FIXME. (f.e. char Buffer[10000] )
Chris Lattner00950542001-06-06 20:29:01 +0000979%.cpp: %.l
Reid Spencercc2d1e22004-10-30 09:19:36 +0000980 $(Echo) Flexing $<
981 $(Verb) $(FLEX) -t $< | \
Reid Spencer4d71b662004-10-22 21:01:56 +0000982 $(SED) 's/void yyunput/inline void yyunput/' | \
983 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
984 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencer80f0ef72004-10-28 00:41:43 +0000985 > $@
Chris Lattner00950542001-06-06 20:29:01 +0000986
Reid Spencer9af3b292004-11-01 07:50:27 +0000987clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000988 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencer3d659492004-11-02 16:36:03 +0000989 $(Verb) $(RM) -f $(LexOutput)
Reid Spencer9af3b292004-11-01 07:50:27 +0000990
Reid Spencercc2d1e22004-10-30 09:19:36 +0000991endif
992
993#---------------------------------------------------------
994# Provide rules for generating a .cpp and .h source files
995# from yacc (bison) input sources.
996#---------------------------------------------------------
997
Reid Spencer3d659492004-11-02 16:36:03 +0000998YaccFiles := $(filter %.y,$(Sources))
999ifneq ($(YaccFiles),)
1000YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001001
1002.PRECIOUS: $(YaccOutput)
1003
1004# Cancel built-in rules for yacc
1005%.c: %.y
1006%.cpp: %.y
1007%.h: %.y
1008
Chris Lattner00950542001-06-06 20:29:01 +00001009# Rule for building the bison parsers...
Chris Lattner00950542001-06-06 20:29:01 +00001010%.cpp %.h : %.y
Reid Spencercc2d1e22004-10-30 09:19:36 +00001011 $(Echo) "Bisoning $*.y"
1012 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1013 $(Verb) $(MV) -f $*.tab.c $*.cpp
1014 $(Verb) $(MV) -f $*.tab.h $*.h
Chris Lattner00950542001-06-06 20:29:01 +00001015
Reid Spencer9af3b292004-11-01 07:50:27 +00001016clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001017 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencer3d659492004-11-02 16:36:03 +00001018 $(Verb) $(RM) -f $(YaccOutput)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001019endif
Chris Lattner00950542001-06-06 20:29:01 +00001020
Reid Spencercc2d1e22004-10-30 09:19:36 +00001021###############################################################################
1022# OTHER RULES: Other rules needed
1023###############################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +00001024
Chris Lattner30440c62003-01-16 21:06:18 +00001025# To create postscript files from dot files...
John Criswelle0f9ac62003-10-02 19:02:02 +00001026ifneq ($(DOT),false)
Chris Lattner30440c62003-01-16 21:06:18 +00001027%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +00001028 $(DOT) -Tps < $< > $@
John Criswell7a73b802003-06-30 21:59:07 +00001029else
1030%.ps: %.dot
Reid Spencercc2d1e22004-10-30 09:19:36 +00001031 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell7a73b802003-06-30 21:59:07 +00001032endif
Chris Lattner30440c62003-01-16 21:06:18 +00001033
John Criswell7f336952003-09-06 14:44:17 +00001034# This rules ensures that header files that are removed still have a rule for
1035# which they can be "generated." This allows make to ignore them and
1036# reproduce the dependency lists.
John Criswell4b6e5d12003-09-18 18:37:08 +00001037%.h:: ;
John Criswell7f336952003-09-06 14:44:17 +00001038
Reid Spencercc2d1e22004-10-30 09:19:36 +00001039# Define clean-local to clean the current directory. Note that this uses a
1040# very conservative approach ensuring that empty variables do not cause
1041# errors or disastrous removal.
Reid Spencer3a561f52004-10-23 20:04:14 +00001042clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001043ifneq ($(strip $(ObjDir)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001044 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencere5487ba2004-10-24 07:53:21 +00001045endif
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001046 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001047ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001048 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001049endif
John Criswell7a73b802003-06-30 21:59:07 +00001050
Reid Spencer3d659492004-11-02 16:36:03 +00001051clean-all-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001052 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer3d659492004-11-02 16:36:03 +00001053
Reid Spencercc2d1e22004-10-30 09:19:36 +00001054# Build tags database for Emacs/Xemacs:
Reid Spencer12d79512004-11-12 02:27:36 +00001055tags:: TAGS CTAGS
1056
Reid Spencercc2d1e22004-10-30 09:19:36 +00001057TAGS:
Reid Spencer12d79512004-11-12 02:27:36 +00001058 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1059 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1060 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1061 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1062 -name '*.cpp' -o -name '*.h' | \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001063 $(ETAGS) $(ETAGSFLAGS) -
1064
Reid Spencer12d79512004-11-12 02:27:36 +00001065CTAGS:
1066 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1067 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1068 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1069 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1070 \( -name '*.cpp' -o -name '*.h' \) -print | \
1071 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1072
1073
Reid Spencer3a561f52004-10-23 20:04:14 +00001074###############################################################################
1075# DEPENDENCIES: Include the dependency files if we should
1076###############################################################################
Chris Lattner33ad24a2003-08-22 14:10:16 +00001077ifndef DISABLE_AUTO_DEPENDENCIES
1078
Reid Spencer3a561f52004-10-23 20:04:14 +00001079# If its not one of the cleaning targets
Reid Spencercc2d1e22004-10-30 09:19:36 +00001080ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencer4d71b662004-10-22 21:01:56 +00001081
Reid Spencer3a561f52004-10-23 20:04:14 +00001082# Get the list of dependency files
Reid Spencercc2d1e22004-10-30 09:19:36 +00001083DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Reid Spencer9af3b292004-11-01 07:50:27 +00001084DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
Misha Brukman4f7a8cf2003-11-09 21:36:19 +00001085
Reid Spencer3a561f52004-10-23 20:04:14 +00001086-include /dev/null $(DependFiles)
1087
John Criswelld741bcf2003-08-12 18:51:51 +00001088endif
Chris Lattner1ddb6b62003-08-18 17:27:40 +00001089
Reid Spencercc2d1e22004-10-30 09:19:36 +00001090endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001091
Reid Spencer151f8ba2004-10-25 08:27:37 +00001092###############################################################################
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001093# CHECK: Running the test suite
1094###############################################################################
1095
1096check::
1097 $(Verb) if test -d "$(BUILD_OBJ_ROOT)/test" ; then \
1098 if test -f "$(BUILD_OBJ_ROOT)/test/Makefile" ; then \
1099 $(EchoCmd) Running test suite ; \
1100 $(MAKE) -C $(BUILD_OBJ_ROOT)/test check-local \
1101 TESTSUITE=$(TESTSUITE) ; \
1102 else \
1103 $(EchoCmd) No Makefile in test directory ; \
1104 fi ; \
1105 else \
1106 $(EchoCmd) No test directory ; \
1107 fi
1108
1109###############################################################################
Reid Spencercc2d1e22004-10-30 09:19:36 +00001110# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer151f8ba2004-10-25 08:27:37 +00001111###############################################################################
1112
Reid Spencere45ebfa2004-10-26 07:09:33 +00001113#------------------------------------------------------------------------
1114# Define distribution related variables
1115#------------------------------------------------------------------------
Reid Spencer151f8ba2004-10-25 08:27:37 +00001116DistName := $(LLVM_TARBALL_NAME)
1117DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001118TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer151f8ba2004-10-25 08:27:37 +00001119DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1120DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1121DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1122DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1123 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001124 Makefile.config.in configure autoconf
1125DistOther := $(notdir $(wildcard \
1126 $(BUILD_SRC_DIR)/*.h \
1127 $(BUILD_SRC_DIR)/*.td \
1128 $(BUILD_SRC_DIR)/*.def \
1129 $(BUILD_SRC_DIR)/*.ll \
1130 $(BUILD_SRC_DIR)/*.in))
Reid Spencercc2d1e22004-10-30 09:19:36 +00001131DistSubDirs := $(SubDirs)
Reid Spencerfbbf3072004-11-29 05:00:33 +00001132DistSources = $(Sources) $(EXTRA_DIST)
1133DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer151f8ba2004-10-25 08:27:37 +00001134
Reid Spencere45ebfa2004-10-26 07:09:33 +00001135#------------------------------------------------------------------------
1136# We MUST build distribution with OBJ_DIR != SRC_DIR
1137#------------------------------------------------------------------------
1138ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1139dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001140 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencere45ebfa2004-10-26 07:09:33 +00001141
Reid Spencere45ebfa2004-10-26 07:09:33 +00001142else
1143
Reid Spencere45ebfa2004-10-26 07:09:33 +00001144#------------------------------------------------------------------------
1145# Prevent catastrophic remove
1146#------------------------------------------------------------------------
1147ifeq ($(LLVM_TARBALL_NAME),)
1148$(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1149endif
1150
1151#------------------------------------------------------------------------
1152# Prevent attempt to run dist targets from anywhere but the top level
1153#------------------------------------------------------------------------
1154ifneq ($(LEVEL),.)
1155
1156dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001157 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001158
1159else
1160
1161#------------------------------------------------------------------------
1162# Provide the top level targets
1163#------------------------------------------------------------------------
1164
Reid Spencercc2d1e22004-10-30 09:19:36 +00001165dist-gzip:: $(DistTarGZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001166
Reid Spencer345235ca2004-12-04 22:34:09 +00001167$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001168 $(Echo) Packing gzipped distribution tar file.
Reid Spencerfbbf3072004-11-29 05:00:33 +00001169 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1170 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencere45ebfa2004-10-26 07:09:33 +00001171
Reid Spencercc2d1e22004-10-30 09:19:36 +00001172dist-bzip2:: $(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001173
Reid Spencer345235ca2004-12-04 22:34:09 +00001174$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001175 $(Echo) Packing bzipped distribution tar file.
Reid Spencerfbbf3072004-11-29 05:00:33 +00001176 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1177 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001178
Reid Spencercc2d1e22004-10-30 09:19:36 +00001179dist-zip:: $(DistZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001180
Reid Spencer345235ca2004-12-04 22:34:09 +00001181$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001182 $(Echo) Packing zipped distribution file.
1183 $(Verb) rm -f $(DistZip)
1184 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001185
1186dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001187 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001188
1189DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1190
Reid Spencer345235ca2004-12-04 22:34:09 +00001191dist-check:: $(DistTarGZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001192 $(Echo) Checking distribution tar file.
1193 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001194 $(RM) -rf $(DistCheckDir) ; \
1195 fi
Reid Spencercc2d1e22004-10-30 09:19:36 +00001196 $(Verb) $(MKDIR) $(DistCheckDir)
1197 $(Verb) cd $(DistCheckDir) && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001198 $(MKDIR) $(DistCheckDir)/build && \
1199 $(MKDIR) $(DistCheckDir)/install && \
1200 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1201 cd build && \
1202 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1203 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
Reid Spencer345235ca2004-12-04 22:34:09 +00001204 $(MAKE) all && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001205 $(MAKE) check && \
1206 $(MAKE) install && \
1207 $(MAKE) uninstall && \
1208 $(MAKE) dist && \
1209 $(MAKE) clean && \
1210 $(MAKE) dist-clean && \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001211 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001212
1213dist-clean::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001214 $(Echo) Cleaning distribution files
Reid Spencer345235ca2004-12-04 22:34:09 +00001215 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1216 $(DistCheckDir)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001217
1218endif
1219
1220#------------------------------------------------------------------------
1221# Provide the recursive distdir target for building the distribution directory
1222#------------------------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +00001223distdir: $(DistDir)/.makedistdir
1224$(DistDir)/.makedistdir: $(DistSources)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001225 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001226 if test -d "$(DistDir)" ; then \
1227 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1228 exit 1 ; \
1229 fi ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001230 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001231 $(RM) -rf $(DistDir); \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001232 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001233 $(MAKE) all ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001234 fi
Reid Spencerfbbf3072004-11-29 05:00:33 +00001235 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001236 $(Verb) $(MKDIR) $(DistDir)
1237 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001238 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1239 for file in $(DistFiles) ; do \
1240 case "$$file" in \
Reid Spencer345235ca2004-12-04 22:34:09 +00001241 $(BUILD_SRC_DIR)/*) \
1242 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1243 ;; \
1244 $(BUILD_SRC_ROOT)/*) \
1245 file=`echo "$$file" | \
1246 sed "s#^$$srcrootstrip/##"` \
1247 ;; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001248 esac; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001249 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1250 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1251 from_dir="$(BUILD_SRC_DIR)" ; \
1252 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001253 from_dir=. ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001254 fi ; \
1255 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001256 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1257 to_dir="$(DistDir)/$$dir"; \
1258 $(MKDIR) "$$to_dir" ; \
1259 else \
1260 to_dir="$(DistDir)"; \
1261 fi; \
1262 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1263 if test -n "$$mid_dir" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001264 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001265 fi ; \
1266 if test -d "$$from_dir/$$file"; then \
1267 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1268 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1269 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1270 fi; \
1271 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1272 elif test -f "$$from_dir/$$file" ; then \
1273 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1274 elif test -L "$$from_dir/$$file" ; then \
1275 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1276 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer345235ca2004-12-04 22:34:09 +00001277 $(EchoCmd) "===== WARNING: Distribution Source " \
1278 "$$from_dir/$$file Not Found!" ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001279 elif test "$(Verb)" != '@' ; then \
1280 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001281 fi; \
1282 done
Reid Spencercc2d1e22004-10-30 09:19:36 +00001283 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001284 if test "$$subdir" \!= "." ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001285 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001286 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001287 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1288 exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001289 fi; \
1290 done
Reid Spencer345235ca2004-12-04 22:34:09 +00001291 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1292 $(EchoCmd) Eliminating CVS directories from distribution ; \
1293 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1294 $(MAKE) dist-hook ; \
1295 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1296 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1297 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1298 -o ! -type d ! -perm -444 -exec \
1299 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1300 || chmod -R a+r $(DistDir) ; \
1301 fi
Reid Spencer151f8ba2004-10-25 08:27:37 +00001302
Reid Spencercc2d1e22004-10-30 09:19:36 +00001303# This is invoked by distdir target, define it as a no-op to avoid errors if not
1304# defined by user.
Reid Spencer151f8ba2004-10-25 08:27:37 +00001305dist-hook::
1306
Reid Spencere53e3972004-10-22 23:06:30 +00001307endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001308
1309###############################################################################
Reid Spencere5487ba2004-10-24 07:53:21 +00001310# TOP LEVEL - targets only to apply at the top level directory
1311###############################################################################
1312
1313ifeq ($(LEVEL),.)
1314
1315#------------------------------------------------------------------------
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001316# Install support for the project's include files:
Reid Spencere5487ba2004-10-24 07:53:21 +00001317#------------------------------------------------------------------------
1318install-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001319 $(Echo) Installing include files
1320 $(Verb) $(MKDIR) $(includedir)
1321 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencere5487ba2004-10-24 07:53:21 +00001322 cd $(BUILD_SRC_ROOT)/include && \
1323 find . -path '*/Internal' -prune -o '(' -type f \
1324 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1325 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1326 fi
1327
1328uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001329 $(Echo) Uninstalling include files
1330 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencere5487ba2004-10-24 07:53:21 +00001331 cd $(BUILD_SRC_ROOT)/include && \
1332 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1333 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1334 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1335 fi
1336
Reid Spencere5487ba2004-10-24 07:53:21 +00001337endif
1338
Reid Spencer4d71b662004-10-22 21:01:56 +00001339#------------------------------------------------------------------------
1340# Print out the directories used for building
Reid Spencercc2d1e22004-10-30 09:19:36 +00001341#------------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001342printvars::
Reid Spencer9af3b292004-11-01 07:50:27 +00001343 $(Echo) "BuildMode : " '$(BuildMode)'
Reid Spencercc2d1e22004-10-30 09:19:36 +00001344 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1345 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1346 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1347 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1348 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1349 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1350 $(Echo) "libdir : " '$(libdir)'
1351 $(Echo) "bindir : " '$(bindir)'
1352 $(Echo) "sysconfdir : " '$(sysconfdir)'
1353 $(Echo) "bytecode_libdir: " '$(bytecode_libdir)'
1354 $(Echo) "UserTargets : " '$(UserTargets)'
1355 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1356 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1357 $(Echo) "ObjDir : " '$(ObjDir)'
1358 $(Echo) "LibDir : " '$(LibDir)'
1359 $(Echo) "ToolDir : " '$(ToolDir)'
Reid Spencer815cbcf2004-11-18 10:03:46 +00001360 $(Echo) "ExmplDir : " '$(ExmplDir)'
Reid Spencer7980ea42004-12-05 05:17:22 +00001361 $(Echo) "Sources : " '$(Sources)'
Reid Spencercc2d1e22004-10-30 09:19:36 +00001362 $(Echo) "TDFiles : " '$(TDFiles)'
1363 $(Echo) "INCFiles : " '$(INCFiles)'
1364 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1365 $(Echo) "Compile.C : " '$(Compile.C)'
1366 $(Echo) "Archive : " '$(Archive)'
Reid Spencer3d659492004-11-02 16:36:03 +00001367 $(Echo) "YaccFiles : " '$(YaccFiles)'
1368 $(Echo) "LexFiles : " '$(LexFiles)'
Reid Spencer7980ea42004-12-05 05:17:22 +00001369 $(Echo) "Module : " '$(Module)'