blob: 775212a24b02ea004b765a9e2c2d3562b848d899 [file] [log] [blame]
Misha Brukman6d5ab862004-04-24 00:10:56 +00001#===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===#
2#
John Criswelld8846c12003-10-21 14:33:46 +00003# The LLVM Compiler Infrastructure
4#
5# This file was developed by the LLVM research group and is distributed under
6# the University of Illinois Open Source License. See LICENSE.TXT for details.
7#
Misha Brukman6d5ab862004-04-24 00:10:56 +00008#===------------------------------------------------------------------------===#
Chris Lattner00950542001-06-06 20:29:01 +00009#
Reid Spencer3a561f52004-10-23 20:04:14 +000010# This file is included by all of the LLVM makefiles. For details on how to use
11# it properly, please see the document MakefileGuide.html in the docs directory.
Chris Lattneraf06a082003-08-15 03:02:52 +000012#
Vikram S. Adved60aede2002-07-09 12:04:21 +000013#===-----------------------------------------------------------------------====
Chris Lattner00950542001-06-06 20:29:01 +000014
Reid Spencercc2d1e22004-10-30 09:19:36 +000015################################################################################
Reid Spencer3a561f52004-10-23 20:04:14 +000016# TARGETS: Define standard targets that can be invoked
Reid Spencercc2d1e22004-10-30 09:19:36 +000017################################################################################
John Criswell7a73b802003-06-30 21:59:07 +000018
Chris Lattner00950542001-06-06 20:29:01 +000019#--------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +000020# Define the various target sets
21#--------------------------------------------------------------------
Chris Lattner7dc02822004-12-03 21:05:57 +000022RecursiveTargets := all clean clean-all install uninstall install-bytecode
Reid Spencer9e8d54a2004-12-06 05:35:13 +000023LocalTargets := all-local clean-local clean-all-local check-local \
Reid Spencer44cb1b32004-12-03 20:08:48 +000024 install-local printvars uninstall-local \
25 install-bytecode-local
Reid Spencer9e8d54a2004-12-06 05:35:13 +000026TopLevelTargets := check dist dist-check dist-clean tags dist-gzip dist-bzip2 \
Reid Spencercc2d1e22004-10-30 09:19:36 +000027 dist-zip
28UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
29InternalTargets := preconditions distdir dist-hook
Reid Spencer3a561f52004-10-23 20:04:14 +000030
Reid Spencercc2d1e22004-10-30 09:19:36 +000031################################################################################
Reid Spencer9411c642004-10-26 22:26:33 +000032# INITIALIZATION: Basic things the makefile needs
Reid Spencercc2d1e22004-10-30 09:19:36 +000033################################################################################
34
35#--------------------------------------------------------------------
36# Set the VPATH so that we can find source files.
37#--------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +000038VPATH=$(PROJ_SRC_DIR)
Reid Spencer9411c642004-10-26 22:26:33 +000039
40#--------------------------------------------------------------------
41# Reset the list of suffixes we know how to build
42#--------------------------------------------------------------------
43.SUFFIXES:
Chris Lattnerb05a76c2005-02-04 21:28:50 +000044.SUFFIXES: .c .cpp .cc .h .hpp .y .l .lo .o .a .bc .td .ps .dot
Reid Spencercc2d1e22004-10-30 09:19:36 +000045.SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
Reid Spencer9411c642004-10-26 22:26:33 +000046
Reid Spencer3a561f52004-10-23 20:04:14 +000047#--------------------------------------------------------------------
48# Mark all of these targets as phony to avoid implicit rule search
49#--------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000050.PHONY: $(UserTargets) $(InternalTargets)
Reid Spencer3a561f52004-10-23 20:04:14 +000051
52#--------------------------------------------------------------------
Reid Spencer9411c642004-10-26 22:26:33 +000053# Make sure all the user-target rules are double colon rules and
54# they are defined first.
Reid Spencer3a561f52004-10-23 20:04:14 +000055#--------------------------------------------------------------------
56
Reid Spencercc2d1e22004-10-30 09:19:36 +000057$(UserTargets)::
Reid Spencer151f8ba2004-10-25 08:27:37 +000058
Reid Spencer9411c642004-10-26 22:26:33 +000059################################################################################
60# PRECONDITIONS: that which must be built/checked first
61################################################################################
62
Reid Spencer44cb1b32004-12-03 20:08:48 +000063SrcMakefiles := $(filter %Makefile %Makefile.tests,\
Reid Spencer11fde542005-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 Spencer9411c642004-10-26 22:26:33 +000079
Reid Spencerca739c62005-08-25 04:59:49 +000080preconditions: $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +000081
82#------------------------------------------------------------------------
83# Make sure the BUILT_SOURCES are built first
84#------------------------------------------------------------------------
Reid Spencer07a549a2004-12-16 07:15:16 +000085$(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000086
87clean-local::
88ifneq ($(strip $(BUILT_SOURCES)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +000089 -$(Verb) $(RM) -f $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000090endif
91
Reid Spencer11fde542005-01-16 02:20:54 +000092ifneq ($(PROJ_OBJ_ROOT),$(PROJ_SRC_ROOT))
Reid Spencer31f95242004-12-16 08:00:46 +000093spotless:
Reid Spencer31f95242004-12-16 08:00:46 +000094 $(Verb) if test -x config.status ; then \
Reid Spencer11fde542005-01-16 02:20:54 +000095 $(EchoCmd) Wiping out $(PROJ_OBJ_ROOT) ; \
Reid Spencer39b73632004-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 Spencer31f95242004-12-16 08:00:46 +0000100 $(RM) -rf * ; \
Reid Spencer39b73632004-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 Spencer11fde542005-01-16 02:20:54 +0000105 $(EchoCmd) Rebuilding configuration of $(PROJ_OBJ_ROOT) ; \
Reid Spencer39b73632004-12-17 07:45:03 +0000106 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
107 $(ConfigStatusScript) ; \
Reid Spencer31f95242004-12-16 08:00:46 +0000108 else \
Reid Spencer11fde542005-01-16 02:20:54 +0000109 $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \
Reid Spencer31f95242004-12-16 08:00:46 +0000110 fi
111endif
112
Reid Spencercc2d1e22004-10-30 09:19:36 +0000113$(BUILT_SOURCES) : $(ObjMakefiles)
Reid Spencer80f0ef72004-10-28 00:41:43 +0000114
Reid Spencer9411c642004-10-26 22:26:33 +0000115#------------------------------------------------------------------------
116# Make sure we're not using a stale configuration
117#------------------------------------------------------------------------
Reid Spencerc3719842004-12-16 18:26:53 +0000118reconfigure:
Reid Spencer11fde542005-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 Spencer32924e02004-12-24 03:36:31 +0000123 fi ; \
Reid Spencerc3719842004-12-16 18:26:53 +0000124 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
125 $(ConfigStatusScript)
126
Reid Spencercc2d1e22004-10-30 09:19:36 +0000127.PRECIOUS: $(ConfigStatusScript)
128$(ConfigStatusScript): $(ConfigureScript)
129 $(Echo) Reconfiguring with $<
Reid Spencer11fde542005-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 Spencer32924e02004-12-24 03:36:31 +0000133 fi ; \
Reid Spencer7d277002004-11-29 12:37:44 +0000134 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
135 $(ConfigStatusScript)
Reid Spencer9411c642004-10-26 22:26:33 +0000136
Reid Spencer6f5f8b32005-08-25 04:44:18 +0000137#------------------------------------------------------------------------
Reid Spencer9411c642004-10-26 22:26:33 +0000138# Make sure the configuration makefile is up to date
139#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +0000140ifneq ($(MakefileConfigIn),)
141$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000142 $(Echo) Regenerating $@
Reid Spencer11fde542005-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 Spencer9411c642004-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 Spencer11fde542005-01-16 02:20:54 +0000156ifneq ($(PROJ_OBJ_DIR),$(PROJ_SRC_DIR))
Reid Spencer9411c642004-10-26 22:26:33 +0000157
Reid Spencer11fde542005-01-16 02:20:54 +0000158Makefile: $(PROJ_SRC_DIR)/Makefile
Reid Spencercc2d1e22004-10-30 09:19:36 +0000159 $(Echo) "Updating Makefile"
160 $(Verb) $(MKDIR) $(@D)
Reid Spencerc3719842004-12-16 18:26:53 +0000161 $(Verb) $(CP) -f $< $@
Reid Spencer9411c642004-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 Spencer11fde542005-01-16 02:20:54 +0000166$(PROJ_OBJ_DIR)/Makefile% : $(PROJ_SRC_DIR)/Makefile%
Reid Spencer86606782004-10-26 23:10:00 +0000167 @case '$?' in \
168 *Makefile.rules) ;; \
169 *.in) ;; \
Reid Spencercc2d1e22004-10-30 09:19:36 +0000170 *) $(Echo) "Updating $(@F)" ; \
Reid Spencer86606782004-10-26 23:10:00 +0000171 $(MKDIR) $(@D) ; \
Reid Spencerc3719842004-12-16 18:26:53 +0000172 $(CP) -f $< $@ ;; \
Reid Spencer86606782004-10-26 23:10:00 +0000173 esac
174
Reid Spencer9411c642004-10-26 22:26:33 +0000175endif
176
177#------------------------------------------------------------------------
178# Set up the basic dependencies
179#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000180$(UserTargets):: $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +0000181
182all:: all-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000183clean:: clean-local
Reid Spencer3d659492004-11-02 16:36:03 +0000184clean-all:: clean-local clean-all-local
Reid Spencer9411c642004-10-26 22:26:33 +0000185install:: install-local
186uninstall:: uninstall-local
Reid Spencer9411c642004-10-26 22:26:33 +0000187install-local:: all-local
Reid Spencer44cb1b32004-12-03 20:08:48 +0000188install-bytecode:: install-bytecode-local
Reid Spencer3a561f52004-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 Lattner00950542001-06-06 20:29:01 +0000196#--------------------------------------------------------------------
197
Reid Spencer325a87e2005-01-02 17:43:20 +0000198
Chris Lattner760da062003-03-14 20:25:22 +0000199ifdef ENABLE_PROFILING
Reid Spencer9af3b292004-11-01 07:50:27 +0000200 BuildMode := Profile
Reid Spencer519799e2004-12-08 04:34:51 +0000201 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
Reid Spencercc2d1e22004-10-30 09:19:36 +0000202 C.Flags := -O3 -DNDEBUG -pg
203 LD.Flags := -O3 -DNDEBUG -pg
Chris Lattner760da062003-03-14 20:25:22 +0000204else
205 ifdef ENABLE_OPTIMIZED
Reid Spencer9af3b292004-11-01 07:50:27 +0000206 BuildMode := Release
Reid Spencer325a87e2005-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 Spencercc2d1e22004-10-30 09:19:36 +0000214 LD.Flags := -O3 -DNDEBUG
Chris Lattner760da062003-03-14 20:25:22 +0000215 else
Reid Spencer9af3b292004-11-01 07:50:27 +0000216 BuildMode := Debug
Reid Spencer519799e2004-12-08 04:34:51 +0000217 CXX.Flags := -g -D_DEBUG
Reid Spencercc2d1e22004-10-30 09:19:36 +0000218 C.Flags := -g -D_DEBUG
219 LD.Flags := -g -D_DEBUG
Reid Spencer4d71b662004-10-22 21:01:56 +0000220 KEEP_SYMBOLS := 1
Chris Lattner760da062003-03-14 20:25:22 +0000221 endif
222endif
223
Reid Spencercc2d1e22004-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 Spencer3a561f52004-10-23 20:04:14 +0000230
Andrew Lenharth39bcf5b2005-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 Spencer3a561f52004-10-23 20:04:14 +0000237#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000238# Directory locations
Reid Spencer3a561f52004-10-23 20:04:14 +0000239#--------------------------------------------------------------------
Reid Spencer11fde542005-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 Spencer815cbcf2004-11-18 10:03:46 +0000244LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer9a5acaf2004-11-18 20:04:39 +0000245LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer775bf892004-12-28 07:59:22 +0000246LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
Reid Spencer2f138e72004-12-22 05:57:21 +0000247CFERuntimeLibDir := $(LLVMGCCDIR)/lib
John Criswell7a73b802003-06-30 21:59:07 +0000248
Reid Spencer3a561f52004-10-23 20:04:14 +0000249#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000250# Full Paths To Compiled Tools and Utilities
Reid Spencer3a561f52004-10-23 20:04:14 +0000251#--------------------------------------------------------------------
Reid Spencer3ca6d8b2005-01-14 16:33:36 +0000252EchoCmd = $(ECHO) llvm[$(MAKELEVEL)]:
253Echo = @$(EchoCmd)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000254ifndef LIBTOOL
Reid Spencer4d71b662004-10-22 21:01:56 +0000255LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencercc2d1e22004-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 Lattner478b3b42004-11-29 19:47:58 +0000266ifndef GCCAS
267GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
268endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000269ifndef GCCLD
270GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
271endif
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000272ifndef LDIS
273LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
274endif
275ifndef LLI
276LLI := $(LLVMToolDir)/lli$(EXEEXT)
277endif
Alkis Evlogimenoseebaf332005-02-27 10:21:37 +0000278ifndef LLC
279LLC := $(LLVMToolDir)/llc$(EXEEXT)
280endif
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000281ifndef LOPT
Alkis Evlogimenos20d793a2004-12-13 18:08:29 +0000282LOPT := $(LLVMToolDir)/opt$(EXEEXT)
Alkis Evlogimenos7e80cd92004-12-13 17:44:14 +0000283endif
Alkis Evlogimenos270e8512005-02-02 00:40:15 +0000284ifndef LBUGPOINT
285LBUGPOINT := $(LLVMToolDir)/bugpoint$(EXEEXT)
286endif
287
John Criswellf5629d02005-01-03 17:42:57 +0000288LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC)
289LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX)
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000290
Reid Spencer3a561f52004-10-23 20:04:14 +0000291#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000292# Adjust to user's request
Reid Spencer3a561f52004-10-23 20:04:14 +0000293#--------------------------------------------------------------------
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000294
Reid Spencer492c2932005-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 Spencercc2d1e22004-10-30 09:19:36 +0000299 LD.Flags += -rpath $(LibDir)
Reid Spencer492c2932005-01-11 04:31:07 +0000300 ifdef LOADABLE_MODULE
301 LD.Flags += -module
302 endif
303else
304 LibTool.Flags += --tag=disable-shared
John Criswell82f4a5a2003-07-31 20:58:51 +0000305endif
306
Reid Spencercceed9f2004-11-08 17:32:12 +0000307ifdef TOOL_VERBOSE
308 C.Flags += -v
309 CXX.Flags += -v
310 LD.Flags += -v
Reid Spencercceed9f2004-11-08 17:32:12 +0000311 VERBOSE := 1
312endif
313
Reid Spencer3a561f52004-10-23 20:04:14 +0000314# Adjust settings for verbose mode
Chris Lattner760da062003-03-14 20:25:22 +0000315ifndef VERBOSE
Reid Spencercc2d1e22004-10-30 09:19:36 +0000316 Verb := @
317 LibTool.Flags += --silent
318 AR.Flags += >/dev/null 2>/dev/null
Reid Spencer11fde542005-01-16 02:20:54 +0000319 ConfigureScriptFLAGS += >$(PROJ_OBJ_DIR)/configure.out 2>&1
Reid Spencer151f8ba2004-10-25 08:27:37 +0000320else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000321 ConfigureScriptFLAGS :=
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000322endif
323
Vikram S. Advefeeae582002-09-18 11:55:13 +0000324# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000325ifndef KEEP_SYMBOLS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000326 Strip := $(PLATFORMSTRIPOPTS)
327 StripWarnMsg := "(without symbols)"
Reid Spencer860598a2005-02-24 07:12:43 +0000328 Install.StripFlag += -s
Vikram S. Advefeeae582002-09-18 11:55:13 +0000329endif
330
Reid Spencer3a561f52004-10-23 20:04:14 +0000331# Adjust linker flags for building an executable
Reid Spencer4d71b662004-10-22 21:01:56 +0000332ifdef TOOLNAME
Reid Spencer815cbcf2004-11-18 10:03:46 +0000333ifdef EXAMPLE_TOOL
334 LD.Flags += -rpath $(ExmplDir) -export-dynamic
335else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000336 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000337endif
Reid Spencer815cbcf2004-11-18 10:03:46 +0000338endif
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000339
Reid Spencer3a561f52004-10-23 20:04:14 +0000340#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000341# Options To Invoke Tools
Reid Spencer3a561f52004-10-23 20:04:14 +0000342#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000343
344CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
345
Duraid Madina0ad8fcf2005-05-16 06:38:09 +0000346ifeq ($(OS),HP-UX)
347 CompileCommonOpts += -D_REENTRANT -D_HPUX_SOURCE
348endif
349
Reid Spencer9a8398e2005-02-14 21:54:08 +0000350LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
Reid Spencer11fde542005-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 Spencer4d71b662004-10-22 21:01:56 +0000357
Reid Spencercc2d1e22004-10-30 09:19:36 +0000358Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
359LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
Reid Spencer2f138e72004-12-22 05:57:21 +0000360BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
361 $(C.Flags) -c
Chris Lattner0cb09f12005-10-05 00:28:41 +0000362Preprocess.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -E $(C.Flags)
363
Reid Spencercc2d1e22004-10-30 09:19:36 +0000364Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
365LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
Reid Spencerbc52ad72004-12-24 14:47:34 +0000366BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
367 $(CXX.Flags) -c
Chris Lattner0cb09f12005-10-05 00:28:41 +0000368Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
Reid Spencercc2d1e22004-10-30 09:19:36 +0000369Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
370 $(CompileCommonOpts) $(LD.Flags) $(Strip)
371Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencera69b1ea2004-10-28 09:15:28 +0000372 $(CompileCommonOpts)
Reid Spencer1a9a69c2005-02-16 16:13:02 +0000373LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) \
374 $(Install.Flags)
Reid Spencer860598a2005-02-24 07:12:43 +0000375ProgInstall = $(INSTALL) $(Install.StripFlag) -m 0755
376DataInstall = $(INSTALL) -m 0644
Reid Spencer11fde542005-01-16 02:20:54 +0000377Burg = $(BURG) -I $(PROJ_SRC_DIR)
378TableGen = $(TBLGEN) -I $(PROJ_SRC_DIR)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000379Archive = $(AR) $(AR.Flags)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000380LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencer4d71b662004-10-22 21:01:56 +0000381ifdef RANLIB
Reid Spencer3a561f52004-10-23 20:04:14 +0000382Ranlib = $(RANLIB)
Reid Spencer4d71b662004-10-22 21:01:56 +0000383else
Reid Spencer3a561f52004-10-23 20:04:14 +0000384Ranlib = ranlib
John Criswell7a73b802003-06-30 21:59:07 +0000385endif
386
Chris Lattner00950542001-06-06 20:29:01 +0000387#----------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +0000388# Get the list of source files and compute object file
389# names from them.
Reid Spencer3a561f52004-10-23 20:04:14 +0000390#----------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +0000391ifdef FAKE_SOURCES
392 Sources :=
393 FakeSources := $(FAKE_SOURCES)
394 ifdef BUILT_SOURCES
395 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
396 endif
397 BaseNameSources := $(sort $(basename $(FakeSources)))
398 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
399 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
400 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000401else
Reid Spencer345235ca2004-12-04 22:34:09 +0000402 ifndef SOURCES
Reid Spencer11fde542005-01-16 02:20:54 +0000403 Sources := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp \
404 $(PROJ_SRC_DIR)/*.cc $(PROJ_SRC_DIR)/*.c $(PROJ_SRC_DIR)/*.y \
405 $(PROJ_SRC_DIR)/*.l))
Reid Spencer345235ca2004-12-04 22:34:09 +0000406 else
407 Sources := $(SOURCES)
408 endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000409
Reid Spencer345235ca2004-12-04 22:34:09 +0000410 ifdef BUILT_SOURCES
411 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
412 endif
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000413
Reid Spencer345235ca2004-12-04 22:34:09 +0000414 BaseNameSources := $(sort $(basename $(Sources)))
415 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
416 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
417 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
418endif
Reid Spencer3a561f52004-10-23 20:04:14 +0000419
420###############################################################################
421# DIRECTORIES: Handle recursive descent of directory structure
422###############################################################################
John Criswell82f4a5a2003-07-31 20:58:51 +0000423
Chris Lattner00950542001-06-06 20:29:01 +0000424#---------------------------------------------------------
Reid Spencera69b1ea2004-10-28 09:15:28 +0000425# Provide rules to make install dirs. This must be early
426# in the file so they get built before dependencies
427#---------------------------------------------------------
428
Reid Spenceraa8bc432005-05-19 20:26:14 +0000429$(PROJ_bindir): $(PROJ_bindir)/.dir
430$(PROJ_libdir): $(PROJ_libdir)/.dir
431$(PROJ_includedir): $(PROJ_includedir)/.dir
432$(PROJ_etcdir): $(PROJ_etcdir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000433
Reid Spencercc2d1e22004-10-30 09:19:36 +0000434# To create other directories, as needed, and timestamp their creation
435%/.dir:
436 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfbbf3072004-11-29 05:00:33 +0000437 $(Verb) $(DATE) > $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000438
Reid Spencer815cbcf2004-11-18 10:03:46 +0000439.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
440.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000441
442#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000443# Handle the DIRS options for sequential construction
Chris Lattner00950542001-06-06 20:29:01 +0000444#---------------------------------------------------------
445
Reid Spencercc2d1e22004-10-30 09:19:36 +0000446SubDirs :=
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000447ifdef DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000448SubDirs += $(DIRS)
449$(RecursiveTargets)::
450 $(Verb) for dir in $(DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000451 if [ ! -f $$dir/Makefile ]; then \
452 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000453 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000454 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000455 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
456 ($(MAKE) -C $$dir $@ ) || exit 1; \
457 fi ; \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000458 done
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000459endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000460
Reid Spencer3a561f52004-10-23 20:04:14 +0000461#---------------------------------------------------------
462# Handle the EXPERIMENTAL_DIRS options ensuring success
463# after each directory is built.
464#---------------------------------------------------------
465ifdef EXPERIMENTAL_DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000466$(RecursiveTargets)::
467 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer3a561f52004-10-23 20:04:14 +0000468 if [ ! -f $$dir/Makefile ]; then \
469 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000470 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000471 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000472 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
473 ($(MAKE) -C $$dir $@ ) || exit 0; \
474 fi ; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000475 done
476endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000477
Reid Spencer3a561f52004-10-23 20:04:14 +0000478#---------------------------------------------------------
479# Handle the PARALLEL_DIRS options for parallel construction
480#---------------------------------------------------------
481ifdef PARALLEL_DIRS
482
Reid Spencercc2d1e22004-10-30 09:19:36 +0000483SubDirs += $(PARALLEL_DIRS)
484
Reid Spencer44cb1b32004-12-03 20:08:48 +0000485# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencercc2d1e22004-10-30 09:19:36 +0000486all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
487clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000488clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000489install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000490uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencer44cb1b32004-12-03 20:08:48 +0000491install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000492
Reid Spencer345235ca2004-12-04 22:34:09 +0000493ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer3a561f52004-10-23 20:04:14 +0000494
Reid Spencer345235ca2004-12-04 22:34:09 +0000495$(ParallelTargets) :
Reid Spencercc2d1e22004-10-30 09:19:36 +0000496 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencer4d71b662004-10-22 21:01:56 +0000497 $(MKDIR) $(@D); \
Reid Spencer11fde542005-01-16 02:20:54 +0000498 $(CP) $(PROJ_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswellb3866b62003-11-25 19:32:22 +0000499 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000500 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
501 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \
502 fi
Chris Lattner00950542001-06-06 20:29:01 +0000503endif
504
Reid Spencer3a561f52004-10-23 20:04:14 +0000505#---------------------------------------------------------
506# Handle the OPTIONAL_DIRS options for directores that may
507# or may not exist.
508#---------------------------------------------------------
John Criswell2a6530f2003-06-27 16:58:44 +0000509ifdef OPTIONAL_DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000510
Reid Spencercc2d1e22004-10-30 09:19:36 +0000511SubDirs += $(OPTIONAL_DIRS)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000512
Reid Spencercc2d1e22004-10-30 09:19:36 +0000513$(RecursiveTargets)::
514 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000515 if [ -d $(PROJ_SRC_DIR)/$$dir ]; then\
Reid Spencer4d71b662004-10-22 21:01:56 +0000516 if [ ! -f $$dir/Makefile ]; then \
517 $(MKDIR) $$dir; \
Reid Spencer11fde542005-01-16 02:20:54 +0000518 $(CP) $(PROJ_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000519 fi; \
Reid Spencera23c0662004-12-08 22:58:34 +0000520 if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \
521 ($(MAKE) -C$$dir $@ ) || exit 1; \
522 fi ; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000523 fi \
John Criswell2a6530f2003-06-27 16:58:44 +0000524 done
525endif
526
Reid Spencerfc945082004-08-20 09:20:05 +0000527#---------------------------------------------------------
528# Handle the CONFIG_FILES options
529#---------------------------------------------------------
530ifdef CONFIG_FILES
Reid Spencerfc945082004-08-20 09:20:05 +0000531
Reid Spencer11fde542005-01-16 02:20:54 +0000532install-local:: $(PROJ_etcdir) $(CONFIG_FILES)
533 $(Echo) Installing Configuration Files To $(PROJ_etcdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000534 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000535 if test -f $(PROJ_OBJ_DIR)/$${file} ; then \
Reid Spencer4a0aaea2005-02-24 03:56:32 +0000536 $(DataInstall) $(PROJ_OBJ_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer11fde542005-01-16 02:20:54 +0000537 elif test -f $(PROJ_SRC_DIR)/$${file} ; then \
Reid Spencer4a0aaea2005-02-24 03:56:32 +0000538 $(DataInstall) $(PROJ_SRC_DIR)/$${file} $(PROJ_etcdir) ; \
Reid Spencer1b426ab2004-11-23 05:59:53 +0000539 else \
540 $(ECHO) Error: cannot find config file $${file}. ; \
541 fi \
Reid Spencerfc945082004-08-20 09:20:05 +0000542 done
Reid Spencer3a561f52004-10-23 20:04:14 +0000543
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000544uninstall-local::
Reid Spencer11fde542005-01-16 02:20:54 +0000545 $(Echo) Uninstalling Configuration Files From $(PROJ_etcdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000546 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer11fde542005-01-16 02:20:54 +0000547 $(RM) -f $(PROJ_etcdir)/$${file} ; \
Reid Spencere5487ba2004-10-24 07:53:21 +0000548 done
549
Reid Spencerfc945082004-08-20 09:20:05 +0000550endif
551
Reid Spencer3a561f52004-10-23 20:04:14 +0000552###############################################################################
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000553# Set up variables for building libararies
554###############################################################################
555
556#---------------------------------------------------------
557# Handle the special "JIT" value for LLVM_LIBS which is a
558# shorthand for a bunch of libraries that get the correct
559# JIT support for a library or a tool that runs JIT.
560#---------------------------------------------------------
561ifeq ($(LLVMLIBS),JIT)
562
563# Make sure we can get our own symbols in the tool
564Link += -dlopen self
565
566# Generic JIT libraries
567JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
568
569# You can enable the X86 JIT on a non-X86 host by setting the flag
570# ENABLE_X86_JIT on the make command line. If not, it will still be
571# enabled automagically on an X86 host.
572ifeq ($(ARCH), x86)
573 ENABLE_X86_JIT = 1
574endif
575
576# What the X86 JIT requires
577ifdef ENABLE_X86_JIT
578 JIT_LIBS += LLVMX86 LLVMSelectionDAG
579endif
580
581# You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
582# ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
583# enabled automagically on an SparcV9 host.
584ifeq ($(ARCH), Sparc)
585 ENABLE_SPARCV9_JIT = 1
586endif
587
588# What the Sparc JIT requires
589ifdef ENABLE_SPARCV9_JIT
590 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
591 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
592 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
593 LLVMDataStructure.a LLVMSparcV9RegAlloc
594endif
595
596# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
597# ENABLE_PPC_JIT on the make command line. If not, it will still be
598# enabled automagically on an PowerPC host.
599ifeq ($(ARCH), PowerPC)
600 ENABLE_PPC_JIT = 1
601endif
602
603# What the PowerPC JIT requires
604ifdef ENABLE_PPC_JIT
605 JIT_LIBS += LLVMPowerPC LLVMSelectionDAG
606endif
607
Andrew Lenharthddc31e82005-07-22 20:54:01 +0000608# You can enable the Alpha JIT on a non-Alpha host by setting the flag
609# ENABLE_ALPHA_JIT on the make command line. If not, it will still be
Misha Brukmanab25eda2005-07-22 22:43:40 +0000610# enabled automagically on an Alpha host.
Andrew Lenharthddc31e82005-07-22 20:54:01 +0000611ifeq ($(ARCH), Alpha)
612 ENABLE_ALPHA_JIT = 1
613endif
614
Andrew Lenharth22894e92005-07-22 22:00:24 +0000615# What the Alpha JIT requires
Andrew Lenharthddc31e82005-07-22 20:54:01 +0000616ifdef ENABLE_ALPHA_JIT
617 JIT_LIBS += LLVMAlpha LLVMSelectionDAG
618endif
619
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000620LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
621 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
622 LLVMSystem.a $(PLATFORMLIBDL)
623endif
624
625#---------------------------------------------------------
626# Define various command line options pertaining to the
627# libraries needed when linking. There are "Proj" libs
628# (defined by the user's project) and "LLVM" libs (defined
629# by the # LLVM project).
630#---------------------------------------------------------
Misha Brukman6c26da62005-08-17 02:38:56 +0000631# Some versions of gcc on Alpha produce too many symbols, so use a .a file
Andrew Lenharth7ac17522005-08-13 05:09:50 +0000632ifeq ($(ARCH),Alpha)
633USEDLIBS := $(subst LLVMCore, LLVMCore.a, $(USEDLIBS))
634LLVMLIBS := $(subst LLVMCore, LLVMCore.a, $(LLVMLIBS))
635endif
636
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000637ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
638ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
639LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
640LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
641ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
642LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
643ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
644LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
645
646###############################################################################
Reid Spencer3a561f52004-10-23 20:04:14 +0000647# Library Build Rules: Four ways to build a library
648###############################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000649
Reid Spencer7980ea42004-12-05 05:17:22 +0000650#---------------------------------------------------------
651# Bytecode Module Targets:
652# If the user set MODULE_NAME then they want to build a
653# bytecode module from the sources. We compile all the
654# sources and link it together into a single bytecode
655# module.
656#---------------------------------------------------------
657
658ifdef MODULE_NAME
Reid Spencer9a8398e2005-02-14 21:54:08 +0000659ifeq ($(strip $(LLVMGCC)),)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000660$(warning Modules require llvm-gcc but no llvm-gcc is available ****)
Reid Spencer9a8398e2005-02-14 21:54:08 +0000661else
Reid Spencer7980ea42004-12-05 05:17:22 +0000662
663Module := $(LibDir)/$(MODULE_NAME).bc
Reid Spencer2f138e72004-12-22 05:57:21 +0000664LinkModule := $(LLVMGCCWITHPATH) -shared -nostdlib
Reid Spencer7980ea42004-12-05 05:17:22 +0000665
666ifdef EXPORTED_SYMBOL_FILE
Reid Spencerf8f57402005-01-28 19:52:32 +0000667LinkModule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
Reid Spencer7980ea42004-12-05 05:17:22 +0000668endif
669
670$(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000671 $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@)
Reid Spencer7980ea42004-12-05 05:17:22 +0000672 $(Verb) $(LinkModule) -o $@ $(ObjectsBC)
673
674all-local:: $(Module)
675
676clean-local::
677ifneq ($(strip $(Module)),)
678 -$(Verb) $(RM) -f $(Module)
679endif
680
Reid Spencerab3690b2004-12-13 07:38:07 +0000681ifdef BYTECODE_DESTINATION
682ModuleDestDir := $(BYTECODE_DESTINATION)
683else
Reid Spencer11fde542005-01-16 02:20:54 +0000684ModuleDestDir := $(PROJ_libdir)
Reid Spencerab3690b2004-12-13 07:38:07 +0000685endif
Reid Spencer7980ea42004-12-05 05:17:22 +0000686
Reid Spencerab3690b2004-12-13 07:38:07 +0000687DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc
688
689install-module:: $(DestModule)
Reid Spencer7980ea42004-12-05 05:17:22 +0000690install-local:: $(DestModule)
691
Reid Spencerab3690b2004-12-13 07:38:07 +0000692$(DestModule): $(ModuleDestDir) $(Module)
Reid Spencer7980ea42004-12-05 05:17:22 +0000693 $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule)
Reid Spencer151bbe42005-02-24 21:30:37 +0000694 $(Verb) $(DataInstall) $(Module) $(DestModule)
Reid Spencer7980ea42004-12-05 05:17:22 +0000695
696uninstall-local::
697 $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule)
698 -$(Verb) $(RM) -f $(DestModule)
699
700endif
Reid Spencer9a8398e2005-02-14 21:54:08 +0000701endif
Brian Gaeke8abff792004-01-22 22:53:48 +0000702
Reid Spencer3a561f52004-10-23 20:04:14 +0000703# if we're building a library ...
Chris Lattner00950542001-06-06 20:29:01 +0000704ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000705
Chris Lattner2a548c52002-09-16 22:36:42 +0000706# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000707LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencer492c2932005-01-11 04:31:07 +0000708ifdef LOADABLE_MODULE
709LibName.LA := $(LibDir)/$(LIBRARYNAME).la
710else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000711LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
Reid Spencer492c2932005-01-11 04:31:07 +0000712endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000713LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
714LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer9a2f1372004-12-02 09:28:21 +0000715LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000716
Reid Spencer3a561f52004-10-23 20:04:14 +0000717#---------------------------------------------------------
718# Shared Library Targets:
719# If the user asked for a shared library to be built
720# with the SHARED_LIBRARY variable, then we provide
721# targets for building them.
722#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000723ifdef SHARED_LIBRARY
724
Reid Spencercc2d1e22004-10-30 09:19:36 +0000725all-local:: $(LibName.LA)
Reid Spencer4d71b662004-10-22 21:01:56 +0000726
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000727ifdef LINK_LIBS_IN_SHARED
728$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
729 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
730 $(Verb) $(Link) -o $@ $(ObjectsLO) \
731 $(ProjLibsOptions) $(LLVMLibsOptions)
732 $(Verb) $(LTInstall) $@ $(LibDir)
733else
Reid Spencerf2ac1892004-12-16 07:36:08 +0000734$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000735 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000736 $(Verb) $(Link) -o $@ $(ObjectsLO)
737 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencer8f9e21e2005-05-19 00:37:31 +0000738endif
Reid Spencer3a561f52004-10-23 20:04:14 +0000739
740clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000741ifneq ($(strip $(LibName.LA)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000742 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000743endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000744
Reid Spencer11fde542005-01-16 02:20:54 +0000745DestSharedLib = $(PROJ_libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencer4d71b662004-10-22 21:01:56 +0000746
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000747install-local:: $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000748
Reid Spencer11fde542005-01-16 02:20:54 +0000749$(DestSharedLib): $(PROJ_libdir) $(LibName.LA)
Reid Spencer9af3b292004-11-01 07:50:27 +0000750 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000751 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
Reid Spencer11fde542005-01-16 02:20:54 +0000752 $(Verb) $(LIBTOOL) --finish $(PROJ_libdir)
Reid Spencere5487ba2004-10-24 07:53:21 +0000753
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000754uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000755 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencer11fde542005-01-16 02:20:54 +0000756 -$(Verb) $(RM) -f $(PROJ_libdir)/lib$(LIBRARYNAME).*
Reid Spencere5487ba2004-10-24 07:53:21 +0000757
Reid Spencer4d71b662004-10-22 21:01:56 +0000758endif
759
Reid Spencer3a561f52004-10-23 20:04:14 +0000760#---------------------------------------------------------
761# Bytecode Library Targets:
762# If the user asked for a bytecode library to be built
763# with the BYTECODE_LIBRARY variable, then we provide
764# targets for building them.
765#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000766ifdef BYTECODE_LIBRARY
Reid Spencer9a8398e2005-02-14 21:54:08 +0000767ifeq ($(strip $(LLVMGCC)),)
Reid Spencer0d255bd2005-05-13 18:32:54 +0000768$(warning Bytecode libraries require llvm-gcc which could not be found ****)
Reid Spencer9a8398e2005-02-14 21:54:08 +0000769else
Reid Spencer4d71b662004-10-22 21:01:56 +0000770
Reid Spencer776b8052004-12-03 06:04:35 +0000771# make the C and C++ compilers strip debug info out of bytecode libraries.
772BCCompile.C += -Wa,-strip-debug
773BCCompile.CXX += -Wa,-strip-debug
774
Reid Spencer9a2f1372004-12-02 09:28:21 +0000775all-local:: $(LibName.BCA)
776
777ifdef EXPORTED_SYMBOL_FILE
Reid Spencer2f138e72004-12-22 05:57:21 +0000778BCLinkLib = $(LLVMGCCWITHPATH) -shared -nostdlib -Xlinker \
Reid Spencer9a2f1372004-12-02 09:28:21 +0000779 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
780
Reid Spencerf2ac1892004-12-16 07:36:08 +0000781$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \
Chris Lattner264ccbe2004-12-15 17:14:06 +0000782 $(LLVMToolDir)/llvm-ar
Reid Spencer9a2f1372004-12-02 09:28:21 +0000783 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
784 "(internalize)"
Chris Lattnerb0ea8642004-12-02 21:23:43 +0000785 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencerefd6bb32004-12-13 03:59:35 +0000786 $(Verb) $(RM) -f $@
Reid Spencer9a2f1372004-12-02 09:28:21 +0000787 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencer4d71b662004-10-22 21:01:56 +0000788else
Reid Spencerf2ac1892004-12-16 07:36:08 +0000789$(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \
Chris Lattner264ccbe2004-12-15 17:14:06 +0000790 $(LLVMToolDir)/llvm-ar
Reid Spencer9a2f1372004-12-02 09:28:21 +0000791 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
Reid Spencerefd6bb32004-12-13 03:59:35 +0000792 $(Verb) $(RM) -f $@
Reid Spencer9a2f1372004-12-02 09:28:21 +0000793 $(Verb) $(LArchive) $@ $(ObjectsBC)
794
Reid Spencer4d71b662004-10-22 21:01:56 +0000795endif
796
Reid Spencer3a561f52004-10-23 20:04:14 +0000797clean-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000798ifneq ($(strip $(LibName.BCA)),)
799 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000800endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000801
Reid Spencer8f094f32004-12-13 07:28:21 +0000802ifdef BYTECODE_DESTINATION
803BytecodeDestDir := $(BYTECODE_DESTINATION)
804else
Reid Spencer11fde542005-01-16 02:20:54 +0000805BytecodeDestDir := $(PROJ_libdir)
Reid Spencer8f094f32004-12-13 07:28:21 +0000806endif
807
808DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
Reid Spencer9a2f1372004-12-02 09:28:21 +0000809
Reid Spencer44cb1b32004-12-03 20:08:48 +0000810install-bytecode-local:: $(DestBytecodeLib)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000811
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000812install-local:: $(DestBytecodeLib)
Chris Lattner481cc7c2003-08-15 02:18:35 +0000813
Reid Spencer8f094f32004-12-13 07:28:21 +0000814$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000815 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerb80621f2005-02-24 21:36:32 +0000816 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000817
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000818uninstall-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000819 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000820 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000821
822endif
Reid Spencer9a8398e2005-02-14 21:54:08 +0000823endif
Vikram S. Adve60f56062002-08-02 18:34:12 +0000824
Reid Spencercc2d1e22004-10-30 09:19:36 +0000825#---------------------------------------------------------
826# ReLinked Library Targets:
827# If the user didn't explicitly forbid building a
828# relinked then we provide targets for building them.
829#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000830ifndef DONT_BUILD_RELINKED
Reid Spencer4d71b662004-10-22 21:01:56 +0000831
Reid Spencercc2d1e22004-10-30 09:19:36 +0000832all-local:: $(LibName.O)
833
Reid Spencerf2ac1892004-12-16 07:36:08 +0000834$(LibName.O): $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000835 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000836 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencer4d71b662004-10-22 21:01:56 +0000837
Reid Spencer3a561f52004-10-23 20:04:14 +0000838clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000839ifneq ($(strip $(LibName.O)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000840 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencere5487ba2004-10-24 07:53:21 +0000841endif
842
Reid Spencer11fde542005-01-16 02:20:54 +0000843DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o
Reid Spencere5487ba2004-10-24 07:53:21 +0000844
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000845install-local:: $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000846
Reid Spencer11fde542005-01-16 02:20:54 +0000847$(DestRelinkedLib): $(PROJ_libdir) $(LibName.O)
Reid Spencer9af3b292004-11-01 07:50:27 +0000848 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000849 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000850
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000851uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000852 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000853 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000854
Chris Lattnere62dbe92002-07-23 17:56:16 +0000855endif
Chris Lattner760da062003-03-14 20:25:22 +0000856
Reid Spencercc2d1e22004-10-30 09:19:36 +0000857#---------------------------------------------------------
858# Archive Library Targets:
859# If the user wanted a regular archive library built,
860# then we provide targets for building them.
861#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000862ifdef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000863
Reid Spencercc2d1e22004-10-30 09:19:36 +0000864all-local:: $(LibName.A)
865
Reid Spencerf2ac1892004-12-16 07:36:08 +0000866$(LibName.A): $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000867 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000868 -$(Verb) $(RM) -f $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000869 $(Verb) $(Archive) $@ $(ObjectsO)
870 $(Verb) $(Ranlib) $@
Vikram S. Adve41e78912002-09-20 14:03:13 +0000871
Reid Spencer3a561f52004-10-23 20:04:14 +0000872clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000873ifneq ($(strip $(LibName.A)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000874 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner00950542001-06-06 20:29:01 +0000875endif
876
Reid Spencer11fde542005-01-16 02:20:54 +0000877DestArchiveLib := $(PROJ_libdir)/lib$(LIBRARYNAME).a
Reid Spencere5487ba2004-10-24 07:53:21 +0000878
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000879install-local:: $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000880
Reid Spencer11fde542005-01-16 02:20:54 +0000881$(DestArchiveLib): $(PROJ_libdir) $(LibName.A)
Reid Spencer9af3b292004-11-01 07:50:27 +0000882 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencer11fde542005-01-16 02:20:54 +0000883 $(Verb) $(MKDIR) $(PROJ_libdir)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000884 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000885
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000886uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000887 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000888 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000889
890endif
891
892# endif LIBRARYNAME
Reid Spencer4d71b662004-10-22 21:01:56 +0000893endif
894
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000895###############################################################################
896# Tool Build Rules: Build executable tool based on TOOLNAME option
897###############################################################################
898
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000899ifdef TOOLNAME
900
Reid Spencercc2d1e22004-10-30 09:19:36 +0000901#---------------------------------------------------------
902# Set up variables for building a tool.
903#---------------------------------------------------------
Reid Spencer815cbcf2004-11-18 10:03:46 +0000904ifdef EXAMPLE_TOOL
Reid Spencer5da2d082005-05-19 21:03:11 +0000905ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000906else
Reid Spencer5da2d082005-05-19 21:03:11 +0000907ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000908endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000909
Reid Spencercc2d1e22004-10-30 09:19:36 +0000910#---------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000911# Tell make that we need to rebuild subdirectories before
912# we can link the tool. This affects things like LLI which
913# has library subdirectories.
914#---------------------------------------------------------
915$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000916
Reid Spencercc2d1e22004-10-30 09:19:36 +0000917#---------------------------------------------------------
918# Provide targets for building the tools
919#---------------------------------------------------------
920all-local:: $(ToolBuildPath)
John Criswell2a6530f2003-06-27 16:58:44 +0000921
Reid Spencer3a561f52004-10-23 20:04:14 +0000922clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000923ifneq ($(strip $(ToolBuildPath)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000924 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencere5487ba2004-10-24 07:53:21 +0000925endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000926
Reid Spencer815cbcf2004-11-18 10:03:46 +0000927ifdef EXAMPLE_TOOL
928$(ToolBuildPath): $(ExmplDir)/.dir
929else
930$(ToolBuildPath): $(ToolDir)/.dir
931endif
932
Reid Spencerf2ac1892004-12-16 07:36:08 +0000933$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencer9af3b292004-11-01 07:50:27 +0000934 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000935 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
Reid Spencer9a8398e2005-02-14 21:54:08 +0000936 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000937 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencere5487ba2004-10-24 07:53:21 +0000938
Reid Spencer11fde542005-01-16 02:20:54 +0000939DestTool = $(PROJ_bindir)/$(TOOLNAME)
Reid Spencere5487ba2004-10-24 07:53:21 +0000940
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000941install-local:: $(DestTool)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000942
Reid Spencer11fde542005-01-16 02:20:54 +0000943$(DestTool): $(PROJ_bindir) $(ToolBuildPath)
Reid Spencer9af3b292004-11-01 07:50:27 +0000944 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencer4a0aaea2005-02-24 03:56:32 +0000945 $(Verb) $(ProgInstall) $(ToolBuildPath) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000946
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000947uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000948 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000949 -$(Verb) $(RM) -f $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000950
Reid Spencer4d71b662004-10-22 21:01:56 +0000951endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000952
Reid Spencercc2d1e22004-10-30 09:19:36 +0000953###############################################################################
954# Object Build Rules: Build object files based on sources
955###############################################################################
956
957# Provide rule sets for when dependency generation is enabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000958ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve41e78912002-09-20 14:03:13 +0000959
Reid Spencercc2d1e22004-10-30 09:19:36 +0000960#---------------------------------------------------------
961# Create .lo files in the ObjDir directory from the .cpp and .c files...
962#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000963ifdef SHARED_LIBRARY
964
Chris Lattner3c473472004-12-16 17:28:50 +0000965$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +0000966 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000967 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
968 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
969 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000970
Chris Lattnerb05a76c2005-02-04 21:28:50 +0000971$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
972 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
973 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
974 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
975 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
976
Chris Lattner3c473472004-12-16 17:28:50 +0000977$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +0000978 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000979 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
980 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
981 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000982
Reid Spencercc2d1e22004-10-30 09:19:36 +0000983#---------------------------------------------------------
984# Create .o files in the ObjDir directory from the .cpp and .c files...
985#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000986else
Reid Spencer4d71b662004-10-22 21:01:56 +0000987
Chris Lattner3c473472004-12-16 17:28:50 +0000988$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +0000989 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000990 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
991 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
992 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000993
Chris Lattnerb05a76c2005-02-04 21:28:50 +0000994$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
995 $(Echo) "Compiling $*.cc for $(BuildMode) build"
996 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
997 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
998 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
999
Chris Lattner3c473472004-12-16 17:28:50 +00001000$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001001 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001002 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
1003 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
1004 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +00001005
1006endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001007
Chris Lattner0cb09f12005-10-05 00:28:41 +00001008## Rules for building preprocessed (.i/.ii) outputs.
1009$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
1010 $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
1011 $(Verb) $(Preprocess.CXX) $< -o $@
1012
1013$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1014 $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
1015 $(Verb) $(Preprocess.CXX) $< -o $@
1016
1017 $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
1018 $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
1019 $(Verb) $(Preprocess.C) $< -o $@
1020
1021
Reid Spencercc2d1e22004-10-30 09:19:36 +00001022#---------------------------------------------------------
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001023# Create .bc files in the ObjDir directory from .cpp .cc and .c files...
Reid Spencercc2d1e22004-10-30 09:19:36 +00001024#---------------------------------------------------------
Chris Lattner3c473472004-12-16 17:28:50 +00001025$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001026 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001027 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
1028 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1029 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +00001030
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001031$(ObjDir)/%.bc: %.cc $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1032 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1033 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
1034 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
1035 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
1036
Chris Lattner3c473472004-12-16 17:28:50 +00001037$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001038 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001039 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
1040 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
1041 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +00001042
Reid Spencercc2d1e22004-10-30 09:19:36 +00001043# Provide alternate rule sets if dependencies are disabled
Reid Spencer4d71b662004-10-22 21:01:56 +00001044else
1045
Reid Spencer3a561f52004-10-23 20:04:14 +00001046ifdef SHARED_LIBRARY
1047
Chris Lattner3c473472004-12-16 17:28:50 +00001048$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001049 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +00001050 $(LTCompile.CXX) $< -o $@
1051
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001052$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1053 $(Echo) "Compiling $*.cc for $(BuildMode) build (PIC)"
1054 $(LTCompile.CXX) $< -o $@
1055
Chris Lattner3c473472004-12-16 17:28:50 +00001056$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerc3719842004-12-16 18:26:53 +00001057 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +00001058 $(LTCompile.C) $< -o $@
1059
1060else
Reid Spencer4d71b662004-10-22 21:01:56 +00001061
Chris Lattner3c473472004-12-16 17:28:50 +00001062$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001063 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +00001064 $(Compile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +00001065
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001066$(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
1067 $(Echo) "Compiling $*.cc for $(BuildMode) build"
1068 $(Compile.CXX) $< -o $@
1069
Chris Lattner3c473472004-12-16 17:28:50 +00001070$(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
Reid Spencerc3719842004-12-16 18:26:53 +00001071 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +00001072 $(Compile.C) $< -o $@
1073endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001074
Chris Lattner3c473472004-12-16 17:28:50 +00001075$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001076 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencer8676b7e2004-10-31 18:52:15 +00001077 $(BCCompile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +00001078
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001079$(ObjDir)/%.bc: %.cc $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
1080 $(Echo) "Compiling $*.cc for $(BuildMode) build (bytecode)"
1081 $(BCCompile.CXX) $< -o $@
1082
Chris Lattner3c473472004-12-16 17:28:50 +00001083$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES)
Reid Spencer9af3b292004-11-01 07:50:27 +00001084 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencer8676b7e2004-10-31 18:52:15 +00001085 $(BCCompile.C) $< -o $@
Brian Gaeke44909cf2003-12-10 00:26:28 +00001086
Chris Lattner1cbc29f2001-09-07 22:57:58 +00001087endif
1088
Reid Spencercc2d1e22004-10-30 09:19:36 +00001089#---------------------------------------------------------
1090# Provide rule to build .bc files from .ll sources,
1091# regardless of dependencies
1092#---------------------------------------------------------
1093$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencer9af3b292004-11-01 07:50:27 +00001094 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001095 $(Verb) $(LLVMAS) $< -f -o $@
1096
1097###############################################################################
1098# TABLEGEN: Provide rules for running tblgen to produce *.inc files
1099###############################################################################
Chris Lattner481cc7c2003-08-15 02:18:35 +00001100
Reid Spencer4d71b662004-10-22 21:01:56 +00001101ifdef TARGET
1102
Reid Spencer11fde542005-01-16 02:20:54 +00001103TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001104INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Chris Lattner3c473472004-12-16 17:28:50 +00001105INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
1106.PRECIOUS: $(INCTMPFiles) $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001107
Chris Lattner3c473472004-12-16 17:28:50 +00001108# All of these files depend on tblgen and the .td files.
1109$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001110
Chris Lattner23ee7952004-12-16 17:38:56 +00001111# INCFiles rule: All of the tblgen generated files are emitted to
1112# $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows
1113# us to only "touch" the real file if the contents of it change. IOW, if
1114# tblgen is modified, all of the .inc.tmp files are regereated, but no
1115# dependencies of the .inc files are, unless the contents of the .inc file
1116# changes.
1117$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
Reid Spencerc3719842004-12-16 18:26:53 +00001118 $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
Chris Lattner3c473472004-12-16 17:28:50 +00001119
1120$(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
1121$(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001122 $(Echo) "Building $(<F) register names with tblgen"
1123 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001124
Chris Lattner3c473472004-12-16 17:28:50 +00001125$(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \
1126$(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001127 $(Echo) "Building $(<F) register information header with tblgen"
1128 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001129
Chris Lattner3c473472004-12-16 17:28:50 +00001130$(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \
1131$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001132 $(Echo) "Building $(<F) register info implementation with tblgen"
1133 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001134
Chris Lattner3c473472004-12-16 17:28:50 +00001135$(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \
1136$(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001137 $(Echo) "Building $(<F) instruction names with tblgen"
1138 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001139
Chris Lattner3c473472004-12-16 17:28:50 +00001140$(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \
1141$(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001142 $(Echo) "Building $(<F) instruction information with tblgen"
1143 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001144
Chris Lattner3c473472004-12-16 17:28:50 +00001145$(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \
1146$(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001147 $(Echo) "Building $(<F) assembly writer with tblgen"
1148 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001149
Chris Lattner02a4f902004-12-16 17:34:04 +00001150$(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \
1151$(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir
1152 $(Echo) "Building $(<F) assembly writer #1 with tblgen"
Reid Spencercc2d1e22004-10-30 09:19:36 +00001153 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001154
Chris Lattner3c473472004-12-16 17:28:50 +00001155$(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \
1156$(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001157 $(Echo) "Building $(<F) code emitter with tblgen"
1158 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +00001159
Chris Lattnerf31f09e2005-09-03 01:15:25 +00001160$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
1161$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
1162 $(Echo) "Building $(<F) instruction selector implementation with tblgen"
1163 $(Verb) $(TableGen) -gen-dag-isel -o $@ $<
1164
1165
Reid Spencer3a561f52004-10-23 20:04:14 +00001166clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001167 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +00001168
1169endif
Chris Lattner481cc7c2003-08-15 02:18:35 +00001170
Reid Spencercc2d1e22004-10-30 09:19:36 +00001171###############################################################################
1172# LEX AND YACC: Provide rules for generating sources with lex and yacc
1173###############################################################################
Chris Lattnere8996782003-01-16 22:44:19 +00001174
Reid Spencercc2d1e22004-10-30 09:19:36 +00001175#---------------------------------------------------------
1176# Provide rules for generating a .cpp source file from
1177# (f)lex input sources.
1178#---------------------------------------------------------
1179
Reid Spencer3d659492004-11-02 16:36:03 +00001180LexFiles := $(filter %.l,$(Sources))
Reid Spencercc2d1e22004-10-30 09:19:36 +00001181
Reid Spencer3d659492004-11-02 16:36:03 +00001182ifneq ($(LexFiles),)
1183
Reid Spencer68a24bd2005-08-27 18:50:39 +00001184# Cancel built-in rules for lex
1185%.c: %.l
1186%.cpp: %.l
Reid Spencercc2d1e22004-10-30 09:19:36 +00001187
1188# Note the extra sed filtering here, used to cut down on the warnings emited
1189# by GCC. The last line is a gross hack to work around flex aparently not
1190# being able to resize the buffer on a large token input. Currently, for
1191# uninitialized string buffers in LLVM we can generate very long tokens, so
1192# this is a hack around it.
Chris Lattnerb7dc2b92003-08-15 20:00:47 +00001193# FIXME. (f.e. char Buffer[10000] )
Reid Spencer68a24bd2005-08-27 18:50:39 +00001194$(PROJ_SRC_DIR)/%.cpp: $(PROJ_SRC_DIR)/%.l
Reid Spencerc2ef8cd2004-12-10 19:44:16 +00001195 $(Echo) Flexing $*.l
Reid Spencer68a24bd2005-08-27 18:50:39 +00001196 $(Verb) $(FLEX) -t $(PROJ_SRC_DIR)/$*.l | \
Reid Spencer4d71b662004-10-22 21:01:56 +00001197 $(SED) 's/void yyunput/inline void yyunput/' | \
1198 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
1199 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001200 > $(PROJ_SRC_DIR)/$*.cpp
1201 $(Echo) "*** DON'T FORGET TO CHECK IN $*.cpp (generated file)"
1202
1203LexObjs := $(patsubst %.l,$(ObjDir)/%.o,$(LexFiles))
1204$(LexObjs): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
Chris Lattner00950542001-06-06 20:29:01 +00001205
Reid Spencer9af3b292004-11-01 07:50:27 +00001206clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001207 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencer3d659492004-11-02 16:36:03 +00001208 $(Verb) $(RM) -f $(LexOutput)
Reid Spencer9af3b292004-11-01 07:50:27 +00001209
Reid Spencercc2d1e22004-10-30 09:19:36 +00001210endif
1211
1212#---------------------------------------------------------
1213# Provide rules for generating a .cpp and .h source files
1214# from yacc (bison) input sources.
1215#---------------------------------------------------------
1216
Reid Spencer3d659492004-11-02 16:36:03 +00001217YaccFiles := $(filter %.y,$(Sources))
1218ifneq ($(YaccFiles),)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001219YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.output)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001220
1221.PRECIOUS: $(YaccOutput)
1222
1223# Cancel built-in rules for yacc
1224%.c: %.y
1225%.cpp: %.y
1226%.h: %.y
1227
Chris Lattner00950542001-06-06 20:29:01 +00001228# Rule for building the bison parsers...
Reid Spencer68a24bd2005-08-27 18:50:39 +00001229$(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
Reid Spencercc2d1e22004-10-30 09:19:36 +00001230 $(Echo) "Bisoning $*.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001231 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
1232 $(Verb) $(MV) -f $*.tab.c $(PROJ_SRC_DIR)/$*.cpp
1233 $(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
1234 $(Echo) "*** DON'T FORGET TO CHECK IN $*.cpp and $*.h (generated files)"
Chris Lattner00950542001-06-06 20:29:01 +00001235
Reid Spencer9af3b292004-11-01 07:50:27 +00001236clean-local::
Reid Spencer3d659492004-11-02 16:36:03 +00001237 $(Verb) $(RM) -f $(YaccOutput)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001238endif
Chris Lattner00950542001-06-06 20:29:01 +00001239
Reid Spencercc2d1e22004-10-30 09:19:36 +00001240###############################################################################
1241# OTHER RULES: Other rules needed
1242###############################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +00001243
Chris Lattner30440c62003-01-16 21:06:18 +00001244# To create postscript files from dot files...
John Criswelle0f9ac62003-10-02 19:02:02 +00001245ifneq ($(DOT),false)
Chris Lattner30440c62003-01-16 21:06:18 +00001246%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +00001247 $(DOT) -Tps < $< > $@
John Criswell7a73b802003-06-30 21:59:07 +00001248else
1249%.ps: %.dot
Reid Spencercc2d1e22004-10-30 09:19:36 +00001250 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell7a73b802003-06-30 21:59:07 +00001251endif
Chris Lattner30440c62003-01-16 21:06:18 +00001252
John Criswell7f336952003-09-06 14:44:17 +00001253# This rules ensures that header files that are removed still have a rule for
1254# which they can be "generated." This allows make to ignore them and
1255# reproduce the dependency lists.
John Criswell4b6e5d12003-09-18 18:37:08 +00001256%.h:: ;
Chris Lattnerb05a76c2005-02-04 21:28:50 +00001257%.hpp:: ;
John Criswell7f336952003-09-06 14:44:17 +00001258
Reid Spencercc2d1e22004-10-30 09:19:36 +00001259# Define clean-local to clean the current directory. Note that this uses a
1260# very conservative approach ensuring that empty variables do not cause
1261# errors or disastrous removal.
Reid Spencer3a561f52004-10-23 20:04:14 +00001262clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001263ifneq ($(strip $(ObjDir)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001264 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencere5487ba2004-10-24 07:53:21 +00001265endif
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001266 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001267ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001268 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001269endif
John Criswell7a73b802003-06-30 21:59:07 +00001270
Reid Spencer3d659492004-11-02 16:36:03 +00001271clean-all-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001272 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer3d659492004-11-02 16:36:03 +00001273
Reid Spencercc2d1e22004-10-30 09:19:36 +00001274# Build tags database for Emacs/Xemacs:
Reid Spencer12d79512004-11-12 02:27:36 +00001275tags:: TAGS CTAGS
1276
Reid Spencercc2d1e22004-10-30 09:19:36 +00001277TAGS:
Reid Spencer11fde542005-01-16 02:20:54 +00001278 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1279 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1280 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1281 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spencer12d79512004-11-12 02:27:36 +00001282 -name '*.cpp' -o -name '*.h' | \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001283 $(ETAGS) $(ETAGSFLAGS) -
1284
Reid Spencer12d79512004-11-12 02:27:36 +00001285CTAGS:
Reid Spencer11fde542005-01-16 02:20:54 +00001286 find $(PROJ_SRC_ROOT)/include $(PROJ_SRC_ROOT)/lib \
1287 $(PROJ_SRC_ROOT)/tools $(PROJ_SRC_ROOT)/examples \
1288 $(PROJ_OBJ_ROOT)/include $(PROJ_OBJ_ROOT)/lib \
1289 $(PROJ_OBJ_ROOT)/tools $(PROJ_OBJ_ROOT)/examples \
Reid Spencer12d79512004-11-12 02:27:36 +00001290 \( -name '*.cpp' -o -name '*.h' \) -print | \
Reid Spencer11fde542005-01-16 02:20:54 +00001291 ctags -ImtT -o $(PROJ_OBJ_ROOT)/CTAGS -L -
Reid Spencer12d79512004-11-12 02:27:36 +00001292
1293
Reid Spencer3a561f52004-10-23 20:04:14 +00001294###############################################################################
1295# DEPENDENCIES: Include the dependency files if we should
1296###############################################################################
Chris Lattner33ad24a2003-08-22 14:10:16 +00001297ifndef DISABLE_AUTO_DEPENDENCIES
1298
Reid Spencer3a561f52004-10-23 20:04:14 +00001299# If its not one of the cleaning targets
Reid Spencercc2d1e22004-10-30 09:19:36 +00001300ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencer4d71b662004-10-22 21:01:56 +00001301
Reid Spencer3a561f52004-10-23 20:04:14 +00001302# Get the list of dependency files
Reid Spencercc2d1e22004-10-30 09:19:36 +00001303DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Reid Spencer11fde542005-01-16 02:20:54 +00001304DependFiles := $(patsubst %,$(PROJ_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
Misha Brukman4f7a8cf2003-11-09 21:36:19 +00001305
Reid Spencer3a561f52004-10-23 20:04:14 +00001306-include /dev/null $(DependFiles)
1307
John Criswelld741bcf2003-08-12 18:51:51 +00001308endif
Chris Lattner1ddb6b62003-08-18 17:27:40 +00001309
Reid Spencercc2d1e22004-10-30 09:19:36 +00001310endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001311
Reid Spencer151f8ba2004-10-25 08:27:37 +00001312###############################################################################
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001313# CHECK: Running the test suite
1314###############################################################################
1315
1316check::
Reid Spencer11fde542005-01-16 02:20:54 +00001317 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/test" ; then \
1318 if test -f "$(PROJ_OBJ_ROOT)/test/Makefile" ; then \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001319 $(EchoCmd) Running test suite ; \
Reid Spencer11fde542005-01-16 02:20:54 +00001320 $(MAKE) -C $(PROJ_OBJ_ROOT)/test check-local \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001321 TESTSUITE=$(TESTSUITE) ; \
1322 else \
1323 $(EchoCmd) No Makefile in test directory ; \
1324 fi ; \
1325 else \
1326 $(EchoCmd) No test directory ; \
1327 fi
1328
1329###############################################################################
Reid Spencercc2d1e22004-10-30 09:19:36 +00001330# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer151f8ba2004-10-25 08:27:37 +00001331###############################################################################
1332
Reid Spencere45ebfa2004-10-26 07:09:33 +00001333#------------------------------------------------------------------------
1334# Define distribution related variables
1335#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +00001336DistName := $(PROJECT_NAME)-$(PROJ_VERSION)
1337DistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1338TopDistDir := $(PROJ_OBJ_ROOT)/$(DistName)
1339DistTarGZip := $(PROJ_OBJ_ROOT)/$(DistName).tar.gz
1340DistZip := $(PROJ_OBJ_ROOT)/$(DistName).zip
1341DistTarBZ2 := $(PROJ_OBJ_ROOT)/$(DistName).tar.bz2
Reid Spencer151f8ba2004-10-25 08:27:37 +00001342DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1343 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001344 Makefile.config.in configure autoconf
1345DistOther := $(notdir $(wildcard \
Reid Spencer11fde542005-01-16 02:20:54 +00001346 $(PROJ_SRC_DIR)/*.h \
1347 $(PROJ_SRC_DIR)/*.td \
1348 $(PROJ_SRC_DIR)/*.def \
1349 $(PROJ_SRC_DIR)/*.ll \
1350 $(PROJ_SRC_DIR)/*.in))
Reid Spencercc2d1e22004-10-30 09:19:36 +00001351DistSubDirs := $(SubDirs)
Reid Spencerfbbf3072004-11-29 05:00:33 +00001352DistSources = $(Sources) $(EXTRA_DIST)
1353DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer151f8ba2004-10-25 08:27:37 +00001354
Reid Spencere45ebfa2004-10-26 07:09:33 +00001355#------------------------------------------------------------------------
1356# We MUST build distribution with OBJ_DIR != SRC_DIR
1357#------------------------------------------------------------------------
Reid Spencer11fde542005-01-16 02:20:54 +00001358ifeq ($(PROJ_SRC_DIR),$(PROJ_OBJ_DIR))
Reid Spencere45ebfa2004-10-26 07:09:33 +00001359dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001360 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencere45ebfa2004-10-26 07:09:33 +00001361
Reid Spencere45ebfa2004-10-26 07:09:33 +00001362else
1363
Reid Spencere45ebfa2004-10-26 07:09:33 +00001364#------------------------------------------------------------------------
Reid Spencere45ebfa2004-10-26 07:09:33 +00001365# Prevent attempt to run dist targets from anywhere but the top level
1366#------------------------------------------------------------------------
1367ifneq ($(LEVEL),.)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001368dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencer11fde542005-01-16 02:20:54 +00001369 $(Echo) ERROR: You must run $@ from $(PROJ_OBJ_ROOT)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001370else
1371
1372#------------------------------------------------------------------------
1373# Provide the top level targets
1374#------------------------------------------------------------------------
1375
Reid Spencercc2d1e22004-10-30 09:19:36 +00001376dist-gzip:: $(DistTarGZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001377
Reid Spencer345235ca2004-12-04 22:34:09 +00001378$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001379 $(Echo) Packing gzipped distribution tar file.
Reid Spencer11fde542005-01-16 02:20:54 +00001380 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
Reid Spencerfbbf3072004-11-29 05:00:33 +00001381 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencere45ebfa2004-10-26 07:09:33 +00001382
Reid Spencercc2d1e22004-10-30 09:19:36 +00001383dist-bzip2:: $(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001384
Reid Spencer345235ca2004-12-04 22:34:09 +00001385$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001386 $(Echo) Packing bzipped distribution tar file.
Reid Spencer11fde542005-01-16 02:20:54 +00001387 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
Reid Spencerfbbf3072004-11-29 05:00:33 +00001388 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001389
Reid Spencercc2d1e22004-10-30 09:19:36 +00001390dist-zip:: $(DistZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001391
Reid Spencer345235ca2004-12-04 22:34:09 +00001392$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001393 $(Echo) Packing zipped distribution file.
1394 $(Verb) rm -f $(DistZip)
Reid Spencer11fde542005-01-16 02:20:54 +00001395 $(Verb) cd $(PROJ_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001396
1397dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001398 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001399
Reid Spencerf8f57402005-01-28 19:52:32 +00001400DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir
Reid Spencere45ebfa2004-10-26 07:09:33 +00001401
Reid Spencer345235ca2004-12-04 22:34:09 +00001402dist-check:: $(DistTarGZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001403 $(Echo) Checking distribution tar file.
1404 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001405 $(RM) -rf $(DistCheckDir) ; \
1406 fi
Reid Spencercc2d1e22004-10-30 09:19:36 +00001407 $(Verb) $(MKDIR) $(DistCheckDir)
1408 $(Verb) cd $(DistCheckDir) && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001409 $(MKDIR) $(DistCheckDir)/build && \
1410 $(MKDIR) $(DistCheckDir)/install && \
1411 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1412 cd build && \
1413 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
Reid Spencer45eeed92005-05-24 02:33:20 +00001414 --srcdir=../$(DistName) $(DIST_CHECK_CONFIG_OPTIONS) && \
Reid Spencer345235ca2004-12-04 22:34:09 +00001415 $(MAKE) all && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001416 $(MAKE) check && \
1417 $(MAKE) install && \
1418 $(MAKE) uninstall && \
1419 $(MAKE) dist && \
1420 $(MAKE) clean && \
1421 $(MAKE) dist-clean && \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001422 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001423
1424dist-clean::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001425 $(Echo) Cleaning distribution files
Reid Spencer345235ca2004-12-04 22:34:09 +00001426 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1427 $(DistCheckDir)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001428
1429endif
1430
1431#------------------------------------------------------------------------
1432# Provide the recursive distdir target for building the distribution directory
1433#------------------------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +00001434distdir: $(DistDir)/.makedistdir
1435$(DistDir)/.makedistdir: $(DistSources)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001436 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001437 if test -d "$(DistDir)" ; then \
1438 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1439 exit 1 ; \
1440 fi ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001441 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001442 $(RM) -rf $(DistDir); \
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001443 $(EchoCmd) Making 'all' to verify build ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001444 $(MAKE) all ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001445 fi
Reid Spencerfbbf3072004-11-29 05:00:33 +00001446 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001447 $(Verb) $(MKDIR) $(DistDir)
Reid Spencer11fde542005-01-16 02:20:54 +00001448 $(Verb) srcdirstrip=`echo "$(PROJ_SRC_DIR)" | sed 's|.|.|g'`; \
1449 srcrootstrip=`echo "$(PROJ_SRC_ROOT)" | sed 's|.|.|g'`; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001450 for file in $(DistFiles) ; do \
1451 case "$$file" in \
Reid Spencer11fde542005-01-16 02:20:54 +00001452 $(PROJ_SRC_DIR)/*) \
Reid Spencer345235ca2004-12-04 22:34:09 +00001453 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1454 ;; \
Reid Spencer11fde542005-01-16 02:20:54 +00001455 $(PROJ_SRC_ROOT)/*) \
Reid Spencer345235ca2004-12-04 22:34:09 +00001456 file=`echo "$$file" | \
1457 sed "s#^$$srcrootstrip/##"` \
1458 ;; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001459 esac; \
Reid Spencer11fde542005-01-16 02:20:54 +00001460 if test -f "$(PROJ_SRC_DIR)/$$file" || \
1461 test -d "$(PROJ_SRC_DIR)/$$file" ; then \
1462 from_dir="$(PROJ_SRC_DIR)" ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001463 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001464 from_dir=. ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001465 fi ; \
1466 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001467 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1468 to_dir="$(DistDir)/$$dir"; \
1469 $(MKDIR) "$$to_dir" ; \
1470 else \
1471 to_dir="$(DistDir)"; \
1472 fi; \
1473 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1474 if test -n "$$mid_dir" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001475 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001476 fi ; \
1477 if test -d "$$from_dir/$$file"; then \
Reid Spencer11fde542005-01-16 02:20:54 +00001478 if test -d "$(PROJ_SRC_DIR)/$$file" && \
1479 test "$$from_dir" != "$(PROJ_SRC_DIR)" ; then \
Reid Spencer45eeed92005-05-24 02:33:20 +00001480 cd $(PROJ_SRC_DIR) ; \
1481 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1482 ( cd $$to_dir ; $(TAR) xf - ) ; \
1483 cd $(PROJ_OBJ_DIR) ; \
1484 else \
1485 cd $$from_dir ; \
1486 $(TAR) cf - $$file --exclude .svn --exclude CVS | \
1487 ( cd $$to_dir ; $(TAR) xf - ) ; \
1488 cd $(PROJ_OBJ_DIR) ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001489 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001490 elif test -f "$$from_dir/$$file" ; then \
Reid Spencerc3719842004-12-16 18:26:53 +00001491 $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001492 elif test -L "$$from_dir/$$file" ; then \
Reid Spencerc3719842004-12-16 18:26:53 +00001493 $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001494 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer345235ca2004-12-04 22:34:09 +00001495 $(EchoCmd) "===== WARNING: Distribution Source " \
1496 "$$from_dir/$$file Not Found!" ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001497 elif test "$(Verb)" != '@' ; then \
1498 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001499 fi; \
1500 done
Reid Spencercc2d1e22004-10-30 09:19:36 +00001501 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001502 if test "$$subdir" \!= "." ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001503 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001504 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001505 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1506 exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001507 fi; \
1508 done
Reid Spencer345235ca2004-12-04 22:34:09 +00001509 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencer45eeed92005-05-24 02:33:20 +00001510 $(EchoCmd) Eliminating CVS/.svn directories from distribution ; \
1511 $(RM) -rf `find $(TopDistDir) -type d \( -name CVS -o -name .svn \) -print` ;\
Reid Spencer345235ca2004-12-04 22:34:09 +00001512 $(MAKE) dist-hook ; \
1513 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1514 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1515 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1516 -o ! -type d ! -perm -444 -exec \
1517 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1518 || chmod -R a+r $(DistDir) ; \
1519 fi
Reid Spencer151f8ba2004-10-25 08:27:37 +00001520
Reid Spencercc2d1e22004-10-30 09:19:36 +00001521# This is invoked by distdir target, define it as a no-op to avoid errors if not
1522# defined by user.
Reid Spencer151f8ba2004-10-25 08:27:37 +00001523dist-hook::
1524
Reid Spencere53e3972004-10-22 23:06:30 +00001525endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001526
1527###############################################################################
Reid Spencere5487ba2004-10-24 07:53:21 +00001528# TOP LEVEL - targets only to apply at the top level directory
1529###############################################################################
1530
1531ifeq ($(LEVEL),.)
1532
1533#------------------------------------------------------------------------
Reid Spencer9e8d54a2004-12-06 05:35:13 +00001534# Install support for the project's include files:
Reid Spencere5487ba2004-10-24 07:53:21 +00001535#------------------------------------------------------------------------
1536install-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001537 $(Echo) Installing include files
Reid Spencer11fde542005-01-16 02:20:54 +00001538 $(Verb) $(MKDIR) $(PROJ_includedir)
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001539 $(Verb) if test -d "$(PROJ_SRC_ROOT)/include" ; then \
Reid Spencer11fde542005-01-16 02:20:54 +00001540 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencer2edabc02005-02-16 15:54:03 +00001541 for hdr in `find . -type f '!' '(' -name '*~' -o -name '.cvsignore' \
1542 -o -name '.#*' -o -name '*.in' ')' -print | grep -v CVS ` ; do \
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001543 instdir=`dirname "$(PROJ_includedir)/$$hdr"` ; \
1544 if test \! -d "$$instdir" ; then \
1545 $(EchoCmd) Making install directory $$instdir ; \
1546 $(MKDIR) $$instdir ;\
1547 fi ; \
1548 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer2edabc02005-02-16 15:54:03 +00001549 done ; \
Reid Spencere5487ba2004-10-24 07:53:21 +00001550 fi
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001551 $(Verb) if test -d "$(PROJ_OBJ_ROOT)/include" ; then \
Reid Spencer2edabc02005-02-16 15:54:03 +00001552 cd $(PROJ_OBJ_ROOT)/include && \
1553 for hdr in `find . -type f -print` ; do \
Reid Spencer4a0aaea2005-02-24 03:56:32 +00001554 $(DataInstall) $$hdr $(PROJ_includedir)/$$hdr ; \
Reid Spencer2edabc02005-02-16 15:54:03 +00001555 done ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001556 fi
Reid Spencere5487ba2004-10-24 07:53:21 +00001557
1558uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001559 $(Echo) Uninstalling include files
Reid Spencer11fde542005-01-16 02:20:54 +00001560 $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \
1561 cd $(PROJ_SRC_ROOT)/include && \
Reid Spencere5487ba2004-10-24 07:53:21 +00001562 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001563 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' -o -name '*.in' ')' \
Reid Spencer11fde542005-01-16 02:20:54 +00001564 -print ')' | grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \
Chris Lattnerca94fa22005-02-09 02:24:00 +00001565 cd $(PROJ_SRC_ROOT)/include && \
1566 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' -print ')' \
1567 | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \
1568 fi
Reid Spencere5487ba2004-10-24 07:53:21 +00001569
Reid Spencere5487ba2004-10-24 07:53:21 +00001570endif
1571
Reid Spencer4d71b662004-10-22 21:01:56 +00001572#------------------------------------------------------------------------
1573# Print out the directories used for building
Reid Spencercc2d1e22004-10-30 09:19:36 +00001574#------------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001575printvars::
Reid Spencer11fde542005-01-16 02:20:54 +00001576 $(Echo) "BuildMode : " '$(BuildMode)'
1577 $(Echo) "PROJ_SRC_ROOT: " '$(PROJ_SRC_ROOT)'
1578 $(Echo) "PROJ_SRC_DIR : " '$(PROJ_SRC_DIR)'
1579 $(Echo) "PROJ_OBJ_ROOT: " '$(PROJ_OBJ_ROOT)'
1580 $(Echo) "PROJ_OBJ_DIR : " '$(PROJ_OBJ_DIR)'
1581 $(Echo) "LLVM_SRC_ROOT: " '$(LLVM_SRC_ROOT)'
1582 $(Echo) "LLVM_OBJ_ROOT: " '$(LLVM_OBJ_ROOT)'
1583 $(Echo) "PROJ_prefix : " '$(PROJ_prefix)'
1584 $(Echo) "PROJ_bindir : " '$(PROJ_bindir)'
1585 $(Echo) "PROJ_libdir : " '$(PROJ_libdir)'
1586 $(Echo) "PROJ_etcdir : " '$(PROJ_etcdir)'
Reid Spencer1a9a69c2005-02-16 16:13:02 +00001587 $(Echo) "PROJ_includedir : " '$(PROJ_includedir)'
Reid Spencer11fde542005-01-16 02:20:54 +00001588 $(Echo) "UserTargets : " '$(UserTargets)'
1589 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1590 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1591 $(Echo) "ObjDir : " '$(ObjDir)'
1592 $(Echo) "LibDir : " '$(LibDir)'
1593 $(Echo) "ToolDir : " '$(ToolDir)'
1594 $(Echo) "ExmplDir : " '$(ExmplDir)'
1595 $(Echo) "Sources : " '$(Sources)'
1596 $(Echo) "TDFiles : " '$(TDFiles)'
1597 $(Echo) "INCFiles : " '$(INCFiles)'
1598 $(Echo) "INCTMPFiles : " '$(INCTMPFiles)'
Reid Spencere0acb762005-03-01 16:27:06 +00001599 $(Echo) "PreConditions: " '$(PreConditions)'
Reid Spencer11fde542005-01-16 02:20:54 +00001600 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1601 $(Echo) "Compile.C : " '$(Compile.C)'
1602 $(Echo) "Archive : " '$(Archive)'
1603 $(Echo) "YaccFiles : " '$(YaccFiles)'
1604 $(Echo) "LexFiles : " '$(LexFiles)'
1605 $(Echo) "Module : " '$(Module)'
Reid Spencer755bcf02005-08-24 10:43:10 +00001606 $(Echo) "FilesToConfig: " '$(FilesToConfigPATH)'