CFLAGS="-I$INCLUDEDIR `pkg-config --cflags sigc++-2.0`"
LIBS="`pkg-config --libs sigc++-2.0` -lpthread"
MACHINE="`uname -m`"
+SYSTEM="`uname -s`"
if [ "$MACHINE" = "x86_64" ]; then
MULTIARCH="x86_64-linux-gnu"
else
MULTIARCH="i386-linux-gnu"
fi
+if [ "$SYSTEM" = "Darwin" ]; then
+ COMPILER="clang++"
+else
+ COMPILER="g++"
+fi
if [ -e /usr/lib/libdl.so -o -e /usr/lib/$MULTIARCH/libdl.so ]; then
LIBS="$LIBS -ldl"
fi
echo "Compiling builder-stage1. This may take several minutes."
objects=""
for i in $sources; do
- obj=`mktemp --tmpdir=temp/bootstrap XXXXXX.o`
+ obj=`mktemp temp/bootstrap/XXXXXX`
+ mv $obj $obj.o
+ obj=$obj.o
dir=${i%/*}
dir=${dir%/unix}
flags="$CFLAGS"
if [ -d "$dir/unix" ]; then
flags="$flags -iquote $dir -iquote $dir/unix"
fi
- g++ -c $i -o $obj $flags
+ $COMPILER -c $i -o $obj $flags
objects="$objects $obj"
done
-g++ $objects -o builder-stage1 $LIBS
+$COMPILER $objects -o builder-stage1 $LIBS
if [ "$KEEP_TEMP" != "yes" ]; then
echo "Cleaning up"
{
"linux",
"freebsd",
+ "darwin",
"windows",
0
};
}
else
{
- sharedlib_patterns.push_back(Pattern("lib%.so"));
+ if(system=="darwin")
+ sharedlib_patterns.push_back(Pattern("lib%.dylib"));
+ else
+ sharedlib_patterns.push_back(Pattern("lib%.so"));
staticlib_patterns.push_back(Pattern("lib%.a"));
executable_patterns.push_back(Pattern("%"));
}
#include "binarypackage.h"
#include "builder.h"
#include "builtintools.h"
+#include "clangtools.h"
#include "datatool.h"
#include "gnutools.h"
#include "installedfile.h"
void Builder::add_default_tools()
{
+ if(current_arch->get_system()=="darwin")
+ toolchain.add_toolchain(new ClangTools(*this, *current_arch));
toolchain.add_toolchain(new GnuTools(*this, *current_arch));
toolchain.add_toolchain(new BuiltinTools(*this));
toolchain.add_tool(new DataTool(*this));
--- /dev/null
+#include "clangccompiler.h"
+
+ClangCCompiler::ClangCCompiler(Builder &b, const Architecture &a):
+ GnuCCompiler(b, a)
+{
+ set_command("clang", true);
+}
--- /dev/null
+#ifndef CLANGCCOMPILER_H_
+#define CLANGCCOMPILER_H_
+
+#include "gnuccompiler.h"
+
+class ClangCCompiler: public GnuCCompiler
+{
+public:
+ ClangCCompiler(Builder &, const Architecture &);
+};
+
+#endif
--- /dev/null
+#include "clangcxxcompiler.h"
+
+ClangCxxCompiler::ClangCxxCompiler(Builder &b, const Architecture &a):
+ GnuCxxCompiler(b, a)
+{
+ set_command("clang++", true);
+}
--- /dev/null
+#ifndef CLANGCXXCOMPILER_H_
+#define CLANGCXXCOMPILER_H_
+
+#include "gnucxxcompiler.h"
+
+class ClangCxxCompiler: public GnuCxxCompiler
+{
+public:
+ ClangCxxCompiler(Builder &, const Architecture &);
+};
+
+#endif
--- /dev/null
+#include "clangccompiler.h"
+#include "clangcxxcompiler.h"
+#include "clangtools.h"
+
+ClangTools::ClangTools(Builder &builder, const Architecture &arch)
+{
+ add_tool(new ClangCCompiler(builder, arch));
+ add_tool(new ClangCxxCompiler(builder, arch));
+}
--- /dev/null
+#ifndef CLANGTOOLS_H_
+#define CLANGTOOLS_H_
+
+#include "toolchain.h"
+
+class ClangTools: public Toolchain
+{
+public:
+ ClangTools(Builder &, const Architecture &);
+};
+
+#endif
else
argv.push_back(format("-O%d", binfo.optimize));
}
- if(binfo.threads && architecture->get_system()!="windows")
+ if(binfo.threads && architecture->get_system()!="windows" && architecture->get_system()!="darwin")
argv.push_back("-pthread");
if((comp.get_type()==Component::LIBRARY || comp.get_type()==Component::MODULE) && architecture->get_system()!="windows")
argv.push_back("-fPIC");
argv.push_back("-shared");
argv.push_back("-fPIC");
if(architecture->get_system()!="windows" && !shlib->get_soname().empty())
- argv.push_back("-Wl,-soname,"+shlib->get_soname());
+ {
+ if(architecture->get_system()=="darwin")
+ {
+ argv.push_back("-install_name");
+ argv.push_back(shlib->get_soname());
+
+ const string &ver = shlib->get_package()->get_version();
+ const string &if_ver = shlib->get_package()->get_interface_version();
+ if(!ver.empty() && !if_ver.empty())
+ {
+ argv.push_back("-current_version");
+ argv.push_back(ver);
+ argv.push_back("-compatibility_version");
+ argv.push_back(if_ver);
+ }
+ }
+ else
+ argv.push_back("-Wl,-soname,"+shlib->get_soname());
+ }
}
const BuildInfo &binfo = comp.get_build_info();
argv.push_back("-L"+i->str());
if(binfo.strip)
argv.push_back("-s");
- if(binfo.threads && architecture->get_system()!="windows")
+ if(binfo.threads && architecture->get_system()!="windows" && architecture->get_system()!="darwin")
argv.push_back("-pthread");
const Architecture &native_arch = builder.get_native_arch();
const Pattern &pattern = arch.get_shared_library_patterns().front();
if(arch.get_system()=="windows")
soname = pattern.apply(format("%s-%s", component->get_name(), version));
+ else if(arch.get_system()=="darwin")
+ {
+ string filename = pattern.apply(component->get_name());
+ string base = FS::basepart(filename);
+ string ext = FS::extpart(filename);
+ soname = format("%s.%s%s", base, version, ext);
+ }
else
soname = format("%s.%s", pattern.apply(component->get_name()), version);