summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-12-26 08:48:48 -0500
committermidipix <writeonce@midipix.org>2018-12-31 21:36:45 -0500
commitf7f887d5191514f5cd61db8f9e4cb9676c296abf (patch)
treee625a8482ac45336aae39c05ae51976f71674e1c
parenteb9c1bcf86daeb0dab4164ce59c68f2008f3d774 (diff)
downloadslibtool-f7f887d5191514f5cd61db8f9e4cb9676c296abf.tar.bz2
slibtool-f7f887d5191514f5cd61db8f9e4cb9676c296abf.tar.xz
build system: major overhaul: removed sysinfo, integrated ccenv.
-rw-r--r--Makefile.in78
-rw-r--r--config.usage11
-rwxr-xr-xconfigure220
-rw-r--r--sofort/ccenv/ccenv.in85
-rw-r--r--sofort/ccenv/ccenv.sh1021
-rw-r--r--sofort/ccenv/ccenv.usage84
-rw-r--r--sofort/ccenv/ccenv.vars82
-rw-r--r--sofort/config.vars14
-rw-r--r--sofort/exrules/default.mk8
-rw-r--r--sofort/exrules/pe-common.mk39
-rw-r--r--sofort/exrules/pe-dlltool.mk15
-rw-r--r--sofort/exrules/pe-mdso.mk15
-rw-r--r--sofort/exrules/pe-version.mk31
-rw-r--r--sofort/flag.vars3
-rw-r--r--sofort/flavor.mk10
-rwxr-xr-xsofort/version.sh (renamed from sysinfo/version.sh)0
-rw-r--r--sysinfo/compiler/any-compiler.mk29
-rw-r--r--sysinfo/compiler/clang.mk31
-rw-r--r--sysinfo/compiler/cparser.mk31
-rw-r--r--sysinfo/compiler/gcc.mk24
-rw-r--r--sysinfo/host/any-host.mk7
-rw-r--r--sysinfo/host/i686-nt32-midipix.mk5
-rw-r--r--sysinfo/host/i686-unknown-linux.mk5
-rw-r--r--sysinfo/host/i686-w64-mingw32.mk5
-rw-r--r--sysinfo/host/native.mk45
-rw-r--r--sysinfo/host/x86_64-nt64-midipix.mk5
-rw-r--r--sysinfo/host/x86_64-unknown-linux.mk5
-rw-r--r--sysinfo/host/x86_64-w64-mingw32.mk5
-rw-r--r--sysinfo/os/any-os.mk16
-rw-r--r--sysinfo/os/bsd.mk14
-rw-r--r--sysinfo/os/cygwin.mk17
-rw-r--r--sysinfo/os/darwin.mk18
-rw-r--r--sysinfo/os/elf.mk6
-rw-r--r--sysinfo/os/linux.mk14
-rw-r--r--sysinfo/os/midipix.mk15
-rw-r--r--sysinfo/os/mingw.mk18
-rw-r--r--sysinfo/os/mingw32.mk1
-rw-r--r--sysinfo/os/mingw64.mk1
-rw-r--r--sysinfo/os/msys.mk18
-rw-r--r--sysinfo/os/pe.mk99
-rw-r--r--sysinfo/toolchain/binutils.mk22
-rw-r--r--sysinfo/toolchain/llvm.mk22
42 files changed, 1493 insertions, 701 deletions
diff --git a/Makefile.in b/Makefile.in
index 0606c5b..5b8006a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -51,29 +51,29 @@ DVIDIR = @dvidir@
PDFDIR = @pdfdir@
PSDIR = @psdir@
-CFLAGS_COMMON = @cflags_common@
-CFLAGS_DEBUG = @cflags_debug@
-CFLAGS_CMDLINE = @cflags_cmdline@
-CFLAGS_CONFIG = @cflags_config@
-CFLAGS_SYSROOT = @cflags_sysroot@
-CFLAGS_OS = @cflags_os@
-CFLAGS_SITE = @cflags_site@
-CFLAGS_PATH = @cflags_path@
-CFLAGS_STRICT = @cflags_strict@
-CFLAGS_UTIL = @cflags_util@
-CFLAGS_LAST = @cflags_last@
-CFLAGS_ONCE = @cflags_once@
-
-LDFLAGS_COMMON = @ldflags_common@
-LDFLAGS_DEBUG = @ldflags_debug@
-LDFLAGS_CMDLINE = @ldflags_cmdline@
-LDFLAGS_CONFIG = @ldflags_config@
-LDFLAGS_SYSROOT = @ldflags_sysroot@
-LDFLAGS_PATH = @ldflags_path@
-LDFLAGS_STRICT = @ldflags_strict@
-LDFLAGS_UTIL = @ldflags_util@
-LDFLAGS_LAST = @ldflags_last@
-LDFLAGS_ONCE = @ldflags_once@
+CFLAGS_COMMON += @cflags_common@
+CFLAGS_DEBUG += @cflags_debug@
+CFLAGS_CMDLINE += @cflags_cmdline@
+CFLAGS_CONFIG += @cflags_config@
+CFLAGS_SYSROOT += @cflags_sysroot@
+CFLAGS_OS += @cflags_os@
+CFLAGS_SITE += @cflags_site@
+CFLAGS_PATH += @cflags_path@
+CFLAGS_STRICT += @cflags_strict@
+CFLAGS_UTIL += @cflags_util@
+CFLAGS_LAST += @cflags_last@
+CFLAGS_ONCE += @cflags_once@
+
+LDFLAGS_COMMON += @ldflags_common@
+LDFLAGS_DEBUG += @ldflags_debug@
+LDFLAGS_CMDLINE += @ldflags_cmdline@
+LDFLAGS_CONFIG += @ldflags_config@
+LDFLAGS_SYSROOT += @ldflags_sysroot@
+LDFLAGS_PATH += @ldflags_path@
+LDFLAGS_STRICT += @ldflags_strict@
+LDFLAGS_UTIL += @ldflags_util@
+LDFLAGS_LAST += @ldflags_last@
+LDFLAGS_ONCE += @ldflags_once@
USER_CC = @user_cc@
USER_CPP = @user_cpp@
@@ -87,15 +87,10 @@ ELF_EH_FRAME = @elf_eh_frame@
ELF_HASH_STYLE = @elf_hash_style@
ELF_CONFIG_DEFS = @elf_config_defs@
-NATIVE_CC = @native_cc@
-NATIVE_CC_HOST = @native_cc_host@
-NATIVE_CC_CFGHOST = @native_cc_cfghost@
-NATIVE_CC_CFLAGS = @native_cc_cflags@
-NATIVE_CC_LDFLAGS = @native_cc_ldflags@
-
-NATIVE_OS = @native_os@
-NATIVE_OS_BITS = @native_os_bits@
-NATIVE_OS_UNDERSCORE = @native_os_underscore@
+NATIVE_HOST = @native_host@
+NATIVE_CFGHOST = @native_cfghost@
+NATIVE_CFLAGS = @native_cflags@
+NATIVE_LDFLAGS = @native_ldflags@
ALL_SHARED = @all_shared@
ALL_STATIC = @all_static@
@@ -114,10 +109,8 @@ static:
install-extras:
install-app-extras:
-include $(PROJECT_DIR)/sysinfo/host/$(HOST).mk
-include $(PROJECT_DIR)/sysinfo/compiler/$(COMPILER).mk
-include $(PROJECT_DIR)/sysinfo/toolchain/$(TOOLCHAIN).mk
-include $(PROJECT_DIR)/sysinfo/os/$(OS).mk
+include ./ccenv/host.mk
+include ./ccenv/native.mk
include ./cfgdefs.mk
include ./usrdefs.mk
@@ -259,7 +252,7 @@ host.tag: Makefile
mv host.tmp host.tag
version.tag: $(GIT_REFERENCE_INDEX) dirs.tag
- $(PROJECT_DIR)/sysinfo/version.sh \
+ $(PROJECT_DIR)/sofort/version.sh \
-s $(SOURCE_DIR) \
-o build/$(PACKAGE)_version.h \
-p $(PACKAGE)
@@ -424,10 +417,13 @@ clean: clean-implib
.display-build:
@echo NATIVE_CC:' '$(NATIVE_CC)
- @echo NATIVE_CC_HOST:' '$(NATIVE_CC_HOST)
- @echo NATIVE_CC_CFGHOST:' '$(NATIVE_CC_CFGHOST)
- @echo NATIVE_CC_CFLAGS:' '$(NATIVE_CC_CFLAGS)
- @echo NATIVE_CC_LDFLAGS:' '$(NATIVE_CC_LDFLAGS)
+ @echo NATIVE_CPP:' '$(NATIVE_CPP)
+ @echo NATIVE_CXX:' '$(NATIVE_CXX)
+
+ @echo NATIVE_HOST:' '$(NATIVE_HOST)
+ @echo NATIVE_CFGHOST:' '$(NATIVE_CFGHOST)
+ @echo NATIVE_CFLAGS:' '$(NATIVE_CFLAGS)
+ @echo NATIVE_LDFLAGS:' '$(NATIVE_LDFLAGS)
@echo
@echo NATIVE_OS:' '$(NATIVE_OS)
@echo NATIVE_OS_BITS:' '$(NATIVE_OS_BITS)
diff --git a/config.usage b/config.usage
index f384ffe..0556093 100644
--- a/config.usage
+++ b/config.usage
@@ -154,10 +154,13 @@ supported variables:
ELF_CONFIG_DEFS
NATIVE_CC
- NATIVE_CC_HOST
- NATIVE_CC_CFGHOST
- NATIVE_CC_CFLAGS
- NATIVE_CC_LDFLAGS
+ NATIVE_CPP
+ NATIVE_CXX
+
+ NATIVE_HOST
+ NATIVE_CFGHOST
+ NATIVE_CFLAGS
+ NATIVE_LDFLAGS
NATIVE_OS
NATIVE_OS_BITS
diff --git a/configure b/configure
index 49596b9..e3a3bbb 100755
--- a/configure
+++ b/configure
@@ -69,6 +69,18 @@ init_vars()
eval "$mb_expr"
done
+ # ccenv
+ . $mb_project_dir/sofort/ccenv/ccenv.sh
+
+ if ! readlink ./ccenv > /dev/null; then
+ if [ -d ./ccenv ]; then
+ rm -f ./ccenv/host.mk
+ rm -f ./ccenv/native.mk
+ rmdir ./ccenv
+ fi
+ fi
+
+ # config.project
if [ -z "$mb_config" ]; then
. $mb_project_dir/config.project
else
@@ -169,19 +181,18 @@ init_vars()
mb_elf_config_defs=$ELF_CONFIG_DEFS
# overrides
- mb_native_cc=$NATIVE_CC
- mb_native_cc_host=$NATIVE_CC_HOST
- mb_native_cc_cfghost=$NATIVE_CC_CFGHOST
- mb_native_cc_cflags=$NATIVE_CC_CFLAGS
- mb_native_cc_ldflags=$NATIVE_CC_LDFLAGS
-
- mb_native_os=$NATIVE_OS
- mb_native_os_bits=$NATIVE_OS_BITS
- mb_native_os_underscore=$NATIVE_OS_UNDERSCORE
-
mb_user_cc=$CC
mb_user_cpp=$CPP
mb_user_cxx=$CXX
+
+ mb_native_cc=$NATIVE_CC
+ mb_native_cpp=$NATIVE_CPP
+ mb_native_cxx=$NATIVE_CXX
+
+ mb_native_host=$NATIVE_HOST
+ mb_native_cfghost=$NATIVE_CFGHOST
+ mb_native_cflags=$NATIVE_CFLAGS
+ mb_native_ldflags=$NATIVE_LDFLAGS
}
@@ -351,132 +362,6 @@ common_defaults()
mb_cflags_debug='-g3 -O0'
fi
fi
-
- # toolchain
- if [ -z "$mb_toolchain" ]; then
- mb_toolchain='binutils'
- fi
-
- # fallback host recipe
- if [ -n "$mb_host" ]; then
- if ! [ -f $mb_project_dir/sysinfo/host/$mb_host.mk ]; then
- if [ -z "$mb_cross_compile" ]; then
- mb_cross_compile=$mb_host-
- fi
-
- mb_host='any-host';
- fi
- fi
-
- # fallback compiler recipe
- if [ -n "$mb_compiler" ]; then
- if ! [ -f $mb_project_dir/sysinfo/compiler/$mb_compiler.mk ]; then
- mb_compiler='any-compiler'
- fi
- fi
-}
-
-
-native_defaults()
-{
- # CC (when set, must be valid)
- if [ -n "$CC" ]; then
- $CC -dM -E - < /dev/null > /dev/null
- fi
-
- # compiler
- [ -z "$mb_native_cc" ] && mb_native_cc='cc'
- $mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
-
- [ -z "$mb_native_cc" ] && mb_native_cc='gcc'
- $mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
-
- [ -z "$mb_native_cc" ] && mb_native_cc='clang'
- $mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
-
- [ -z "$mb_native_cc" ] && mb_native_cc='cparser'
- $mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
-
- if [ -z "$mb_native_cc" ]; then
- echo "configure: info: could not find a working native compiler."
- mb_native_cc='false'
- fi
-
- if [ -z "$mb_native_cc_host" ]; then
- mb_native_cc_host=$($mb_native_cc $mb_native_cc_cflags -dumpmachine)
- fi
-
- if [ -z "$mb_compiler" ]; then
- $mb_native_cc -dM -E - < /dev/null | grep -q '__clang__' && mb_compiler='clang'
- fi
-
- if [ -z "$mb_compiler" ]; then
- $mb_native_cc -dM -E - < /dev/null | grep -q '__GCC' && mb_compiler='gcc'
- fi
-
- if [ -z "$mb_compiler" ]; then
- $mb_native_cc -dM -E - < /dev/null | grep -q "^gcc" && mb_compiler='gcc'
- fi
-
- if [ -z "$mb_compiler" ]; then
- $mb_native_cc -dM -E - < /dev/null | grep -q '__CPARSER__' && mb_compiler='cparser'
- fi
-
- if [ -z "$mb_compiler" ]; then
- echo "configure: info: could not identify the native compiler."
- mb_compiler='any-compiler'
- fi
-
-
- # host
- if [ -z "$mb_host" ]; then
- mb_host='native'
- fi
-
-
- # target
- if [ -z "$mb_target" ]; then
- mb_target='native'
- fi
-
-
- # os
- if [ -z "$mb_native_os" ]; then
- mb_native_os=$(uname | tr '[:upper:]' '[:lower:]')
- fi
-
- mb_native_os_sizeof_pointer=$($mb_native_cc -dM -E - < /dev/null \
- | awk '$2 == "__SIZEOF_POINTER__" { print $3 }')
-
- mb_native_os_bits=$((8 * ${mb_native_os_sizeof_pointer:-0}))
-
- if [ $mb_native_os_bits = 32 ]; then
- mb_native_os_underscore='_'
- else
- mb_native_os_underscore=''
- fi
-
- if [ -z "$mb_native_os_sizeof_pointer" ]; then
- warning_msg "config error: could not determine size of pointer on native system."
- fi
-
- # grumpily support crooked uname output
- if ! [ -f $mb_project_dir/sysinfo/os/$mb_native_os.mk ]; then
- mb_native_os=$(echo $mb_native_os | cut -d'_' -f1)
- fi
-
- # fallback os recipe
- if ! [ -f $mb_project_dir/sysinfo/os/$mb_native_os.mk ]; then
- mb_native_os='any-os';
- fi
-}
-
-
-cross_defaults()
-{
- if [ -z "$mb_cross_compile" ] && [ "$mb_host" != native ]; then
- mb_cross_compile=$mb_host'-'
- fi
}
@@ -517,23 +402,18 @@ config_copy()
$mb_project_dir/Makefile.in \
| sed -e 's/[ \t]*$//g' \
> $mb_pwd/Makefile.tmp
+}
- if [ -z "$mb_cchost" ]; then
- if [ "$mb_host" = 'native' ]; then
- if [ -n "$mb_user_cc" ]; then
- mbt_cc="$mb_user_cc"
- else
- mbt_cc="$mb_native_cc"
- fi
- mbt_cflags=$(make -f $mb_pwd/Makefile.tmp .display-cflags)
- mb_cchost=$($mbt_cc $mbt_cflags -dumpmachine)
- else
- mb_cchost=$mb_host
- fi
- fi
-}
+config_ccenv()
+{
+ mkdir -p ./ccenv
+ touch ./ccenv/host.mk
+ touch ./ccenv/native.mk
+ ccenv_set_host_variables
+ ccenv_set_native_variables
+}
config_custom()
{
@@ -631,7 +511,32 @@ verify_build_directory
# two: args
for arg ; do
case "$arg" in
- --help) usage
+ --help)
+ usage
+ ;;
+ --help=ccenv)
+ ccenv_usage
+ ;;
+
+ # ccenv
+ --cross-compile=*)
+ mb_cross_compile=${arg#*=}
+ ;;
+ --compiler=*)
+ mb_compiler=${arg#*=}
+ ;;
+ --toolchain=*)
+ mb_toolchain=${arg#*=}
+ ;;
+ --zealous)
+ mb_agnostic=yes
+ mb_zealous=
+ ;;
+ --zealous=*)
+ mb_zealous=${arg#*=}
+ ;;
+ --ccenv=*)
+ mb_ccenv=${arg#*=}
;;
# dirs
@@ -724,18 +629,9 @@ for arg ; do
--arch=*)
mb_arch=${arg#*=}
;;
- --compiler=*)
- mb_compiler=${arg#*=}
- ;;
- --toolchain=*)
- mb_toolchain=${arg#*=}
- ;;
--sysroot=*)
mb_sysroot=${arg#*=}
;;
- --cross-compile=*)
- mb_cross_compile=${arg#*=}
- ;;
--shell=*)
mb_shell=${arg#*=}
;;
@@ -867,14 +763,12 @@ fi
# four: defaults
common_defaults
-native_defaults
-cross_defaults
-
# five: config
config_flags
config_copy
+config_ccenv
config_custom
config_cfghost
config_support
diff --git a/sofort/ccenv/ccenv.in b/sofort/ccenv/ccenv.in
new file mode 100644
index 0000000..531a7dd
--- /dev/null
+++ b/sofort/ccenv/ccenv.in
@@ -0,0 +1,85 @@
+# @ccenv_cfgtype@ system flavor
+OS = @ccenv_os@
+OS_SEMANTICS = @ccenv_os_semantics@
+
+OS_DSO_EXRULES = @ccenv_os_dso_exrules@
+OS_DSO_LINKAGE = @ccenv_os_dso_linkage@
+
+OS_APP_PREFIX = @ccenv_os_app_prefix@
+OS_APP_SUFFIX = @ccenv_os_app_suffix@
+
+OS_LIB_PREFIX = @ccenv_os_lib_prefix@
+OS_LIB_SUFFIX = @ccenv_os_lib_suffix@
+
+OS_IMPLIB_EXT = @ccenv_os_implib_ext@
+OS_LIBDEF_EXT = @ccenv_os_libdef_ext@
+
+OS_ARCHIVE_EXT = @ccenv_os_archive_ext@
+OS_SONAME = @ccenv_os_soname@
+
+OS_LIB_PREFIXED_SUFFIX = @ccenv_os_lib_prefixed_suffix@
+OS_LIB_SUFFIXED_SUFFIX = @ccenv_os_lib_suffixed_suffix@
+
+# @ccenv_cfgtype@ characteristics
+CC_HOST = @ccenv_cc_host@
+CC_BITS = @ccenv_cc_bits@
+
+CC_BINFMT = @ccenv_cc_binfmt@
+CC_UNDERSCORE = @ccenv_cc_underscore@
+
+CC_ARCH_BFD = @ccenv_cc_arch_bfd@
+CC_ARCH_LLVM = @ccenv_cc_arch_llvm@
+
+# incompatible tool variants
+AS_ASM = @ccenv_as_asm@
+AS_LL = @ccenv_as_ll@
+AS_MC = @ccenv_as_mc@
+
+LD_BFD = @ccenv_ld_bfd@
+LD_GOLD = @ccenv_ld_gold@
+LD_LLD = @ccenv_ld_lld@
+
+OBJDUMP_BFD = @ccenv_objdump_bfd@
+OBJDUMP_LLVM = @ccenv_objdump_llvm@
+
+READELF_BFD = @ccenv_readelf_bfd@
+READELF_LLVM = @ccenv_readelf_llvm@
+
+# @ccenv_cfgtype@ primary tools
+CC = @ccenv_cc@
+CPP = @ccenv_cpp@
+CXX = @ccenv_cxx@
+
+AR = @ccenv_ar@
+NM = @ccenv_nm@
+OBJDUMP = @ccenv_objdump@
+RANLIB = @ccenv_ranlib@
+SIZE = @ccenv_size@
+STRIP = @ccenv_strip@
+STRINGS = @ccenv_strings@
+
+ADDR2LINE = @ccenv_addr2line@
+COV = @ccenv_cov@
+CXXFILT = @ccenv_cxxfilt@
+OBJCOPY = @ccenv_objcopy@
+
+ELFEDIT = @ccenv_elfedit@
+READELF = @ccenv_readelf@
+READOBJ = @ccenv_readobj@
+
+PERK = @ccenv_perk@
+MDSO = @ccenv_mdso@
+DLLTOOL = @ccenv_dlltool@
+
+WINDMC = @ccenv_windmc@
+WINDRC = @ccenv_windrc@
+
+# @ccenv_cfgtype@ secondary tools
+# note: the direct use of $(@ccenv_makevar_prefix@LD) is highly discouraged
+AS = @ccenv_as@
+LD = @ccenv_ld@
+
+# @ccenv_cfgtype@ cflags
+CFLAGS_OS += @ccenv_cflags_os@
+CFLAGS_PIC += @ccenv_cflags_pic@
+
diff --git a/sofort/ccenv/ccenv.sh b/sofort/ccenv/ccenv.sh
new file mode 100644
index 0000000..91d9309
--- /dev/null
+++ b/sofort/ccenv/ccenv.sh
@@ -0,0 +1,1021 @@
+# ccenv.sh: sofort's tool-finding bits,
+# invoked from within the project-agnostic configure script.
+
+# invocation and names of binary tools:
+# agnostic names (ar, nm, objdump, ...);
+# target-prefixed agnostic names (x86_64-nt64-midipix-ar, ...);
+# branded names (llvm-ar, llvm-nm, llvm-objdump, ...);
+# target-prefixed branded names (x86_64-linux-gnu-gcc-ar, ...);
+# target-specifying branded tools (llvm-ar --target=x86_64-linux, ...).
+
+# cross-compilation: default search order:
+# target-prefixed agnostic tools;
+# target-prefixed branded tools, starting with the prefix
+# most commonly associated with the selected compiler (that is,
+# ``gcc'' when using gcc, and ``llvm'' when using clang);
+# target-speficying branded tools, starting once again with the
+# prefix most commonly associated with the selected compiler.
+
+# internal variables of interest:
+# ccenv_cfgtype: the type of host being tested (host/native)
+# ccenv_cfgfile: the configuration file for the host being tested
+# ccenv_cflags: the comprehensive cflags for the host being tested
+# ccenv_cchost: the host being tested, as reported by -dumpmachine
+
+
+ccenv_usage()
+{
+ cat "$mb_project_dir"/sofort/ccenv/ccenv.usage
+ exit 0
+}
+
+
+ccenv_newline()
+{
+ printf '\n' >> "$ccenv_cfgfile"
+}
+
+
+ccenv_comment()
+{
+ ccenv_internal_str='#'
+
+ for ccenv_internal_arg ; do
+ ccenv_internal_str="$ccenv_internal_str $ccenv_internal_arg"
+ done
+
+ printf '%s\n' "$ccenv_internal_str" >> "$ccenv_cfgfile"
+}
+
+
+ccenv_find_tool()
+{
+ if [ -z "$ccenv_prefixes" ]; then
+ for ccenv_tool in $ccenv_candidates; do
+ command -v "$ccenv_tool" > /dev/null && return 0
+ done
+
+ ccenv_tool=false
+
+ return 0
+ fi
+
+ for ccenv_prefix in $ccenv_prefixes; do
+ for ccenv_candidate in $ccenv_candidates; do
+ ccenv_tool="$ccenv_prefix$ccenv_candidate"
+ command -v "$ccenv_tool" > /dev/null && return 0
+ done
+ done
+
+ for ccenv_tool in $ccenv_candidates; do
+ command -v "$ccenv_tool" > /dev/null && return 0
+ done
+
+ ccenv_tool=false
+
+ return 0
+}
+
+
+ccenv_set_primary_tools()
+{
+ ccenv_core_tools="ar nm objdump ranlib size strip strings objcopy"
+ ccenv_hack_tools="addr2line cov elfedit readelf readobj"
+ ccenv_peep_tools="perk mdso dlltool windmc windres"
+
+ for __tool in $ccenv_core_tools $ccenv_hack_tools $ccenv_peep_tools; do
+ if [ -n "$mb_agnostic" ]; then
+ ccenv_candidates=" $__tool"
+
+ elif [ -n "$mb_zealous" ]; then
+ ccenv_candidates="$mb_zealous-$__tool"
+
+ elif [ "$mb_toolchain" = 'gcc' ]; then
+ ccenv_candidates="gcc-$__tool"
+ ccenv_candidates="$ccenv_candidates $__tool"
+ ccenv_candidates="$ccenv_candidates llvm-$__tool"
+
+ elif [ "$mb_toolchain" = 'llvm' ]; then
+ ccenv_candidates="llvm-$__tool"
+ ccenv_candidates="$ccenv_candidates $__tool"
+ ccenv_candidates="$ccenv_candidates gcc-$__tool"
+
+ elif [ -n "$mb_toolchain" ]; then
+ ccenv_candidates="$mb_toolchain-$__tool"
+ ccenv_candidates="$ccenv_candidates $__tool"
+ ccenv_candidates="$ccenv_candidates gcc-$__tool"
+ ccenv_candidates="$ccenv_candidates llvm-$__tool"
+
+ else
+ ccenv_candidates="$__tool"
+ ccenv_candidates="$ccenv_candidates gcc-$__tool"
+ ccenv_candidates="$ccenv_candidates llvm-$__tool"
+ fi
+
+ if [ "$ccenv_cfgtype" = 'host' ]; then
+ ccenv_var_prefix='mb_'
+ else
+ ccenv_var_prefix='mb_native_'
+ fi
+
+ ccenv_var_name=$ccenv_var_prefix$__tool
+ ccenv_var_expr='${'$ccenv_var_name':-}'
+ eval ccenv_var_val=$ccenv_var_expr
+
+ if [ -n "$ccenv_var_val" ]; then
+ eval ccenv_$__tool="$ccenv_var_val"
+ else
+ ccenv_find_tool
+ eval ccenv_$__tool="$ccenv_tool"
+ fi
+ done
+
+ # windrc
+ ccenv_windrc="$ccenv_windres"
+}
+
+ccenv_set_tool_variants()
+{
+ # as (asm)
+ ccenv_candidates=as
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" = false ]; then
+ ccenv_as_asm=
+ else
+ $ccenv_tool --help | grep -i '.bc assembler' \
+ || ccenv_as_asm="$ccenv_tool"
+ fi
+
+ # as (ll)
+ ccenv_candidates=llvm-as
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" != false ]; then
+ ccenv_as_ll="$ccenv_tool"
+ fi
+
+ # as (mc)
+ ccenv_candidates=llvm-mc
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" != false ]; then
+ ccenv_as_mc="$ccenv_tool"
+ fi
+
+ # ld (bfd)
+ ccenv_candidates=ld.bfd
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" != false ]; then
+ ccenv_ld_bfd="$ccenv_tool"
+ fi
+
+ # ld (gold)
+ ccenv_candidates=ld.gold
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" != false ]; then
+ ccenv_ld_gold="$ccenv_tool"
+ fi
+
+ # ld (lld)
+ ccenv_candidates=lld
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" != false ]; then
+ ccenv_ld_lld="$ccenv_tool"
+ fi
+
+ # objdump (bfd)
+ ccenv_candidates=objdump
+ ccenv_find_tool
+
+ $ccenv_tool --version | grep -i Binutils \
+ > /dev/null \
+ && ccenv_objdump_bfd="$ccenv_tool"
+
+ # objdump (llvm)
+ ccenv_candidates=llvm-objdump
+ ccenv_find_tool
+
+ $ccenv_tool --version | grep -i LLVM \
+ > /dev/null \
+ && ccenv_objdump_llvm="$ccenv_tool"
+
+ # readelf (bfd)
+ ccenv_candidates=readelf
+ ccenv_find_tool
+
+ $ccenv_tool --version | grep -i Binutils \
+ > /dev/null \
+ && ccenv_readelf_bfd="$ccenv_tool"
+
+ # readelf (llvm)
+ ccenv_candidates=llvm-readelf
+ ccenv_find_tool
+
+ $ccenv_tool --version | grep -i LLVM \
+ > /dev/null \
+ && ccenv_readelf_llvm="$ccenv_tool"
+
+ # as
+ if [ -n "$ccenv_cc" ]; then
+ ccenv_as='$('"$ccenv_makevar_prefix"'CC) -x assembler'
+ elif [ -n "$mb_agnostic" ]; then
+ ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
+ elif [ "$mb_zealous" = 'gcc' ]; then
+ ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
+ elif [ -n "$mb_zealous" = 'llvm' ]; then
+ ccenv_as='$('"$ccenv_makevar_prefix"'AS_MC)'
+ elif [ "$mb_toolchain" = 'gcc' ]; then
+ ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
+ elif [ "$mb_toolchain" = 'llvm' ]; then
+ ccenv_as='$('"$ccenv_makevar_prefix"'AS_MC)'
+ fi
+
+ # ld
+ if [ -n "$ccenv_cc" ]; then
+ ccenv_ld='$('"$ccenv_makevar_prefix"'CC) -nostdlib -nostartfiles'
+ fi
+}
+
+ccenv_set_c_compiler_candidates()
+{
+ if [ -n "$mb_compiler" ]; then
+ ccenv_candidates="$mb_compiler"
+
+ elif [ -n "$mb_agnostic" ]; then
+ ccenv_candidates="c99 c11 cc"
+
+ elif [ "$mb_zealous" = 'gcc' ]; then
+ ccenv_candidates="gcc"
+
+ elif [ "$mb_zealous" = 'llvm' ]; then
+ ccenv_candidates="clang"
+
+ elif [ "$mb_toolchain" = 'gcc' ]; then
+ ccenv_candidates="gcc c99 c11 cc clang"
+
+ elif [ "$mb_toolchain" = 'llvm' ]; then
+ ccenv_candidates="clang c99 c11 cc gcc"
+
+ elif [ -n "$mb_toolchain" ]; then
+ ccenv_candidates="$mb_toolchain c99 c11 cc gcc clang"
+
+ else
+ ccenv_candidates="c99 c11 cc gcc clang"
+ fi
+}
+
+
+ccenv_set_cc()
+{
+ if [ -z "$ccenv_cc" ]; then
+ ccenv_set_c_compiler_candidates
+ ccenv_find_tool
+ ccenv_cc="$ccenv_tool"
+ fi
+
+ if [ "$ccenv_cc" = false ] && [ -n "$mb_compiler" ]; then
+ ccenv_cc="$mb_compiler"
+ fi
+
+ ccenv_cc_cmd="$ccenv_cc"
+
+ if [ "$ccenv_cfgtype" = 'native' ]; then
+ return 0
+ fi
+
+ if [ -n "$mb_cchost" ]; then
+ ccenv_host="$mb_cchost"
+ elif [ -n "$mb_host" ]; then
+ ccenv_host="$mb_host"
+ else
+ ccenv_host=
+ fi
+
+ if [ -z "$ccenv_host" ]; then
+ ccenv_host=$($ccenv_cc $ccenv_cflags -dumpmachine 2>/dev/null)
+ ccenv_cchost=$ccenv_host
+ else
+ ccenv_tmp=$(mktemp)
+ ccenv_cmd="$ccenv_cc --target=$ccenv_host -E -xc -"
+
+ if [ -z "$mb_user_cc" ]; then
+ $ccenv_cmd < /dev/null > /dev/null \
+ 2>"$ccenv_tmp" || true
+
+ ccenv_errors=$(cat "$ccenv_tmp")
+
+ if [ -z "$ccenv_errors" ]; then
+ ccenv_tflags="--target=$ccenv_host"
+ ccenv_cc="$ccenv_cc $ccenv_tflags"
+ fi
+ fi
+
+ ccenv_cchost=$($ccenv_cc $ccenv_cflags -dumpmachine 2>/dev/null)
+ fi
+
+ if [ "$ccenv_cchost" != "$ccenv_host" ]; then
+ printf 'ccenv:\n' >&2
+ printf 'ccenv: ccenv_host: %s \n' $ccenv_host >&2
+ printf 'ccenv: ccenv_cchost: %s \n' $ccenv_cchost >&2
+
+ if [ -z "$ccenv_tflags" ]; then
+ printf 'ccenv:\n' >&2
+ printf 'ccenv: ccenv_host and ccenv_cchost do not match, most likely because:\n' >&2
+ printf 'ccenv: (1) you explicitly set CC (or passed --compiler=...)\n' >&2
+ printf 'ccenv: (2) the selected compiler does not accept --target=...\n' >&2
+ printf 'ccenv: (3) the host reported by -dumpmachine differs from the one you requested.\n' >&2
+ fi
+
+ if [ -n "$ccenv_errors" ]; then
+ printf 'ccenv:\n' >&2
+ printf 'ccenv: something went wrong, see the command and compiler message below.\n\n' >&2
+ printf 'cmd: %s < /dev/null > /dev/null\n' "$ccenv_cmd" >&2
+ printf '%s\n\n' "$ccenv_errors" >&2
+ else
+ printf 'ccenv:\n' >&2
+ printf 'ccenv: something went wrong, bailing out.\n\n' >&2
+ fi
+
+ return 2
+ fi
+}
+
+ccenv_set_cpp()
+{
+ case "$ccenv_cc_cmd" in
+ cc | c99 | c11 | gcc)
+ ccenv_cpp_prefix=
+ ccenv_candidates="cpp" ;;
+
+ clang )
+ ccenv_cpp_prefix=
+ ccenv_candidates="clang-cpp" ;;
+
+ *-cc )
+ ccenv_cpp_prefix=${ccenv_cc_cmd%-cc*}-
+ ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
+
+ *-c99 )
+ ccenv_cpp_prefix=${ccenv_cc_cmd%-c99*}-
+ ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
+
+ *-c11 )
+ ccenv_cpp_prefix=${ccenv_cc_cmd%-c11*}-
+ ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
+
+ *-gcc )
+ ccenv_cpp_prefix=${ccenv_cc_cmd%-gcc*}-
+ ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
+
+ *-clang )
+ ccenv_cpp_prefix=${ccenv_cc_cmd%-clang*}-
+ ccenv_candidates="${ccenv_cpp_prefix}clang-cpp" ;;
+
+ * )
+ ccenv_cpp="$ccenv_cc -E"
+ return 0
+ esac
+
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" = false ]; then
+ ccenv_cpp="$ccenv_cc -E"
+ elif [ -n "$ccenv_tflags" ]; then
+ ccenv_cpp="$ccenv_tool $ccenv_tflags"
+ else
+ ccenv_cpp="$ccenv_tool"
+ fi
+}
+
+ccenv_set_cxx()
+{
+ case "$ccenv_cc_cmd" in
+ cc | c99 | c11 )
+ ccenv_cxx_prefix=
+ ccenv_candidates="cxx c++" ;;
+
+ gcc )
+ ccenv_cxx_prefix=
+ ccenv_candidates="g++" ;;
+
+ clang )
+ ccenv_cxx_prefix=
+ ccenv_candidates="clang++" ;;
+
+ *-gcc )
+ ccenv_cpp_prefix=${ccenv_cc_cmd%-gcc*}-
+ ccenv_candidates="${ccenv_cpp_prefix}g++" ;;
+
+ *-clang )
+ ccenv_cpp_prefix=${ccenv_cc_cmd%-clang*}-
+ ccenv_candidates="${ccenv_cpp_prefix}clang++" ;;
+
+ *cc )
+ ccenv_cxx_prefix=${ccenv_cc_cmd%cc*}
+ ccenv_candidates="${ccenv_cpp_prefix}++" ;;
+
+ * )
+ ccenv_cxx="$ccenv_cc -xc++"
+ return 0
+ esac
+
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" = false ]; then
+ ccenv_cxx="$ccenv_cc -xc++"
+ elif [ -n "$ccenv_tflags" ]; then
+ ccenv_cxx="$ccenv_tool $ccenv_tflags"
+ else
+ ccenv_cxx="$ccenv_tool"
+ fi
+}
+
+ccenv_set_cc_host()
+{
+ ccenv_cc_host="$ccenv_cchost"
+}
+
+ccenv_set_cc_bits()
+{
+ ccenv_internal_size=
+ ccenv_internal_type='void *'
+ ccenv_internal_test='char x[(sizeof(%s) == %s/8) ? 1 : -1];'
+
+ for ccenv_internal_guess in 64 32 128; do
+ if [ -z $ccenv_internal_size ]; then
+ ccenv_internal_str=$(printf "$ccenv_internal_test" \
+ "$ccenv_internal_type" \
+ "$ccenv_internal_guess")
+
+ printf '%s' "$ccenv_internal_str" \
+ | $ccenv_cc -S -xc - -o - \
+ $ccenv_cflags \
+ > /dev/null 2>/dev/null \
+ && ccenv_internal_size=$ccenv_internal_guess
+ fi
+ done
+
+ ccenv_cc_bits=$ccenv_internal_size
+}
+
+ccenv_set_cc_underscore()
+{
+ ccenv_fn_name='ZmYaXyWbVe_UuTnSdReQrPsOcNoNrLe'
+ ccenv_fn_code='int %s(void){return 0;}'
+
+ printf "$ccenv_fn_code" $ccenv_fn_name \
+ | $ccenv_cc -xc - -S -o - \
+ | grep _$ccenv_fn_name \
+ > /dev/null \
+ && ccenv_cc_underscore='_'
+
+ return 0
+}
+
+ccenv_create_framework_executable()
+{
+ if [ -f $ccenv_image ]; then
+ mv $ccenv_image $ccenv_image.tmp
+ rm -f $ccenv_image.tmp
+ fi
+
+ printf 'int main(void){return 0;}' \
+ | $ccenv_cc -xc - \
+ -o $ccenv_image \
+ || return 1
+
+ return 0
+}
+
+ccenv_create_freestanding_executable()
+{
+ if [ -f $ccenv_image ]; then
+ mv $ccenv_image $ccenv_image.tmp
+ rm -f $ccenv_image.tmp
+ fi
+
+ if [ -z "ccenv_cc_underscore" ]; then
+ ccenv_start_fn='_start'
+ else
+ ccenv_start_fn='start'
+ fi
+
+ printf 'int %s(void){return 0;}' "$ccenv_start_fn" \
+ | $ccenv_cc -xc - \
+ -ffreestanding \
+ -nostdlib -nostartfiles \
+ -o $ccenv_image \
+ || return 1
+
+ ccenv_freestd=yes
+
+ return 0
+}
+
+ccenv_set_cc_binfmt()
+{
+ ccenv_use_perk=
+ ccenv_use_readelf=
+ ccenv_use_readobj=
+ ccenv_use_bfd_objdump=
+ ccenv_use_llvm_objdump=
+
+ ccenv_create_framework_executable \
+ || ccenv_create_freestanding_executable \
+ || return 0
+
+ # PE / perk
+ if [ -n "$ccenv_perk" ]; then
+ $ccenv_perk $ccenv_image 2>/dev/null \
+ && ccenv_cc_binfmt='PE' \
+ && ccenv_use_perk=yes
+ fi
+
+ # ELF / readelf
+ if [ -n "$ccenv_readelf" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ $ccenv_readelf -h $ccenv_image 2>/dev/null \
+ | grep 'Magic:' | sed -e 's/[ ]*//g' \
+ | grep 'Magic:7f454c46' \
+ > /dev/null \
+ && ccenv_cc_binfmt='ELF' \
+ && ccenv_use_readelf=yes
+ fi
+
+ # a marble of astonishing design:
+ # llvm-readelf also parses PE and Mach-O
+
+ if [ -n "$ccenv_readelf_llvm" ]; then
+ ccenv_readany="$ccenv_readelf_llvm"
+ else
+ ccenv_readany="$ccenv_readelf"
+ fi
+
+ # PE / readelf
+ if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ $ccenv_readany -h $ccenv_image 2>/dev/null \
+ | grep 'Magic:' | sed -e 's/[ ]*//g' \
+ | grep 'Magic:MZ' \
+ > /dev/null \
+ && ccenv_cc_binfmt='PE' \
+ && ccenv_use_readelf=yes
+ fi
+
+ # MACHO-64 / readelf
+ if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ $ccenv_readany -h $ccenv_image 2>/dev/null \
+ | grep -i 'Magic:' | sed -e 's/[ ]*//g' \
+ | grep -i '(0xfeedfacf)' \
+ > /dev/null \
+ && ccenv_cc_binfmt='MACHO' \
+ && ccenv_use_readelf=yes
+ fi
+
+ # MACHO-32 / readelf
+ if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ $ccenv_readany -h $ccenv_image 2>/dev/null \
+ | grep -i 'Magic:' | sed -e 's/[ ]*//g' \
+ | grep -i '(0xcafebabe)' \
+ > /dev/null \
+ && ccenv_cc_binfmt='MACHO' \
+ && ccenv_use_readelf=yes
+ fi
+
+ # MACHO / readobj
+ if [ -n "$ccenv_readobj" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ $ccenv_readobj $ccenv_image 2>/dev/null \
+ | grep -i 'Format:' | sed 's/ /_/g' \
+ | grep -i '_Mach-O_' \
+ > /dev/null \
+ && ccenv_cc_binfmt='MACHO' \
+ && ccenv_use_readobj=yes
+ fi
+
+ # MACHO / objdump (llvm)
+ if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ $ccenv_objdump -section-headers $ccenv_image \
+ 2>/dev/null \
+ | grep -i 'file format Mach-O' \
+ > /dev/null \
+ && ccenv_cc_binfmt='MACHO' \
+ && ccenv_use_objdump=yes
+ fi
+
+ # MACHO / objdump (bfd)
+ if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ $ccenv_objdump -h $ccenv_image 2>/dev/null \
+ | grep -i 'file format Mach-O' \
+ > /dev/null \
+ && ccenv_cc_binfmt='MACHO' \
+ && ccenv_use_objdump=yes
+ fi
+
+ # PE / objdump (bfd)
+ if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ $ccenv_objdump -h $ccenv_image 2>/dev/null \
+ | grep -i 'file format pei-' \
+ > /dev/null \
+ && ccenv_cc_binfmt='PE' \
+ && ccenv_use_bfd_objdump=yes
+ fi
+}
+
+ccenv_set_os_pe()
+{
+ if [ -n "$ccenv_freestd" ]; then
+ case "$ccenv_cchost" in
+ *-midipix | *-midipix-* )
+ ccenv_os='midipix' ;;
+ *-mingw | *-mingw32 | *-mingw64 )
+ ccenv_os='mingw' ;;
+ *-mingw-* | *-mingw32-* | *-mingw64 )
+ ccenv_os='mingw' ;;
+ *-msys | *-msys2 | *-msys-* | *-msys2-* )
+ ccenv_os='msys' ;;
+ *-cygwin | *-cygwin-* )
+ ccenv_os='cygwin' ;;
+ esac
+ fi
+
+ if [ -n "$ccenv_os" ]; then
+ return 0
+ fi
+
+ if [ -n "$ccenv_use_perk" ]; then
+ ccenv_framework=$($ccenv_perk -y $ccenv_image)
+ ccenv_os=${ccenv_framework#*-*-*-*}
+ fi
+
+ if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
+ $ccenv_objdump_bfd -x $ccenv_image | grep -i 'DLL Name' \
+ | grep 'cygwin1.dll' > /dev/null \
+ && ccenv_os='cygwin'
+ fi
+
+ if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
+ $ccenv_objdump_bfd -x $ccenv_image | grep -i 'DLL Name' \
+ | grep 'msys-2.0.dll' > /dev/null \
+ && ccenv_os='msys'
+ fi
+
+ if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
+ $ccenv_objdump_bfd -x $ccenv_image \
+ | grep -i 'DLL Name' | grep '.CRT' \
+ > /dev/null \
+ && $ccenv_objdump_bfd -x $ccenv_image \
+ | grep -i 'DLL Name' | grep '.bss' \
+ > /dev/null \
+ && $ccenv_objdump_bfd -x $ccenv_image \
+ | grep -i 'DLL Name' | grep '.tls' \
+ > /dev/null \
+ && ccenv_os='mingw'
+ fi
+}
+
+ccenv_set_os_macho()
+{
+ case "$ccenv_cchost" in
+ *-apple-darwin* )
+ ccenv_os='darwin' ;;
+ esac
+}
+
+ccenv_set_os()
+{
+ case "$ccenv_cc_binfmt" in
+ PE )
+ ccenv_set_os_pe ;;
+ MACHO )
+ ccenv_set_os_macho ;;
+ esac
+
+ if [ -n "$ccenv_os" ]; then
+ return 0
+ fi
+
+ case "$ccenv_cchost" in
+ *-*-*-* )
+ ccenv_tip=${ccenv_host%-*}
+ ccenv_os=${ccenv_tip#*-*-}
+ ;;
+
+ *-*-* )
+ ccenv_tip=${ccenv_host%-*}
+ ccenv_os=${ccenv_tip#*-}
+ ;;
+ esac
+
+ if [ -z "$ccenv_os" ]; then
+ ccenv_os='anyos'
+ fi
+}
+
+ccenv_set_os_flags()
+{
+ case "$ccenv_os" in
+ darwin )
+ ccenv_cflags_os='-D_DARWIN_C_SOURCE'
+ ccenv_cflags_pic='-fPIC'
+ ;;
+ midipix )
+ ccenv_cflags_os=
+ ccenv_cflags_pic='-fPIC'
+ ;;
+ cygwin )
+ ccenv_cflags_os=
+ ccenv_cflags_pic=
+ ;;
+ msys | msys* | mingw | mingw* )
+ ccenv_cflags_os='-U__STRICT_ANSI__'
+ ccenv_cflags_pic=
+ ;;
+ * )
+ ccenv_cflags_os=
+ ccenv_cflags_pic='-fPIC'
+ ;;
+ esac
+}
+
+ccenv_set_os_semantics()
+{
+ # binary_format - core_api - ex_api - dependency_resolution
+
+ case "$ccenv_os" in
+ linux )
+ ccenv_os_semantics='elf-posix-linux-ldso'
+ ;;
+ bsd )
+ ccenv_os_semantics='elf-posix-bsd-ldso'
+ ;;
+ darwin )
+ ccenv_os_semantics='macho-posix-osx-ldso'
+ ;;
+ midipix )
+ ccenv_os_semantics='pe-posix-winnt-ldso'
+ ;;
+ cygwin )
+ ccenv_os_semantics='pe-hybrid-winnt-unsafe'
+ ;;
+ msys )
+ ccenv_os_semantics='pe-hybrid-winnt-unsafe'
+ ;;
+ mingw )
+ ccenv_os_semantics='pe-win32-winnt-unsafe'
+ ;;
+ esac
+
+ if [ -n "$ccenv_os_semantics" ]; then
+ return 0
+ fi
+
+ if [ -n "$ccenv_cc_binfmt" ]; then
+ ccenv_os_semantics_pattern='%s-posix-anyos-unknown'
+ ccenv_os_semantics=$(printf \
+ "$ccenv_os_semantics_pattern" \
+ "$ccenv_cc_binfmt" \
+ | tr '[:upper:]' '[:lower:]')
+ else
+ ccenv_os_semantics='unknown-posix-anyos-unknown'
+ fi
+}
+
+ccenv_set_os_dso_exrules()
+{
+ case "$ccenv_os" in
+ midipix )
+ ccenv_os_dso_exrules='pe-mdso'
+ ;;
+ * )
+ if [ "$ccenv_cc_binfmt" = 'PE' ]; then
+ ccenv_os_dso_exrules='pe-dlltool'
+ else
+ ccenv_os_dso_exrules='default'
+ fi
+ esac
+}
+
+ccenv_set_os_dso_linkage()
+{
+ # todo: PIC, PIE, and friends
+ ccenv_os_dso_linkage='default'
+}
+
+ccenv_set_os_dso_patterns_darwin()
+{
+ ccenv_os_app_prefix=
+ ccenv_os_app_suffix=
+
+ ccenv_os_lib_prefix=lib
+ ccenv_os_lib_suffix=.dylib
+
+ ccenv_os_implib_ext=.invalid
+ ccenv_os_libdef_ext=.invalid
+
+ ccenv_os_archive_ext=.a
+ ccenv_os_soname=symlink
+
+ ccenv_os_lib_prefixed_suffix=
+ ccenv_os_lib_suffixed_suffix='$(OS_LIB_SUFFIX)'
+}
+
+ccenv_set_os_dso_patterns_mdso()
+{
+ ccenv_os_app_prefix=
+ ccenv_os_app_suffix=
+
+ ccenv_os_lib_prefix=lib
+ ccenv_os_lib_suffix=.so
+
+ ccenv_os_implib_ext=.lib.a
+ ccenv_os_libdef_ext=.so.def
+
+ ccenv_os_archive_ext=.a
+ ccenv_os_soname=symlink
+
+ ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
+ ccenv_os_lib_suffixed_suffix=
+}
+
+ccenv_set_os_dso_patterns_dlltool()
+{
+ ccenv_os_app_prefix=
+ ccenv_os_app_suffix=.exe
+
+ ccenv_os_lib_prefix=lib
+ ccenv_os_lib_suffix=.dll
+
+ ccenv_os_implib_ext=.dll.a
+ ccenv_os_libdef_ext=.def
+
+ ccenv_os_archive_ext=.a
+ ccenv_os_soname=copy
+
+ ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
+ ccenv_os_lib_suffixed_suffix=
+}
+
+ccenv_set_os_dso_patterns_default()
+{
+ ccenv_os_app_prefix=
+ ccenv_os_app_suffix=
+
+ ccenv_os_lib_prefix=lib
+ ccenv_os_lib_suffix=.so
+
+ ccenv_os_implib_ext=.invalid
+ ccenv_os_libdef_ext=.invalid
+
+ ccenv_os_archive_ext=.a
+ ccenv_os_soname=symlink
+
+ ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
+ ccenv_os_lib_suffixed_suffix=
+}
+
+ccenv_set_os_dso_patterns()
+{
+ # sover: .so.x.y.z
+ # verso: .x.y.z.so
+
+ case "$ccenv_os" in
+ darwin )
+ ccenv_set_os_dso_patterns_darwin
+ ;;
+ midipix )
+ ccenv_set_os_dso_patterns_mdso
+ ;;
+ cygwin | msys | mingw )
+ ccenv_set_os_dso_patterns_dlltool
+ ;;
+ * )
+ ccenv_set_os_dso_patterns_default
+ ;;
+ esac
+}
+
+ccenv_output_defs()
+{
+ ccenv_in="$mb_project_dir/sofort/ccenv/ccenv.in"
+ ccenv_mk="$mb_pwd/ccenv/$ccenv_cfgtype.mk"
+
+ if [ $ccenv_cfgtype = 'native' ]; then
+
+ ccenv_tmp=$(mktemp)
+
+ sed \
+ -e 's/^\s*$/@/g' \
+ -e 's/^/NATIVE_/' \
+ -e 's/NATIVE_@//g' \
+ -e 's/NATIVE_#/#/g' \
+ -e 's/ =/=/g' \
+ -e 's/ +=/+=/g' \
+ "$ccenv_in" > "$ccenv_tmp"
+
+ ccenv_in="$ccenv_tmp"
+ fi
+
+ ccenv_vars=$(cut -d'=' -f1 "$mb_project_dir/sofort/ccenv/ccenv.vars" \
+ | grep -v '^#')
+
+ ccenv_exvars="ccenv_cfgtype ccenv_makevar_prefix"
+
+ ccenv_sed_substs=" \
+ $(for __var in $ccenv_vars $ccenv_exvars; do \
+ printf '%s"$%s"%s' "-e 's/@$__var@/'" \
+ "$__var" "'/g' "; \
+ done)"
+
+ eval sed $ccenv_sed_substs "$ccenv_in" \
+ | sed -e 's/[ \t]*$//g' \
+ > "$ccenv_mk"
+
+ return 0
+}
+
+ccenv_clean_up()
+{
+ rm -f $ccenv_image
+}
+
+ccenv_common_init()
+{
+ . "$mb_project_dir/sofort/ccenv/ccenv.vars"
+
+ ccenv_cfgtype=$1
+ ccenv_cfgfile="$mb_pwd/ccenv/$ccenv_cfgtype.mk"
+ ccenv_freestd=
+
+ if [ $ccenv_cfgtype = 'native' ]; then
+ ccenv_makevar_prefix='NATIVE_'
+ ccenv_image='./ccenv/native.a.out'
+ else
+ ccenv_makevar_prefix=
+ ccenv_image='./ccenv/host.a.out'
+ fi
+
+ if [ $ccenv_cfgtype = 'native' ]; then
+ ccenv_prefixes=
+ elif [ -n "$mb_cross_compile" ]; then
+ ccenv_prefixes="$mb_cross_compile"
+ elif [ -n "$mb_host" ]; then
+ ccenv_prefixes="$mb_host-"
+ else
+ ccenv_prefixes=
+ fi
+
+ if [ $ccenv_cfgtype = 'host' ]; then
+ ccenv_tflags=
+ ccenv_cflags=$(make -s -f "$mb_pwd/Makefile.tmp" .display-cflags)
+ ccenv_cc="$mb_user_cc"
+ ccenv_cpp="$mb_user_cpp"
+ ccenv_cxx="$mb_user_cxx"
+ else
+ ccenv_tflags=
+ ccenv_cflags="$mb_native_cflags"
+ ccenv_cc="$mb_native_cc"
+ ccenv_cpp="$mb_native_cpp"
+ ccenv_cxx="$mb_native_cxx"
+ fi
+}
+
+ccenv_set_characteristics()
+{
+ ccenv_set_cc_host
+ ccenv_set_cc_bits
+ ccenv_set_cc_underscore
+ ccenv_set_cc_binfmt
+}
+
+ccenv_set_toolchain_variables()
+{
+ ccenv_common_init $1
+ ccenv_set_cc
+ ccenv_set_cpp
+ ccenv_set_cxx
+ ccenv_set_primary_tools
+ ccenv_set_tool_variants
+ ccenv_set_characteristics
+
+ ccenv_set_os
+ ccenv_set_os_flags
+ ccenv_set_os_semantics
+ ccenv_set_os_dso_exrules
+ ccenv_set_os_dso_linkage
+ ccenv_set_os_dso_patterns
+
+ ccenv_output_defs
+ ccenv_clean_up
+}
+
+ccenv_set_host_variables()
+{
+ ccenv_set_toolchain_variables 'host'
+}
+
+ccenv_set_native_variables()
+{
+ ccenv_set_toolchain_variables 'native'
+}
diff --git a/sofort/ccenv/ccenv.usage b/sofort/ccenv/ccenv.usage
new file mode 100644
index 0000000..44e5f05
--- /dev/null
+++ b/sofort/ccenv/ccenv.usage
@@ -0,0 +1,84 @@
+A few words on sofort's tool-finding logic
+==========================================
+
+# the goals of sofort's tool-finding logic are:
+- follow a clear, transparent, and consistent logic
+- allow users to easily specify per-build preferences
+- allow distros to easily and cleanly use site-wide settings
+
+
+# three-way terminology:
+- native machine: where make(1) will be running.
+- host machine: where the package's program or libraries will execute.
+- target machine: where code generated by the host package will execute.
+
+! NOTE, however, that the host/target distinction is only relevant
+ when building a code-generating utility (e.g. a compiler), and that
+ the two are otherwise rather synonymous. Moreover, in practice it
+ is much more common to see configure scripts being invoked with a
+ --target=<machine> argument specifying the host, than with a
+ --host=<machine> argument.
+
+
+# invocation and names of binary tools:
+- agnostic names (ar, nm, objdump, ...)
+- branded names (llvm-ar, llvm-nm, llvm-objdump, ...)
+- machine-prefixed agnostic names (x86_64-nt64-midipix-ar, ...)
+- machine-prefixed branded names (x86_64-linux-gnu-gcc-ar, ...)
+- machine-specifying branded tools, as in
+ llvm-ar --target=x86_64-linux.
+
+
+# cross-compilation: default search order:
+- machine-prefixed agnostic tools
+- machine-prefixed branded tools, starting with the prefix
+ most commonly associated with the selected compiler (that is,
+ ``gcc'' when using gcc, and ``llvm'' when using clang)
+- (machine-specifying) agnostic tools
+- (machine-speficying) branded tools, starting once again with the
+ prefix most commonly associated with the selected compiler
+
+
+# native builds: default search order:
+- agnostic tools
+- machine-prefixed agnostic tools
+- machine-prefixed branded tools
+- branded tools
+
+
+# using an alternate search order:
+- --toolchain=<prefix> (e.g. --toolchain=llvm) --> search for tools
+ that begin with <prefix> before searching for agnostic tools
+
+
+# restricting which tools may be searched:
+- --zealous --> only search for agnostic tools
+- --zealous=<prefix> --> only search for <prefix>-branded tools
+
+
+# per-tool overrides, by example of the ``ar'' tool:
+- AR=ar --> set AR to $(command -v ar)
+- AR=/path/to/ar --> set AR to the specified absolute path
+
+
+# consistency:
+- in the above case of AR=ar, using $(command -v ar) ensures
+ that the same tool is used throughout the lifetime of the
+ build project.
+
+
+# host generated config file and variable names:
+- ccenv/host.mk
+- AR, NM, OBJDUMP, ...
+
+
+# native generated config file and variable names:
+- ccenv/native.mk
+- NATIVE_AR, NATIVE_NM, NATIVE_OBJDUMP, ...
+
+
+# distro: site-wide preferences
+- --ccenv=/path/to/site-specific/ccenv
+- use the above to create ccenv as a symlink to
+ /path/to/site-specific/ccenv, and to accordingly
+ skip configure's tool-finding step.
diff --git a/sofort/ccenv/ccenv.vars b/sofort/ccenv/ccenv.vars
new file mode 100644
index 0000000..1d68357
--- /dev/null
+++ b/sofort/ccenv/ccenv.vars
@@ -0,0 +1,82 @@
+# system flavor
+ccenv_os=
+ccenv_os_semantics=
+
+ccenv_os_dso_exrules=
+ccenv_os_dso_linkage=
+
+ccenv_os_app_prefix=
+ccenv_os_app_suffix=
+
+ccenv_os_lib_prefix=
+ccenv_os_lib_suffix=
+
+ccenv_os_implib_ext=
+ccenv_os_libdef_ext=
+
+ccenv_os_archive_ext=
+ccenv_os_soname=
+
+ccenv_os_lib_prefixed_suffix=
+ccenv_os_lib_suffixed_suffix=
+
+# characteristics
+ccenv_cc_host=
+ccenv_cc_bits=
+
+ccenv_cc_binfmt=
+ccenv_cc_underscore=
+
+ccenv_cc_arch_bfd=
+ccenv_cc_arch_llvm=
+
+# incompatible tool variants
+ccenv_as_asm=
+ccenv_as_ll=
+ccenv_as_mc=
+
+ccenv_ld_bfd=
+ccenv_ld_gold=
+ccenv_ld_lld=
+
+ccenv_objdump_bfd=
+ccenv_objdump_llvm=
+
+ccenv_readelf_bfd=
+ccenv_readelf_llvm=
+
+# tool variables
+ccenv_cc=
+ccenv_cpp=
+ccenv_cxx=
+
+ccenv_as=
+ccenv_ld=
+
+ccenv_ar=
+ccenv_nm=
+ccenv_objdump=
+ccenv_ranlib=
+ccenv_size=
+ccenv_strip=
+ccenv_strings=
+
+ccenv_addr2line=
+ccenv_cov=
+ccenv_cxxfilt=
+ccenv_objcopy=
+
+ccenv_elfedit=
+ccenv_readelf=
+ccenv_readobj=
+
+ccenv_perk=
+ccenv_mdso=
+ccenv_dlltool=
+
+ccenv_windmc=
+ccenv_windrc=
+
+# cflags
+ccenv_cflags_os=
+ccenv_cflags_pic=
diff --git a/sofort/config.vars b/sofort/config.vars
index c4b3358..ac7c2aa 100644
--- a/sofort/config.vars
+++ b/sofort/config.vars
@@ -23,6 +23,7 @@ target
arch
compiler
toolchain
+zealous
sysroot
cross_compile
shell
@@ -94,14 +95,13 @@ elf_hash_style
elf_config_defs
native_cc
-native_cc_host
-native_cc_cfghost
-native_cc_cflags
-native_cc_ldflags
+native_cpp
+native_cxx
-native_os
-native_os_bits
-native_os_underscore
+native_host
+native_cfghost
+native_cflags
+native_ldflags
all_shared
all_static
diff --git a/sofort/exrules/default.mk b/sofort/exrules/default.mk
new file mode 100644
index 0000000..ad1c11c
--- /dev/null
+++ b/sofort/exrules/default.mk
@@ -0,0 +1,8 @@
+DSO_REF_VER = $(SHARED_LIB)
+DSO_REF_SONAME = $(SHARED_SONAME)
+DSO_REF_SOLINK = $(SHARED_SOLINK)
+
+LDFLAGS_SHARED += -Wl,-soname
+LDFLAGS_SHARED += -Wl,$(DSO_SONAME)
+
+.PHONY: $(IMPLIB_DEF) $(IMPLIB_VER) $(IMPLIB_SONAME) $(IMPLIB_SOLINK)
diff --git a/sofort/exrules/pe-common.mk b/sofort/exrules/pe-common.mk
new file mode 100644
index 0000000..be19ab3
--- /dev/null
+++ b/sofort/exrules/pe-common.mk
@@ -0,0 +1,39 @@
+DSO_REF_VER = $(IMPLIB_VER)
+DSO_REF_SONAME = $(IMPLIB_SONAME)
+DSO_REF_SOLINK = $(IMPLIB_SOLINK)
+
+LDFLAGS_IMPLIB += -Wl,--output-def
+LDFLAGS_IMPLIB += -Wl,$(IMPLIB_DEF)
+
+LDFLAGS_SONAME += -Wl,-soname
+LDFLAGS_SONAME += -Wl,$(DSO_SONAME)
+LDFLAGS_SHARED += $(LDFLAGS_SONAME)
+
+DSO_LIBPATH ?= loader
+PE_SUBSYSTEM ?= windows
+LDFLAGS_COMMON += -Wl,--subsystem=$(PE_SUBSYSTEM)
+
+implib: implib-ver package-implib-soname package-implib-solink
+
+implib-ver: shared-lib $(IMPLIB_VER)
+
+implib-soname: shared-lib $(IMPLIB_SONAME)
+
+implib-solink: shared-lib $(IMPLIB_SOLINK)
+
+$(IMPLIB_DEF): shared-lib
+
+install-implib: install-implib-ver \
+ package-install-implib-soname \
+ package-install-implib-solink
+
+install-implib-ver: implib-ver
+ mkdir -p $(DESTDIR)$(LIBDIR)
+ cp $(IMPLIB_VER) $(DESTDIR)$(LIBDIR)
+
+clean-implib:
+ rm -f $(SHARED_LIB)
+ rm -f $(IMPLIB_DEF)
+ rm -f $(IMPLIB_VER)
+ rm -f $(IMPLIB_SONAME)
+ rm -f $(IMPLIB_SOLINK)
diff --git a/sofort/exrules/pe-dlltool.mk b/sofort/exrules/pe-dlltool.mk
new file mode 100644
index 0000000..6694ed5
--- /dev/null
+++ b/sofort/exrules/pe-dlltool.mk
@@ -0,0 +1,15 @@
+include $(PROJECT_DIR)/sofort/exrules/pe-common.mk
+
+$(IMPLIB_VER): $(IMPLIB_DEF)
+ $(DLLTOOL) -l $(IMPLIB_VER) -d $(IMPLIB_DEF) -D $(DSO_VER)
+
+ifeq ($(AVOID_VERSION),yes)
+
+else
+
+$(IMPLIB_SONAME): $(IMPLIB_DEF)
+ $(DLLTOOL) -l $(IMPLIB_SONAME) -d $(IMPLIB_DEF) -D $(DSO_SONAME)
+
+endif
+
+include $(PROJECT_DIR)/sofort/exrules/pe-version.mk
diff --git a/sofort/exrules/pe-mdso.mk b/sofort/exrules/pe-mdso.mk
new file mode 100644
index 0000000..b5e2dba
--- /dev/null
+++ b/sofort/exrules/pe-mdso.mk
@@ -0,0 +1,15 @@
+include $(PROJECT_DIR)/sofort/exrules/pe-common.mk
+
+$(IMPLIB_VER): $(IMPLIB_DEF)
+ $(MDSO) -m $(CC_BITS) -i $(IMPLIB_VER) -n $(DSO_VER) -l $(DSO_LIBPATH) $<
+
+ifeq ($(AVOID_VERSION),yes)
+
+else
+
+$(IMPLIB_SONAME): $(IMPLIB_DEF)
+ $(MDSO) -m $(CC_BITS) -i $(IMPLIB_SONAME) -n $(DSO_SONAME) $(IMPLIB_DEF)
+
+endif
+
+include $(PROJECT_DIR)/sofort/exrules/pe-version.mk
diff --git a/sofort/exrules/pe-version.mk b/sofort/exrules/pe-version.mk
new file mode 100644
index 0000000..38714b4
--- /dev/null
+++ b/sofort/exrules/pe-version.mk
@@ -0,0 +1,31 @@
+ifeq ($(AVOID_VERSION),yes)
+
+package-implib-soname:
+package-implib-solink:
+package-install-implib-soname:
+package-install-implib-solink:
+
+else
+
+package-implib-soname: implib-soname
+package-implib-solink: implib-solink
+package-install-implib-soname: install-implib-soname
+package-install-implib-solink: install-implib-solink
+
+
+$(IMPLIB_SOLINK): $(IMPLIB_SONAME)
+ rm -f $(IMPLIB_SOLINK).tmp
+ ln -s $(IMP_SONAME) $(IMPLIB_SOLINK).tmp
+ mv $(IMPLIB_SOLINK).tmp $(IMPLIB_SOLINK)
+
+install-implib-soname: implib-soname
+ mkdir -p $(DESTDIR)$(LIBDIR)
+ cp $(IMPLIB_SONAME) $(DESTDIR)$(LIBDIR)
+
+install-implib-solink: implib-soname
+ mkdir -p $(DESTDIR)$(LIBDIR)
+ rm -f $(IMPLIB_SOLINK).tmp
+ ln -s $(IMP_SONAME) $(IMPLIB_SOLINK).tmp
+ mv $(IMPLIB_SOLINK).tmp $(DESTDIR)$(LIBDIR)/$(IMP_SOLINK)
+
+endif
diff --git a/sofort/flag.vars b/sofort/flag.vars
index 798096b..4229e3e 100644
--- a/sofort/flag.vars
+++ b/sofort/flag.vars
@@ -14,6 +14,9 @@ mb_exec_prefix_set
mb_bindir_basename
+# ccenv
+mb_agnostic
+
# cfgtest
mb_cfgtest_cc
mb_cfgtest_cflags
diff --git a/sofort/flavor.mk b/sofort/flavor.mk
index 8e0bbc4..bd9ab06 100644
--- a/sofort/flavor.mk
+++ b/sofort/flavor.mk
@@ -1,13 +1,7 @@
-ifeq ($(OS_BINFMT),PE)
-include $(PROJECT_DIR)/sysinfo/os/pe.mk
+ifneq ($(OS_DSO_EXRULES),)
+include $(PROJECT_DIR)/sofort/exrules/$(OS_DSO_EXRULES).mk
endif
-ifeq ($(OS_BINFMT),ELF)
-include $(PROJECT_DIR)/sysinfo/os/elf.mk
-endif
-
-
-
ifeq ($(DISABLE_STATIC),yes)
package-static:
package-install-static:
diff --git a/sysinfo/version.sh b/sofort/version.sh
index f510a32..f510a32 100755
--- a/sysinfo/version.sh
+++ b/sofort/version.sh
diff --git a/sysinfo/compiler/any-compiler.mk b/sysinfo/compiler/any-compiler.mk
deleted file mode 100644
index 4c98621..0000000
--- a/sysinfo/compiler/any-compiler.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-ifeq ($(CROSS_COMPILE)x,x)
- CROSS_HOST =
- CROSS_HOST_SPEC =
-else
- CROSS_HOST =
- CROSS_HOST_SPEC =
-endif
-
-
-ifeq ($(USER_CC)x,x)
- CC = $(NATIVE_CC) $(CROSS_HOST_SPEC)
-else
- CC = $(USER_CC) $(CROSS_HOST_SPEC)
-endif
-
-ifeq ($(USER_CPP)x,x)
- CPP = $(NATIVE_CC) $(CROSS_HOST_SPEC) -E
-else
- CPP = $(USER_CPP) $(CROSS_HOST_SPEC) -E
-endif
-
-ifeq ($(USER_CXX)x,x)
- CXX = $(NATIVE_CC) $(CROSS_HOST_SPEC) -std=c++
-else
- CXX = $(USER_CXX) $(CROSS_HOST_SPEC) -std=c++
-endif
-
-
-CFLAGS_PIC = -fPIC
diff --git a/sysinfo/compiler/clang.mk b/sysinfo/compiler/clang.mk
deleted file mode 100644
index 77b4b86..0000000
--- a/sysinfo/compiler/clang.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-ifeq ($(CROSS_COMPILE)x,x)
- CROSS_HOST =
- CROSS_HOST_SPEC =
-else ifeq ($(CROSS_HOST)x,x)
- CROSS_HOST = $(HOST)
- CROSS_HOST_SPEC = --target=$(HOST)
-else
- CROSS_HOST_SPEC = --target=$(CROSS_HOST)
-endif
-
-
-ifeq ($(USER_CC)x,x)
- CC = $(NATIVE_CC) $(CROSS_HOST_SPEC)
-else
- CC = $(USER_CC) $(CROSS_HOST_SPEC)
-endif
-
-ifeq ($(USER_CPP)x,x)
- CPP = $(NATIVE_CC) $(CROSS_HOST_SPEC) -E
-else
- CPP = $(USER_CPP) $(CROSS_HOST_SPEC) -E
-endif
-
-ifeq ($(USER_CXX)x,x)
- CXX = $(NATIVE_CC)++ $(CROSS_HOST_SPEC)
-else
- CXX = $(USER_CXX) $(CROSS_HOST_SPEC)
-endif
-
-
-CFLAGS_PIC = -fPIC
diff --git a/sysinfo/compiler/cparser.mk b/sysinfo/compiler/cparser.mk
deleted file mode 100644
index 6c4dc8e..0000000
--- a/sysinfo/compiler/cparser.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-ifeq ($(CROSS_COMPILE)x,x)
- CROSS_HOST =
- CROSS_HOST_SPEC =
-else ifeq ($(CROSS_HOST)x,x)
- CROSS_HOST = $(HOST)
- CROSS_HOST_SPEC = --target=$(HOST)
-else
- CROSS_HOST_SPEC = --target=$(CROSS_HOST)
-endif
-
-
-ifeq ($(USER_CC)x,x)
- CC = $(NATIVE_CC) $(CROSS_HOST_SPEC) -Wno-experimental -integrated-cpp
-else
- CC = $(USER_CC) $(CROSS_HOST_SPEC) -Wno-experimental -integrated-cpp
-endif
-
-ifeq ($(USER_CPP)x,x)
- CPP = $(NATIVE_CC) $(CROSS_HOST_SPEC) -Wno-experimental -integrated-cpp -E
-else
- CPP = $(USER_CPP) $(CROSS_HOST_SPEC) -Wno-experimental -integrated-cpp -E
-endif
-
-ifeq ($(USER_CXX)x,x)
- CXX = $(NATIVE_CC) $(CROSS_HOST_SPEC) -Wno-experimental -integrated-cpp -std=c++
-else
- CXX = $(USER_CXX) $(CROSS_HOST_SPEC) -Wno-experimental -integrated-cpp -std=c++
-endif
-
-
-CFLAGS_PIC = -fPIC
diff --git a/sysinfo/compiler/gcc.mk b/sysinfo/compiler/gcc.mk
deleted file mode 100644
index d14d8dc..0000000
--- a/sysinfo/compiler/gcc.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-ifeq ($(USER_CC)x,x)
- ifeq ($(CROSS_COMPILE)x,x)
- CC = $(CROSS_COMPILE)$(NATIVE_CC)
- else
- CC = $(CROSS_COMPILE)gcc
- endif
-else
- CC = $(USER_CC)
-endif
-
-ifeq ($(USER_CPP)x,x)
- CPP = $(CROSS_COMPILE)cpp
-else
- CPP = $(USER_CPP)
-endif
-
-ifeq ($(USER_CXX)x,x)
- CXX = $(CROSS_COMPILE)c++
-else
- CXX = $(USER_CXX)
-endif
-
-
-CFLAGS_PIC = -fPIC
diff --git a/sysinfo/host/any-host.mk b/sysinfo/host/any-host.mk
deleted file mode 100644
index acb606a..0000000
--- a/sysinfo/host/any-host.mk
+++ /dev/null
@@ -1,7 +0,0 @@
-include $(PROJECT_DIR)/sysinfo/os/any-os.mk
-
-ARCH =
-HOST_BITS =
-HOST_UNDERSCORE =
-
-CROSS_HOST = $(TARGET)
diff --git a/sysinfo/host/i686-nt32-midipix.mk b/sysinfo/host/i686-nt32-midipix.mk
deleted file mode 100644
index fd4b8f8..0000000
--- a/sysinfo/host/i686-nt32-midipix.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-include $(PROJECT_DIR)/sysinfo/os/midipix.mk
-
-ARCH = nt32
-HOST_BITS = 32
-HOST_UNDERSCORE = '_'
diff --git a/sysinfo/host/i686-unknown-linux.mk b/sysinfo/host/i686-unknown-linux.mk
deleted file mode 100644
index bec437c..0000000
--- a/sysinfo/host/i686-unknown-linux.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-include $(PROJECT_DIR)/sysinfo/os/linux.mk
-
-ARCH = i386
-HOST_BITS = 32
-HOST_UNDERSCORE = '_'
diff --git a/sysinfo/host/i686-w64-mingw32.mk b/sysinfo/host/i686-w64-mingw32.mk
deleted file mode 100644
index b18e2e3..0000000
--- a/sysinfo/host/i686-w64-mingw32.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-include $(PROJECT_DIR)/sysinfo/os/mingw.mk
-
-ARCH = w32
-HOST_BITS = 32
-HOST_UNDERSCORE = '_'
diff --git a/sysinfo/host/native.mk b/sysinfo/host/native.mk
deleted file mode 100644
index f0cf720..0000000
--- a/sysinfo/host/native.mk
+++ /dev/null
@@ -1,45 +0,0 @@
-include $(PROJECT_DIR)/sysinfo/os/$(NATIVE_OS).mk
-
-OS = $(NATIVE_OS)
-HOST_BITS = $(NATIVE_OS_BITS)
-HOST_UNDERSCORE = $(NATIVE_OS_UNDERSCORE)
-
-ifeq ($(OS),linux)
- ifeq ($(HOST_BITS),32)
- ARCH = i386
- else ifeq ($(HOST_BITS),64)
- ARCH = x86_64
- endif
-endif
-
-ifeq ($(OS),midipix)
- ifeq ($(HOST_BITS),32)
- ARCH = nt32
- else ifeq ($(HOST_BITS),64)
- ARCH = nt64
- endif
-endif
-
-ifeq ($(OS),mingw)
- ifeq ($(HOST_BITS),32)
- ARCH = w32
- else ifeq ($(HOST_BITS),64)
- ARCH = w64
- endif
-endif
-
-ifeq ($(OS),bsd)
- ifeq ($(HOST_BITS),32)
- ARCH = bsd32
- else ifeq ($(HOST_BITS),64)
- ARCH = bsd64
- endif
-endif
-
-ifeq ($(OS),darwin)
- ifeq ($(HOST_BITS),32)
- ARCH = dw32
- else ifeq ($(HOST_BITS),64)
- ARCH = dw64
- endif
-endif
diff --git a/sysinfo/host/x86_64-nt64-midipix.mk b/sysinfo/host/x86_64-nt64-midipix.mk
deleted file mode 100644
index d0e1d52..0000000
--- a/sysinfo/host/x86_64-nt64-midipix.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-include $(PROJECT_DIR)/sysinfo/os/midipix.mk
-
-ARCH = nt64
-HOST_BITS = 64
-HOST_UNDERSCORE = ''
diff --git a/sysinfo/host/x86_64-unknown-linux.mk b/sysinfo/host/x86_64-unknown-linux.mk
deleted file mode 100644
index 4bd1bff..0000000
--- a/sysinfo/host/x86_64-unknown-linux.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-include $(PROJECT_DIR)/sysinfo/os/linux.mk
-
-ARCH = x86_64
-HOST_BITS = 64
-HOST_UNDERSCORE = ''
diff --git a/sysinfo/host/x86_64-w64-mingw32.mk b/sysinfo/host/x86_64-w64-mingw32.mk
deleted file mode 100644
index a86f9b0..0000000
--- a/sysinfo/host/x86_64-w64-mingw32.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-include $(PROJECT_DIR)/sysinfo/os/mingw.mk
-
-ARCH = w64
-HOST_BITS = 64
-HOST_UNDERSCORE = ''
diff --git a/sysinfo/os/any-os.mk b/sysinfo/os/any-os.mk
deleted file mode 100644
index 6c5a2af..0000000
--- a/sysinfo/os/any-os.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-OS = any-os
-OS_APP_PREFIX =
-OS_APP_SUFFIX =
-OS_LIB_PREFIX = lib
-OS_LIB_SUFFIX = .so
-OS_IMPLIB_EXT = .invalid
-OS_LIBDEF_EXT = .invalid
-OS_ARCHIVE_EXT = .a
-OS_SONAME = symlink
-OS_BINFMT = ELF
-
-.PHONY: $(IMPLIB_DEF) $(IMPLIB_VER) $(IMPLIB_SONAME) $(IMPLIB_SOLINK)
-
-# dso suffix notation
-OS_LIB_PREFIXED_SUFFIX = $(OS_LIB_SUFFIX)
-OS_LIB_SUFFIXED_SUFFIX =
diff --git a/sysinfo/os/bsd.mk b/sysinfo/os/bsd.mk
deleted file mode 100644
index 67453da..0000000
--- a/sysinfo/os/bsd.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-OS = bsd
-OS_APP_PREFIX =
-OS_APP_SUFFIX =
-OS_LIB_PREFIX = lib
-OS_LIB_SUFFIX = .so
-OS_IMPLIB_EXT = .invalid
-OS_LIBDEF_EXT = .invalid
-OS_ARCHIVE_EXT = .a
-OS_SONAME = symlink
-OS_BINFMT = ELF
-
-# dso suffix notation
-OS_LIB_PREFIXED_SUFFIX = $(OS_LIB_SUFFIX)
-OS_LIB_SUFFIXED_SUFFIX =
diff --git a/sysinfo/os/cygwin.mk b/sysinfo/os/cygwin.mk
deleted file mode 100644
index 290aa0d..0000000
--- a/sysinfo/os/cygwin.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-OS = cygwin
-OS_APP_PREFIX =
-OS_APP_SUFFIX = .exe
-OS_LIB_PREFIX = lib
-OS_LIB_SUFFIX = .dll
-OS_IMPLIB_EXT = .dll.a
-OS_LIBDEF_EXT = .def
-OS_ARCHIVE_EXT = .a
-OS_SONAME = copy
-OS_BINFMT = PE
-OS_IMPLIB_TOOL = dlltool
-
-CFLAGS_PIC =
-
-# dso suffix notation
-OS_LIB_PREFIXED_SUFFIX = $(OS_LIB_SUFFIX)
-OS_LIB_SUFFIXED_SUFFIX =
diff --git a/sysinfo/os/darwin.mk b/sysinfo/os/darwin.mk
deleted file mode 100644
index abc9bc7..0000000
--- a/sysinfo/os/darwin.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-OS = darwin
-OS_APP_PREFIX =
-OS_APP_SUFFIX =
-OS_LIB_PREFIX = lib
-OS_LIB_SUFFIX = .dylib
-OS_IMPLIB_EXT = .invalid
-OS_LIBDEF_EXT = .invalid
-OS_ARCHIVE_EXT = .a
-OS_SONAME = symlink
-OS_BINFMT = MACHO
-
-CFLAGS_OS += -D_DARWIN_C_SOURCE
-
-.PHONY: $(IMPLIB_DEF) $(IMPLIB_VER) $(IMPLIB_SONAME) $(IMPLIB_SOLINK)
-
-# dso suffix notation
-OS_LIB_PREFIXED_SUFFIX =
-OS_LIB_SUFFIXED_SUFFIX = $(OS_LIB_SUFFIX)
diff --git a/sysinfo/os/elf.mk b/sysinfo/os/elf.mk
deleted file mode 100644
index 6878c6a..0000000
--- a/sysinfo/os/elf.mk
+++ /dev/null
@@ -1,6 +0,0 @@
-DSO_REF_VER = $(SHARED_LIB)
-DSO_REF_SONAME = $(SHARED_SONAME)
-DSO_REF_SOLINK = $(SHARED_SOLINK)
-
-LDFLAGS_SHARED += -Wl,-soname
-LDFLAGS_SHARED += -Wl,$(DSO_SONAME)
diff --git a/sysinfo/os/linux.mk b/sysinfo/os/linux.mk
deleted file mode 100644
index b9a5f5c..0000000
--- a/sysinfo/os/linux.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-OS = linux
-OS_APP_PREFIX =
-OS_APP_SUFFIX =
-OS_LIB_PREFIX = lib
-OS_LIB_SUFFIX = .so
-OS_IMPLIB_EXT = .invalid
-OS_LIBDEF_EXT = .invalid
-OS_ARCHIVE_EXT = .a
-OS_SONAME = symlink
-OS_BINFMT = ELF
-
-# dso suffix notation
-OS_LIB_PREFIXED_SUFFIX = $(OS_LIB_SUFFIX)
-OS_LIB_SUFFIXED_SUFFIX =
diff --git a/sysinfo/os/midipix.mk b/sysinfo/os/midipix.mk
deleted file mode 100644
index d23d387..0000000
--- a/sysinfo/os/midipix.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-OS = midipix
-OS_APP_PREFIX =
-OS_APP_SUFFIX =
-OS_LIB_PREFIX = lib
-OS_LIB_SUFFIX = .so
-OS_IMPLIB_EXT = .lib.a
-OS_LIBDEF_EXT = .so.def
-OS_ARCHIVE_EXT = .a
-OS_SONAME = symlink
-OS_BINFMT = PE
-OS_IMPLIB_TOOL = mdso
-
-# dso suffix notation
-OS_LIB_PREFIXED_SUFFIX = $(OS_LIB_SUFFIX)
-OS_LIB_SUFFIXED_SUFFIX =
diff --git a/sysinfo/os/mingw.mk b/sysinfo/os/mingw.mk
deleted file mode 100644
index 1a352ba..0000000
--- a/sysinfo/os/mingw.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-OS = mingw
-OS_APP_PREFIX =
-OS_APP_SUFFIX = .exe
-OS_LIB_PREFIX = lib
-OS_LIB_SUFFIX = .dll
-OS_IMPLIB_EXT = .dll.a
-OS_LIBDEF_EXT = .def
-OS_ARCHIVE_EXT = .a
-OS_SONAME = copy
-OS_BINFMT = PE
-OS_IMPLIB_TOOL = dlltool
-
-CFLAGS_PIC =
-CFLAGS_OS += -U__STRICT_ANSI__
-
-# dso suffix notation
-OS_LIB_PREFIXED_SUFFIX = $(OS_LIB_SUFFIX)
-OS_LIB_SUFFIXED_SUFFIX =
diff --git a/sysinfo/os/mingw32.mk b/sysinfo/os/mingw32.mk
deleted file mode 100644
index 542b6a9..0000000
--- a/sysinfo/os/mingw32.mk
+++ /dev/null
@@ -1 +0,0 @@
-include $(PROJECT_DIR)/sysinfo/os/mingw.mk
diff --git a/sysinfo/os/mingw64.mk b/sysinfo/os/mingw64.mk
deleted file mode 100644
index 542b6a9..0000000
--- a/sysinfo/os/mingw64.mk
+++ /dev/null
@@ -1 +0,0 @@
-include $(PROJECT_DIR)/sysinfo/os/mingw.mk
diff --git a/sysinfo/os/msys.mk b/sysinfo/os/msys.mk
deleted file mode 100644
index 70fcd68..0000000
--- a/sysinfo/os/msys.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-OS = msys
-OS_APP_PREFIX =
-OS_APP_SUFFIX = .exe
-OS_LIB_PREFIX = lib
-OS_LIB_SUFFIX = .dll
-OS_IMPLIB_EXT = .dll.a
-OS_LIBDEF_EXT = .def
-OS_ARCHIVE_EXT = .a
-OS_SONAME = copy
-OS_BINFMT = PE
-OS_IMPLIB_TOOL = dlltool
-
-CFLAGS_PIC =
-CFLAGS_OS += -U__STRICT_ANSI__
-
-# dso suffix notation
-OS_LIB_PREFIXED_SUFFIX = $(OS_LIB_SUFFIX)
-OS_LIB_SUFFIXED_SUFFIX =
diff --git a/sysinfo/os/pe.mk b/sysinfo/os/pe.mk
deleted file mode 100644
index 6f9e8ef..0000000
--- a/sysinfo/os/pe.mk
+++ /dev/null
@@ -1,99 +0,0 @@
-DSO_REF_VER = $(IMPLIB_VER)
-DSO_REF_SONAME = $(IMPLIB_SONAME)
-DSO_REF_SOLINK = $(IMPLIB_SOLINK)
-
-LDFLAGS_IMPLIB += -Wl,--output-def
-LDFLAGS_IMPLIB += -Wl,$(IMPLIB_DEF)
-
-LDFLAGS_SONAME += -Wl,-soname
-LDFLAGS_SONAME += -Wl,$(DSO_SONAME)
-LDFLAGS_SHARED += $(LDFLAGS_SONAME)
-
-DSO_LIBPATH ?= loader
-PE_SUBSYSTEM ?= windows
-LDFLAGS_COMMON += -Wl,--subsystem=$(PE_SUBSYSTEM)
-
-implib: implib-ver package-implib-soname package-implib-solink
-
-implib-ver: shared-lib $(IMPLIB_VER)
-
-implib-soname: shared-lib $(IMPLIB_SONAME)
-
-implib-solink: shared-lib $(IMPLIB_SOLINK)
-
-$(IMPLIB_DEF): shared-lib
-
-install-implib: install-implib-ver \
- package-install-implib-soname \
- package-install-implib-solink
-
-install-implib-ver: implib-ver
- mkdir -p $(DESTDIR)$(LIBDIR)
- cp $(IMPLIB_VER) $(DESTDIR)$(LIBDIR)
-
-clean-implib:
- rm -f $(SHARED_LIB)
- rm -f $(IMPLIB_DEF)
- rm -f $(IMPLIB_VER)
- rm -f $(IMPLIB_SONAME)
- rm -f $(IMPLIB_SOLINK)
-
-
-ifeq ($(OS_IMPLIB_TOOL),mdso)
-
-$(IMPLIB_VER): $(IMPLIB_DEF)
- $(MDSO) -m $(HOST_BITS) -i $(IMPLIB_VER) -n $(DSO_VER) -l $(DSO_LIBPATH) $<
-
-else ifeq ($(OS_IMPLIB_TOOL),dlltool)
-
-$(IMPLIB_VER): $(IMPLIB_DEF)
- $(DLLTOOL) -l $(IMPLIB_VER) -d $(IMPLIB_DEF) -D $(DSO_VER)
-
-endif
-
-
-
-ifeq ($(AVOID_VERSION),yes)
-
-package-implib-soname:
-package-implib-solink:
-package-install-implib-soname:
-package-install-implib-solink:
-
-else
-
-package-implib-soname: implib-soname
-package-implib-solink: implib-solink
-package-install-implib-soname: install-implib-soname
-package-install-implib-solink: install-implib-solink
-
-
-ifeq ($(OS_IMPLIB_TOOL),mdso)
-
-$(IMPLIB_SONAME): $(IMPLIB_DEF)
- $(MDSO) -m $(HOST_BITS) -i $(IMPLIB_SONAME) -n $(DSO_SONAME) $(IMPLIB_DEF)
-
-else ifeq ($(OS_IMPLIB_TOOL),dlltool)
-
-$(IMPLIB_SONAME): $(IMPLIB_DEF)
- $(DLLTOOL) -l $(IMPLIB_SONAME) -d $(IMPLIB_DEF) -D $(DSO_SONAME)
-
-endif
-
-
-$(IMPLIB_SOLINK): $(IMPLIB_SONAME)
- rm -f $(IMPLIB_SOLINK).tmp
- ln -s $(IMP_SONAME) $(IMPLIB_SOLINK).tmp
- mv $(IMPLIB_SOLINK).tmp $(IMPLIB_SOLINK)
-
-install-implib-soname: implib-soname
- mkdir -p $(DESTDIR)$(LIBDIR)
- cp $(IMPLIB_SONAME) $(DESTDIR)$(LIBDIR)
-
-install-implib-solink: implib-soname
- mkdir -p $(DESTDIR)$(LIBDIR)
- rm -f $(IMPLIB_SOLINK).tmp
- ln -s $(IMP_SONAME) $(IMPLIB_SOLINK).tmp
- mv $(IMPLIB_SOLINK).tmp $(DESTDIR)$(LIBDIR)/$(IMP_SOLINK)
-
-endif
diff --git a/sysinfo/toolchain/binutils.mk b/sysinfo/toolchain/binutils.mk
deleted file mode 100644
index 9cb532a..0000000
--- a/sysinfo/toolchain/binutils.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-AS = $(CROSS_COMPILE)as
-AR = $(CROSS_COMPILE)ar
-LD = $(CROSS_COMPILE)ld
-NM = $(CROSS_COMPILE)nm
-OBJDUMP = $(CROSS_COMPILE)objdump
-RANLIB = $(CROSS_COMPILE)ranlib
-SIZE = $(CROSS_COMPILE)size
-STRIP = $(CROSS_COMPILE)strip
-STRINGS = $(CROSS_COMPILE)strings
-
-
-ADDR2LINE = $(CROSS_COMPILE)addr2line
-COV = $(CROSS_COMPILE)gcov
-CXXFILT = $(CROSS_COMPILE)c++filt
-ELFEDIT = $(CROSS_COMPILE)elfedit
-OBJCOPY = $(CROSS_COMPILE)objcopy
-READELF = $(CROSS_COMPILE)readelf
-DLLTOOL = $(CROSS_COMPILE)dlltool
-MDSO = $(CROSS_COMPILE)mdso
-PERK = $(CROSS_COMPILE)perk
-MC = $(CROSS_COMPILE)windmc
-RC = $(CROSS_COMPILE)windres
diff --git a/sysinfo/toolchain/llvm.mk b/sysinfo/toolchain/llvm.mk
deleted file mode 100644
index 8082c0a..0000000
--- a/sysinfo/toolchain/llvm.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-AS = llvm-mc -filetype=obj
-AR = llvm-ar
-LD = lld
-NM = llvm-nm
-OBJDUMP = llvm-objdump
-RANLIB = llvm-ranlib
-SIZE = llvm-size
-STRIP = $(CROSS_COMPILE)strip
-STRINGS = $(CROSS_COMPILE)strings
-
-
-ADDR2LINE = $(CROSS_COMPILE)addr2line
-COV = $(CROSS_COMPILE)gcov
-CXXFILT = $(CROSS_COMPILE)c++filt
-ELFEDIT = $(CROSS_COMPILE)elfedit
-OBJCOPY = $(CROSS_COMPILE)objcopy
-READELF = $(CROSS_COMPILE)readelf
-DLLTOOL = $(CROSS_COMPILE)dlltool
-MDSO = $(CROSS_COMPILE)mdso
-PERK = $(CROSS_COMPILE)perk
-MC = $(CROSS_COMPILE)windmc
-RC = $(CROSS_COMPILE)windres