+#include <msp/strconv.h>
#include <msp/strutils.h>
#include "builder.h"
#include "misc.h"
if(flags&LIB)
export_binfo.libpath.push_back((Path::Path(config.get_option("prefix").value)/"lib").str());
+ string optimize=config.get_option("optimize").value;
+ if(strtol(optimize))
+ {
+ build_info.cflags.push_back("-O"+optimize);
+ string cpu=config.get_option("cpu").value;
+ if(cpu!="auto")
+ build_info.cflags.push_back("-march="+cpu);
+ }
+
+ if(strtobool(config.get_option("debug").value))
+ build_info.cflags.push_back("-ggdb");
+
build_info.unique();
export_binfo.unique();
void Package::process_options(const RawOptionMap &opts)
{
- config.process(opts);
+ if(config.process(opts))
+ config.save(source/".options.cache");
}
Package *Package::create(Builder &b, const string &name)
{
list<string> argv;
argv.push_back("pkg-config");
+ argv.push_back("--silence-errors");
argv.push_back("--cflags");
argv.push_back("--libs");
argv.push_back(name);
vector<string> info=split(run_command(argv));
if(info.empty())
- return 0;
+ {
+ if(name=="opengl")
+ info.push_back("-lGL");
+ else if(name=="pthread")
+ info.push_back("-lpthread");
+ else
+ return 0;
+ }
Package *pkg=new Package(b, name, info);
return pkg;
{
buildable=true;
- config.add_option("tempdir", "temp", "Directory for storing temporary files");
- config.add_option("optimize", "0", "Apply compiler optimizations");
- config.add_option("debug", "0", "Produce debugging symbols");
+ config.add_option("tempdir", "temp", "Directory for storing temporary files");
+ config.add_option("optimize", "0", "Apply compiler optimizations");
+ config.add_option("debug", "0", "Produce debugging symbols");
+ config.add_option("cpu", "auto", "CPU type to optimize for");
+ config.add_option("arch", "native", "Architecture for cross-compiling");
const char *home=getenv("HOME");
unsigned flags=get_install_flags();
config.add_option("includedir", "$prefix/lib", "Library installation directory");
if(flags&DATA)
config.add_option("includedir", "$prefix/share", "Data installation directory");*/
+
+ config.load(source/".options.cache");
}
unsigned Package::get_install_flags()
add("require", &Loader::require);
add("program", &Loader::program);
add("library", &Loader::library);
+ add("headers", &Loader::headers);
}
Package::Loader::~Loader()
pkg.requires.push_back(PackageRef(pkg.builder, n));
}
-void Package::Loader::program(const std::string &n)
+void Package::Loader::program(const string &n)
{
Component prog(pkg, Component::PROGRAM, n);
load_sub(prog);
pkg.components.push_back(prog);
}
-void Package::Loader::library(const std::string &n)
+void Package::Loader::library(const string &n)
{
Component prog(pkg, Component::LIBRARY, n);
load_sub(prog);
pkg.components.push_back(prog);
}
+
+void Package::Loader::headers(const string &n)
+{
+ Component prog(pkg, Component::HEADERS, n);
+ load_sub(prog);
+ pkg.components.push_back(prog);
+}