blob: f509058f8d996df62462d3cf78b87286c32a3867 [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 Spencer97e40f12004-12-16 07:15:16 +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 Spencer55814372004-12-16 08:00:46 +000084ifneq ($(BUILD_OBJ_ROOT),$(BUILD_SRC_ROOT))
85spotless:
86 $(Echo) Wiping out $(BUILD_OBJ_ROOT) and rebuilding configuration.
87 $(Verb) if test -x config.status ; then \
88 $(MV) config.status .. ; \
89 $(MV) mklib .. ; \
90 $(RM) -rf * ; \
91 $(MV) ../config.status . ; \
92 $(MV) ../mklib . ; \
93 ./config.status ; \
94 else \
95 $(EchoCmd) "make spotless" can only be run from $(BUILD_OBJ_ROOT); \
96 fi
97endif
98
Reid Spencerf88808a2004-10-30 09:19:36 +000099$(BUILT_SOURCES) : $(ObjMakefiles)
Reid Spencerb7f710a2004-10-28 00:41:43 +0000100
Reid Spencer77a46d22004-10-26 22:26:33 +0000101#------------------------------------------------------------------------
102# Make sure we're not using a stale configuration
103#------------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000104.PRECIOUS: $(ConfigStatusScript)
105$(ConfigStatusScript): $(ConfigureScript)
106 $(Echo) Reconfiguring with $<
Reid Spencer50f34872004-11-29 12:37:44 +0000107 $(Verb) cd $(BUILD_OBJ_ROOT) && \
108 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
109 $(ConfigStatusScript)
Reid Spencer77a46d22004-10-26 22:26:33 +0000110
111#------------------------------------------------------------------------
112# Make sure the configuration makefile is up to date
113#------------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000114$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
115 $(Echo) Regenerating $@
116 $(Verb) cd $(LLVM_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
Reid Spencer77a46d22004-10-26 22:26:33 +0000117
118#------------------------------------------------------------------------
119# If the Makefile in the source tree has been updated, copy it over into the
120# build tree. But, only do this if the source and object makefiles differ
121#------------------------------------------------------------------------
122ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
123
Reid Spencer91234ff2004-11-17 19:08:44 +0000124Makefile: $(BUILD_SRC_DIR)/Makefile
Reid Spencerf88808a2004-10-30 09:19:36 +0000125 $(Echo) "Updating Makefile"
126 $(Verb) $(MKDIR) $(@D)
127 $(Verb) cp -f $< $@
Reid Spencer77a46d22004-10-26 22:26:33 +0000128
129# Copy the Makefile.* files unless we're in the root directory which avoids
130# the copying of Makefile.config.in or other things that should be explicitly
131# taken care of.
Reid Spencer77a46d22004-10-26 22:26:33 +0000132$(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
Reid Spencerd94bb332004-10-26 23:10:00 +0000133 @case '$?' in \
134 *Makefile.rules) ;; \
135 *.in) ;; \
Reid Spencerf88808a2004-10-30 09:19:36 +0000136 *) $(Echo) "Updating $(@F)" ; \
Reid Spencerd94bb332004-10-26 23:10:00 +0000137 $(MKDIR) $(@D) ; \
138 cp -f $< $@ ;; \
139 esac
140
Reid Spencer77a46d22004-10-26 22:26:33 +0000141endif
142
143#------------------------------------------------------------------------
144# Set up the basic dependencies
145#------------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000146$(UserTargets):: $(PreConditions)
Reid Spencer77a46d22004-10-26 22:26:33 +0000147
148all:: all-local
Reid Spencer81cd0492004-10-23 20:04:14 +0000149clean:: clean-local
Reid Spencer9d0c1e02004-11-02 16:36:03 +0000150clean-all:: clean-local clean-all-local
Reid Spencer77a46d22004-10-26 22:26:33 +0000151install:: install-local
152uninstall:: uninstall-local
Reid Spencer77a46d22004-10-26 22:26:33 +0000153install-local:: all-local
Reid Spencerd4bd3752004-12-03 20:08:48 +0000154install-bytecode:: install-bytecode-local
Reid Spencer81cd0492004-10-23 20:04:14 +0000155
156###############################################################################
157# VARIABLES: Set up various variables based on configuration data
158###############################################################################
159
160#--------------------------------------------------------------------
161# Variables derived from configuration we are building
Chris Lattner2f7c9632001-06-06 20:29:01 +0000162#--------------------------------------------------------------------
163
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000164ifdef ENABLE_PROFILING
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000165 BuildMode := Profile
Reid Spencercd7d6cf2004-12-08 04:34:51 +0000166 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
Reid Spencerf88808a2004-10-30 09:19:36 +0000167 C.Flags := -O3 -DNDEBUG -pg
168 LD.Flags := -O3 -DNDEBUG -pg
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000169else
170 ifdef ENABLE_OPTIMIZED
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000171 BuildMode := Release
Reid Spencercd7d6cf2004-12-08 04:34:51 +0000172 CXX.Flags := -O3 -DNDEBUG -finline-functions \
Reid Spencercc52c2c2004-12-08 04:26:23 +0000173 -felide-constructors -fomit-frame-pointer
Reid Spencerf88808a2004-10-30 09:19:36 +0000174 C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
175 LD.Flags := -O3 -DNDEBUG
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000176 else
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000177 BuildMode := Debug
Reid Spencercd7d6cf2004-12-08 04:34:51 +0000178 CXX.Flags := -g -D_DEBUG
Reid Spencerf88808a2004-10-30 09:19:36 +0000179 C.Flags := -g -D_DEBUG
180 LD.Flags := -g -D_DEBUG
Reid Spencerf206bd72004-10-22 21:01:56 +0000181 KEEP_SYMBOLS := 1
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000182 endif
183endif
184
Reid Spencerf88808a2004-10-30 09:19:36 +0000185CXX.Flags += $(CXXFLAGS)
186C.Flags += $(CFLAGS)
187CPP.Flags += $(CPPFLAGS)
188LD.Flags += $(LDFLAGS)
189AR.Flags := cru
190LibTool.Flags := --tag=CXX
Reid Spencer81cd0492004-10-23 20:04:14 +0000191
192#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000193# Directory locations
Reid Spencer81cd0492004-10-23 20:04:14 +0000194#--------------------------------------------------------------------
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000195ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000196LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer0dbf1012004-11-18 20:04:39 +0000197ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000198ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
199LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer0dbf1012004-11-18 20:04:39 +0000200LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000201LExmplDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
John Criswell3ef61af2003-06-30 21:59:07 +0000202
Reid Spencer81cd0492004-10-23 20:04:14 +0000203#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000204# Full Paths To Compiled Tools and Utilities
Reid Spencer81cd0492004-10-23 20:04:14 +0000205#--------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000206EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
207Echo := @$(EchoCmd)
208ifndef LIBTOOL
Reid Spencerf206bd72004-10-22 21:01:56 +0000209LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencerf88808a2004-10-30 09:19:36 +0000210endif
211ifndef LLVMAS
212LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
213endif
214ifndef BURG
215BURG := $(LLVMToolDir)/burg$(EXEEXT)
216endif
217ifndef TBLGEN
218TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
219endif
Chris Lattner0ea40c92004-11-29 19:47:58 +0000220ifndef GCCAS
221GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
222endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000223ifndef GCCLD
224GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
225endif
226ifndef LLVMGCC
227LLVMGCC := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/gcc
228endif
229ifndef LLVMGXX
230LLVMGXX := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/g++
231endif
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000232ifndef LDIS
233LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
234endif
235ifndef LLI
236LLI := $(LLVMToolDir)/lli$(EXEEXT)
237endif
238ifndef LOPT
Alkis Evlogimenos7c7705d2004-12-13 18:08:29 +0000239LOPT := $(LLVMToolDir)/opt$(EXEEXT)
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000240endif
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000241
Reid Spencer81cd0492004-10-23 20:04:14 +0000242#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000243# Adjust to user's request
Reid Spencer81cd0492004-10-23 20:04:14 +0000244#--------------------------------------------------------------------
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000245
Reid Spencerf88808a2004-10-30 09:19:36 +0000246# Adjust LIBTOOL flags for shared libraries, or not.
John Criswell3601f372003-07-31 20:58:51 +0000247ifndef SHARED_LIBRARY
Reid Spencerf88808a2004-10-30 09:19:36 +0000248 LibTool.Flags += --tag=disable-shared
Reid Spencerf206bd72004-10-22 21:01:56 +0000249else
Reid Spencerf88808a2004-10-30 09:19:36 +0000250 LD.Flags += -rpath $(LibDir)
John Criswell3601f372003-07-31 20:58:51 +0000251endif
252
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000253ifdef TOOL_VERBOSE
254 C.Flags += -v
255 CXX.Flags += -v
256 LD.Flags += -v
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000257 VERBOSE := 1
258endif
259
Reid Spencer81cd0492004-10-23 20:04:14 +0000260# Adjust settings for verbose mode
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000261ifndef VERBOSE
Reid Spencerf88808a2004-10-30 09:19:36 +0000262 Verb := @
263 LibTool.Flags += --silent
264 AR.Flags += >/dev/null 2>/dev/null
265 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
Reid Spencer100080c2004-10-25 08:27:37 +0000266else
Reid Spencerf88808a2004-10-30 09:19:36 +0000267 ConfigureScriptFLAGS :=
Misha Brukman1326a7c2002-09-12 16:05:39 +0000268endif
269
Vikram S. Adved141c282002-09-18 11:55:13 +0000270# By default, strip symbol information from executable
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000271ifndef KEEP_SYMBOLS
Reid Spencerf88808a2004-10-30 09:19:36 +0000272 Strip := $(PLATFORMSTRIPOPTS)
273 StripWarnMsg := "(without symbols)"
Vikram S. Adved141c282002-09-18 11:55:13 +0000274endif
275
Reid Spencer81cd0492004-10-23 20:04:14 +0000276# Adjust linker flags for building an executable
Reid Spencerf206bd72004-10-22 21:01:56 +0000277ifdef TOOLNAME
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000278ifdef EXAMPLE_TOOL
279 LD.Flags += -rpath $(ExmplDir) -export-dynamic
280else
Reid Spencerf88808a2004-10-30 09:19:36 +0000281 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000282endif
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000283endif
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000284
Reid Spencer81cd0492004-10-23 20:04:14 +0000285#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000286# Options To Invoke Tools
Reid Spencer81cd0492004-10-23 20:04:14 +0000287#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000288
289CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
290
Reid Spencerf88808a2004-10-30 09:19:36 +0000291LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
292CPP.Flags += -I$(BUILD_OBJ_DIR) \
Reid Spencer100080c2004-10-25 08:27:37 +0000293 -I$(BUILD_SRC_DIR) \
294 -I$(BUILD_SRC_ROOT)/include \
295 -I$(BUILD_OBJ_ROOT)/include \
296 -I$(LLVM_OBJ_ROOT)/include \
297 -I$(LLVM_SRC_ROOT)/include \
298 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
Reid Spencerf206bd72004-10-22 21:01:56 +0000299
Reid Spencerf88808a2004-10-30 09:19:36 +0000300Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
301LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
302BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
303Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
304LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
305BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
306Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
307 $(CompileCommonOpts) $(LD.Flags) $(Strip)
308Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000309 $(CompileCommonOpts)
Reid Spencerf88808a2004-10-30 09:19:36 +0000310LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
Reid Spencer81cd0492004-10-23 20:04:14 +0000311Burg = $(BURG) -I $(BUILD_SRC_DIR)
312TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
Reid Spencerf88808a2004-10-30 09:19:36 +0000313Archive = $(AR) $(AR.Flags)
Reid Spencer32f7e422004-12-02 09:28:21 +0000314LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencerf206bd72004-10-22 21:01:56 +0000315ifdef RANLIB
Reid Spencer81cd0492004-10-23 20:04:14 +0000316Ranlib = $(RANLIB)
Reid Spencerf206bd72004-10-22 21:01:56 +0000317else
Reid Spencer81cd0492004-10-23 20:04:14 +0000318Ranlib = ranlib
John Criswell3ef61af2003-06-30 21:59:07 +0000319endif
320
Chris Lattner2f7c9632001-06-06 20:29:01 +0000321#----------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +0000322# Get the list of source files and compute object file
323# names from them.
Reid Spencer81cd0492004-10-23 20:04:14 +0000324#----------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +0000325ifdef FAKE_SOURCES
326 Sources :=
327 FakeSources := $(FAKE_SOURCES)
328 ifdef BUILT_SOURCES
329 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
330 endif
331 BaseNameSources := $(sort $(basename $(FakeSources)))
332 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
333 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
334 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
Reid Spencerf88808a2004-10-30 09:19:36 +0000335else
Reid Spencer81546582004-12-04 22:34:09 +0000336 ifndef SOURCES
337 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
338 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
339 $(BUILD_SRC_DIR)/*.l))
340 else
341 Sources := $(SOURCES)
342 endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000343
Reid Spencer81546582004-12-04 22:34:09 +0000344 ifdef BUILT_SOURCES
345 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
346 endif
Vikram S. Advefe346892001-07-15 13:16:47 +0000347
Reid Spencer81546582004-12-04 22:34:09 +0000348 BaseNameSources := $(sort $(basename $(Sources)))
349 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
350 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
351 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
352endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000353
354###############################################################################
355# DIRECTORIES: Handle recursive descent of directory structure
356###############################################################################
John Criswell3601f372003-07-31 20:58:51 +0000357
Chris Lattner2f7c9632001-06-06 20:29:01 +0000358#---------------------------------------------------------
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000359# Provide rules to make install dirs. This must be early
360# in the file so they get built before dependencies
361#---------------------------------------------------------
362
363$(bindir):
Reid Spencerf88808a2004-10-30 09:19:36 +0000364 $(Verb) $(MKDIR) $(bindir)
Chris Lattner615e7fb2004-11-01 06:14:59 +0000365
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000366$(libdir):
Reid Spencerf88808a2004-10-30 09:19:36 +0000367 $(Verb) $(MKDIR) $(libdir)
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000368
Reid Spencerefe3a822004-12-13 07:38:07 +0000369$(includedir):
370 $(Verb) $(MKDIR) $(includedir)
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000371
372$(sysconfdir):
Reid Spencerf88808a2004-10-30 09:19:36 +0000373 $(Verb) $(MKDIR) $(sysconfdir)
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000374
Reid Spencerf88808a2004-10-30 09:19:36 +0000375# To create other directories, as needed, and timestamp their creation
376%/.dir:
377 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfc66af42004-11-29 05:00:33 +0000378 $(Verb) $(DATE) > $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000379
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000380.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
381.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000382
383#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000384# Handle the DIRS options for sequential construction
Chris Lattner2f7c9632001-06-06 20:29:01 +0000385#---------------------------------------------------------
386
Reid Spencerf88808a2004-10-30 09:19:36 +0000387SubDirs :=
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000388ifdef DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000389SubDirs += $(DIRS)
390$(RecursiveTargets)::
391 $(Verb) for dir in $(DIRS); do \
Reid Spencerf206bd72004-10-22 21:01:56 +0000392 if [ ! -f $$dir/Makefile ]; then \
393 $(MKDIR) $$dir; \
394 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
395 fi; \
Reid Spencer4e197482004-12-08 22:58:34 +0000396 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
397 ($(MAKE) -C $$dir $@ ) || exit 1; \
398 fi ; \
Chris Lattner539a23c2002-09-17 23:35:02 +0000399 done
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000400endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000401
Reid Spencer81cd0492004-10-23 20:04:14 +0000402#---------------------------------------------------------
403# Handle the EXPERIMENTAL_DIRS options ensuring success
404# after each directory is built.
405#---------------------------------------------------------
406ifdef EXPERIMENTAL_DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000407$(RecursiveTargets)::
408 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer81cd0492004-10-23 20:04:14 +0000409 if [ ! -f $$dir/Makefile ]; then \
410 $(MKDIR) $$dir; \
411 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
412 fi; \
Reid Spencer4e197482004-12-08 22:58:34 +0000413 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
414 ($(MAKE) -C $$dir $@ ) || exit 0; \
415 fi ; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000416 done
417endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000418
Reid Spencer81cd0492004-10-23 20:04:14 +0000419#---------------------------------------------------------
420# Handle the PARALLEL_DIRS options for parallel construction
421#---------------------------------------------------------
422ifdef PARALLEL_DIRS
423
Reid Spencerf88808a2004-10-30 09:19:36 +0000424SubDirs += $(PARALLEL_DIRS)
425
Reid Spencerd4bd3752004-12-03 20:08:48 +0000426# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencerf88808a2004-10-30 09:19:36 +0000427all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
428clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000429clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencerf88808a2004-10-30 09:19:36 +0000430install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000431uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencerd4bd3752004-12-03 20:08:48 +0000432install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000433
Reid Spencer81546582004-12-04 22:34:09 +0000434ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer81cd0492004-10-23 20:04:14 +0000435
Reid Spencer81546582004-12-04 22:34:09 +0000436$(ParallelTargets) :
Reid Spencerf88808a2004-10-30 09:19:36 +0000437 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencerf206bd72004-10-22 21:01:56 +0000438 $(MKDIR) $(@D); \
439 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswell6df35dd2003-11-25 19:32:22 +0000440 fi; \
Reid Spencer4e197482004-12-08 22:58:34 +0000441 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
442 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
443 fi
Chris Lattner2f7c9632001-06-06 20:29:01 +0000444endif
445
Reid Spencer81cd0492004-10-23 20:04:14 +0000446#---------------------------------------------------------
447# Handle the OPTIONAL_DIRS options for directores that may
448# or may not exist.
449#---------------------------------------------------------
John Criswell8224df92003-06-27 16:58:44 +0000450ifdef OPTIONAL_DIRS
Reid Spencer100080c2004-10-25 08:27:37 +0000451
Reid Spencerf88808a2004-10-30 09:19:36 +0000452SubDirs += $(OPTIONAL_DIRS)
Reid Spencer100080c2004-10-25 08:27:37 +0000453
Reid Spencerf88808a2004-10-30 09:19:36 +0000454$(RecursiveTargets)::
455 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencerf206bd72004-10-22 21:01:56 +0000456 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
457 if [ ! -f $$dir/Makefile ]; then \
458 $(MKDIR) $$dir; \
459 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
460 fi; \
Reid Spencer4e197482004-12-08 22:58:34 +0000461 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
462 ($(MAKE) -C$$dir $@ ) || exit 1; \
463 fi ; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000464 fi \
John Criswell8224df92003-06-27 16:58:44 +0000465 done
466endif
467
Reid Spencercc51e7b2004-08-20 09:20:05 +0000468#---------------------------------------------------------
469# Handle the CONFIG_FILES options
470#---------------------------------------------------------
471ifdef CONFIG_FILES
Reid Spencercc51e7b2004-08-20 09:20:05 +0000472
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000473install-local:: $(sysconfdir) $(CONFIG_FILES)
Reid Spencerf88808a2004-10-30 09:19:36 +0000474 $(Echo) Installing Configuration Files To $(sysconfdir)
475 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer39d6a612004-11-23 05:59:53 +0000476 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
477 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
478 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
479 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
480 else \
481 $(ECHO) Error: cannot find config file $${file}. ; \
482 fi \
Reid Spencercc51e7b2004-08-20 09:20:05 +0000483 done
Reid Spencer81cd0492004-10-23 20:04:14 +0000484
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000485uninstall-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000486 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
487 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer100080c2004-10-25 08:27:37 +0000488 $(RM) -f $(sysconfdir)/$${file} ; \
Reid Spencer12a3a052004-10-24 07:53:21 +0000489 done
490
Reid Spencercc51e7b2004-08-20 09:20:05 +0000491endif
492
Reid Spencer81cd0492004-10-23 20:04:14 +0000493###############################################################################
494# Library Build Rules: Four ways to build a library
495###############################################################################
Chris Lattner2f7c9632001-06-06 20:29:01 +0000496
Reid Spencerd78077d2004-12-05 05:17:22 +0000497#---------------------------------------------------------
498# Bytecode Module Targets:
499# If the user set MODULE_NAME then they want to build a
500# bytecode module from the sources. We compile all the
501# sources and link it together into a single bytecode
502# module.
503#---------------------------------------------------------
504
505ifdef MODULE_NAME
506
507Module := $(LibDir)/$(MODULE_NAME).bc
508LinkModule := $(LLVMGCC) -shared -nostdlib
509
510ifdef EXPORTED_SYMBOL_FILE
511LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
512endif
513
514$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
515 $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@)
516 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
517
518all-local:: $(Module)
519
520clean-local::
521ifneq ($(strip $(Module)),)
522 -$(Verb) $(RM) -f $(Module)
523endif
524
Reid Spencerefe3a822004-12-13 07:38:07 +0000525ifdef BYTECODE_DESTINATION
526ModuleDestDir := $(BYTECODE_DESTINATION)
527else
Reid Spencer05d4d602004-12-14 22:44:05 +0000528ModuleDestDir := $(libdir)
Reid Spencerefe3a822004-12-13 07:38:07 +0000529endif
Reid Spencerd78077d2004-12-05 05:17:22 +0000530
Reid Spencerefe3a822004-12-13 07:38:07 +0000531DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
532
533install-module:: $(DestModule)
Reid Spencerd78077d2004-12-05 05:17:22 +0000534install-local:: $(DestModule)
535
Reid Spencerefe3a822004-12-13 07:38:07 +0000536$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencerd78077d2004-12-05 05:17:22 +0000537 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
538 $(Verb) $(INSTALL) $(Module) $@
539
540uninstall-local::
541 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
542 -$(Verb) $(RM) -f $(DestModule)
543
544endif
Brian Gaekeecc92bf2004-01-22 22:53:48 +0000545
Reid Spencer81cd0492004-10-23 20:04:14 +0000546# if we're building a library ...
Chris Lattner2f7c9632001-06-06 20:29:01 +0000547ifdef LIBRARYNAME
Vikram S. Advefe346892001-07-15 13:16:47 +0000548
Chris Lattner0100eab2002-09-16 22:36:42 +0000549# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000550LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencerf88808a2004-10-30 09:19:36 +0000551LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
552LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
553LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer32f7e422004-12-02 09:28:21 +0000554LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000555
Reid Spencer81cd0492004-10-23 20:04:14 +0000556#---------------------------------------------------------
557# Shared Library Targets:
558# If the user asked for a shared library to be built
559# with the SHARED_LIBRARY variable, then we provide
560# targets for building them.
561#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000562ifdef SHARED_LIBRARY
563
Reid Spencerf88808a2004-10-30 09:19:36 +0000564all-local:: $(LibName.LA)
Reid Spencerf206bd72004-10-22 21:01:56 +0000565
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000566$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000567 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf88808a2004-10-30 09:19:36 +0000568 $(Verb) $(Link) -o $@ $(ObjectsLO)
569 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencer81cd0492004-10-23 20:04:14 +0000570
571clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000572ifneq ($(strip $(LibName.LA)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000573 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000574endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000575
Reid Spencer12a3a052004-10-24 07:53:21 +0000576DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf206bd72004-10-22 21:01:56 +0000577
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000578install-local:: $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000579
Reid Spencerf88808a2004-10-30 09:19:36 +0000580$(DestSharedLib): $(libdir) $(LibName.LA)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000581 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000582 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
583 $(Verb) $(LIBTOOL) --finish $(libdir)
Reid Spencer12a3a052004-10-24 07:53:21 +0000584
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000585uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000586 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spenceraee67e62004-11-12 02:27:36 +0000587 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
Reid Spencer12a3a052004-10-24 07:53:21 +0000588
Reid Spencerf206bd72004-10-22 21:01:56 +0000589endif
590
Reid Spencer81cd0492004-10-23 20:04:14 +0000591#---------------------------------------------------------
592# Bytecode Library Targets:
593# If the user asked for a bytecode library to be built
594# with the BYTECODE_LIBRARY variable, then we provide
595# targets for building them.
596#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000597ifdef BYTECODE_LIBRARY
598
Reid Spencer2b1b83a2004-12-03 06:04:35 +0000599# make the C and C++ compilers strip debug info out of bytecode libraries.
600BCCompile.C += -Wa,-strip-debug
601BCCompile.CXX += -Wa,-strip-debug
602
Reid Spencer32f7e422004-12-02 09:28:21 +0000603all-local:: $(LibName.BCA)
604
605ifdef EXPORTED_SYMBOL_FILE
606BCLinkLib = $(LLVMGCC) -shared -nostdlib -Xlinker \
607 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
608
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000609$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +0000610 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +0000611 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
612 "(internalize)"
Chris Lattnere3d98f12004-12-02 21:23:43 +0000613 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencer85d55ad2004-12-13 03:59:35 +0000614 $(Verb) $(RM) -f $@
Reid Spencer32f7e422004-12-02 09:28:21 +0000615 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencerf206bd72004-10-22 21:01:56 +0000616else
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000617$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +0000618 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +0000619 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencer85d55ad2004-12-13 03:59:35 +0000620 $(Verb) $(RM) -f $@
Reid Spencer32f7e422004-12-02 09:28:21 +0000621 $(Verb) $(LArchive) $@ $(ObjectsBC)
622
Reid Spencerf206bd72004-10-22 21:01:56 +0000623endif
624
Reid Spencer81cd0492004-10-23 20:04:14 +0000625clean-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000626ifneq ($(strip $(LibName.BCA)),)
627 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000628endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000629
Reid Spencer65086be2004-12-13 07:28:21 +0000630ifdef BYTECODE_DESTINATION
631BytecodeDestDir := $(BYTECODE_DESTINATION)
632else
633BytecodeDestDir := $(libdir)
634endif
635
636DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
Reid Spencer32f7e422004-12-02 09:28:21 +0000637
Reid Spencerd4bd3752004-12-03 20:08:48 +0000638install-bytecode-local:: $(DestBytecodeLib)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000639
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000640install-local:: $(DestBytecodeLib)
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000641
Reid Spencer65086be2004-12-13 07:28:21 +0000642$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
Reid Spencer32f7e422004-12-02 09:28:21 +0000643 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
644 $(Verb) $(INSTALL) $(LibName.BCA) $@
Reid Spencer12a3a052004-10-24 07:53:21 +0000645
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000646uninstall-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000647 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000648 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000649
650endif
Vikram S. Adve15bd3ad2002-08-02 18:34:12 +0000651
Reid Spencerf88808a2004-10-30 09:19:36 +0000652#---------------------------------------------------------
653# ReLinked Library Targets:
654# If the user didn't explicitly forbid building a
655# relinked then we provide targets for building them.
656#---------------------------------------------------------
Chris Lattner76d98ba2002-07-23 17:56:16 +0000657ifndef DONT_BUILD_RELINKED
Reid Spencerf206bd72004-10-22 21:01:56 +0000658
Reid Spencerf88808a2004-10-30 09:19:36 +0000659all-local:: $(LibName.O)
660
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000661$(LibName.O): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000662 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencerf88808a2004-10-30 09:19:36 +0000663 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencerf206bd72004-10-22 21:01:56 +0000664
Reid Spencer81cd0492004-10-23 20:04:14 +0000665clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000666ifneq ($(strip $(LibName.O)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000667 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencer12a3a052004-10-24 07:53:21 +0000668endif
669
670DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
671
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000672install-local:: $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000673
Reid Spencerf88808a2004-10-30 09:19:36 +0000674$(DestRelinkedLib): $(libdir) $(LibName.O)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000675 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000676 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000677
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000678uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000679 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000680 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000681
Chris Lattner76d98ba2002-07-23 17:56:16 +0000682endif
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000683
Reid Spencerf88808a2004-10-30 09:19:36 +0000684#---------------------------------------------------------
685# Archive Library Targets:
686# If the user wanted a regular archive library built,
687# then we provide targets for building them.
688#---------------------------------------------------------
Chris Lattner76d98ba2002-07-23 17:56:16 +0000689ifdef BUILD_ARCHIVE
Chris Lattner76d98ba2002-07-23 17:56:16 +0000690
Reid Spencerf88808a2004-10-30 09:19:36 +0000691all-local:: $(LibName.A)
692
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000693$(LibName.A): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000694 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000695 -$(Verb) $(RM) -f $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000696 $(Verb) $(Archive) $@ $(ObjectsO)
697 $(Verb) $(Ranlib) $@
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000698
Reid Spencer81cd0492004-10-23 20:04:14 +0000699clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000700ifneq ($(strip $(LibName.A)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000701 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000702endif
703
Reid Spencer12a3a052004-10-24 07:53:21 +0000704DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
705
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000706install-local:: $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000707
Reid Spencerf88808a2004-10-30 09:19:36 +0000708$(DestArchiveLib): $(libdir) $(LibName.A)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000709 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000710 $(Verb) $(MKDIR) $(libdir)
711 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000712
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000713uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000714 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000715 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000716
717endif
718
719# endif LIBRARYNAME
Reid Spencerf206bd72004-10-22 21:01:56 +0000720endif
721
Reid Spencerdcba7782004-10-24 08:21:04 +0000722###############################################################################
723# Tool Build Rules: Build executable tool based on TOOLNAME option
724###############################################################################
725
Chris Lattner07c7c192001-09-07 22:57:58 +0000726ifdef TOOLNAME
727
Reid Spencerf88808a2004-10-30 09:19:36 +0000728#---------------------------------------------------------
Reid Spenceraf4495a2004-11-29 07:17:07 +0000729# Handle the special "JIT" value for LLVM_LIBS which is a
730# shorthand for a bunch of libraries that get the correct
731# JIT support for a tool that runs JIT.
732#---------------------------------------------------------
733ifeq ($(LLVMLIBS),JIT)
734
735# Make sure we can get our own symbols in the tool
736Link += -dlopen self
737
738# Generic JIT libraries
739JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
740
741# You can enable the X86 JIT on a non-X86 host by setting the flag
742# ENABLE_X86_JIT on the make command line. If not, it will still be
743# enabled automagically on an X86 host.
744ifeq ($(ARCH), x86)
745 ENABLE_X86_JIT = 1
746endif
747
748# What the X86 JIT requires
749ifdef ENABLE_X86_JIT
750 JIT_LIBS += LLVMX86 LLVMSelectionDAG
751endif
752
753# You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
754# ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
755# enabled automagically on an SparcV9 host.
756ifeq ($(ARCH), Sparc)
757 ENABLE_SPARCV9_JIT = 1
758endif
759
760# What the Sparc JIT requires
761ifdef ENABLE_SPARCV9_JIT
762 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
763 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
764 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
765 LLVMDataStructure.a LLVMSparcV9RegAlloc
766endif
767
768# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
769# ENABLE_PPC_JIT on the make command line. If not, it will still be
770# enabled automagically on an PowerPC host.
771ifeq ($(ARCH), PowerPC)
772 ENABLE_PPC_JIT = 1
773endif
774
775# What the PowerPC JIT requires
776ifdef ENABLE_PPC_JIT
777 JIT_LIBS += LLVMPowerPC
778endif
779
780LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
781 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
782 LLVMSystem.a $(PLATFORMLIBDL)
783endif
784
785#---------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000786# Set up variables for building a tool.
787#---------------------------------------------------------
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000788ifdef EXAMPLE_TOOL
789ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
790else
Reid Spencerf88808a2004-10-30 09:19:36 +0000791ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000792endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000793ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
794ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
795LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
796LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
797ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
798LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
799ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
800LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
Chris Lattner07c7c192001-09-07 22:57:58 +0000801
Reid Spencerf88808a2004-10-30 09:19:36 +0000802#---------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000803# Tell make that we need to rebuild subdirectories before
804# we can link the tool. This affects things like LLI which
805# has library subdirectories.
806#---------------------------------------------------------
807$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner3ecb7762003-01-22 16:13:31 +0000808
Reid Spencerf88808a2004-10-30 09:19:36 +0000809#---------------------------------------------------------
810# Provide targets for building the tools
811#---------------------------------------------------------
812all-local:: $(ToolBuildPath)
John Criswell8224df92003-06-27 16:58:44 +0000813
Reid Spencer81cd0492004-10-23 20:04:14 +0000814clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000815ifneq ($(strip $(ToolBuildPath)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000816 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencer12a3a052004-10-24 07:53:21 +0000817endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000818
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000819ifdef EXAMPLE_TOOL
820$(ToolBuildPath): $(ExmplDir)/.dir
821else
822$(ToolBuildPath): $(ToolDir)/.dir
823endif
824
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000825$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000826 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencerf88808a2004-10-30 09:19:36 +0000827 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
828 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000829 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencer12a3a052004-10-24 07:53:21 +0000830
831DestTool = $(bindir)/$(TOOLNAME)
832
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000833install-local:: $(DestTool)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000834
Reid Spencerf88808a2004-10-30 09:19:36 +0000835$(DestTool): $(bindir) $(ToolBuildPath)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000836 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencerf88808a2004-10-30 09:19:36 +0000837 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000838
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000839uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000840 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000841 -$(Verb) $(RM) -f $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000842
Reid Spencerf206bd72004-10-22 21:01:56 +0000843endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000844
Reid Spencerf88808a2004-10-30 09:19:36 +0000845###############################################################################
846# Object Build Rules: Build object files based on sources
847###############################################################################
848
849# Provide rule sets for when dependency generation is enabled
Reid Spencerf206bd72004-10-22 21:01:56 +0000850ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000851
Reid Spencerf88808a2004-10-30 09:19:36 +0000852#---------------------------------------------------------
853# Create .lo files in the ObjDir directory from the .cpp and .c files...
854#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000855ifdef SHARED_LIBRARY
856
Chris Lattner2a023902004-12-16 17:28:50 +0000857$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000858 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencerf88808a2004-10-30 09:19:36 +0000859 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
860 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
861 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000862
Chris Lattner2a023902004-12-16 17:28:50 +0000863$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000864 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencerf88808a2004-10-30 09:19:36 +0000865 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
866 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
867 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000868
Reid Spencerf88808a2004-10-30 09:19:36 +0000869#---------------------------------------------------------
870# Create .o files in the ObjDir directory from the .cpp and .c files...
871#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000872else
Reid Spencerf206bd72004-10-22 21:01:56 +0000873
Chris Lattner2a023902004-12-16 17:28:50 +0000874$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000875 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +0000876 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
877 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
878 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +0000879
Chris Lattner2a023902004-12-16 17:28:50 +0000880$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000881 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +0000882 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
883 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
884 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000885
886endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000887
Reid Spencerf88808a2004-10-30 09:19:36 +0000888#---------------------------------------------------------
889# Create .bc files in the ObjDir directory from .cpp and .c files...
890#---------------------------------------------------------
Chris Lattner2a023902004-12-16 17:28:50 +0000891$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000892 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencerf88808a2004-10-30 09:19:36 +0000893 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
894 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
895 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +0000896
Chris Lattner2a023902004-12-16 17:28:50 +0000897$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000898 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencerf88808a2004-10-30 09:19:36 +0000899 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
900 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
901 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +0000902
Reid Spencerf88808a2004-10-30 09:19:36 +0000903# Provide alternate rule sets if dependencies are disabled
Reid Spencerf206bd72004-10-22 21:01:56 +0000904else
905
Reid Spencer81cd0492004-10-23 20:04:14 +0000906ifdef SHARED_LIBRARY
907
Chris Lattner2a023902004-12-16 17:28:50 +0000908$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000909 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000910 $(LTCompile.CXX) $< -o $@
911
Chris Lattner2a023902004-12-16 17:28:50 +0000912$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000913 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +0000914 $(LTCompile.C) $< -o $@
915
916else
Reid Spencerf206bd72004-10-22 21:01:56 +0000917
Chris Lattner2a023902004-12-16 17:28:50 +0000918$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000919 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer81cd0492004-10-23 20:04:14 +0000920 $(Compile.CXX) $< -o $@
Reid Spencerf206bd72004-10-22 21:01:56 +0000921
Chris Lattner2a023902004-12-16 17:28:50 +0000922$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000923 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer81cd0492004-10-23 20:04:14 +0000924 $(Compile.C) $< -o $@
925endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000926
Chris Lattner2a023902004-12-16 17:28:50 +0000927$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000928 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencer991f66a2004-10-31 18:52:15 +0000929 $(BCCompile.CXX) $< -o $@
Reid Spencerf206bd72004-10-22 21:01:56 +0000930
Chris Lattner2a023902004-12-16 17:28:50 +0000931$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000932 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencer991f66a2004-10-31 18:52:15 +0000933 $(BCCompile.C) $< -o $@
Brian Gaeke0f148bc2003-12-10 00:26:28 +0000934
Chris Lattner07c7c192001-09-07 22:57:58 +0000935endif
936
Reid Spencerf88808a2004-10-30 09:19:36 +0000937#---------------------------------------------------------
938# Provide rule to build .bc files from .ll sources,
939# regardless of dependencies
940#---------------------------------------------------------
941$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000942 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +0000943 $(Verb) $(LLVMAS) $< -f -o $@
944
945###############################################################################
946# TABLEGEN: Provide rules for running tblgen to produce *.inc files
947###############################################################################
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000948
Reid Spencerf206bd72004-10-22 21:01:56 +0000949ifdef TARGET
950
Reid Spencerf88808a2004-10-30 09:19:36 +0000951TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
952INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Chris Lattner2a023902004-12-16 17:28:50 +0000953INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
954.PRECIOUS: $(INCTMPFiles) $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +0000955
Chris Lattner2a023902004-12-16 17:28:50 +0000956# All of these files depend on tblgen and the .td files.
957$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +0000958
Chris Lattnerf86914d2004-12-16 17:38:56 +0000959# INCFiles rule: All of the tblgen generated files are emitted to
960# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
961# us to only "touch" the real file if the contents of it change. IOW, if
962# tblgen is modified, all of the .inc.tmp files are regereated, but no
963# dependencies of the .inc files are, unless the contents of the .inc file
964# changes.
965$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
966 $(Verb) cmp -s $@ $< || cp $< $@
Chris Lattner2a023902004-12-16 17:28:50 +0000967
968$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
969$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +0000970 $(Echo) "Building $(<F) register names with tblgen"
971 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000972
Chris Lattner2a023902004-12-16 17:28:50 +0000973$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
974$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +0000975 $(Echo) "Building $(<F) register information header with tblgen"
976 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000977
Chris Lattner2a023902004-12-16 17:28:50 +0000978$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
979$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +0000980 $(Echo) "Building $(<F) register info implementation with tblgen"
981 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000982
Chris Lattner2a023902004-12-16 17:28:50 +0000983$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
984$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +0000985 $(Echo) "Building $(<F) instruction names with tblgen"
986 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000987
Chris Lattner2a023902004-12-16 17:28:50 +0000988$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
989$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +0000990 $(Echo) "Building $(<F) instruction information with tblgen"
991 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000992
Chris Lattner2a023902004-12-16 17:28:50 +0000993$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
994$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +0000995 $(Echo) "Building $(<F) assembly writer with tblgen"
996 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +0000997
Chris Lattner22f937a2004-12-16 17:34:04 +0000998$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
999$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1000 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Reid Spencerf88808a2004-10-30 09:19:36 +00001001 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001002
Chris Lattner2a023902004-12-16 17:28:50 +00001003$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1004$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001005 $(Echo) "Building $(<F) code emitter with tblgen"
1006 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001007
Reid Spencer81cd0492004-10-23 20:04:14 +00001008clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001009 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001010
1011endif
Chris Lattner0c4f4fe2003-08-15 02:18:35 +00001012
Reid Spencerf88808a2004-10-30 09:19:36 +00001013###############################################################################
1014# LEX AND YACC: Provide rules for generating sources with lex and yacc
1015###############################################################################
Chris Lattnerdb644dd2003-01-16 22:44:19 +00001016
Reid Spencerf88808a2004-10-30 09:19:36 +00001017#---------------------------------------------------------
1018# Provide rules for generating a .cpp source file from
1019# (f)lex input sources.
1020#---------------------------------------------------------
1021
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001022LexFiles := $(filter %.l,$(Sources))
Reid Spencerf88808a2004-10-30 09:19:36 +00001023
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001024ifneq ($(LexFiles),)
1025
1026LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
Reid Spencerf88808a2004-10-30 09:19:36 +00001027
1028.PRECIOUS: $(LexOutput)
1029
1030# Note the extra sed filtering here, used to cut down on the warnings emited
1031# by GCC. The last line is a gross hack to work around flex aparently not
1032# being able to resize the buffer on a large token input. Currently, for
1033# uninitialized string buffers in LLVM we can generate very long tokens, so
1034# this is a hack around it.
Chris Lattner92fc9b02003-08-15 20:00:47 +00001035# FIXME. (f.e. char Buffer[10000] )
Chris Lattner2f7c9632001-06-06 20:29:01 +00001036%.cpp: %.l
Reid Spencer993b95e2004-12-10 19:44:16 +00001037 $(Echo) Flexing $*.l
Reid Spencerf88808a2004-10-30 09:19:36 +00001038 $(Verb) $(FLEX) -t $< | \
Reid Spencerf206bd72004-10-22 21:01:56 +00001039 $(SED) 's/void yyunput/inline void yyunput/' | \
1040 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1041 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencerb7f710a2004-10-28 00:41:43 +00001042 > $@
Chris Lattner2f7c9632001-06-06 20:29:01 +00001043
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001044clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001045 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001046 $(Verb) $(RM) -f $(LexOutput)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001047
Reid Spencerf88808a2004-10-30 09:19:36 +00001048endif
1049
1050#---------------------------------------------------------
1051# Provide rules for generating a .cpp and .h source files
1052# from yacc (bison) input sources.
1053#---------------------------------------------------------
1054
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001055YaccFiles := $(filter %.y,$(Sources))
1056ifneq ($(YaccFiles),)
1057YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
Reid Spencerf88808a2004-10-30 09:19:36 +00001058
1059.PRECIOUS: $(YaccOutput)
1060
1061# Cancel built-in rules for yacc
1062%.c: %.y
1063%.cpp: %.y
1064%.h: %.y
1065
Chris Lattner2f7c9632001-06-06 20:29:01 +00001066# Rule for building the bison parsers...
Chris Lattner2f7c9632001-06-06 20:29:01 +00001067%.cpp %.h : %.y
Reid Spencerf88808a2004-10-30 09:19:36 +00001068 $(Echo) "Bisoning $*.y"
1069 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1070 $(Verb) $(MV) -f $*.tab.c $*.cpp
1071 $(Verb) $(MV) -f $*.tab.h $*.h
Chris Lattner2f7c9632001-06-06 20:29:01 +00001072
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001073clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001074 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001075 $(Verb) $(RM) -f $(YaccOutput)
Reid Spencerf88808a2004-10-30 09:19:36 +00001076endif
Chris Lattner2f7c9632001-06-06 20:29:01 +00001077
Reid Spencerf88808a2004-10-30 09:19:36 +00001078###############################################################################
1079# OTHER RULES: Other rules needed
1080###############################################################################
Reid Spencerf206bd72004-10-22 21:01:56 +00001081
Chris Lattner23d47392003-01-16 21:06:18 +00001082# To create postscript files from dot files...
John Criswell4ffb8442003-10-02 19:02:02 +00001083ifneq ($(DOT),false)
Chris Lattner23d47392003-01-16 21:06:18 +00001084%.ps: %.dot
Reid Spencerf206bd72004-10-22 21:01:56 +00001085 $(DOT) -Tps < $< > $@
John Criswell3ef61af2003-06-30 21:59:07 +00001086else
1087%.ps: %.dot
Reid Spencerf88808a2004-10-30 09:19:36 +00001088 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell3ef61af2003-06-30 21:59:07 +00001089endif
Chris Lattner23d47392003-01-16 21:06:18 +00001090
John Criswell0a6e6aa2003-09-06 14:44:17 +00001091# This rules ensures that header files that are removed still have a rule for
1092# which they can be "generated." This allows make to ignore them and
1093# reproduce the dependency lists.
John Criswella8391af2003-09-18 18:37:08 +00001094%.h:: ;
John Criswell0a6e6aa2003-09-06 14:44:17 +00001095
Reid Spencerf88808a2004-10-30 09:19:36 +00001096# Define clean-local to clean the current directory. Note that this uses a
1097# very conservative approach ensuring that empty variables do not cause
1098# errors or disastrous removal.
Reid Spencer81cd0492004-10-23 20:04:14 +00001099clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001100ifneq ($(strip $(ObjDir)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001101 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencer12a3a052004-10-24 07:53:21 +00001102endif
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001103 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke8625f682004-01-21 19:53:11 +00001104ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001105 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke8625f682004-01-21 19:53:11 +00001106endif
John Criswell3ef61af2003-06-30 21:59:07 +00001107
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001108clean-all-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001109 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001110
Reid Spencerf88808a2004-10-30 09:19:36 +00001111# Build tags database for Emacs/Xemacs:
Reid Spenceraee67e62004-11-12 02:27:36 +00001112tags:: TAGS CTAGS
1113
Reid Spencerf88808a2004-10-30 09:19:36 +00001114TAGS:
Reid Spenceraee67e62004-11-12 02:27:36 +00001115 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1116 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1117 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1118 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1119 -name '*.cpp' -o -name '*.h' | \
Reid Spencerf88808a2004-10-30 09:19:36 +00001120 $(ETAGS) $(ETAGSFLAGS) -
1121
Reid Spenceraee67e62004-11-12 02:27:36 +00001122CTAGS:
1123 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1124 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1125 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1126 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1127 \( -name '*.cpp' -o -name '*.h' \) -print | \
1128 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1129
1130
Reid Spencer81cd0492004-10-23 20:04:14 +00001131###############################################################################
1132# DEPENDENCIES: Include the dependency files if we should
1133###############################################################################
Chris Lattnere9d7d702003-08-22 14:10:16 +00001134ifndef DISABLE_AUTO_DEPENDENCIES
1135
Reid Spencer81cd0492004-10-23 20:04:14 +00001136# If its not one of the cleaning targets
Reid Spencerf88808a2004-10-30 09:19:36 +00001137ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencerf206bd72004-10-22 21:01:56 +00001138
Reid Spencer81cd0492004-10-23 20:04:14 +00001139# Get the list of dependency files
Reid Spencerf88808a2004-10-30 09:19:36 +00001140DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001141DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
Misha Brukmanb891ffb2003-11-09 21:36:19 +00001142
Reid Spencer81cd0492004-10-23 20:04:14 +00001143-include /dev/null $(DependFiles)
1144
John Criswell48ecca62003-08-12 18:51:51 +00001145endif
Chris Lattner598222b2003-08-18 17:27:40 +00001146
Reid Spencerf88808a2004-10-30 09:19:36 +00001147endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001148
Reid Spencer100080c2004-10-25 08:27:37 +00001149###############################################################################
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001150# CHECK: Running the test suite
1151###############################################################################
1152
1153check::
1154 $(Verb) if test -d "$(BUILD_OBJ_ROOT)/test" ; then \
1155 if test -f "$(BUILD_OBJ_ROOT)/test/Makefile" ; then \
1156 $(EchoCmd) Running test suite ; \
1157 $(MAKE) -C $(BUILD_OBJ_ROOT)/test check-local \
1158 TESTSUITE=$(TESTSUITE) ; \
1159 else \
1160 $(EchoCmd) No Makefile in test directory ; \
1161 fi ; \
1162 else \
1163 $(EchoCmd) No test directory ; \
1164 fi
1165
1166###############################################################################
Reid Spencerf88808a2004-10-30 09:19:36 +00001167# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer100080c2004-10-25 08:27:37 +00001168###############################################################################
1169
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001170#------------------------------------------------------------------------
1171# Define distribution related variables
1172#------------------------------------------------------------------------
Reid Spencer100080c2004-10-25 08:27:37 +00001173DistName := $(LLVM_TARBALL_NAME)
1174DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001175TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer100080c2004-10-25 08:27:37 +00001176DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1177DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1178DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1179DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1180 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001181 Makefile.config.in configure autoconf
1182DistOther := $(notdir $(wildcard \
1183 $(BUILD_SRC_DIR)/*.h \
1184 $(BUILD_SRC_DIR)/*.td \
1185 $(BUILD_SRC_DIR)/*.def \
1186 $(BUILD_SRC_DIR)/*.ll \
1187 $(BUILD_SRC_DIR)/*.in))
Reid Spencerf88808a2004-10-30 09:19:36 +00001188DistSubDirs := $(SubDirs)
Reid Spencerfc66af42004-11-29 05:00:33 +00001189DistSources = $(Sources) $(EXTRA_DIST)
1190DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer100080c2004-10-25 08:27:37 +00001191
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001192#------------------------------------------------------------------------
1193# We MUST build distribution with OBJ_DIR != SRC_DIR
1194#------------------------------------------------------------------------
1195ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1196dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerf88808a2004-10-30 09:19:36 +00001197 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001198
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001199else
1200
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001201#------------------------------------------------------------------------
1202# Prevent catastrophic remove
1203#------------------------------------------------------------------------
1204ifeq ($(LLVM_TARBALL_NAME),)
1205$(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1206endif
1207
1208#------------------------------------------------------------------------
1209# Prevent attempt to run dist targets from anywhere but the top level
1210#------------------------------------------------------------------------
1211ifneq ($(LEVEL),.)
1212
1213dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerf88808a2004-10-30 09:19:36 +00001214 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001215
1216else
1217
1218#------------------------------------------------------------------------
1219# Provide the top level targets
1220#------------------------------------------------------------------------
1221
Reid Spencerf88808a2004-10-30 09:19:36 +00001222dist-gzip:: $(DistTarGZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001223
Reid Spencer81546582004-12-04 22:34:09 +00001224$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001225 $(Echo) Packing gzipped distribution tar file.
Reid Spencerfc66af42004-11-29 05:00:33 +00001226 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1227 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001228
Reid Spencerf88808a2004-10-30 09:19:36 +00001229dist-bzip2:: $(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001230
Reid Spencer81546582004-12-04 22:34:09 +00001231$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001232 $(Echo) Packing bzipped distribution tar file.
Reid Spencerfc66af42004-11-29 05:00:33 +00001233 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1234 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001235
Reid Spencerf88808a2004-10-30 09:19:36 +00001236dist-zip:: $(DistZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001237
Reid Spencer81546582004-12-04 22:34:09 +00001238$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001239 $(Echo) Packing zipped distribution file.
1240 $(Verb) rm -f $(DistZip)
1241 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001242
1243dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001244 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001245
1246DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1247
Reid Spencer81546582004-12-04 22:34:09 +00001248dist-check:: $(DistTarGZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001249 $(Echo) Checking distribution tar file.
1250 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001251 $(RM) -rf $(DistCheckDir) ; \
1252 fi
Reid Spencerf88808a2004-10-30 09:19:36 +00001253 $(Verb) $(MKDIR) $(DistCheckDir)
1254 $(Verb) cd $(DistCheckDir) && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001255 $(MKDIR) $(DistCheckDir)/build && \
1256 $(MKDIR) $(DistCheckDir)/install && \
1257 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1258 cd build && \
1259 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1260 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
Reid Spencer81546582004-12-04 22:34:09 +00001261 $(MAKE) all && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001262 $(MAKE) check && \
1263 $(MAKE) install && \
1264 $(MAKE) uninstall && \
1265 $(MAKE) dist && \
1266 $(MAKE) clean && \
1267 $(MAKE) dist-clean && \
Reid Spencerf88808a2004-10-30 09:19:36 +00001268 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001269
1270dist-clean::
Reid Spencerf88808a2004-10-30 09:19:36 +00001271 $(Echo) Cleaning distribution files
Reid Spencer81546582004-12-04 22:34:09 +00001272 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1273 $(DistCheckDir)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001274
1275endif
1276
1277#------------------------------------------------------------------------
1278# Provide the recursive distdir target for building the distribution directory
1279#------------------------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +00001280distdir: $(DistDir)/.makedistdir
1281$(DistDir)/.makedistdir: $(DistSources)
Reid Spencerf88808a2004-10-30 09:19:36 +00001282 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001283 if test -d "$(DistDir)" ; then \
1284 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1285 exit 1 ; \
1286 fi ; \
Reid Spencer81546582004-12-04 22:34:09 +00001287 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001288 $(RM) -rf $(DistDir); \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001289 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer81546582004-12-04 22:34:09 +00001290 $(MAKE) all ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001291 fi
Reid Spencerfc66af42004-11-29 05:00:33 +00001292 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencerf88808a2004-10-30 09:19:36 +00001293 $(Verb) $(MKDIR) $(DistDir)
1294 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
Reid Spencer100080c2004-10-25 08:27:37 +00001295 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1296 for file in $(DistFiles) ; do \
1297 case "$$file" in \
Reid Spencer81546582004-12-04 22:34:09 +00001298 $(BUILD_SRC_DIR)/*) \
1299 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1300 ;; \
1301 $(BUILD_SRC_ROOT)/*) \
1302 file=`echo "$$file" | \
1303 sed "s#^$$srcrootstrip/##"` \
1304 ;; \
Reid Spencer100080c2004-10-25 08:27:37 +00001305 esac; \
Reid Spencer81546582004-12-04 22:34:09 +00001306 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1307 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1308 from_dir="$(BUILD_SRC_DIR)" ; \
1309 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001310 from_dir=. ; \
Reid Spencer81546582004-12-04 22:34:09 +00001311 fi ; \
1312 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001313 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1314 to_dir="$(DistDir)/$$dir"; \
1315 $(MKDIR) "$$to_dir" ; \
1316 else \
1317 to_dir="$(DistDir)"; \
1318 fi; \
1319 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1320 if test -n "$$mid_dir" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001321 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001322 fi ; \
1323 if test -d "$$from_dir/$$file"; then \
1324 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1325 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1326 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1327 fi; \
1328 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1329 elif test -f "$$from_dir/$$file" ; then \
1330 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1331 elif test -L "$$from_dir/$$file" ; then \
1332 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1333 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer81546582004-12-04 22:34:09 +00001334 $(EchoCmd) "===== WARNING: Distribution Source " \
1335 "$$from_dir/$$file Not Found!" ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001336 elif test "$(Verb)" != '@' ; then \
1337 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001338 fi; \
1339 done
Reid Spencerf88808a2004-10-30 09:19:36 +00001340 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer100080c2004-10-25 08:27:37 +00001341 if test "$$subdir" \!= "." ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001342 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001343 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer81546582004-12-04 22:34:09 +00001344 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1345 exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001346 fi; \
1347 done
Reid Spencer81546582004-12-04 22:34:09 +00001348 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1349 $(EchoCmd) Eliminating CVS directories from distribution ; \
1350 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1351 $(MAKE) dist-hook ; \
1352 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1353 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1354 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1355 -o ! -type d ! -perm -444 -exec \
1356 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1357 || chmod -R a+r $(DistDir) ; \
1358 fi
Reid Spencer100080c2004-10-25 08:27:37 +00001359
Reid Spencerf88808a2004-10-30 09:19:36 +00001360# This is invoked by distdir target, define it as a no-op to avoid errors if not
1361# defined by user.
Reid Spencer100080c2004-10-25 08:27:37 +00001362dist-hook::
1363
Reid Spencer23a70372004-10-22 23:06:30 +00001364endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001365
1366###############################################################################
Reid Spencer12a3a052004-10-24 07:53:21 +00001367# TOP LEVEL - targets only to apply at the top level directory
1368###############################################################################
1369
1370ifeq ($(LEVEL),.)
1371
1372#------------------------------------------------------------------------
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001373# Install support for the project's include files:
Reid Spencer12a3a052004-10-24 07:53:21 +00001374#------------------------------------------------------------------------
1375install-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001376 $(Echo) Installing include files
1377 $(Verb) $(MKDIR) $(includedir)
1378 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencer12a3a052004-10-24 07:53:21 +00001379 cd $(BUILD_SRC_ROOT)/include && \
1380 find . -path '*/Internal' -prune -o '(' -type f \
1381 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1382 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1383 fi
1384
1385uninstall-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001386 $(Echo) Uninstalling include files
1387 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencer12a3a052004-10-24 07:53:21 +00001388 cd $(BUILD_SRC_ROOT)/include && \
1389 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1390 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1391 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1392 fi
1393
Reid Spencer12a3a052004-10-24 07:53:21 +00001394endif
1395
Reid Spencerf206bd72004-10-22 21:01:56 +00001396#------------------------------------------------------------------------
1397# Print out the directories used for building
Reid Spencerf88808a2004-10-30 09:19:36 +00001398#------------------------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001399printvars::
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001400 $(Echo) "BuildMode : " '$(BuildMode)'
Reid Spencerf88808a2004-10-30 09:19:36 +00001401 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1402 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1403 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1404 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1405 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1406 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1407 $(Echo) "libdir : " '$(libdir)'
1408 $(Echo) "bindir : " '$(bindir)'
1409 $(Echo) "sysconfdir : " '$(sysconfdir)'
Reid Spencerf88808a2004-10-30 09:19:36 +00001410 $(Echo) "UserTargets : " '$(UserTargets)'
1411 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1412 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1413 $(Echo) "ObjDir : " '$(ObjDir)'
1414 $(Echo) "LibDir : " '$(LibDir)'
1415 $(Echo) "ToolDir : " '$(ToolDir)'
Reid Spencer7e9e0b02004-11-18 10:03:46 +00001416 $(Echo) "ExmplDir : " '$(ExmplDir)'
Reid Spencerd78077d2004-12-05 05:17:22 +00001417 $(Echo) "Sources : " '$(Sources)'
Reid Spencerf88808a2004-10-30 09:19:36 +00001418 $(Echo) "TDFiles : " '$(TDFiles)'
1419 $(Echo) "INCFiles : " '$(INCFiles)'
Chris Lattner2a023902004-12-16 17:28:50 +00001420 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
Reid Spencerf88808a2004-10-30 09:19:36 +00001421 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1422 $(Echo) "Compile.C : " '$(Compile.C)'
1423 $(Echo) "Archive : " '$(Archive)'
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001424 $(Echo) "YaccFiles : " '$(YaccFiles)'
1425 $(Echo) "LexFiles : " '$(LexFiles)'
Reid Spencerd78077d2004-12-05 05:17:22 +00001426 $(Echo) "Module : " '$(Module)'