summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2023-01-21 16:31:54 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2023-01-21 22:15:33 +0100
commita38c6682e4fb1f45aa1f37d10c2480aa517ea3bc (patch)
treed767d3f18eab231fdd0cff8fdd0c602869c42848 /src
parente4ccfe780f52cdb6c0764074effcd60235d33762 (diff)
Make sure libctor itself is built in the 'build' system and not 'host' system. Only detect tooling for the system/tools actually required in the tasks.
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap.cc18
-rw-r--r--src/configure.cc353
-rw-r--r--src/configure.cc.bak387
-rw-r--r--src/ctor.h4
-rw-r--r--src/task_ar.cc2
-rw-r--r--src/task_cc.cc1
-rw-r--r--src/task_ld.cc2
-rw-r--r--src/task_so.cc2
8 files changed, 277 insertions, 492 deletions
diff --git a/src/bootstrap.cc b/src/bootstrap.cc
index bb2d45f..55bd3e0 100644
--- a/src/bootstrap.cc
+++ b/src/bootstrap.cc
@@ -28,7 +28,7 @@ const ctor::configuration& ctor::get_configuration()
static bool initialised{false};
if(!initialised)
{
- cfg.host_toolchain = getToolChain(cfg.get(ctor::cfg::host_cxx, "/usr/bin/g++"));
+ cfg.build_toolchain = getToolChain(cfg.get(ctor::cfg::build_cxx, "/usr/bin/g++"));
initialised = true;
}
@@ -42,13 +42,25 @@ bool ctor::configuration::has(const std::string& key) const
const std::string& ctor::configuration::get(const std::string& key, const std::string& default_value) const
{
- if(key == ctor::cfg::host_cxx && std::getenv("CXX"))
+ if(key == ctor::cfg::build_cxx && std::getenv("CXX"))
{
static std::string s = std::getenv("CXX");
return s;
}
- if(key == ctor::cfg::host_ar && std::getenv("AR"))
+ if(key == ctor::cfg::build_cc && std::getenv("CC"))
+ {
+ static std::string s = std::getenv("CC");
+ return s;
+ }
+
+ if(key == ctor::cfg::build_ld && std::getenv("LD"))
+ {
+ static std::string s = std::getenv("LD");
+ return s;
+ }
+
+ if(key == ctor::cfg::build_ar && std::getenv("AR"))
{
static std::string s = std::getenv("AR");
return s;
diff --git a/src/configure.cc b/src/configure.cc
index b4829ac..c08ed88 100644
--- a/src/configure.cc
+++ b/src/configure.cc
@@ -30,7 +30,7 @@ const ctor::configuration& __attribute__((weak)) ctor::get_configuration()
static bool initialised{false};
if(!initialised)
{
- cfg.host_toolchain = getToolChain(cfg.get(ctor::cfg::host_cxx, "g++"));
+ cfg.build_toolchain = getToolChain(cfg.get(ctor::cfg::build_cxx, "/usr/bin/g++"));
initialised = true;
}
return cfg;
@@ -374,31 +374,101 @@ int regenerateCache(ctor::settings& settings,
}
auto tasks = getTasks(settings, {}, false);
-/*
- bool needs_cpp{false};
- bool needs_c{false};
- bool needs_ar{false};
- bool needs_asm{false};
+
+ bool needs_build{true}; // we always need to compile ctor itself
+ bool needs_build_c{false};
+ bool needs_build_cxx{true}; // we always need to compile ctor itself
+ bool needs_build_ld{true}; // we always need to compile ctor itself
+ bool needs_build_ar{false};
+ bool needs_build_asm{false};
+
+ bool needs_host_c{false};
+ bool needs_host{false};
+ bool needs_host_cxx{false};
+ bool needs_host_ld{false};
+ bool needs_host_ar{false};
+ bool needs_host_asm{false};
+
for(const auto& task :tasks)
{
- switch(task->sourceLanguage())
+ switch(task->outputSystem())
{
- case Language::Auto:
- std::cerr << "TargetLanguage not deduced!\n";
- exit(1);
- break;
- case Language::C:
- needs_cpp = false;
- break;
- case Language::Cpp:
- needs_c = true;
+ case ctor::output_system::build:
+ needs_build = true;
+ switch(task->targetType())
+ {
+ case ctor::target_type::executable:
+ case ctor::target_type::unit_test:
+ case ctor::target_type::dynamic_library:
+ needs_build_ld = true;
+ break;
+ case ctor::target_type::static_library:
+ case ctor::target_type::unit_test_library:
+ needs_build_ar = true;
+ break;
+ case ctor::target_type::object:
+ switch(task->sourceLanguage())
+ {
+ case ctor::language::automatic:
+ std::cerr << "TargetLanguage not deduced!\n";
+ exit(1);
+ break;
+ case ctor::language::c:
+ needs_build_c = true;
+ break;
+ case ctor::language::cpp:
+ needs_build_cxx = true;
+ break;
+ case ctor::language::assembler:
+ needs_build_asm = true;
+ break;
+ }
+ break;
+ case ctor::target_type::function:
+ case ctor::target_type::automatic:
+ case ctor::target_type::unknown:
+ break;
+ }
break;
- case Language::Asm:
- needs_asm = true;
+ case ctor::output_system::host:
+ needs_host = true;
+ switch(task->targetType())
+ {
+ case ctor::target_type::executable:
+ case ctor::target_type::unit_test:
+ case ctor::target_type::dynamic_library:
+ needs_host_ld = true;
+ break;
+ case ctor::target_type::static_library:
+ case ctor::target_type::unit_test_library:
+ needs_host_ar = true;
+ break;
+ case ctor::target_type::object:
+ switch(task->sourceLanguage())
+ {
+ case ctor::language::automatic:
+ std::cerr << "TargetLanguage not deduced!\n";
+ exit(1);
+ break;
+ case ctor::language::c:
+ needs_host_c = true;
+ break;
+ case ctor::language::cpp:
+ needs_host_cxx = true;
+ break;
+ case ctor::language::assembler:
+ needs_host_asm = true;
+ break;
+ }
+ break;
+ case ctor::target_type::function:
+ case ctor::target_type::automatic:
+ case ctor::target_type::unknown:
+ break;
+ }
break;
}
}
-*/
auto cc_env = env.find("CC");
if(cc_env != env.end())
@@ -432,94 +502,141 @@ int regenerateCache(ctor::settings& settings,
paths = get_paths(path_env->second);
}
- // Host detection
- auto host_cc = locate(cc_prog, paths, host_arch_prefix);
- if(host_cc.empty())
+ std::string host_cc;
+ std::string host_cxx;
+ std::string host_ld;
+ std::string host_ar;
+ ctor::toolchain host_toolchain{ctor::toolchain::none};
+ ctor::arch host_arch{ctor::arch::unknown};
+ if(needs_host)
{
- std::cerr << "Could not locate host_cc prog" << std::endl;
- return 1;
- }
+ // Host detection
+ if(needs_host_c)
+ {
+ host_cc = locate(cc_prog, paths, host_arch_prefix);
+ if(host_cc.empty())
+ {
+ std::cerr << "Could not locate host_cc prog" << std::endl;
+ return 1;
+ }
+ }
- auto host_cxx = locate(cxx_prog, paths, host_arch_prefix);
- if(host_cxx.empty())
- {
- std::cerr << "Could not locate host_cxx prog" << std::endl;
- return 1;
- }
+ if(needs_host_cxx)
+ {
+ host_cxx = locate(cxx_prog, paths, host_arch_prefix);
+ if(host_cxx.empty())
+ {
+ std::cerr << "Could not locate host_cxx prog" << std::endl;
+ return 1;
+ }
+ }
- auto host_ar = locate(ar_prog, paths, host_arch_prefix);
- if(host_ar.empty())
- {
- std::cerr << "Could not locate host_ar prog" << std::endl;
- return 1;
- }
+ if(needs_host_ar)
+ {
+ host_ar = locate(ar_prog, paths, host_arch_prefix);
+ if(host_ar.empty())
+ {
+ std::cerr << "Could not locate host_ar prog" << std::endl;
+ return 1;
+ }
+ }
- auto host_ld = locate(ld_prog, paths, host_arch_prefix);
- if(host_ld.empty())
- {
- std::cerr << "Could not locate host_ld prog" << std::endl;
- return 1;
- }
+ if(needs_host_ld)
+ {
+ host_ld = locate(ld_prog, paths, host_arch_prefix);
+ if(host_ld.empty())
+ {
+ std::cerr << "Could not locate host_ld prog" << std::endl;
+ return 1;
+ }
+ }
- auto host_toolchain = getToolChain(host_cxx);
- auto host_arch_str = get_arch(ctor::output_system::host);
- auto host_arch = get_arch(ctor::output_system::host, host_arch_str);
+ if(needs_host_asm)
+ {
+ // TODO
+ }
- std::cout << "** Host architecture '" << host_arch_str << "': " << host_arch << std::endl;
+ host_toolchain = getToolChain(host_cxx);
+ auto host_arch_str = get_arch(ctor::output_system::host);
+ host_arch = get_arch(ctor::output_system::host, host_arch_str);
- if(host_arch == ctor::arch::unknown)
- {
- std::cerr << "Could not detect host architecture" << std::endl;
- return 1;
- }
+ std::cout << "** Host architecture '" << host_arch_str << "': " << host_arch << std::endl;
- // Build detection
- auto build_cc = locate(cc_prog, paths, build_arch_prefix);
- if(build_cc.empty())
- {
- std::cerr << "Could not locate build_cc prog" << std::endl;
- return 1;
+ if(host_arch == ctor::arch::unknown)
+ {
+ std::cerr << "Could not detect host architecture" << std::endl;
+ return 1;
+ }
}
- auto build_cxx = locate(cxx_prog, paths, build_arch_prefix);
- if(build_cxx.empty())
+ std::string build_cc;
+ std::string build_cxx;
+ std::string build_ld;
+ std::string build_ar;
+ ctor::toolchain build_toolchain{ctor::toolchain::none};
+ ctor::arch build_arch{ctor::arch::unknown};
+ if(needs_build)
{
- std::cerr << "Could not locate build_cxx prog" << std::endl;
- return 1;
- }
+ // Build detection
+ if(needs_build_c)
+ {
+ build_cc = locate(cc_prog, paths, build_arch_prefix);
+ if(build_cc.empty())
+ {
+ std::cerr << "Could not locate build_cc prog" << std::endl;
+ return 1;
+ }
+ }
- auto build_ar = locate(ar_prog, paths, build_arch_prefix);
- if(build_ar.empty())
- {
- std::cerr << "Could not locate build_ar prog" << std::endl;
- return 1;
- }
+ if(needs_build_cxx)
+ {
+ build_cxx = locate(cxx_prog, paths, build_arch_prefix);
+ if(build_cxx.empty())
+ {
+ std::cerr << "Could not locate build_cxx prog" << std::endl;
+ return 1;
+ }
+ }
- auto build_ld = locate(ld_prog, paths, build_arch_prefix);
- if(build_ld.empty())
- {
- std::cerr << "Could not locate build_ld prog" << std::endl;
- return 1;
- }
+ if(needs_build_ar)
+ {
+ build_ar = locate(ar_prog, paths, build_arch_prefix);
+ if(build_ar.empty())
+ {
+ std::cerr << "Could not locate build_ar prog" << std::endl;
+ return 1;
+ }
+ }
- auto build_toolchain = getToolChain(build_cxx);
- auto build_arch_str = get_arch(ctor::output_system::build);
- auto build_arch = get_arch(ctor::output_system::build, build_arch_str);
+ if(needs_build_ld)
+ {
+ build_ld = locate(ld_prog, paths, build_arch_prefix);
+ if(build_ld.empty())
+ {
+ std::cerr << "Could not locate build_ld prog" << std::endl;
+ return 1;
+ }
+ }
- std::cout << "** Build architecture '" << build_arch_str << "': " << build_arch << std::endl;
+ if(needs_build_asm)
+ {
+ // TODO
+ }
- if(build_arch == ctor::arch::unknown)
- {
- std::cerr << "Could not detect build architecture" << std::endl;
- return 1;
- }
+ build_toolchain = getToolChain(build_cxx);
+ auto build_arch_str = get_arch(ctor::output_system::build);
+ build_arch = get_arch(ctor::output_system::build, build_arch_str);
- if(!host_cxx.empty())
- {
- // This is needed for bootstrapping (when running configure for the first time)
- ctor::conf_values[ctor::cfg::host_cxx] = host_cxx;
+ std::cout << "** Build architecture '" << build_arch_str << "': " << build_arch << std::endl;
+
+ if(build_arch == ctor::arch::unknown)
+ {
+ std::cerr << "Could not detect build architecture" << std::endl;
+ return 1;
+ }
}
+
// Store current values for execution in this execution context.
if(!ctor_includedir.empty())
{
@@ -544,10 +661,16 @@ int regenerateCache(ctor::settings& settings,
istr << "{\n";
istr << " static ctor::configuration cfg =\n";
istr << " {\n";
- istr << " .host_toolchain = " << host_toolchain << ",\n";
- istr << " .host_arch = " << host_arch << ",\n";
- istr << " .build_toolchain = " << build_toolchain << ",\n";
- istr << " .build_arch = " << build_arch << ",\n";
+ if(needs_host)
+ {
+ istr << " .host_toolchain = " << host_toolchain << ",\n";
+ istr << " .host_arch = " << host_arch << ",\n";
+ }
+ if(needs_build)
+ {
+ istr << " .build_toolchain = " << build_toolchain << ",\n";
+ istr << " .build_arch = " << build_arch << ",\n";
+ }
istr << " .args = {";
for(const auto& arg : args)
{
@@ -567,14 +690,44 @@ int regenerateCache(ctor::settings& settings,
istr << " { \"" << ctor::cfg::builddir << "\", \"" << esc(builddir) << "\" },\n";
ctor::builddir = builddir;
}
- istr << " { \"" << ctor::cfg::host_cc << "\", \"" << esc(host_cc) << "\" },\n";
- istr << " { \"" << ctor::cfg::host_cxx << "\", \"" << esc(host_cxx) << "\" },\n";
- istr << " { \"" << ctor::cfg::host_ar << "\", \"" << esc(host_ar) << "\" },\n";
- istr << " { \"" << ctor::cfg::host_ld << "\", \"" << esc(host_ld) << "\" },\n";
- istr << " { \"" << ctor::cfg::build_cc << "\", \"" << esc(build_cc) << "\" },\n";
- istr << " { \"" << ctor::cfg::build_cxx << "\", \"" << esc(build_cxx) << "\" },\n";
- istr << " { \"" << ctor::cfg::build_ar << "\", \"" << esc(build_ar) << "\" },\n";
- istr << " { \"" << ctor::cfg::build_ld << "\", \"" << esc(build_ld) << "\" },\n";
+ if(needs_host)
+ {
+ if(needs_host_c)
+ {
+ istr << " { \"" << ctor::cfg::host_cc << "\", \"" << esc(host_cc) << "\" },\n";
+ }
+ if(needs_host_cxx)
+ {
+ istr << " { \"" << ctor::cfg::host_cxx << "\", \"" << esc(host_cxx) << "\" },\n";
+ }
+ if(needs_host_ar)
+ {
+ istr << " { \"" << ctor::cfg::host_ar << "\", \"" << esc(host_ar) << "\" },\n";
+ }
+ if(needs_host_ld)
+ {
+ istr << " { \"" << ctor::cfg::host_ld << "\", \"" << esc(host_ld) << "\" },\n";
+ }
+ }
+ if(needs_build)
+ {
+ if(needs_build_c)
+ {
+ istr << " { \"" << ctor::cfg::build_cc << "\", \"" << esc(build_cc) << "\" },\n";
+ }
+ if(needs_build_cxx)
+ {
+ istr << " { \"" << ctor::cfg::build_cxx << "\", \"" << esc(build_cxx) << "\" },\n";
+ }
+ if(needs_build_ar)
+ {
+ istr << " { \"" << ctor::cfg::build_ar << "\", \"" << esc(build_ar) << "\" },\n";
+ }
+ if(needs_build_ld)
+ {
+ istr << " { \"" << ctor::cfg::build_ld << "\", \"" << esc(build_ld) << "\" },\n";
+ }
+ }
if(!ctor_includedir.empty())
{
istr << " { \"" << ctor::cfg::ctor_includedir << "\", \"" << esc(ctor_includedir) << "\" },\n";
diff --git a/src/configure.cc.bak b/src/configure.cc.bak
deleted file mode 100644
index bcbeea9..0000000
--- a/src/configure.cc.bak
+++ /dev/null
@@ -1,387 +0,0 @@
-// -*- c++ -*-
-// Distributed under the BSD 2-Clause License.
-// See accompanying file LICENSE for details.
-#include "configure.h"
-
-#include <iostream>
-#include <filesystem>
-#include <fstream>
-
-#include <getoptpp/getoptpp.hpp>
-
-#include "settings.h"
-#include "execute.h"
-#include "libcppbuild.h"
-#include "tasks.h"
-
-std::filesystem::path configurationFile("configuration.cc");
-std::filesystem::path configHeaderFile("config.h");
-
-const std::map<std::string, std::string> default_configuration{};
-const std::map<std::string, std::string>& __attribute__((weak)) configuration()
-{
- return default_configuration;
-}
-
-bool hasConfiguration(const std::string& key)
-{
- const auto& c = configuration();
- return c.find(key) != c.end();
-}
-
-const std::string& getConfiguration(const std::string& key,
- const std::string& defaultValue)
-{
- const auto& c = configuration();
- if(hasConfiguration(key))
- {
- return c.at(key);
- }
-
- return defaultValue;
-}
-
-
-/*
-Configuration:
- -h, --help display this help and exit
- --help=short display options specific to this package
- --help=recursive display the short help of all the included packages
- -V, --version display version information and exit
- -q, --quiet, --silent do not print `checking ...' messages
- --cache-file=FILE cache test results in FILE [disabled]
- -C, --config-cache alias for `--cache-file=config.cache'
- -n, --no-create do not create output files
- --srcdir=DIR find the sources in DIR [configure dir or `..']
-
-Installation directories:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [/usr/local]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [PREFIX]
-
-By default, `make install' will install all the files in
-`/usr/local/bin', `/usr/local/lib' etc. You can specify
-an installation prefix other than `/usr/local' using `--prefix',
-for instance `--prefix=$HOME'.
-
-For better control, use the options below.
-
-Fine tuning of the installation directories:
- --bindir=DIR user executables [EPREFIX/bin]
- --sbindir=DIR system admin executables [EPREFIX/sbin]
- --libexecdir=DIR program executables [EPREFIX/libexec]
- --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --libdir=DIR object code libraries [EPREFIX/lib]
- --includedir=DIR C header files [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc [/usr/include]
- --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
- --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
- --infodir=DIR info documentation [DATAROOTDIR/info]
- --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
- --mandir=DIR man documentation [DATAROOTDIR/man]
- --docdir=DIR documentation root [DATAROOTDIR/doc/drumgizmo]
- --htmldir=DIR html documentation [DOCDIR]
- --dvidir=DIR dvi documentation [DOCDIR]
- --pdfdir=DIR pdf documentation [DOCDIR]
- --psdir=DIR ps documentation [DOCDIR]
-
-Program names:
- --program-prefix=PREFIX prepend PREFIX to installed program names
- --program-suffix=SUFFIX append SUFFIX to installed program names
- --program-transform-name=PROGRAM run sed PROGRAM on installed program names
-
-System types:
- --build=BUILD configure for building on BUILD [guessed]
- --host=HOST cross-compile to build programs to run on HOST [BUILD]
-
-Optional Features:
- --disable-option-checking ignore unrecognized --enable/--with options
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --enable-silent-rules less verbose build output (undo: "make V=1")
- --disable-silent-rules verbose build output (undo: "make V=0")
- --enable-dependency-tracking
- do not reject slow dependency extractors
- --disable-dependency-tracking
- speeds up one-time build
- --enable-shared[=PKGS] build shared libraries [default=yes]
- --enable-static[=PKGS] build static libraries [default=yes]
- --enable-fast-install[=PKGS]
- optimize for fast installation [default=yes]
- --disable-libtool-lock avoid locking (might break parallel builds)
- --disable-largefile omit support for large files
- --enable-gui=backend Use specified gui backend. Can be x11, win32, cocoa,
- pugl-x11, pugl-win32, pugl-cocoa or auto
- [default=auto]
- --enable-custom-channel-count=count
- Compile with specified number of output channels
- [default=16]
- --enable-lv2 Compile the LV2 plugin [default=no]
- --enable-vst Compile the VST plugin [default=no]
- --enable-cli Compile the command line interface [default=yes]
- --disable-input-dummy Disable input dummy plugin [default=enabled]
- --disable-input-test Disable input test plugin [default=enabled]
- --disable-input-jackmidi
- Disable input jackmidi plugin [default=enabled]
- --disable-input-alsamidi
- Disable input alsamidi plugin [default=enabled]
- --disable-input-midifile
- Disable input midifile plugin [default=enabled]
- --disable-input-oss Disable input oss plugin [enabled by default on
- FreeBSD, disabled otherwise]
- --disable-output-dummy Disable output dummy plugin [default=enabled]
- --disable-output-jackaudio
- Disable output jack plugin [default=enabled]
- --disable-output-alsa Disable output alsa plugin [default=enabled]
- --disable-output-wavfile
- Disable output wavfile plugin [default=enabled]
- --disable-output-oss Disable output oss plugin [enabled by default on
- FreeBSD, disabled otherwise]
- --enable-sse=level Enable SSE Level 1, 2, 3 or auto [default=auto]
-
-Optional Packages:
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use
- both]
- --with-aix-soname=aix|svr4|both
- shared library versioning (aka "SONAME") variant to
- provide on AIX, [default=aix].
- --with-gnu-ld assume the C compiler uses GNU ld [default=no]
- --with-sysroot[=DIR] Search for dependent libraries within DIR (or the
- compiler's sysroot if not specified).
- --with-debug Build with debug support
- --with-nls Build with nls support (default nls enabled)
- --with-test Build unit tests
- --with-lv2dir=DIR Use DIR as the lv2 plugin directory
- [default=LIBDIR/lv2]
- --with-vst-sources Point this to the vstsdk24 directory
-
-Some influential environment variables:
- CXX C++ compiler command
- CXXFLAGS C++ compiler flags
- LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
- nonstandard directory <lib dir>
- LIBS libraries to pass to the linker, e.g. -l<library>
- CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
- you have headers in a nonstandard directory <include dir>
- OBJC Objective C compiler command
- OBJCFLAGS Objective C compiler flags
- OBJCXX Objective C++ compiler command
- OBJCXXFLAGS Objective C++ compiler flags
- CC C compiler command
- CFLAGS C compiler flags
- LT_SYS_LIBRARY_PATH
- User-defined run-time library search path.
- CPP C preprocessor
- CXXCPP C++ preprocessor
- PKG_CONFIG path to pkg-config utility
- PKG_CONFIG_PATH
- directories to add to pkg-config's search path
- PKG_CONFIG_LIBDIR
- path overriding pkg-config's built-in search path
- X11_CFLAGS C compiler flags for X11, overriding pkg-config
- X11_LIBS linker flags for X11, overriding pkg-config
- XEXT_CFLAGS C compiler flags for XEXT, overriding pkg-config
- XEXT_LIBS linker flags for XEXT, overriding pkg-config
- LV2_CFLAGS C compiler flags for LV2, overriding pkg-config
- LV2_LIBS linker flags for LV2, overriding pkg-config
- SMF_CFLAGS C compiler flags for SMF, overriding pkg-config
- SMF_LIBS linker flags for SMF, overriding pkg-config
- SNDFILE_CFLAGS
- C compiler flags for SNDFILE, overriding pkg-config
- SNDFILE_LIBS
- linker flags for SNDFILE, overriding pkg-config
- JACK_CFLAGS C compiler flags for JACK, overriding pkg-config
- JACK_LIBS linker flags for JACK, overriding pkg-config
- ALSA_CFLAGS C compiler flags for ALSA, overriding pkg-config
- ALSA_LIBS linker flags for ALSA, overriding pkg-config
-
-Use these variables to override the choices made by `configure' or to help
-it to find libraries and programs with nonstandard names/locations.
-
-Report bugs to the package provider.
-*/
-int configure(int argc, char* argv[])
-{
- Settings settings;
-
- settings.builddir = "build";
-
- std::string cmd_str;
- for(int i = 0; i < argc; ++i)
- {
- if(i > 0)
- {
- cmd_str += " ";
- }
- cmd_str += argv[i];
- }
-
- dg::Options opt;
- int key{256};
-
- std::string build_arch;
- std::string build_path;
- std::string host_arch;
- std::string host_path;
-
- opt.add("build-dir", required_argument, 'b',
- "Set output directory for build files (default: '" +
- settings.builddir + "').",
- [&]() {
- settings.builddir = optarg;
- return 0;
- });
-
- opt.add("verbose", no_argument, 'v',
- "Be verbose. Add multiple times for more verbosity.",
- [&]() {
- settings.verbose++;
- return 0;
- });
-
- opt.add("build", required_argument, key++,
- "Configure for building on specified architecture.",
- [&]() {
- build_arch = optarg;
- return 0;
- });
-
- opt.add("build-path", required_argument, key++,
- "Set path to build tool-chain.",
- [&]() {
- build_path = optarg;
- return 0;
- });
-
- opt.add("host", required_argument, key++,
- "Cross-compile to build programs to run on specified architecture.",
- [&]() {
- host_arch = optarg;
- return 0;
- });
-
- opt.add("host-path", required_argument, key++,
- "Set path to cross-compile tool-chain.",
- [&]() {
- host_path = optarg;
- return 0;
- });
-
- opt.add("help", no_argument, 'h',
- "Print this help text.",
- [&]() {
- std::cout << "configure usage stuff\n";
- opt.help();
- exit(0);
- return 0;
- });
-
- opt.process(argc, argv);
-
- if(host_arch.empty())
- {
- host_arch = build_arch;
- }
-
- auto tasks = getTasks(settings);
-
- bool needs_cpp{false};
- bool needs_c{false};
- bool needs_ar{false};
- bool needs_asm{false};
- for(const auto& task :tasks)
- {
- switch(task->sourceLanguage())
- {
- case Language::Auto:
- std::cerr << "TargetLanguage not deduced!\n";
- exit(1);
- break;
- case Language::C:
- needs_cpp = false;
- break;
- case Language::Cpp:
- needs_c = true;
- break;
- case Language::Asm:
- needs_asm = true;
- break;
- }
- }
-
- // CC=clang
- // CXX=clang++
-
- std::string path_env = std::getenv("PATH");
- std::cout << path_env << "\n";
-
- std::vector<std::string> paths;
-
- {
- std::stringstream ss(path_env);
- std::string path;
- while (std::getline(ss, path, ':'))
- {
- paths.push_back(path);
- }
- }
- for(const auto& path_str : paths)
- {
- std::filesystem::path path(path_str);
- auto gcc = path / "gcc";
- if(std::filesystem::exists(gcc))
- {
- std::cout << "Found file gcc in path: " << path << "\n";
- auto perms = std::filesystem::status(gcc).permissions();
- if((perms & std::filesystem::perms::owner_exec) != std::filesystem::perms::none)
- {
- std::cout << " - executable by owner\n";
- }
- if((perms & std::filesystem::perms::group_exec) != std::filesystem::perms::none)
- {
- std::cout << " - executable by group\n";
- }
- if((perms & std::filesystem::perms::others_exec) != std::filesystem::perms::none)
- {
- std::cout << " - executable by others\n";
- }
- }
- }
- exit(0);
-
- {
- std::ofstream istr(configurationFile);
- istr << "#include \"libcppbuild.h\"\n\n";
- istr << "const std::map<std::string, std::string>& configuration()\n";
- istr << "{\n";
- istr << " static std::map<std::string, std::string> c =\n";
- istr << " {\n";
- istr << " { \"cmd\", \"" << cmd_str << "\" },\n";
- istr << " { \"" << cfg::builddir << "\", \"" << settings.builddir << "\" },\n";
- istr << " { \"" << cfg::target_cc << "\", \"/usr/bin/gcc\" },\n";
- istr << " { \"" << cfg::target_cpp << "\", \"/usr/bin/g++\" },\n";
- istr << " { \"" << cfg::target_ar << "\", \"/usr/bin/ar\" },\n";
- istr << " { \"" << cfg::target_ld << "\", \"/usr/bin/ld\" },\n";
- istr << " { \"" << cfg::host_cc << "\", \"/usr/bin/gcc\" },\n";
- istr << " { \"" << cfg::host_cpp << "\", \"/usr/bin/g++\" },\n";
- istr << " { \"" << cfg::host_ar << "\", \"/usr/bin/ar\" },\n";
- istr << " { \"" << cfg::host_ld << "\", \"/usr/bin/ld\" },\n";
- istr << " };\n";
- istr << " return c;\n";
- istr << "}\n";
- }
-
- {
- std::ofstream istr(configHeaderFile);
- istr << "#pragma once\n\n";
- istr << "#define HAS_FOO 1\n";
- istr << "//#define HAS_BAR 1\n";
- }
-
- return 0;
-}
diff --git a/src/ctor.h b/src/ctor.h
index 1b6c560..3b64cb5 100644
--- a/src/ctor.h
+++ b/src/ctor.h
@@ -201,7 +201,7 @@ struct build_configuration
{
std::string name; // Name - used for referring in other configurations.
ctor::target_type type{ctor::target_type::automatic};
- ctor::output_system system{ctor::output_system::host};
+ ctor::output_system system{ctor::output_system::build};
std::string target; // Output target file for this configuration
std::vector<ctor::source> sources; // source list
std::vector<std::string> depends; // internal target dependencies
@@ -225,7 +225,7 @@ struct external_manual
struct external_configuration
{
std::string name; // Name for configuration
- ctor::output_system system{ctor::output_system::host};
+ ctor::output_system system{ctor::output_system::build};
std::variant<ctor::external_manual> external;
};
diff --git a/src/task_ar.cc b/src/task_ar.cc
index 60f7dd1..19a65ae 100644
--- a/src/task_ar.cc
+++ b/src/task_ar.cc
@@ -22,6 +22,8 @@ TaskAR::TaskAR(const ctor::build_configuration& config,
, sourceDir(sourceDir)
{
target_type = ctor::target_type::static_library;
+ output_system = config.system;
+
_targetFile = target;
auto toolchain = getToolChain(config.system);
_targetFile = extension(toolchain, target_type, config.system, _targetFile);
diff --git a/src/task_cc.cc b/src/task_cc.cc
index 5c4adfb..294c5ea 100644
--- a/src/task_cc.cc
+++ b/src/task_cc.cc
@@ -30,6 +30,7 @@ TaskCC::TaskCC(const ctor::build_configuration& config, const ctor::settings& se
base += sourceFile.stem();
target_type = ctor::target_type::object;
+ output_system = config.system;
source_language = source.language;
if(source_language == ctor::language::automatic)
{
diff --git a/src/task_ld.cc b/src/task_ld.cc
index b7e8749..b0aa4ae 100644
--- a/src/task_ld.cc
+++ b/src/task_ld.cc
@@ -22,6 +22,8 @@ TaskLD::TaskLD(const ctor::build_configuration& config,
, sourceDir(sourceDir)
{
target_type = config.type;
+ output_system = config.system;
+
if(target_type == ctor::target_type::automatic)
{
target_type = ctor::target_type::executable;
diff --git a/src/task_so.cc b/src/task_so.cc
index 54f9c05..ba96388 100644
--- a/src/task_so.cc
+++ b/src/task_so.cc
@@ -24,6 +24,8 @@ TaskSO::TaskSO(const ctor::build_configuration& config,
std::filesystem::path base = sourceDir;
target_type = ctor::target_type::dynamic_library;
+ output_system = config.system;
+
_targetFile = base / target;
auto toolchain = getToolChain(config.system);
_targetFile = extension(toolchain, target_type, config.system, _targetFile);