blob: 75e1cde27540a9b7365bd4ff10ef597488926764 [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
234endif
235
Reid Spencer81cd0492004-10-23 20:04:14 +0000236# Adjust settings for verbose mode
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000237ifndef VERBOSE
Reid Spencerf88808a2004-10-30 09:19:36 +0000238 Verb := @
239 LibTool.Flags += --silent
240 AR.Flags += >/dev/null 2>/dev/null
241 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
Reid Spencer100080c2004-10-25 08:27:37 +0000242else
Reid Spencerf88808a2004-10-30 09:19:36 +0000243 ConfigureScriptFLAGS :=
Misha Brukman1326a7c2002-09-12 16:05:39 +0000244endif
245
Vikram S. Adved141c282002-09-18 11:55:13 +0000246# By default, strip symbol information from executable
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000247ifndef KEEP_SYMBOLS
Reid Spencerf88808a2004-10-30 09:19:36 +0000248 Strip := $(PLATFORMSTRIPOPTS)
249 StripWarnMsg := "(without symbols)"
Vikram S. Adved141c282002-09-18 11:55:13 +0000250endif
251
Reid Spencer81cd0492004-10-23 20:04:14 +0000252# Adjust linker flags for building an executable
Reid Spencerf206bd72004-10-22 21:01:56 +0000253ifdef TOOLNAME
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000254ifdef EXAMPLE_TOOL
255 LD.Flags += -rpath $(ExmplDir) -export-dynamic
256else
Reid Spencerf88808a2004-10-30 09:19:36 +0000257 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000258endif
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000259endif
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000260
Reid Spencer81cd0492004-10-23 20:04:14 +0000261#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000262# Options To Invoke Tools
Reid Spencer81cd0492004-10-23 20:04:14 +0000263#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000264
265CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
266
Reid Spencerf88808a2004-10-30 09:19:36 +0000267LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
268CPP.Flags += -I$(BUILD_OBJ_DIR) \
Reid Spencer100080c2004-10-25 08:27:37 +0000269 -I$(BUILD_SRC_DIR) \
270 -I$(BUILD_SRC_ROOT)/include \
271 -I$(BUILD_OBJ_ROOT)/include \
272 -I$(LLVM_OBJ_ROOT)/include \
273 -I$(LLVM_SRC_ROOT)/include \
274 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
Reid Spencerf206bd72004-10-22 21:01:56 +0000275
Reid Spencerf88808a2004-10-30 09:19:36 +0000276Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
277LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
278BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
279Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
280LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
281BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
282Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
283 $(CompileCommonOpts) $(LD.Flags) $(Strip)
284Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000285 $(CompileCommonOpts)
Reid Spencerf88808a2004-10-30 09:19:36 +0000286LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
Reid Spencer81cd0492004-10-23 20:04:14 +0000287Burg = $(BURG) -I $(BUILD_SRC_DIR)
288TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
Reid Spencerf88808a2004-10-30 09:19:36 +0000289Archive = $(AR) $(AR.Flags)
Reid Spencer32f7e422004-12-02 09:28:21 +0000290LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencerf206bd72004-10-22 21:01:56 +0000291ifdef RANLIB
Reid Spencer81cd0492004-10-23 20:04:14 +0000292Ranlib = $(RANLIB)
Reid Spencerf206bd72004-10-22 21:01:56 +0000293else
Reid Spencer81cd0492004-10-23 20:04:14 +0000294Ranlib = ranlib
John Criswell3ef61af2003-06-30 21:59:07 +0000295endif
296
Chris Lattner2f7c9632001-06-06 20:29:01 +0000297#----------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +0000298# Get the list of source files and compute object file
299# names from them.
Reid Spencer81cd0492004-10-23 20:04:14 +0000300#----------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +0000301ifdef FAKE_SOURCES
302 Sources :=
303 FakeSources := $(FAKE_SOURCES)
304 ifdef BUILT_SOURCES
305 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
306 endif
307 BaseNameSources := $(sort $(basename $(FakeSources)))
308 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
309 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
310 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
Reid Spencerf88808a2004-10-30 09:19:36 +0000311else
Reid Spencer81546582004-12-04 22:34:09 +0000312 ifndef SOURCES
313 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
314 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
315 $(BUILD_SRC_DIR)/*.l))
316 else
317 Sources := $(SOURCES)
318 endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000319
Reid Spencer81546582004-12-04 22:34:09 +0000320 ifdef BUILT_SOURCES
321 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
322 endif
Vikram S. Advefe346892001-07-15 13:16:47 +0000323
Reid Spencer81546582004-12-04 22:34:09 +0000324 BaseNameSources := $(sort $(basename $(Sources)))
325 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
326 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
327 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
328endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000329
330###############################################################################
331# DIRECTORIES: Handle recursive descent of directory structure
332###############################################################################
John Criswell3601f372003-07-31 20:58:51 +0000333
Chris Lattner2f7c9632001-06-06 20:29:01 +0000334#---------------------------------------------------------
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000335# Provide rules to make install dirs. This must be early
336# in the file so they get built before dependencies
337#---------------------------------------------------------
338
339$(bindir):
Reid Spencerf88808a2004-10-30 09:19:36 +0000340 $(Verb) $(MKDIR) $(bindir)
Chris Lattner615e7fb2004-11-01 06:14:59 +0000341
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000342$(libdir):
Reid Spencerf88808a2004-10-30 09:19:36 +0000343 $(Verb) $(MKDIR) $(libdir)
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000344
345$(bytecode_libdir):
Reid Spencerf88808a2004-10-30 09:19:36 +0000346 $(Verb) $(MKDIR) $(bytecode_libdir)
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000347
348$(sysconfdir):
Reid Spencerf88808a2004-10-30 09:19:36 +0000349 $(Verb) $(MKDIR) $(sysconfdir)
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000350
Reid Spencerf88808a2004-10-30 09:19:36 +0000351# To create other directories, as needed, and timestamp their creation
352%/.dir:
353 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfc66af42004-11-29 05:00:33 +0000354 $(Verb) $(DATE) > $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000355
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000356.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
357.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000358
359#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000360# Handle the DIRS options for sequential construction
Chris Lattner2f7c9632001-06-06 20:29:01 +0000361#---------------------------------------------------------
362
Reid Spencerf88808a2004-10-30 09:19:36 +0000363SubDirs :=
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000364ifdef DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000365SubDirs += $(DIRS)
366$(RecursiveTargets)::
367 $(Verb) for dir in $(DIRS); do \
Reid Spencerf206bd72004-10-22 21:01:56 +0000368 if [ ! -f $$dir/Makefile ]; then \
369 $(MKDIR) $$dir; \
370 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
371 fi; \
Reid Spencer4e197482004-12-08 22:58:34 +0000372 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
373 ($(MAKE) -C $$dir $@ ) || exit 1; \
374 fi ; \
Chris Lattner539a23c2002-09-17 23:35:02 +0000375 done
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000376endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000377
Reid Spencer81cd0492004-10-23 20:04:14 +0000378#---------------------------------------------------------
379# Handle the EXPERIMENTAL_DIRS options ensuring success
380# after each directory is built.
381#---------------------------------------------------------
382ifdef EXPERIMENTAL_DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000383$(RecursiveTargets)::
384 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer81cd0492004-10-23 20:04:14 +0000385 if [ ! -f $$dir/Makefile ]; then \
386 $(MKDIR) $$dir; \
387 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
388 fi; \
Reid Spencer4e197482004-12-08 22:58:34 +0000389 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
390 ($(MAKE) -C $$dir $@ ) || exit 0; \
391 fi ; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000392 done
393endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000394
Reid Spencer81cd0492004-10-23 20:04:14 +0000395#---------------------------------------------------------
396# Handle the PARALLEL_DIRS options for parallel construction
397#---------------------------------------------------------
398ifdef PARALLEL_DIRS
399
Reid Spencerf88808a2004-10-30 09:19:36 +0000400SubDirs += $(PARALLEL_DIRS)
401
Reid Spencerd4bd3752004-12-03 20:08:48 +0000402# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencerf88808a2004-10-30 09:19:36 +0000403all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
404clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000405clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencerf88808a2004-10-30 09:19:36 +0000406install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000407uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencerd4bd3752004-12-03 20:08:48 +0000408install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000409
Reid Spencer81546582004-12-04 22:34:09 +0000410ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer81cd0492004-10-23 20:04:14 +0000411
Reid Spencer81546582004-12-04 22:34:09 +0000412$(ParallelTargets) :
Reid Spencerf88808a2004-10-30 09:19:36 +0000413 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencerf206bd72004-10-22 21:01:56 +0000414 $(MKDIR) $(@D); \
415 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswell6df35dd2003-11-25 19:32:22 +0000416 fi; \
Reid Spencer4e197482004-12-08 22:58:34 +0000417 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
418 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
419 fi
Chris Lattner2f7c9632001-06-06 20:29:01 +0000420endif
421
Reid Spencer81cd0492004-10-23 20:04:14 +0000422#---------------------------------------------------------
423# Handle the OPTIONAL_DIRS options for directores that may
424# or may not exist.
425#---------------------------------------------------------
John Criswell8224df92003-06-27 16:58:44 +0000426ifdef OPTIONAL_DIRS
Reid Spencer100080c2004-10-25 08:27:37 +0000427
Reid Spencerf88808a2004-10-30 09:19:36 +0000428SubDirs += $(OPTIONAL_DIRS)
Reid Spencer100080c2004-10-25 08:27:37 +0000429
Reid Spencerf88808a2004-10-30 09:19:36 +0000430$(RecursiveTargets)::
431 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencerf206bd72004-10-22 21:01:56 +0000432 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
433 if [ ! -f $$dir/Makefile ]; then \
434 $(MKDIR) $$dir; \
435 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
436 fi; \
Reid Spencer4e197482004-12-08 22:58:34 +0000437 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
438 ($(MAKE) -C$$dir $@ ) || exit 1; \
439 fi ; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000440 fi \
John Criswell8224df92003-06-27 16:58:44 +0000441 done
442endif
443
Reid Spencercc51e7b2004-08-20 09:20:05 +0000444#---------------------------------------------------------
445# Handle the CONFIG_FILES options
446#---------------------------------------------------------
447ifdef CONFIG_FILES
Reid Spencercc51e7b2004-08-20 09:20:05 +0000448
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000449install-local:: $(sysconfdir) $(CONFIG_FILES)
Reid Spencerf88808a2004-10-30 09:19:36 +0000450 $(Echo) Installing Configuration Files To $(sysconfdir)
451 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer39d6a612004-11-23 05:59:53 +0000452 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
453 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
454 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
455 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
456 else \
457 $(ECHO) Error: cannot find config file $${file}. ; \
458 fi \
Reid Spencercc51e7b2004-08-20 09:20:05 +0000459 done
Reid Spencer81cd0492004-10-23 20:04:14 +0000460
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000461uninstall-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000462 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
463 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer100080c2004-10-25 08:27:37 +0000464 $(RM) -f $(sysconfdir)/$${file} ; \
Reid Spencer12a3a052004-10-24 07:53:21 +0000465 done
466
Reid Spencercc51e7b2004-08-20 09:20:05 +0000467endif
468
Reid Spencer81cd0492004-10-23 20:04:14 +0000469###############################################################################
470# Library Build Rules: Four ways to build a library
471###############################################################################
Chris Lattner2f7c9632001-06-06 20:29:01 +0000472
Reid Spencerd78077d2004-12-05 05:17:22 +0000473#---------------------------------------------------------
474# Bytecode Module Targets:
475# If the user set MODULE_NAME then they want to build a
476# bytecode module from the sources. We compile all the
477# sources and link it together into a single bytecode
478# module.
479#---------------------------------------------------------
480
481ifdef MODULE_NAME
482
483Module := $(LibDir)/$(MODULE_NAME).bc
484LinkModule := $(LLVMGCC) -shared -nostdlib
485
486ifdef EXPORTED_SYMBOL_FILE
487LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
488endif
489
490$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
491 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
492 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
493
494all-local:: $(Module)
495
496clean-local::
497ifneq ($(strip $(Module)),)
498 -$(Verb) $(RM) -f $(Module)
499endif
500
501DestModule := $(bytecode_libdir)/$(MODULE_NAME).bc
502
503install-local:: $(DestModule)
504
505$(DestModule): $(bytecode_libdir) $(Module)
506 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
507 $(Verb) $(INSTALL) $(Module) $@
508
509uninstall-local::
510 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
511 -$(Verb) $(RM) -f $(DestModule)
512
513endif
Brian Gaekeecc92bf2004-01-22 22:53:48 +0000514
Reid Spencer81cd0492004-10-23 20:04:14 +0000515# if we're building a library ...
Chris Lattner2f7c9632001-06-06 20:29:01 +0000516ifdef LIBRARYNAME
Vikram S. Advefe346892001-07-15 13:16:47 +0000517
Chris Lattner0100eab2002-09-16 22:36:42 +0000518# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000519LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencerf88808a2004-10-30 09:19:36 +0000520LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
521LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
522LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer32f7e422004-12-02 09:28:21 +0000523LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000524
Reid Spencer81cd0492004-10-23 20:04:14 +0000525#---------------------------------------------------------
526# Shared Library Targets:
527# If the user asked for a shared library to be built
528# with the SHARED_LIBRARY variable, then we provide
529# targets for building them.
530#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000531ifdef SHARED_LIBRARY
532
Reid Spencerf88808a2004-10-30 09:19:36 +0000533all-local:: $(LibName.LA)
Reid Spencerf206bd72004-10-22 21:01:56 +0000534
Reid Spencerf88808a2004-10-30 09:19:36 +0000535$(LibName.LA): $(BUILT_SOURCES) $(ObjectsLO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000536 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf88808a2004-10-30 09:19:36 +0000537 $(Verb) $(Link) -o $@ $(ObjectsLO)
538 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencer81cd0492004-10-23 20:04:14 +0000539
540clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000541ifneq ($(strip $(LibName.LA)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000542 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000543endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000544
Reid Spencer12a3a052004-10-24 07:53:21 +0000545DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf206bd72004-10-22 21:01:56 +0000546
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000547install-local:: $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000548
Reid Spencerf88808a2004-10-30 09:19:36 +0000549$(DestSharedLib): $(libdir) $(LibName.LA)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000550 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000551 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
552 $(Verb) $(LIBTOOL) --finish $(libdir)
Reid Spencer12a3a052004-10-24 07:53:21 +0000553
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000554uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000555 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spenceraee67e62004-11-12 02:27:36 +0000556 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
Reid Spencer12a3a052004-10-24 07:53:21 +0000557
Reid Spencerf206bd72004-10-22 21:01:56 +0000558endif
559
Reid Spencer81cd0492004-10-23 20:04:14 +0000560#---------------------------------------------------------
561# Bytecode Library Targets:
562# If the user asked for a bytecode library to be built
563# with the BYTECODE_LIBRARY variable, then we provide
564# targets for building them.
565#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000566ifdef BYTECODE_LIBRARY
567
Reid Spencer2b1b83a2004-12-03 06:04:35 +0000568# make the C and C++ compilers strip debug info out of bytecode libraries.
569BCCompile.C += -Wa,-strip-debug
570BCCompile.CXX += -Wa,-strip-debug
571
Reid Spencer32f7e422004-12-02 09:28:21 +0000572all-local:: $(LibName.BCA)
573
574ifdef EXPORTED_SYMBOL_FILE
575BCLinkLib = $(LLVMGCC) -shared -nostdlib -Xlinker \
576 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
577
578$(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
579 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
580 "(internalize)"
Chris Lattnere3d98f12004-12-02 21:23:43 +0000581 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencer32f7e422004-12-02 09:28:21 +0000582 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencerf206bd72004-10-22 21:01:56 +0000583else
Reid Spencer81546582004-12-04 22:34:09 +0000584$(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir
Reid Spencer32f7e422004-12-02 09:28:21 +0000585 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
586 $(Verb) $(LArchive) $@ $(ObjectsBC)
587
Reid Spencerf206bd72004-10-22 21:01:56 +0000588endif
589
Reid Spencer81cd0492004-10-23 20:04:14 +0000590clean-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000591ifneq ($(strip $(LibName.BCA)),)
592 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000593endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000594
Reid Spencer32f7e422004-12-02 09:28:21 +0000595DestBytecodeLib = $(bytecode_libdir)/lib$(LIBRARYNAME).a
596
Reid Spencerd4bd3752004-12-03 20:08:48 +0000597install-bytecode-local:: $(DestBytecodeLib)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000598
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000599install-local:: $(DestBytecodeLib)
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000600
Reid Spencer32f7e422004-12-02 09:28:21 +0000601$(DestBytecodeLib): $(bytecode_libdir) $(LibName.BCA)
602 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
603 $(Verb) $(INSTALL) $(LibName.BCA) $@
Reid Spencer12a3a052004-10-24 07:53:21 +0000604
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000605uninstall-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000606 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000607 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000608
609endif
Vikram S. Adve15bd3ad2002-08-02 18:34:12 +0000610
Reid Spencerf88808a2004-10-30 09:19:36 +0000611#---------------------------------------------------------
612# ReLinked Library Targets:
613# If the user didn't explicitly forbid building a
614# relinked then we provide targets for building them.
615#---------------------------------------------------------
Chris Lattner76d98ba2002-07-23 17:56:16 +0000616ifndef DONT_BUILD_RELINKED
Reid Spencerf206bd72004-10-22 21:01:56 +0000617
Reid Spencerf88808a2004-10-30 09:19:36 +0000618all-local:: $(LibName.O)
619
620$(LibName.O): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000621 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencerf88808a2004-10-30 09:19:36 +0000622 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencerf206bd72004-10-22 21:01:56 +0000623
Reid Spencer81cd0492004-10-23 20:04:14 +0000624clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000625ifneq ($(strip $(LibName.O)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000626 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencer12a3a052004-10-24 07:53:21 +0000627endif
628
629DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
630
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000631install-local:: $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000632
Reid Spencerf88808a2004-10-30 09:19:36 +0000633$(DestRelinkedLib): $(libdir) $(LibName.O)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000634 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000635 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000636
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000637uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000638 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000639 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000640
Chris Lattner76d98ba2002-07-23 17:56:16 +0000641endif
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000642
Reid Spencerf88808a2004-10-30 09:19:36 +0000643#---------------------------------------------------------
644# Archive Library Targets:
645# If the user wanted a regular archive library built,
646# then we provide targets for building them.
647#---------------------------------------------------------
Chris Lattner76d98ba2002-07-23 17:56:16 +0000648ifdef BUILD_ARCHIVE
Chris Lattner76d98ba2002-07-23 17:56:16 +0000649
Reid Spencerf88808a2004-10-30 09:19:36 +0000650all-local:: $(LibName.A)
651
652$(LibName.A): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000653 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000654 -$(Verb) $(RM) -f $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000655 $(Verb) $(Archive) $@ $(ObjectsO)
656 $(Verb) $(Ranlib) $@
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000657
Reid Spencer81cd0492004-10-23 20:04:14 +0000658clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000659ifneq ($(strip $(LibName.A)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000660 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000661endif
662
Reid Spencer12a3a052004-10-24 07:53:21 +0000663DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
664
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000665install-local:: $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000666
Reid Spencerf88808a2004-10-30 09:19:36 +0000667$(DestArchiveLib): $(libdir) $(LibName.A)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000668 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000669 $(Verb) $(MKDIR) $(libdir)
670 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000671
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000672uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000673 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000674 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000675
676endif
677
678# endif LIBRARYNAME
Reid Spencerf206bd72004-10-22 21:01:56 +0000679endif
680
Reid Spencerdcba7782004-10-24 08:21:04 +0000681###############################################################################
682# Tool Build Rules: Build executable tool based on TOOLNAME option
683###############################################################################
684
Chris Lattner07c7c192001-09-07 22:57:58 +0000685ifdef TOOLNAME
686
Reid Spencerf88808a2004-10-30 09:19:36 +0000687#---------------------------------------------------------
Reid Spenceraf4495a2004-11-29 07:17:07 +0000688# Handle the special "JIT" value for LLVM_LIBS which is a
689# shorthand for a bunch of libraries that get the correct
690# JIT support for a tool that runs JIT.
691#---------------------------------------------------------
692ifeq ($(LLVMLIBS),JIT)
693
694# Make sure we can get our own symbols in the tool
695Link += -dlopen self
696
697# Generic JIT libraries
698JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
699
700# You can enable the X86 JIT on a non-X86 host by setting the flag
701# ENABLE_X86_JIT on the make command line. If not, it will still be
702# enabled automagically on an X86 host.
703ifeq ($(ARCH), x86)
704 ENABLE_X86_JIT = 1
705endif
706
707# What the X86 JIT requires
708ifdef ENABLE_X86_JIT
709 JIT_LIBS += LLVMX86 LLVMSelectionDAG
710endif
711
712# You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
713# ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
714# enabled automagically on an SparcV9 host.
715ifeq ($(ARCH), Sparc)
716 ENABLE_SPARCV9_JIT = 1
717endif
718
719# What the Sparc JIT requires
720ifdef ENABLE_SPARCV9_JIT
721 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
722 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
723 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
724 LLVMDataStructure.a LLVMSparcV9RegAlloc
725endif
726
727# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
728# ENABLE_PPC_JIT on the make command line. If not, it will still be
729# enabled automagically on an PowerPC host.
730ifeq ($(ARCH), PowerPC)
731 ENABLE_PPC_JIT = 1
732endif
733
734# What the PowerPC JIT requires
735ifdef ENABLE_PPC_JIT
736 JIT_LIBS += LLVMPowerPC
737endif
738
739LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
740 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
741 LLVMSystem.a $(PLATFORMLIBDL)
742endif
743
744#---------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000745# Set up variables for building a tool.
746#---------------------------------------------------------
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000747ifdef EXAMPLE_TOOL
748ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
749else
Reid Spencerf88808a2004-10-30 09:19:36 +0000750ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000751endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000752ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
753ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
754LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
755LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
756ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
757LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
758ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
759LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
Chris Lattner07c7c192001-09-07 22:57:58 +0000760
Reid Spencerf88808a2004-10-30 09:19:36 +0000761#---------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000762# Tell make that we need to rebuild subdirectories before
763# we can link the tool. This affects things like LLI which
764# has library subdirectories.
765#---------------------------------------------------------
766$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner3ecb7762003-01-22 16:13:31 +0000767
Reid Spencerf88808a2004-10-30 09:19:36 +0000768#---------------------------------------------------------
769# Provide targets for building the tools
770#---------------------------------------------------------
771all-local:: $(ToolBuildPath)
John Criswell8224df92003-06-27 16:58:44 +0000772
Reid Spencer81cd0492004-10-23 20:04:14 +0000773clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000774ifneq ($(strip $(ToolBuildPath)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000775 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencer12a3a052004-10-24 07:53:21 +0000776endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000777
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000778ifdef EXAMPLE_TOOL
779$(ToolBuildPath): $(ExmplDir)/.dir
780else
781$(ToolBuildPath): $(ToolDir)/.dir
782endif
783
784$(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000785 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencerf88808a2004-10-30 09:19:36 +0000786 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
787 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000788 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencer12a3a052004-10-24 07:53:21 +0000789
790DestTool = $(bindir)/$(TOOLNAME)
791
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000792install-local:: $(DestTool)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000793
Reid Spencerf88808a2004-10-30 09:19:36 +0000794$(DestTool): $(bindir) $(ToolBuildPath)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000795 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencerf88808a2004-10-30 09:19:36 +0000796 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000797
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000798uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000799 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000800 -$(Verb) $(RM) -f $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000801
Reid Spencerf206bd72004-10-22 21:01:56 +0000802endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000803
Reid Spencerf88808a2004-10-30 09:19:36 +0000804###############################################################################
805# Object Build Rules: Build object files based on sources
806###############################################################################
807
808# Provide rule sets for when dependency generation is enabled
Reid Spencerf206bd72004-10-22 21:01:56 +0000809ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000810
Reid Spencerf88808a2004-10-30 09:19:36 +0000811#---------------------------------------------------------
812# Create .lo files in the ObjDir directory from the .cpp and .c files...
813#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000814ifdef SHARED_LIBRARY
815
Reid Spencerf88808a2004-10-30 09:19:36 +0000816$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000817 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencerf88808a2004-10-30 09:19:36 +0000818 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
819 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
820 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000821
Reid Spencerf88808a2004-10-30 09:19:36 +0000822$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000823 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencerf88808a2004-10-30 09:19:36 +0000824 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
825 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
826 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000827
Reid Spencerf88808a2004-10-30 09:19:36 +0000828#---------------------------------------------------------
829# Create .o files in the ObjDir directory from the .cpp and .c files...
830#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000831else
Reid Spencerf206bd72004-10-22 21:01:56 +0000832
Reid Spencerf88808a2004-10-30 09:19:36 +0000833$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000834 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +0000835 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
836 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
837 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +0000838
Reid Spencerf88808a2004-10-30 09:19:36 +0000839$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000840 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +0000841 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
842 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
843 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000844
845endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000846
Reid Spencerf88808a2004-10-30 09:19:36 +0000847#---------------------------------------------------------
848# Create .bc files in the ObjDir directory from .cpp and .c files...
849#---------------------------------------------------------
Chris Lattner0ea40c92004-11-29 19:47:58 +0000850$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000851 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencerf88808a2004-10-30 09:19:36 +0000852 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
853 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
854 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +0000855
Chris Lattner0ea40c92004-11-29 19:47:58 +0000856$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000857 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencerf88808a2004-10-30 09:19:36 +0000858 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
859 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
860 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +0000861
Reid Spencerf88808a2004-10-30 09:19:36 +0000862# Provide alternate rule sets if dependencies are disabled
Reid Spencerf206bd72004-10-22 21:01:56 +0000863else
864
Reid Spencer81cd0492004-10-23 20:04:14 +0000865ifdef SHARED_LIBRARY
866
Reid Spencerf88808a2004-10-30 09:19:36 +0000867$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000868 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000869 $(LTCompile.CXX) $< -o $@
870
Reid Spencerf88808a2004-10-30 09:19:36 +0000871$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000872 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000873 $(LTCompile.C) $< -o $@
874
875else
Reid Spencerf206bd72004-10-22 21:01:56 +0000876
Reid Spencerf88808a2004-10-30 09:19:36 +0000877$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000878 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer81cd0492004-10-23 20:04:14 +0000879 $(Compile.CXX) $< -o $@
Reid Spencerf206bd72004-10-22 21:01:56 +0000880
Reid Spencerf88808a2004-10-30 09:19:36 +0000881$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000882 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer81cd0492004-10-23 20:04:14 +0000883 $(Compile.C) $< -o $@
884endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000885
Chris Lattner0ea40c92004-11-29 19:47:58 +0000886$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000887 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencer991f66a2004-10-31 18:52:15 +0000888 $(BCCompile.CXX) $< -o $@
Reid Spencerf206bd72004-10-22 21:01:56 +0000889
Chris Lattner0ea40c92004-11-29 19:47:58 +0000890$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000891 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencer991f66a2004-10-31 18:52:15 +0000892 $(BCCompile.C) $< -o $@
Brian Gaeke0f148bc2003-12-10 00:26:28 +0000893
Chris Lattner07c7c192001-09-07 22:57:58 +0000894endif
895
Reid Spencerf88808a2004-10-30 09:19:36 +0000896#---------------------------------------------------------
897# Provide rule to build .bc files from .ll sources,
898# regardless of dependencies
899#---------------------------------------------------------
900$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000901 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +0000902 $(Verb) $(LLVMAS) $< -f -o $@
903
904###############################################################################
905# TABLEGEN: Provide rules for running tblgen to produce *.inc files
906###############################################################################
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000907
Reid Spencerf206bd72004-10-22 21:01:56 +0000908ifdef TARGET
909
Reid Spencerf88808a2004-10-30 09:19:36 +0000910TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
911INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Reid Spencerf206bd72004-10-22 21:01:56 +0000912
Reid Spencerf88808a2004-10-30 09:19:36 +0000913$(INCFiles) : $(TBLGEN) $(TDFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +0000914
Reid Spencer94105c72004-10-27 04:34:35 +0000915%GenRegisterNames.inc : %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000916 $(Echo) "Building $(<F) register names with tblgen"
917 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000918
Reid Spencer94105c72004-10-27 04:34:35 +0000919%GenRegisterInfo.h.inc : %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000920 $(Echo) "Building $(<F) register information header with tblgen"
921 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000922
923%GenRegisterInfo.inc : %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000924 $(Echo) "Building $(<F) register info implementation with tblgen"
925 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000926
927%GenInstrNames.inc : %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000928 $(Echo) "Building $(<F) instruction names with tblgen"
929 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000930
931%GenInstrInfo.inc : %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000932 $(Echo) "Building $(<F) instruction information with tblgen"
933 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000934
935%GenAsmWriter.inc : %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000936 $(Echo) "Building $(<F) assembly writer with tblgen"
937 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000938
939%GenATTAsmWriter.inc : %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000940 $(Echo) "Building $(<F) AT&T assembly writer with tblgen"
941 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000942
943%GenIntelAsmWriter.inc : %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000944 $(Echo) "Building $(<F) Intel assembly writer with tblgen"
945 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000946
947%GenInstrSelector.inc: %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000948 $(Echo) "Building $(<F) instruction selector with tblgen"
949 $(Verb) $(TableGen) -gen-instr-selector -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000950
951%GenCodeEmitter.inc:: %.td
Reid Spencerf88808a2004-10-30 09:19:36 +0000952 $(Echo) "Building $(<F) code emitter with tblgen"
953 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000954
Reid Spencer81cd0492004-10-23 20:04:14 +0000955clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000956 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +0000957
958endif
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000959
Reid Spencerf88808a2004-10-30 09:19:36 +0000960###############################################################################
961# LEX AND YACC: Provide rules for generating sources with lex and yacc
962###############################################################################
Chris Lattnerdb644dd2003-01-16 22:44:19 +0000963
Reid Spencerf88808a2004-10-30 09:19:36 +0000964#---------------------------------------------------------
965# Provide rules for generating a .cpp source file from
966# (f)lex input sources.
967#---------------------------------------------------------
968
Reid Spencer9d0c1e02004-11-02 16:36:03 +0000969LexFiles := $(filter %.l,$(Sources))
Reid Spencerf88808a2004-10-30 09:19:36 +0000970
Reid Spencer9d0c1e02004-11-02 16:36:03 +0000971ifneq ($(LexFiles),)
972
973LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
Reid Spencerf88808a2004-10-30 09:19:36 +0000974
975.PRECIOUS: $(LexOutput)
976
977# Note the extra sed filtering here, used to cut down on the warnings emited
978# by GCC. The last line is a gross hack to work around flex aparently not
979# being able to resize the buffer on a large token input. Currently, for
980# uninitialized string buffers in LLVM we can generate very long tokens, so
981# this is a hack around it.
Chris Lattner92fc9b02003-08-15 20:00:47 +0000982# FIXME. (f.e. char Buffer[10000] )
Chris Lattner2f7c9632001-06-06 20:29:01 +0000983%.cpp: %.l
Reid Spencer993b95e2004-12-10 19:44:16 +0000984 $(Echo) Flexing $*.l
Reid Spencerf88808a2004-10-30 09:19:36 +0000985 $(Verb) $(FLEX) -t $< | \
Reid Spencerf206bd72004-10-22 21:01:56 +0000986 $(SED) 's/void yyunput/inline void yyunput/' | \
987 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
988 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencerb7f710a2004-10-28 00:41:43 +0000989 > $@
Chris Lattner2f7c9632001-06-06 20:29:01 +0000990
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000991clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000992 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencer9d0c1e02004-11-02 16:36:03 +0000993 $(Verb) $(RM) -f $(LexOutput)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000994
Reid Spencerf88808a2004-10-30 09:19:36 +0000995endif
996
997#---------------------------------------------------------
998# Provide rules for generating a .cpp and .h source files
999# from yacc (bison) input sources.
1000#---------------------------------------------------------
1001
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001002YaccFiles := $(filter %.y,$(Sources))
1003ifneq ($(YaccFiles),)
1004YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
Reid Spencerf88808a2004-10-30 09:19:36 +00001005
1006.PRECIOUS: $(YaccOutput)
1007
1008# Cancel built-in rules for yacc
1009%.c: %.y
1010%.cpp: %.y
1011%.h: %.y
1012
Chris Lattner2f7c9632001-06-06 20:29:01 +00001013# Rule for building the bison parsers...
Chris Lattner2f7c9632001-06-06 20:29:01 +00001014%.cpp %.h : %.y
Reid Spencerf88808a2004-10-30 09:19:36 +00001015 $(Echo) "Bisoning $*.y"
1016 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1017 $(Verb) $(MV) -f $*.tab.c $*.cpp
1018 $(Verb) $(MV) -f $*.tab.h $*.h
Chris Lattner2f7c9632001-06-06 20:29:01 +00001019
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001020clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001021 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001022 $(Verb) $(RM) -f $(YaccOutput)
Reid Spencerf88808a2004-10-30 09:19:36 +00001023endif
Chris Lattner2f7c9632001-06-06 20:29:01 +00001024
Reid Spencerf88808a2004-10-30 09:19:36 +00001025###############################################################################
1026# OTHER RULES: Other rules needed
1027###############################################################################
Reid Spencerf206bd72004-10-22 21:01:56 +00001028
Chris Lattner23d47392003-01-16 21:06:18 +00001029# To create postscript files from dot files...
John Criswell4ffb8442003-10-02 19:02:02 +00001030ifneq ($(DOT),false)
Chris Lattner23d47392003-01-16 21:06:18 +00001031%.ps: %.dot
Reid Spencerf206bd72004-10-22 21:01:56 +00001032 $(DOT) -Tps < $< > $@
John Criswell3ef61af2003-06-30 21:59:07 +00001033else
1034%.ps: %.dot
Reid Spencerf88808a2004-10-30 09:19:36 +00001035 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell3ef61af2003-06-30 21:59:07 +00001036endif
Chris Lattner23d47392003-01-16 21:06:18 +00001037
John Criswell0a6e6aa2003-09-06 14:44:17 +00001038# This rules ensures that header files that are removed still have a rule for
1039# which they can be "generated." This allows make to ignore them and
1040# reproduce the dependency lists.
John Criswella8391af2003-09-18 18:37:08 +00001041%.h:: ;
John Criswell0a6e6aa2003-09-06 14:44:17 +00001042
Reid Spencerf88808a2004-10-30 09:19:36 +00001043# Define clean-local to clean the current directory. Note that this uses a
1044# very conservative approach ensuring that empty variables do not cause
1045# errors or disastrous removal.
Reid Spencer81cd0492004-10-23 20:04:14 +00001046clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001047ifneq ($(strip $(ObjDir)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001048 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencer12a3a052004-10-24 07:53:21 +00001049endif
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001050 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke8625f682004-01-21 19:53:11 +00001051ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001052 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke8625f682004-01-21 19:53:11 +00001053endif
John Criswell3ef61af2003-06-30 21:59:07 +00001054
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001055clean-all-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001056 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001057
Reid Spencerf88808a2004-10-30 09:19:36 +00001058# Build tags database for Emacs/Xemacs:
Reid Spenceraee67e62004-11-12 02:27:36 +00001059tags:: TAGS CTAGS
1060
Reid Spencerf88808a2004-10-30 09:19:36 +00001061TAGS:
Reid Spenceraee67e62004-11-12 02:27:36 +00001062 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1063 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1064 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1065 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1066 -name '*.cpp' -o -name '*.h' | \
Reid Spencerf88808a2004-10-30 09:19:36 +00001067 $(ETAGS) $(ETAGSFLAGS) -
1068
Reid Spenceraee67e62004-11-12 02:27:36 +00001069CTAGS:
1070 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1071 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1072 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1073 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1074 \( -name '*.cpp' -o -name '*.h' \) -print | \
1075 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1076
1077
Reid Spencer81cd0492004-10-23 20:04:14 +00001078###############################################################################
1079# DEPENDENCIES: Include the dependency files if we should
1080###############################################################################
Chris Lattnere9d7d702003-08-22 14:10:16 +00001081ifndef DISABLE_AUTO_DEPENDENCIES
1082
Reid Spencer81cd0492004-10-23 20:04:14 +00001083# If its not one of the cleaning targets
Reid Spencerf88808a2004-10-30 09:19:36 +00001084ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencerf206bd72004-10-22 21:01:56 +00001085
Reid Spencer81cd0492004-10-23 20:04:14 +00001086# Get the list of dependency files
Reid Spencerf88808a2004-10-30 09:19:36 +00001087DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001088DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
Misha Brukmanb891ffb2003-11-09 21:36:19 +00001089
Reid Spencer81cd0492004-10-23 20:04:14 +00001090-include /dev/null $(DependFiles)
1091
John Criswell48ecca62003-08-12 18:51:51 +00001092endif
Chris Lattner598222b2003-08-18 17:27:40 +00001093
Reid Spencerf88808a2004-10-30 09:19:36 +00001094endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001095
Reid Spencer100080c2004-10-25 08:27:37 +00001096###############################################################################
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001097# CHECK: Running the test suite
1098###############################################################################
1099
1100check::
1101 $(Verb) if test -d "$(BUILD_OBJ_ROOT)/test" ; then \
1102 if test -f "$(BUILD_OBJ_ROOT)/test/Makefile" ; then \
1103 $(EchoCmd) Running test suite ; \
1104 $(MAKE) -C $(BUILD_OBJ_ROOT)/test check-local \
1105 TESTSUITE=$(TESTSUITE) ; \
1106 else \
1107 $(EchoCmd) No Makefile in test directory ; \
1108 fi ; \
1109 else \
1110 $(EchoCmd) No test directory ; \
1111 fi
1112
1113###############################################################################
Reid Spencerf88808a2004-10-30 09:19:36 +00001114# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer100080c2004-10-25 08:27:37 +00001115###############################################################################
1116
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001117#------------------------------------------------------------------------
1118# Define distribution related variables
1119#------------------------------------------------------------------------
Reid Spencer100080c2004-10-25 08:27:37 +00001120DistName := $(LLVM_TARBALL_NAME)
1121DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001122TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer100080c2004-10-25 08:27:37 +00001123DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1124DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1125DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1126DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1127 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001128 Makefile.config.in configure autoconf
1129DistOther := $(notdir $(wildcard \
1130 $(BUILD_SRC_DIR)/*.h \
1131 $(BUILD_SRC_DIR)/*.td \
1132 $(BUILD_SRC_DIR)/*.def \
1133 $(BUILD_SRC_DIR)/*.ll \
1134 $(BUILD_SRC_DIR)/*.in))
Reid Spencerf88808a2004-10-30 09:19:36 +00001135DistSubDirs := $(SubDirs)
Reid Spencerfc66af42004-11-29 05:00:33 +00001136DistSources = $(Sources) $(EXTRA_DIST)
1137DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer100080c2004-10-25 08:27:37 +00001138
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001139#------------------------------------------------------------------------
1140# We MUST build distribution with OBJ_DIR != SRC_DIR
1141#------------------------------------------------------------------------
1142ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1143dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerf88808a2004-10-30 09:19:36 +00001144 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001145
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001146else
1147
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001148#------------------------------------------------------------------------
1149# Prevent catastrophic remove
1150#------------------------------------------------------------------------
1151ifeq ($(LLVM_TARBALL_NAME),)
1152$(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1153endif
1154
1155#------------------------------------------------------------------------
1156# Prevent attempt to run dist targets from anywhere but the top level
1157#------------------------------------------------------------------------
1158ifneq ($(LEVEL),.)
1159
1160dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerf88808a2004-10-30 09:19:36 +00001161 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001162
1163else
1164
1165#------------------------------------------------------------------------
1166# Provide the top level targets
1167#------------------------------------------------------------------------
1168
Reid Spencerf88808a2004-10-30 09:19:36 +00001169dist-gzip:: $(DistTarGZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001170
Reid Spencer81546582004-12-04 22:34:09 +00001171$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001172 $(Echo) Packing gzipped distribution tar file.
Reid Spencerfc66af42004-11-29 05:00:33 +00001173 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1174 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001175
Reid Spencerf88808a2004-10-30 09:19:36 +00001176dist-bzip2:: $(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001177
Reid Spencer81546582004-12-04 22:34:09 +00001178$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001179 $(Echo) Packing bzipped distribution tar file.
Reid Spencerfc66af42004-11-29 05:00:33 +00001180 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1181 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001182
Reid Spencerf88808a2004-10-30 09:19:36 +00001183dist-zip:: $(DistZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001184
Reid Spencer81546582004-12-04 22:34:09 +00001185$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001186 $(Echo) Packing zipped distribution file.
1187 $(Verb) rm -f $(DistZip)
1188 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001189
1190dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001191 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001192
1193DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1194
Reid Spencer81546582004-12-04 22:34:09 +00001195dist-check:: $(DistTarGZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001196 $(Echo) Checking distribution tar file.
1197 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001198 $(RM) -rf $(DistCheckDir) ; \
1199 fi
Reid Spencerf88808a2004-10-30 09:19:36 +00001200 $(Verb) $(MKDIR) $(DistCheckDir)
1201 $(Verb) cd $(DistCheckDir) && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001202 $(MKDIR) $(DistCheckDir)/build && \
1203 $(MKDIR) $(DistCheckDir)/install && \
1204 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1205 cd build && \
1206 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1207 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
Reid Spencer81546582004-12-04 22:34:09 +00001208 $(MAKE) all && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001209 $(MAKE) check && \
1210 $(MAKE) install && \
1211 $(MAKE) uninstall && \
1212 $(MAKE) dist && \
1213 $(MAKE) clean && \
1214 $(MAKE) dist-clean && \
Reid Spencerf88808a2004-10-30 09:19:36 +00001215 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001216
1217dist-clean::
Reid Spencerf88808a2004-10-30 09:19:36 +00001218 $(Echo) Cleaning distribution files
Reid Spencer81546582004-12-04 22:34:09 +00001219 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1220 $(DistCheckDir)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001221
1222endif
1223
1224#------------------------------------------------------------------------
1225# Provide the recursive distdir target for building the distribution directory
1226#------------------------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +00001227distdir: $(DistDir)/.makedistdir
1228$(DistDir)/.makedistdir: $(DistSources)
Reid Spencerf88808a2004-10-30 09:19:36 +00001229 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001230 if test -d "$(DistDir)" ; then \
1231 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1232 exit 1 ; \
1233 fi ; \
Reid Spencer81546582004-12-04 22:34:09 +00001234 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001235 $(RM) -rf $(DistDir); \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001236 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer81546582004-12-04 22:34:09 +00001237 $(MAKE) all ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001238 fi
Reid Spencerfc66af42004-11-29 05:00:33 +00001239 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencerf88808a2004-10-30 09:19:36 +00001240 $(Verb) $(MKDIR) $(DistDir)
1241 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
Reid Spencer100080c2004-10-25 08:27:37 +00001242 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1243 for file in $(DistFiles) ; do \
1244 case "$$file" in \
Reid Spencer81546582004-12-04 22:34:09 +00001245 $(BUILD_SRC_DIR)/*) \
1246 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1247 ;; \
1248 $(BUILD_SRC_ROOT)/*) \
1249 file=`echo "$$file" | \
1250 sed "s#^$$srcrootstrip/##"` \
1251 ;; \
Reid Spencer100080c2004-10-25 08:27:37 +00001252 esac; \
Reid Spencer81546582004-12-04 22:34:09 +00001253 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1254 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1255 from_dir="$(BUILD_SRC_DIR)" ; \
1256 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001257 from_dir=. ; \
Reid Spencer81546582004-12-04 22:34:09 +00001258 fi ; \
1259 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001260 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1261 to_dir="$(DistDir)/$$dir"; \
1262 $(MKDIR) "$$to_dir" ; \
1263 else \
1264 to_dir="$(DistDir)"; \
1265 fi; \
1266 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1267 if test -n "$$mid_dir" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001268 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001269 fi ; \
1270 if test -d "$$from_dir/$$file"; then \
1271 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1272 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1273 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1274 fi; \
1275 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1276 elif test -f "$$from_dir/$$file" ; then \
1277 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1278 elif test -L "$$from_dir/$$file" ; then \
1279 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1280 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer81546582004-12-04 22:34:09 +00001281 $(EchoCmd) "===== WARNING: Distribution Source " \
1282 "$$from_dir/$$file Not Found!" ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001283 elif test "$(Verb)" != '@' ; then \
1284 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001285 fi; \
1286 done
Reid Spencerf88808a2004-10-30 09:19:36 +00001287 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer100080c2004-10-25 08:27:37 +00001288 if test "$$subdir" \!= "." ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001289 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001290 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer81546582004-12-04 22:34:09 +00001291 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1292 exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001293 fi; \
1294 done
Reid Spencer81546582004-12-04 22:34:09 +00001295 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1296 $(EchoCmd) Eliminating CVS directories from distribution ; \
1297 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1298 $(MAKE) dist-hook ; \
1299 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1300 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1301 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1302 -o ! -type d ! -perm -444 -exec \
1303 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1304 || chmod -R a+r $(DistDir) ; \
1305 fi
Reid Spencer100080c2004-10-25 08:27:37 +00001306
Reid Spencerf88808a2004-10-30 09:19:36 +00001307# This is invoked by distdir target, define it as a no-op to avoid errors if not
1308# defined by user.
Reid Spencer100080c2004-10-25 08:27:37 +00001309dist-hook::
1310
Reid Spencer23a70372004-10-22 23:06:30 +00001311endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001312
1313###############################################################################
Reid Spencer12a3a052004-10-24 07:53:21 +00001314# TOP LEVEL - targets only to apply at the top level directory
1315###############################################################################
1316
1317ifeq ($(LEVEL),.)
1318
1319#------------------------------------------------------------------------
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001320# Install support for the project's include files:
Reid Spencer12a3a052004-10-24 07:53:21 +00001321#------------------------------------------------------------------------
1322install-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001323 $(Echo) Installing include files
1324 $(Verb) $(MKDIR) $(includedir)
1325 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencer12a3a052004-10-24 07:53:21 +00001326 cd $(BUILD_SRC_ROOT)/include && \
1327 find . -path '*/Internal' -prune -o '(' -type f \
1328 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1329 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1330 fi
1331
1332uninstall-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001333 $(Echo) Uninstalling include files
1334 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencer12a3a052004-10-24 07:53:21 +00001335 cd $(BUILD_SRC_ROOT)/include && \
1336 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1337 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1338 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1339 fi
1340
Reid Spencer12a3a052004-10-24 07:53:21 +00001341endif
1342
Reid Spencerf206bd72004-10-22 21:01:56 +00001343#------------------------------------------------------------------------
1344# Print out the directories used for building
Reid Spencerf88808a2004-10-30 09:19:36 +00001345#------------------------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001346printvars::
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001347 $(Echo) "BuildMode : " '$(BuildMode)'
Reid Spencerf88808a2004-10-30 09:19:36 +00001348 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1349 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1350 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1351 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1352 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1353 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1354 $(Echo) "libdir : " '$(libdir)'
1355 $(Echo) "bindir : " '$(bindir)'
1356 $(Echo) "sysconfdir : " '$(sysconfdir)'
1357 $(Echo) "bytecode_libdir: " '$(bytecode_libdir)'
1358 $(Echo) "UserTargets : " '$(UserTargets)'
1359 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1360 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1361 $(Echo) "ObjDir : " '$(ObjDir)'
1362 $(Echo) "LibDir : " '$(LibDir)'
1363 $(Echo) "ToolDir : " '$(ToolDir)'
Reid Spencer7e9e0b02004-11-18 10:03:46 +00001364 $(Echo) "ExmplDir : " '$(ExmplDir)'
Reid Spencerd78077d2004-12-05 05:17:22 +00001365 $(Echo) "Sources : " '$(Sources)'
Reid Spencerf88808a2004-10-30 09:19:36 +00001366 $(Echo) "TDFiles : " '$(TDFiles)'
1367 $(Echo) "INCFiles : " '$(INCFiles)'
1368 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1369 $(Echo) "Compile.C : " '$(Compile.C)'
1370 $(Echo) "Archive : " '$(Archive)'
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001371 $(Echo) "YaccFiles : " '$(YaccFiles)'
1372 $(Echo) "LexFiles : " '$(LexFiles)'
Reid Spencerd78077d2004-12-05 05:17:22 +00001373 $(Echo) "Module : " '$(Module)'