-LLVM_OBJ_ROOT := $(BUILD_OBJ_ROOT)
-endif
-
-###########################################################################
-# Default Targets:
-# The following targets are the standard top level targets for
-# building.
-###########################################################################
-
-ifdef SHARED_LIBRARY
-# if SHARED_LIBRARY is specified, the default is to build the dynamic lib
-all:: dynamic
-endif
-
-ifdef BYTECODE_LIBRARY
-# if BYTECODE_LIBRARY is specified, the default is to build the bytecode lib
-all:: bytecodelib
-install:: bytecodelib-install
-endif
-
-# Default Rule: Make sure it's also a :: rule
-all ::
-
-# Default for install is to at least build everything...
-install ::
-
-# Default rule for test. It ensures everything has a test rule
-test::
-
-# Default rule for building only bytecode.
-bytecode::
-
-# Print out the directories used for building
-prdirs::
- echo "Home Offset : " $(HOME_OBJ_ROOT)
- echo "Build Source Root: " $(BUILD_SRC_ROOT)
- echo "Build Source Dir : " $(BUILD_SRC_DIR)
- echo "Build Object Root: " $(BUILD_OBJ_ROOT)
- echo "Build Object Dir : " $(BUILD_OBJ_DIR)
- echo "LLVM Source Root: " $(LLVM_SRC_ROOT)
- echo "LLVM Object Root: " $(LLVM_OBJ_ROOT)
-
-#
-# Mark all of these targets as phony. This will hopefully speed up builds
-# slightly since GNU Make will not try to find implicit rules for targets
-# which are marked as Phony.
-#
-.PHONY: all dynamic bytecodelib bytecodelib-install
-.PHONY: clean distclean install test bytecode prdirs
-
-###########################################################################
-# Miscellaneous paths and commands:
-# This section defines various configuration macros, such as where
-# to find burg, tblgen, and libtool.
-###########################################################################
-
-#--------------------------------------------------------------------
-# Variables derived from configuration options...
-#--------------------------------------------------------------------
-
-#BinInstDir=/usr/local/bin
-#LibInstDir=/usr/local/lib/xxx
-#DocInstDir=/usr/doc/xxx
-
-BURG_OPTS = -I
-
-ifdef ENABLE_PROFILING
- ENABLE_OPTIMIZED = 1
- CONFIGURATION := Profile
-else
- ifdef ENABLE_OPTIMIZED
- CONFIGURATION := Release
- else
- CONFIGURATION := Debug
- endif
-endif
-
-#
-# Enable this for profiling support with 'gprof'
-# This automatically enables optimized builds.
-#
-ifdef ENABLE_PROFILING
- PROFILE = -pg
-endif
-
-#
-# Suffixes for library compilation rules
-#
-.SUFFIXES: .so
-
-###########################################################################
-# Library Locations:
-# These variables describe various library locations:
-#
-# DEST* = Location of where libraries that are built will be placed.
-# LLVM* = Location of LLVM libraries used for linking.
-# PROJ* = Location of previously built libraries used for linking.
-###########################################################################
-
-# Libraries that are being built
-DESTLIBDEBUG := $(BUILD_OBJ_ROOT)/lib/Debug
-DESTLIBRELEASE := $(BUILD_OBJ_ROOT)/lib/Release
-DESTLIBPROFILE := $(BUILD_OBJ_ROOT)/lib/Profile
-DESTLIBBYTECODE := $(BUILD_OBJ_ROOT)/lib/Bytecode
-DESTLIBCURRENT := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
-
-# LLVM libraries used for linking
-LLVMLIBDEBUGSOURCE := $(LLVM_OBJ_ROOT)/lib/Debug
-LLVMLIBRELEASESOURCE := $(LLVM_OBJ_ROOT)/lib/Release
-LLVMLIBPROFILESOURCE := $(LLVM_OBJ_ROOT)/lib/Profile
-LLVMLIBCURRENTSOURCE := $(LLVM_OBJ_ROOT)/lib/$(CONFIGURATION)
-
-# Libraries that were built that will now be used for linking
-PROJLIBDEBUGSOURCE := $(BUILD_OBJ_ROOT)/lib/Debug
-PROJLIBRELEASESOURCE := $(BUILD_OBJ_ROOT)/lib/Release
-PROJLIBPROFILESOURCE := $(BUILD_OBJ_ROOT)/lib/Profile
-PROJLIBCURRENTSOURCE := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
-
-###########################################################################
-# Tool Locations
-# These variables describe various tool locations:
-#
-# DEST* = Location of where tools that are built will be placed.
-# LLVM* = Location of LLVM tools used for building.
-# PROJ* = Location of previously built tools used for linking.
-###########################################################################
-
-DESTTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug
-DESTTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release
-DESTTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile
-DESTTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
-
-LLVMTOOLDEBUG := $(LLVM_OBJ_ROOT)/tools/Debug
-LLVMTOOLRELEASE := $(LLVM_OBJ_ROOT)/tools/Release
-LLVMTOOLPROFILE := $(LLVM_OBJ_ROOT)/tools/Profile
-LLVMTOOLCURRENT := $(LLVM_OBJ_ROOT)/tools/$(CONFIGURATION)
-
-PROJTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug
-PROJTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release
-PROJTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile
-PROJTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
-
-#
-# Libtool is found in the current directory.
-#
-LIBTOOL := $(LLVM_SRC_ROOT)/mklib
-
-#
-# If we're not building a shared library, use the disable-shared tag with
-# libtool. This will disable the building of objects for shared libraries and
-# only generate static library objects.
-#
-# For dynamic libraries, we'll take the performance hit for now, since we
-# almost never build them.
-#
-# This should speed up compilation and require no modifications to future
-# versions of libtool.
-#
-ifndef SHARED_LIBRARY
-LIBTOOL += --tag=disable-shared
-endif
-
-#
-# Verbosity levels
-#
-ifndef VERBOSE
-VERB := @
-LIBTOOL += --silent
-endif
-
-###########################################################################
-# Miscellaneous paths and commands (part deux):
-# This section defines various configuration macros, such as where
-# to find burg, tblgen, and libtool.
-###########################################################################
-
-#--------------------------------------------------------------------------
-# Utilities used while building the LLVM tree, which live in the utils dir
-#
-BURG := $(LLVMTOOLCURRENT)/burg
-RunBurg := $(BURG) $(BURG_OPTS)
-TBLGEN := $(LLVMTOOLCURRENT)/tblgen
-
-#--------------------------------------------------------------------------
-# The LLVM GCC front-end in C and C++ flavors
-#
-LLVMGCC := PATH=$(LLVMTOOLCURRENT):$(PATH) $(LLVMGCCDIR)/bin/gcc
-LCC1 := $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1
-LLVMGXX := PATH=$(LLVMTOOLCURRENT):$(PATH) $(LLVMGCCDIR)/bin/g++
-LCC1XX := $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1plus
-
-#--------------------------------------------------------------------------
-# Some of the compiled LLVM tools which are used for compilation of runtime
-# libraries.
-#
-LLVMAS := $(LLVMTOOLCURRENT)/as
-
-
-###########################################################################
-# Compile Time Flags
-###########################################################################
-
-#
-# Include both the project headers and the LLVM headers for compilation and
-# dependency computation.
-#
-CPPFLAGS += -I$(BUILD_SRC_ROOT)/include -I$(LLVM_SRC_ROOT)/include
-
-# By default, strip symbol information from executable
-ifndef KEEP_SYMBOLS
-STRIP = $(PLATFORMSTRIPOPTS)
-STRIP_WARN_MSG = "(without symbols)"
-endif
-
-# Allow gnu extensions...
-CPPFLAGS += -D_GNU_SOURCE
-
-CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include
-CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions -fshort-enums
-
-#
-# Compile commands with libtool.
-#
-Compile := $(LIBTOOL) --mode=compile $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
-CompileC := $(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CCFLAGS) $(CompileCommonOpts)
-
-# Compile a cpp file, don't link...
-CompileG := $(Compile) -g -D_DEBUG
-CompileO := $(Compile) $(CompileOptimizeOpts) -felide-constructors -fomit-frame-pointer
-CompileP := $(Compile) $(CompileOptimizeOpts) -felide-constructors $(PROFILE)
-
-# Compile a c file, don't link...
-CompileCG := $(CompileC) -g -D_DEBUG
-CompileCO := $(CompileC) $(CompileOptimizeOpts) -fomit-frame-pointer
-CompileCP := $(CompileC) $(CompileOptimizeOpts) $(PROFILE)
-
-###########################################################################
-# Link Time Options
-###########################################################################
-
-#
-# Link final executable
-# (Note that we always link with the C++ compiler).
-#
-Link := $(LIBTOOL) --mode=link $(CXX)
-
-# link both projlib and llvmlib libraries
-LinkG := $(Link) -g -L$(PROJLIBDEBUGSOURCE) -L$(LLVMLIBDEBUGSOURCE) $(STRIP)
-LinkO := $(Link) -O3 -L$(PROJLIBRELEASESOURCE) -L$(LLVMLIBRELEASESOURCE)
-LinkP := $(Link) -O3 -L$(PROJLIBPROFILESOURCE) -L$(LLVMLIBPROFILESOURCE) $(PROFILE)
-
-# Create one .o file from a bunch of .o files...
-Relink := ${LIBTOOL} --mode=link $(CXX)
-ifndef SHARED_LIBRARY
-Relink += -only-static
-endif
-
-#
-# Configure where the item being compiled should go.
-#
-ifdef SHARED_LIBRARY
-Link += -rpath $(DESTLIBCURRENT)
-endif
-
-ifdef TOOLNAME
-Link += -rpath $(DESTTOOLCURRENT)
-endif
-
-# Create dependancy file from CPP file, send to stdout.
-Depend := $(CXX) -MM -I$(LEVEL)/include $(CPPFLAGS)
-DependC := $(CC) -MM -I$(LEVEL)/include $(CPPFLAGS)
-
-# Archive a bunch of .o files into a .a file...
-AR = ${AR_PATH} cq
-
-#----------------------------------------------------------
-
-# Source includes all of the cpp files, and objects are derived from the
-# source files...
-# The local Makefile can list other Source files via ExtraSource = ...
-#
-ifndef Source
-Source := $(ExtraSource) $(wildcard *.cpp *.c *.y *.l)
-endif
-
-#
-# Libtool Objects
-#
-Srcs := $(sort $(notdir $(basename $(Source))))
-Objs := $(addsuffix .lo, $(Srcs))
-ObjectsO := $(addprefix $(BUILD_OBJ_DIR)/Release/,$(Objs))
-ObjectsP := $(addprefix $(BUILD_OBJ_DIR)/Profile/,$(Objs))
-ObjectsG := $(addprefix $(BUILD_OBJ_DIR)/Debug/,$(Objs))
-ObjectsBC := $(addprefix $(BUILD_OBJ_DIR)/Bytecode/,$(addsuffix .bc, $(Srcs)))
-
-#
-# The real objects underlying the libtool objects
-#
-RObjs := $(sort $(patsubst Debug/%.o, %.o, $(addsuffix .o,$(notdir $(basename $(Source))))))
-RObjectsO := $(addprefix $(BUILD_OBJ_DIR)/Release/,$(RObjs))
-RObjectsP := $(addprefix $(BUILD_OBJ_DIR)/Profile/,$(RObjs))
-RObjectsG := $(addprefix $(BUILD_OBJ_DIR)/Debug/,$(RObjs))
-
-#---------------------------------------------------------
-# Handle the DIRS and PARALLEL_DIRS options
-#---------------------------------------------------------
-
-ifdef DIRS
-all install clean test bytecode ::
- $(VERB) for dir in ${DIRS}; do \
- (cd $$dir; $(MAKE) $@) || exit 1; \
- done
-endif
-
-# Handle PARALLEL_DIRS
-ifdef PARALLEL_DIRS
-all :: $(addsuffix /.makeall , $(PARALLEL_DIRS))
-install :: $(addsuffix /.makeinstall , $(PARALLEL_DIRS))
-clean :: $(addsuffix /.makeclean , $(PARALLEL_DIRS))
-test :: $(addsuffix /.maketest , $(PARALLEL_DIRS))
-bytecode :: $(addsuffix /.makebytecode, $(PARALLEL_DIRS))
-
-%/.makeall %/.makeinstall %/.makeclean %/.maketest %/.makebytecode:
- $(VERB) cd $(@D); $(MAKE) $(subst $(@D)/.make,,$@)
-endif
-
-# Handle directories that may or may not exist
-ifdef OPTIONAL_DIRS
-all install clean test bytecode ::
- $(VERB) for dir in ${OPTIONAL_DIRS}; do \
- if [ -d $$dir ]; \
- then\
- (cd $$dir; $(MAKE) $@) || exit 1; \
- fi \
- done
-endif
-
-###########################################################################
-# Library Build Rules:
-#
-#---------------------------------------------------------
-# Handle the LIBRARYNAME option - used when building libs...
-#---------------------------------------------------------
-#
-# When libraries are built, they are allowed to optionally define the
-# DONT_BUILD_RELINKED make variable, which, when defined, prevents a .o file
-# from being built for the library. This .o files may then be linked to by a
-# tool if the tool does not need (or want) the semantics a .a file provides
-# (linking in only object files that are "needed"). If a library is never to
-# be used in this way, it is better to define DONT_BUILD_RELINKED, and define
-# BUILD_ARCHIVE instead.
-#
-# Some libraries must be built as .a files (libscalar for example) because if
-# it's built as a .o file, then all of the constituent .o files in it will be
-# linked into tools (for example gccas) even if they only use one of the parts
-# of it. For this reason, sometimes it's useful to use libraries as .a files.
-###########################################################################
-
-ifdef LIBRARYNAME
-
-# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
-LIBRARYNAME := $(strip $(LIBRARYNAME))
-
-LIBNAME_O := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).so
-LIBNAME_P := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).so
-LIBNAME_G := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).so
-LIBNAME_AO := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).a
-LIBNAME_AP := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).a
-LIBNAME_AG := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).a
-LIBNAME_OBJO := $(DESTLIBRELEASE)/$(LIBRARYNAME).o
-LIBNAME_OBJP := $(DESTLIBPROFILE)/$(LIBRARYNAME).o
-LIBNAME_OBJG := $(DESTLIBDEBUG)/$(LIBRARYNAME).o
-LIBNAME_BC := $(DESTLIBBYTECODE)/lib$(LIBRARYNAME).bc
-
-#--------------------------------------------------------------------
-# Library Targets
-# Modify the top level targets to build the desired libraries.
-#--------------------------------------------------------------------
-
-# dynamic target builds a shared object version of the library...
-dynamic:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).so
-bytecodelib:: $(LIBNAME_BC)
-bytecodelib-install:: $(LLVMGCCDIR)/bytecode-libs/lib$(LIBRARYNAME).bc
-
-$(LLVMGCCDIR)/bytecode-libs/lib$(LIBRARYNAME).bc: $(LIBNAME_BC)
- @echo ======= Installing $(LIBRARYNAME) bytecode library =======
- cp $< $@
-
-# Does the library want a .o version built?
-ifndef DONT_BUILD_RELINKED
-all:: $(DESTLIBCURRENT)/$(LIBRARYNAME).o
-endif
-
-# Does the library want an archive version built?
-ifdef BUILD_ARCHIVE
-all:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).a
-endif
-
-#--------------------------------------------------------------------
-# Rules for building libraries
-#--------------------------------------------------------------------
-
-LinkBCLib := $(LLVMGCC) -shared
-ifdef EXPORTED_SYMBOL_LIST
-LinkBCLib += -Xlinker -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
-else
-LinkBCLib += -Xlinker -disable-internalize
-endif
-
-
-# Rule for building bytecode libraries.
-$(LIBNAME_BC): $(ObjectsBC) $(LibSubDirs) $(DESTLIBBYTECODE)/.dir
- @echo ======= Linking $(LIBRARYNAME) bytecode library =======
- $(VERB) $(LinkBCLib) -o $@ $(ObjectsBC) $(LibSubDirs) $(LibLinkOpts)
-#
-# Rules for building dynamically linked libraries.
-#
-$(LIBNAME_O): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
- @echo ======= Linking $(LIBRARYNAME) dynamic release library =======
- $(VERB) $(Link) -o $*.la $(ObjectsO) $(LibSubDirs) $(LibLinkOpts)
- $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $*.la $(DESTLIBCURRENT)
-
-$(LIBNAME_P): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
- @echo ======= Linking $(LIBRARYNAME) dynamic profile library =======
- $(VERB) $(Link) -o $*.la $(ObjectsP) $(LibSubDirs) $(LibLinkOpts)
- $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $*.la $(DESTLIBCURRENT)
-
-$(LIBNAME_G): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
- @echo ======= Linking $(LIBRARYNAME) dynamic debug library =======
- $(VERB) $(Link) -o $*.la $(ObjectsG) $(LibSubDirs) $(LibLinkOpts)
- $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $*.la $(DESTLIBCURRENT)
-
-#
-# Rules for building static archive libraries.
-#
-$(LIBNAME_AO): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
- @echo ======= Linking $(LIBRARYNAME) archive release library =======
- @$(RM) -f $@
- $(VERB) $(Link) -03 -o $@ $(ObjectsO) $(LibSubDirs) -static
-
-$(LIBNAME_AP): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
- @echo ======= Linking $(LIBRARYNAME) archive profile library =======
- @$(RM) -f $@
- $(VERB) $(Link) -03 $(PROFILE) -o $@ $(ObjectsP) $(LibSubDirs) -static
-
-$(LIBNAME_AG): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
- @echo ======= Linking $(LIBRARYNAME) archive debug library =======
- @$(RM) -f $@
- $(VERB) $(Link) -g $(STRIP) -o $@ $(ObjectsG) $(LibSubDirs) -static
-
-
-#
-# Rules for building .o libraries.
-#
-# JTC:
-# Note that for this special case, we specify the actual object files
-# instead of their libtool counterparts. This is because libtool
-# doesn't want to generate a reloadable object file unless it is given
-# .o files explicitly.
-#
-# Note that we're making an assumption here: If we build a .lo file,
-# it's corresponding .o file will be placed in the same directory.
-#
-# I think that is safe.
-#
-$(LIBNAME_OBJO): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
- @echo "Linking $@"
- $(VERB) $(Relink) -o $@ $(RObjectsO) $(LibSubDirs)
-
-$(LIBNAME_OBJP): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
- @echo "Linking $@"
- $(VERB) $(Relink) -o $@ $(RObjectsP) $(LibSubDirs)
-
-$(LIBNAME_OBJG): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
- @echo "Linking $@"
- $(VERB) $(Relink) -o $@ $(RObjectsG) $(LibSubDirs)
-
-endif
-
-#------------------------------------------------------------------------
-# Create a TAGS database for emacs
-#------------------------------------------------------------------------
-
-ifdef ETAGS
-ifeq ($(LEVEL), .)
-tags:
- $(ETAGS) -l c++ `find include lib tools -name '*.cpp' -o -name '*.h'`
-all:: tags
-endif