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)
79 # If we have a home directory, append our offset from it to OBJ_ROOT.
80 # This will "emulate" the previous behavior while not breaking builds
81 # in which there is no home directory.
84 OBJ_ROOT := $(OBJ_ROOT)$(patsubst $(HOME)%,%,$(BUILD_SRC_ROOT))
86 OBJ_ROOT := $(OBJ_ROOT)/$(shell basename $(BUILD_SRC_ROOT))
90 # Set the object build directory. Its location depends upon the source path
91 # and where object files should go.
95 BUILD_OBJ_DIR = $(shell pwd)
97 BUILD_OBJ_DIR := $(OBJ_ROOT)$(patsubst $(BUILD_SRC_ROOT)%,%,$(shell cd $(BUILD_SRC_DIR); pwd))
102 # Set the root of the object directory.
104 ifndef BUILD_OBJ_ROOT
106 BUILD_OBJ_ROOT = $(shell cd $(LEVEL); pwd)
108 BUILD_OBJ_ROOT := $(OBJ_ROOT)$(patsubst $(BUILD_SRC_ROOT)%,%,$(shell cd $(BUILD_SRC_ROOT); pwd))
113 # Set the LLVM source directory.
114 # It is typically the root directory of what we're compiling now.
117 LLVM_SRC_ROOT = $(BUILD_SRC_ROOT)
121 # Set the LLVM object directory.
124 LLVM_OBJ_ROOT = $(BUILD_OBJ_ROOT)
127 # Figure out how to do platform specific stuff on this platform. This is really
128 # gross and should be autoconfiscated (automake actually), but should hopefully
129 # work on Linux and solaris (SunOS).
131 UNAME := $(shell uname)
132 include $(LLVM_SRC_ROOT)/Makefile.$(UNAME)
135 # if SHARED_LIBRARY is specified, the default is to build the dynamic lib
139 # Default Rule: Make sure it's also a :: rule
142 # Default for install is to at least build everything...
145 # Default rule for test. It ensures everything has a test rule
149 echo "LLVM Source Root : $(LLVM_SRC_ROOT)"; \
150 echo "LLVM Object Root : $(LLVM_OBJ_ROOT)"; \
151 echo "Build Source Root : $(BUILD_SRC_ROOT)"; \
152 echo "Build Source Directory : $(BUILD_SRC_DIR)"; \
153 echo "Build Object Root : $(BUILD_OBJ_ROOT)"; \
154 echo "Build Object Directory : $(BUILD_OBJ_DIR)";
156 #--------------------------------------------------------------------
157 # Variables derived from configuration options...
158 #--------------------------------------------------------------------
160 #BinInstDir=/usr/local/bin
161 #LibInstDir=/usr/local/lib/xxx
162 #DocInstDir=/usr/doc/xxx
166 PURIFY := $(PURIFY) -cache-dir="$(BUILD_OBJ_ROOT)/../purifycache" -chain-length="30" -messages=all
168 ifdef ENABLE_PROFILING
170 CONFIGURATION := Profile
172 ifdef ENABLE_OPTIMIZED
173 CONFIGURATION := Release
175 CONFIGURATION := Debug
179 ###########################################################################
181 # These variables describe various library locations:
183 # DEST* = Location of where libraries that are built will be placed.
184 # LLVM* = Location of LLVM libraries used for linking.
185 # PROJ* = Location of previously built libraries used for linking.
186 ###########################################################################
188 # Libraries that are being built
189 DESTLIBDEBUG := $(BUILD_OBJ_ROOT)/lib/Debug
190 DESTLIBRELEASE := $(BUILD_OBJ_ROOT)/lib/Release
191 DESTLIBPROFILE := $(BUILD_OBJ_ROOT)/lib/Profile
192 DESTLIBCURRENT := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
194 # LLVM libraries used for linking
195 LLVMLIBDEBUGSOURCE := $(LLVM_OBJ_ROOT)/lib/Debug
196 LLVMLIBRELEASESOURCE := $(LLVM_OBJ_ROOT)/lib/Release
197 LLVMLIBPROFILESOURCE := $(LLVM_OBJ_ROOT)/lib/Profile
198 LLVMLIBCURRENTSOURCE := $(LLVM_OBJ_ROOT)/lib/$(CONFIGURATION)
200 # Libraries that were built that will now be used for linking
201 PROJLIBDEBUGSOURCE := $(BUILD_OBJ_ROOT)/lib/Debug
202 PROJLIBRELEASESOURCE := $(BUILD_OBJ_ROOT)/lib/Release
203 PROJLIBPROFILESOURCE := $(BUILD_OBJ_ROOT)/lib/Profile
204 PROJLIBCURRENTSOURCE := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
206 ###########################################################################
208 # These variables describe various tool locations:
210 # DEST* = Location of where tools that are built will be placed.
211 # LLVM* = Location of LLVM tools used for building.
212 # PROJ* = Location of previously built tools used for linking.
213 ###########################################################################
215 DESTTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug
216 DESTTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release
217 DESTTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile
218 DESTTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
220 LLVMTOOLDEBUG := $(LLVM_OBJ_ROOT)/tools/Debug
221 LLVMTOOLRELEASE := $(LLVM_OBJ_ROOT)/tools/Release
222 LLVMTOOLPROFILE := $(LLVM_OBJ_ROOT)/tools/Profile
223 LLVMTOOLCURRENT := $(LLVM_OBJ_ROOT)/tools/$(CONFIGURATION)
225 PROJTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug
226 PROJTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release
227 PROJTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile
228 PROJTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
235 #---------------------------------------------------------
236 # Compilation options...
237 #---------------------------------------------------------
239 ###########################################################################
240 # Special tools used while building the LLVM tree. Burg is built as part of the
242 ###########################################################################
243 BURG := $(LLVMTOOLCURRENT)/burg
244 RunBurg := $(BURG) $(BURG_OPTS)
246 TBLGEN := $(LLVMTOOLCURRENT)/tblgen
248 # Enable this for profiling support with 'gprof'
249 # This automatically enables optimized builds.
250 ifdef ENABLE_PROFILING
254 ###########################################################################
256 ###########################################################################
259 # Include both the project headers and the LLVM headers for compilation
261 CPPFLAGS += -I$(BUILD_SRC_ROOT)/include -I$(LLVM_SRC_ROOT)/include
263 # By default, strip symbol information from executable
265 STRIP = $(PLATFORMSTRIPOPTS)
266 STRIP_WARN_MSG = "(without symbols) "
269 # Allow gnu extensions...
270 CPPFLAGS += -D_GNU_SOURCE
272 # -Wno-unused-parameter
273 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include
274 CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions -fshort-enums
276 # Compile a cpp file, don't link...
277 Compile := $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
278 CompileG := $(Compile) -g -D_DEBUG
279 CompileO := $(Compile) $(CompileOptimizeOpts) -felide-constructors -fomit-frame-pointer
280 CompileP := $(Compile) $(CompileOptimizeOpts) -felide-constructors $(PROFILE)
282 # Compile a c file, don't link...
283 CompileC := $(CC) -c $(CPPFLAGS) $(CCFLAGS) $(CompileCommonOpts)
284 CompileCG := $(CompileC) -g -D_DEBUG
285 CompileCO := $(CompileC) $(CompileOptimizeOpts) -fomit-frame-pointer
286 CompileCP := $(CompileC) $(CompileOptimizeOpts) $(PROFILE)
289 # Link final executable
291 ifdef ENABLE_PURIFY # To enable purify, build with 'gmake ENABLE_PURIFY=1'
292 Link := $(PURIFY) $(CXX) -static
298 # include both projlib source and llvmlib source
299 LinkG := $(Link) -g -L$(PROJLIBDEBUGSOURCE) -L$(LLVMLIBDEBUGSOURCE) $(STRIP)
300 LinkO := $(Link) -O3 -L$(PROJLIBRELEASESOURCE) -L$(LLVMLIBRELEASESOURCE)
301 LinkP := $(Link) -O3 -L$(PROJLIBPROFILESOURCE) -L$(LLVMLIBPROFILESOURCE) $(PROFILE)
303 LinkG := $(Link) -g -L$(LLVMLIBDEBUGSOURCE) $(STRIP)
304 LinkO := $(Link) -O3 -L$(LLVMLIBRELEASESOURCE)
305 LinkP := $(Link) -O3 -L$(LLVMLIBPROFILESOURCE) $(PROFILE)
310 # Create one .o file from a bunch of .o files...
313 # MakeSO - Create a .so file from a .o files...
314 MakeSO := $(CXX) $(MakeSharedObjectOption)
315 MakeSOO := $(MakeSO) -O3
316 MakeSOP := $(MakeSOO) $(PROFILE)
318 # Create dependancy file from CPP file, send to stdout.
319 Depend := $(CXX) -MM -I$(LEVEL)/include $(CPPFLAGS)
320 DependC := $(CC) -MM -I$(LEVEL)/include $(CPPFLAGS)
322 # Archive a bunch of .o files into a .a file...
325 #----------------------------------------------------------
327 # Source includes all of the cpp files, and objects are derived from the
329 # The local Makefile can list other Source files via ExtraSource = ...
332 Source := $(ExtraSource) $(wildcard *.cpp *.c *.y *.l)
335 Objs := $(sort $(patsubst Debug/%.o, %.o, $(addsuffix .o,$(notdir $(basename $(Source))))))
336 ObjectsO := $(addprefix $(BUILD_OBJ_DIR)/Release/,$(Objs))
337 ObjectsP := $(addprefix $(BUILD_OBJ_DIR)/Profile/,$(Objs))
338 ObjectsG := $(addprefix $(BUILD_OBJ_DIR)/Debug/,$(Objs))
341 #---------------------------------------------------------
342 # Handle the DIRS and PARALLEL_DIRS options
343 #---------------------------------------------------------
346 all install clean test ::
347 $(VERB) for dir in ${DIRS}; do \
348 (cd $$dir; $(MAKE) $@) || exit 1; \
352 # Handle PARALLEL_DIRS
354 all :: $(addsuffix /.makeall , $(PARALLEL_DIRS))
355 install :: $(addsuffix /.makeinstall, $(PARALLEL_DIRS))
356 clean :: $(addsuffix /.makeclean , $(PARALLEL_DIRS))
357 test :: $(addsuffix /.maketest , $(PARALLEL_DIRS))
359 %/.makeall %/.makeinstall %/.makeclean %/.maketest:
360 $(VERB) cd $(@D); $(MAKE) $(subst $(@D)/.make,,$@)
363 #---------------------------------------------------------
364 # Handle the LIBRARYNAME option - used when building libs...
365 #---------------------------------------------------------
367 # When libraries are built, they are allowed to optionally define the
368 # DONT_BUILD_RELINKED make variable, which, when defined, prevents a .o file
369 # from being built for the library. This .o files may then be linked to by a
370 # tool if the tool does not need (or want) the semantics a .a file provides
371 # (linking in only object files that are "needed"). If a library is never to
372 # be used in this way, it is better to define DONT_BUILD_RELINKED, and define
373 # BUILD_ARCHIVE instead.
375 # Some libraries must be built as .a files (libscalar for example) because if
376 # it's built as a .o file, then all of the constituent .o files in it will be
377 # linked into tools (for example gccas) even if they only use one of the parts
378 # of it. For this reason, sometimes it's useful to use libraries as .a files.
382 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
383 LIBRARYNAME := $(strip $(LIBRARYNAME))
385 LIBNAME_O := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).so
386 LIBNAME_P := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).so
387 LIBNAME_G := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).so
388 LIBNAME_AO := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).a
389 LIBNAME_AP := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).a
390 LIBNAME_AG := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).a
391 LIBNAME_OBJO := $(DESTLIBRELEASE)/$(LIBRARYNAME).o
392 LIBNAME_OBJP := $(DESTLIBPROFILE)/$(LIBRARYNAME).o
393 LIBNAME_OBJG := $(DESTLIBDEBUG)/$(LIBRARYNAME).o
395 # dynamic target builds a shared object version of the library...
396 dynamic:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).so
398 # Does the library want a .o version built?
399 ifndef DONT_BUILD_RELINKED
400 all:: $(DESTLIBCURRENT)/$(LIBRARYNAME).o
403 # Does the library want an archive version built?
405 all:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).a
408 $(LIBNAME_O): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
409 @echo ======= Linking $(LIBRARYNAME) release library =======
410 $(VERB) $(MakeSOO) -o $@ $(ObjectsO) $(LibSubDirs) $(LibLinkOpts)
412 $(LIBNAME_P): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
413 @echo ======= Linking $(LIBRARYNAME) profile library =======
414 $(VERB) $(MakeSOP) -o $@ $(ObjectsP) $(LibSubDirs) $(LibLinkOpts)
416 $(LIBNAME_G): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
417 @echo ======= Linking $(LIBRARYNAME) debug library =======
418 $(VERB) $(MakeSO) -g -o $@ $(ObjectsG) $(LibSubDirs) $(LibLinkOpts)
420 $(LIBNAME_AO): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
421 @echo ======= Linking $(LIBRARYNAME) release library =======
423 $(VERB) $(AR) $@ $(ObjectsO) $(LibSubDirs)
425 $(LIBNAME_AP): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
426 @echo ======= Linking $(LIBRARYNAME) profile library =======
428 $(VERB) $(AR) $@ $(ObjectsP) $(LibSubDirs)
430 $(LIBNAME_AG): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
431 @echo ======= Linking $(LIBRARYNAME) debug library =======
433 $(VERB) $(AR) $@ $(ObjectsG) $(LibSubDirs)
435 $(LIBNAME_OBJO): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
437 $(VERB) $(Relink) -o $@ $(ObjectsO) $(LibSubDirs)
439 $(LIBNAME_OBJP): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
441 $(VERB) $(Relink) -o $@ $(ObjectsP) $(LibSubDirs)
443 $(LIBNAME_OBJG): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
445 $(VERB) $(Relink) -o $@ $(ObjectsG) $(LibSubDirs)
449 #------------------------------------------------------------------------
450 # Create a TAGS database for emacs
451 #------------------------------------------------------------------------
455 etags -l c++ `find include lib tools -name '*.cpp' -o -name '*.h'`
459 #------------------------------------------------------------------------
460 # Handle the TOOLNAME option - used when building tool executables...
461 #------------------------------------------------------------------------
463 # The TOOLNAME option should be used with a USEDLIBS variable that tells the
464 # libraries (and the order of the libs) that should be linked to the
465 # tool. USEDLIBS should contain a list of library names (some with .a extension)
466 # that are automatically linked in as .o files unless the .a suffix is added.
470 # TOOLEXENAME* - These compute the output filenames to generate...
471 TOOLEXENAME_G := $(DESTTOOLDEBUG)/$(TOOLNAME)
472 TOOLEXENAME_O := $(DESTTOOLRELEASE)/$(TOOLNAME)
473 TOOLEXENAME_P := $(DESTTOOLPROFILE)/$(TOOLNAME)
474 TOOLEXENAMES := $(DESTTOOLCURRENT)/$(TOOLNAME)
476 # USED_LIBS_OPTIONS - Compute the options line that add -llib1 -llib2, etc.
477 PROJ_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
478 PROJ_LIBS_OPTIONS_G := $(patsubst %.o, $(PROJLIBDEBUGSOURCE)/%.o, $(PROJ_LIBS_OPTIONS))
479 PROJ_LIBS_OPTIONS_O := $(patsubst %.o, $(PROJLIBRELEASESOURCE)/%.o,$(PROJ_LIBS_OPTIONS))
480 PROJ_LIBS_OPTIONS_P := $(patsubst %.o, $(PROJLIBPROFILESOURCE)/%.o,$(PROJ_LIBS_OPTIONS))
482 LLVM_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
483 LLVM_LIBS_OPTIONS_G := $(patsubst %.o, $(LLVMLIBDEBUGSOURCE)/%.o, $(LLVM_LIBS_OPTIONS))
484 LLVM_LIBS_OPTIONS_O := $(patsubst %.o, $(LLVMLIBRELEASESOURCE)/%.o,$(LLVM_LIBS_OPTIONS))
485 LLVM_LIBS_OPTIONS_P := $(patsubst %.o, $(LLVMLIBPROFILESOURCE)/%.o,$(LLVM_LIBS_OPTIONS))
487 LIB_OPTS_G := $(LLVM_LIBS_OPTIONS_G) $(PROJ_LIBS_OPTIONS_G)
488 LIB_OPTS_O := $(LLVM_LIBS_OPTIONS_O) $(PROJ_LIBS_OPTIONS_O)
489 LIB_OPTS_P := $(LLVM_LIBS_OPTIONS_P) $(PROJ_LIBS_OPTIONS_P)
491 # USED_LIB_PATHS - Compute the path of the libraries used so that tools are
492 # rebuilt if libraries change. This has to make sure to handle .a/.so and .o
495 STATICUSEDLIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
496 USED_LIB_PATHS_G := $(addprefix $(DESTLIBDEBUG)/, $(STATICUSEDLIBS))
497 USED_LIB_PATHS_O := $(addprefix $(DESTLIBRELEASE)/, $(STATICUSEDLIBS))
498 USED_LIB_PATHS_P := $(addprefix $(DESTLIBPROFILE)/, $(STATICUSEDLIBS))
499 LINK_OPTS := $(TOOLLINKOPTS) $(PLATFORMLINKOPTS)
506 # Tell make that we need to rebuild subdirectories before we can link the tool.
507 # This affects things like LLI which has library subdirectories.
508 $(USED_LIB_PATHS_G) $(USED_LIB_PATHS_O) $(USED_LIB_PATHS_P): \
509 $(addsuffix /.makeall, $(PARALLEL_DIRS))
511 all:: $(TOOLEXENAMES)
513 $(VERB) rm -f $(TOOLEXENAMES)
515 $(TOOLEXENAME_G): $(ObjectsG) $(USED_LIB_PATHS_G) $(DESTTOOLDEBUG)/.dir
516 @echo ======= Linking $(TOOLNAME) debug executable $(STRIP_WARN_MSG)=======
517 $(VERB) $(LinkG) -o $@ $(ObjectsG) $(LIB_OPTS_G) $(LINK_OPTS)
519 $(TOOLEXENAME_O): $(ObjectsO) $(USED_LIB_PATHS_O) $(DESTTOOLRELEASE)/.dir
520 @echo ======= Linking $(TOOLNAME) release executable =======
521 $(VERB) $(LinkO) -o $@ $(ObjectsO) $(LIB_OPTS_O) $(LINK_OPTS)
523 $(TOOLEXENAME_P): $(ObjectsP) $(USED_LIB_PATHS_P) $(DESTTOOLPROFILE)/.dir
524 @echo ======= Linking $(TOOLNAME) profile executable =======
525 $(VERB) $(LinkP) -o $@ $(ObjectsP) $(LIB_OPTS_P) $(LINK_OPTS)
531 #---------------------------------------------------------
532 .PRECIOUS: $(BUILD_OBJ_DIR)/Depend/.dir
533 .PRECIOUS: $(BUILD_OBJ_DIR)/Debug/.dir $(BUILD_OBJ_DIR)/Release/.dir
535 # Create .o files in the ObjectFiles directory from the .cpp and .c files...
536 $(BUILD_OBJ_DIR)/Release/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Release/.dir
538 $(VERB) $(CompileO) $< -o $@
540 $(BUILD_OBJ_DIR)/Release/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Release/.dir
541 $(VERB) $(CompileCO) $< -o $@
543 $(BUILD_OBJ_DIR)/Profile/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Profile/.dir
545 $(VERB) $(CompileP) $< -o $@
547 $(BUILD_OBJ_DIR)/Profile/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Profile/.dir
549 $(VERB) $(CompileCP) $< -o $@
551 $(BUILD_OBJ_DIR)/Debug/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Debug/.dir
553 $(VERB) $(CompileG) $< -o $@
555 $(BUILD_OBJ_DIR)/Debug/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Debug/.dir
556 $(VERB) $(CompileCG) $< -o $@
559 # Rules for building lex/yacc files
561 LEX_FILES = $(filter %.l, $(Source))
562 LEX_OUTPUT = $(LEX_FILES:%.l=%.cpp)
563 YACC_FILES = $(filter %.y, $(Source))
564 YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output)
565 .PRECIOUS: $(LEX_OUTPUT) $(YACC_OUTPUT)
567 # Create a .cpp source file from a flex input file... this uses sed to cut down
568 # on the warnings emited by GCC...
570 # The last line is a gross hack to work around flex aparently not being able to
571 # resize the buffer on a large token input. Currently, for uninitialized string
572 # buffers in LLVM we can generate very long tokens, so this is a hack around it.
573 # FIXME. (f.e. char Buffer[10000]; )
576 $(FLEX) -t $< | sed '/^find_rule/d' | \
577 sed 's/void yyunput/inline void yyunput/' | \
578 sed 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
579 sed 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' > $@
581 # Rule for building the bison parsers...
582 %.c: %.y # Cancel built-in rules for yacc
583 %.h: %.y # Cancel built-in rules for yacc
585 @echo Bison\'ing $<...
586 $(VERB) $(BISON) -v -d -p $(<:%Parser.y=%) $*.y
587 $(VERB) mv -f $*.tab.c $*.cpp
588 $(VERB) mv -f $*.tab.h $*.h
590 # To create the directories...
595 # To create postscript files from dot files...
599 # 'make clean' nukes the tree
601 $(VERB) rm -rf $(BUILD_OBJ_DIR)/Debug $(BUILD_OBJ_DIR)/Release $(BUILD_OBJ_DIR)/Profile $(BUILD_OBJ_DIR)/Depend
602 $(VERB) rm -f core core.[0-9][0-9]* *.o *.d *.so *~ *.flc
603 $(VERB) rm -f $(LEX_OUTPUT) $(YACC_OUTPUT)
605 # If dependencies were generated for the file that included this file,
606 # include the dependancies now...
608 SourceBaseNames := $(basename $(notdir $(filter-out Debug/%, $(Source))))
609 SourceDepend := $(SourceBaseNames:%=$(BUILD_OBJ_DIR)/Depend/%.d)
611 # Create dependencies for the *.cpp files...
613 $(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Depend/.dir
614 $(VERB) $(Depend) $< | sed 's|$*\.o *|$(BUILD_OBJ_DIR)/Release/& $(BUILD_OBJ_DIR)/Profile/& $(BUILD_OBJ_DIR)/Debug/& $(BUILD_OBJ_DIR)/Depend/$(@F)|g' > $@
616 # Create dependencies for the *.c files...
618 $(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Depend/.dir
619 $(VERB) $(DependC) $< | sed 's|$*\.o *|Release/& Profile/& Debug/& Depend/$(@F)|g' > $@
621 ifneq ($(SourceDepend),)
622 -include $(SourceDepend)