+#------------------------------------------------------------------------
+# 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
+else
+tags:
+ ${ECHO} "Cannot build $@: The program etags is not installed"
+endif
+
+#------------------------------------------------------------------------
+# Handle the TOOLNAME option - used when building tool executables...
+#------------------------------------------------------------------------
+#
+# The TOOLNAME option should be used with a USEDLIBS variable that tells the
+# libraries (and the order of the libs) that should be linked to the
+# tool. USEDLIBS should contain a list of library names (some with .a extension)
+# that are automatically linked in as .o files unless the .a suffix is added.
+#
+ifdef TOOLNAME
+
+# TOOLEXENAME* - These compute the output filenames to generate...
+TOOLEXENAME_G := $(DESTTOOLDEBUG)/$(TOOLNAME)
+TOOLEXENAME_O := $(DESTTOOLRELEASE)/$(TOOLNAME)
+TOOLEXENAME_P := $(DESTTOOLPROFILE)/$(TOOLNAME)
+TOOLEXENAMES := $(DESTTOOLCURRENT)/$(TOOLNAME)
+
+# USED_LIBS_OPTIONS - Compute the options line that add -llib1 -llib2, etc.
+PROJ_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
+PROJ_LIBS_OPTIONS_G := $(patsubst %.o, $(PROJLIBDEBUGSOURCE)/%.o, $(PROJ_LIBS_OPTIONS))
+PROJ_LIBS_OPTIONS_O := $(patsubst %.o, $(PROJLIBRELEASESOURCE)/%.o,$(PROJ_LIBS_OPTIONS))
+PROJ_LIBS_OPTIONS_P := $(patsubst %.o, $(PROJLIBPROFILESOURCE)/%.o,$(PROJ_LIBS_OPTIONS))
+
+LLVM_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
+LLVM_LIBS_OPTIONS_G := $(patsubst %.o, $(LLVMLIBDEBUGSOURCE)/%.o, $(LLVM_LIBS_OPTIONS))
+LLVM_LIBS_OPTIONS_O := $(patsubst %.o, $(LLVMLIBRELEASESOURCE)/%.o,$(LLVM_LIBS_OPTIONS))
+LLVM_LIBS_OPTIONS_P := $(patsubst %.o, $(LLVMLIBPROFILESOURCE)/%.o,$(LLVM_LIBS_OPTIONS))
+
+LIB_OPTS_G := $(LLVM_LIBS_OPTIONS_G) $(PROJ_LIBS_OPTIONS_G)
+LIB_OPTS_O := $(LLVM_LIBS_OPTIONS_O) $(PROJ_LIBS_OPTIONS_O)
+LIB_OPTS_P := $(LLVM_LIBS_OPTIONS_P) $(PROJ_LIBS_OPTIONS_P)
+
+# USED_LIB_PATHS - Compute the path of the libraries used so that tools are
+# rebuilt if libraries change. This has to make sure to handle .a/.so and .o
+# files separately.
+#
+STATICUSEDLIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
+USED_LIB_PATHS_G := $(addprefix $(DESTLIBDEBUG)/, $(STATICUSEDLIBS))
+USED_LIB_PATHS_O := $(addprefix $(DESTLIBRELEASE)/, $(STATICUSEDLIBS))
+USED_LIB_PATHS_P := $(addprefix $(DESTLIBPROFILE)/, $(STATICUSEDLIBS))
+#LINK_OPTS := $(TOOLLINKOPTS) $(PLATFORMLINKOPTS)
+
+#
+# Libtool link options:
+# Ensure that all binaries have their symbols exported so that they can
+# by dlsym'ed.
+#
+LINK_OPTS := -export-dynamic $(TOOLLINKOPTS)