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. LLVM_SRC_ROOT - If specified, points to the top of the LLVM source tree.
35 # 7. LLVM_OBJ_ROOT - If specified, points to the top directory where LLVM
36 # object files are placed.
38 # 8. BUILD_SRC_DIR - The directory which contains the current set of Makefiles
39 # and usually the source code too (unless SourceDir is set).
41 # 9. BUILD_SRC_ROOT - The root directory of the source code being compiled.
43 # 10. BUILD_OBJ_DIR - The directory where object code should be placed.
45 # 11. BUILD_OBJ_ROOT - The root directory for where object code should be
49 # LLVM, LLVM_SRC_ROOT = BUILD_SRC_ROOT, and
50 # LLVM_OBJ_ROOT = BUILD_OBJ_ROOT.
51 #===-----------------------------------------------------------------------====
54 # Configuration file to set paths specific to local installation of LLVM
56 include $(LEVEL)/Makefile.config
58 ###########################################################################
59 # Directory Configuration
60 # This section of the Makefile determines what is where. To be
61 # specific, there are several locations that need to be defined:
63 # o LLVM_SRC_ROOT : The root directory of the LLVM source code.
64 # o LLVM_OBJ_ROOT : The root directory containing the built LLVM code.
66 # o BUILD_SRC_DIR : The directory containing the code to build.
67 # o BUILD_SRC_ROOT : The root directory of the code to build.
69 # o BUILD_OBJ_DIR : The directory in which compiled code will be placed.
70 # o BUILD_OBJ_ROOT : The root directory in which compiled code is placed.
72 ###########################################################################
75 # Set the source build directory. That is almost always the current directory.
78 BUILD_SRC_DIR = $(shell pwd)
82 # Set the source root directory.
85 BUILD_SRC_ROOT = $(shell cd $(BUILD_SRC_DIR)/$(LEVEL); pwd)
89 # Determine the path of the source tree relative from $HOME (the mythical
92 HOME_OBJ_ROOT := $(OBJ_ROOT)$(patsubst $(HOME)%,%,$(BUILD_SRC_ROOT))
95 # Set the object build directory. Its location depends upon the source path
96 # and where object files should go.
100 BUILD_OBJ_DIR = $(BUILD_SRC_DIR)
102 BUILD_OBJ_DIR := $(HOME_OBJ_ROOT)$(patsubst $(BUILD_SRC_ROOT)%,%,$(BUILD_SRC_DIR))
107 # Set the root of the object directory.
109 ifndef BUILD_OBJ_ROOT
111 BUILD_OBJ_ROOT = $(BUILD_SRC_ROOT)
113 BUILD_OBJ_ROOT := $(HOME_OBJ_ROOT)
118 # Set the LLVM source directory.
119 # It is typically the root directory of what we're compiling now.
122 LLVM_SRC_ROOT = $(BUILD_SRC_ROOT)
126 # Set the LLVM object directory.
129 LLVM_OBJ_ROOT = $(BUILD_OBJ_ROOT)
132 ###########################################################################
134 # The following targets are the standard top level targets for
136 ###########################################################################
139 # if SHARED_LIBRARY is specified, the default is to build the dynamic lib
143 # Default Rule: Make sure it's also a :: rule
146 # Default for install is to at least build everything...
149 # Default rule for test. It ensures everything has a test rule
152 # Default rule for building only bytecode.
155 # Print out the directories used for building
157 echo "Home Offset : " $(HOME_OBJ_ROOT);
158 echo "Build Source Root: " $(BUILD_SRC_ROOT);
159 echo "Build Source Dir : " $(BUILD_SRC_DIR);
160 echo "Build Object Root: " $(BUILD_OBJ_ROOT);
161 echo "Build Object Dir : " $(BUILD_OBJ_DIR);
162 echo "LLVM Source Root: " $(LLVM_SRC_ROOT);
163 echo "LLVM Object Root: " $(LLVM_OBJ_ROOT);
165 ###########################################################################
166 # Miscellaneous paths and commands:
167 # This section defines various configuration macros, such as where
168 # to find burg, tblgen, and libtool.
169 ###########################################################################
171 #--------------------------------------------------------------------
172 # Variables derived from configuration options...
173 #--------------------------------------------------------------------
175 #BinInstDir=/usr/local/bin
176 #LibInstDir=/usr/local/lib/xxx
177 #DocInstDir=/usr/doc/xxx
181 PURIFY := $(PURIFY) -cache-dir="$(BUILD_OBJ_ROOT)/../purifycache" -chain-length="30" -messages=all
183 ifdef ENABLE_PROFILING
185 CONFIGURATION := Profile
187 ifdef ENABLE_OPTIMIZED
188 CONFIGURATION := Release
190 CONFIGURATION := Debug
195 # Enable this for profiling support with 'gprof'
196 # This automatically enables optimized builds.
198 ifdef ENABLE_PROFILING
203 # Suffixes for library compilation rules
207 ###########################################################################
209 # These variables describe various library locations:
211 # DEST* = Location of where libraries that are built will be placed.
212 # LLVM* = Location of LLVM libraries used for linking.
213 # PROJ* = Location of previously built libraries used for linking.
214 ###########################################################################
216 # Libraries that are being built
217 DESTLIBDEBUG := $(BUILD_OBJ_ROOT)/lib/Debug
218 DESTLIBRELEASE := $(BUILD_OBJ_ROOT)/lib/Release
219 DESTLIBPROFILE := $(BUILD_OBJ_ROOT)/lib/Profile
220 DESTLIBCURRENT := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
222 # LLVM libraries used for linking
223 LLVMLIBDEBUGSOURCE := $(LLVM_OBJ_ROOT)/lib/Debug
224 LLVMLIBRELEASESOURCE := $(LLVM_OBJ_ROOT)/lib/Release
225 LLVMLIBPROFILESOURCE := $(LLVM_OBJ_ROOT)/lib/Profile
226 LLVMLIBCURRENTSOURCE := $(LLVM_OBJ_ROOT)/lib/$(CONFIGURATION)
228 # Libraries that were built that will now be used for linking
229 PROJLIBDEBUGSOURCE := $(BUILD_OBJ_ROOT)/lib/Debug
230 PROJLIBRELEASESOURCE := $(BUILD_OBJ_ROOT)/lib/Release
231 PROJLIBPROFILESOURCE := $(BUILD_OBJ_ROOT)/lib/Profile
232 PROJLIBCURRENTSOURCE := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
234 ###########################################################################
236 # These variables describe various tool locations:
238 # DEST* = Location of where tools that are built will be placed.
239 # LLVM* = Location of LLVM tools used for building.
240 # PROJ* = Location of previously built tools used for linking.
241 ###########################################################################
243 DESTTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug
244 DESTTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release
245 DESTTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile
246 DESTTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
248 LLVMTOOLDEBUG := $(LLVM_OBJ_ROOT)/tools/Debug
249 LLVMTOOLRELEASE := $(LLVM_OBJ_ROOT)/tools/Release
250 LLVMTOOLPROFILE := $(LLVM_OBJ_ROOT)/tools/Profile
251 LLVMTOOLCURRENT := $(LLVM_OBJ_ROOT)/tools/$(CONFIGURATION)
253 PROJTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug
254 PROJTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release
255 PROJTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile
256 PROJTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
259 # Libtool is found in the current directory.
262 LIBTOOL=$(LLVM_SRC_ROOT)/libtool
264 LIBTOOL=$(LLVM_SRC_ROOT)/libtool --silent
274 ###########################################################################
275 # Miscellaneous paths and commands (part deux):
276 # This section defines various configuration macros, such as where
277 # to find burg, tblgen, and libtool.
278 ###########################################################################
280 #--------------------------------------------------------------------------
281 # Special tools used while building the LLVM tree. Burg is built as part
282 # of the utils directory.
283 #--------------------------------------------------------------------------
284 BURG := $(LLVMTOOLCURRENT)/burg
285 RunBurg := $(BURG) $(BURG_OPTS)
287 TBLGEN := $(LLVMTOOLCURRENT)/tblgen
290 ###########################################################################
292 ###########################################################################
295 # Include both the project headers and the LLVM headers for compilation and
296 # dependency computation.
298 CPPFLAGS += -I$(BUILD_SRC_ROOT)/include -I$(LLVM_SRC_ROOT)/include
300 # By default, strip symbol information from executable
302 STRIP = $(PLATFORMSTRIPOPTS)
303 STRIP_WARN_MSG = "(without symbols)"
306 # Allow gnu extensions...
307 CPPFLAGS += -D_GNU_SOURCE
309 # -Wno-unused-parameter
310 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include
311 CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions -fshort-enums
314 # Compile commands with libtool.
316 Compile := $(LIBTOOL) --mode=compile $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
317 CompileC := $(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CCFLAGS) $(CompileCommonOpts)
320 # Add the LLVM specific "-only-static" option so that we only compile .o files
321 # once when not building a shared library.
323 # For shared libraries, we will end up building twice, but that doesn't happen
324 # very often, so we'll let it go.
326 ifndef SHARED_LIBRARY
327 Compile := $(Compile) -only-static
328 CompileC := $(CompileC) -only-static
331 # Compile a cpp file, don't link...
332 CompileG := $(Compile) -g -D_DEBUG
333 CompileO := $(Compile) $(CompileOptimizeOpts) -felide-constructors -fomit-frame-pointer
334 CompileP := $(Compile) $(CompileOptimizeOpts) -felide-constructors $(PROFILE)
336 # Compile a c file, don't link...
337 CompileCG := $(CompileC) -g -D_DEBUG
338 CompileCO := $(CompileC) $(CompileOptimizeOpts) -fomit-frame-pointer
339 CompileCP := $(CompileC) $(CompileOptimizeOpts) $(PROFILE)
341 ###########################################################################
343 ###########################################################################
346 # Link final executable
347 # (Note that we always link with the C++ compiler).
349 ifdef ENABLE_PURIFY # To enable purify, build with 'gmake ENABLE_PURIFY=1'
350 Link := $(PURIFY) $(LIBTOOL) --mode=link $(CXX) -static
352 Link := $(LIBTOOL) --mode=link $(CXX)
355 # link both projlib and llvmlib libraries
356 LinkG := $(Link) -g -L$(PROJLIBDEBUGSOURCE) -L$(LLVMLIBDEBUGSOURCE) $(STRIP)
357 LinkO := $(Link) -O3 -L$(PROJLIBRELEASESOURCE) -L$(LLVMLIBRELEASESOURCE)
358 LinkP := $(Link) -O3 -L$(PROJLIBPROFILESOURCE) -L$(LLVMLIBPROFILESOURCE) $(PROFILE)
360 # Create one .o file from a bunch of .o files...
361 Relink = ${LIBTOOL} --mode=link $(CXX)
363 # MakeSO - Create a .so file from a .o files...
364 #MakeSO := $(LIBTOOL) --mode=link $(CXX) $(MakeSharedObjectOption)
365 #MakeSOO := $(MakeSO) -O3
366 #MakeSOP := $(MakeSOO) $(PROFILE)
369 # Configure where the item being compiled should go.
372 Link := $(Link) -rpath $(DESTLIBCURRENT)
376 Link := $(Link) -rpath $(DESTTOOLCURRENT)
379 # Create dependancy file from CPP file, send to stdout.
380 Depend := $(CXX) -MM -I$(LEVEL)/include $(CPPFLAGS)
381 DependC := $(CC) -MM -I$(LEVEL)/include $(CPPFLAGS)
383 # Archive a bunch of .o files into a .a file...
386 #----------------------------------------------------------
388 # Source includes all of the cpp files, and objects are derived from the
390 # The local Makefile can list other Source files via ExtraSource = ...
393 Source := $(ExtraSource) $(wildcard *.cpp *.c *.y *.l)
396 Objs := $(sort $(patsubst Debug/%.lo, %.lo, $(addsuffix .lo,$(notdir $(basename $(Source))))))
397 ObjectsO := $(addprefix $(BUILD_OBJ_DIR)/Release/,$(Objs))
398 ObjectsP := $(addprefix $(BUILD_OBJ_DIR)/Profile/,$(Objs))
399 ObjectsG := $(addprefix $(BUILD_OBJ_DIR)/Debug/,$(Objs))
401 #---------------------------------------------------------
402 # Handle the DIRS and PARALLEL_DIRS options
403 #---------------------------------------------------------
406 all install clean test bytecode ::
407 $(VERB) for dir in ${DIRS}; do \
408 (cd $$dir; $(MAKE) $@) || exit 1; \
412 # Handle PARALLEL_DIRS
414 all :: $(addsuffix /.makeall , $(PARALLEL_DIRS))
415 install :: $(addsuffix /.makeinstall , $(PARALLEL_DIRS))
416 clean :: $(addsuffix /.makeclean , $(PARALLEL_DIRS))
417 test :: $(addsuffix /.maketest , $(PARALLEL_DIRS))
418 bytecode :: $(addsuffix /.makebytecode, $(PARALLEL_DIRS))
420 %/.makeall %/.makeinstall %/.makeclean %/.maketest %/.makebytecode:
421 $(VERB) cd $(@D); $(MAKE) $(subst $(@D)/.make,,$@)
424 # Handle directories that may or may not exist
426 all install clean test bytecode ::
427 $(VERB) for dir in ${OPTIONAL_DIRS}; do \
430 (cd $$dir; $(MAKE) $@) || exit 1; \
435 ###########################################################################
436 # Library Build Rules:
438 #---------------------------------------------------------
439 # Handle the LIBRARYNAME option - used when building libs...
440 #---------------------------------------------------------
442 # When libraries are built, they are allowed to optionally define the
443 # DONT_BUILD_RELINKED make variable, which, when defined, prevents a .o file
444 # from being built for the library. This .o files may then be linked to by a
445 # tool if the tool does not need (or want) the semantics a .a file provides
446 # (linking in only object files that are "needed"). If a library is never to
447 # be used in this way, it is better to define DONT_BUILD_RELINKED, and define
448 # BUILD_ARCHIVE instead.
450 # Some libraries must be built as .a files (libscalar for example) because if
451 # it's built as a .o file, then all of the constituent .o files in it will be
452 # linked into tools (for example gccas) even if they only use one of the parts
453 # of it. For this reason, sometimes it's useful to use libraries as .a files.
454 ###########################################################################
458 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
459 LIBRARYNAME := $(strip $(LIBRARYNAME))
461 LIBNAME_O := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).so
462 LIBNAME_P := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).so
463 LIBNAME_G := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).so
464 LIBNAME_AO := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).a
465 LIBNAME_AP := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).a
466 LIBNAME_AG := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).a
467 LIBNAME_OBJO := $(DESTLIBRELEASE)/$(LIBRARYNAME).o
468 LIBNAME_OBJP := $(DESTLIBPROFILE)/$(LIBRARYNAME).o
469 LIBNAME_OBJG := $(DESTLIBDEBUG)/$(LIBRARYNAME).o
471 #--------------------------------------------------------------------
473 # Modify the top level targets to build the desired libraries.
474 #--------------------------------------------------------------------
476 # dynamic target builds a shared object version of the library...
477 dynamic:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).so
479 # Does the library want a .o version built?
480 ifndef DONT_BUILD_RELINKED
481 all:: $(DESTLIBCURRENT)/$(LIBRARYNAME).o
484 # Does the library want an archive version built?
486 all:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).a
489 #--------------------------------------------------------------------
490 # Rules for building libraries
491 #--------------------------------------------------------------------
494 # Rules for building dynamically linked libraries.
496 $(LIBNAME_O): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
497 @echo ======= Linking $(LIBRARYNAME) dynamic release library =======
498 $(VERB) $(Link) -o $*.la $(ObjectsO) $(LibSubDirs) $(LibLinkOpts);
499 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $*.la $(DESTLIBCURRENT);
501 $(LIBNAME_P): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
502 @echo ======= Linking $(LIBRARYNAME) dynamic profile library =======
503 $(VERB) $(Link) -o $*.la $(ObjectsP) $(LibSubDirs) $(LibLinkOpts);
504 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $*.la $(DESTLIBCURRENT);
506 $(LIBNAME_G): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
507 @echo ======= Linking $(LIBRARYNAME) dynamic debug library =======
508 $(VERB) $(Link) -o $*.la $(ObjectsG) $(LibSubDirs) $(LibLinkOpts);
509 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $*.la $(DESTLIBCURRENT);
512 # Rules for building static archive libraries.
514 $(LIBNAME_AO): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
515 @echo ======= Linking $(LIBRARYNAME) archive release library =======
517 $(VERB) $(Link) -03 -o $@ $(ObjectsO) $(LibSubDirs) -static
519 $(LIBNAME_AP): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
520 @echo ======= Linking $(LIBRARYNAME) archive profile library =======
522 $(VERB) $(Link) -03 $(PROFILE) -o $@ $(ObjectsP) $(LibSubDirs) -static
524 $(LIBNAME_AG): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
525 @echo ======= Linking $(LIBRARYNAME) archive debug library =======
527 $(VERB) $(Link) -g $(STRIP) -o $@ $(ObjectsG) $(LibSubDirs) -static
530 # Rules for building .o libraries.
532 $(LIBNAME_OBJO): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
534 $(VERB) $(Relink) -o $@ $(ObjectsO) $(LibSubDirs)
536 $(LIBNAME_OBJP): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
538 $(VERB) $(Relink) -o $@ $(ObjectsP) $(LibSubDirs)
540 $(LIBNAME_OBJG): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
542 $(VERB) $(Relink) -o $@ $(ObjectsG) $(LibSubDirs)
546 #------------------------------------------------------------------------
547 # Create a TAGS database for emacs
548 #------------------------------------------------------------------------
553 $(ETAGS) -l c++ `find include lib tools -name '*.cpp' -o -name '*.h'`
558 ${ECHO} "Cannot build $@: The program etags is not installed"
561 #------------------------------------------------------------------------
562 # Handle the TOOLNAME option - used when building tool executables...
563 #------------------------------------------------------------------------
565 # The TOOLNAME option should be used with a USEDLIBS variable that tells the
566 # libraries (and the order of the libs) that should be linked to the
567 # tool. USEDLIBS should contain a list of library names (some with .a extension)
568 # that are automatically linked in as .o files unless the .a suffix is added.
572 # TOOLEXENAME* - These compute the output filenames to generate...
573 TOOLEXENAME_G := $(DESTTOOLDEBUG)/$(TOOLNAME)
574 TOOLEXENAME_O := $(DESTTOOLRELEASE)/$(TOOLNAME)
575 TOOLEXENAME_P := $(DESTTOOLPROFILE)/$(TOOLNAME)
576 TOOLEXENAMES := $(DESTTOOLCURRENT)/$(TOOLNAME)
578 # USED_LIBS_OPTIONS - Compute the options line that add -llib1 -llib2, etc.
579 PROJ_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
580 PROJ_LIBS_OPTIONS_G := $(patsubst %.o, $(PROJLIBDEBUGSOURCE)/%.o, $(PROJ_LIBS_OPTIONS))
581 PROJ_LIBS_OPTIONS_O := $(patsubst %.o, $(PROJLIBRELEASESOURCE)/%.o,$(PROJ_LIBS_OPTIONS))
582 PROJ_LIBS_OPTIONS_P := $(patsubst %.o, $(PROJLIBPROFILESOURCE)/%.o,$(PROJ_LIBS_OPTIONS))
584 LLVM_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
585 LLVM_LIBS_OPTIONS_G := $(patsubst %.o, $(LLVMLIBDEBUGSOURCE)/%.o, $(LLVM_LIBS_OPTIONS))
586 LLVM_LIBS_OPTIONS_O := $(patsubst %.o, $(LLVMLIBRELEASESOURCE)/%.o,$(LLVM_LIBS_OPTIONS))
587 LLVM_LIBS_OPTIONS_P := $(patsubst %.o, $(LLVMLIBPROFILESOURCE)/%.o,$(LLVM_LIBS_OPTIONS))
589 LIB_OPTS_G := $(LLVM_LIBS_OPTIONS_G) $(PROJ_LIBS_OPTIONS_G)
590 LIB_OPTS_O := $(LLVM_LIBS_OPTIONS_O) $(PROJ_LIBS_OPTIONS_O)
591 LIB_OPTS_P := $(LLVM_LIBS_OPTIONS_P) $(PROJ_LIBS_OPTIONS_P)
593 # USED_LIB_PATHS - Compute the path of the libraries used so that tools are
594 # rebuilt if libraries change. This has to make sure to handle .a/.so and .o
597 STATICUSEDLIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
598 USED_LIB_PATHS_G := $(addprefix $(DESTLIBDEBUG)/, $(STATICUSEDLIBS))
599 USED_LIB_PATHS_O := $(addprefix $(DESTLIBRELEASE)/, $(STATICUSEDLIBS))
600 USED_LIB_PATHS_P := $(addprefix $(DESTLIBPROFILE)/, $(STATICUSEDLIBS))
601 #LINK_OPTS := $(TOOLLINKOPTS) $(PLATFORMLINKOPTS)
604 # Libtool link options:
605 # Ensure that all binaries have their symbols exported so that they can
608 LINK_OPTS := -export-dynamic $(TOOLLINKOPTS)
614 # Tell make that we need to rebuild subdirectories before we can link the tool.
615 # This affects things like LLI which has library subdirectories.
616 $(USED_LIB_PATHS_G) $(USED_LIB_PATHS_O) $(USED_LIB_PATHS_P): \
617 $(addsuffix /.makeall, $(PARALLEL_DIRS))
619 all:: $(TOOLEXENAMES)
622 $(VERB) $(RM) -f $(TOOLEXENAMES)
624 $(TOOLEXENAME_G): $(ObjectsG) $(USED_LIB_PATHS_G) $(DESTTOOLDEBUG)/.dir
625 @echo ======= Linking $(TOOLNAME) debug executable $(STRIP_WARN_MSG) =======
626 $(VERB) $(LinkG) -o $@ $(ObjectsG) $(LIB_OPTS_G) $(LINK_OPTS) $(LIBS)
628 $(TOOLEXENAME_O): $(ObjectsO) $(USED_LIB_PATHS_O) $(DESTTOOLRELEASE)/.dir
629 @echo ======= Linking $(TOOLNAME) release executable =======
630 $(VERB) $(LinkO) -o $@ $(ObjectsO) $(LIB_OPTS_O) $(LINK_OPTS) $(LIBS)
632 $(TOOLEXENAME_P): $(ObjectsP) $(USED_LIB_PATHS_P) $(DESTTOOLPROFILE)/.dir
633 @echo ======= Linking $(TOOLNAME) profile executable =======
634 $(VERB) $(LinkP) -o $@ $(ObjectsP) $(LIB_OPTS_P) $(LINK_OPTS) $(LIBS)
640 #---------------------------------------------------------
641 .PRECIOUS: $(BUILD_OBJ_DIR)/Depend/.dir
642 .PRECIOUS: $(BUILD_OBJ_DIR)/Debug/.dir $(BUILD_OBJ_DIR)/Release/.dir
644 # Create .o files in the ObjectFiles directory from the .cpp and .c files...
645 #$(BUILD_OBJ_DIR)/Release/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Release/.dir
646 #@echo "Compiling $<"
647 #$(VERB) $(CompileO) $< -o $@
649 #$(BUILD_OBJ_DIR)/Release/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Release/.dir
650 #$(VERB) $(CompileCO) $< -o $@
652 #$(BUILD_OBJ_DIR)/Profile/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Profile/.dir
653 #@echo "Compiling $<"
654 #$(VERB) $(CompileP) $< -o $@
656 #$(BUILD_OBJ_DIR)/Profile/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Profile/.dir
657 #@echo "Compiling $<"
658 #$(VERB) $(CompileCP) $< -o $@
660 #$(BUILD_OBJ_DIR)/Debug/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Debug/.dir
661 #@echo "Compiling $<"
662 #$(VERB) $(CompileG) $< -o $@
664 #$(BUILD_OBJ_DIR)/Debug/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Debug/.dir
665 #$(VERB) $(CompileCG) $< -o $@
667 # Create .lo files in the ObjectFiles directory from the .cpp and .c files...
668 $(BUILD_OBJ_DIR)/Release/%.lo: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Release/.dir
670 $(VERB) $(CompileO) $< -o $@
672 $(BUILD_OBJ_DIR)/Release/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Release/.dir
674 $(VERB) $(CompileCO) $< -o $@
676 $(BUILD_OBJ_DIR)/Profile/%.lo: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Profile/.dir
678 $(VERB) $(CompileP) $< -o $@
680 $(BUILD_OBJ_DIR)/Profile/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Profile/.dir
682 $(VERB) $(CompileCP) $< -o $@
684 $(BUILD_OBJ_DIR)/Debug/%.lo: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Debug/.dir
686 $(VERB) $(CompileG) $< -o $@
688 $(BUILD_OBJ_DIR)/Debug/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Debug/.dir
690 $(VERB) $(CompileCG) $< -o $@
692 # Create .lo files in the ObjectFiles directory from the .cpp and .c files...
693 $(BUILD_OBJ_DIR)/Release/%.lo: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Release/.dir
695 $(VERB) $(CompileO) $< -o $@
697 $(BUILD_OBJ_DIR)/Release/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Release/.dir
698 $(VERB) $(CompileCO) $< -o $@
700 $(BUILD_OBJ_DIR)/Profile/%.lo: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Profile/.dir
702 $(VERB) $(CompileP) $< -o $@
704 $(BUILD_OBJ_DIR)/Profile/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Profile/.dir
706 $(VERB) $(CompileCP) $< -o $@
708 $(BUILD_OBJ_DIR)/Debug/%.lo: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Debug/.dir
710 $(VERB) $(CompileG) $< -o $@
712 $(BUILD_OBJ_DIR)/Debug/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Debug/.dir
713 $(VERB) $(CompileCG) $< -o $@
716 # Rules for building lex/yacc files
718 LEX_FILES = $(filter %.l, $(Source))
719 LEX_OUTPUT = $(LEX_FILES:%.l=%.cpp)
720 YACC_FILES = $(filter %.y, $(Source))
721 YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output)
722 .PRECIOUS: $(LEX_OUTPUT) $(YACC_OUTPUT)
724 # Create a .cpp source file from a flex input file... this uses sed to cut down
725 # on the warnings emited by GCC...
727 # The last line is a gross hack to work around flex aparently not being able to
728 # resize the buffer on a large token input. Currently, for uninitialized string
729 # buffers in LLVM we can generate very long tokens, so this is a hack around it.
730 # FIXME. (f.e. char Buffer[10000]; )
733 $(FLEX) -t $< | $(SED) '/^find_rule/d' | \
734 $(SED) 's/void yyunput/inline void yyunput/' | \
735 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
736 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' > $@
738 # Rule for building the bison parsers...
739 %.c: %.y # Cancel built-in rules for yacc
740 %.h: %.y # Cancel built-in rules for yacc
742 @echo Bison\'ing $<...
743 $(VERB) $(BISON) -v -d -p $(<:%Parser.y=%) $*.y
744 $(VERB) ${MV} -f $*.tab.c $*.cpp
745 $(VERB) ${MV} -f $*.tab.h $*.h
747 # To create the directories...
749 $(VERB) ${MKDIR} $* > /dev/null
752 # To create postscript files from dot files...
755 ${DOT} -Tps < $< > $@
758 ${ECHO} "Cannot build $@: The program dot is not installed"
761 # 'make clean' nukes the tree
763 $(VERB) $(RM) -rf $(BUILD_OBJ_DIR)/Debug $(BUILD_OBJ_DIR)/Release $(BUILD_OBJ_DIR)/Profile $(BUILD_OBJ_DIR)/Depend
764 $(VERB) $(RM) -f core core.[0-9][0-9]* *.o *.d *.so *~ *.flc
765 $(VERB) $(RM) -f $(LEX_OUTPUT) $(YACC_OUTPUT)
768 $(VERB) (cd $(LLVM_SRC_ROOT); $(RM) -rf $(LEVEL)/Makefile.config \
769 $(LEVEL)/include/Config/config.h \
770 $(LEVEL)/autom4te.cache \
773 ###########################################################################
775 # Define variables and rules that generate header file dependencies
776 # from C/C++ source files.
777 ###########################################################################
779 # If dependencies were generated for the file that included this file,
780 # include the dependancies now...
782 SourceBaseNames := $(basename $(notdir $(filter-out Debug/%, $(Source))))
783 SourceDepend := $(SourceBaseNames:%=$(BUILD_OBJ_DIR)/Depend/%.d)
787 # This allows a user to manually ask for an update in the dependencies
789 depend: $(SourceDepend)
792 # Create dependencies for the *.cpp files...
794 $(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Depend/.dir
795 $(VERB) $(Depend) $< | $(SED) 's|\.o|\.lo|' | $(SED) 's|$*\.lo *|$(BUILD_OBJ_DIR)/Release/& $(BUILD_OBJ_DIR)/Profile/& $(BUILD_OBJ_DIR)/Debug/& $(BUILD_OBJ_DIR)/Depend/$(@F)|g' > $@
797 # Create dependencies for the *.c files...
799 $(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Depend/.dir
800 $(VERB) $(DependC) -o $@ $< | $(SED) 's|\.o|\.lo|' | $(SED) 's|$*\.lo *|$(BUILD_OBJ_DIR)/Release/& $(BUILD_OBJ_DIR)/Profile/& $(BUILD_OBJ_DIR)/Debug/& $(BUILD_OBJ_DIR)/Depend/$(@F)|g' > $@
803 # Include dependencies generated from C/C++ source files, but not if we
804 # are cleaning (this example taken from the GNU Make Manual).
806 ifneq ($(MAKECMDGOALS),clean)
807 ifneq ($(SourceDepend),)
808 -include $(SourceDepend)