1 #===-- Makefile.common - Common make rules for LLVM -------*- makefile -*--====
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.
8 # The following functionality can be set by setting incoming variables.
9 # The variable $(LEVEL) *must* be set:
11 # 1. LEVEL - The level of the current subdirectory from the top of the
12 # MagicStats view. This level should be expressed as a path, for
13 # example, ../.. for two levels deep.
15 # 2. DIRS - A list of subdirectories to be built. Fake targets are set up
16 # so that each of the targets "all", "install", and "clean" each build
17 # the subdirectories before the local target. DIRS are guaranteed to be
20 # 3. PARALLEL_DIRS - A list of subdirectories to be built, but that may be
21 # built in any order. All DIRS are built in order before PARALLEL_DIRS are
22 # built, which are then built in any order.
24 # 4. Source - If specified, this sets the source code filenames. If this
25 # is not set, it defaults to be all of the .cpp, .c, .y, and .l files
26 # in the current directory. Also, if you want to build files in addition
27 # to the local files, you can use the ExtraSource variable
29 # 5. SourceDir - If specified, this specifies a directory that the source files
30 # are in, if they are not in the current directory. This should include a
31 # trailing / character.
33 # 6. PROJ_COMPILE - If set to 1, then this makefile can also be used to
34 # compile other projects using llvm. Note if this option is set then the
35 # following *must* hold
36 # PROJLEVEL should be set to the top of the source directory for the
38 # LEVEL should be set to the top of LLVM source tree
39 # LLVM_LIB_DIR should be set to the top of the LLVM build tree
41 #===-----------------------------------------------------------------------====
43 # Configuration file to set paths specific to local installation of LLVM
45 include $(LEVEL)/Makefile.config
47 ###########################################################################
48 # Directory Configuration
49 # This section of the Makefile determines what is where. To be
50 # specific, there are several locations that need to be defined:
52 # o LLVM_SRC_ROOT : The root directory of the LLVM source code.
53 # o LLVM_OBJ_ROOT : The root directory containing the built LLVM code.
55 # o BUILD_SRC_DIR : The directory containing the code to build.
56 # o BUILD_SRC_ROOT : The root directory of the code to build.
58 # o BUILD_OBJ_DIR : The directory in which compiled code will be placed.
59 # o BUILD_OBJ_ROOT : The root directory in which compiled code is placed.
61 ###########################################################################
64 # Set the source build directory. That is almost always the current directory.
67 BUILD_SRC_DIR = $(shell pwd)
71 # Set the source root directory.
74 BUILD_SRC_ROOT = $(shell cd $(BUILD_SRC_DIR)/$(LEVEL); pwd)
78 # Set the object build directory. Its location depends upon the source path
79 # and where object files should go.
83 BUILD_OBJ_DIR = $(shell pwd)
85 BUILD_OBJ_DIR := $(OBJ_ROOT)$(patsubst $(shell dirname $(BUILD_SRC_ROOT))%,%,$(shell cd $(BUILD_SRC_DIR); pwd))
90 # Set the root of the object directory.
94 BUILD_OBJ_ROOT = $(shell cd $(LEVEL); pwd)
96 BUILD_OBJ_ROOT := $(OBJ_ROOT)$(patsubst $(shell dirname $(BUILD_SRC_ROOT))%,%,$(shell cd $(BUILD_SRC_ROOT); pwd))
101 # Set the LLVM source directory.
102 # It is typically the root directory of what we're compiling now.
105 LLVM_SRC_ROOT = $(BUILD_SRC_ROOT)
109 # Set the LLVM object directory.
112 LLVM_OBJ_ROOT = $(BUILD_OBJ_ROOT)
115 # Figure out how to do platform specific stuff on this platform. This is really
116 # gross and should be autoconfiscated (automake actually), but should hopefully
117 # work on Linux and solaris (SunOS).
119 UNAME := $(shell uname)
120 include $(LLVM_SRC_ROOT)/Makefile.$(UNAME)
123 # if SHARED_LIBRARY is specified, the default is to build the dynamic lib
127 # Default Rule: Make sure it's also a :: rule
130 # Default for install is to at least build everything...
133 # Default rule for test. It ensures everything has a test rule
136 #--------------------------------------------------------------------
137 # Variables derived from configuration options...
138 #--------------------------------------------------------------------
140 #BinInstDir=/usr/local/bin
141 #LibInstDir=/usr/local/lib/xxx
142 #DocInstDir=/usr/doc/xxx
146 PURIFY := $(PURIFY) -cache-dir="$(BUILD_OBJ_ROOT)/../purifycache" -chain-length="30" -messages=all
148 ifdef ENABLE_PROFILING
150 CONFIGURATION := Profile
152 ifdef ENABLE_OPTIMIZED
153 CONFIGURATION := Release
155 CONFIGURATION := Debug
159 ###########################################################################
161 # These variables describe various library locations:
163 # DEST* = Location of where libraries that are built will be placed.
164 # LLVM* = Location of LLVM libraries used for linking.
165 # PROJ* = Location of previously built libraries used for linking.
166 ###########################################################################
168 # Libraries that are being built
169 DESTLIBDEBUG := $(BUILD_OBJ_ROOT)/lib/Debug
170 DESTLIBRELEASE := $(BUILD_OBJ_ROOT)/lib/Release
171 DESTLIBPROFILE := $(BUILD_OBJ_ROOT)/lib/Profile
172 DESTLIBCURRENT := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
174 # LLVM libraries used for linking
175 LLVMLIBDEBUGSOURCE := $(LLVM_OBJ_ROOT)/lib/Debug
176 LLVMLIBRELEASESOURCE := $(LLVM_OBJ_ROOT)/lib/Release
177 LLVMLIBPROFILESOURCE := $(LLVM_OBJ_ROOT)/lib/Profile
178 LLVMLIBCURRENTSOURCE := $(LLVM_OBJ_ROOT)/lib/$(CONFIGURATION)
180 # Libraries that were built that will now be used for linking
181 PROJLIBDEBUGSOURCE := $(BUILD_OBJ_ROOT)/lib/Debug
182 PROJLIBRELEASESOURCE := $(BUILD_OBJ_ROOT)/lib/Release
183 PROJLIBPROFILESOURCE := $(BUILD_OBJ_ROOT)/lib/Profile
184 PROJLIBCURRENTSOURCE := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
186 ###########################################################################
188 # These variables describe various tool locations:
190 # DEST* = Location of where tools that are built will be placed.
191 # LLVM* = Location of LLVM tools used for building.
192 # PROJ* = Location of previously built tools used for linking.
193 ###########################################################################
195 DESTTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug
196 DESTTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release
197 DESTTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile
198 DESTTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
200 LLVMTOOLDEBUG := $(LLVM_OBJ_ROOT)/tools/Debug
201 LLVMTOOLRELEASE := $(LLVM_OBJ_ROOT)/tools/Release
202 LLVMTOOLPROFILE := $(LLVM_OBJ_ROOT)/tools/Profile
203 LLVMTOOLCURRENT := $(LLVM_OBJ_ROOT)/tools/$(CONFIGURATION)
205 PROJTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug
206 PROJTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release
207 PROJTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile
208 PROJTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
215 #---------------------------------------------------------
216 # Compilation options...
217 #---------------------------------------------------------
219 ###########################################################################
220 # Special tools used while building the LLVM tree. Burg is built as part of the
222 ###########################################################################
223 BURG := $(LLVMTOOLCURRENT)/burg
224 RunBurg := $(BURG) $(BURG_OPTS)
226 TBLGEN := $(LLVMTOOLCURRENT)/tblgen
228 # Enable this for profiling support with 'gprof'
229 # This automatically enables optimized builds.
230 ifdef ENABLE_PROFILING
234 ###########################################################################
236 ###########################################################################
239 # Include both the project headers and the LLVM headers for compilation
241 CPPFLAGS += -I$(BUILD_SRC_ROOT)/include -I$(LLVM_SRC_ROOT)/include
243 # By default, strip symbol information from executable
245 STRIP = $(PLATFORMSTRIPOPTS)
246 STRIP_WARN_MSG = "(without symbols) "
249 # Allow gnu extensions...
250 CPPFLAGS += -D_GNU_SOURCE
252 # -Wno-unused-parameter
253 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include
254 CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions -fshort-enums
256 # Compile a cpp file, don't link...
257 Compile := $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
258 CompileG := $(Compile) -g -D_DEBUG
259 CompileO := $(Compile) $(CompileOptimizeOpts) -felide-constructors -fomit-frame-pointer
260 CompileP := $(Compile) $(CompileOptimizeOpts) -felide-constructors $(PROFILE)
262 # Compile a c file, don't link...
263 CompileC := $(CC) -c $(CPPFLAGS) $(CCFLAGS) $(CompileCommonOpts)
264 CompileCG := $(CompileC) -g -D_DEBUG
265 CompileCO := $(CompileC) $(CompileOptimizeOpts) -fomit-frame-pointer
266 CompileCP := $(CompileC) $(CompileOptimizeOpts) $(PROFILE)
269 # Link final executable
271 ifdef ENABLE_PURIFY # To enable purify, build with 'gmake ENABLE_PURIFY=1'
272 Link := $(PURIFY) $(CXX) -static
278 # include both projlib source and llvmlib source
279 LinkG := $(Link) -g -L$(PROJLIBDEBUGSOURCE) -L$(LLVMLIBDEBUGSOURCE) $(STRIP)
280 LinkO := $(Link) -O3 -L$(PROJLIBRELEASESOURCE) -L$(LLVMLIBRELEASESOURCE)
281 LinkP := $(Link) -O3 -L$(PROJLIBPROFILESOURCE) -L$(LLVMLIBPROFILESOURCE) $(PROFILE)
283 LinkG := $(Link) -g -L$(LLVMLIBDEBUGSOURCE) $(STRIP)
284 LinkO := $(Link) -O3 -L$(LLVMLIBRELEASESOURCE)
285 LinkP := $(Link) -O3 -L$(LLVMLIBPROFILESOURCE) $(PROFILE)
290 # Create one .o file from a bunch of .o files...
293 # MakeSO - Create a .so file from a .o files...
294 MakeSO := $(CXX) $(MakeSharedObjectOption)
295 MakeSOO := $(MakeSO) -O3
296 MakeSOP := $(MakeSOO) $(PROFILE)
298 # Create dependancy file from CPP file, send to stdout.
299 Depend := $(CXX) -MM -I$(LEVEL)/include $(CPPFLAGS)
300 DependC := $(CC) -MM -I$(LEVEL)/include $(CPPFLAGS)
302 # Archive a bunch of .o files into a .a file...
305 #----------------------------------------------------------
307 # Source includes all of the cpp files, and objects are derived from the
309 # The local Makefile can list other Source files via ExtraSource = ...
312 Source := $(ExtraSource) $(wildcard *.cpp *.c *.y *.l)
315 Objs := $(sort $(patsubst Debug/%.o, %.o, $(addsuffix .o,$(notdir $(basename $(Source))))))
316 ObjectsO := $(addprefix $(BUILD_OBJ_DIR)/Release/,$(Objs))
317 ObjectsP := $(addprefix $(BUILD_OBJ_DIR)/Profile/,$(Objs))
318 ObjectsG := $(addprefix $(BUILD_OBJ_DIR)/Debug/,$(Objs))
321 #---------------------------------------------------------
322 # Handle the DIRS and PARALLEL_DIRS options
323 #---------------------------------------------------------
326 all install clean test ::
327 $(VERB) for dir in ${DIRS}; do \
328 (cd $$dir; $(MAKE) $@) || exit 1; \
332 # Handle PARALLEL_DIRS
334 all :: $(addsuffix /.makeall , $(PARALLEL_DIRS))
335 install :: $(addsuffix /.makeinstall, $(PARALLEL_DIRS))
336 clean :: $(addsuffix /.makeclean , $(PARALLEL_DIRS))
337 test :: $(addsuffix /.maketest , $(PARALLEL_DIRS))
339 %/.makeall %/.makeinstall %/.makeclean %/.maketest:
340 $(VERB) cd $(@D); $(MAKE) $(subst $(@D)/.make,,$@)
343 #---------------------------------------------------------
344 # Handle the LIBRARYNAME option - used when building libs...
345 #---------------------------------------------------------
347 # When libraries are built, they are allowed to optionally define the
348 # DONT_BUILD_RELINKED make variable, which, when defined, prevents a .o file
349 # from being built for the library. This .o files may then be linked to by a
350 # tool if the tool does not need (or want) the semantics a .a file provides
351 # (linking in only object files that are "needed"). If a library is never to
352 # be used in this way, it is better to define DONT_BUILD_RELINKED, and define
353 # BUILD_ARCHIVE instead.
355 # Some libraries must be built as .a files (libscalar for example) because if
356 # it's built as a .o file, then all of the constituent .o files in it will be
357 # linked into tools (for example gccas) even if they only use one of the parts
358 # of it. For this reason, sometimes it's useful to use libraries as .a files.
362 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
363 LIBRARYNAME := $(strip $(LIBRARYNAME))
365 LIBNAME_O := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).so
366 LIBNAME_P := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).so
367 LIBNAME_G := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).so
368 LIBNAME_AO := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).a
369 LIBNAME_AP := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).a
370 LIBNAME_AG := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).a
371 LIBNAME_OBJO := $(DESTLIBRELEASE)/$(LIBRARYNAME).o
372 LIBNAME_OBJP := $(DESTLIBPROFILE)/$(LIBRARYNAME).o
373 LIBNAME_OBJG := $(DESTLIBDEBUG)/$(LIBRARYNAME).o
375 # dynamic target builds a shared object version of the library...
376 dynamic:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).so
378 # Does the library want a .o version built?
379 ifndef DONT_BUILD_RELINKED
380 all:: $(DESTLIBCURRENT)/$(LIBRARYNAME).o
383 # Does the library want an archive version built?
385 all:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).a
388 $(LIBNAME_O): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
389 @echo ======= Linking $(LIBRARYNAME) release library =======
390 $(VERB) $(MakeSOO) -o $@ $(ObjectsO) $(LibSubDirs) $(LibLinkOpts)
392 $(LIBNAME_P): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
393 @echo ======= Linking $(LIBRARYNAME) profile library =======
394 $(VERB) $(MakeSOP) -o $@ $(ObjectsP) $(LibSubDirs) $(LibLinkOpts)
396 $(LIBNAME_G): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
397 @echo ======= Linking $(LIBRARYNAME) debug library =======
398 $(VERB) $(MakeSO) -g -o $@ $(ObjectsG) $(LibSubDirs) $(LibLinkOpts)
400 $(LIBNAME_AO): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
401 @echo ======= Linking $(LIBRARYNAME) release library =======
403 $(VERB) $(AR) $@ $(ObjectsO) $(LibSubDirs)
405 $(LIBNAME_AP): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
406 @echo ======= Linking $(LIBRARYNAME) profile library =======
408 $(VERB) $(AR) $@ $(ObjectsP) $(LibSubDirs)
410 $(LIBNAME_AG): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
411 @echo ======= Linking $(LIBRARYNAME) debug library =======
413 $(VERB) $(AR) $@ $(ObjectsG) $(LibSubDirs)
415 $(LIBNAME_OBJO): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
417 $(VERB) $(Relink) -o $@ $(ObjectsO) $(LibSubDirs)
419 $(LIBNAME_OBJP): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
421 $(VERB) $(Relink) -o $@ $(ObjectsP) $(LibSubDirs)
423 $(LIBNAME_OBJG): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
425 $(VERB) $(Relink) -o $@ $(ObjectsG) $(LibSubDirs)
429 #------------------------------------------------------------------------
430 # Create a TAGS database for emacs
431 #------------------------------------------------------------------------
435 etags -l c++ `find include lib tools -name '*.cpp' -o -name '*.h'`
439 #------------------------------------------------------------------------
440 # Handle the TOOLNAME option - used when building tool executables...
441 #------------------------------------------------------------------------
443 # The TOOLNAME option should be used with a USEDLIBS variable that tells the
444 # libraries (and the order of the libs) that should be linked to the
445 # tool. USEDLIBS should contain a list of library names (some with .a extension)
446 # that are automatically linked in as .o files unless the .a suffix is added.
450 # TOOLEXENAME* - These compute the output filenames to generate...
451 TOOLEXENAME_G := $(DESTTOOLDEBUG)/$(TOOLNAME)
452 TOOLEXENAME_O := $(DESTTOOLRELEASE)/$(TOOLNAME)
453 TOOLEXENAME_P := $(DESTTOOLPROFILE)/$(TOOLNAME)
454 TOOLEXENAMES := $(DESTTOOLCURRENT)/$(TOOLNAME)
456 # USED_LIBS_OPTIONS - Compute the options line that add -llib1 -llib2, etc.
457 PROJ_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
458 PROJ_LIBS_OPTIONS_G := $(patsubst %.o, $(PROJLIBDEBUGSOURCE)/%.o, $(PROJ_LIBS_OPTIONS))
459 PROJ_LIBS_OPTIONS_O := $(patsubst %.o, $(PROJLIBRELEASESOURCE)/%.o,$(PROJ_LIBS_OPTIONS))
460 PROJ_LIBS_OPTIONS_P := $(patsubst %.o, $(PROJLIBPROFILESOURCE)/%.o,$(PROJ_LIBS_OPTIONS))
462 LLVM_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
463 LLVM_LIBS_OPTIONS_G := $(patsubst %.o, $(LLVMLIBDEBUGSOURCE)/%.o, $(LLVM_LIBS_OPTIONS))
464 LLVM_LIBS_OPTIONS_O := $(patsubst %.o, $(LLVMLIBRELEASESOURCE)/%.o,$(LLVM_LIBS_OPTIONS))
465 LLVM_LIBS_OPTIONS_P := $(patsubst %.o, $(LLVMLIBPROFILESOURCE)/%.o,$(LLVM_LIBS_OPTIONS))
467 LIB_OPTS_G := $(LLVM_LIBS_OPTIONS_G) $(PROJ_LIBS_OPTIONS_G)
468 LIB_OPTS_O := $(LLVM_LIBS_OPTIONS_O) $(PROJ_LIBS_OPTIONS_O)
469 LIB_OPTS_P := $(LLVM_LIBS_OPTIONS_P) $(PROJ_LIBS_OPTIONS_P)
471 # USED_LIB_PATHS - Compute the path of the libraries used so that tools are
472 # rebuilt if libraries change. This has to make sure to handle .a/.so and .o
475 STATICUSEDLIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
476 USED_LIB_PATHS_G := $(addprefix $(DESTLIBDEBUG)/, $(STATICUSEDLIBS))
477 USED_LIB_PATHS_O := $(addprefix $(DESTLIBRELEASE)/, $(STATICUSEDLIBS))
478 USED_LIB_PATHS_P := $(addprefix $(DESTLIBPROFILE)/, $(STATICUSEDLIBS))
479 LINK_OPTS := $(TOOLLINKOPTS) $(PLATFORMLINKOPTS)
486 # Tell make that we need to rebuild subdirectories before we can link the tool.
487 # This affects things like LLI which has library subdirectories.
488 $(USED_LIB_PATHS_G) $(USED_LIB_PATHS_O) $(USED_LIB_PATHS_P): \
489 $(addsuffix /.makeall, $(PARALLEL_DIRS))
491 all:: $(TOOLEXENAMES)
493 $(VERB) rm -f $(TOOLEXENAMES)
495 $(TOOLEXENAME_G): $(ObjectsG) $(USED_LIB_PATHS_G) $(DESTTOOLDEBUG)/.dir
496 @echo ======= Linking $(TOOLNAME) debug executable $(STRIP_WARN_MSG)=======
497 $(VERB) $(LinkG) -o $@ $(ObjectsG) $(LIB_OPTS_G) $(LINK_OPTS)
499 $(TOOLEXENAME_O): $(ObjectsO) $(USED_LIB_PATHS_O) $(DESTTOOLRELEASE)/.dir
500 @echo ======= Linking $(TOOLNAME) release executable =======
501 $(VERB) $(LinkO) -o $@ $(ObjectsO) $(LIB_OPTS_O) $(LINK_OPTS)
503 $(TOOLEXENAME_P): $(ObjectsP) $(USED_LIB_PATHS_P) $(DESTTOOLPROFILE)/.dir
504 @echo ======= Linking $(TOOLNAME) profile executable =======
505 $(VERB) $(LinkP) -o $@ $(ObjectsP) $(LIB_OPTS_P) $(LINK_OPTS)
511 #---------------------------------------------------------
512 .PRECIOUS: $(BUILD_OBJ_DIR)/Depend/.dir
513 .PRECIOUS: $(BUILD_OBJ_DIR)/Debug/.dir $(BUILD_OBJ_DIR)/Release/.dir
515 # Create .o files in the ObjectFiles directory from the .cpp and .c files...
516 $(BUILD_OBJ_DIR)/Release/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Release/.dir
518 $(VERB) $(CompileO) $< -o $@
520 $(BUILD_OBJ_DIR)/Release/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Release/.dir
521 $(VERB) $(CompileCO) $< -o $@
523 $(BUILD_OBJ_DIR)/Profile/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Profile/.dir
525 $(VERB) $(CompileP) $< -o $@
527 $(BUILD_OBJ_DIR)/Profile/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Profile/.dir
529 $(VERB) $(CompileCP) $< -o $@
531 $(BUILD_OBJ_DIR)/Debug/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Debug/.dir
533 $(VERB) $(CompileG) $< -o $@
535 $(BUILD_OBJ_DIR)/Debug/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Debug/.dir
536 $(VERB) $(CompileCG) $< -o $@
539 # Rules for building lex/yacc files
541 LEX_FILES = $(filter %.l, $(Source))
542 LEX_OUTPUT = $(LEX_FILES:%.l=%.cpp)
543 YACC_FILES = $(filter %.y, $(Source))
544 YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output)
545 .PRECIOUS: $(LEX_OUTPUT) $(YACC_OUTPUT)
547 # Create a .cpp source file from a flex input file... this uses sed to cut down
548 # on the warnings emited by GCC...
550 # The last line is a gross hack to work around flex aparently not being able to
551 # resize the buffer on a large token input. Currently, for uninitialized string
552 # buffers in LLVM we can generate very long tokens, so this is a hack around it.
553 # FIXME. (f.e. char Buffer[10000]; )
556 $(FLEX) -t $< | sed '/^find_rule/d' | \
557 sed 's/void yyunput/inline void yyunput/' | \
558 sed 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
559 sed 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' > $@
561 # Rule for building the bison parsers...
562 %.c: %.y # Cancel built-in rules for yacc
563 %.h: %.y # Cancel built-in rules for yacc
565 @echo Bison\'ing $<...
566 $(VERB) $(BISON) -v -d -p $(<:%Parser.y=%) $*.y
567 $(VERB) mv -f $*.tab.c $*.cpp
568 $(VERB) mv -f $*.tab.h $*.h
570 # To create the directories...
575 # To create postscript files from dot files...
579 # 'make clean' nukes the tree
581 $(VERB) rm -rf $(BUILD_OBJ_DIR)/Debug $(BUILD_OBJ_DIR)/Release $(BUILD_OBJ_DIR)/Profile $(BUILD_OBJ_DIR)/Depend
582 $(VERB) rm -f core core.[0-9][0-9]* *.o *.d *.so *~ *.flc
583 $(VERB) rm -f $(LEX_OUTPUT) $(YACC_OUTPUT)
585 # If dependencies were generated for the file that included this file,
586 # include the dependancies now...
588 SourceBaseNames := $(basename $(notdir $(filter-out Debug/%, $(Source))))
589 SourceDepend := $(SourceBaseNames:%=$(BUILD_OBJ_DIR)/Depend/%.d)
591 # Create dependencies for the *.cpp files...
593 $(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Depend/.dir
594 $(VERB) $(Depend) $< | sed 's|$*\.o *|$(BUILD_OBJ_DIR)/Release/& $(BUILD_OBJ_DIR)/Profile/& $(BUILD_OBJ_DIR)/Debug/& $(BUILD_OBJ_DIR)/Depend/$(@F)|g' > $@
596 # Create dependencies for the *.c files...
598 $(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Depend/.dir
599 $(VERB) $(DependC) $< | sed 's|$*\.o *|Release/& Profile/& Debug/& Depend/$(@F)|g' > $@
601 ifneq ($(SourceDepend),)
602 -include $(SourceDepend)