blob: 7ab25956601b91069e5915ac92241e09d5f6b1a7 [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
Chris Lattner672d71d2004-12-03 23:56:41 +000023LocalTargets := all-local clean-local clean-all-local \
Reid Spencer44cb1b32004-12-03 20:08:48 +000024 install-local printvars uninstall-local \
25 install-bytecode-local
Reid Spencercc2d1e22004-10-30 09:19:36 +000026TopLevelTargets := dist dist-check dist-clean tags dist-gzip dist-bzip2 \
27 dist-zip
28UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
29InternalTargets := preconditions distdir dist-hook
Reid Spencer3a561f52004-10-23 20:04:14 +000030
Reid Spencercc2d1e22004-10-30 09:19:36 +000031################################################################################
Reid Spencer9411c642004-10-26 22:26:33 +000032# INITIALIZATION: Basic things the makefile needs
Reid Spencercc2d1e22004-10-30 09:19:36 +000033################################################################################
34
35#--------------------------------------------------------------------
36# Set the VPATH so that we can find source files.
37#--------------------------------------------------------------------
38VPATH=$(BUILD_SRC_DIR)
Reid Spencer9411c642004-10-26 22:26:33 +000039
40#--------------------------------------------------------------------
41# Reset the list of suffixes we know how to build
42#--------------------------------------------------------------------
43.SUFFIXES:
Reid Spencercc2d1e22004-10-30 09:19:36 +000044.SUFFIXES: .c .cpp .h .hpp .y .l .lo .o .a .bc .td .ps .dot
45.SUFFIXES: $(SHLIBEXT) $(SUFFIXES)
Reid Spencer9411c642004-10-26 22:26:33 +000046
Reid Spencer3a561f52004-10-23 20:04:14 +000047#--------------------------------------------------------------------
48# Mark all of these targets as phony to avoid implicit rule search
49#--------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000050.PHONY: $(UserTargets) $(InternalTargets)
Reid Spencer3a561f52004-10-23 20:04:14 +000051
52#--------------------------------------------------------------------
Reid Spencer9411c642004-10-26 22:26:33 +000053# Make sure all the user-target rules are double colon rules and
54# they are defined first.
Reid Spencer3a561f52004-10-23 20:04:14 +000055#--------------------------------------------------------------------
56
Reid Spencercc2d1e22004-10-30 09:19:36 +000057$(UserTargets)::
Reid Spencer151f8ba2004-10-25 08:27:37 +000058
Reid Spencer9411c642004-10-26 22:26:33 +000059################################################################################
60# PRECONDITIONS: that which must be built/checked first
61################################################################################
62
Reid Spencer44cb1b32004-12-03 20:08:48 +000063SrcMakefiles := $(filter %Makefile %Makefile.tests,\
Reid Spencer023c4462004-11-17 19:08:44 +000064 $(wildcard $(BUILD_SRC_DIR)/Makefile*))
Reid Spencercc2d1e22004-10-30 09:19:36 +000065ObjMakefiles := $(subst $(BUILD_SRC_DIR),$(BUILD_OBJ_DIR),$(SrcMakefiles))
66ConfigureScript := $(LLVM_SRC_ROOT)/configure
67ConfigStatusScript := $(LLVM_OBJ_ROOT)/config.status
68MakefileConfigIn := $(LLVM_SRC_ROOT)/Makefile.config.in
69MakefileConfig := $(LLVM_OBJ_ROOT)/Makefile.config
70PreConditions := $(ConfigStatusScript) $(MakefileConfig) $(ObjMakefiles)
Reid Spencer9411c642004-10-26 22:26:33 +000071
Reid Spencercc2d1e22004-10-30 09:19:36 +000072preconditions : $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +000073
74#------------------------------------------------------------------------
75# Make sure the BUILT_SOURCES are built first
76#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000077$(filter-out clean clean-local,UserTargets):: $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000078
79clean-local::
80ifneq ($(strip $(BUILT_SOURCES)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +000081 -$(Verb) $(RM) -f $(BUILT_SOURCES)
Reid Spencer9411c642004-10-26 22:26:33 +000082endif
83
Reid Spencercc2d1e22004-10-30 09:19:36 +000084$(BUILT_SOURCES) : $(ObjMakefiles)
Reid Spencer80f0ef72004-10-28 00:41:43 +000085
Reid Spencer9411c642004-10-26 22:26:33 +000086#------------------------------------------------------------------------
87# Make sure we're not using a stale configuration
88#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000089.PRECIOUS: $(ConfigStatusScript)
90$(ConfigStatusScript): $(ConfigureScript)
91 $(Echo) Reconfiguring with $<
Reid Spencer7d277002004-11-29 12:37:44 +000092 $(Verb) cd $(BUILD_OBJ_ROOT) && \
93 $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
94 $(ConfigStatusScript)
Reid Spencer9411c642004-10-26 22:26:33 +000095
96#------------------------------------------------------------------------
97# Make sure the configuration makefile is up to date
98#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +000099$(MakefileConfig): $(MakefileConfigIn) $(ConfigStatusScript)
100 $(Echo) Regenerating $@
101 $(Verb) cd $(LLVM_OBJ_ROOT) ; $(ConfigStatusScript) Makefile.config
Reid Spencer9411c642004-10-26 22:26:33 +0000102
103#------------------------------------------------------------------------
104# If the Makefile in the source tree has been updated, copy it over into the
105# build tree. But, only do this if the source and object makefiles differ
106#------------------------------------------------------------------------
107ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR))
108
Reid Spencer023c4462004-11-17 19:08:44 +0000109Makefile: $(BUILD_SRC_DIR)/Makefile
Reid Spencercc2d1e22004-10-30 09:19:36 +0000110 $(Echo) "Updating Makefile"
111 $(Verb) $(MKDIR) $(@D)
112 $(Verb) cp -f $< $@
Reid Spencer9411c642004-10-26 22:26:33 +0000113
114# Copy the Makefile.* files unless we're in the root directory which avoids
115# the copying of Makefile.config.in or other things that should be explicitly
116# taken care of.
Reid Spencer9411c642004-10-26 22:26:33 +0000117$(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile%
Reid Spencer86606782004-10-26 23:10:00 +0000118 @case '$?' in \
119 *Makefile.rules) ;; \
120 *.in) ;; \
Reid Spencercc2d1e22004-10-30 09:19:36 +0000121 *) $(Echo) "Updating $(@F)" ; \
Reid Spencer86606782004-10-26 23:10:00 +0000122 $(MKDIR) $(@D) ; \
123 cp -f $< $@ ;; \
124 esac
125
Reid Spencer9411c642004-10-26 22:26:33 +0000126endif
127
128#------------------------------------------------------------------------
129# Set up the basic dependencies
130#------------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000131$(UserTargets):: $(PreConditions)
Reid Spencer9411c642004-10-26 22:26:33 +0000132
133all:: all-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000134clean:: clean-local
Reid Spencer3d659492004-11-02 16:36:03 +0000135clean-all:: clean-local clean-all-local
Reid Spencer9411c642004-10-26 22:26:33 +0000136install:: install-local
137uninstall:: uninstall-local
Reid Spencer9411c642004-10-26 22:26:33 +0000138install-local:: all-local
Reid Spencer44cb1b32004-12-03 20:08:48 +0000139install-bytecode:: install-bytecode-local
Reid Spencer3a561f52004-10-23 20:04:14 +0000140
141###############################################################################
142# VARIABLES: Set up various variables based on configuration data
143###############################################################################
144
145#--------------------------------------------------------------------
146# Variables derived from configuration we are building
Chris Lattner00950542001-06-06 20:29:01 +0000147#--------------------------------------------------------------------
148
Chris Lattner760da062003-03-14 20:25:22 +0000149ifdef ENABLE_PROFILING
Reid Spencer9af3b292004-11-01 07:50:27 +0000150 BuildMode := Profile
Reid Spencercc2d1e22004-10-30 09:19:36 +0000151 CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg
152 C.Flags := -O3 -DNDEBUG -pg
153 LD.Flags := -O3 -DNDEBUG -pg
Chris Lattner760da062003-03-14 20:25:22 +0000154else
155 ifdef ENABLE_OPTIMIZED
Reid Spencer9af3b292004-11-01 07:50:27 +0000156 BuildMode := Release
Reid Spencercc2d1e22004-10-30 09:19:36 +0000157 CXX.Flags := -O3 -DNDEBUG -finline-functions -felide-constructors -fomit-frame-pointer
158 C.Flags := -O3 -DNDEBUG -fomit-frame-pointer
159 LD.Flags := -O3 -DNDEBUG
Chris Lattner760da062003-03-14 20:25:22 +0000160 else
Reid Spencer9af3b292004-11-01 07:50:27 +0000161 BuildMode := Debug
Reid Spencercc2d1e22004-10-30 09:19:36 +0000162 CXX.Flags := -g -D_DEBUG
163 C.Flags := -g -D_DEBUG
164 LD.Flags := -g -D_DEBUG
Reid Spencer4d71b662004-10-22 21:01:56 +0000165 KEEP_SYMBOLS := 1
Chris Lattner760da062003-03-14 20:25:22 +0000166 endif
167endif
168
Reid Spencercc2d1e22004-10-30 09:19:36 +0000169CXX.Flags += $(CXXFLAGS)
170C.Flags += $(CFLAGS)
171CPP.Flags += $(CPPFLAGS)
172LD.Flags += $(LDFLAGS)
173AR.Flags := cru
174LibTool.Flags := --tag=CXX
Reid Spencer3a561f52004-10-23 20:04:14 +0000175
176#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000177# Directory locations
Reid Spencer3a561f52004-10-23 20:04:14 +0000178#--------------------------------------------------------------------
Reid Spencer9af3b292004-11-01 07:50:27 +0000179ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000180LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer9a5acaf2004-11-18 20:04:39 +0000181ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer815cbcf2004-11-18 10:03:46 +0000182ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples
183LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib
Reid Spencer9a5acaf2004-11-18 20:04:39 +0000184LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
Reid Spencer815cbcf2004-11-18 10:03:46 +0000185LExmplDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/examples
John Criswell7a73b802003-06-30 21:59:07 +0000186
Reid Spencer3a561f52004-10-23 20:04:14 +0000187#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000188# Full Paths To Compiled Tools and Utilities
Reid Spencer3a561f52004-10-23 20:04:14 +0000189#--------------------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000190EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]:
191Echo := @$(EchoCmd)
192ifndef LIBTOOL
Reid Spencer4d71b662004-10-22 21:01:56 +0000193LIBTOOL := $(LLVM_OBJ_ROOT)/mklib
Reid Spencercc2d1e22004-10-30 09:19:36 +0000194endif
195ifndef LLVMAS
196LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT)
197endif
198ifndef BURG
199BURG := $(LLVMToolDir)/burg$(EXEEXT)
200endif
201ifndef TBLGEN
202TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT)
203endif
Chris Lattner478b3b42004-11-29 19:47:58 +0000204ifndef GCCAS
205GCCAS := $(LLVMToolDir)/gccas$(EXEEXT)
206endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000207ifndef GCCLD
208GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
209endif
210ifndef LLVMGCC
211LLVMGCC := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/gcc
212endif
213ifndef LLVMGXX
214LLVMGXX := PATH=$(LLVMToolDir):$(PATH) $(LLVMGCCDIR)/bin/g++
215endif
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000216
Reid Spencer4d71b662004-10-22 21:01:56 +0000217# Need a better way to compute this.
Reid Spencercc2d1e22004-10-30 09:19:36 +0000218LLVMGCCLibDir := $(dir $(shell $(LLVMGCC) -print-file-name=libgcc.a))/
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000219
Reid Spencer3a561f52004-10-23 20:04:14 +0000220#--------------------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000221# Adjust to user's request
Reid Spencer3a561f52004-10-23 20:04:14 +0000222#--------------------------------------------------------------------
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000223
Reid Spencercc2d1e22004-10-30 09:19:36 +0000224# Adjust LIBTOOL flags for shared libraries, or not.
John Criswell82f4a5a2003-07-31 20:58:51 +0000225ifndef SHARED_LIBRARY
Reid Spencercc2d1e22004-10-30 09:19:36 +0000226 LibTool.Flags += --tag=disable-shared
Reid Spencer4d71b662004-10-22 21:01:56 +0000227else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000228 LD.Flags += -rpath $(LibDir)
John Criswell82f4a5a2003-07-31 20:58:51 +0000229endif
230
Reid Spencercceed9f2004-11-08 17:32:12 +0000231ifdef TOOL_VERBOSE
232 C.Flags += -v
233 CXX.Flags += -v
234 LD.Flags += -v
Reid Spencercceed9f2004-11-08 17:32:12 +0000235 VERBOSE := 1
Reid Spencer9a2f1372004-12-02 09:28:21 +0000236else
Reid Spencercceed9f2004-11-08 17:32:12 +0000237endif
238
Reid Spencer3a561f52004-10-23 20:04:14 +0000239# Adjust settings for verbose mode
Chris Lattner760da062003-03-14 20:25:22 +0000240ifndef VERBOSE
Reid Spencercc2d1e22004-10-30 09:19:36 +0000241 Verb := @
242 LibTool.Flags += --silent
243 AR.Flags += >/dev/null 2>/dev/null
244 ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1
Reid Spencer151f8ba2004-10-25 08:27:37 +0000245else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000246 ConfigureScriptFLAGS :=
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000247endif
248
Vikram S. Advefeeae582002-09-18 11:55:13 +0000249# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000250ifndef KEEP_SYMBOLS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000251 Strip := $(PLATFORMSTRIPOPTS)
252 StripWarnMsg := "(without symbols)"
Vikram S. Advefeeae582002-09-18 11:55:13 +0000253endif
254
Reid Spencer3a561f52004-10-23 20:04:14 +0000255# Adjust linker flags for building an executable
Reid Spencer4d71b662004-10-22 21:01:56 +0000256ifdef TOOLNAME
Reid Spencer815cbcf2004-11-18 10:03:46 +0000257ifdef EXAMPLE_TOOL
258 LD.Flags += -rpath $(ExmplDir) -export-dynamic
259else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000260 LD.Flags += -rpath $(ToolDir) -export-dynamic
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000261endif
Reid Spencer815cbcf2004-11-18 10:03:46 +0000262endif
Dinakar Dhurjati87ea8aa2003-10-29 14:28:35 +0000263
Reid Spencer3a561f52004-10-23 20:04:14 +0000264#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000265# Options To Invoke Tools
Reid Spencer3a561f52004-10-23 20:04:14 +0000266#----------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000267
268CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused
269
Reid Spencercc2d1e22004-10-30 09:19:36 +0000270LD.Flags += -L$(LibDir) -L$(LLVMLibDir)
271CPP.Flags += -I$(BUILD_OBJ_DIR) \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000272 -I$(BUILD_SRC_DIR) \
273 -I$(BUILD_SRC_ROOT)/include \
274 -I$(BUILD_OBJ_ROOT)/include \
275 -I$(LLVM_OBJ_ROOT)/include \
276 -I$(LLVM_SRC_ROOT)/include \
277 -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
Reid Spencer4d71b662004-10-22 21:01:56 +0000278
Reid Spencercc2d1e22004-10-30 09:19:36 +0000279Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
280LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
281BCCompile.C = $(LLVMGCC) $(CPP.Flags) $(CompileCommonOpts) $(C.Flags) -c
282Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
283LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
284BCCompile.CXX = $(LLVMGXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
285Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
286 $(CompileCommonOpts) $(LD.Flags) $(Strip)
287Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
Reid Spencera69b1ea2004-10-28 09:15:28 +0000288 $(CompileCommonOpts)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000289LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL)
Reid Spencer3a561f52004-10-23 20:04:14 +0000290Burg = $(BURG) -I $(BUILD_SRC_DIR)
291TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000292Archive = $(AR) $(AR.Flags)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000293LArchive = $(LLVMToolDir)/llvm-ar rcsf
Reid Spencer4d71b662004-10-22 21:01:56 +0000294ifdef RANLIB
Reid Spencer3a561f52004-10-23 20:04:14 +0000295Ranlib = $(RANLIB)
Reid Spencer4d71b662004-10-22 21:01:56 +0000296else
Reid Spencer3a561f52004-10-23 20:04:14 +0000297Ranlib = ranlib
John Criswell7a73b802003-06-30 21:59:07 +0000298endif
299
Chris Lattner00950542001-06-06 20:29:01 +0000300#----------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +0000301# Get the list of source files and compute object file
302# names from them.
Reid Spencer3a561f52004-10-23 20:04:14 +0000303#----------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +0000304ifdef FAKE_SOURCES
305 Sources :=
306 FakeSources := $(FAKE_SOURCES)
307 ifdef BUILT_SOURCES
308 FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
309 endif
310 BaseNameSources := $(sort $(basename $(FakeSources)))
311 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
312 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
313 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000314else
Reid Spencer345235ca2004-12-04 22:34:09 +0000315 ifndef SOURCES
316 Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \
317 $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \
318 $(BUILD_SRC_DIR)/*.l))
319 else
320 Sources := $(SOURCES)
321 endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000322
Reid Spencer345235ca2004-12-04 22:34:09 +0000323 ifdef BUILT_SOURCES
324 Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES))
325 endif
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000326
Reid Spencer345235ca2004-12-04 22:34:09 +0000327 BaseNameSources := $(sort $(basename $(Sources)))
328 ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o)
329 ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo)
330 ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc)
331endif
Reid Spencer3a561f52004-10-23 20:04:14 +0000332
333###############################################################################
334# DIRECTORIES: Handle recursive descent of directory structure
335###############################################################################
John Criswell82f4a5a2003-07-31 20:58:51 +0000336
Chris Lattner00950542001-06-06 20:29:01 +0000337#---------------------------------------------------------
Reid Spencera69b1ea2004-10-28 09:15:28 +0000338# Provide rules to make install dirs. This must be early
339# in the file so they get built before dependencies
340#---------------------------------------------------------
341
342$(bindir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000343 $(Verb) $(MKDIR) $(bindir)
Chris Lattnere4cb90f2004-11-01 06:14:59 +0000344
Reid Spencera69b1ea2004-10-28 09:15:28 +0000345$(libdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000346 $(Verb) $(MKDIR) $(libdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000347
348$(bytecode_libdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000349 $(Verb) $(MKDIR) $(bytecode_libdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000350
351$(sysconfdir):
Reid Spencercc2d1e22004-10-30 09:19:36 +0000352 $(Verb) $(MKDIR) $(sysconfdir)
Reid Spencera69b1ea2004-10-28 09:15:28 +0000353
Reid Spencercc2d1e22004-10-30 09:19:36 +0000354# To create other directories, as needed, and timestamp their creation
355%/.dir:
356 $(Verb) $(MKDIR) $* > /dev/null
Reid Spencerfbbf3072004-11-29 05:00:33 +0000357 $(Verb) $(DATE) > $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000358
Reid Spencer815cbcf2004-11-18 10:03:46 +0000359.PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir
360.PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir
Reid Spencera69b1ea2004-10-28 09:15:28 +0000361
362#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000363# Handle the DIRS options for sequential construction
Chris Lattner00950542001-06-06 20:29:01 +0000364#---------------------------------------------------------
365
Reid Spencercc2d1e22004-10-30 09:19:36 +0000366SubDirs :=
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000367ifdef DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000368SubDirs += $(DIRS)
369$(RecursiveTargets)::
370 $(Verb) for dir in $(DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000371 if [ ! -f $$dir/Makefile ]; then \
372 $(MKDIR) $$dir; \
373 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
374 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000375 ($(MAKE) -C $$dir $@ ) || exit 1; \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000376 done
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000377endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000378
Reid Spencer3a561f52004-10-23 20:04:14 +0000379#---------------------------------------------------------
380# Handle the EXPERIMENTAL_DIRS options ensuring success
381# after each directory is built.
382#---------------------------------------------------------
383ifdef EXPERIMENTAL_DIRS
Reid Spencercc2d1e22004-10-30 09:19:36 +0000384$(RecursiveTargets)::
385 $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \
Reid Spencer3a561f52004-10-23 20:04:14 +0000386 if [ ! -f $$dir/Makefile ]; then \
387 $(MKDIR) $$dir; \
388 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
389 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000390 ($(MAKE) -C $$dir $@ ) || exit 0; \
Reid Spencer3a561f52004-10-23 20:04:14 +0000391 done
392endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000393
Reid Spencer3a561f52004-10-23 20:04:14 +0000394#---------------------------------------------------------
395# Handle the PARALLEL_DIRS options for parallel construction
396#---------------------------------------------------------
397ifdef PARALLEL_DIRS
398
Reid Spencercc2d1e22004-10-30 09:19:36 +0000399SubDirs += $(PARALLEL_DIRS)
400
Reid Spencer44cb1b32004-12-03 20:08:48 +0000401# Unfortunately, this list must be maintained if new recursive targets are added
Reid Spencercc2d1e22004-10-30 09:19:36 +0000402all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS))
403clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS))
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000404clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000405install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000406uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS))
Reid Spencer44cb1b32004-12-03 20:08:48 +0000407install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS))
Reid Spencer3a561f52004-10-23 20:04:14 +0000408
Reid Spencer345235ca2004-12-04 22:34:09 +0000409ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T))
Reid Spencer3a561f52004-10-23 20:04:14 +0000410
Reid Spencer345235ca2004-12-04 22:34:09 +0000411$(ParallelTargets) :
Reid Spencercc2d1e22004-10-30 09:19:36 +0000412 $(Verb) if [ ! -f $(@D)/Makefile ]; then \
Reid Spencer4d71b662004-10-22 21:01:56 +0000413 $(MKDIR) $(@D); \
414 cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \
John Criswellb3866b62003-11-25 19:32:22 +0000415 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000416 $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@)
Chris Lattner00950542001-06-06 20:29:01 +0000417endif
418
Reid Spencer3a561f52004-10-23 20:04:14 +0000419#---------------------------------------------------------
420# Handle the OPTIONAL_DIRS options for directores that may
421# or may not exist.
422#---------------------------------------------------------
John Criswell2a6530f2003-06-27 16:58:44 +0000423ifdef OPTIONAL_DIRS
Reid Spencer151f8ba2004-10-25 08:27:37 +0000424
Reid Spencercc2d1e22004-10-30 09:19:36 +0000425SubDirs += $(OPTIONAL_DIRS)
Reid Spencer151f8ba2004-10-25 08:27:37 +0000426
Reid Spencercc2d1e22004-10-30 09:19:36 +0000427$(RecursiveTargets)::
428 $(Verb) for dir in $(OPTIONAL_DIRS); do \
Reid Spencer4d71b662004-10-22 21:01:56 +0000429 if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\
430 if [ ! -f $$dir/Makefile ]; then \
431 $(MKDIR) $$dir; \
432 cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \
433 fi; \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000434 ($(MAKE) -C$$dir $@ ) || exit 1; \
Reid Spencer4d71b662004-10-22 21:01:56 +0000435 fi \
John Criswell2a6530f2003-06-27 16:58:44 +0000436 done
437endif
438
Reid Spencerfc945082004-08-20 09:20:05 +0000439#---------------------------------------------------------
440# Handle the CONFIG_FILES options
441#---------------------------------------------------------
442ifdef CONFIG_FILES
Reid Spencerfc945082004-08-20 09:20:05 +0000443
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000444install-local:: $(sysconfdir) $(CONFIG_FILES)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000445 $(Echo) Installing Configuration Files To $(sysconfdir)
446 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer1b426ab2004-11-23 05:59:53 +0000447 if test -f $(BUILD_OBJ_DIR)/$${file} ; then \
448 $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \
449 elif test -f $(BUILD_SRC_DIR)/$${file} ; then \
450 $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \
451 else \
452 $(ECHO) Error: cannot find config file $${file}. ; \
453 fi \
Reid Spencerfc945082004-08-20 09:20:05 +0000454 done
Reid Spencer3a561f52004-10-23 20:04:14 +0000455
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000456uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000457 $(Echo) Uninstalling Configuration Files From $(sysconfdir)
458 $(Verb)for file in $(CONFIG_FILES); do \
Reid Spencer151f8ba2004-10-25 08:27:37 +0000459 $(RM) -f $(sysconfdir)/$${file} ; \
Reid Spencere5487ba2004-10-24 07:53:21 +0000460 done
461
Reid Spencerfc945082004-08-20 09:20:05 +0000462endif
463
Reid Spencer3a561f52004-10-23 20:04:14 +0000464###############################################################################
465# Library Build Rules: Four ways to build a library
466###############################################################################
Chris Lattner00950542001-06-06 20:29:01 +0000467
Brian Gaeke8abff792004-01-22 22:53:48 +0000468
Reid Spencer3a561f52004-10-23 20:04:14 +0000469# if we're building a library ...
Chris Lattner00950542001-06-06 20:29:01 +0000470ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000471
Chris Lattner2a548c52002-09-16 22:36:42 +0000472# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000473LIBRARYNAME := $(strip $(LIBRARYNAME))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000474LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la
475LibName.A := $(LibDir)/lib$(LIBRARYNAME).a
476LibName.O := $(LibDir)/$(LIBRARYNAME).o
Reid Spencer9a2f1372004-12-02 09:28:21 +0000477LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000478
Reid Spencer3a561f52004-10-23 20:04:14 +0000479#---------------------------------------------------------
480# Shared Library Targets:
481# If the user asked for a shared library to be built
482# with the SHARED_LIBRARY variable, then we provide
483# targets for building them.
484#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000485ifdef SHARED_LIBRARY
486
Reid Spencercc2d1e22004-10-30 09:19:36 +0000487all-local:: $(LibName.LA)
Reid Spencer4d71b662004-10-22 21:01:56 +0000488
Reid Spencercc2d1e22004-10-30 09:19:36 +0000489$(LibName.LA): $(BUILT_SOURCES) $(ObjectsLO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000490 $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000491 $(Verb) $(Link) -o $@ $(ObjectsLO)
492 $(Verb) $(LTInstall) $@ $(LibDir)
Reid Spencer3a561f52004-10-23 20:04:14 +0000493
494clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000495ifneq ($(strip $(LibName.LA)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000496 -$(Verb) $(RM) -f $(LibName.LA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000497endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000498
Reid Spencere5487ba2004-10-24 07:53:21 +0000499DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT)
Reid Spencer4d71b662004-10-22 21:01:56 +0000500
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000501install-local:: $(DestSharedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000502
Reid Spencercc2d1e22004-10-30 09:19:36 +0000503$(DestSharedLib): $(libdir) $(LibName.LA)
Reid Spencer9af3b292004-11-01 07:50:27 +0000504 $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000505 $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib)
506 $(Verb) $(LIBTOOL) --finish $(libdir)
Reid Spencere5487ba2004-10-24 07:53:21 +0000507
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000508uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000509 $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
Reid Spencer12d79512004-11-12 02:27:36 +0000510 -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).*
Reid Spencere5487ba2004-10-24 07:53:21 +0000511
Reid Spencer4d71b662004-10-22 21:01:56 +0000512endif
513
Reid Spencer3a561f52004-10-23 20:04:14 +0000514#---------------------------------------------------------
515# Bytecode Library Targets:
516# If the user asked for a bytecode library to be built
517# with the BYTECODE_LIBRARY variable, then we provide
518# targets for building them.
519#---------------------------------------------------------
Reid Spencer4d71b662004-10-22 21:01:56 +0000520ifdef BYTECODE_LIBRARY
521
Reid Spencer776b8052004-12-03 06:04:35 +0000522# make the C and C++ compilers strip debug info out of bytecode libraries.
523BCCompile.C += -Wa,-strip-debug
524BCCompile.CXX += -Wa,-strip-debug
525
Reid Spencer9a2f1372004-12-02 09:28:21 +0000526all-local:: $(LibName.BCA)
527
528ifdef EXPORTED_SYMBOL_FILE
529BCLinkLib = $(LLVMGCC) -shared -nostdlib -Xlinker \
530 -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE)
531
532$(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD)
533 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \
534 "(internalize)"
Chris Lattnerb0ea8642004-12-02 21:23:43 +0000535 $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC)
Reid Spencer9a2f1372004-12-02 09:28:21 +0000536 $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o
Reid Spencer4d71b662004-10-22 21:01:56 +0000537else
Reid Spencer345235ca2004-12-04 22:34:09 +0000538$(LibName.BCA): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir
Reid Spencer9a2f1372004-12-02 09:28:21 +0000539 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
540 $(Verb) $(LArchive) $@ $(ObjectsBC)
541
Reid Spencer4d71b662004-10-22 21:01:56 +0000542endif
543
Reid Spencer3a561f52004-10-23 20:04:14 +0000544clean-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000545ifneq ($(strip $(LibName.BCA)),)
546 -$(Verb) $(RM) -f $(LibName.BCA)
Reid Spencere5487ba2004-10-24 07:53:21 +0000547endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000548
Reid Spencer9a2f1372004-12-02 09:28:21 +0000549DestBytecodeLib = $(bytecode_libdir)/lib$(LIBRARYNAME).a
550
Reid Spencer44cb1b32004-12-03 20:08:48 +0000551install-bytecode-local:: $(DestBytecodeLib)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000552
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000553install-local:: $(DestBytecodeLib)
Chris Lattner481cc7c2003-08-15 02:18:35 +0000554
Reid Spencer9a2f1372004-12-02 09:28:21 +0000555$(DestBytecodeLib): $(bytecode_libdir) $(LibName.BCA)
556 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
557 $(Verb) $(INSTALL) $(LibName.BCA) $@
Reid Spencere5487ba2004-10-24 07:53:21 +0000558
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000559uninstall-local::
Reid Spencer9a2f1372004-12-02 09:28:21 +0000560 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000561 -$(Verb) $(RM) -f $(DestBytecodeLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000562
563endif
Vikram S. Adve60f56062002-08-02 18:34:12 +0000564
Reid Spencercc2d1e22004-10-30 09:19:36 +0000565#---------------------------------------------------------
566# ReLinked Library Targets:
567# If the user didn't explicitly forbid building a
568# relinked then we provide targets for building them.
569#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000570ifndef DONT_BUILD_RELINKED
Reid Spencer4d71b662004-10-22 21:01:56 +0000571
Reid Spencercc2d1e22004-10-30 09:19:36 +0000572all-local:: $(LibName.O)
573
574$(LibName.O): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000575 $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000576 $(Verb) $(Relink) -o $@ $(ObjectsO)
Reid Spencer4d71b662004-10-22 21:01:56 +0000577
Reid Spencer3a561f52004-10-23 20:04:14 +0000578clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000579ifneq ($(strip $(LibName.O)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000580 -$(Verb) $(RM) -f $(LibName.O)
Reid Spencere5487ba2004-10-24 07:53:21 +0000581endif
582
583DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o
584
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000585install-local:: $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000586
Reid Spencercc2d1e22004-10-30 09:19:36 +0000587$(DestRelinkedLib): $(libdir) $(LibName.O)
Reid Spencer9af3b292004-11-01 07:50:27 +0000588 $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000589 $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000590
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000591uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000592 $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000593 -$(Verb) $(RM) -f $(DestRelinkedLib)
Reid Spencer4d71b662004-10-22 21:01:56 +0000594
Chris Lattnere62dbe92002-07-23 17:56:16 +0000595endif
Chris Lattner760da062003-03-14 20:25:22 +0000596
Reid Spencercc2d1e22004-10-30 09:19:36 +0000597#---------------------------------------------------------
598# Archive Library Targets:
599# If the user wanted a regular archive library built,
600# then we provide targets for building them.
601#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000602ifdef BUILD_ARCHIVE
Chris Lattnere62dbe92002-07-23 17:56:16 +0000603
Reid Spencercc2d1e22004-10-30 09:19:36 +0000604all-local:: $(LibName.A)
605
606$(LibName.A): $(BUILT_SOURCES) $(ObjectsO) $(LibDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000607 $(Echo) Building $(BuildMode) Archive Library $(notdir $@)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000608 -$(Verb) $(RM) -f $@
Reid Spencercc2d1e22004-10-30 09:19:36 +0000609 $(Verb) $(Archive) $@ $(ObjectsO)
610 $(Verb) $(Ranlib) $@
Vikram S. Adve41e78912002-09-20 14:03:13 +0000611
Reid Spencer3a561f52004-10-23 20:04:14 +0000612clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000613ifneq ($(strip $(LibName.A)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000614 -$(Verb) $(RM) -f $(LibName.A)
Chris Lattner00950542001-06-06 20:29:01 +0000615endif
616
Reid Spencere5487ba2004-10-24 07:53:21 +0000617DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a
618
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000619install-local:: $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000620
Reid Spencercc2d1e22004-10-30 09:19:36 +0000621$(DestArchiveLib): $(libdir) $(LibName.A)
Reid Spencer9af3b292004-11-01 07:50:27 +0000622 $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000623 $(Verb) $(MKDIR) $(libdir)
624 $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000625
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000626uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000627 $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000628 -$(Verb) $(RM) -f $(DestArchiveLib)
Reid Spencere5487ba2004-10-24 07:53:21 +0000629
630endif
631
632# endif LIBRARYNAME
Reid Spencer4d71b662004-10-22 21:01:56 +0000633endif
634
Reid Spencerb1dd3dd2004-10-24 08:21:04 +0000635###############################################################################
636# Tool Build Rules: Build executable tool based on TOOLNAME option
637###############################################################################
638
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000639ifdef TOOLNAME
640
Reid Spencercc2d1e22004-10-30 09:19:36 +0000641#---------------------------------------------------------
Reid Spencer7c787c92004-11-29 07:17:07 +0000642# Handle the special "JIT" value for LLVM_LIBS which is a
643# shorthand for a bunch of libraries that get the correct
644# JIT support for a tool that runs JIT.
645#---------------------------------------------------------
646ifeq ($(LLVMLIBS),JIT)
647
648# Make sure we can get our own symbols in the tool
649Link += -dlopen self
650
651# Generic JIT libraries
652JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine
653
654# You can enable the X86 JIT on a non-X86 host by setting the flag
655# ENABLE_X86_JIT on the make command line. If not, it will still be
656# enabled automagically on an X86 host.
657ifeq ($(ARCH), x86)
658 ENABLE_X86_JIT = 1
659endif
660
661# What the X86 JIT requires
662ifdef ENABLE_X86_JIT
663 JIT_LIBS += LLVMX86 LLVMSelectionDAG
664endif
665
666# You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag
667# ENABLE_SPARCV9_JIT on the make command line. If not, it will still be
668# enabled automagically on an SparcV9 host.
669ifeq ($(ARCH), Sparc)
670 ENABLE_SPARCV9_JIT = 1
671endif
672
673# What the Sparc JIT requires
674ifdef ENABLE_SPARCV9_JIT
675 JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
676 LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
677 LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
678 LLVMDataStructure.a LLVMSparcV9RegAlloc
679endif
680
681# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
682# ENABLE_PPC_JIT on the make command line. If not, it will still be
683# enabled automagically on an PowerPC host.
684ifeq ($(ARCH), PowerPC)
685 ENABLE_PPC_JIT = 1
686endif
687
688# What the PowerPC JIT requires
689ifdef ENABLE_PPC_JIT
690 JIT_LIBS += LLVMPowerPC
691endif
692
693LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
694 LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
695 LLVMSystem.a $(PLATFORMLIBDL)
696endif
697
698#---------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000699# Set up variables for building a tool.
700#---------------------------------------------------------
Reid Spencer815cbcf2004-11-18 10:03:46 +0000701ifdef EXAMPLE_TOOL
702ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT)
703else
Reid Spencercc2d1e22004-10-30 09:19:36 +0000704ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT)
Reid Spencer815cbcf2004-11-18 10:03:46 +0000705endif
Reid Spencercc2d1e22004-10-30 09:19:36 +0000706ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
707ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions))
708LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
709LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions))
710ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
711LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS)))
712ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs))
713LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000714
Reid Spencercc2d1e22004-10-30 09:19:36 +0000715#---------------------------------------------------------
Reid Spencercc2d1e22004-10-30 09:19:36 +0000716# Tell make that we need to rebuild subdirectories before
717# we can link the tool. This affects things like LLI which
718# has library subdirectories.
719#---------------------------------------------------------
720$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000721
Reid Spencercc2d1e22004-10-30 09:19:36 +0000722#---------------------------------------------------------
723# Provide targets for building the tools
724#---------------------------------------------------------
725all-local:: $(ToolBuildPath)
John Criswell2a6530f2003-06-27 16:58:44 +0000726
Reid Spencer3a561f52004-10-23 20:04:14 +0000727clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +0000728ifneq ($(strip $(ToolBuildPath)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000729 -$(Verb) $(RM) -f $(ToolBuildPath)
Reid Spencere5487ba2004-10-24 07:53:21 +0000730endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000731
Reid Spencer815cbcf2004-11-18 10:03:46 +0000732ifdef EXAMPLE_TOOL
733$(ToolBuildPath): $(ExmplDir)/.dir
734else
735$(ToolBuildPath): $(ToolDir)/.dir
736endif
737
738$(ToolBuildPath): $(BUILT_SOURCES) $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
Reid Spencer9af3b292004-11-01 07:50:27 +0000739 $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000740 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
741 $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB)
Reid Spencer9af3b292004-11-01 07:50:27 +0000742 $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg)
Reid Spencere5487ba2004-10-24 07:53:21 +0000743
744DestTool = $(bindir)/$(TOOLNAME)
745
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000746install-local:: $(DestTool)
Reid Spencere45ebfa2004-10-26 07:09:33 +0000747
Reid Spencercc2d1e22004-10-30 09:19:36 +0000748$(DestTool): $(bindir) $(ToolBuildPath)
Reid Spencer9af3b292004-11-01 07:50:27 +0000749 $(Echo) Installing $(BuildMode) $(DestTool)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000750 $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000751
Reid Spencerc6dcc6a2004-10-28 07:57:28 +0000752uninstall-local::
Reid Spencer9af3b292004-11-01 07:50:27 +0000753 $(Echo) Uninstalling $(BuildMode) $(DestTool)
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000754 -$(Verb) $(RM) -f $(DestTool)
Reid Spencere5487ba2004-10-24 07:53:21 +0000755
Reid Spencer4d71b662004-10-22 21:01:56 +0000756endif
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000757
Reid Spencercc2d1e22004-10-30 09:19:36 +0000758###############################################################################
759# Object Build Rules: Build object files based on sources
760###############################################################################
761
762# Provide rule sets for when dependency generation is enabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000763ifndef DISABLE_AUTO_DEPENDENCIES
Vikram S. Adve41e78912002-09-20 14:03:13 +0000764
Reid Spencercc2d1e22004-10-30 09:19:36 +0000765#---------------------------------------------------------
766# Create .lo files in the ObjDir directory from the .cpp and .c files...
767#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000768ifdef SHARED_LIBRARY
769
Reid Spencercc2d1e22004-10-30 09:19:36 +0000770$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000771 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000772 $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \
773 then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
774 else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000775
Reid Spencercc2d1e22004-10-30 09:19:36 +0000776$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000777 $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000778 $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
779 then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
780 else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000781
Reid Spencercc2d1e22004-10-30 09:19:36 +0000782#---------------------------------------------------------
783# Create .o files in the ObjDir directory from the .cpp and .c files...
784#---------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +0000785else
Reid Spencer4d71b662004-10-22 21:01:56 +0000786
Reid Spencercc2d1e22004-10-30 09:19:36 +0000787$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000788 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000789 $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \
790 then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \
791 else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000792
Reid Spencercc2d1e22004-10-30 09:19:36 +0000793$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000794 $(Echo) "Compiling $*.c for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000795 $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \
796 then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \
797 else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi
Reid Spencer3a561f52004-10-23 20:04:14 +0000798
799endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000800
Reid Spencercc2d1e22004-10-30 09:19:36 +0000801#---------------------------------------------------------
802# Create .bc files in the ObjDir directory from .cpp and .c files...
803#---------------------------------------------------------
Chris Lattner478b3b42004-11-29 19:47:58 +0000804$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000805 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000806 $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \
807 then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \
808 else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000809
Chris Lattner478b3b42004-11-29 19:47:58 +0000810$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000811 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000812 $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \
813 then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \
814 else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi
Reid Spencer4d71b662004-10-22 21:01:56 +0000815
Reid Spencercc2d1e22004-10-30 09:19:36 +0000816# Provide alternate rule sets if dependencies are disabled
Reid Spencer4d71b662004-10-22 21:01:56 +0000817else
818
Reid Spencer3a561f52004-10-23 20:04:14 +0000819ifdef SHARED_LIBRARY
820
Reid Spencercc2d1e22004-10-30 09:19:36 +0000821$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000822 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000823 $(LTCompile.CXX) $< -o $@
824
Reid Spencercc2d1e22004-10-30 09:19:36 +0000825$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000826 $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)"
Reid Spencer3a561f52004-10-23 20:04:14 +0000827 $(LTCompile.C) $< -o $@
828
829else
Reid Spencer4d71b662004-10-22 21:01:56 +0000830
Reid Spencercc2d1e22004-10-30 09:19:36 +0000831$(ObjDir)/%.o: %.cpp $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000832 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +0000833 $(Compile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000834
Reid Spencercc2d1e22004-10-30 09:19:36 +0000835$(ObjDir)/%.o: %.c $(ObjDir)/.dir
Reid Spencer9af3b292004-11-01 07:50:27 +0000836 $(Echo) "Compiling $*.cpp for $(BuildMode) build"
Reid Spencer3a561f52004-10-23 20:04:14 +0000837 $(Compile.C) $< -o $@
838endif
Reid Spencer4d71b662004-10-22 21:01:56 +0000839
Chris Lattner478b3b42004-11-29 19:47:58 +0000840$(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000841 $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)"
Reid Spencer8676b7e2004-10-31 18:52:15 +0000842 $(BCCompile.CXX) $< -o $@
Reid Spencer4d71b662004-10-22 21:01:56 +0000843
Chris Lattner478b3b42004-11-29 19:47:58 +0000844$(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000845 $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)"
Reid Spencer8676b7e2004-10-31 18:52:15 +0000846 $(BCCompile.C) $< -o $@
Brian Gaeke44909cf2003-12-10 00:26:28 +0000847
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000848endif
849
Reid Spencercc2d1e22004-10-30 09:19:36 +0000850#---------------------------------------------------------
851# Provide rule to build .bc files from .ll sources,
852# regardless of dependencies
853#---------------------------------------------------------
854$(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
Reid Spencer9af3b292004-11-01 07:50:27 +0000855 $(Echo) "Compiling $*.ll for $(BuildMode) build"
Reid Spencercc2d1e22004-10-30 09:19:36 +0000856 $(Verb) $(LLVMAS) $< -f -o $@
857
858###############################################################################
859# TABLEGEN: Provide rules for running tblgen to produce *.inc files
860###############################################################################
Chris Lattner481cc7c2003-08-15 02:18:35 +0000861
Reid Spencer4d71b662004-10-22 21:01:56 +0000862ifdef TARGET
863
Reid Spencercc2d1e22004-10-30 09:19:36 +0000864TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
865INCFiles := $(filter %.inc,$(BUILT_SOURCES))
Reid Spencer4d71b662004-10-22 21:01:56 +0000866
Reid Spencercc2d1e22004-10-30 09:19:36 +0000867$(INCFiles) : $(TBLGEN) $(TDFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +0000868
Reid Spencer16544482004-10-27 04:34:35 +0000869%GenRegisterNames.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000870 $(Echo) "Building $(<F) register names with tblgen"
871 $(Verb) $(TableGen) -gen-register-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000872
Reid Spencer16544482004-10-27 04:34:35 +0000873%GenRegisterInfo.h.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000874 $(Echo) "Building $(<F) register information header with tblgen"
875 $(Verb) $(TableGen) -gen-register-desc-header -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000876
877%GenRegisterInfo.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000878 $(Echo) "Building $(<F) register info implementation with tblgen"
879 $(Verb) $(TableGen) -gen-register-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000880
881%GenInstrNames.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000882 $(Echo) "Building $(<F) instruction names with tblgen"
883 $(Verb) $(TableGen) -gen-instr-enums -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000884
885%GenInstrInfo.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000886 $(Echo) "Building $(<F) instruction information with tblgen"
887 $(Verb) $(TableGen) -gen-instr-desc -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000888
889%GenAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000890 $(Echo) "Building $(<F) assembly writer with tblgen"
891 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000892
893%GenATTAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000894 $(Echo) "Building $(<F) AT&T assembly writer with tblgen"
895 $(Verb) $(TableGen) -gen-asm-writer -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000896
897%GenIntelAsmWriter.inc : %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000898 $(Echo) "Building $(<F) Intel assembly writer with tblgen"
899 $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000900
901%GenInstrSelector.inc: %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000902 $(Echo) "Building $(<F) instruction selector with tblgen"
903 $(Verb) $(TableGen) -gen-instr-selector -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000904
905%GenCodeEmitter.inc:: %.td
Reid Spencercc2d1e22004-10-30 09:19:36 +0000906 $(Echo) "Building $(<F) code emitter with tblgen"
907 $(Verb) $(TableGen) -gen-emitter -o $@ $<
Reid Spencer4d71b662004-10-22 21:01:56 +0000908
Reid Spencer3a561f52004-10-23 20:04:14 +0000909clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000910 -$(Verb) $(RM) -f $(INCFiles)
Reid Spencer4d71b662004-10-22 21:01:56 +0000911
912endif
Chris Lattner481cc7c2003-08-15 02:18:35 +0000913
Reid Spencercc2d1e22004-10-30 09:19:36 +0000914###############################################################################
915# LEX AND YACC: Provide rules for generating sources with lex and yacc
916###############################################################################
Chris Lattnere8996782003-01-16 22:44:19 +0000917
Reid Spencercc2d1e22004-10-30 09:19:36 +0000918#---------------------------------------------------------
919# Provide rules for generating a .cpp source file from
920# (f)lex input sources.
921#---------------------------------------------------------
922
Reid Spencer3d659492004-11-02 16:36:03 +0000923LexFiles := $(filter %.l,$(Sources))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000924
Reid Spencer3d659492004-11-02 16:36:03 +0000925ifneq ($(LexFiles),)
926
927LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
Reid Spencercc2d1e22004-10-30 09:19:36 +0000928
929.PRECIOUS: $(LexOutput)
930
931# Note the extra sed filtering here, used to cut down on the warnings emited
932# by GCC. The last line is a gross hack to work around flex aparently not
933# being able to resize the buffer on a large token input. Currently, for
934# uninitialized string buffers in LLVM we can generate very long tokens, so
935# this is a hack around it.
Chris Lattnerb7dc2b92003-08-15 20:00:47 +0000936# FIXME. (f.e. char Buffer[10000] )
Chris Lattner00950542001-06-06 20:29:01 +0000937%.cpp: %.l
Reid Spencercc2d1e22004-10-30 09:19:36 +0000938 $(Echo) Flexing $<
939 $(Verb) $(FLEX) -t $< | \
Reid Spencer4d71b662004-10-22 21:01:56 +0000940 $(SED) 's/void yyunput/inline void yyunput/' | \
941 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
942 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
Reid Spencer80f0ef72004-10-28 00:41:43 +0000943 > $@
Chris Lattner00950542001-06-06 20:29:01 +0000944
Reid Spencer9af3b292004-11-01 07:50:27 +0000945clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000946 -$(Verb) $(RM) -f $(LexOutput)
Reid Spencer3d659492004-11-02 16:36:03 +0000947 $(Verb) $(RM) -f $(LexOutput)
Reid Spencer9af3b292004-11-01 07:50:27 +0000948
Reid Spencercc2d1e22004-10-30 09:19:36 +0000949endif
950
951#---------------------------------------------------------
952# Provide rules for generating a .cpp and .h source files
953# from yacc (bison) input sources.
954#---------------------------------------------------------
955
Reid Spencer3d659492004-11-02 16:36:03 +0000956YaccFiles := $(filter %.y,$(Sources))
957ifneq ($(YaccFiles),)
958YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000959
960.PRECIOUS: $(YaccOutput)
961
962# Cancel built-in rules for yacc
963%.c: %.y
964%.cpp: %.y
965%.h: %.y
966
Chris Lattner00950542001-06-06 20:29:01 +0000967# Rule for building the bison parsers...
Chris Lattner00950542001-06-06 20:29:01 +0000968%.cpp %.h : %.y
Reid Spencercc2d1e22004-10-30 09:19:36 +0000969 $(Echo) "Bisoning $*.y"
970 $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
971 $(Verb) $(MV) -f $*.tab.c $*.cpp
972 $(Verb) $(MV) -f $*.tab.h $*.h
Chris Lattner00950542001-06-06 20:29:01 +0000973
Reid Spencer9af3b292004-11-01 07:50:27 +0000974clean-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +0000975 -$(Verb) $(RM) -f $(YaccOutput)
Reid Spencer3d659492004-11-02 16:36:03 +0000976 $(Verb) $(RM) -f $(YaccOutput)
Reid Spencercc2d1e22004-10-30 09:19:36 +0000977endif
Chris Lattner00950542001-06-06 20:29:01 +0000978
Reid Spencercc2d1e22004-10-30 09:19:36 +0000979###############################################################################
980# OTHER RULES: Other rules needed
981###############################################################################
Reid Spencer4d71b662004-10-22 21:01:56 +0000982
Chris Lattner30440c62003-01-16 21:06:18 +0000983# To create postscript files from dot files...
John Criswelle0f9ac62003-10-02 19:02:02 +0000984ifneq ($(DOT),false)
Chris Lattner30440c62003-01-16 21:06:18 +0000985%.ps: %.dot
Reid Spencer4d71b662004-10-22 21:01:56 +0000986 $(DOT) -Tps < $< > $@
John Criswell7a73b802003-06-30 21:59:07 +0000987else
988%.ps: %.dot
Reid Spencercc2d1e22004-10-30 09:19:36 +0000989 $(Echo) "Cannot build $@: The program dot is not installed"
John Criswell7a73b802003-06-30 21:59:07 +0000990endif
Chris Lattner30440c62003-01-16 21:06:18 +0000991
John Criswell7f336952003-09-06 14:44:17 +0000992# This rules ensures that header files that are removed still have a rule for
993# which they can be "generated." This allows make to ignore them and
994# reproduce the dependency lists.
John Criswell4b6e5d12003-09-18 18:37:08 +0000995%.h:: ;
John Criswell7f336952003-09-06 14:44:17 +0000996
Reid Spencercc2d1e22004-10-30 09:19:36 +0000997# Define clean-local to clean the current directory. Note that this uses a
998# very conservative approach ensuring that empty variables do not cause
999# errors or disastrous removal.
Reid Spencer3a561f52004-10-23 20:04:14 +00001000clean-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001001ifneq ($(strip $(ObjDir)),)
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001002 -$(Verb) $(RM) -rf $(ObjDir)
Reid Spencere5487ba2004-10-24 07:53:21 +00001003endif
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001004 -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001005ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001006 -$(Verb) $(RM) -f *$(SHLIBEXT)
Brian Gaeke9d3cd402004-01-21 19:53:11 +00001007endif
John Criswell7a73b802003-06-30 21:59:07 +00001008
Reid Spencer3d659492004-11-02 16:36:03 +00001009clean-all-local::
Reid Spencerca5fe8f2004-11-02 16:56:15 +00001010 -$(Verb) $(RM) -rf Debug Release Profile
Reid Spencer3d659492004-11-02 16:36:03 +00001011
Reid Spencercc2d1e22004-10-30 09:19:36 +00001012# Build tags database for Emacs/Xemacs:
Reid Spencer12d79512004-11-12 02:27:36 +00001013tags:: TAGS CTAGS
1014
Reid Spencercc2d1e22004-10-30 09:19:36 +00001015TAGS:
Reid Spencer12d79512004-11-12 02:27:36 +00001016 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1017 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1018 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1019 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1020 -name '*.cpp' -o -name '*.h' | \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001021 $(ETAGS) $(ETAGSFLAGS) -
1022
Reid Spencer12d79512004-11-12 02:27:36 +00001023CTAGS:
1024 find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \
1025 $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \
1026 $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \
1027 $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \
1028 \( -name '*.cpp' -o -name '*.h' \) -print | \
1029 ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L -
1030
1031
Reid Spencer3a561f52004-10-23 20:04:14 +00001032###############################################################################
1033# DEPENDENCIES: Include the dependency files if we should
1034###############################################################################
Chris Lattner33ad24a2003-08-22 14:10:16 +00001035ifndef DISABLE_AUTO_DEPENDENCIES
1036
Reid Spencer3a561f52004-10-23 20:04:14 +00001037# If its not one of the cleaning targets
Reid Spencercc2d1e22004-10-30 09:19:36 +00001038ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),)
Reid Spencer4d71b662004-10-22 21:01:56 +00001039
Reid Spencer3a561f52004-10-23 20:04:14 +00001040# Get the list of dependency files
Reid Spencercc2d1e22004-10-30 09:19:36 +00001041DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
Reid Spencer9af3b292004-11-01 07:50:27 +00001042DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles))
Misha Brukman4f7a8cf2003-11-09 21:36:19 +00001043
Reid Spencer3a561f52004-10-23 20:04:14 +00001044-include /dev/null $(DependFiles)
1045
John Criswelld741bcf2003-08-12 18:51:51 +00001046endif
Chris Lattner1ddb6b62003-08-18 17:27:40 +00001047
Reid Spencercc2d1e22004-10-30 09:19:36 +00001048endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001049
Reid Spencer151f8ba2004-10-25 08:27:37 +00001050###############################################################################
Reid Spencercc2d1e22004-10-30 09:19:36 +00001051# DISTRIBUTION: Handle construction of a distribution tarball
Reid Spencer151f8ba2004-10-25 08:27:37 +00001052###############################################################################
1053
Reid Spencere45ebfa2004-10-26 07:09:33 +00001054#------------------------------------------------------------------------
1055# Define distribution related variables
1056#------------------------------------------------------------------------
Reid Spencer151f8ba2004-10-25 08:27:37 +00001057DistName := $(LLVM_TARBALL_NAME)
1058DistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001059TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName)
Reid Spencer151f8ba2004-10-25 08:27:37 +00001060DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz
1061DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip
1062DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2
1063DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \
1064 ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001065 Makefile.config.in configure autoconf
1066DistOther := $(notdir $(wildcard \
1067 $(BUILD_SRC_DIR)/*.h \
1068 $(BUILD_SRC_DIR)/*.td \
1069 $(BUILD_SRC_DIR)/*.def \
1070 $(BUILD_SRC_DIR)/*.ll \
1071 $(BUILD_SRC_DIR)/*.in))
Reid Spencercc2d1e22004-10-30 09:19:36 +00001072DistSubDirs := $(SubDirs)
Reid Spencerfbbf3072004-11-29 05:00:33 +00001073DistSources = $(Sources) $(EXTRA_DIST)
1074DistFiles = $(DistAlways) $(DistSources) $(DistOther)
Reid Spencer151f8ba2004-10-25 08:27:37 +00001075
Reid Spencere45ebfa2004-10-26 07:09:33 +00001076#------------------------------------------------------------------------
1077# We MUST build distribution with OBJ_DIR != SRC_DIR
1078#------------------------------------------------------------------------
1079ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR))
1080dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001081 $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR
Reid Spencere45ebfa2004-10-26 07:09:33 +00001082
Reid Spencere45ebfa2004-10-26 07:09:33 +00001083else
1084
Reid Spencere45ebfa2004-10-26 07:09:33 +00001085#------------------------------------------------------------------------
1086# Prevent catastrophic remove
1087#------------------------------------------------------------------------
1088ifeq ($(LLVM_TARBALL_NAME),)
1089$(error LLVM_TARBALL_NAME is empty. Please rerun configure)
1090endif
1091
1092#------------------------------------------------------------------------
1093# Prevent attempt to run dist targets from anywhere but the top level
1094#------------------------------------------------------------------------
1095ifneq ($(LEVEL),.)
1096
1097dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip ::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001098 $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001099
1100else
1101
1102#------------------------------------------------------------------------
1103# Provide the top level targets
1104#------------------------------------------------------------------------
1105
Reid Spencercc2d1e22004-10-30 09:19:36 +00001106dist-gzip:: $(DistTarGZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001107
Reid Spencer345235ca2004-12-04 22:34:09 +00001108$(DistTarGZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001109 $(Echo) Packing gzipped distribution tar file.
Reid Spencerfbbf3072004-11-29 05:00:33 +00001110 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \
1111 $(GZIP) -c > "$(DistTarGZip)"
Reid Spencere45ebfa2004-10-26 07:09:33 +00001112
Reid Spencercc2d1e22004-10-30 09:19:36 +00001113dist-bzip2:: $(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001114
Reid Spencer345235ca2004-12-04 22:34:09 +00001115$(DistTarBZ2) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001116 $(Echo) Packing bzipped distribution tar file.
Reid Spencerfbbf3072004-11-29 05:00:33 +00001117 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \
1118 $(BZIP2) -c >$(DistTarBZ2)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001119
Reid Spencercc2d1e22004-10-30 09:19:36 +00001120dist-zip:: $(DistZip)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001121
Reid Spencer345235ca2004-12-04 22:34:09 +00001122$(DistZip) : $(TopDistDir)/.makedistdir
Reid Spencercc2d1e22004-10-30 09:19:36 +00001123 $(Echo) Packing zipped distribution file.
1124 $(Verb) rm -f $(DistZip)
1125 $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001126
1127dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001128 $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001129
1130DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir
1131
Reid Spencer345235ca2004-12-04 22:34:09 +00001132dist-check:: $(DistTarGZip)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001133 $(Echo) Checking distribution tar file.
1134 $(Verb) if test -d $(DistCheckDir) ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001135 $(RM) -rf $(DistCheckDir) ; \
1136 fi
Reid Spencercc2d1e22004-10-30 09:19:36 +00001137 $(Verb) $(MKDIR) $(DistCheckDir)
1138 $(Verb) cd $(DistCheckDir) && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001139 $(MKDIR) $(DistCheckDir)/build && \
1140 $(MKDIR) $(DistCheckDir)/install && \
1141 gunzip -c $(DistTarGZip) | $(TAR) xf - && \
1142 cd build && \
1143 ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \
1144 --srcdir=../$(DistName) --with-llvmgccdir="$(LLVMGCCDIR)" && \
Reid Spencer345235ca2004-12-04 22:34:09 +00001145 $(MAKE) all && \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001146 $(MAKE) check && \
1147 $(MAKE) install && \
1148 $(MAKE) uninstall && \
1149 $(MAKE) dist && \
1150 $(MAKE) clean && \
1151 $(MAKE) dist-clean && \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001152 $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution =====
Reid Spencere45ebfa2004-10-26 07:09:33 +00001153
1154dist-clean::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001155 $(Echo) Cleaning distribution files
Reid Spencer345235ca2004-12-04 22:34:09 +00001156 -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \
1157 $(DistCheckDir)
Reid Spencere45ebfa2004-10-26 07:09:33 +00001158
1159endif
1160
1161#------------------------------------------------------------------------
1162# Provide the recursive distdir target for building the distribution directory
1163#------------------------------------------------------------------------
Reid Spencer345235ca2004-12-04 22:34:09 +00001164distdir: $(DistDir)/.makedistdir
1165$(DistDir)/.makedistdir: $(DistSources)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001166 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001167 if test -d "$(DistDir)" ; then \
1168 find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \
1169 exit 1 ; \
1170 fi ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001171 $(EchoCmd) Removing old $(DistDir) ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001172 $(RM) -rf $(DistDir); \
Reid Spencer345235ca2004-12-04 22:34:09 +00001173 $(EchoCmd) Making 'all' to be sure. ; \
1174 $(MAKE) all ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001175 fi
Reid Spencerfbbf3072004-11-29 05:00:33 +00001176 $(Echo) Building Distribution Directory $(DistDir)
Reid Spencercc2d1e22004-10-30 09:19:36 +00001177 $(Verb) $(MKDIR) $(DistDir)
1178 $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001179 srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \
1180 for file in $(DistFiles) ; do \
1181 case "$$file" in \
Reid Spencer345235ca2004-12-04 22:34:09 +00001182 $(BUILD_SRC_DIR)/*) \
1183 file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \
1184 ;; \
1185 $(BUILD_SRC_ROOT)/*) \
1186 file=`echo "$$file" | \
1187 sed "s#^$$srcrootstrip/##"` \
1188 ;; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001189 esac; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001190 if test -f "$(BUILD_SRC_DIR)/$$file" || \
1191 test -d "$(BUILD_SRC_DIR)/$$file" ; then \
1192 from_dir="$(BUILD_SRC_DIR)" ; \
1193 elif test -f "$$file" || test -d "$$file" ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001194 from_dir=. ; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001195 fi ; \
1196 to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001197 if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \
1198 to_dir="$(DistDir)/$$dir"; \
1199 $(MKDIR) "$$to_dir" ; \
1200 else \
1201 to_dir="$(DistDir)"; \
1202 fi; \
1203 mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \
1204 if test -n "$$mid_dir" ; then \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001205 $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001206 fi ; \
1207 if test -d "$$from_dir/$$file"; then \
1208 if test -d "$(BUILD_SRC_DIR)/$$file" && \
1209 test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \
1210 cp -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \
1211 fi; \
1212 cp -pR $$from_dir/$$file $$to_dir || exit 1; \
1213 elif test -f "$$from_dir/$$file" ; then \
1214 cp -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \
1215 elif test -L "$$from_dir/$$file" ; then \
1216 cp -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \
1217 elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \
Reid Spencer345235ca2004-12-04 22:34:09 +00001218 $(EchoCmd) "===== WARNING: Distribution Source " \
1219 "$$from_dir/$$file Not Found!" ; \
Reid Spencercc2d1e22004-10-30 09:19:36 +00001220 elif test "$(Verb)" != '@' ; then \
1221 $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001222 fi; \
1223 done
Reid Spencercc2d1e22004-10-30 09:19:36 +00001224 $(Verb) for subdir in $(DistSubDirs) ; do \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001225 if test "$$subdir" \!= "." ; then \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001226 new_distdir="$(DistDir)/$$subdir" ; \
Reid Spencere45ebfa2004-10-26 07:09:33 +00001227 test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \
Reid Spencer345235ca2004-12-04 22:34:09 +00001228 ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \
1229 exit 1; \
Reid Spencer151f8ba2004-10-25 08:27:37 +00001230 fi; \
1231 done
Reid Spencer345235ca2004-12-04 22:34:09 +00001232 $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \
1233 $(EchoCmd) Eliminating CVS directories from distribution ; \
1234 $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\
1235 $(MAKE) dist-hook ; \
1236 $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \
1237 -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \
1238 -o ! -type d ! -perm -400 -exec chmod a+r {} \; \
1239 -o ! -type d ! -perm -444 -exec \
1240 $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \
1241 || chmod -R a+r $(DistDir) ; \
1242 fi
Reid Spencer151f8ba2004-10-25 08:27:37 +00001243
Reid Spencercc2d1e22004-10-30 09:19:36 +00001244# This is invoked by distdir target, define it as a no-op to avoid errors if not
1245# defined by user.
Reid Spencer151f8ba2004-10-25 08:27:37 +00001246dist-hook::
1247
Reid Spencere53e3972004-10-22 23:06:30 +00001248endif
Reid Spencer4d71b662004-10-22 21:01:56 +00001249
1250###############################################################################
Reid Spencere5487ba2004-10-24 07:53:21 +00001251# TOP LEVEL - targets only to apply at the top level directory
1252###############################################################################
1253
1254ifeq ($(LEVEL),.)
1255
1256#------------------------------------------------------------------------
Reid Spencere5487ba2004-10-24 07:53:21 +00001257# Install support for project's include files:
1258#------------------------------------------------------------------------
1259install-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001260 $(Echo) Installing include files
1261 $(Verb) $(MKDIR) $(includedir)
1262 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencere5487ba2004-10-24 07:53:21 +00001263 cd $(BUILD_SRC_ROOT)/include && \
1264 find . -path '*/Internal' -prune -o '(' -type f \
1265 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1266 -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \
1267 fi
1268
1269uninstall-local::
Reid Spencercc2d1e22004-10-30 09:19:36 +00001270 $(Echo) Uninstalling include files
1271 $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \
Reid Spencere5487ba2004-10-24 07:53:21 +00001272 cd $(BUILD_SRC_ROOT)/include && \
1273 $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \
1274 '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \
1275 -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \
1276 fi
1277
Reid Spencere5487ba2004-10-24 07:53:21 +00001278endif
1279
Reid Spencer4d71b662004-10-22 21:01:56 +00001280#------------------------------------------------------------------------
1281# Print out the directories used for building
Reid Spencercc2d1e22004-10-30 09:19:36 +00001282#------------------------------------------------------------------------
Reid Spencer3a561f52004-10-23 20:04:14 +00001283printvars::
Reid Spencer9af3b292004-11-01 07:50:27 +00001284 $(Echo) "BuildMode : " '$(BuildMode)'
Reid Spencercc2d1e22004-10-30 09:19:36 +00001285 $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)'
1286 $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)'
1287 $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)'
1288 $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)'
1289 $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)'
1290 $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)'
1291 $(Echo) "libdir : " '$(libdir)'
1292 $(Echo) "bindir : " '$(bindir)'
1293 $(Echo) "sysconfdir : " '$(sysconfdir)'
1294 $(Echo) "bytecode_libdir: " '$(bytecode_libdir)'
1295 $(Echo) "UserTargets : " '$(UserTargets)'
1296 $(Echo) "ObjMakefiles : " '$(ObjMakefiles)'
1297 $(Echo) "SrcMakefiles : " '$(SrcMakefiles)'
1298 $(Echo) "ObjDir : " '$(ObjDir)'
1299 $(Echo) "LibDir : " '$(LibDir)'
1300 $(Echo) "ToolDir : " '$(ToolDir)'
Reid Spencer815cbcf2004-11-18 10:03:46 +00001301 $(Echo) "ExmplDir : " '$(ExmplDir)'
Reid Spencercc2d1e22004-10-30 09:19:36 +00001302 $(Echo) "TDFiles : " '$(TDFiles)'
1303 $(Echo) "INCFiles : " '$(INCFiles)'
1304 $(Echo) "Compile.CXX : " '$(Compile.CXX)'
1305 $(Echo) "Compile.C : " '$(Compile.C)'
1306 $(Echo) "Archive : " '$(Archive)'
Reid Spencer3d659492004-11-02 16:36:03 +00001307 $(Echo) "YaccFiles : " '$(YaccFiles)'
1308 $(Echo) "LexFiles : " '$(LexFiles)'