blob: f6e3467e787418812efb6f188d1a6797dd3d0df9 [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#--------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +000038VPATH=$(PROJ_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:
Chris Lattnerf60c1702005-02-04 21:28:50 +000044.SUFFIXES: .c .cpp .cc .h .hpp .y .l .lo .o .a .bc .td .ps .dot
Reid Spencerf88808a2004-10-30 09:19:36 +000045.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 Spencerba6a3db2005-01-16 02:20:54 +000064 $(wildcard $(PROJ_SRC_DIR)/Makefile*))
65ObjMakefiles := $(subst $(PROJ_SRC_DIR),$(PROJ_OBJ_DIR),$(SrcMakefiles))
66ConfigureScript := $(PROJ_SRC_ROOT)/configure
67ConfigStatusScript := $(PROJ_OBJ_ROOT)/config.status
68MakefileConfigIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.config.in))
69MakefileCommonIn := $(strip $(wildcard $(PROJ_SRC_ROOT)/Makefile.common.in))
70MakefileConfig := $(PROJ_OBJ_ROOT)/Makefile.config
71MakefileCommon := $(PROJ_OBJ_ROOT)/Makefile.common
72PreConditions := $(ConfigStatusScript) $(ObjMakefiles)
73ifneq ($(MakefileCommonIn),)
74PreConditions += $(MakefileCommon)
75endif
76ifneq ($(MakefileConfigIn),)
77PreConditions += $(MakefileConfig)
78endif
Reid Spencer77a46d22004-10-26 22:26:33 +000079
Reid Spencerf88808a2004-10-30 09:19:36 +000080preconditions : $(PreConditions)
Reid Spencer77a46d22004-10-26 22:26:33 +000081
82#------------------------------------------------------------------------
83# Make sure the BUILT_SOURCES are built first
84#------------------------------------------------------------------------
Reid Spencer97e40f12004-12-16 07:15:16 +000085$(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
Reid Spencer77a46d22004-10-26 22:26:33 +000086
87clean-local::
88ifneq ($(strip $(BUILT_SOURCES)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +000089 -$(Verb) $(RM) -f $(BUILT_SOURCES)
Reid Spencer77a46d22004-10-26 22:26:33 +000090endif
91
Reid Spencerba6a3db2005-01-16 02:20:54 +000092ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
Reid Spencer55814372004-12-16 08:00:46 +000093spotless:
Reid Spencer55814372004-12-16 08:00:46 +000094 $(Verb) if test -x config.status ; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +000095 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
Reid Spencer7ef8e662004-12-17 07:45:03 +000096 $(MKDIR) .spotless.save ; \
97 $(MV) config.status .spotless.save ; \
98 $(MV) mklib .spotless.save ; \
99 $(MV) projects .spotless.save ; \
Reid Spencer55814372004-12-16 08:00:46 +0000100 $(RM) -rf * ; \
Reid Spencer7ef8e662004-12-17 07:45:03 +0000101 $(MV) .spotless.save/config.status . ; \
102 $(MV) .spotless.save/mklib . ; \
103 $(MV) .spotless.save/projects . ; \
104 $(RM) -rf .spotless.save ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000105 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
Reid Spencer7ef8e662004-12-17 07:45:03 +0000106 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
107 $(ConfigStatusScript) ; \
Reid Spencer55814372004-12-16 08:00:46 +0000108 else \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000109 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
Reid Spencer55814372004-12-16 08:00:46 +0000110 fi
111endif
112
Reid Spencerf88808a2004-10-30 09:19:36 +0000113$(BUILT_SOURCES) : $(ObjMakefiles)
Reid Spencerb7f710a2004-10-28 00:41:43 +0000114
Reid Spencer77a46d22004-10-26 22:26:33 +0000115#------------------------------------------------------------------------
116# Make sure we're not using a stale configuration
117#------------------------------------------------------------------------
Reid Spencerafdc82c2004-12-16 18:26:53 +0000118reconfigure:
Reid Spencerba6a3db2005-01-16 02:20:54 +0000119 $(Echo) Reconfiguring $(PROJ_OBJ_ROOT)
120 $(Verb) cd $(PROJ_OBJ_ROOT) && \
121 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
122 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
Reid Spencer35655d62004-12-24 03:36:31 +0000123 fi ; \
Reid Spencerafdc82c2004-12-16 18:26:53 +0000124 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
125 $(ConfigStatusScript)
126
Reid Spencerf88808a2004-10-30 09:19:36 +0000127.PRECIOUS: $(ConfigStatusScript)
128$(ConfigStatusScript): $(ConfigureScript)
129 $(Echo) Reconfiguring with $<
Reid Spencerba6a3db2005-01-16 02:20:54 +0000130 $(Verb) cd $(PROJ_OBJ_ROOT) && \
131 if test -w $(PROJ_OBJ_ROOT)/config.cache ; then \
132 $(RM) $(PROJ_OBJ_ROOT)/config.cache ; \
Reid Spencer35655d62004-12-24 03:36:31 +0000133 fi ; \
Reid Spencer50f34872004-11-29 12:37:44 +0000134 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
135 $(ConfigStatusScript)
Reid Spencer77a46d22004-10-26 22:26:33 +0000136
137#------------------------------------------------------------------------
138# Make sure the configuration makefile is up to date
139#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +0000140ifneq ($(MakefileConfigIn),)
141$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
Reid Spencerf88808a2004-10-30 09:19:36 +0000142 $(Echo) Regenerating $@
Reid Spencerba6a3db2005-01-16 02:20:54 +0000143 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
144endif
145
146ifneq ($(MakefileCommonIn),)
147$(MakefileCommon): $(MakefileCommonIn) $(ConfigStatusScript)
148 $(Echo) Regenerating $@
149 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.common
150endif
Reid Spencer77a46d22004-10-26 22:26:33 +0000151
152#------------------------------------------------------------------------
153# If the Makefile in the source tree has been updated, copy it over into the
154# build tree. But, only do this if the source and object makefiles differ
155#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +0000156ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
Reid Spencer77a46d22004-10-26 22:26:33 +0000157
Reid Spencerba6a3db2005-01-16 02:20:54 +0000158Makefile: $(PROJ_SRC_DIR)/Makefile
Reid Spencerf88808a2004-10-30 09:19:36 +0000159 $(Echo) "Updating Makefile"
160 $(Verb) $(MKDIR) $(@D)
Reid Spencerafdc82c2004-12-16 18:26:53 +0000161 $(Verb) $(CP) -f $< $@
Reid Spencer77a46d22004-10-26 22:26:33 +0000162
163# Copy the Makefile.* files unless we're in the root directory which avoids
164# the copying of Makefile.config.in or other things that should be explicitly
165# taken care of.
Reid Spencerba6a3db2005-01-16 02:20:54 +0000166$(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
Reid Spencerd94bb332004-10-26 23:10:00 +0000167 @case '$?' in \
168 *Makefile.rules) ;; \
169 *.in) ;; \
Reid Spencerf88808a2004-10-30 09:19:36 +0000170 *) $(Echo) "Updating $(@F)" ; \
Reid Spencerd94bb332004-10-26 23:10:00 +0000171 $(MKDIR) $(@D) ; \
Reid Spencerafdc82c2004-12-16 18:26:53 +0000172 $(CP) -f $< $@ ;; \
Reid Spencerd94bb332004-10-26 23:10:00 +0000173 esac
174
Reid Spencer77a46d22004-10-26 22:26:33 +0000175endif
176
177#------------------------------------------------------------------------
178# Set up the basic dependencies
179#------------------------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000180$(UserTargets):: $(PreConditions)
Reid Spencer77a46d22004-10-26 22:26:33 +0000181
182all:: all-local
Reid Spencer81cd0492004-10-23 20:04:14 +0000183clean:: clean-local
Reid Spencer9d0c1e02004-11-02 16:36:03 +0000184clean-all:: clean-local clean-all-local
Reid Spencer77a46d22004-10-26 22:26:33 +0000185install:: install-local
186uninstall:: uninstall-local
Reid Spencer77a46d22004-10-26 22:26:33 +0000187install-local:: all-local
Reid Spencerd4bd3752004-12-03 20:08:48 +0000188install-bytecode:: install-bytecode-local
Reid Spencer81cd0492004-10-23 20:04:14 +0000189
190###############################################################################
191# VARIABLES: Set up various variables based on configuration data
192###############################################################################
193
194#--------------------------------------------------------------------
195# Variables derived from configuration we are building
Chris Lattner2f7c9632001-06-06 20:29:01 +0000196#--------------------------------------------------------------------
197
Reid Spencer34982d82005-01-02 17:43:20 +0000198
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000199ifdef ENABLE_PROFILING
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000200 BuildMode := Profile
Reid Spencercd7d6cf2004-12-08 04:34:51 +0000201 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
Reid Spencerf88808a2004-10-30 09:19:36 +0000202 C.Flags := -O3 -DNDEBUG -pg
203 LD.Flags := -O3 -DNDEBUG -pg
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000204else
205 ifdef ENABLE_OPTIMIZED
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000206 BuildMode := Release
Reid Spencer34982d82005-01-02 17:43:20 +0000207 # Don't use -fomit-frame-pointer on FreeBSD
208 ifneq ($(OS),FreeBSD)
209 OmitFramePointer := -fomit-frame-pointer
210 endif
211 CXX.Flags := -O3 -DNDEBUG -finline-functions -felide-constructors \
212 $(OmitFramePointer)
213 C.Flags := -O3 -DNDEBUG $(OmitFramePointer)
Reid Spencerf88808a2004-10-30 09:19:36 +0000214 LD.Flags := -O3 -DNDEBUG
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000215 else
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000216 BuildMode := Debug
Reid Spencercd7d6cf2004-12-08 04:34:51 +0000217 CXX.Flags := -g -D_DEBUG
Reid Spencerf88808a2004-10-30 09:19:36 +0000218 C.Flags := -g -D_DEBUG
219 LD.Flags := -g -D_DEBUG
Reid Spencerf206bd72004-10-22 21:01:56 +0000220 KEEP_SYMBOLS := 1
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000221 endif
222endif
223
Reid Spencerf88808a2004-10-30 09:19:36 +0000224CXX.Flags += $(CXXFLAGS)
225C.Flags += $(CFLAGS)
226CPP.Flags += $(CPPFLAGS)
227LD.Flags += $(LDFLAGS)
228AR.Flags := cru
229LibTool.Flags := --tag=CXX
Reid Spencer81cd0492004-10-23 20:04:14 +0000230
Andrew Lenharth9a98def2005-02-13 03:41:10 +0000231#Make Floating point ieee complient on alpha
232ifeq ($(ARCH),Alpha)
233 CXX.Flags += -mieee
234 CPP.Flags += -mieee
235endif
236
Reid Spencer81cd0492004-10-23 20:04:14 +0000237#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000238# Directory locations
Reid Spencer81cd0492004-10-23 20:04:14 +0000239#--------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +0000240ObjDir := $(PROJ_OBJ_DIR)/$(BuildMode)
241LibDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib
242ToolDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin
243ExmplDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000244LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer0dbf1012004-11-18 20:04:39 +0000245LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencerb9f8de62004-12-28 07:59:22 +0000246LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer2bba41c2004-12-22 05:57:21 +0000247CFERuntimeLibDir := $(LLVMGCCDIR)/lib
John Criswell3ef61af2003-06-30 21:59:07 +0000248
Reid Spencer81cd0492004-10-23 20:04:14 +0000249#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000250# Full Paths To Compiled Tools and Utilities
Reid Spencer81cd0492004-10-23 20:04:14 +0000251#--------------------------------------------------------------------
Reid Spencerb12e2902005-01-14 16:33:36 +0000252EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
253Echo = @$(EchoCmd)
Reid Spencerf88808a2004-10-30 09:19:36 +0000254ifndef LIBTOOL
Reid Spencerf206bd72004-10-22 21:01:56 +0000255LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencerf88808a2004-10-30 09:19:36 +0000256endif
257ifndef LLVMAS
258LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
259endif
260ifndef BURG
261BURG := $(LLVMToolDir)/burg$(EXEEXT)
262endif
263ifndef TBLGEN
264TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
265endif
Chris Lattner0ea40c92004-11-29 19:47:58 +0000266ifndef GCCAS
267GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
268endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000269ifndef GCCLD
270GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
271endif
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000272ifndef LDIS
273LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
274endif
275ifndef LLI
276LLI := $(LLVMToolDir)/lli$(EXEEXT)
277endif
Alkis Evlogimenos24340582005-02-27 10:21:37 +0000278ifndef LLC
279LLC := $(LLVMToolDir)/llc$(EXEEXT)
280endif
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000281ifndef LOPT
Alkis Evlogimenos7c7705d2004-12-13 18:08:29 +0000282LOPT := $(LLVMToolDir)/opt$(EXEEXT)
Alkis Evlogimenosa20de022004-12-13 17:44:14 +0000283endif
Alkis Evlogimenos7c04a3d2005-02-02 00:40:15 +0000284ifndef LBUGPOINT
285LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
286endif
287
John Criswelldc665012005-01-03 17:42:57 +0000288LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
289LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000290
Reid Spencer81cd0492004-10-23 20:04:14 +0000291#--------------------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000292# Adjust to user's request
Reid Spencer81cd0492004-10-23 20:04:14 +0000293#--------------------------------------------------------------------
Dinakar Dhurjati41f77482003-05-29 16:18:20 +0000294
Reid Spencer87e645c2005-01-11 04:31:07 +0000295# Adjust LD.Flags and Libtool.Flags depending on the kind of library that is
296# to be built. Note that if LOADABLE_MODULE is specified then the resulting
297# shared library can be opened with dlopen
298ifdef SHARED_LIBRARY
Reid Spencerf88808a2004-10-30 09:19:36 +0000299 LD.Flags += -rpath $(LibDir)
Reid Spencer87e645c2005-01-11 04:31:07 +0000300 ifdef LOADABLE_MODULE
301 LD.Flags += -module
302 endif
303else
304 LibTool.Flags += --tag=disable-shared
John Criswell3601f372003-07-31 20:58:51 +0000305endif
306
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000307ifdef TOOL_VERBOSE
308 C.Flags += -v
309 CXX.Flags += -v
310 LD.Flags += -v
Reid Spencerf8b4a8e2004-11-08 17:32:12 +0000311 VERBOSE := 1
312endif
313
Reid Spencer81cd0492004-10-23 20:04:14 +0000314# Adjust settings for verbose mode
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000315ifndef VERBOSE
Reid Spencerf88808a2004-10-30 09:19:36 +0000316 Verb := @
317 LibTool.Flags += --silent
318 AR.Flags += >/dev/null 2>/dev/null
Reid Spencerba6a3db2005-01-16 02:20:54 +0000319 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
Reid Spencer100080c2004-10-25 08:27:37 +0000320else
Reid Spencerf88808a2004-10-30 09:19:36 +0000321 ConfigureScriptFLAGS :=
Misha Brukman1326a7c2002-09-12 16:05:39 +0000322endif
323
Vikram S. Adved141c282002-09-18 11:55:13 +0000324# By default, strip symbol information from executable
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000325ifndef KEEP_SYMBOLS
Reid Spencerf88808a2004-10-30 09:19:36 +0000326 Strip := $(PLATFORMSTRIPOPTS)
327 StripWarnMsg := "(without symbols)"
Reid Spencer247a10e2005-02-24 07:12:43 +0000328 Install.StripFlag += -s
Vikram S. Adved141c282002-09-18 11:55:13 +0000329endif
330
Reid Spencer81cd0492004-10-23 20:04:14 +0000331# Adjust linker flags for building an executable
Reid Spencerf206bd72004-10-22 21:01:56 +0000332ifdef TOOLNAME
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000333ifdef EXAMPLE_TOOL
334 LD.Flags += -rpath $(ExmplDir) -export-dynamic
335else
Reid Spencerf88808a2004-10-30 09:19:36 +0000336 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000337endif
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000338endif
Dinakar Dhurjati3ac83a92003-10-29 14:28:35 +0000339
Reid Spencer81cd0492004-10-23 20:04:14 +0000340#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000341# Options To Invoke Tools
Reid Spencer81cd0492004-10-23 20:04:14 +0000342#----------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000343
344CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
345
Duraid Madina60c9a3c2005-05-16 06:38:09 +0000346ifeq ($(OS),HP-UX)
347 CompileCommonOpts += -D_REENTRANT -D_HPUX_SOURCE
348endif
349
Reid Spencere9fa5442005-02-14 21:54:08 +0000350LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000351CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
352 -I$(PROJ_OBJ_ROOT)/include \
353 -I$(PROJ_SRC_ROOT)/include \
354 -I$(LLVM_OBJ_ROOT)/include \
355 -I$(LLVM_SRC_ROOT)/include \
356 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
Reid Spencerf206bd72004-10-22 21:01:56 +0000357
Reid Spencerf88808a2004-10-30 09:19:36 +0000358Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
359LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
Reid Spencer2bba41c2004-12-22 05:57:21 +0000360BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
361 $(C.Flags) -c
Reid Spencerf88808a2004-10-30 09:19:36 +0000362Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
363LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
Reid Spencerc005fba2004-12-24 14:47:34 +0000364BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
365 $(CXX.Flags) -c
Reid Spencerf88808a2004-10-30 09:19:36 +0000366Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
367 $(CompileCommonOpts) $(LD.Flags) $(Strip)
368Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000369 $(CompileCommonOpts)
Reid Spencerfe0a01e2005-02-16 16:13:02 +0000370LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
371 $(Install.Flags)
Reid Spencer247a10e2005-02-24 07:12:43 +0000372ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
373DataInstall = $(INSTALL) -m 0644
Reid Spencerba6a3db2005-01-16 02:20:54 +0000374Burg = $(BURG) -I $(PROJ_SRC_DIR)
375TableGen = $(TBLGEN) -I $(PROJ_SRC_DIR)
Reid Spencerf88808a2004-10-30 09:19:36 +0000376Archive = $(AR) $(AR.Flags)
Reid Spencer32f7e422004-12-02 09:28:21 +0000377LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencerf206bd72004-10-22 21:01:56 +0000378ifdef RANLIB
Reid Spencer81cd0492004-10-23 20:04:14 +0000379Ranlib = $(RANLIB)
Reid Spencerf206bd72004-10-22 21:01:56 +0000380else
Reid Spencer81cd0492004-10-23 20:04:14 +0000381Ranlib = ranlib
John Criswell3ef61af2003-06-30 21:59:07 +0000382endif
383
Chris Lattner2f7c9632001-06-06 20:29:01 +0000384#----------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +0000385# Get the list of source files and compute object file
386# names from them.
Reid Spencer81cd0492004-10-23 20:04:14 +0000387#----------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +0000388ifdef FAKE_SOURCES
389 Sources :=
390 FakeSources := $(FAKE_SOURCES)
391 ifdef BUILT_SOURCES
392 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
393 endif
394 BaseNameSources := $(sort $(basename $(FakeSources)))
395 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
396 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
397 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
Reid Spencerf88808a2004-10-30 09:19:36 +0000398else
Reid Spencer81546582004-12-04 22:34:09 +0000399 ifndef SOURCES
Reid Spencerba6a3db2005-01-16 02:20:54 +0000400 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
401 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
402 $(PROJ_SRC_DIR)/*.l))
Reid Spencer81546582004-12-04 22:34:09 +0000403 else
404 Sources := $(SOURCES)
405 endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000406
Reid Spencer81546582004-12-04 22:34:09 +0000407 ifdef BUILT_SOURCES
408 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
409 endif
Vikram S. Advefe346892001-07-15 13:16:47 +0000410
Reid Spencer81546582004-12-04 22:34:09 +0000411 BaseNameSources := $(sort $(basename $(Sources)))
412 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
413 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
414 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
415endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000416
417###############################################################################
418# DIRECTORIES: Handle recursive descent of directory structure
419###############################################################################
John Criswell3601f372003-07-31 20:58:51 +0000420
Chris Lattner2f7c9632001-06-06 20:29:01 +0000421#---------------------------------------------------------
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000422# Provide rules to make install dirs. This must be early
423# in the file so they get built before dependencies
424#---------------------------------------------------------
425
Reid Spencer90b689d2005-05-19 20:26:14 +0000426$(PROJ_bindir): $(PROJ_bindir)/.dir
427$(PROJ_libdir): $(PROJ_libdir)/.dir
428$(PROJ_includedir): $(PROJ_includedir)/.dir
429$(PROJ_etcdir): $(PROJ_etcdir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000430
Reid Spencerf88808a2004-10-30 09:19:36 +0000431# To create other directories, as needed, and timestamp their creation
432%/.dir:
433 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfc66af42004-11-29 05:00:33 +0000434 $(Verb) $(DATE) > $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000435
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000436.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
437.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencer9c7bfc92004-10-28 09:15:28 +0000438
439#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000440# Handle the DIRS options for sequential construction
Chris Lattner2f7c9632001-06-06 20:29:01 +0000441#---------------------------------------------------------
442
Reid Spencerf88808a2004-10-30 09:19:36 +0000443SubDirs :=
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000444ifdef DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000445SubDirs += $(DIRS)
446$(RecursiveTargets)::
447 $(Verb) for dir in $(DIRS); do \
Reid Spencerf206bd72004-10-22 21:01:56 +0000448 if [ ! -f $$dir/Makefile ]; then \
449 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000450 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000451 fi; \
Reid Spencer4e197482004-12-08 22:58:34 +0000452 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
453 ($(MAKE) -C $$dir $@ ) || exit 1; \
454 fi ; \
Chris Lattner539a23c2002-09-17 23:35:02 +0000455 done
Anand Shukla8c2a0ee2002-09-18 04:29:30 +0000456endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000457
Reid Spencer81cd0492004-10-23 20:04:14 +0000458#---------------------------------------------------------
459# Handle the EXPERIMENTAL_DIRS options ensuring success
460# after each directory is built.
461#---------------------------------------------------------
462ifdef EXPERIMENTAL_DIRS
Reid Spencerf88808a2004-10-30 09:19:36 +0000463$(RecursiveTargets)::
464 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer81cd0492004-10-23 20:04:14 +0000465 if [ ! -f $$dir/Makefile ]; then \
466 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000467 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000468 fi; \
Reid Spencer4e197482004-12-08 22:58:34 +0000469 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
470 ($(MAKE) -C $$dir $@ ) || exit 0; \
471 fi ; \
Reid Spencer81cd0492004-10-23 20:04:14 +0000472 done
473endif
Chris Lattnerf3dd5f52002-09-18 03:22:27 +0000474
Reid Spencer81cd0492004-10-23 20:04:14 +0000475#---------------------------------------------------------
476# Handle the PARALLEL_DIRS options for parallel construction
477#---------------------------------------------------------
478ifdef PARALLEL_DIRS
479
Reid Spencerf88808a2004-10-30 09:19:36 +0000480SubDirs += $(PARALLEL_DIRS)
481
Reid Spencerd4bd3752004-12-03 20:08:48 +0000482# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencerf88808a2004-10-30 09:19:36 +0000483all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
484clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000485clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencerf88808a2004-10-30 09:19:36 +0000486install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000487uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencerd4bd3752004-12-03 20:08:48 +0000488install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer81cd0492004-10-23 20:04:14 +0000489
Reid Spencer81546582004-12-04 22:34:09 +0000490ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer81cd0492004-10-23 20:04:14 +0000491
Reid Spencer81546582004-12-04 22:34:09 +0000492$(ParallelTargets) :
Reid Spencerf88808a2004-10-30 09:19:36 +0000493 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencerf206bd72004-10-22 21:01:56 +0000494 $(MKDIR) $(@D); \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000495 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswell6df35dd2003-11-25 19:32:22 +0000496 fi; \
Reid Spencer4e197482004-12-08 22:58:34 +0000497 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
498 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
499 fi
Chris Lattner2f7c9632001-06-06 20:29:01 +0000500endif
501
Reid Spencer81cd0492004-10-23 20:04:14 +0000502#---------------------------------------------------------
503# Handle the OPTIONAL_DIRS options for directores that may
504# or may not exist.
505#---------------------------------------------------------
John Criswell8224df92003-06-27 16:58:44 +0000506ifdef OPTIONAL_DIRS
Reid Spencer100080c2004-10-25 08:27:37 +0000507
Reid Spencerf88808a2004-10-30 09:19:36 +0000508SubDirs += $(OPTIONAL_DIRS)
Reid Spencer100080c2004-10-25 08:27:37 +0000509
Reid Spencerf88808a2004-10-30 09:19:36 +0000510$(RecursiveTargets)::
511 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000512 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
Reid Spencerf206bd72004-10-22 21:01:56 +0000513 if [ ! -f $$dir/Makefile ]; then \
514 $(MKDIR) $$dir; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000515 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000516 fi; \
Reid Spencer4e197482004-12-08 22:58:34 +0000517 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
518 ($(MAKE) -C$$dir $@ ) || exit 1; \
519 fi ; \
Reid Spencerf206bd72004-10-22 21:01:56 +0000520 fi \
John Criswell8224df92003-06-27 16:58:44 +0000521 done
522endif
523
Reid Spencercc51e7b2004-08-20 09:20:05 +0000524#---------------------------------------------------------
525# Handle the CONFIG_FILES options
526#---------------------------------------------------------
527ifdef CONFIG_FILES
Reid Spencercc51e7b2004-08-20 09:20:05 +0000528
Reid Spencerba6a3db2005-01-16 02:20:54 +0000529install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
530 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000531 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000532 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
Reid Spencerc43b1d42005-02-24 03:56:32 +0000533 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000534 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
Reid Spencerc43b1d42005-02-24 03:56:32 +0000535 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer39d6a612004-11-23 05:59:53 +0000536 else \
537 $(ECHO) Error: cannot find config file $${file}. ; \
538 fi \
Reid Spencercc51e7b2004-08-20 09:20:05 +0000539 done
Reid Spencer81cd0492004-10-23 20:04:14 +0000540
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000541uninstall-local::
Reid Spencerba6a3db2005-01-16 02:20:54 +0000542 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000543 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencerba6a3db2005-01-16 02:20:54 +0000544 $(RM) -f $(PROJ_etcdir)/$${file} ; \
Reid Spencer12a3a052004-10-24 07:53:21 +0000545 done
546
Reid Spencercc51e7b2004-08-20 09:20:05 +0000547endif
548
Reid Spencer81cd0492004-10-23 20:04:14 +0000549###############################################################################
Reid Spencera80f1672005-05-19 00:37:31 +0000550# Set up variables for building libararies
551###############################################################################
552
553#---------------------------------------------------------
554# Handle the special "JIT" value for LLVM_LIBS which is a
555# shorthand for a bunch of libraries that get the correct
556# JIT support for a library or a tool that runs JIT.
557#---------------------------------------------------------
558ifeq ($(LLVMLIBS),JIT)
559
560# Make sure we can get our own symbols in the tool
561Link += -dlopen self
562
563# Generic JIT libraries
564JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
565
566# You can enable the X86 JIT on a non-X86 host by setting the flag
567# ENABLE_X86_JIT on the make command line. If not, it will still be
568# enabled automagically on an X86 host.
569ifeq ($(ARCH), x86)
570 ENABLE_X86_JIT = 1
571endif
572
573# What the X86 JIT requires
574ifdef ENABLE_X86_JIT
575 JIT_LIBS += LLVMX86 LLVMSelectionDAG
576endif
577
578# You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
579# ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
580# enabled automagically on an SparcV9 host.
581ifeq ($(ARCH), Sparc)
582 ENABLE_SPARCV9_JIT = 1
583endif
584
585# What the Sparc JIT requires
586ifdef ENABLE_SPARCV9_JIT
587 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
588 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
589 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
590 LLVMDataStructure.a LLVMSparcV9RegAlloc
591endif
592
593# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
594# ENABLE_PPC_JIT on the make command line. If not, it will still be
595# enabled automagically on an PowerPC host.
596ifeq ($(ARCH), PowerPC)
597 ENABLE_PPC_JIT = 1
598endif
599
600# What the PowerPC JIT requires
601ifdef ENABLE_PPC_JIT
602 JIT_LIBS += LLVMPowerPC LLVMSelectionDAG
603endif
604
Andrew Lenharthc7fe0f52005-07-22 20:54:01 +0000605# You can enable the Alpha JIT on a non-Alpha host by setting the flag
606# ENABLE_ALPHA_JIT on the make command line. If not, it will still be
607# enabled automagically on an PowerPC host.
608ifeq ($(ARCH), Alpha)
609 ENABLE_ALPHA_JIT = 1
610endif
611
612# What the PowerPC JIT requires
613ifdef ENABLE_ALPHA_JIT
614 JIT_LIBS += LLVMAlpha LLVMSelectionDAG
615endif
616
Reid Spencera80f1672005-05-19 00:37:31 +0000617LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
618 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
619 LLVMSystem.a $(PLATFORMLIBDL)
620endif
621
622#---------------------------------------------------------
623# Define various command line options pertaining to the
624# libraries needed when linking. There are "Proj" libs
625# (defined by the user's project) and "LLVM" libs (defined
626# by the # LLVM project).
627#---------------------------------------------------------
628ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
629ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
630LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
631LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
632ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
633LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
634ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
635LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
636
637###############################################################################
Reid Spencer81cd0492004-10-23 20:04:14 +0000638# Library Build Rules: Four ways to build a library
639###############################################################################
Chris Lattner2f7c9632001-06-06 20:29:01 +0000640
Reid Spencerd78077d2004-12-05 05:17:22 +0000641#---------------------------------------------------------
642# Bytecode Module Targets:
643# If the user set MODULE_NAME then they want to build a
644# bytecode module from the sources. We compile all the
645# sources and link it together into a single bytecode
646# module.
647#---------------------------------------------------------
648
649ifdef MODULE_NAME
Reid Spencere9fa5442005-02-14 21:54:08 +0000650ifeq ($(strip $(LLVMGCC)),)
Reid Spencer83745dd2005-05-13 18:32:54 +0000651$(warning Modules require llvm-gcc but no llvm-gcc is available ****)
Reid Spencere9fa5442005-02-14 21:54:08 +0000652else
Reid Spencerd78077d2004-12-05 05:17:22 +0000653
654Module := $(LibDir)/$(MODULE_NAME).bc
Reid Spencer2bba41c2004-12-22 05:57:21 +0000655LinkModule := $(LLVMGCCWITHPATH) -shared -nostdlib
Reid Spencerd78077d2004-12-05 05:17:22 +0000656
657ifdef EXPORTED_SYMBOL_FILE
Reid Spencer3a468752005-01-28 19:52:32 +0000658LinkModule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencerd78077d2004-12-05 05:17:22 +0000659endif
660
661$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
Reid Spencer83745dd2005-05-13 18:32:54 +0000662 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
Reid Spencerd78077d2004-12-05 05:17:22 +0000663 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
664
665all-local:: $(Module)
666
667clean-local::
668ifneq ($(strip $(Module)),)
669 -$(Verb) $(RM) -f $(Module)
670endif
671
Reid Spencerefe3a822004-12-13 07:38:07 +0000672ifdef BYTECODE_DESTINATION
673ModuleDestDir := $(BYTECODE_DESTINATION)
674else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000675ModuleDestDir := $(PROJ_libdir)
Reid Spencerefe3a822004-12-13 07:38:07 +0000676endif
Reid Spencerd78077d2004-12-05 05:17:22 +0000677
Reid Spencerefe3a822004-12-13 07:38:07 +0000678DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
679
680install-module:: $(DestModule)
Reid Spencerd78077d2004-12-05 05:17:22 +0000681install-local:: $(DestModule)
682
Reid Spencerefe3a822004-12-13 07:38:07 +0000683$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencerd78077d2004-12-05 05:17:22 +0000684 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
Reid Spencerd77a4c02005-02-24 21:30:37 +0000685 $(Verb) $(DataInstall) $(Module) $(DestModule)
Reid Spencerd78077d2004-12-05 05:17:22 +0000686
687uninstall-local::
688 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
689 -$(Verb) $(RM) -f $(DestModule)
690
691endif
Reid Spencere9fa5442005-02-14 21:54:08 +0000692endif
Brian Gaekeecc92bf2004-01-22 22:53:48 +0000693
Reid Spencer81cd0492004-10-23 20:04:14 +0000694# if we're building a library ...
Chris Lattner2f7c9632001-06-06 20:29:01 +0000695ifdef LIBRARYNAME
Vikram S. Advefe346892001-07-15 13:16:47 +0000696
Chris Lattner0100eab2002-09-16 22:36:42 +0000697# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000698LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencer87e645c2005-01-11 04:31:07 +0000699ifdef LOADABLE_MODULE
700LibName.LA := $(LibDir)/$(LIBRARYNAME).la
701else
Reid Spencerf88808a2004-10-30 09:19:36 +0000702LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
Reid Spencer87e645c2005-01-11 04:31:07 +0000703endif
Reid Spencerf88808a2004-10-30 09:19:36 +0000704LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
705LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer32f7e422004-12-02 09:28:21 +0000706LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnere6e193ca2002-09-16 22:34:56 +0000707
Reid Spencer81cd0492004-10-23 20:04:14 +0000708#---------------------------------------------------------
709# Shared Library Targets:
710# If the user asked for a shared library to be built
711# with the SHARED_LIBRARY variable, then we provide
712# targets for building them.
713#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000714ifdef SHARED_LIBRARY
715
Reid Spencerf88808a2004-10-30 09:19:36 +0000716all-local:: $(LibName.LA)
Reid Spencerf206bd72004-10-22 21:01:56 +0000717
Reid Spencera80f1672005-05-19 00:37:31 +0000718ifdef LINK_LIBS_IN_SHARED
719$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
720 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
721 $(Verb) $(Link) -o $@ $(ObjectsLO) \
722 $(ProjLibsOptions) $(LLVMLibsOptions)
723 $(Verb) $(LTInstall) $@ $(LibDir)
724else
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000725$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000726 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf88808a2004-10-30 09:19:36 +0000727 $(Verb) $(Link) -o $@ $(ObjectsLO)
728 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencera80f1672005-05-19 00:37:31 +0000729endif
Reid Spencer81cd0492004-10-23 20:04:14 +0000730
731clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000732ifneq ($(strip $(LibName.LA)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000733 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000734endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000735
Reid Spencerba6a3db2005-01-16 02:20:54 +0000736DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencerf206bd72004-10-22 21:01:56 +0000737
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000738install-local:: $(DestSharedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000739
Reid Spencerba6a3db2005-01-16 02:20:54 +0000740$(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000741 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000742 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000743 $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
Reid Spencer12a3a052004-10-24 07:53:21 +0000744
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000745uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000746 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000747 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
Reid Spencer12a3a052004-10-24 07:53:21 +0000748
Reid Spencerf206bd72004-10-22 21:01:56 +0000749endif
750
Reid Spencer81cd0492004-10-23 20:04:14 +0000751#---------------------------------------------------------
752# Bytecode Library Targets:
753# If the user asked for a bytecode library to be built
754# with the BYTECODE_LIBRARY variable, then we provide
755# targets for building them.
756#---------------------------------------------------------
Reid Spencerf206bd72004-10-22 21:01:56 +0000757ifdef BYTECODE_LIBRARY
Reid Spencere9fa5442005-02-14 21:54:08 +0000758ifeq ($(strip $(LLVMGCC)),)
Reid Spencer83745dd2005-05-13 18:32:54 +0000759$(warning Bytecode libraries require llvm-gcc which could not be found ****)
Reid Spencere9fa5442005-02-14 21:54:08 +0000760else
Reid Spencerf206bd72004-10-22 21:01:56 +0000761
Reid Spencer2b1b83a2004-12-03 06:04:35 +0000762# make the C and C++ compilers strip debug info out of bytecode libraries.
763BCCompile.C += -Wa,-strip-debug
764BCCompile.CXX += -Wa,-strip-debug
765
Reid Spencer32f7e422004-12-02 09:28:21 +0000766all-local:: $(LibName.BCA)
767
768ifdef EXPORTED_SYMBOL_FILE
Reid Spencer2bba41c2004-12-22 05:57:21 +0000769BCLinkLib = $(LLVMGCCWITHPATH) -shared -nostdlib -Xlinker \
Reid Spencer32f7e422004-12-02 09:28:21 +0000770 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
771
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000772$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +0000773 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +0000774 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
775 "(internalize)"
Chris Lattnere3d98f12004-12-02 21:23:43 +0000776 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencer85d55ad2004-12-13 03:59:35 +0000777 $(Verb) $(RM) -f $@
Reid Spencer32f7e422004-12-02 09:28:21 +0000778 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencerf206bd72004-10-22 21:01:56 +0000779else
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000780$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
Chris Lattnerc0bd4b12004-12-15 17:14:06 +0000781 $(LLVMToolDir)/llvm-ar
Reid Spencer32f7e422004-12-02 09:28:21 +0000782 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencer85d55ad2004-12-13 03:59:35 +0000783 $(Verb) $(RM) -f $@
Reid Spencer32f7e422004-12-02 09:28:21 +0000784 $(Verb) $(LArchive) $@ $(ObjectsBC)
785
Reid Spencerf206bd72004-10-22 21:01:56 +0000786endif
787
Reid Spencer81cd0492004-10-23 20:04:14 +0000788clean-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000789ifneq ($(strip $(LibName.BCA)),)
790 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencer12a3a052004-10-24 07:53:21 +0000791endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000792
Reid Spencer65086be2004-12-13 07:28:21 +0000793ifdef BYTECODE_DESTINATION
794BytecodeDestDir := $(BYTECODE_DESTINATION)
795else
Reid Spencerba6a3db2005-01-16 02:20:54 +0000796BytecodeDestDir := $(PROJ_libdir)
Reid Spencer65086be2004-12-13 07:28:21 +0000797endif
798
799DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
Reid Spencer32f7e422004-12-02 09:28:21 +0000800
Reid Spencerd4bd3752004-12-03 20:08:48 +0000801install-bytecode-local:: $(DestBytecodeLib)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000802
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000803install-local:: $(DestBytecodeLib)
Chris Lattner0c4f4fe2003-08-15 02:18:35 +0000804
Reid Spencer65086be2004-12-13 07:28:21 +0000805$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
Reid Spencer32f7e422004-12-02 09:28:21 +0000806 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerdcc53752005-02-24 21:36:32 +0000807 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000808
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000809uninstall-local::
Reid Spencer32f7e422004-12-02 09:28:21 +0000810 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000811 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000812
813endif
Reid Spencere9fa5442005-02-14 21:54:08 +0000814endif
Vikram S. Adve15bd3ad2002-08-02 18:34:12 +0000815
Reid Spencerf88808a2004-10-30 09:19:36 +0000816#---------------------------------------------------------
817# ReLinked Library Targets:
818# If the user didn't explicitly forbid building a
819# relinked then we provide targets for building them.
820#---------------------------------------------------------
Chris Lattner76d98ba2002-07-23 17:56:16 +0000821ifndef DONT_BUILD_RELINKED
Reid Spencerf206bd72004-10-22 21:01:56 +0000822
Reid Spencerf88808a2004-10-30 09:19:36 +0000823all-local:: $(LibName.O)
824
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000825$(LibName.O): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000826 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencerf88808a2004-10-30 09:19:36 +0000827 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencerf206bd72004-10-22 21:01:56 +0000828
Reid Spencer81cd0492004-10-23 20:04:14 +0000829clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000830ifneq ($(strip $(LibName.O)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000831 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencer12a3a052004-10-24 07:53:21 +0000832endif
833
Reid Spencerba6a3db2005-01-16 02:20:54 +0000834DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
Reid Spencer12a3a052004-10-24 07:53:21 +0000835
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000836install-local:: $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000837
Reid Spencerba6a3db2005-01-16 02:20:54 +0000838$(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000839 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerf88808a2004-10-30 09:19:36 +0000840 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000841
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000842uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000843 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000844 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencerf206bd72004-10-22 21:01:56 +0000845
Chris Lattner76d98ba2002-07-23 17:56:16 +0000846endif
Chris Lattnerc2bd7cf2003-03-14 20:25:22 +0000847
Reid Spencerf88808a2004-10-30 09:19:36 +0000848#---------------------------------------------------------
849# Archive Library Targets:
850# If the user wanted a regular archive library built,
851# then we provide targets for building them.
852#---------------------------------------------------------
Chris Lattner76d98ba2002-07-23 17:56:16 +0000853ifdef BUILD_ARCHIVE
Chris Lattner76d98ba2002-07-23 17:56:16 +0000854
Reid Spencerf88808a2004-10-30 09:19:36 +0000855all-local:: $(LibName.A)
856
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000857$(LibName.A): $(ObjectsO) $(LibDir)/.dir
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000858 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000859 -$(Verb) $(RM) -f $@
Reid Spencerf88808a2004-10-30 09:19:36 +0000860 $(Verb) $(Archive) $@ $(ObjectsO)
861 $(Verb) $(Ranlib) $@
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000862
Reid Spencer81cd0492004-10-23 20:04:14 +0000863clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000864ifneq ($(strip $(LibName.A)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000865 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000866endif
867
Reid Spencerba6a3db2005-01-16 02:20:54 +0000868DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
Reid Spencer12a3a052004-10-24 07:53:21 +0000869
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000870install-local:: $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000871
Reid Spencerba6a3db2005-01-16 02:20:54 +0000872$(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000873 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerba6a3db2005-01-16 02:20:54 +0000874 $(Verb) $(MKDIR) $(PROJ_libdir)
Reid Spencerf88808a2004-10-30 09:19:36 +0000875 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000876
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000877uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000878 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000879 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencer12a3a052004-10-24 07:53:21 +0000880
881endif
882
883# endif LIBRARYNAME
Reid Spencerf206bd72004-10-22 21:01:56 +0000884endif
885
Reid Spencerdcba7782004-10-24 08:21:04 +0000886###############################################################################
887# Tool Build Rules: Build executable tool based on TOOLNAME option
888###############################################################################
889
Chris Lattner07c7c192001-09-07 22:57:58 +0000890ifdef TOOLNAME
891
Reid Spencerf88808a2004-10-30 09:19:36 +0000892#---------------------------------------------------------
893# Set up variables for building a tool.
894#---------------------------------------------------------
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000895ifdef EXAMPLE_TOOL
Reid Spencer98a2d982005-05-19 21:03:11 +0000896ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000897else
Reid Spencer98a2d982005-05-19 21:03:11 +0000898ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000899endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000900
Reid Spencerf88808a2004-10-30 09:19:36 +0000901#---------------------------------------------------------
Reid Spencerf88808a2004-10-30 09:19:36 +0000902# Tell make that we need to rebuild subdirectories before
903# we can link the tool. This affects things like LLI which
904# has library subdirectories.
905#---------------------------------------------------------
906$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner3ecb7762003-01-22 16:13:31 +0000907
Reid Spencerf88808a2004-10-30 09:19:36 +0000908#---------------------------------------------------------
909# Provide targets for building the tools
910#---------------------------------------------------------
911all-local:: $(ToolBuildPath)
John Criswell8224df92003-06-27 16:58:44 +0000912
Reid Spencer81cd0492004-10-23 20:04:14 +0000913clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +0000914ifneq ($(strip $(ToolBuildPath)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000915 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencer12a3a052004-10-24 07:53:21 +0000916endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000917
Reid Spencer7e9e0b02004-11-18 10:03:46 +0000918ifdef EXAMPLE_TOOL
919$(ToolBuildPath): $(ExmplDir)/.dir
920else
921$(ToolBuildPath): $(ToolDir)/.dir
922endif
923
Reid Spenceraeea3cf2004-12-16 07:36:08 +0000924$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000925 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencerf88808a2004-10-30 09:19:36 +0000926 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
Reid Spencere9fa5442005-02-14 21:54:08 +0000927 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000928 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencer12a3a052004-10-24 07:53:21 +0000929
Reid Spencerba6a3db2005-01-16 02:20:54 +0000930DestTool = $(PROJ_bindir)/$(TOOLNAME)
Reid Spencer12a3a052004-10-24 07:53:21 +0000931
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000932install-local:: $(DestTool)
Reid Spencer8da1b5d2004-10-26 07:09:33 +0000933
Reid Spencerba6a3db2005-01-16 02:20:54 +0000934$(DestTool): $(PROJ_bindir) $(ToolBuildPath)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000935 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencerc43b1d42005-02-24 03:56:32 +0000936 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000937
Reid Spencerbe6a4e92004-10-28 07:57:28 +0000938uninstall-local::
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000939 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencer651dd3ad2004-11-02 16:56:15 +0000940 -$(Verb) $(RM) -f $(DestTool)
Reid Spencer12a3a052004-10-24 07:53:21 +0000941
Reid Spencerf206bd72004-10-22 21:01:56 +0000942endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000943
Reid Spencerf88808a2004-10-30 09:19:36 +0000944###############################################################################
945# Object Build Rules: Build object files based on sources
946###############################################################################
947
948# Provide rule sets for when dependency generation is enabled
Reid Spencerf206bd72004-10-22 21:01:56 +0000949ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve20aa62f2002-09-20 14:03:13 +0000950
Reid Spencerf88808a2004-10-30 09:19:36 +0000951#---------------------------------------------------------
952# Create .lo files in the ObjDir directory from the .cpp and .c files...
953#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000954ifdef SHARED_LIBRARY
955
Chris Lattner2a023902004-12-16 17:28:50 +0000956$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000957 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencerf88808a2004-10-30 09:19:36 +0000958 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
959 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
960 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000961
Chris Lattnerf60c1702005-02-04 21:28:50 +0000962$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
963 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
964 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
965 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
966 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
967
Chris Lattner2a023902004-12-16 17:28:50 +0000968$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000969 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencerf88808a2004-10-30 09:19:36 +0000970 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
971 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
972 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000973
Reid Spencerf88808a2004-10-30 09:19:36 +0000974#---------------------------------------------------------
975# Create .o files in the ObjDir directory from the .cpp and .c files...
976#---------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +0000977else
Reid Spencerf206bd72004-10-22 21:01:56 +0000978
Chris Lattner2a023902004-12-16 17:28:50 +0000979$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000980 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +0000981 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
982 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
983 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +0000984
Chris Lattnerf60c1702005-02-04 21:28:50 +0000985$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
986 $(Echo) "Compiling $*.cc for $(BuildMode) build"
987 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
988 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
989 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
990
Chris Lattner2a023902004-12-16 17:28:50 +0000991$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +0000992 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +0000993 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
994 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
995 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer81cd0492004-10-23 20:04:14 +0000996
997endif
Reid Spencerf206bd72004-10-22 21:01:56 +0000998
Reid Spencerf88808a2004-10-30 09:19:36 +0000999#---------------------------------------------------------
Chris Lattnerf60c1702005-02-04 21:28:50 +00001000# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
Reid Spencerf88808a2004-10-30 09:19:36 +00001001#---------------------------------------------------------
Chris Lattner2a023902004-12-16 17:28:50 +00001002$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001003 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencerf88808a2004-10-30 09:19:36 +00001004 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
1005 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1006 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +00001007
Chris Lattnerf60c1702005-02-04 21:28:50 +00001008$(ObjDir)/%.bc: %.cc $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1009 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1010 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
1011 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1012 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1013
Chris Lattner2a023902004-12-16 17:28:50 +00001014$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001015 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencerf88808a2004-10-30 09:19:36 +00001016 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
1017 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1018 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencerf206bd72004-10-22 21:01:56 +00001019
Reid Spencerf88808a2004-10-30 09:19:36 +00001020# Provide alternate rule sets if dependencies are disabled
Reid Spencerf206bd72004-10-22 21:01:56 +00001021else
1022
Reid Spencer81cd0492004-10-23 20:04:14 +00001023ifdef SHARED_LIBRARY
1024
Chris Lattner2a023902004-12-16 17:28:50 +00001025$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001026 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +00001027 $(LTCompile.CXX) $< -o $@
1028
Chris Lattnerf60c1702005-02-04 21:28:50 +00001029$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1030 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
1031 $(LTCompile.CXX) $< -o $@
1032
Chris Lattner2a023902004-12-16 17:28:50 +00001033$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerafdc82c2004-12-16 18:26:53 +00001034 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencer81cd0492004-10-23 20:04:14 +00001035 $(LTCompile.C) $< -o $@
1036
1037else
Reid Spencerf206bd72004-10-22 21:01:56 +00001038
Chris Lattner2a023902004-12-16 17:28:50 +00001039$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001040 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer81cd0492004-10-23 20:04:14 +00001041 $(Compile.CXX) $< -o $@
Reid Spencerf206bd72004-10-22 21:01:56 +00001042
Chris Lattnerf60c1702005-02-04 21:28:50 +00001043$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1044 $(Echo) "Compiling $*.cc for $(BuildMode) build"
1045 $(Compile.CXX) $< -o $@
1046
Chris Lattner2a023902004-12-16 17:28:50 +00001047$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerafdc82c2004-12-16 18:26:53 +00001048 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencer81cd0492004-10-23 20:04:14 +00001049 $(Compile.C) $< -o $@
1050endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001051
Chris Lattner2a023902004-12-16 17:28:50 +00001052$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001053 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencer991f66a2004-10-31 18:52:15 +00001054 $(BCCompile.CXX) $< -o $@
Reid Spencerf206bd72004-10-22 21:01:56 +00001055
Chris Lattnerf60c1702005-02-04 21:28:50 +00001056$(ObjDir)/%.bc: %.cc $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1057 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1058 $(BCCompile.CXX) $< -o $@
1059
Chris Lattner2a023902004-12-16 17:28:50 +00001060$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001061 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencer991f66a2004-10-31 18:52:15 +00001062 $(BCCompile.C) $< -o $@
Brian Gaeke0f148bc2003-12-10 00:26:28 +00001063
Chris Lattner07c7c192001-09-07 22:57:58 +00001064endif
1065
Reid Spencerf88808a2004-10-30 09:19:36 +00001066#---------------------------------------------------------
1067# Provide rule to build .bc files from .ll sources,
1068# regardless of dependencies
1069#---------------------------------------------------------
1070$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001071 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencerf88808a2004-10-30 09:19:36 +00001072 $(Verb) $(LLVMAS) $< -f -o $@
1073
1074###############################################################################
1075# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1076###############################################################################
Chris Lattner0c4f4fe2003-08-15 02:18:35 +00001077
Reid Spencerf206bd72004-10-22 21:01:56 +00001078ifdef TARGET
1079
Reid Spencerba6a3db2005-01-16 02:20:54 +00001080TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
Reid Spencerf88808a2004-10-30 09:19:36 +00001081INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Chris Lattner2a023902004-12-16 17:28:50 +00001082INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1083.PRECIOUS: $(INCTMPFiles) $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001084
Chris Lattner2a023902004-12-16 17:28:50 +00001085# All of these files depend on tblgen and the .td files.
1086$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001087
Chris Lattnerf86914d2004-12-16 17:38:56 +00001088# INCFiles rule: All of the tblgen generated files are emitted to
1089# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1090# us to only "touch" the real file if the contents of it change. IOW, if
1091# tblgen is modified, all of the .inc.tmp files are regereated, but no
1092# dependencies of the .inc files are, unless the contents of the .inc file
1093# changes.
1094$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
Reid Spencerafdc82c2004-12-16 18:26:53 +00001095 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
Chris Lattner2a023902004-12-16 17:28:50 +00001096
1097$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1098$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001099 $(Echo) "Building $(<F) register names with tblgen"
1100 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001101
Chris Lattner2a023902004-12-16 17:28:50 +00001102$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1103$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001104 $(Echo) "Building $(<F) register information header with tblgen"
1105 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001106
Chris Lattner2a023902004-12-16 17:28:50 +00001107$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1108$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001109 $(Echo) "Building $(<F) register info implementation with tblgen"
1110 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001111
Chris Lattner2a023902004-12-16 17:28:50 +00001112$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1113$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001114 $(Echo) "Building $(<F) instruction names with tblgen"
1115 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001116
Chris Lattner2a023902004-12-16 17:28:50 +00001117$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1118$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001119 $(Echo) "Building $(<F) instruction information with tblgen"
1120 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001121
Chris Lattner2a023902004-12-16 17:28:50 +00001122$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1123$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001124 $(Echo) "Building $(<F) assembly writer with tblgen"
1125 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001126
Chris Lattner22f937a2004-12-16 17:34:04 +00001127$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1128$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1129 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Reid Spencerf88808a2004-10-30 09:19:36 +00001130 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001131
Chris Lattner2a023902004-12-16 17:28:50 +00001132$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1133$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
Reid Spencerf88808a2004-10-30 09:19:36 +00001134 $(Echo) "Building $(<F) code emitter with tblgen"
1135 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencerf206bd72004-10-22 21:01:56 +00001136
Reid Spencer81cd0492004-10-23 20:04:14 +00001137clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001138 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencerf206bd72004-10-22 21:01:56 +00001139
1140endif
Chris Lattner0c4f4fe2003-08-15 02:18:35 +00001141
Reid Spencerf88808a2004-10-30 09:19:36 +00001142###############################################################################
1143# LEX AND YACC: Provide rules for generating sources with lex and yacc
1144###############################################################################
Chris Lattnerdb644dd2003-01-16 22:44:19 +00001145
Reid Spencerf88808a2004-10-30 09:19:36 +00001146#---------------------------------------------------------
1147# Provide rules for generating a .cpp source file from
1148# (f)lex input sources.
1149#---------------------------------------------------------
1150
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001151LexFiles := $(filter %.l,$(Sources))
Reid Spencerf88808a2004-10-30 09:19:36 +00001152
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001153ifneq ($(LexFiles),)
1154
1155LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
Reid Spencerf88808a2004-10-30 09:19:36 +00001156
1157.PRECIOUS: $(LexOutput)
1158
1159# Note the extra sed filtering here, used to cut down on the warnings emited
1160# by GCC. The last line is a gross hack to work around flex aparently not
1161# being able to resize the buffer on a large token input. Currently, for
1162# uninitialized string buffers in LLVM we can generate very long tokens, so
1163# this is a hack around it.
Chris Lattner92fc9b02003-08-15 20:00:47 +00001164# FIXME. (f.e. char Buffer[10000] )
Chris Lattner2f7c9632001-06-06 20:29:01 +00001165%.cpp: %.l
Reid Spencer993b95e2004-12-10 19:44:16 +00001166 $(Echo) Flexing $*.l
Reid Spencerf88808a2004-10-30 09:19:36 +00001167 $(Verb) $(FLEX) -t $< | \
Reid Spencerf206bd72004-10-22 21:01:56 +00001168 $(SED) 's/void yyunput/inline void yyunput/' | \
1169 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1170 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencerb7f710a2004-10-28 00:41:43 +00001171 > $@
Chris Lattner2f7c9632001-06-06 20:29:01 +00001172
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001173clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001174 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001175 $(Verb) $(RM) -f $(LexOutput)
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001176
Reid Spencerf88808a2004-10-30 09:19:36 +00001177endif
1178
1179#---------------------------------------------------------
1180# Provide rules for generating a .cpp and .h source files
1181# from yacc (bison) input sources.
1182#---------------------------------------------------------
1183
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001184YaccFiles := $(filter %.y,$(Sources))
1185ifneq ($(YaccFiles),)
1186YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
Reid Spencerf88808a2004-10-30 09:19:36 +00001187
1188.PRECIOUS: $(YaccOutput)
1189
1190# Cancel built-in rules for yacc
1191%.c: %.y
1192%.cpp: %.y
1193%.h: %.y
1194
Chris Lattner2f7c9632001-06-06 20:29:01 +00001195# Rule for building the bison parsers...
Chris Lattner2f7c9632001-06-06 20:29:01 +00001196%.cpp %.h : %.y
Reid Spencerf88808a2004-10-30 09:19:36 +00001197 $(Echo) "Bisoning $*.y"
1198 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1199 $(Verb) $(MV) -f $*.tab.c $*.cpp
1200 $(Verb) $(MV) -f $*.tab.h $*.h
Chris Lattner2f7c9632001-06-06 20:29:01 +00001201
Reid Spencerb5b92fb2004-11-01 07:50:27 +00001202clean-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001203 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001204 $(Verb) $(RM) -f $(YaccOutput)
Reid Spencerf88808a2004-10-30 09:19:36 +00001205endif
Chris Lattner2f7c9632001-06-06 20:29:01 +00001206
Reid Spencerf88808a2004-10-30 09:19:36 +00001207###############################################################################
1208# OTHER RULES: Other rules needed
1209###############################################################################
Reid Spencerf206bd72004-10-22 21:01:56 +00001210
Chris Lattner23d47392003-01-16 21:06:18 +00001211# To create postscript files from dot files...
John Criswell4ffb8442003-10-02 19:02:02 +00001212ifneq ($(DOT),false)
Chris Lattner23d47392003-01-16 21:06:18 +00001213%.ps: %.dot
Reid Spencerf206bd72004-10-22 21:01:56 +00001214 $(DOT) -Tps < $< > $@
John Criswell3ef61af2003-06-30 21:59:07 +00001215else
1216%.ps: %.dot
Reid Spencerf88808a2004-10-30 09:19:36 +00001217 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell3ef61af2003-06-30 21:59:07 +00001218endif
Chris Lattner23d47392003-01-16 21:06:18 +00001219
John Criswell0a6e6aa2003-09-06 14:44:17 +00001220# This rules ensures that header files that are removed still have a rule for
1221# which they can be "generated." This allows make to ignore them and
1222# reproduce the dependency lists.
John Criswella8391af2003-09-18 18:37:08 +00001223%.h:: ;
Chris Lattnerf60c1702005-02-04 21:28:50 +00001224%.hpp:: ;
John Criswell0a6e6aa2003-09-06 14:44:17 +00001225
Reid Spencerf88808a2004-10-30 09:19:36 +00001226# Define clean-local to clean the current directory. Note that this uses a
1227# very conservative approach ensuring that empty variables do not cause
1228# errors or disastrous removal.
Reid Spencer81cd0492004-10-23 20:04:14 +00001229clean-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001230ifneq ($(strip $(ObjDir)),)
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001231 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencer12a3a052004-10-24 07:53:21 +00001232endif
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001233 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke8625f682004-01-21 19:53:11 +00001234ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001235 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke8625f682004-01-21 19:53:11 +00001236endif
John Criswell3ef61af2003-06-30 21:59:07 +00001237
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001238clean-all-local::
Reid Spencer651dd3ad2004-11-02 16:56:15 +00001239 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer9d0c1e02004-11-02 16:36:03 +00001240
Reid Spencerf88808a2004-10-30 09:19:36 +00001241# Build tags database for Emacs/Xemacs:
Reid Spenceraee67e62004-11-12 02:27:36 +00001242tags:: TAGS CTAGS
1243
Reid Spencerf88808a2004-10-30 09:19:36 +00001244TAGS:
Reid Spencerba6a3db2005-01-16 02:20:54 +00001245 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1246 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1247 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1248 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spenceraee67e62004-11-12 02:27:36 +00001249 -name '*.cpp' -o -name '*.h' | \
Reid Spencerf88808a2004-10-30 09:19:36 +00001250 $(ETAGS) $(ETAGSFLAGS) -
1251
Reid Spenceraee67e62004-11-12 02:27:36 +00001252CTAGS:
Reid Spencerba6a3db2005-01-16 02:20:54 +00001253 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1254 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1255 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1256 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spenceraee67e62004-11-12 02:27:36 +00001257 \( -name '*.cpp' -o -name '*.h' \) -print | \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001258 ctags -ImtT -o $(PROJ_OBJ_ROOT)/CTAGS -L -
Reid Spenceraee67e62004-11-12 02:27:36 +00001259
1260
Reid Spencer81cd0492004-10-23 20:04:14 +00001261###############################################################################
1262# DEPENDENCIES: Include the dependency files if we should
1263###############################################################################
Chris Lattnere9d7d702003-08-22 14:10:16 +00001264ifndef DISABLE_AUTO_DEPENDENCIES
1265
Reid Spencer81cd0492004-10-23 20:04:14 +00001266# If its not one of the cleaning targets
Reid Spencerf88808a2004-10-30 09:19:36 +00001267ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencerf206bd72004-10-22 21:01:56 +00001268
Reid Spencer81cd0492004-10-23 20:04:14 +00001269# Get the list of dependency files
Reid Spencerf88808a2004-10-30 09:19:36 +00001270DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Reid Spencerba6a3db2005-01-16 02:20:54 +00001271DependFiles := $(patsubst %,$(PROJ_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
Misha Brukmanb891ffb2003-11-09 21:36:19 +00001272
Reid Spencer81cd0492004-10-23 20:04:14 +00001273-include /dev/null $(DependFiles)
1274
John Criswell48ecca62003-08-12 18:51:51 +00001275endif
Chris Lattner598222b2003-08-18 17:27:40 +00001276
Reid Spencerf88808a2004-10-30 09:19:36 +00001277endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001278
Reid Spencer100080c2004-10-25 08:27:37 +00001279###############################################################################
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001280# CHECK: Running the test suite
1281###############################################################################
1282
1283check::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001284 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1285 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001286 $(EchoCmd) Running test suite ; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001287 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001288 TESTSUITE=$(TESTSUITE) ; \
1289 else \
1290 $(EchoCmd) No Makefile in test directory ; \
1291 fi ; \
1292 else \
1293 $(EchoCmd) No test directory ; \
1294 fi
1295
1296###############################################################################
Reid Spencerf88808a2004-10-30 09:19:36 +00001297# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer100080c2004-10-25 08:27:37 +00001298###############################################################################
1299
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001300#------------------------------------------------------------------------
1301# Define distribution related variables
1302#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +00001303DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1304DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1305TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1306DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1307DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1308DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
Reid Spencer100080c2004-10-25 08:27:37 +00001309DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1310 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001311 Makefile.config.in configure autoconf
1312DistOther := $(notdir $(wildcard \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001313 $(PROJ_SRC_DIR)/*.h \
1314 $(PROJ_SRC_DIR)/*.td \
1315 $(PROJ_SRC_DIR)/*.def \
1316 $(PROJ_SRC_DIR)/*.ll \
1317 $(PROJ_SRC_DIR)/*.in))
Reid Spencerf88808a2004-10-30 09:19:36 +00001318DistSubDirs := $(SubDirs)
Reid Spencerfc66af42004-11-29 05:00:33 +00001319DistSources = $(Sources) $(EXTRA_DIST)
1320DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer100080c2004-10-25 08:27:37 +00001321
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001322#------------------------------------------------------------------------
1323# We MUST build distribution with OBJ_DIR != SRC_DIR
1324#------------------------------------------------------------------------
Reid Spencerba6a3db2005-01-16 02:20:54 +00001325ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001326dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerf88808a2004-10-30 09:19:36 +00001327 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001328
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001329else
1330
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001331#------------------------------------------------------------------------
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001332# Prevent attempt to run dist targets from anywhere but the top level
1333#------------------------------------------------------------------------
1334ifneq ($(LEVEL),.)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001335dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001336 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001337else
1338
1339#------------------------------------------------------------------------
1340# Provide the top level targets
1341#------------------------------------------------------------------------
1342
Reid Spencerf88808a2004-10-30 09:19:36 +00001343dist-gzip:: $(DistTarGZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001344
Reid Spencer81546582004-12-04 22:34:09 +00001345$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001346 $(Echo) Packing gzipped distribution tar file.
Reid Spencerba6a3db2005-01-16 02:20:54 +00001347 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
Reid Spencerfc66af42004-11-29 05:00:33 +00001348 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001349
Reid Spencerf88808a2004-10-30 09:19:36 +00001350dist-bzip2:: $(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001351
Reid Spencer81546582004-12-04 22:34:09 +00001352$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001353 $(Echo) Packing bzipped distribution tar file.
Reid Spencerba6a3db2005-01-16 02:20:54 +00001354 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
Reid Spencerfc66af42004-11-29 05:00:33 +00001355 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001356
Reid Spencerf88808a2004-10-30 09:19:36 +00001357dist-zip:: $(DistZip)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001358
Reid Spencer81546582004-12-04 22:34:09 +00001359$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencerf88808a2004-10-30 09:19:36 +00001360 $(Echo) Packing zipped distribution file.
1361 $(Verb) rm -f $(DistZip)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001362 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001363
1364dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001365 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001366
Reid Spencer3a468752005-01-28 19:52:32 +00001367DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001368
Reid Spencer81546582004-12-04 22:34:09 +00001369dist-check:: $(DistTarGZip)
Reid Spencerf88808a2004-10-30 09:19:36 +00001370 $(Echo) Checking distribution tar file.
1371 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001372 $(RM) -rf $(DistCheckDir) ; \
1373 fi
Reid Spencerf88808a2004-10-30 09:19:36 +00001374 $(Verb) $(MKDIR) $(DistCheckDir)
1375 $(Verb) cd $(DistCheckDir) && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001376 $(MKDIR) $(DistCheckDir)/build && \
1377 $(MKDIR) $(DistCheckDir)/install && \
1378 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1379 cd build && \
1380 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
Reid Spencer13f51932005-05-24 02:33:20 +00001381 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
Reid Spencer81546582004-12-04 22:34:09 +00001382 $(MAKE) all && \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001383 $(MAKE) check && \
1384 $(MAKE) install && \
1385 $(MAKE) uninstall && \
1386 $(MAKE) dist && \
1387 $(MAKE) clean && \
1388 $(MAKE) dist-clean && \
Reid Spencerf88808a2004-10-30 09:19:36 +00001389 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001390
1391dist-clean::
Reid Spencerf88808a2004-10-30 09:19:36 +00001392 $(Echo) Cleaning distribution files
Reid Spencer81546582004-12-04 22:34:09 +00001393 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1394 $(DistCheckDir)
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001395
1396endif
1397
1398#------------------------------------------------------------------------
1399# Provide the recursive distdir target for building the distribution directory
1400#------------------------------------------------------------------------
Reid Spencer81546582004-12-04 22:34:09 +00001401distdir: $(DistDir)/.makedistdir
1402$(DistDir)/.makedistdir: $(DistSources)
Reid Spencerf88808a2004-10-30 09:19:36 +00001403 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001404 if test -d "$(DistDir)" ; then \
1405 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1406 exit 1 ; \
1407 fi ; \
Reid Spencer81546582004-12-04 22:34:09 +00001408 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001409 $(RM) -rf $(DistDir); \
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001410 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer81546582004-12-04 22:34:09 +00001411 $(MAKE) all ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001412 fi
Reid Spencerfc66af42004-11-29 05:00:33 +00001413 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencerf88808a2004-10-30 09:19:36 +00001414 $(Verb) $(MKDIR) $(DistDir)
Reid Spencerba6a3db2005-01-16 02:20:54 +00001415 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1416 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
Reid Spencer100080c2004-10-25 08:27:37 +00001417 for file in $(DistFiles) ; do \
1418 case "$$file" in \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001419 $(PROJ_SRC_DIR)/*) \
Reid Spencer81546582004-12-04 22:34:09 +00001420 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1421 ;; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001422 $(PROJ_SRC_ROOT)/*) \
Reid Spencer81546582004-12-04 22:34:09 +00001423 file=`echo "$$file" | \
1424 sed "s#^$$srcrootstrip/##"` \
1425 ;; \
Reid Spencer100080c2004-10-25 08:27:37 +00001426 esac; \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001427 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1428 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1429 from_dir="$(PROJ_SRC_DIR)" ; \
Reid Spencer81546582004-12-04 22:34:09 +00001430 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001431 from_dir=. ; \
Reid Spencer81546582004-12-04 22:34:09 +00001432 fi ; \
1433 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001434 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1435 to_dir="$(DistDir)/$$dir"; \
1436 $(MKDIR) "$$to_dir" ; \
1437 else \
1438 to_dir="$(DistDir)"; \
1439 fi; \
1440 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1441 if test -n "$$mid_dir" ; then \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001442 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001443 fi ; \
1444 if test -d "$$from_dir/$$file"; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001445 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1446 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
Reid Spencer13f51932005-05-24 02:33:20 +00001447 cd $(PROJ_SRC_DIR) ; \
1448 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1449 ( cd $$to_dir ; $(TAR) xf - ) ; \
1450 cd $(PROJ_OBJ_DIR) ; \
1451 else \
1452 cd $$from_dir ; \
1453 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1454 ( cd $$to_dir ; $(TAR) xf - ) ; \
1455 cd $(PROJ_OBJ_DIR) ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001456 fi; \
Reid Spencer100080c2004-10-25 08:27:37 +00001457 elif test -f "$$from_dir/$$file" ; then \
Reid Spencerafdc82c2004-12-16 18:26:53 +00001458 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001459 elif test -L "$$from_dir/$$file" ; then \
Reid Spencerafdc82c2004-12-16 18:26:53 +00001460 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001461 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer81546582004-12-04 22:34:09 +00001462 $(EchoCmd) "===== WARNING: Distribution Source " \
1463 "$$from_dir/$$file Not Found!" ; \
Reid Spencerf88808a2004-10-30 09:19:36 +00001464 elif test "$(Verb)" != '@' ; then \
1465 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer100080c2004-10-25 08:27:37 +00001466 fi; \
1467 done
Reid Spencerf88808a2004-10-30 09:19:36 +00001468 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer100080c2004-10-25 08:27:37 +00001469 if test "$$subdir" \!= "." ; then \
Reid Spencer100080c2004-10-25 08:27:37 +00001470 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencer8da1b5d2004-10-26 07:09:33 +00001471 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer81546582004-12-04 22:34:09 +00001472 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1473 exit 1; \
Reid Spencer100080c2004-10-25 08:27:37 +00001474 fi; \
1475 done
Reid Spencer81546582004-12-04 22:34:09 +00001476 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer13f51932005-05-24 02:33:20 +00001477 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1478 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o -name .svn \) -print` ;\
Reid Spencer81546582004-12-04 22:34:09 +00001479 $(MAKE) dist-hook ; \
1480 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1481 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1482 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1483 -o ! -type d ! -perm -444 -exec \
1484 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1485 || chmod -R a+r $(DistDir) ; \
1486 fi
Reid Spencer100080c2004-10-25 08:27:37 +00001487
Reid Spencerf88808a2004-10-30 09:19:36 +00001488# This is invoked by distdir target, define it as a no-op to avoid errors if not
1489# defined by user.
Reid Spencer100080c2004-10-25 08:27:37 +00001490dist-hook::
1491
Reid Spencer23a70372004-10-22 23:06:30 +00001492endif
Reid Spencerf206bd72004-10-22 21:01:56 +00001493
1494###############################################################################
Reid Spencer12a3a052004-10-24 07:53:21 +00001495# TOP LEVEL - targets only to apply at the top level directory
1496###############################################################################
1497
1498ifeq ($(LEVEL),.)
1499
1500#------------------------------------------------------------------------
Reid Spencer8b5ebe52004-12-06 05:35:13 +00001501# Install support for the project's include files:
Reid Spencer12a3a052004-10-24 07:53:21 +00001502#------------------------------------------------------------------------
1503install-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001504 $(Echo) Installing include files
Reid Spencerba6a3db2005-01-16 02:20:54 +00001505 $(Verb) $(MKDIR) $(PROJ_includedir)
Reid Spencerc43b1d42005-02-24 03:56:32 +00001506 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001507 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer48a82f42005-02-16 15:54:03 +00001508 for hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
1509 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS ` ; do \
Reid Spencerc43b1d42005-02-24 03:56:32 +00001510 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1511 if test \! -d "$$instdir" ; then \
1512 $(EchoCmd) Making install directory $$instdir ; \
1513 $(MKDIR) $$instdir ;\
1514 fi ; \
1515 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer48a82f42005-02-16 15:54:03 +00001516 done ; \
Reid Spencer12a3a052004-10-24 07:53:21 +00001517 fi
Reid Spencerc43b1d42005-02-24 03:56:32 +00001518 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
Reid Spencer48a82f42005-02-16 15:54:03 +00001519 cd $(PROJ_OBJ_ROOT)/include && \
1520 for hdr in `find . -type f -print` ; do \
Reid Spencerc43b1d42005-02-24 03:56:32 +00001521 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer48a82f42005-02-16 15:54:03 +00001522 done ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001523 fi
Reid Spencer12a3a052004-10-24 07:53:21 +00001524
1525uninstall-local::
Reid Spencerf88808a2004-10-30 09:19:36 +00001526 $(Echo) Uninstalling include files
Reid Spencerba6a3db2005-01-16 02:20:54 +00001527 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1528 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer12a3a052004-10-24 07:53:21 +00001529 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001530 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' -o -name '*.in' ')' \
Reid Spencerba6a3db2005-01-16 02:20:54 +00001531 -print ')' | grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
Chris Lattner81bfc9e2005-02-09 02:24:00 +00001532 cd $(PROJ_SRC_ROOT)/include && \
1533 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' -print ')' \
1534 | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1535 fi
Reid Spencer12a3a052004-10-24 07:53:21 +00001536
Reid Spencer12a3a052004-10-24 07:53:21 +00001537endif
1538
Reid Spencerf206bd72004-10-22 21:01:56 +00001539#------------------------------------------------------------------------
1540# Print out the directories used for building
Reid Spencerf88808a2004-10-30 09:19:36 +00001541#------------------------------------------------------------------------
Reid Spencer81cd0492004-10-23 20:04:14 +00001542printvars::
Reid Spencerba6a3db2005-01-16 02:20:54 +00001543 $(Echo) "BuildMode : " '$(BuildMode)'
1544 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1545 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1546 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1547 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1548 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1549 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1550 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1551 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1552 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1553 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
Reid Spencerfe0a01e2005-02-16 16:13:02 +00001554 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
Reid Spencerba6a3db2005-01-16 02:20:54 +00001555 $(Echo) "UserTargets : " '$(UserTargets)'
1556 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1557 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1558 $(Echo) "ObjDir : " '$(ObjDir)'
1559 $(Echo) "LibDir : " '$(LibDir)'
1560 $(Echo) "ToolDir : " '$(ToolDir)'
1561 $(Echo) "ExmplDir : " '$(ExmplDir)'
1562 $(Echo) "Sources : " '$(Sources)'
1563 $(Echo) "TDFiles : " '$(TDFiles)'
1564 $(Echo) "INCFiles : " '$(INCFiles)'
1565 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
Reid Spencerfefb9ea2005-03-01 16:27:06 +00001566 $(Echo) "PreConditions: " '$(PreConditions)'
Reid Spencerba6a3db2005-01-16 02:20:54 +00001567 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1568 $(Echo) "Compile.C : " '$(Compile.C)'
1569 $(Echo) "Archive : " '$(Archive)'
1570 $(Echo) "YaccFiles : " '$(YaccFiles)'
1571 $(Echo) "LexFiles : " '$(LexFiles)'
1572 $(Echo) "Module : " '$(Module)'