blob: d564cad3eb1fa632c997cfd6368ff71c3ab31aae [file] [log] [blame]
Vikram S. Adve24132e82002-07-09 12:04:21 +00001#===-- Makefile.common - Common make rules for LLVM -------*- makefile -*--====
Chris Lattner2f7c9632001-06-06 20:29:01 +00002#
3# This file is included by all of the LLVM makefiles. This file defines common
4# rules to do things like compile a .cpp file or generate dependancy info.
5# These are platform dependant, so this is the file used to specify these
6# system dependant operations.
7#
8# The following functionality may be set by setting incoming variables:
9#
10# 1. LEVEL - The level of the current subdirectory from the top of the
11# MagicStats view. This level should be expressed as a path, for
12# example, ../.. for two levels deep.
13#
14# 2. DIRS - A list of subdirectories to be built. Fake targets are set up
15# so that each of the targets "all", "install", and "clean" each build.
16# the subdirectories before the local target.
17#
18# 3. Source - If specified, this sets the source code filenames. If this
19# is not set, it defaults to be all of the .cpp, .c, .y, and .l files
Chris Lattneree6e1992001-10-18 01:48:09 +000020# in the current directory. Also, if you want to build files in addition
21# to the local files, you can use the ExtraSource variable
Chris Lattner2f7c9632001-06-06 20:29:01 +000022#
Vikram S. Adve24132e82002-07-09 12:04:21 +000023#===-----------------------------------------------------------------------====
Chris Lattner2f7c9632001-06-06 20:29:01 +000024
Chris Lattner76d98ba2002-07-23 17:56:16 +000025# These are options that can either be enabled here, or can be enabled on the
Chris Lattneread864f2002-08-03 20:19:30 +000026# make command line (ie, make ENABLE_PROFILING=1)
27#
28
29# When ENABLE_PROFILING is enabled, the llvm source base is built with profile
30# information to allow gprof to be used to get execution frequencies.
Chris Lattner76d98ba2002-07-23 17:56:16 +000031#
32#ENABLE_PROFILING = 1
Chris Lattneread864f2002-08-03 20:19:30 +000033
34# When ENABLE_PURIFY is enabled, the LLVM tools are linked with purify (which
35# must be locally installed) to allow for some automated memory error debugging.
36#
Chris Lattner76d98ba2002-07-23 17:56:16 +000037#ENABLE_PURIFY = 1
Chris Lattneread864f2002-08-03 20:19:30 +000038
39# When ENABLE_OPTIMIZED is enabled, Release builds of all of the LLVM code are
40# turned on, and Debug builds are turned off.
41#
Chris Lattner76d98ba2002-07-23 17:56:16 +000042#ENABLE_OPTIMIZED = 1
43
Vikram S. Adve0bfb4cc2002-08-29 18:40:51 +000044# Current working directory, used below
45CUR_DIRECTORY := $(shell pwd)
46
47# Path to directory where object files should be stored during a build.
48# Set this to "." if you do not want to use a separate place for object files.
49#
50BUILD_DIR = /shared/$(LOGIN_NAME)$(patsubst $(HOME)%,%,$(CUR_DIRECTORY))
51
52# Flag whether or not to use a separate location for build files
Chris Lattner77330fa2002-08-09 15:41:55 +000053#
Vikram S. Adve0bfb4cc2002-08-29 18:40:51 +000054ifeq ($(BUILD_DIR),".")
55 BUILD_ROOT = $(BUILD_DIR)
56endif
Chris Lattner77330fa2002-08-09 15:41:55 +000057
Chris Lattner570c6a62002-07-23 19:21:31 +000058ifdef SHARED_LIBRARY
59# if SHARED_LIBRARY is specified, the default is to build the dynamic lib
60dynamic ::
61endif
62
Chris Lattner44601ba2001-06-29 05:20:16 +000063# Default Rule: Make sure it's also a :: rule
Chris Lattner2f7c9632001-06-06 20:29:01 +000064all ::
65
66# Default for install is to at least build everything...
67install ::
68
Chris Lattner77330fa2002-08-09 15:41:55 +000069
70# Figure out which directory to build stuff into. We want to build into the
71# /shared directory by default because it is guaranteed to be local to the
72# current machine.
73#
Chris Lattner01f68c62002-08-12 21:19:28 +000074ifdef BUILD_ROOT
75BUILD_ROOT_TOP := $(LEVEL)
76else
77
Chris Lattner77330fa2002-08-09 15:41:55 +000078LOGIN_NAME := $(shell whoami)
Vikram S. Adve0bfb4cc2002-08-29 18:40:51 +000079BUILD_ROOT := $(BUILD_DIR)
Chris Lattner01f68c62002-08-12 21:19:28 +000080
81# Calculate the BUILD_ROOT_TOP variable, which is the top of the llvm/ tree.
82# Note that although this is just equal to $(BUILD_ROOT)/$(LEVEL), we cannot use
83# this expression because some of the directories on the source tree may not
84# exist in the build tree (for example the test/ heirarchy). Thus we evaluate
85# the directory to eliminate the ../'s
86#
87TOP_DIRECTORY := $(shell cd $(LEVEL); pwd)
88BUILD_ROOT_TOP := /shared/$(LOGIN_NAME)$(patsubst $(HOME)%,%,$(TOP_DIRECTORY))
Chris Lattner77330fa2002-08-09 15:41:55 +000089endif
90
Chris Lattner2f7c9632001-06-06 20:29:01 +000091#--------------------------------------------------------------------
92# Installation configuration options...
93#--------------------------------------------------------------------
94
95#BinInstDir=/usr/local/bin
96#LibInstDir=/usrl/local/lib/xxx
97#DocInstDir=/usr/doc/xxx
98
Vikram S. Adveca4a3822001-08-06 19:01:20 +000099BURG = /home/vadve/vadve/Research/DynOpt/Burg/burg
100BURG_OPTS = -I
101
Chris Lattnerb20b290c2001-10-30 20:24:08 +0000102
Chris Lattner56b56d92002-08-17 21:39:58 +0000103PURIFY = /usr/dcs/applications/purify/bin/purify -cache-dir="$(BUILD_ROOT_TOP)/../purifycache" -chain-length="30" -messages=all
Chris Lattnerb20b290c2001-10-30 20:24:08 +0000104
Chris Lattner76d98ba2002-07-23 17:56:16 +0000105# Shorthand for commonly accessed directories
Chris Lattner01f68c62002-08-12 21:19:28 +0000106LIBDEBUG := $(BUILD_ROOT_TOP)/lib/Debug
107LIBRELEASE := $(BUILD_ROOT_TOP)/lib/Release
108TOOLDEBUG := $(BUILD_ROOT_TOP)/tools/Debug
109TOOLRELEASE := $(BUILD_ROOT_TOP)/tools/Release
Chris Lattner76d98ba2002-07-23 17:56:16 +0000110
Chris Lattner2f7c9632001-06-06 20:29:01 +0000111#---------------------------------------------------------
112# Compilation options...
113#---------------------------------------------------------
114
Vikram S. Adveca4a3822001-08-06 19:01:20 +0000115# Special tools used while building
Chris Lattner01f68c62002-08-12 21:19:28 +0000116RunBurg := $(BURG) $(BURG_OPTS)
Vikram S. Adveca4a3822001-08-06 19:01:20 +0000117
Chris Lattner2f7c9632001-06-06 20:29:01 +0000118# Enable this for profiling support with 'gprof'
Chris Lattner198d5eb2002-05-10 18:51:54 +0000119ifdef ENABLE_PROFILING
120PROFILE = -pg
121else
122PROFILE =
123endif
Chris Lattner2f7c9632001-06-06 20:29:01 +0000124
Chris Lattner068f8222002-01-23 05:46:01 +0000125# -Wno-unused-parameter
Chris Lattner01f68c62002-08-12 21:19:28 +0000126CompileCommonOpts := $(PROFILE) -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include
Chris Lattner2f7c9632001-06-06 20:29:01 +0000127
128# Compile a file, don't link...
Chris Lattner01f68c62002-08-12 21:19:28 +0000129Compile := $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
130CompileG := $(Compile) -g -D_DEBUG
131CompileO := $(Compile) -O3 -DNDEBUG -finline-functions -felide-constructors -fnonnull-objects -freg-struct-return -fshort-enums
Chris Lattner2f7c9632001-06-06 20:29:01 +0000132
133# Link final executable
Chris Lattnerb20b290c2001-10-30 20:24:08 +0000134
Chris Lattnerd711a5e2002-07-31 21:32:05 +0000135ifdef ENABLE_PURIFY # To enable purify, build with 'gmake ENABLE_PURIFY=1'
Chris Lattner01f68c62002-08-12 21:19:28 +0000136Link := $(PURIFY) $(CXX) $(PROFILE) -static
Chris Lattnerf0a88d12002-04-05 18:56:58 +0000137else
Chris Lattner01f68c62002-08-12 21:19:28 +0000138Link := $(CXX) $(PROFILE)
Chris Lattnerf0a88d12002-04-05 18:56:58 +0000139endif
Chris Lattner01f68c62002-08-12 21:19:28 +0000140LinkG := $(Link) -g -L $(LIBDEBUG)
141LinkO := $(Link) -O3 -L $(LIBRELEASE)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000142
Chris Lattner76d98ba2002-07-23 17:56:16 +0000143# Create a .so file from a .o files...
Chris Lattner01f68c62002-08-12 21:19:28 +0000144#MakeSO := $(CXX) -shared $(PROFILE)
145MakeSO := $(CXX) -G $(PROFILE)
146MakeSOO := $(MakeSO) -O3
Chris Lattner2f7c9632001-06-06 20:29:01 +0000147
Chris Lattner76d98ba2002-07-23 17:56:16 +0000148# Create one .o file from a bunch of .o files...
149Relink = ld -r
150
Chris Lattner2f7c9632001-06-06 20:29:01 +0000151# Create dependancy file from CPP file, send to stdout.
Chris Lattner01f68c62002-08-12 21:19:28 +0000152Depend := $(CXX) -MM -I$(LEVEL)/include $(CPPFLAGS)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000153
154# Archive a bunch of .o files into a .a file...
155AR = ar cq
156
157#----------------------------------------------------------
158
159# Source includes all of the cpp files, and objects are derived from the
160# source files...
Chris Lattneree6e1992001-10-18 01:48:09 +0000161# The local Makefile can list other Source files via ExtraSource = ...
Vikram S. Advebd9cae22001-10-17 12:33:55 +0000162#
Chris Lattneree6e1992001-10-18 01:48:09 +0000163Source := $(ExtraSource) $(wildcard *.cpp *.c *.y *.l)
Vikram S. Advefe346892001-07-15 13:16:47 +0000164
Chris Lattnerd1a72292002-07-25 15:01:19 +0000165Objs := $(sort $(patsubst Debug/%.o, %.o, $(addsuffix .o,$(basename $(Source)))))
Chris Lattner77330fa2002-08-09 15:41:55 +0000166ObjectsO = $(addprefix $(BUILD_ROOT)/Release/,$(Objs)))
167ObjectsG = $(addprefix $(BUILD_ROOT)/Debug/,$(Objs))
Chris Lattner2f7c9632001-06-06 20:29:01 +0000168
Chris Lattner76d98ba2002-07-23 17:56:16 +0000169
Chris Lattner2f7c9632001-06-06 20:29:01 +0000170#---------------------------------------------------------
171# Handle the DIRS option
172#---------------------------------------------------------
173
174ifdef DIRS # Only do this if we're using DIRS!
175
176all :: $(addsuffix /.makeall , $(DIRS))
177install :: $(addsuffix /.makeinstall, $(DIRS))
178clean :: $(addsuffix /.makeclean , $(DIRS))
179
180%/.makeall %/.makeclean %/.makeinstall:
181 cd $(@D); $(MAKE) $(subst $(@D)/.make,,$@)
182endif
183
184#---------------------------------------------------------
185# Handle the LIBRARYNAME option - used when building libs...
186#---------------------------------------------------------
Chris Lattner76d98ba2002-07-23 17:56:16 +0000187#
188# When libraries are built, they are allowed to optionally define the
189# DONT_BUILD_RELINKED make variable, which, when defined, prevents a .o file
190# from being built for the library. This .o files may then be linked to by a
191# tool if the tool does not need (or want) the semantics a .a file provides
192# (linking in only object files that are "needed"). If a library is never to
193# be used in this way, it is better to define DONT_BUILD_RELINKED, and define
194# BUILD_ARCHIVE instead.
195#
196# Some libraries must be built as .a files (libscalar for example) because if
Chris Lattnerd711a5e2002-07-31 21:32:05 +0000197# it's built as a .o file, then all of the constituent .o files in it will be
Chris Lattner76d98ba2002-07-23 17:56:16 +0000198# linked into tools (for example gccas) even if they only use one of the parts
199# of it. For this reason, sometimes it's useful to use libraries as .a files.
Chris Lattner2f7c9632001-06-06 20:29:01 +0000200
201ifdef LIBRARYNAME
Vikram S. Advefe346892001-07-15 13:16:47 +0000202
Chris Lattner76d98ba2002-07-23 17:56:16 +0000203LIBNAME_O := $(LIBRELEASE)/lib$(LIBRARYNAME).so
204LIBNAME_G := $(LIBDEBUG)/lib$(LIBRARYNAME).so
205LIBNAME_AO := $(LIBRELEASE)/lib$(LIBRARYNAME).a
206LIBNAME_AG := $(LIBDEBUG)/lib$(LIBRARYNAME).a
207LIBNAME_OBJO := $(LIBRELEASE)/$(LIBRARYNAME).o
208LIBNAME_OBJG := $(LIBDEBUG)/$(LIBRARYNAME).o
Chris Lattner2f7c9632001-06-06 20:29:01 +0000209
Vikram S. Adve15bd3ad2002-08-02 18:34:12 +0000210
211ifndef ENABLE_OPTIMIZED
Chris Lattner76d98ba2002-07-23 17:56:16 +0000212BUILD_LIBNAME_G := $(LIBNAME_G)
213ifndef DONT_BUILD_RELINKED
214BUILD_LIBNAME_OBJG := $(LIBNAME_OBJG)
215endif
216ifdef BUILD_ARCHIVE
217BUILD_LIBNAME_AG := $(LIBNAME_AG)
218endif
Vikram S. Adve15bd3ad2002-08-02 18:34:12 +0000219endif
Chris Lattner2f7c9632001-06-06 20:29:01 +0000220
Chris Lattner76d98ba2002-07-23 17:56:16 +0000221# If optimized builds are enabled...
222ifdef ENABLE_OPTIMIZED
223BUILD_LIBNAME_O := $(LIBNAME_O)
224ifndef DONT_BUILD_RELINKED
225BUILD_LIBNAME_OBJO := $(LIBNAME_OBJO)
226endif
227ifdef BUILD_ARCHIVE
228BUILD_LIBNAME_AO := $(LIBNAME_AO)
229endif
230endif
231
232all:: $(BUILD_LIBNAME_AG) $(BUILD_LIBNAME_OBJG) # Debug
233all:: $(BUILD_LIBNAME_AO) $(BUILD_LIBNAME_OBJO) # Release
234dynamic:: $(BUILD_LIBNAME_G) $(BUILD_LIBNAME_O) # .so files
235
Chris Lattner77330fa2002-08-09 15:41:55 +0000236$(LIBNAME_O): $(ObjectsO) $(LibSubDirs) $(LIBRELEASE)/.dir
Chris Lattner2f7c9632001-06-06 20:29:01 +0000237 @echo ======= Linking $(LIBRARYNAME) release library =======
238 $(MakeSOO) -o $@ $(ObjectsO) $(LibSubDirs) $(LibLinkOpts)
239
Chris Lattner77330fa2002-08-09 15:41:55 +0000240$(LIBNAME_G): $(ObjectsG) $(LibSubDirs) $(LIBDEBUG)/.dir
Chris Lattner2f7c9632001-06-06 20:29:01 +0000241 @echo ======= Linking $(LIBRARYNAME) debug library =======
Chris Lattner76d98ba2002-07-23 17:56:16 +0000242 $(MakeSO) -g -o $@ $(ObjectsG) $(LibSubDirs) $(LibLinkOpts)
Chris Lattner2f7c9632001-06-06 20:29:01 +0000243
Chris Lattner77330fa2002-08-09 15:41:55 +0000244$(LIBNAME_AO): $(ObjectsO) $(LibSubDirs) $(LIBRELEASE)/.dir
Vikram S. Advefe346892001-07-15 13:16:47 +0000245 @echo ======= Linking $(LIBRARYNAME) release library =======
Chris Lattner07c7c192001-09-07 22:57:58 +0000246 @rm -f $@
Chris Lattner01f68c62002-08-12 21:19:28 +0000247 $(AR) $@ $(ObjectsO) $(LibSubDirs)
Vikram S. Advefe346892001-07-15 13:16:47 +0000248
Chris Lattner77330fa2002-08-09 15:41:55 +0000249$(LIBNAME_AG): $(ObjectsG) $(LibSubDirs) $(LIBDEBUG)/.dir
Vikram S. Advefe346892001-07-15 13:16:47 +0000250 @echo ======= Linking $(LIBRARYNAME) debug library =======
Chris Lattner07c7c192001-09-07 22:57:58 +0000251 @rm -f $@
Chris Lattner01f68c62002-08-12 21:19:28 +0000252 $(AR) $@ $(ObjectsG) $(LibSubDirs)
Vikram S. Advefe346892001-07-15 13:16:47 +0000253
Chris Lattner77330fa2002-08-09 15:41:55 +0000254$(LIBNAME_OBJO): $(ObjectsO) $(LibSubDirs) $(LIBRELEASE)/.dir
Chris Lattner76d98ba2002-07-23 17:56:16 +0000255 $(Relink) -o $@ $(ObjectsO) $(LibSubDirs)
256
Chris Lattner77330fa2002-08-09 15:41:55 +0000257$(LIBNAME_OBJG): $(ObjectsG) $(LibSubDirs) $(LIBDEBUG)/.dir
Chris Lattner76d98ba2002-07-23 17:56:16 +0000258 $(Relink) -o $@ $(ObjectsG) $(LibSubDirs)
259
Chris Lattner2f7c9632001-06-06 20:29:01 +0000260endif
261
Chris Lattner07c7c192001-09-07 22:57:58 +0000262#------------------------------------------------------------------------
Vikram S. Advefa9dc582001-10-10 22:35:00 +0000263# Create a TAGS database for emacs
264#------------------------------------------------------------------------
265
Vikram S. Advea0e99082001-10-13 12:26:59 +0000266ifeq ($(LEVEL), .)
Vikram S. Advea0e99082001-10-13 12:26:59 +0000267tags:
Chris Lattner198d5eb2002-05-10 18:51:54 +0000268 etags -l c++ `find include lib tools -name '*.cpp' -o -name '*.h'`
Vikram S. Advea0e99082001-10-13 12:26:59 +0000269all:: tags
Vikram S. Advea0e99082001-10-13 12:26:59 +0000270endif
Vikram S. Advefa9dc582001-10-10 22:35:00 +0000271
272#------------------------------------------------------------------------
Chris Lattner07c7c192001-09-07 22:57:58 +0000273# Handle the TOOLNAME option - used when building tool executables...
274#------------------------------------------------------------------------
275#
276# The TOOLNAME option should be used with a USEDLIBS variable that tells the
Chris Lattner76d98ba2002-07-23 17:56:16 +0000277# libraries (and the order of the libs) that should be linked to the
278# tool. USEDLIBS should contain a list of library names (some with .a extension)
279# that are automatically linked in as .o files unless the .a suffix is added.
Chris Lattner07c7c192001-09-07 22:57:58 +0000280#
281ifdef TOOLNAME
282
283# TOOLEXENAME* - These compute the output filenames to generate...
Chris Lattner01f68c62002-08-12 21:19:28 +0000284TOOLEXENAME_G := $(BUILD_ROOT_TOP)/tools/Debug/$(TOOLNAME)
285TOOLEXENAME_O := $(BUILD_ROOT_TOP)/tools/Release/$(TOOLNAME)
286TOOLEXENAMES := $(TOOLEXENAME_G)
Chris Lattner76d98ba2002-07-23 17:56:16 +0000287ifdef ENABLE_OPTIMIZED
288TOOLEXENAMES += $(TOOLEXENAME_O)
289endif
Chris Lattner07c7c192001-09-07 22:57:58 +0000290
291# USED_LIBS_OPTIONS - Compute the options line that add -llib1 -llib2, etc.
Chris Lattner76d98ba2002-07-23 17:56:16 +0000292USED_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
293USED_LIBS_OPTIONS_G := $(patsubst %.o, $(LIBDEBUG)/%.o, $(USED_LIBS_OPTIONS))
294USED_LIBS_OPTIONS_O := $(patsubst %.o, $(LIBRELEASE)/%.o,$(USED_LIBS_OPTIONS))
295
Chris Lattner07c7c192001-09-07 22:57:58 +0000296
297# USED_LIB_PATHS - Compute the path of the libraries used so that tools are
Chris Lattner76d98ba2002-07-23 17:56:16 +0000298# rebuilt if libraries change. This has to make sure to handle .a/.so and .o
299# files seperately.
Chris Lattner07c7c192001-09-07 22:57:58 +0000300#
Chris Lattner76d98ba2002-07-23 17:56:16 +0000301STATICUSEDLIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
302USED_LIB_PATHS_G := $(addprefix $(LIBDEBUG)/, $(STATICUSEDLIBS))
303USED_LIB_PATHS_O := $(addprefix $(LIBRELEASE)/, $(STATICUSEDLIBS))
Chris Lattner07c7c192001-09-07 22:57:58 +0000304
Chris Lattner1fd501f2001-10-13 05:10:29 +0000305all:: $(TOOLEXENAMES)
Chris Lattner07c7c192001-09-07 22:57:58 +0000306clean::
307 rm -f $(TOOLEXENAMES)
308
Chris Lattner01f68c62002-08-12 21:19:28 +0000309$(TOOLEXENAME_G): $(ObjectsG) $(USED_LIB_PATHS_G) $(BUILD_ROOT_TOP)/tools/Debug/.dir
Chris Lattner76d98ba2002-07-23 17:56:16 +0000310 $(LinkG) -o $@ $(ObjectsG) $(USED_LIBS_OPTIONS_G) $(TOOLLINKOPTS)
Chris Lattner07c7c192001-09-07 22:57:58 +0000311
Chris Lattner01f68c62002-08-12 21:19:28 +0000312$(TOOLEXENAME_O): $(ObjectsO) $(USED_LIB_PATHS_O) $(BUILD_ROOT_TOP)/tools/Release/.dir
Chris Lattner76d98ba2002-07-23 17:56:16 +0000313 $(LinkO) -o $@ $(ObjectsG) $(USED_LIBS_OPTIONS_O) $(TOOLLINKOPTS)
Chris Lattner07c7c192001-09-07 22:57:58 +0000314
315endif
316
317
Chris Lattner2f7c9632001-06-06 20:29:01 +0000318
319#---------------------------------------------------------
Chris Lattner77330fa2002-08-09 15:41:55 +0000320.PRECIOUS: $(BUILD_ROOT)/Depend/.dir
321.PRECIOUS: $(BUILD_ROOT)/Debug/.dir $(BUILD_ROOT)/Release/.dir
Chris Lattner2f7c9632001-06-06 20:29:01 +0000322
Vikram S. Advefe346892001-07-15 13:16:47 +0000323# Create dependencies for the *.cpp files...
Chris Lattner77330fa2002-08-09 15:41:55 +0000324$(BUILD_ROOT)/Depend/%.d: %.cpp $(BUILD_ROOT)/Depend/.dir
Chris Lattnere5b0f652002-08-09 19:18:12 +0000325 $(Depend) $< | sed 's|$*\.o *|$(BUILD_ROOT)/Release/& $(BUILD_ROOT)/Debug/& $(BUILD_ROOT)/Depend/$(@F)|g' > $@
Chris Lattner2f7c9632001-06-06 20:29:01 +0000326
Vikram S. Advefe346892001-07-15 13:16:47 +0000327# Create dependencies for the *.c files...
Chris Lattner77330fa2002-08-09 15:41:55 +0000328$(BUILD_ROOT)/Depend/%.d: %.c $(BUILD_ROOT)/Depend/.dir
Vikram S. Advefe346892001-07-15 13:16:47 +0000329 $(Depend) $< | sed 's|$*\.o *|Release/& Debug/& Depend/$(@F)|g' > $@
330
331# Create .o files in the ObjectFiles directory from the .cpp and .c files...
Chris Lattner77330fa2002-08-09 15:41:55 +0000332$(BUILD_ROOT)/Release/%.o: %.cpp $(BUILD_ROOT)/Release/.dir
Chris Lattner2f7c9632001-06-06 20:29:01 +0000333 $(CompileO) $< -o $@
334
Chris Lattner068f8222002-01-23 05:46:01 +0000335#Release/%.o: %.c Release/.dir Depend/.dir
336# $(CompileOC) $< -o $@
Vikram S. Advefe346892001-07-15 13:16:47 +0000337
Chris Lattner77330fa2002-08-09 15:41:55 +0000338$(BUILD_ROOT)/Debug/%.o: %.cpp $(BUILD_ROOT)/Debug/.dir
Chris Lattner2f7c9632001-06-06 20:29:01 +0000339 $(CompileG) $< -o $@
340
Chris Lattner77330fa2002-08-09 15:41:55 +0000341#Debug/%.o: %.c Debug/.dir
Chris Lattner068f8222002-01-23 05:46:01 +0000342# $(CompileGC) $< -o $@
Vikram S. Advefe346892001-07-15 13:16:47 +0000343
Chris Lattner2f7c9632001-06-06 20:29:01 +0000344# Create a .cpp source file from a flex input file... this uses sed to cut down
345# on the warnings emited by GCC...
346%.cpp: %.l
347 flex -t $< | sed '/^find_rule/d' | sed 's/void yyunput/inline void yyunput/' | sed 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' > $@
348
349# Rule for building the bison parsers...
350
351%.cpp %.h : %.y
Chris Lattner198d5eb2002-05-10 18:51:54 +0000352 bison -v -d -p $(<:%Parser.y=%) $(basename $@).y
Chris Lattner2f7c9632001-06-06 20:29:01 +0000353 mv -f $(basename $@).tab.c $(basename $@).cpp
354 mv -f $(basename $@).tab.h $(basename $@).h
355
356# To create the directories...
357%/.dir:
358 mkdir -p $(@D)
359 @date > $@
360
Chris Lattnerd711a5e2002-07-31 21:32:05 +0000361# Clean nukes the tree
Chris Lattner2f7c9632001-06-06 20:29:01 +0000362clean::
Vikram S. Advefddb1172002-08-22 03:20:27 +0000363 rm -rf $(BUILD_ROOT)/Debug $(BUILD_ROOT)/Release $(BUILD_ROOT)/Depend
Chris Lattner2f7c9632001-06-06 20:29:01 +0000364 rm -f core *.o *.d *.so *~ *.flc
365
366# If dependancies were generated for the file that included this file,
367# include the dependancies now...
368#
Chris Lattner01f68c62002-08-12 21:19:28 +0000369SourceDepend := $(addsuffix .d,$(addprefix $(BUILD_ROOT)/Depend/,$(basename $(filter-out Debug/%, $(Source)))))
Chris Lattner2f7c9632001-06-06 20:29:01 +0000370ifneq ($(SourceDepend),)
371include $(SourceDepend)
372endif