2011-12-01 20:18:09 +00:00
|
|
|
//===-- llvm-config.cpp - LLVM project configuration utility --------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This tool encapsulates information about an LLVM project configuration for
|
|
|
|
// use by other project's build environments (to determine installed path,
|
|
|
|
// available features, required libraries, etc.).
|
|
|
|
//
|
|
|
|
// Note that although this tool *may* be used by some parts of LLVM's build
|
|
|
|
// itself (i.e., the Makefiles use it to compute required libraries when linking
|
|
|
|
// tools), this tool is primarily designed to support external projects.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/ADT/STLExtras.h"
|
|
|
|
#include "llvm/ADT/StringMap.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
2014-03-29 01:08:53 +00:00
|
|
|
#include "llvm/ADT/Triple.h"
|
2011-12-01 20:18:09 +00:00
|
|
|
#include "llvm/ADT/Twine.h"
|
|
|
|
#include "llvm/Config/config.h"
|
|
|
|
#include "llvm/Config/llvm-config.h"
|
|
|
|
#include "llvm/Support/FileSystem.h"
|
|
|
|
#include "llvm/Support/Path.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <set>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
// Include the build time variables we can report to the user. This is generated
|
|
|
|
// at build time from the BuildVariables.inc.in file by the build system.
|
|
|
|
#include "BuildVariables.inc"
|
|
|
|
|
|
|
|
// Include the component table. This creates an array of struct
|
|
|
|
// AvailableComponent entries, which record the component name, library name,
|
|
|
|
// and required components for all of the available libraries.
|
|
|
|
//
|
|
|
|
// Not all components define a library, we also use "library groups" as a way to
|
|
|
|
// create entries for pseudo groups like x86 or all-targets.
|
|
|
|
#include "LibraryDependencies.inc"
|
|
|
|
|
|
|
|
/// \brief Traverse a single component adding to the topological ordering in
|
|
|
|
/// \arg RequiredLibs.
|
|
|
|
///
|
|
|
|
/// \param Name - The component to traverse.
|
|
|
|
/// \param ComponentMap - A prebuilt map of component names to descriptors.
|
|
|
|
/// \param VisitedComponents [in] [out] - The set of already visited components.
|
|
|
|
/// \param RequiredLibs [out] - The ordered list of required libraries.
|
|
|
|
static void VisitComponent(StringRef Name,
|
|
|
|
const StringMap<AvailableComponent*> &ComponentMap,
|
|
|
|
std::set<AvailableComponent*> &VisitedComponents,
|
2012-05-15 18:44:17 +00:00
|
|
|
std::vector<StringRef> &RequiredLibs,
|
|
|
|
bool IncludeNonInstalled) {
|
2011-12-01 20:18:09 +00:00
|
|
|
// Lookup the component.
|
|
|
|
AvailableComponent *AC = ComponentMap.lookup(Name);
|
|
|
|
assert(AC && "Invalid component name!");
|
|
|
|
|
|
|
|
// Add to the visited table.
|
|
|
|
if (!VisitedComponents.insert(AC).second) {
|
|
|
|
// We are done if the component has already been visited.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-15 18:44:17 +00:00
|
|
|
// Only include non-installed components if requested.
|
|
|
|
if (!AC->IsInstalled && !IncludeNonInstalled)
|
|
|
|
return;
|
|
|
|
|
2011-12-01 20:18:09 +00:00
|
|
|
// Otherwise, visit all the dependencies.
|
|
|
|
for (unsigned i = 0; AC->RequiredLibraries[i]; ++i) {
|
|
|
|
VisitComponent(AC->RequiredLibraries[i], ComponentMap, VisitedComponents,
|
2012-05-15 18:44:17 +00:00
|
|
|
RequiredLibs, IncludeNonInstalled);
|
2011-12-01 20:18:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add to the required library list.
|
|
|
|
if (AC->Library)
|
|
|
|
RequiredLibs.push_back(AC->Library);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Compute the list of required libraries for a given list of
|
|
|
|
/// components, in an order suitable for passing to a linker (that is, libraries
|
|
|
|
/// appear prior to their dependencies).
|
|
|
|
///
|
|
|
|
/// \param Components - The names of the components to find libraries for.
|
|
|
|
/// \param RequiredLibs [out] - On return, the ordered list of libraries that
|
|
|
|
/// are required to link the given components.
|
2012-05-15 18:44:17 +00:00
|
|
|
/// \param IncludeNonInstalled - Whether non-installed components should be
|
|
|
|
/// reported.
|
2015-03-09 16:23:46 +00:00
|
|
|
static void ComputeLibsForComponents(const std::vector<StringRef> &Components,
|
|
|
|
std::vector<StringRef> &RequiredLibs,
|
|
|
|
bool IncludeNonInstalled) {
|
2011-12-01 20:18:09 +00:00
|
|
|
std::set<AvailableComponent*> VisitedComponents;
|
|
|
|
|
|
|
|
// Build a map of component names to information.
|
|
|
|
StringMap<AvailableComponent*> ComponentMap;
|
|
|
|
for (unsigned i = 0; i != array_lengthof(AvailableComponents); ++i) {
|
|
|
|
AvailableComponent *AC = &AvailableComponents[i];
|
|
|
|
ComponentMap[AC->Name] = AC;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Visit the components.
|
|
|
|
for (unsigned i = 0, e = Components.size(); i != e; ++i) {
|
|
|
|
// Users are allowed to provide mixed case component names.
|
|
|
|
std::string ComponentLower = Components[i].lower();
|
|
|
|
|
|
|
|
// Validate that the user supplied a valid component name.
|
|
|
|
if (!ComponentMap.count(ComponentLower)) {
|
|
|
|
llvm::errs() << "llvm-config: unknown component name: " << Components[i]
|
|
|
|
<< "\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
VisitComponent(ComponentLower, ComponentMap, VisitedComponents,
|
2012-05-15 18:44:17 +00:00
|
|
|
RequiredLibs, IncludeNonInstalled);
|
2011-12-01 20:18:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// The list is now ordered with leafs first, we want the libraries to printed
|
|
|
|
// in the reverse order of dependency.
|
|
|
|
std::reverse(RequiredLibs.begin(), RequiredLibs.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* *** */
|
|
|
|
|
2015-03-09 16:23:46 +00:00
|
|
|
static void usage() {
|
2011-12-01 20:18:09 +00:00
|
|
|
errs() << "\
|
|
|
|
usage: llvm-config <OPTION>... [<COMPONENT>...]\n\
|
|
|
|
\n\
|
|
|
|
Get various configuration information needed to compile programs which use\n\
|
|
|
|
LLVM. Typically called from 'configure' scripts. Examples:\n\
|
|
|
|
llvm-config --cxxflags\n\
|
|
|
|
llvm-config --ldflags\n\
|
|
|
|
llvm-config --libs engine bcreader scalaropts\n\
|
|
|
|
\n\
|
|
|
|
Options:\n\
|
|
|
|
--version Print LLVM version.\n\
|
|
|
|
--prefix Print the installation prefix.\n\
|
|
|
|
--src-root Print the source root LLVM was built from.\n\
|
|
|
|
--obj-root Print the object root used to build LLVM.\n\
|
|
|
|
--bindir Directory containing LLVM executables.\n\
|
|
|
|
--includedir Directory containing LLVM headers.\n\
|
|
|
|
--libdir Directory containing LLVM libraries.\n\
|
|
|
|
--cppflags C preprocessor flags for files that include LLVM headers.\n\
|
|
|
|
--cflags C compiler flags for files that include LLVM headers.\n\
|
|
|
|
--cxxflags C++ compiler flags for files that include LLVM headers.\n\
|
|
|
|
--ldflags Print Linker flags.\n\
|
2013-12-25 02:24:32 +00:00
|
|
|
--system-libs System Libraries needed to link against LLVM components.\n\
|
2011-12-01 20:18:09 +00:00
|
|
|
--libs Libraries needed to link against LLVM components.\n\
|
|
|
|
--libnames Bare library names for in-tree builds.\n\
|
|
|
|
--libfiles Fully qualified library filenames for makefile depends.\n\
|
|
|
|
--components List of all possible components.\n\
|
|
|
|
--targets-built List of all targets currently built.\n\
|
|
|
|
--host-target Target triple used to configure LLVM.\n\
|
|
|
|
--build-mode Print build mode of LLVM tree (e.g. Debug or Release).\n\
|
2013-12-03 23:22:25 +00:00
|
|
|
--assertion-mode Print assertion mode of LLVM tree (ON or OFF).\n\
|
2011-12-01 20:18:09 +00:00
|
|
|
Typical components:\n\
|
|
|
|
all All LLVM libraries (default).\n\
|
|
|
|
engine Either a native JIT or a bitcode interpreter.\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Compute the path to the main executable.
|
2013-06-26 05:01:35 +00:00
|
|
|
std::string GetExecutablePath(const char *Argv0) {
|
2011-12-01 20:18:09 +00:00
|
|
|
// This just needs to be some symbol in the binary; C++ doesn't
|
|
|
|
// allow taking the address of ::main however.
|
|
|
|
void *P = (void*) (intptr_t) GetExecutablePath;
|
2013-06-26 05:01:35 +00:00
|
|
|
return llvm::sys::fs::getMainExecutable(Argv0, P);
|
2011-12-01 20:18:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
std::vector<StringRef> Components;
|
|
|
|
bool PrintLibs = false, PrintLibNames = false, PrintLibFiles = false;
|
2013-12-19 08:46:36 +00:00
|
|
|
bool PrintSystemLibs = false;
|
2011-12-01 20:18:09 +00:00
|
|
|
bool HasAnyOption = false;
|
|
|
|
|
|
|
|
// llvm-config is designed to support being run both from a development tree
|
|
|
|
// and from an installed path. We try and auto-detect which case we are in so
|
|
|
|
// that we can report the correct information when run from a development
|
|
|
|
// tree.
|
2012-01-26 01:31:38 +00:00
|
|
|
bool IsInDevelopmentTree;
|
|
|
|
enum { MakefileStyle, CMakeStyle, CMakeBuildModeStyle } DevelopmentTreeLayout;
|
2013-06-26 05:01:35 +00:00
|
|
|
llvm::SmallString<256> CurrentPath(GetExecutablePath(argv[0]));
|
2011-12-01 20:18:09 +00:00
|
|
|
std::string CurrentExecPrefix;
|
|
|
|
std::string ActiveObjRoot;
|
|
|
|
|
2013-12-17 05:48:37 +00:00
|
|
|
// If CMAKE_CFG_INTDIR is given, honor it as build mode.
|
|
|
|
char const *build_mode = LLVM_BUILDMODE;
|
|
|
|
#if defined(CMAKE_CFG_INTDIR)
|
|
|
|
if (!(CMAKE_CFG_INTDIR[0] == '.' && CMAKE_CFG_INTDIR[1] == '\0'))
|
|
|
|
build_mode = CMAKE_CFG_INTDIR;
|
|
|
|
#endif
|
|
|
|
|
2011-12-01 20:18:09 +00:00
|
|
|
// Create an absolute path, and pop up one directory (we expect to be inside a
|
|
|
|
// bin dir).
|
|
|
|
sys::fs::make_absolute(CurrentPath);
|
|
|
|
CurrentExecPrefix = sys::path::parent_path(
|
|
|
|
sys::path::parent_path(CurrentPath)).str();
|
|
|
|
|
|
|
|
// Check to see if we are inside a development tree by comparing to possible
|
2012-05-15 22:07:18 +00:00
|
|
|
// locations (prefix style or CMake style).
|
|
|
|
if (sys::fs::equivalent(CurrentExecPrefix,
|
2013-12-20 17:35:46 +00:00
|
|
|
Twine(LLVM_OBJ_ROOT) + "/" + build_mode)) {
|
2011-12-01 20:18:09 +00:00
|
|
|
IsInDevelopmentTree = true;
|
2012-01-26 01:31:38 +00:00
|
|
|
DevelopmentTreeLayout = MakefileStyle;
|
2011-12-01 20:18:09 +00:00
|
|
|
|
|
|
|
// If we are in a development tree, then check if we are in a BuildTools
|
|
|
|
// directory. This indicates we are built for the build triple, but we
|
|
|
|
// always want to provide information for the host triple.
|
|
|
|
if (sys::path::filename(LLVM_OBJ_ROOT) == "BuildTools") {
|
|
|
|
ActiveObjRoot = sys::path::parent_path(LLVM_OBJ_ROOT);
|
|
|
|
} else {
|
|
|
|
ActiveObjRoot = LLVM_OBJ_ROOT;
|
|
|
|
}
|
2012-05-15 22:07:18 +00:00
|
|
|
} else if (sys::fs::equivalent(CurrentExecPrefix, LLVM_OBJ_ROOT)) {
|
2012-01-26 01:31:38 +00:00
|
|
|
IsInDevelopmentTree = true;
|
|
|
|
DevelopmentTreeLayout = CMakeStyle;
|
|
|
|
ActiveObjRoot = LLVM_OBJ_ROOT;
|
2012-05-15 22:07:18 +00:00
|
|
|
} else if (sys::fs::equivalent(CurrentExecPrefix,
|
|
|
|
Twine(LLVM_OBJ_ROOT) + "/bin")) {
|
2011-12-01 20:18:09 +00:00
|
|
|
IsInDevelopmentTree = true;
|
2012-01-26 01:31:38 +00:00
|
|
|
DevelopmentTreeLayout = CMakeBuildModeStyle;
|
2011-12-01 20:18:09 +00:00
|
|
|
ActiveObjRoot = LLVM_OBJ_ROOT;
|
|
|
|
} else {
|
|
|
|
IsInDevelopmentTree = false;
|
2012-02-23 08:25:25 +00:00
|
|
|
DevelopmentTreeLayout = MakefileStyle; // Initialized to avoid warnings.
|
2011-12-01 20:18:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Compute various directory locations based on the derived location
|
|
|
|
// information.
|
|
|
|
std::string ActivePrefix, ActiveBinDir, ActiveIncludeDir, ActiveLibDir;
|
|
|
|
std::string ActiveIncludeOption;
|
|
|
|
if (IsInDevelopmentTree) {
|
|
|
|
ActiveIncludeDir = std::string(LLVM_SRC_ROOT) + "/include";
|
|
|
|
ActivePrefix = CurrentExecPrefix;
|
|
|
|
|
|
|
|
// CMake organizes the products differently than a normal prefix style
|
|
|
|
// layout.
|
2012-01-26 01:31:38 +00:00
|
|
|
switch (DevelopmentTreeLayout) {
|
|
|
|
case MakefileStyle:
|
2013-12-20 17:35:52 +00:00
|
|
|
ActivePrefix = ActiveObjRoot;
|
2013-12-20 17:35:46 +00:00
|
|
|
ActiveBinDir = ActiveObjRoot + "/" + build_mode + "/bin";
|
2014-12-29 11:16:25 +00:00
|
|
|
ActiveLibDir =
|
|
|
|
ActiveObjRoot + "/" + build_mode + "/lib" + LLVM_LIBDIR_SUFFIX;
|
2012-01-26 01:31:38 +00:00
|
|
|
break;
|
|
|
|
case CMakeStyle:
|
|
|
|
ActiveBinDir = ActiveObjRoot + "/bin";
|
2014-12-29 11:16:25 +00:00
|
|
|
ActiveLibDir = ActiveObjRoot + "/lib" + LLVM_LIBDIR_SUFFIX;
|
2012-01-26 01:31:38 +00:00
|
|
|
break;
|
|
|
|
case CMakeBuildModeStyle:
|
2013-12-19 16:02:23 +00:00
|
|
|
ActivePrefix = ActiveObjRoot;
|
2013-12-17 05:48:37 +00:00
|
|
|
ActiveBinDir = ActiveObjRoot + "/bin/" + build_mode;
|
2014-12-29 11:16:25 +00:00
|
|
|
ActiveLibDir =
|
|
|
|
ActiveObjRoot + "/lib" + LLVM_LIBDIR_SUFFIX + "/" + build_mode;
|
2012-01-26 01:31:38 +00:00
|
|
|
break;
|
2011-12-01 20:18:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// We need to include files from both the source and object trees.
|
|
|
|
ActiveIncludeOption = ("-I" + ActiveIncludeDir + " " +
|
|
|
|
"-I" + ActiveObjRoot + "/include");
|
|
|
|
} else {
|
|
|
|
ActivePrefix = CurrentExecPrefix;
|
|
|
|
ActiveIncludeDir = ActivePrefix + "/include";
|
|
|
|
ActiveBinDir = ActivePrefix + "/bin";
|
2014-12-29 11:16:25 +00:00
|
|
|
ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
|
2011-12-01 20:18:09 +00:00
|
|
|
ActiveIncludeOption = "-I" + ActiveIncludeDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
raw_ostream &OS = outs();
|
|
|
|
for (int i = 1; i != argc; ++i) {
|
|
|
|
StringRef Arg = argv[i];
|
|
|
|
|
|
|
|
if (Arg.startswith("-")) {
|
|
|
|
HasAnyOption = true;
|
|
|
|
if (Arg == "--version") {
|
|
|
|
OS << PACKAGE_VERSION << '\n';
|
|
|
|
} else if (Arg == "--prefix") {
|
|
|
|
OS << ActivePrefix << '\n';
|
|
|
|
} else if (Arg == "--bindir") {
|
|
|
|
OS << ActiveBinDir << '\n';
|
|
|
|
} else if (Arg == "--includedir") {
|
|
|
|
OS << ActiveIncludeDir << '\n';
|
|
|
|
} else if (Arg == "--libdir") {
|
|
|
|
OS << ActiveLibDir << '\n';
|
|
|
|
} else if (Arg == "--cppflags") {
|
|
|
|
OS << ActiveIncludeOption << ' ' << LLVM_CPPFLAGS << '\n';
|
|
|
|
} else if (Arg == "--cflags") {
|
|
|
|
OS << ActiveIncludeOption << ' ' << LLVM_CFLAGS << '\n';
|
|
|
|
} else if (Arg == "--cxxflags") {
|
|
|
|
OS << ActiveIncludeOption << ' ' << LLVM_CXXFLAGS << '\n';
|
|
|
|
} else if (Arg == "--ldflags") {
|
2013-12-19 08:46:36 +00:00
|
|
|
OS << "-L" << ActiveLibDir << ' ' << LLVM_LDFLAGS << '\n';
|
|
|
|
} else if (Arg == "--system-libs") {
|
|
|
|
PrintSystemLibs = true;
|
2011-12-01 20:18:09 +00:00
|
|
|
} else if (Arg == "--libs") {
|
|
|
|
PrintLibs = true;
|
|
|
|
} else if (Arg == "--libnames") {
|
|
|
|
PrintLibNames = true;
|
|
|
|
} else if (Arg == "--libfiles") {
|
|
|
|
PrintLibFiles = true;
|
|
|
|
} else if (Arg == "--components") {
|
|
|
|
for (unsigned j = 0; j != array_lengthof(AvailableComponents); ++j) {
|
2012-05-15 18:44:17 +00:00
|
|
|
// Only include non-installed components when in a development tree.
|
|
|
|
if (!AvailableComponents[j].IsInstalled && !IsInDevelopmentTree)
|
|
|
|
continue;
|
|
|
|
|
2011-12-01 20:18:09 +00:00
|
|
|
OS << ' ';
|
|
|
|
OS << AvailableComponents[j].Name;
|
|
|
|
}
|
|
|
|
OS << '\n';
|
|
|
|
} else if (Arg == "--targets-built") {
|
2011-12-16 00:04:43 +00:00
|
|
|
OS << LLVM_TARGETS_BUILT << '\n';
|
2011-12-01 20:18:09 +00:00
|
|
|
} else if (Arg == "--host-target") {
|
2014-03-29 01:08:53 +00:00
|
|
|
OS << Triple::normalize(LLVM_DEFAULT_TARGET_TRIPLE) << '\n';
|
2011-12-01 20:18:09 +00:00
|
|
|
} else if (Arg == "--build-mode") {
|
2013-12-03 14:35:17 +00:00
|
|
|
OS << build_mode << '\n';
|
2013-12-03 23:22:25 +00:00
|
|
|
} else if (Arg == "--assertion-mode") {
|
|
|
|
#if defined(NDEBUG)
|
|
|
|
OS << "OFF\n";
|
|
|
|
#else
|
|
|
|
OS << "ON\n";
|
|
|
|
#endif
|
2011-12-01 20:18:09 +00:00
|
|
|
} else if (Arg == "--obj-root") {
|
2013-12-19 16:02:28 +00:00
|
|
|
OS << ActivePrefix << '\n';
|
2011-12-01 20:18:09 +00:00
|
|
|
} else if (Arg == "--src-root") {
|
|
|
|
OS << LLVM_SRC_ROOT << '\n';
|
|
|
|
} else {
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Components.push_back(Arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!HasAnyOption)
|
|
|
|
usage();
|
|
|
|
|
2013-12-19 08:46:36 +00:00
|
|
|
if (PrintLibs || PrintLibNames || PrintLibFiles || PrintSystemLibs) {
|
2011-12-12 18:22:04 +00:00
|
|
|
// If no components were specified, default to "all".
|
|
|
|
if (Components.empty())
|
|
|
|
Components.push_back("all");
|
|
|
|
|
2011-12-01 20:18:09 +00:00
|
|
|
// Construct the list of all the required libraries.
|
|
|
|
std::vector<StringRef> RequiredLibs;
|
2012-05-15 18:44:17 +00:00
|
|
|
ComputeLibsForComponents(Components, RequiredLibs,
|
|
|
|
/*IncludeNonInstalled=*/IsInDevelopmentTree);
|
2011-12-01 20:18:09 +00:00
|
|
|
|
2014-03-03 15:06:14 +00:00
|
|
|
if (PrintLibs || PrintLibNames || PrintLibFiles) {
|
2015-07-27 18:26:30 +00:00
|
|
|
// If LLVM was built as a shared library, there will be only one thing
|
|
|
|
// that users should link against.
|
|
|
|
const bool IsSharedLib = (std::strcmp(BUILD_SHARED_LIBS, "ON") == 0);
|
|
|
|
const bool WasBuiltWithCMake = (std::strcmp(WAS_BUILT_WITH_CMAKE, "ON") == 0);
|
|
|
|
// CMake correctly builds components as separate shared libraries, however
|
|
|
|
// autoconfig/make builds components a static libraries and then links
|
|
|
|
// them all together to form a single shared library. Thus, only when
|
|
|
|
// `WAS_BUILT_WITH_CMAKE` is `OFF` and `BUILD_SHARED_LIBS` is `ON` do we
|
|
|
|
// override `RequiredLibs` with the single library name.
|
|
|
|
if (IsSharedLib && !WasBuiltWithCMake) {
|
|
|
|
RequiredLibs.clear();
|
|
|
|
std::string Name = "libLLVM-" PACKAGE_VERSION;
|
|
|
|
const Triple HostTriple(LLVM_DEFAULT_TARGET_TRIPLE);
|
|
|
|
if (HostTriple.isOSWindows()) {
|
|
|
|
Name += ".dll";
|
|
|
|
} else if (HostTriple.isOSDarwin()) {
|
|
|
|
Name += ".dylib";
|
|
|
|
} else {
|
|
|
|
// default to linux' ext:
|
|
|
|
Name += ".so";
|
|
|
|
}
|
|
|
|
RequiredLibs.push_back(Name);
|
|
|
|
}
|
|
|
|
|
2014-03-03 15:06:14 +00:00
|
|
|
for (unsigned i = 0, e = RequiredLibs.size(); i != e; ++i) {
|
|
|
|
StringRef Lib = RequiredLibs[i];
|
|
|
|
if (i)
|
|
|
|
OS << ' ';
|
2011-12-01 20:18:09 +00:00
|
|
|
|
2014-03-03 15:06:14 +00:00
|
|
|
if (PrintLibNames) {
|
|
|
|
OS << Lib;
|
|
|
|
} else if (PrintLibFiles) {
|
|
|
|
OS << ActiveLibDir << '/' << Lib;
|
|
|
|
} else if (PrintLibs) {
|
|
|
|
// If this is a typical library name, include it using -l.
|
2015-07-27 18:26:30 +00:00
|
|
|
if (Lib.startswith("lib")) {
|
|
|
|
size_t FromEnd = 0;
|
|
|
|
if (Lib.endswith(".a")) {
|
|
|
|
FromEnd = 2;
|
|
|
|
} else if (Lib.endswith(".so")) {
|
|
|
|
FromEnd = 3;
|
|
|
|
} else if (Lib.endswith(".dylib")) {
|
|
|
|
FromEnd = 6;
|
|
|
|
} else {
|
|
|
|
FromEnd = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FromEnd != 0) {
|
|
|
|
OS << "-l" << Lib.slice(3, Lib.size() - FromEnd);
|
|
|
|
} else {
|
|
|
|
OS << "-l:" << Lib;
|
|
|
|
}
|
2014-03-03 15:06:14 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, print the full path.
|
|
|
|
OS << ActiveLibDir << '/' << Lib;
|
|
|
|
}
|
2011-12-01 20:18:09 +00:00
|
|
|
}
|
2014-03-03 15:06:14 +00:00
|
|
|
OS << '\n';
|
2011-12-01 20:18:09 +00:00
|
|
|
}
|
2013-12-19 08:46:36 +00:00
|
|
|
|
|
|
|
// Print SYSTEM_LIBS after --libs.
|
|
|
|
// FIXME: Each LLVM component may have its dependent system libs.
|
|
|
|
if (PrintSystemLibs)
|
|
|
|
OS << LLVM_SYSTEM_LIBS << '\n';
|
2011-12-01 20:18:09 +00:00
|
|
|
} else if (!Components.empty()) {
|
|
|
|
errs() << "llvm-config: error: components given, but unused\n\n";
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|