summaryrefslogtreecommitdiff
path: root/sofort
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-04-28 17:47:08 +0000
committermidipix <writeonce@midipix.org>2024-04-28 17:47:08 +0000
commit1b64c0ca9f6438c5bb35f34a46344030b61b789a (patch)
treec1c41b3abf8af0c8fb2484681a7ef0e9707913ef /sofort
parent646efeb80e90cdc80e35a337273943b6ba87bb6f (diff)
downloadtreebnf-1b64c0ca9f6438c5bb35f34a46344030b61b789a.tar.bz2
treebnf-1b64c0ca9f6438c5bb35f34a46344030b61b789a.tar.xz
build system: imported sofort, a project-agnostic build system.
Diffstat (limited to 'sofort')
-rw-r--r--sofort/ccenv/ccenv.in96
-rw-r--r--sofort/ccenv/ccenv.sh1853
-rw-r--r--sofort/ccenv/ccenv.usage78
-rw-r--r--sofort/ccenv/ccenv.vars97
-rw-r--r--sofort/ccenv/ccswitch.strs51
-rw-r--r--sofort/ccenv/pedefs.in4
-rw-r--r--sofort/cfgtest/cfgtest.sh939
-rw-r--r--sofort/config/cfgdefs.in6
-rw-r--r--sofort/config/config.vars151
-rw-r--r--sofort/config/flag.vars25
-rw-r--r--sofort/config/opt.vars9
-rw-r--r--sofort/core/_flavor/flavor_app_frontend_disabled.mk6
-rw-r--r--sofort/core/_flavor/flavor_app_frontend_enabled.mk6
-rw-r--r--sofort/core/_flavor/flavor_app_linking_all_shared.mk7
-rw-r--r--sofort/core/_flavor/flavor_app_linking_all_static.mk7
-rw-r--r--sofort/core/_flavor/flavor_app_linking_default.mk7
-rw-r--r--sofort/core/_flavor/flavor_install_headers_custom.mk4
-rw-r--r--sofort/core/_flavor/flavor_install_headers_default.mk4
-rw-r--r--sofort/core/_flavor/flavor_shared_library_disabled.mk5
-rw-r--r--sofort/core/_flavor/flavor_shared_library_enabled.mk5
-rw-r--r--sofort/core/_flavor/flavor_static_library_disabled.mk5
-rw-r--r--sofort/core/_flavor/flavor_static_library_enabled.mk5
-rw-r--r--sofort/core/_infer/infer_modern.mk22
-rw-r--r--sofort/core/_infer/infer_posix.mk27
-rw-r--r--sofort/core/_version/_soname/version_soname_copy.mk8
-rw-r--r--sofort/core/_version/_soname/version_soname_symlink.mk12
-rw-r--r--sofort/core/_version/version_none.mk10
-rw-r--r--sofort/core/_version/version_used.mk26
-rw-r--r--sofort/core/defs.mk66
-rw-r--r--sofort/core/flavor.mk12
-rw-r--r--sofort/core/infer.mk4
-rw-r--r--sofort/core/modern.m4117
-rw-r--r--sofort/core/pkgconf.mk39
-rw-r--r--sofort/core/version.mk10
-rw-r--r--sofort/exrules/_pe/pe_mdso_version_none.mk2
-rw-r--r--sofort/exrules/_pe/pe_mdso_version_used.mk5
-rw-r--r--sofort/exrules/_pe/pe_version_none.mk7
-rw-r--r--sofort/exrules/_pe/pe_version_used.mk23
-rw-r--r--sofort/exrules/default.mk17
-rw-r--r--sofort/exrules/pe-common.mk42
-rw-r--r--sofort/exrules/pe-dlltool.mk18
-rw-r--r--sofort/exrules/pe-mdso.mk11
-rw-r--r--sofort/exrules/pe-version.mk4
-rwxr-xr-xsofort/tools/pkgconf.sh136
-rwxr-xr-xsofort/tools/srctree.sh83
-rwxr-xr-xsofort/tools/version.sh75
46 files changed, 4146 insertions, 0 deletions
diff --git a/sofort/ccenv/ccenv.in b/sofort/ccenv/ccenv.in
new file mode 100644
index 0000000..0daff84
--- /dev/null
+++ b/sofort/ccenv/ccenv.in
@@ -0,0 +1,96 @@
+# @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_ARFMT = @ccenv_cc_arfmt@
+CC_SOFMT = @ccenv_cc_sofmt@
+CC_BINFMT = @ccenv_cc_binfmt@
+CC_UNDERSCORE = @ccenv_cc_underscore@
+CC_ENVIRONMENT = @ccenv_cc_environment@
+
+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@
+
+PKGCONF = @ccenv_pkgconf@
+
+# @ccenv_cfgtype@ secondary tools
+# note: the direct use of $(@ccenv_makevar_prefix@LD) is highly discouraged
+AS = @ccenv_as@
+LD = @ccenv_ld@
+
+# @ccenv_cfgtype@ visibility attributes
+CFLAGS_ATTR_VISIBILITY_DEFAULT = -D_ATTR_VISIBILITY_DEFAULT=@ccenv_attr_visibility_default@
+CFLAGS_ATTR_VISIBILITY_HIDDEN = -D_ATTR_VISIBILITY_HIDDEN=@ccenv_attr_visibility_hidden@
+CFLAGS_ATTR_VISIBILITY_INTERNAL = -D_ATTR_VISIBILITY_INTERNAL=@ccenv_attr_visibility_internal@
+CFLAGS_ATTR_VISIBILITY_PROTECTED = -D_ATTR_VISIBILITY_PROTECTED=@ccenv_attr_visibility_protected@
+
+# @ccenv_cfgtype@ cflags
+CFLAGS_OS += -DOS_LIB_SUFFIX=\"@ccenv_os_lib_suffix@\"
+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..d975c6b
--- /dev/null
+++ b/sofort/ccenv/ccenv.sh
@@ -0,0 +1,1853 @@
+
+# ccenv.sh: sofort's tool-finding bits,
+# invoked from within the project-agnostic configure script.
+
+# this file is covered by COPYING.SOFORT.
+
+# 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
+
+# variables available to cfgdefs.sh and cfgfini.sh:
+# ccenv_host_cflags: expanded cflags, valid for the host compiler
+# ccenv_host_ldflags: expanded ldflags, valid for the host compiler
+# ccenv_host_sysroot: host sysroot, as reported by the host compiler
+# ccenv_native_cflags: expanded cflags, valid for the native compiler
+# ccenv_native_ldflags: expanded ldflags, valid for the native compiler
+# ccenv_native_sysroot: native sysroot, as reported by the native compiler
+
+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_tool_prolog()
+{
+ ccenv_line_dots='.....................................'
+ ccenv_tool_desc=" == checking for ${1}"
+ ccenv_tool_dlen="${#ccenv_line_dots}"
+
+ printf '\n%s\n' '________________________' >&3
+ printf "ccenv: checking for ${1}\n\n" >&3
+ printf "%${ccenv_tool_dlen}.${ccenv_tool_dlen}s" \
+ "${ccenv_tool_desc} ${mb_line_dots}"
+}
+
+
+ccenv_tool_epilog()
+{
+ ccenv_line_dots='................................'
+ ccenv_tool_dlen="$((${#ccenv_line_dots} - ${#1}))"
+
+ case ${ccenv_tool_dlen} in
+ 0 | -* )
+ ccenv_tool_dlen='3' ;;
+ esac
+
+ printf "%${ccenv_tool_dlen}.${ccenv_tool_dlen}s %s.\n" \
+ "${ccenv_line_dots}" "${1}"
+
+ if [ "${1}" = 'false' ]; then
+ printf '\n\nccenv: not (yet) found.\n' >&3
+ else
+ printf "\n\nccenv : found $(command -v ${1}).\n" >&3
+ fi
+
+ printf '%s\n' '------------------------' >&3
+}
+
+
+ccenv_tool_variant_epilog()
+{
+ ccenv_expr=${1}='${'${1}':-false}'
+ eval "$ccenv_expr"
+
+ ccenv_expr='${'${1}'}'
+ eval ccenv_tool_epilog "$ccenv_expr"
+}
+
+
+ccenv_attr_prolog()
+{
+ ccenv_line_dots=' .....................................'
+ ccenv_attr_desc=" == detect ${ccenv_cfgtype} ${1}"
+ ccenv_attr_dlen="${#ccenv_line_dots}"
+
+ printf "%${ccenv_attr_dlen}.${ccenv_attr_dlen}s" \
+ "${ccenv_attr_desc} ${ccenv_line_dots}"
+
+ printf '\n%s\n' '________________________' >&3
+ printf "ccenv: detecting ${1}\n\n" >&3
+}
+
+
+ccenv_attr_epilog()
+{
+ ccenv_line_dots='................................'
+ ccenv_tool_dlen="$((${#ccenv_line_dots} - 1 - ${#1}))"
+
+ case ${ccenv_tool_dlen} in
+ 0 | -* )
+ ccenv_tool_dlen='3' ;;
+ esac
+
+ printf "%${ccenv_tool_dlen}.${ccenv_tool_dlen}s %s.\n" \
+ "${ccenv_line_dots}" "${1}"
+
+ printf '\n\nccenv: detected result: %s\n' "${1}" >&3
+ printf '%s\n' '------------------------' >&3
+}
+
+
+ccenv_find_tool()
+{
+ if [ -z "$ccenv_prefixes" ]; then
+ for ccenv_candidate in $(printf '%s' "$ccenv_candidates"); do
+ ccenv_cmd_args="${@:-}"
+
+ if [ -z "$ccenv_cmd_args" ]; then
+ if command -v "$ccenv_candidate" > /dev/null; then
+ ccenv_tool="$ccenv_candidate"
+ return 0
+ fi
+ else
+ if command -v "$ccenv_candidate" > /dev/null; then
+ if "$ccenv_candidate" $@ > /dev/null 2>&3; then
+ ccenv_tool="$ccenv_candidate"
+ return 0
+ fi
+ fi
+ fi
+ done
+
+ ccenv_tool=false
+
+ return 0
+ fi
+
+ for ccenv_prefix in $(printf '%s' "$ccenv_prefixes"); do
+ for ccenv_candidate in $(printf '%s' "$ccenv_candidates"); do
+ ccenv_tool="$ccenv_prefix$ccenv_candidate"
+
+ if command -v "$ccenv_tool" > /dev/null; then
+ return 0
+ fi
+ done
+ done
+
+ for ccenv_candidate in $(printf '%s' "$ccenv_candidates"); do
+ if command -v "$ccenv_candidate" > /dev/null; then
+ ccenv_tool="$ccenv_candidate"
+ return 0
+ fi
+ 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 otool"
+ ccenv_peep_tools="perk mdso dlltool windmc windres pkgconf"
+
+ for __tool in $(printf '%s' "$ccenv_core_tools $ccenv_hack_tools $ccenv_peep_tools"); do
+ ccenv_tool_prolog "$__tool"
+
+ 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"
+
+ elif [ "$__tool" = 'pkgconf' ]; then
+ ccenv_candidates="$__tool pkg-config"
+
+ 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_tool=
+ 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"
+ ccenv_tool="$ccenv_var_val"
+ else
+ ccenv_find_tool
+ eval ccenv_$__tool="$ccenv_tool"
+ fi
+
+ ccenv_tool_epilog "$ccenv_tool"
+ done
+
+ # windrc
+ ccenv_windrc="$ccenv_windres"
+
+ # archive format preamble
+ if [ -n "$ccenv_dumpmachine_switch" ]; then
+ ccenv_libgcc_path=$($ccenv_cc -print-file-name=libgcc.a \
+ 2>/dev/null)
+
+ if [ -n "$ccenv_libgcc_path" ]; then
+ ccenv_libgcc_a_header=$(od -b -N8 \
+ $($ccenv_cc -print-file-name=libgcc.a) \
+ | head -n1)
+ else
+ ccenv_libgcc_a_header=
+ fi
+ else
+ ccenv_libgcc_a_header=
+ fi
+
+ # ar (default)
+ ccenv_cc_arfmt='common'
+
+ # ar (big)
+ ccenv_bigaf_header=$(printf '%s\n' '<bigaf>' | od -b | head -n1)
+
+ if [ "$ccenv_libgcc_a_header" = "$ccenv_bigaf_header" ]; then
+ ccenv_cc_arfmt='bigaf'
+
+ for __tool in $(printf '%s' "$ccenv_core_tools"); do
+ ccenv_var_name=ccenv_$__tool
+ ccenv_var_expr='${'$ccenv_var_name':-}'
+ eval ccenv_var_val="$ccenv_var_expr"
+
+ if [ "$ccenv_var_val" != false ]; then
+ ccenv_var_val="$ccenv_var_val -X64"
+ ccenv_var_expr='${ccenv_var_val:-}'
+ eval ccenv_$__tool="$ccenv_var_expr"
+ fi
+ done
+ fi
+
+ # ar (small)
+ ccenv_aiaff_header=$(printf '%s\n' '<aiaff>' | od -b | head -n1)
+
+ if [ "$ccenv_libgcc_a_header" = "$ccenv_aiaff_header" ]; then
+ ccenv_cc_arfmt='aiaff'
+
+ for __tool in $(printf '%s' "$ccenv_core_tools"); do
+ ccenv_var_name=ccenv_$__tool
+ ccenv_var_expr='${'$ccenv_var_name':-}'
+ eval ccenv_var_val="$ccenv_var_expr"
+
+ if [ "$ccenv_var_val" != false ]; then
+ ccenv_var_val="$ccenv_var_val -X32"
+ ccenv_var_expr='${ccenv_var_val:-}'
+ eval ccenv_$__tool="$ccenv_var_expr"
+ fi
+ done
+ fi
+}
+
+ccenv_set_tool_variants()
+{
+ # as (asm)
+ ccenv_tool_prolog 'as (asm)'
+ ccenv_candidates=as
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" = false ]; then
+ ccenv_as_asm=
+ else
+ $ccenv_tool --help 2>&1 | grep -i '.bc assembler' \
+ || ccenv_as_asm="$ccenv_tool"
+ fi
+
+ ccenv_tool_variant_epilog 'ccenv_as_asm'
+
+ # as (ll)
+ ccenv_tool_prolog 'as (ll)'
+ ccenv_candidates=llvm-as
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" != false ]; then
+ ccenv_as_ll="$ccenv_tool"
+ fi
+
+ ccenv_tool_variant_epilog 'ccenv_as_ll'
+
+ # as (mc)
+ ccenv_tool_prolog 'as (mc)'
+ ccenv_candidates=llvm-mc
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" != false ]; then
+ ccenv_as_mc="$ccenv_tool"
+ fi
+
+ ccenv_tool_variant_epilog 'ccenv_as_mc'
+
+ # ld (bfd)
+ ccenv_tool_prolog 'ld (bfd)'
+ ccenv_candidates=ld.bfd
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" != false ]; then
+ ccenv_ld_bfd="$ccenv_tool"
+ fi
+
+ ccenv_tool_variant_epilog 'ccenv_ld_bfd'
+
+ # ld (gold)
+ ccenv_tool_prolog 'ld (gold)'
+ ccenv_candidates=ld.gold
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" != false ]; then
+ ccenv_ld_gold="$ccenv_tool"
+ fi
+
+ ccenv_tool_variant_epilog 'ccenv_ld_gold'
+
+ # ld (lld)
+ ccenv_tool_prolog 'ld (lld)'
+ ccenv_candidates=lld
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" != false ]; then
+ ccenv_ld_lld="$ccenv_tool"
+ fi
+
+ ccenv_tool_variant_epilog 'ccenv_ld_lld'
+
+ # objdump (bfd)
+ ccenv_tool_prolog 'objdump (bfd)'
+ ccenv_candidates=objdump
+ ccenv_find_tool
+
+ if $ccenv_tool --version | grep -i Binutils > /dev/null; then
+ ccenv_objdump_bfd="$ccenv_tool"
+ fi
+
+ ccenv_tool_variant_epilog 'ccenv_objdump_bfd'
+
+ # objdump (llvm)
+ ccenv_tool_prolog 'objdump (llvm)'
+ ccenv_candidates=llvm-objdump
+ ccenv_find_tool
+
+ if $ccenv_tool --version | grep -i LLVM > /dev/null; then
+ ccenv_objdump_llvm="$ccenv_tool"
+ fi
+
+ ccenv_tool_variant_epilog 'ccenv_objdump_llvm'
+
+ # readelf (bfd)
+ ccenv_tool_prolog 'readelf (bfd)'
+ ccenv_candidates=readelf
+ ccenv_find_tool
+
+ if $ccenv_tool --version | grep -i Binutils > /dev/null; then
+ ccenv_readelf_bfd="$ccenv_tool"
+ fi
+
+ ccenv_tool_variant_epilog 'ccenv_readelf_bfd'
+
+ # readelf (llvm)
+ ccenv_tool_prolog 'readelf (llvm)'
+ ccenv_candidates=llvm-readelf
+ ccenv_find_tool
+
+ if $ccenv_tool --version | grep -i LLVM > /dev/null; then
+ ccenv_readelf_llvm="$ccenv_tool"
+ fi
+
+ ccenv_tool_variant_epilog 'ccenv_readelf_llvm'
+
+ # as
+ if [ -n "$ccenv_cc" ]; then
+ ccenv_as='$('"$ccenv_makevar_prefix"'CC) -c -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="cc gcc clang c99 c11"
+ fi
+}
+
+
+ccenv_set_cc()
+{
+ ccenv_tool_prolog 'C compiler'
+
+ 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_tool_epilog "$ccenv_cc"
+
+
+ if [ $ccenv_cfgtype = 'host' ]; then
+ ccenv_host_cc="$ccenv_cc"
+ cfgtest_host_section
+ ccenv_host_cc=
+ else
+ ccenv_native_cc="$ccenv_cc"
+ cfgtest_native_section
+ ccenv_native_cc=
+ fi
+
+ cfgtest_silent='yes'
+
+ if cfgtest_compiler_switch -dumpmachine ; then
+ ccenv_dumpmachine_switch='-dumpmachine'
+ else
+ ccenv_dumpmachine_switch=
+ fi
+
+ if cfgtest_code_snippet_asm 'typedef int dummy;' ; then
+ eval ccenv_${ccenv_cfgtype}_stdin_input='yes'
+ else
+ eval ccenv_${ccenv_cfgtype}_stdin_input='no'
+ fi
+
+ unset cfgtest_silent
+
+ ccenv_cc_cmd="$ccenv_cc"
+ ccenv_errors=
+
+ if [ "$ccenv_cfgtype" = 'native' ]; then
+ ccenv_host=
+
+ if [ -n "$mb_native_host" ]; then
+ ccenv_host="$mb_native_host"
+
+ elif [ -n "$ccenv_dumpmachine_switch" ]; then
+ ccenv_host=$(eval $ccenv_cc $(printf '%s' "$ccenv_cflags") \
+ $ccenv_dumpmachine_switch 2>&3)
+
+ elif command -v slibtool > /dev/null 2>&1; then
+ ccenv=$(slibtool --dumpmachine 2>/dev/null || true)
+ fi
+
+ if [ -z "$ccenv_host" ]; then
+ ccenv_machine=$(uname -m 2>/dev/null)
+ ccenv_system=$(uname -s 2>/dev/null)
+
+ ccenv_machine="${ccenv_machine:-unknown}"
+ ccenv_system="${ccenv_system:-anyos}"
+
+ ccenv_host=$(printf '%s' "${ccenv_machine}-unknown-${ccenv_system}" \
+ | tr '[[:upper:]]' '[[:lower:]]')
+ fi
+
+ ccenv_cchost=$ccenv_host
+ 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" ] && [ -n "$ccenv_dumpmachine_switch" ]; then
+ ccenv_host=$(eval $ccenv_cc $(printf '%s' "$ccenv_cflags") \
+ $ccenv_dumpmachine_switch 2>&3)
+ ccenv_cchost=$ccenv_host
+
+ elif [ -z "$ccenv_host" ]; then
+ # no -dumpmachine support and no --host argument implies native build
+ if command -v slibtool > /dev/null 2>&1; then
+ ccenv=$(slibtool --dumpmachine 2>/dev/null || true)
+ fi
+
+ if [ -z "$ccenv_host" ]; then
+ ccenv_machine=$(uname -m 2>/dev/null)
+ ccenv_system=$(uname -s 2>/dev/null)
+
+ ccenv_machine="${ccenv_machine:-unknown}"
+ ccenv_system="${ccenv_system:-anyos}"
+
+ ccenv_host=$(printf '%s' "${ccenv_machine}-unknown-${ccenv_system}" \
+ | tr '[[:upper:]]' '[[:lower:]]')
+ fi
+
+ ccenv_cchost=$ccenv_host
+
+ elif [ -n "$ccenv_dumpmachine_switch" ]; then
+ ccenv_tmp=$(mktemp ./tmp_XXXXXXXXXXXXXXXX)
+ ccenv_cmd="$ccenv_cc --target=$ccenv_host -E -xc -"
+
+ if [ -z "$mb_user_cc" ]; then
+ $(printf %s "$ccenv_cmd") < /dev/null > /dev/null \
+ 2>"$ccenv_tmp" || true
+
+ ccenv_errors=$(cat "$ccenv_tmp")
+
+ if [ -z "$ccenv_errors" ]; then
+ ccenv_tool_prolog 'C compiler for host'
+ ccenv_tflags="--target=$ccenv_host"
+ ccenv_cc="$ccenv_cc $ccenv_tflags"
+ ccenv_tool_epilog "$ccenv_cc"
+ else
+ printf '%s' "$ccenv_errors" >&3
+ fi
+ fi
+
+ rm -f "$ccenv_tmp"
+ unset ccenv_tmp
+
+ ccenv_cchost=$(eval $ccenv_cc $(printf '%s' "$ccenv_cflags") \
+ $ccenv_dumpmachine_switch 2>&3)
+ fi
+
+ if [ -z "$ccenv_dumpmachine_switch" ] && [ -n "$ccenv_host" ]; then
+ ccenv_cchost="$ccenv_host"
+
+ elif [ "$ccenv_cchost" != "$ccenv_host" ]; then
+ printf 'error!\n' >&2
+ 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()
+{
+ ccenv_tool_prolog 'C pre-processor'
+
+ 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"
+ ccenv_tool_epilog "$ccenv_cpp"
+ 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_tool_epilog "$ccenv_cpp"
+}
+
+ccenv_set_cxx()
+{
+ ccenv_tool_prolog 'C++ compiler'
+
+ 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_cxx_prefix=${ccenv_cc_cmd%-gcc*}-
+ ccenv_candidates="${ccenv_cxx_prefix}g++" ;;
+
+ *-clang )
+ ccenv_cxx_prefix=${ccenv_cc_cmd%-clang*}-
+ ccenv_candidates="${ccenv_cxx_prefix}clang++" ;;
+
+ /*cc | /*c99 | /*c11 )
+ ccenv_cxx_prefix=${ccenv_cc_cmd%/*}
+ ccenv_candidates="${ccenv_cxx_prefix}/cxx"
+ ccenv_candidates="${ccenv_candidates} ${ccenv_cxx_prefix}/c++" ;;
+
+ /*gcc )
+ ccenv_cxx_prefix=${ccenv_cc_cmd%/*}
+ ccenv_candidates="${ccenv_cxx_prefix}/g++" ;;
+
+ /*clang )
+ ccenv_cxx_prefix=${ccenv_cc_cmd%/*}
+ ccenv_candidates="${ccenv_cxx_prefix}/clang++" ;;
+
+ * )
+ ccenv_cxx="$ccenv_cc -xc++"
+ ccenv_tool_epilog "$ccenv_cxx"
+ 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_tool_epilog "$ccenv_cxx"
+}
+
+ccenv_set_cc_host()
+{
+ ccenv_attr_prolog 'system'
+ ccenv_cc_host="$ccenv_cchost"
+ ccenv_attr_epilog "$ccenv_cc_host"
+}
+
+ccenv_set_cc_bits()
+{
+ ccenv_attr_prolog '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")
+
+ ccenv_expr='ccenv_stdin_input=$ccenv_'${ccenv_cfgtype}'_stdin_input'
+ eval ${ccenv_expr}
+
+ if [ "$ccenv_stdin_input" = 'yes' ]; then
+ printf '%s' "$ccenv_internal_str" \
+ | eval $ccenv_cc -S -xc - -o - \
+ $(printf '%s' "$ccenv_cflags") \
+ > /dev/null 2>&3 \
+ && ccenv_internal_size=$ccenv_internal_guess
+ else
+ ccenv_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
+
+ printf '%s' "$ccenv_internal_str" \
+ > "$ccenv_tmpname"
+
+ $ccenv_cc -c "$ccenv_tmpname" -o a.out \
+ > /dev/null 2>&3 \
+ && ccenv_internal_size=$ccenv_internal_guess
+
+ rm "$ccenv_tmpname"
+ fi
+ fi
+ done
+
+ ccenv_cc_bits=$ccenv_internal_size
+
+ ccenv_attr_epilog "$ccenv_cc_bits"
+}
+
+ccenv_set_cc_underscore()
+{
+ ccenv_attr_prolog 'prepended underscores'
+
+ ccenv_fn_name='ZmYaXyWbVe_UuTnSdReQrPsOcNoNrLe'
+ ccenv_fn_code='int %s(void){return 0;}'
+
+ ccenv_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
+
+ printf "$ccenv_fn_code" $ccenv_fn_name \
+ > "$ccenv_tmpname"
+
+ $ccenv_cc -c "$ccenv_tmpname" -o a.out \
+ > /dev/null 2>&3
+
+ if "$ccenv_nm" a.out | grep \
+ -e "^_$ccenv_fn_name" \
+ -e " _$ccenv_fn_name" \
+ > /dev/null; then
+ ccenv_cc_underscore='_'
+ ccenv_attr_epilog 'yes'
+ else
+ ccenv_attr_epilog 'no'
+ fi
+
+ rm "$ccenv_tmpname"
+ rm a.out
+
+ return 0
+}
+
+ccenv_create_framework_executable()
+{
+ if [ "$ccenv_cfgtype" = 'host' ]; then
+ if [ "$mb_freestanding" = 'yes' ]; then
+ return 1
+ fi
+ fi
+
+ if [ -f $ccenv_image ]; then
+ mv $ccenv_image $ccenv_image.tmp
+ rm -f $ccenv_image.tmp
+ fi
+
+ ccenv_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
+
+ printf 'int main(void){return 0;}' \
+ > "$ccenv_tmpname"
+
+ if $ccenv_cc "$ccenv_tmpname" -o $ccenv_image 2>&3; then
+ ccenv_ret=0
+ ccenv_cc_environment='hosted'
+ else
+ ccenv_ret=1
+ fi
+
+ rm "$ccenv_tmpname"
+
+ return $ccenv_ret
+}
+
+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
+
+ ccenv_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
+
+ printf 'int %s(void){return 0;}' "$ccenv_start_fn" \
+ > "$ccenv_tmpname"
+
+ if $ccenv_cc "$ccenv_tmpname" \
+ -ffreestanding \
+ -nostdlib -nostartfiles \
+ -o $ccenv_image \
+ 2>&3; then
+ ccenv_ret=0
+ ccenv_cc_environment='freestanding'
+ else
+ ccenv_ret=1
+ fi
+
+ rm "$ccenv_tmpname"
+
+ return $ccenv_ret
+}
+
+ccenv_set_cc_binfmt_error()
+{
+ ccenv_attr_epilog '(unable to create executable)'
+}
+
+ccenv_set_cc_binfmt()
+{
+ ccenv_use_perk=
+ ccenv_use_otool=
+ ccenv_use_readelf=
+ ccenv_use_readobj=
+ ccenv_use_bfd_objdump=
+ ccenv_use_llvm_objdump=
+
+ ccenv_attr_prolog 'binary format'
+
+ ccenv_create_framework_executable \
+ || ccenv_create_freestanding_executable \
+ || ccenv_set_cc_binfmt_error \
+ || return 0
+
+ # PE / perk
+ if [ -n "$ccenv_perk" ]; then
+ if $ccenv_perk $ccenv_image 2>&3; then
+ ccenv_cc_binfmt='PE'
+ ccenv_use_perk=yes
+ fi
+ fi
+
+ # ELF / readelf
+ if [ -n "$ccenv_readelf" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ if $ccenv_readelf -h $ccenv_image 2>&3 \
+ | grep 'Magic:' | sed -e 's/[ ]*//g' \
+ | grep 'Magic:7f454c46' \
+ > /dev/null; then
+ ccenv_cc_binfmt='ELF'
+ ccenv_use_readelf=yes
+ fi
+ 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
+ if $ccenv_readany -h $ccenv_image 2>&3 \
+ | grep 'Magic:' | sed -e 's/[ ]*//g' \
+ | grep 'Magic:MZ' \
+ > /dev/null; then
+ ccenv_cc_binfmt='PE'
+ ccenv_use_readelf=yes
+ fi
+ fi
+
+ # MACHO-64 / otool
+ if [ -n "$ccenv_otool" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ if $ccenv_otool -hv $ccenv_image 2>&3 \
+ | grep -i 'MH_MAGIC_64' \
+ > /dev/null; then
+ ccenv_cc_binfmt='MACHO'
+ ccenv_use_otool=yes
+ fi
+ fi
+
+ # MACHO-32 / otool
+ if [ -n "$ccenv_otool" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ if $ccenv_otool -hv $ccenv_image 2>&3 \
+ | grep -i 'MH_MAGIC' \
+ > /dev/null; then
+ ccenv_cc_binfmt='MACHO'
+ ccenv_use_otool=yes
+ fi
+ fi
+
+ # MACHO-64 / readelf
+ if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ if $ccenv_readany -h $ccenv_image 2>&3 \
+ | grep -i 'Magic:' | sed -e 's/[ ]*//g' \
+ | grep -i '(0xfeedfacf)' \
+ > /dev/null; then
+ ccenv_cc_binfmt='MACHO'
+ ccenv_use_readelf=yes
+ fi
+ fi
+
+ # MACHO-32 / readelf
+ if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ if $ccenv_readany -h $ccenv_image 2>&3 \
+ | grep -i 'Magic:' | sed -e 's/[ ]*//g' \
+ | grep -i '(0xcafebabe)' \
+ > /dev/null; then
+ ccenv_cc_binfmt='MACHO'
+ ccenv_use_readelf=yes
+ fi
+ fi
+
+ # MACHO / readobj
+ if [ -n "$ccenv_readobj" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ if $ccenv_readobj $ccenv_image 2>&3 \
+ | grep -i 'Format:' \
+ | sed -e 's/ /_/g' \
+ | grep -i '_Mach-O_' \
+ > /dev/null; then
+ ccenv_cc_binfmt='MACHO'
+ ccenv_use_readobj=yes
+ fi
+ fi
+
+ # MACHO / objdump (llvm)
+ if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ if $ccenv_objdump -section-headers $ccenv_image \
+ 2>&3 \
+ | grep -i 'file format Mach-O' \
+ > /dev/null; then
+ ccenv_cc_binfmt='MACHO'
+ ccenv_use_objdump=yes
+ fi
+ fi
+
+ # MACHO / objdump (bfd)
+ if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ $ccenv_objdump -h $ccenv_image 2>&3 \
+ | 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
+ if $ccenv_objdump -h $ccenv_image 2>&3 \
+ | grep -i 'file format pei-' \
+ > /dev/null; then
+ ccenv_cc_binfmt='PE'
+ ccenv_use_bfd_objdump=yes
+ fi
+ fi
+
+ ccenv_attr_epilog "$ccenv_cc_binfmt"
+}
+
+ccenv_set_os_pe()
+{
+ if [ "$ccenv_cc_environment" = 'freestanding' ]; 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()
+{
+ ccenv_attr_prolog 'os name'
+
+ case "$ccenv_cc_binfmt" in
+ PE )
+ ccenv_set_os_pe ;;
+ MACHO )
+ ccenv_set_os_macho ;;
+ esac
+
+ if [ -n "$ccenv_os" ]; then
+ ccenv_attr_epilog "$ccenv_os"
+ return 0
+ fi
+
+ case "$ccenv_cchost" in
+ *-*-musl | *-*-gnu )
+ ccenv_tip=${ccenv_cchost%-*}
+ ccenv_os=${ccenv_tip#*-}
+ ;;
+ *-*-solaris* )
+ ccenv_os='solaris'
+ ;;
+ *-*-*bsd* | *-*-dragonfly* )
+ ccenv_os='bsd'
+ ;;
+ *-*-*-* )
+ ccenv_tip=${ccenv_cchost%-*}
+ ccenv_os=${ccenv_tip#*-*-}
+ ;;
+ *-*-* )
+ ccenv_os=${ccenv_cchost#*-*-}
+ ;;
+ *-* )
+ ccenv_os=${ccenv_cchost#*-}
+ ;;
+ esac
+
+ if [ -z "$ccenv_os" ]; then
+ ccenv_os='anyos'
+ fi
+
+ ccenv_attr_epilog "$ccenv_os"
+}
+
+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
+
+ ccenv_attr_prolog 'os semantics'
+
+ 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
+ ccenv_attr_epilog "$ccenv_os_semantics"
+ 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_attr_epilog "$ccenv_os_semantics"
+}
+
+ccenv_set_os_dso_format()
+{
+ ccenv_attr_prolog 'os dso format'
+
+ case "$ccenv_cc_arfmt" in
+ common )
+ ccenv_cc_sofmt="$ccenv_cc_binfmt"
+ ;;
+
+ bigaf )
+ ccenv_libgcc_s_a_header=$(od -b -N8 \
+ $($ccenv_cc -print-file-name=libgcc_s.a) \
+ 2>/dev/null \
+ | head -n1)
+
+ ccenv_libgcc_s_so_header=$(od -b -N8 \
+ $($ccenv_cc -print-file-name=libgcc_s.so) \
+ 2>/dev/null \
+ | head -n1)
+
+ if [ "$ccenv_libgcc_s_a_header" = "$ccenv_bigaf_header" ]; then
+ ccenv_cc_sofmt='bigaf'
+ elif [ "$ccenv_libgcc_s_so_header" = "$ccenv_bigaf_header" ]; then
+ ccenv_cc_sofmt='bigaf'
+ else
+ ccenv_cc_sofmt="$ccenv_cc_binfmt"
+ fi
+ ;;
+
+ aiaff )
+ ccenv_libgcc_s_a_header=$(od -b -N8 \
+ $($ccenv_cc -print-file-name=libgcc_s.a) \
+ | head -n1)
+
+ ccenv_libgcc_s_so_header=$(od -b -N8 \
+ $($ccenv_cc -print-file-name=libgcc_s.so) \
+ | head -n1)
+
+ if [ "$ccenv_libgcc_s_a_header" = "$ccenv_aiaff_header" ]; then
+ ccenv_cc_sofmt='aiaff'
+ elif [ "$ccenv_libgcc_s_so_header" = "$ccenv_aiaff_header" ]; then
+ ccenv_cc_sofmt='aiaff'
+ else
+ ccenv_cc_sofmt="$ccenv_cc_binfmt"
+ fi
+ ;;
+ esac
+
+ if [ "$ccenv_cfgtype" = 'host' ]; then
+ case "$ccenv_cc_sofmt" in
+ bigaf | aiaff )
+ mb_shared_lib_cmd='$(AR) -rcs'
+ mb_shared_lib_ldflags=
+ ;;
+
+ * )
+ mb_shared_lib_cmd='$(CC) -shared -o'
+ mb_shared_lib_ldflags='$(LDFLAGS_SHARED)'
+ ;;
+ esac
+ fi
+
+ ccenv_attr_epilog "$ccenv_cc_sofmt"
+}
+
+ccenv_set_os_dso_exrules()
+{
+ ccenv_attr_prolog '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_attr_epilog "$ccenv_os_dso_exrules"
+}
+
+ccenv_set_os_dso_linkage()
+{
+ # todo: PIC, PIE, and friends
+ ccenv_attr_prolog 'os linkage'
+ ccenv_os_dso_linkage='default'
+ ccenv_attr_epilog "$ccenv_os_dso_linkage"
+}
+
+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_set_os_pe_switches()
+{
+ if [ "$ccenv_cc_binfmt" = 'PE' ] && [ -z "$ccenv_pe_subsystem" ]; then
+ case "$ccenv_os" in
+ midipix | mingw )
+ ccenv_pe_subsystem='windows'
+ ;;
+ * )
+ ccenv_pe_subsystem='console'
+ ;;
+ esac
+ fi
+
+ if [ "$ccenv_cc_binfmt" = 'PE' ]; then
+ if ! cfgtest_macro_definition '__PE__'; then
+ ccenv_cflags_os="${ccenv_cflags_os} -D__PE__"
+ fi
+
+ if ! cfgtest_macro_definition '__dllexport'; then
+ ccenv_cflags_os="${ccenv_cflags_os} -D__dllexport=__attribute__\(\(__dllexport__\)\)"
+ fi
+
+ if ! cfgtest_macro_definition '__dllimport'; then
+ ccenv_cflags_os="${ccenv_cflags_os} -D__dllimport=__attribute__\(\(__dllimport__\)\)"
+ fi
+ fi
+}
+
+ccenv_set_os_gate_switches()
+{
+ if [ "$ccenv_os" = 'solaris' ]; then
+ if ! cfgtest_macro_definition 'AT_FDCWD'; then
+ ccenv_cflags_os="${ccenv_cflags_os} -D__EXTENSIONS__"
+ fi
+ fi
+}
+
+ccenv_set_os_bsd_switches()
+{
+ if [ "$ccenv_os" = 'bsd' ]; then
+ mb_cfgtest_headers='sys/mman.h'
+
+ if ! cfgtest_macro_definition 'MAP_ANON'; then
+ ccenv_cflags_os="${ccenv_cflags_os} -D__BSD_VISIBLE"
+ fi
+
+ mb_cfgtest_headers=
+ fi
+}
+
+ccenv_output_defs()
+{
+ ccenv_in="$mb_project_dir/sofort/ccenv/ccenv.in"
+ ccenv_mk="$mb_pwd/ccenv/$ccenv_cfgtype.mk"
+ ccenv_tmp=
+
+ if [ "$ccenv_cc_binfmt" = 'PE' ]; then
+ ccenv_pe="$mb_project_dir/sofort/ccenv/pedefs.in"
+ ccenv_in="$ccenv_in $ccenv_pe"
+ fi
+
+ if [ $ccenv_cfgtype = 'native' ]; then
+
+ ccenv_tmp=$(mktemp ./tmp_XXXXXXXXXXXXXXXX)
+
+ sed \
+ -e 's/^[[:space:]]*$/@/g' \
+ -e 's/^/NATIVE_/' \
+ -e 's/NATIVE_@//g' \
+ -e 's/NATIVE_#/#/g' \
+ -e 's/ =/=/g' \
+ -e 's/ +=/+=/g' \
+ $(printf '%s ' $ccenv_in) \
+ > "$ccenv_tmp"
+
+ ccenv_in="$ccenv_tmp"
+ else
+ unset ccenv_tmp
+ fi
+
+ ccenv_var_defs=
+ ccenv_sed_substs="-e s/@ccenv_cfgtype@/${ccenv_cfgtype}/g"
+
+ ccenv_vars=$(cut -d'=' -f1 "$mb_project_dir/sofort/ccenv/ccenv.vars" \
+ | grep -v '^#');
+
+ ccenv_exvars="ccenv_makevar_prefix"
+
+ for __var in $(printf '%s' "$ccenv_vars $ccenv_exvars"); do
+ ccenv_sed_subst=$(printf '%s %s%s%s' \
+ '-e' "'s^@$__var@" \
+ "^___${__var}___" \
+ "^g'")
+
+ ccenv_sed_substs="$ccenv_sed_substs $ccenv_sed_subst"
+
+ ccenv_var_def=$(printf '%s%s="${%s}"' "-D" "___${__var}___" "${__var}")
+ eval ccenv_var_defs='"$ccenv_var_defs "$ccenv_var_def'
+ done
+
+ eval sed $ccenv_sed_substs $(printf '%s ' $ccenv_in) \
+ | eval m4 $ccenv_var_defs - \
+ | sed -e 's/[[:blank:]]*$//g' \
+ > "$ccenv_mk"
+
+ if [ "$ccenv_cfgtype" = 'host' ]; then
+ for __var in $(printf '%s' "$ccenv_vars"); do
+ ccenv_src_var=$__var
+ ccenv_dst_var=mb_${__var#*ccenv_}
+ ccenv_var_expr='${'$ccenv_src_var':-}'
+ eval $ccenv_dst_var=$ccenv_var_expr
+
+ done
+
+ mb_host=$ccenv_host
+ mb_cchost=$ccenv_cchost
+ else
+ for __var in $(printf '%s' "$ccenv_vars"); do
+ ccenv_src_var=$__var
+ ccenv_dst_var=mb_native_${__var#*ccenv_}
+ ccenv_var_expr='${'$ccenv_src_var':-}'
+ eval "$ccenv_dst_var=$ccenv_var_expr"
+ done
+
+ mb_native_host=$ccenv_host
+ mb_native_cchost=$ccenv_cchost
+ fi
+
+ if [ -n "${ccenv_tmp:-}" ]; then
+ rm -f "$ccenv_tmp"
+ unset ccenv_tmp
+ fi
+
+
+ if [ "${ccenv_cfgtype}" = 'host' ]; then
+ ccenv_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" .cflags-host)
+ ccenv_ldflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" .ldflags-host)
+ else
+ ccenv_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" .cflags-native)
+ ccenv_ldflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" .ldflags-native)
+ fi
+
+ ccenv_cflags="${ccenv_cflags#*: }"
+ ccenv_ldflags="${ccenv_ldflags#*: }"
+
+ ccenv_sysroot=$(eval $ccenv_cc $(printf '%s' "$ccenv_cflags") \
+ -print-sysroot 2>/dev/null || true)
+
+ eval 'ccenv_'${ccenv_cfgtype}'_cflags'=\'$ccenv_cflags\'
+ eval 'ccenv_'${ccenv_cfgtype}'_ldflags'=\'$ccenv_ldflags\'
+ eval 'ccenv_'${ccenv_cfgtype}'_sysroot'=\'$ccenv_sysroot\'
+
+ eval 'ccenv_'${ccenv_cfgtype}'_cc'=\'$ccenv_cc\'
+ eval 'ccenv_'${ccenv_cfgtype}'_cc_environment'=\'$ccenv_cc_environment\'
+ eval 'ccenv_'${ccenv_cfgtype}'_dumpmachine_switch'=\'$ccenv_dumpmachine_switch\'
+ eval 'ccenv_'${ccenv_cfgtype}'_pkgconf'=\'$ccenv_pkgconf\'
+
+}
+
+ccenv_set_cc_sysroot_vars()
+{
+ if [ "$ccenv_cfgtype" = 'native' ] || [ -z "$mb_sysroot" ]; then
+ return 0
+ fi
+
+ cfgtest_host_section
+ ccenv_switch_var="--sysroot=${mb_sysroot}"
+
+ if cfgtest_compiler_switch_arg "${ccenv_switch_var}"; then
+ printf '\n# %s sysroot: cflags and ldflags\n' "$ccenv_cfgtype" \
+ >> "$ccenv_mk"
+
+ for ccenv_make_var in '_CFLAGS_SYSROOT' '_LDFLAGS_SYSROOT'; do
+ printf '%-40s= %s\n' "${ccenv_make_var}" "${ccenv_switch_var}" \
+ >> "$ccenv_mk"
+ done
+ else
+ printf '\n# %s sysroot: cflags and ldflags %s\n' "$ccenv_cfgtype" \
+ '(not supported: see config.log)' \
+ >> "$ccenv_mk"
+
+ for ccenv_make_var in '_CFLAGS_SYSROOT' '_LDFLAGS_SYSROOT'; do
+ printf '%-40s=\n' "${ccenv_make_var}" \
+ >> "$ccenv_mk"
+ done
+ fi
+}
+
+ccenv_set_cc_switch_vars()
+{
+ printf '\n# %s cflags: supported compiler switches\n' "$ccenv_cfgtype" \
+ >> "$ccenv_mk"
+
+ if [ -f $mb_project_dir/project/config/ccswitch.strs ]; then
+ ccenv_switch_vars=$(cat \
+ $mb_project_dir/sofort/ccenv/ccswitch.strs \
+ $mb_project_dir/project/config/ccswitch.strs \
+ | grep -v -e '^#' -e '^-Wl,' \
+ | sort -u)
+ else
+ ccenv_switch_vars=$(grep -v -e '^#' -e '^-Wl,' \
+ $mb_project_dir/sofort/ccenv/ccswitch.strs \
+ | sort -u)
+ fi
+
+ if [ $ccenv_cfgtype = 'host' ]; then
+ ccenv_makevar_prefix='_CFLAGS_'
+ cfgtest_host_section
+ else
+ ccenv_makevar_prefix='_NATIVE_CFLAGS_'
+ cfgtest_native_section
+ fi
+
+ for ccenv_switch_var in $(printf '%s' "$ccenv_switch_vars"); do
+ ccenv_make_var=${ccenv_switch_var%=}
+ ccenv_make_var=${ccenv_make_var%,}
+
+ ccenv_make_var=${ccenv_make_var##---}
+ ccenv_make_var=${ccenv_make_var##--}
+ ccenv_make_var=${ccenv_make_var##-}
+
+ ccenv_make_var=$(printf '%s' "$ccenv_make_var" \
+ | sed -e 's/=/_/g' -e 's/-/_/g' -e 's/,/_/g')
+
+ ccenv_make_var="${ccenv_makevar_prefix}${ccenv_make_var}"
+
+ if cfgtest_compiler_switch "$ccenv_switch_var"; then
+ ccenv_switch_var=${ccenv_switch_var%=}
+ ccenv_switch_var=${ccenv_switch_var%,}
+
+ printf '%-40s= %s\n' "${ccenv_make_var}" "${ccenv_switch_var}" \
+ >> "$ccenv_mk"
+ else
+ printf '%-40s=\n' "${ccenv_make_var}" \
+ >> "$ccenv_mk"
+ fi
+ done
+}
+
+ccenv_set_cc_linker_switch_vars()
+{
+ printf '\n# %s ldflags: supported compiler switches\n' "$ccenv_cfgtype" \
+ >> "$ccenv_mk"
+
+ if [ -f $mb_project_dir/project/config/ccswitch.strs ]; then
+ ccenv_switch_vars=$(cat \
+ $mb_project_dir/sofort/ccenv/ccswitch.strs \
+ $mb_project_dir/project/config/ccswitch.strs \
+ | grep -e '^-Wl,' \
+ | sort -u)
+ else
+ ccenv_switch_vars=$(grep -e '^-Wl,' \
+ $mb_project_dir/sofort/ccenv/ccswitch.strs \
+ | sort -u)
+ fi
+
+ if [ $ccenv_cfgtype = 'host' ]; then
+ ccenv_makevar_prefix='_LDFLAGS_'
+ cfgtest_host_section
+ else
+ ccenv_makevar_prefix='_NATIVE_LDFLAGS_'
+ cfgtest_native_section
+ fi
+
+ for ccenv_switch_var in $(printf '%s' "$ccenv_switch_vars"); do
+ ccenv_make_var=${ccenv_switch_var%=}
+ ccenv_make_var=${ccenv_make_var%,}
+
+ ccenv_make_var=${ccenv_make_var##---}
+ ccenv_make_var=${ccenv_make_var##--}
+ ccenv_make_var=${ccenv_make_var##-}
+
+ ccenv_make_var=$(printf '%s' "$ccenv_make_var" \
+ | sed -e 's/=/_/g' -e 's/-/_/g' -e 's/,/_/g')
+
+ ccenv_make_var="${ccenv_makevar_prefix}${ccenv_make_var}"
+
+ if cfgtest_compiler_switch "$ccenv_switch_var"; then
+ ccenv_switch_var=${ccenv_switch_var%=}
+ ccenv_switch_var=${ccenv_switch_var%,}
+
+ printf '%-40s= %s\n' "${ccenv_make_var}" "${ccenv_switch_var}" \
+ >> "$ccenv_mk"
+ else
+ printf '%-40s=\n' "${ccenv_make_var}" \
+ >> "$ccenv_mk"
+ fi
+ done
+}
+
+ccenv_set_cc_attr_visibility_vars()
+{
+ if cfgtest_attr_visibility 'default'; then
+ ccenv_attr_visibility_default="$mb_cfgtest_attr"
+ fi
+
+ if cfgtest_attr_visibility 'hidden'; then
+ ccenv_attr_visibility_hidden="$mb_cfgtest_attr"
+ fi
+
+ if cfgtest_attr_visibility 'internal'; then
+ ccenv_attr_visibility_internal="$mb_cfgtest_attr"
+ fi
+
+ if cfgtest_attr_visibility 'protected'; then
+ ccenv_attr_visibility_protected="$mb_cfgtest_attr"
+ fi
+}
+
+ccenv_dso_verify()
+{
+ ccenv_str='int foo(int x){return ++x;}'
+ ccenv_cmd="$ccenv_cc -xc - -shared -o a.out"
+
+ rm -f a.out
+
+ printf '%s' "$ccenv_str" | $(printf %s "$ccenv_cmd") \
+ > /dev/null 2>&3 \
+ || mb_disable_shared=yes
+
+ rm -f a.out
+}
+
+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_cchost=
+
+ 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=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" \
+ OS_DSO_EXRULES=default \
+ OS_SONAME=symlink \
+ OS_ARCHIVE_EXT='.a' \
+ .cflags-host)
+
+ ccenv_cflags="${ccenv_cflags#*: }"
+
+ ccenv_cc="$mb_user_cc"
+ ccenv_cpp="$mb_user_cpp"
+ ccenv_cxx="$mb_user_cxx"
+
+ ccenv_pe_subsystem="$mb_pe_subsystem"
+ ccenv_pe_image_base="$mb_pe_image_base"
+ else
+ ccenv_tflags=
+ ccenv_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" \
+ OS_DSO_EXRULES=default \
+ OS_SONAME=symlink \
+ OS_ARCHIVE_EXT='.a' \
+ .cflags-native)
+
+ ccenv_cflags="${ccenv_cflags#*: }"
+
+ ccenv_cc="$mb_native_cc"
+ ccenv_cpp="$mb_native_cpp"
+ ccenv_cxx="$mb_native_cxx"
+
+ ccenv_pe_subsystem="$mb_native_pe_subsystem"
+ ccenv_pe_image_base="$mb_native_pe_image_base"
+ fi
+}
+
+ccenv_set_characteristics()
+{
+ ccenv_set_cc_host
+ ccenv_set_cc_bits
+ ccenv_set_cc_binfmt
+ ccenv_set_cc_underscore
+}
+
+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_format
+ ccenv_set_os_dso_exrules
+ ccenv_set_os_dso_linkage
+ ccenv_set_os_dso_patterns
+ ccenv_set_os_pe_switches
+ ccenv_set_os_gate_switches
+ ccenv_set_os_bsd_switches
+ ccenv_set_cc_attr_visibility_vars
+
+ ccenv_output_defs
+ ccenv_clean_up
+
+ ccenv_set_cc_sysroot_vars
+ ccenv_set_cc_switch_vars
+ ccenv_set_cc_linker_switch_vars
+}
+
+ccenv_set_host_variables()
+{
+ output_script_status ${mb_script} \
+ 'detect and query host (targeted) system'
+
+ ccenv_set_toolchain_variables 'host'
+ ccenv_dso_verify
+}
+
+ccenv_set_native_variables()
+{
+ output_script_status ${mb_script} \
+ 'detect and query native (local build) system'
+
+ if [ _$mb_ccenv_skip_native != _yes ]; then
+ ccenv_set_toolchain_variables 'native'
+ fi
+}
diff --git a/sofort/ccenv/ccenv.usage b/sofort/ccenv/ccenv.usage
new file mode 100644
index 0000000..8eab780
--- /dev/null
+++ b/sofort/ccenv/ccenv.usage
@@ -0,0 +1,78 @@
+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
+
+
+# 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..054b638
--- /dev/null
+++ b/sofort/ccenv/ccenv.vars
@@ -0,0 +1,97 @@
+# 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_arfmt=
+ccenv_cc_sofmt=
+ccenv_cc_binfmt=
+ccenv_cc_underscore=
+ccenv_cc_environment=
+
+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=
+
+ccenv_pkgconf=
+
+# visibility attributes
+ccenv_attr_visibility_default=
+ccenv_attr_visibility_hidden=
+ccenv_attr_visibility_internal=
+ccenv_attr_visibility_protected=
+
+# cflags
+ccenv_cflags_os=
+ccenv_cflags_pic=
+
+# pe
+ccenv_pe_subsystem=
+ccenv_pe_image_base=
diff --git a/sofort/ccenv/ccswitch.strs b/sofort/ccenv/ccswitch.strs
new file mode 100644
index 0000000..277e02e
--- /dev/null
+++ b/sofort/ccenv/ccswitch.strs
@@ -0,0 +1,51 @@
+# ccswitch.strs: project-agnostic list of compiler switches,
+# for which support is tested by default.
+
+# when -foo is supported by the host or native compiler, add
+# ``CFLAGS_foo = -foo'' to the respective ccenv variable file
+# (that is, ccenv/host.mk or ccenv/native.mk).
+
+# the make variable prefix is _CFLAGS_ or _NATIVE_CFLAGS_
+# (_LDFLAGS_ or _NATIVE_LDFLAGS for -Wl, linker options),
+# to which the compiler-switch, minus leading dashes and
+# trailing equal-sign or comma, is appended; non-leading
+# dashes and non-trailing equal-signs and commas are then
+# substituted with underscores.
+
+# the project-agnostic list below can be supplemented by a
+# project-specific one, named project/config/ccswitch.strs.
+
+# toolchain switches
+-dumpmachine
+-print-file-name=
+
+# flavors and variants
+-std=c89
+-std=c99
+-std=c11
+
+# linker switches
+-Wl,--print-map
+-Wl,--no-undefined
+-Wl,--verbose
+
+# errors and warnings
+-Wall
+-Werror
+-Wextra
+-Wundef
+-Wpedantic
+
+# debugging
+-g
+-g0
+-g1
+-g2
+-g3
+
+# optimization
+-O0
+-O1
+-O2
+-O3
+-Os
diff --git a/sofort/ccenv/pedefs.in b/sofort/ccenv/pedefs.in
new file mode 100644
index 0000000..008b271
--- /dev/null
+++ b/sofort/ccenv/pedefs.in
@@ -0,0 +1,4 @@
+# @ccenv_cfgtype@ pe switches
+PE_SUBSYSTEM = @ccenv_pe_subsystem@
+PE_IMAGE_BASE = @ccenv_pe_image_base@
+
diff --git a/sofort/cfgtest/cfgtest.sh b/sofort/cfgtest/cfgtest.sh
new file mode 100644
index 0000000..7bb27a0
--- /dev/null
+++ b/sofort/cfgtest/cfgtest.sh
@@ -0,0 +1,939 @@
+# cfgtest.sh: sofort's config test framework,
+# for use from within a project's custom cfgdefs.sh.
+
+# this file is covered by COPYING.SOFORT.
+
+# in the common scenario, host-specific tests are preceded
+# by a single invocation of cfgtest_host_section, whereas
+# native (build) system tests are preceded by the invocation
+# of cfgtest_native_section.
+
+# cfgdefs fraework variables:
+# mb_cfgtest_cc: the compiler used for the current test
+# mb_cfgtest_pkgconf: the pkgconf utility used for the current test
+# mb_cfgtest_cflags: the compiler flags used for the current test
+# mb_cfgtest_cfgtype: the type of the current test (host/native)
+# mb_cfgtest_makevar: the make variable affected by the current test
+# mb_cfgtest_headers: headers for ad-hoc inclusion with the current test
+# mb_cfgtest_attr: if supported, the compiler-specific attribute definition
+
+
+cfgtest_newline()
+{
+ printf '\n' >> $mb_pwd/cfgdefs.mk
+}
+
+
+cfgtest_comment()
+{
+ mb_internal_str='#'
+
+ for mb_internal_arg ; do
+ mb_internal_str="$mb_internal_str $mb_internal_arg"
+ done
+
+ printf '%s\n' "$mb_internal_str" >> $mb_pwd/cfgdefs.mk
+}
+
+
+cfgtest_host_section()
+{
+ mb_cfgtest_cc="$ccenv_host_cc"
+ mb_cfgtest_pkgconf="${ccenv_host_pkgconf:-false}"
+ mb_cfgtest_cfgtype='host'
+ mb_cfgtest_stdin_input=${ccenv_host_stdin_input:-}
+ mb_cfgtest_environment=${ccenv_host_cc_environment:-}
+
+ mb_cfgtest_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" \
+ OS_DSO_EXRULES=default \
+ OS_SONAME=symlink \
+ OS_ARCHIVE_EXT='.a' \
+ .cflags-host)
+
+ mb_cfgtest_cflags="${mb_cfgtest_cflags#*: }"
+
+ mb_cfgtest_ldflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" \
+ OS_DSO_EXRULES=default \
+ OS_SONAME=symlink \
+ OS_ARCHIVE_EXT='.a' \
+ .ldflags-host)
+
+ mb_cfgtest_ldflags="${mb_cfgtest_ldflags#*: }"
+}
+
+
+cfgtest_native_section()
+{
+ mb_cfgtest_cc="$ccenv_native_cc"
+ mb_cfgtest_pkgconf="${ccenv_native_pkgconf:-false}"
+ mb_cfgtest_cfgtype='native'
+ mb_cfgtest_stdin_input=${ccenv_native_stdin_input:-}
+ mb_cfgtest_environment=${ccenv_native_cc_environment:-}
+
+ mb_cfgtest_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" \
+ OS_DSO_EXRULES=default \
+ OS_SONAME=symlink \
+ OS_ARCHIVE_EXT='.a' \
+ .cflags-native)
+
+ mb_cfgtest_cflags="${mb_cfgtest_cflags#*: }"
+
+ mb_cfgtest_ldflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" \
+ OS_DSO_EXRULES=default \
+ OS_SONAME=symlink \
+ OS_ARCHIVE_EXT='.a' \
+ .ldflags-native)
+
+ mb_cfgtest_ldflags="${mb_cfgtest_ldflags#*: }"
+}
+
+
+cfgtest_prolog()
+{
+ cfgtest_line_dots='...........................'
+ cfgtest_line_dots="${cfgtest_line_dots}${cfgtest_line_dots}"
+ cfgtest_tool_desc=" == trying ${mb_cfgtest_cfgtype} ${1}: ${2}"
+ cfgtest_tool_dlen="${#cfgtest_line_dots}"
+
+ printf '\n%s\n' '________________________' >&3
+ printf "cfgtest: probing for ${mb_cfgtest_cfgtype} ${1}: ${2}\n\n" >&3
+
+ if [ "${cfgtest_silent:-}" != 'yes' ]; then
+ printf "%${cfgtest_tool_dlen}.${cfgtest_tool_dlen}s" \
+ "${cfgtest_tool_desc} ${mb_line_dots}"
+ fi
+}
+
+
+cfgtest_epilog()
+{
+ cfgtest_line_dots='...............'
+ cfgtest_tool_dlen="$((${#cfgtest_line_dots} - ${#2}))"
+
+ if [ "${cfgtest_silent:-}" != 'yes' ]; then
+ printf "%${cfgtest_tool_dlen}.${cfgtest_tool_dlen}s %s.\n" \
+ "${cfgtest_line_dots}" "${2}"
+ fi
+
+ if [ "${1}" = 'snippet' ] && [ -f 'a.out' ]; then
+ rm -f 'a.out'
+ fi
+
+ if [ "$mb_cfgtest_stdin_input" = 'no' ]; then
+ rm 'cfgtest_c3RyaWN0X21vZGUK.c'
+ fi
+
+ if [ "${1}" = 'snippet' ] && [ "${2}" = '(error)' ]; then
+ printf '\n\ncfgtest: the %s compiler %s %s.\n' \
+ "$mb_cfgtest_cfgtype" \
+ 'failed to compile the above code' \
+ "${1}" >&3
+ printf '%s\n' '------------------------' >&3
+ return 1
+ fi
+
+ if [ "${1}" = 'attr' ] && [ "${2}" = '(error)' ]; then
+ printf '\n\ncfgtest: the %s compiler %s %s_ attribute.\n' \
+ "$mb_cfgtest_cfgtype" \
+ 'does not appear to support the _' \
+ "${3}" >&3
+ printf '%s\n' '------------------------' >&3
+ return 1
+ fi
+
+ if [ "${2}" = '-----' ] || [ "${2}" = '(missing)' ]; then
+ printf '\n\ncfgtest: %s %s is missing or cannot be found.\n' "${1}" "${3}" >&3
+ printf '%s\n' '------------------------' >&3
+ return 1
+ elif [ "${1}" = 'size-of-type' ] && [ "${2}" = '(error)' ]; then
+ printf '\n\ncfgtest: could not determine size of type `%s.\n' "${3}'" >&3
+ printf '%s\n' '------------------------' >&3
+ return 1
+ elif [ "${1}" = 'switch' ] && [ "${2}" = '(error)' ]; then
+ printf '\n\ncfgtest: the switch `%s is not supported by the %s compiler.\n' \
+ "${3}'" "$mb_cfgtest_cfgtype" >&3
+ printf '%s\n' '------------------------' >&3
+ return 1
+ elif [ "${2}" = '(error)' ]; then
+ printf '\n\ncfgtest: %s `%s is not defined or cannot be used.\n' "${1}" "${3}'" >&3
+ printf '%s\n' '------------------------' >&3
+ return 1
+ fi
+}
+
+
+cfgtest_entity_size_prolog()
+{
+ cfgtest_line_dots='.......................'
+ cfgtest_line_dots="${cfgtest_line_dots}${cfgtest_line_dots}"
+ cfgtest_tool_desc=" == checking size of ${mb_cfgtest_cfgtype} type: ${@}"
+ cfgtest_tool_dlen="${#cfgtest_line_dots}"
+
+ printf '\n%s\n' '________________________' >&3
+ printf "cfgtest: checking size of ${mb_cfgtest_cfgtype} type: ${@}\n\n" >&3
+
+ printf "%${cfgtest_tool_dlen}.${cfgtest_tool_dlen}s" \
+ "${cfgtest_tool_desc} ${mb_line_dots}"
+}
+
+
+cfgtest_makevar_set()
+{
+ if [ -n "${@}" ]; then
+ mb_internal_str='= '
+ else
+ mb_internal_str='='
+ fi
+
+ printf '%-25s%s%s\n' "$mb_cfgtest_makevar" "$mb_internal_str" "${@}" \
+ >> $mb_pwd/cfgdefs.mk
+
+ unset cfgtest_internal_unit_test
+}
+
+
+cfgtest_makevar_append()
+{
+ mb_internal_str='+='
+
+ for mb_internal_arg ; do
+ if ! [ -z "$mb_internal_arg" ]; then
+ mb_internal_str="$mb_internal_str $mb_internal_arg"
+ fi
+ done
+
+ printf '%-24s%s\n' "$mb_cfgtest_makevar" "$mb_internal_str" \
+ >> $mb_pwd/cfgdefs.mk
+
+ unset cfgtest_internal_unit_test
+}
+
+
+cfgtest_cflags_append()
+{
+ if [ $mb_cfgtest_cfgtype = 'host' ]; then
+ mb_internal_makevar='CFLAGS_CONFIG'
+ else
+ mb_internal_makevar='NATIVE_CFLAGS'
+ fi
+
+ mb_cfgtest_makevar_saved=$mb_cfgtest_makevar
+ mb_cfgtest_makevar=$mb_internal_makevar
+
+ cfgtest_makevar_append "$@"
+ mb_cfgtest_makevar=$mb_cfgtest_makevar_saved
+}
+
+
+cfgtest_ldflags_append()
+{
+ if [ $mb_cfgtest_cfgtype = 'host' ]; then
+ mb_internal_makevar='LDFLAGS_CONFIG'
+ else
+ mb_internal_makevar='NATIVE_LDFLAGS'
+ fi
+
+ mb_cfgtest_makevar_saved=$mb_cfgtest_makevar
+ mb_cfgtest_makevar=$mb_internal_makevar
+
+ cfgtest_makevar_append "$@"
+ mb_cfgtest_makevar=$mb_cfgtest_makevar_saved
+}
+
+
+cfgtest_common_init()
+{
+ # cfgtest variables
+ cfgtest_type="${1:-}"
+
+ if [ "$mb_cfgtest_stdin_input" = 'no' ]; then
+ if [ "$cfgtest_type" = 'lib' ]; then
+ cfgtest_fmt='%s cfgtest_c3RyaWN0X21vZGUK.c -o a.out'
+ elif [ "$cfgtest_type" = 'ldflag' ]; then
+ cfgtest_fmt='%s cfgtest_c3RyaWN0X21vZGUK.c -o a.out'
+ else
+ cfgtest_fmt='%s -c cfgtest_c3RyaWN0X21vZGUK.c -o a.out'
+ fi
+ elif [ "$cfgtest_type" = 'asm' ]; then
+ cfgtest_fmt='%s -c -xc - -o a.out'
+ elif [ "$cfgtest_type" = 'attr' ]; then
+ cfgtest_fmt='%s -c -xc - -o a.out -Werror'
+ elif [ "$cfgtest_type" = 'lib' ]; then
+ cfgtest_fmt='%s -xc - -o a.out'
+ elif [ "$cfgtest_type" = 'ldflag' ]; then
+ cfgtest_fmt='%s -xc - -o a.out'
+ else
+ cfgtest_fmt='%s -S -xc - -o -'
+ fi
+
+
+ if [ "$cfgtest_type" = 'lib' ]; then
+ cfgtest_cmd=$(printf "$cfgtest_fmt %s %s %s" \
+ "$mb_cfgtest_cc" \
+ "$mb_cfgtest_cflags" \
+ "$mb_cfgtest_ldflags" \
+ "$cfgtest_libs")
+
+ elif [ "$cfgtest_type" = 'ldflag' ]; then
+ cfgtest_cmd=$(printf "$cfgtest_fmt %s %s %s" \
+ "$mb_cfgtest_cc" \
+ "$mb_cfgtest_cflags" \
+ "$mb_cfgtest_ldflags" \
+ "$cfgtest_switches")
+
+ elif [ "$cfgtest_type" = 'switch' ]; then
+ cfgtest_cmd=$(printf "$cfgtest_fmt %s %s" \
+ "$mb_cfgtest_cc" \
+ "$mb_cfgtest_cflags" \
+ "$cfgtest_switches")
+ else
+ cfgtest_cmd=$(printf "$cfgtest_fmt %s" \
+ "$mb_cfgtest_cc" \
+ "$mb_cfgtest_cflags")
+ fi
+
+
+ if [ -n "$mb_cfgtest_headers" ]; then
+ cfgtest_inc=$(printf '#include <%s>\n' $mb_cfgtest_headers)
+ cfgtest_src=$(printf '%s\n_\n' "$cfgtest_inc" \
+ | m4 -D_="$cfgtest_code_snippet")
+ else
+ cfgtest_inc=
+ cfgtest_src="$cfgtest_code_snippet"
+ fi
+
+
+ # config.log
+ printf "$cfgtest_fmt" "$mb_cfgtest_cc" >&3
+
+ for cfgtest_cflag in $(printf '%s' "$mb_cfgtest_cflags"); do
+ printf ' \\\n\t%s' "$cfgtest_cflag" >&3
+ done
+
+ for cfgtest_ldflag in $(printf '%s' "$mb_cfgtest_ldflags"); do
+ printf ' \\\n\t%s' "$cfgtest_ldflag" >&3
+ done
+
+ if [ "$cfgtest_type" = 'lib' ]; then
+ for cfgtest_lib in $(printf '%s' "$cfgtest_libs"); do
+ printf ' \\\n\t%s' "$cfgtest_lib" >&3
+ done
+
+ elif [ "$cfgtest_type" = 'switch' ] || [ "$cfgtest_type" = 'ldflag' ]; then
+ for cfgtest_switch in $(printf '%s' "$cfgtest_switches"); do
+ printf ' \\\n\t%s' "$cfgtest_switch" >&3
+ done
+ fi
+
+ printf ' \\\n' >&3
+ printf '<< _SRCEOF\n%s\n' "$cfgtest_src" >&3
+ printf '_SRCEOF\n\n\n' >&3
+
+ if [ "$mb_cfgtest_stdin_input" = 'no' ]; then
+ printf '%s' "$cfgtest_src" > 'cfgtest_c3RyaWN0X21vZGUK.c'
+ cfgtest_src=
+ fi
+}
+
+
+cfgtest_header_presence()
+{
+ #init
+ cfgtest_prolog 'header' "${1}"
+
+ cfgtest_code_snippet=$(printf '#include <%s>\n' "${1}")
+ cfgtest_code_onedecl='int fn(void){return 0;}'
+
+ cfgtest_code_snippet=$(printf '%s\n%s\n' \
+ "$cfgtest_code_snippet" \
+ "$cfgtest_code_onedecl")
+
+ cfgtest_common_init
+
+ # execute
+ printf '%s\n' "$cfgtest_src" \
+ | eval $(printf '%s' "$cfgtest_cmd") \
+ > /dev/null 2>&3 \
+ || cfgtest_epilog 'header' '-----' "<${1}>" \
+ || return
+
+ # result
+ mb_internal_str=$(printf '%s%s' '-DHAVE_' "${1}" \
+ | sed -e 's/\./_/g' -e 's@/@_@g' \
+ | tr "[:lower:]" "[:upper:]")
+
+ if [ -z ${cfgtest_internal_unit_test:-} ]; then
+ cfgtest_cflags_append "$mb_internal_str"
+ else
+ cfgtest_makevar_append "$mb_internal_str"
+ fi
+
+ printf 'cfgtest: %s header <%s> was found and may be included.\n' \
+ "$mb_cfgtest_cfgtype" "${1}" >&3
+ printf '%s\n' '------------------------' >&3
+
+ cfgtest_epilog 'header' "${1}"
+}
+
+
+cfgtest_header_absence()
+{
+ #init
+ cfgtest_prolog 'header absence' "${1}"
+
+ cfgtest_code_snippet=$(printf '#include <%s>\n' "${1}")
+ cfgtest_code_onedecl='int fn(void){return 0;}'
+
+ cfgtest_code_snippet=$(printf '%s\n%s\n' \
+ "$cfgtest_code_snippet" \
+ "$cfgtest_code_onedecl")
+
+ cfgtest_common_init
+
+ # execute
+ printf '%s\n' "$cfgtest_src" \
+ | eval $(printf '%s' "$cfgtest_cmd") \
+ > /dev/null 2>&3 \
+ && printf 'cfgtest: %s header <%s>: no error.' \
+ "$mb_cfgtest_cfgtype" "${1}" >&3 \
+ && cfgtest_epilog 'header' "${1}" \
+ && return
+
+ # result
+ mb_internal_str=$(printf '%s%s' '-DHAVE_NO_' "$@" \
+ | sed -e 's/\./_/g' -e 's@/@_@g' \
+ | tr "[:lower:]" "[:upper:]")
+
+ if [ -z ${cfgtest_internal_unit_test:-} ]; then
+ cfgtest_cflags_append "$mb_internal_str"
+ else
+ cfgtest_makevar_append "$mb_internal_str"
+ fi
+
+ printf 'cfgtest: %s header <%s> may not be included.\n' \
+ "$mb_cfgtest_cfgtype" "${1}" >&3
+ printf '%s\n' '------------------------' >&3
+
+ cfgtest_epilog 'header' '-----' "${1}"
+}
+
+
+cfgtest_interface_presence()
+{
+ # init
+ cfgtest_prolog 'interface' "${1}"
+
+ cfgtest_code_snippet=$(printf 'void (*addr)() = (void (*)())&%s;\n' "${1}")
+
+ cfgtest_common_init
+
+ # execute
+ printf '%s\n' "$cfgtest_src" \
+ | eval $(printf '%s' "$cfgtest_cmd") \
+ > /dev/null 2>&3 \
+ || cfgtest_epilog 'interface' '(error)' "${1}" \
+ || return
+
+ # result
+ mb_internal_str=$(printf '%s%s' '-DHAVE_' "$@" \
+ | sed -e 's/\./_/g' \
+ | tr "[:lower:]" "[:upper:]")
+
+ if [ -z ${cfgtest_internal_unit_test:-} ]; then
+ cfgtest_cflags_append "$mb_internal_str"
+ else
+ cfgtest_makevar_append "$mb_internal_str"
+ fi
+
+ printf 'cfgtest: %s interface `%s'"'"' is available.\n' \
+ "$mb_cfgtest_cfgtype" "${1}" >&3
+ printf '%s\n' '------------------------' >&3
+
+ cfgtest_epilog 'interface' "${1}"
+
+ return 0
+}
+
+
+cfgtest_decl_presence()
+{
+ # init
+ cfgtest_prolog 'decl' "${1}"
+
+ cfgtest_code_snippet=$(printf 'void * any = (void *)(%s);' "${1}")
+
+ cfgtest_common_init
+
+ # execute
+ printf '%s\n' "$cfgtest_src" \
+ | eval $(printf '%s' "$cfgtest_cmd") \
+ > /dev/null 2>&3 \
+ || cfgtest_epilog 'decl' '(error)' "${1}" \
+ || return
+
+ # does the argument solely consist of the macro or enum member name?
+ mb_internal_str=$(printf '%s' "$@" | tr -d '[a-z][A-Z][0-9][_]')
+
+ if [ -n "$mb_internal_str" ]; then
+ cfgtest_epilog 'decl' '(defined)'
+ return 0
+ fi
+
+ # result
+ mb_internal_str=$(printf '%s%s' '-DHAVE_DECL_' "$@" \
+ | sed -e 's/\./_/g' \
+ | tr "[:lower:]" "[:upper:]")
+
+ if [ -z ${cfgtest_internal_unit_test:-} ]; then
+ cfgtest_cflags_append "$mb_internal_str"
+ else
+ cfgtest_makevar_append "$mb_internal_str"
+ fi
+
+ printf 'cfgtest: `%s'"'"' is defined for the %s system.\n' \
+ "${1}" "$mb_cfgtest_cfgtype" >&3
+ printf '%s\n' '------------------------' >&3
+
+ cfgtest_epilog 'decl' '(defined)'
+
+ return 0
+}
+
+
+cfgtest_type_size()
+{
+ cfgtest_entity_size_prolog "$@"
+
+ mb_internal_size=''
+ mb_internal_test='char x[(sizeof(%s) == %s) ? 1 : -1];'
+
+ for mb_internal_guess in 8 4 2 1 16 32 64 128; do
+ if [ -z $mb_internal_size ]; then
+ printf '# guess %s ===>\n' "$mb_internal_guess" >&3
+
+ mb_internal_type="$@"
+
+ cfgtest_code_snippet=$(printf "$mb_internal_test" \
+ "$mb_internal_type" "$mb_internal_guess")
+
+ cfgtest_common_init
+
+ printf '%s\n' "$cfgtest_src" \
+ | eval $(printf '%s' "$cfgtest_cmd") \
+ > /dev/null 2>&3 \
+ && mb_internal_size=$mb_internal_guess
+
+ printf '\n' >&3
+ fi
+ done
+
+ # unrecognized type, or type size not within range
+ if [ -z $mb_internal_size ]; then
+ cfgtest_epilog 'size-of-type' '(error)' "@"
+ return 1
+ fi
+
+ # -DSIZEOF_TYPE=SIZE
+ mb_internal_str=$(printf '%s%s=%s' '-DSIZEOF_' \
+ "$mb_internal_type" \
+ "$mb_internal_size" \
+ | sed -e 's/\ /_/g' -e 's/*/P/g' \
+ | tr "[:lower:]" "[:upper:]")
+
+ if [ -z ${cfgtest_internal_unit_test:-} ]; then
+ cfgtest_cflags_append "$mb_internal_str"
+ else
+ cfgtest_makevar_append "$mb_internal_str"
+ fi
+
+ printf 'cfgtest: size of type `%s'"'"' determined to be %s\n' \
+ "${@}" "$mb_internal_size" >&3
+ printf '%s\n' '------------------------' >&3
+
+ cfgtest_epilog 'size-of-type' "$mb_internal_size"
+
+ return 0
+}
+
+
+cfgtest_attr_visibility()
+{
+ # init
+ cfgtest_prolog 'compiler visibility attr' "${1}"
+
+ cfgtest_attr_syntax='__attribute__((__visibility__("'"${1}"'")))'
+ cfgtest_code_snippet="$cfgtest_attr_syntax"' int f_'"${1}"'(void);'
+
+ cfgtest_common_init 'attr'
+
+ # execute
+ cfgtest_ret=1
+
+ printf '%s\n' "$cfgtest_src" \
+ | eval $(printf '%s' "$cfgtest_cmd") \
+ > /dev/null 2>&3 \
+ || cfgtest_epilog 'attr' '(error)' "${1}" \
+ || return
+
+ # result
+ mb_cfgtest_attr=$(printf '__attribute__\\(\\(__visibility__\\(\\"%s\\"\\)\\)\\)' "${1}")
+
+ cfgtest_ret=0
+
+ printf 'cfgtest: %s compiler: above attribute is supported; see also ccenv/%s.mk.\n\n' \
+ "$mb_cfgtest_cfgtype" "$mb_cfgtest_cfgtype" >&3
+
+ cfgtest_epilog 'attr' '(ok)'
+
+ return 0
+}
+
+
+cfgtest_code_snippet_asm()
+{
+ # init
+ cfgtest_prolog 'support of code snippet' '<...>'
+
+ cfgtest_code_snippet="$@"
+
+ cfgtest_common_init 'asm'
+
+ # execute
+ cfgtest_ret=1
+
+ printf '%s\n' "$cfgtest_src" \
+ | eval $(printf '%s' "$cfgtest_cmd") \
+ > /dev/null 2>&3 \
+ || cfgtest_epilog 'snippet' '(error)' \
+ || return
+
+ # result
+ cfgtest_ret=0
+
+ printf 'cfgtest: %s compiler: above code snippet compiled successfully.\n\n' \
+ "$mb_cfgtest_cfgtype" >&3
+
+ cfgtest_epilog 'snippet' '(ok)'
+
+ return 0
+}
+
+
+cfgtest_macro_definition()
+{
+ # init
+ cfgtest_prolog 'macro definition' "${1}"
+
+ cfgtest_code_snippet=$(printf '%s\n' \
+ "#ifndef ${1}" \
+ "#error macro ${1} is not defined." \
+ "#endif")
+
+ cfgtest_common_init 'macro'
+
+ # execute
+ cfgtest_ret=1
+
+ printf '%s\n' "$cfgtest_src" \
+ | eval $(printf '%s' "$cfgtest_cmd") \
+ > /dev/null 2>&3 \
+ || cfgtest_epilog 'macro' '(error)' "${1}" \
+ || return
+
+ # result
+ cfgtest_ret=0
+
+ printf 'cfgtest: %s compiler: above macro definition test compiled successfully.\n\n' \
+ "$mb_cfgtest_cfgtype" >&3
+
+ cfgtest_epilog 'macro' '(defined)'
+
+ return 0
+}
+
+
+cfgtest_library_presence()
+{
+ # init
+ cfgtest_libs=
+ cfgtest_spc=
+
+ for cfgtest_lib in ${@}; do
+ cfgtest_libs="$cfgtest_libs$cfgtest_spc$cfgtest_lib"
+ cfgtest_spc=' '
+ done
+
+ if [ "${1}" = "$cfgtest_libs" ]; then
+ cfgtest_prolog 'library' "${1#*-l}"
+ else
+ cfgtest_prolog 'lib module' '(see config.log)'
+ fi
+
+ if [ "$mb_cfgtest_environment" = 'freestanding' ]; then
+ if [ -z "ccenv_cc_underscore" ]; then
+ cfgtest_code_snippet='int start(void){return 0;}'
+ else
+ cfgtest_code_snippet='int _start(void){return 0;}'
+ fi
+ else
+ cfgtest_code_snippet='int main(void){return 0;}'
+ fi
+
+ cfgtest_common_init 'lib'
+
+ # execute
+ printf '%s\n' "$cfgtest_src" \
+ | eval $(printf '%s' "$cfgtest_cmd") \
+ > /dev/null 2>&3 \
+ || cfgtest_epilog 'library' '-----' "$@" \
+ || return 1
+
+ # result
+ printf 'cfgtest: `%s'"'"' was accepted by the linker driver.\n' \
+ "$cfgtest_libs" >&3
+ printf '%s\n' '------------------------' >&3
+
+ cfgtest_epilog 'library' '(present)'
+
+ return 0
+}
+
+
+cfgtest_package_exists()
+{
+ # init
+ cfgtest_pkg=
+
+ for cfgtest_arg in ${@}; do
+ case "$cfgtest_arg" in
+ -*)
+ ;;
+
+ *)
+ cfgtest_pkg="$cfgtest_arg"
+ ;;
+ esac
+ done
+
+ cfgtest_prolog 'package' "$cfgtest_pkg"
+
+ # execute
+ "$mb_cfgtest_pkgconf" "${@}" \
+ > /dev/null 2>&3 \
+ || cfgtest_epilog 'package' '(missing)' "$cfgtest_pkg" \
+ || return 1
+
+ # result
+ printf 'cfgtest: package `%s'"'"' was found.\n' \
+ "$cfgtest_pkg" >&3
+ printf '%s\n' '------------------------' >&3
+
+ cfgtest_epilog 'package' '(exists)' "$cfgtest_pkg"
+
+ return 0
+}
+
+
+cfgtest_package_config()
+{
+ # init
+ if ! cfgtest_package_exists "${@}"; then
+ return 0
+ fi
+
+ cfgtest_pkg=
+
+ for cfgtest_arg in ${@}; do
+ case "$cfgtest_arg" in
+ -*)
+ ;;
+
+ *)
+ cfgtest_pkg="$cfgtest_arg"
+ ;;
+ esac
+ done
+
+ cfgtest_makevar_prefix=
+ cfgtest_pkgconf_prefix=
+
+ if [ "$mb_cfgtest_cfgtype" = 'native' ]; then
+ cfgtest_makevar_prefix='_NATIVE'
+ else
+ if [ -n "${mb_sysroot}" ]; then
+ cfgtest_pkgconf_prefix="--define-variable=prefix=${mb_sysroot}"
+ fi
+ fi
+
+ cfgtest_newline
+ cfgtest_comment 'package config:' "$cfgtest_pkg"
+
+ # foo.pc
+ cfgtest_pkgconf_path=$("$mb_cfgtest_pkgconf" \
+ --path "${@}" \
+ 2>/dev/null || true)
+
+ if [ -z "$cfgtest_pkgconf_path" ]; then
+ cfgtest_pkgconf_path=$("$mb_cfgtest_pkgconf" \
+ --debug "${@}" 2>&1 \
+ | grep ".pc'$" \
+ | head -n1 \
+ || true)
+
+ cfgtest_pkgconf_path="${cfgtest_pkgconf_path##* \'}"
+ cfgtest_pkgconf_path="${cfgtest_pkgconf_path%%\'}"
+ fi
+
+ mb_cfgtest_makevar=$(printf '%s_PKGCONF_%s' \
+ "$cfgtest_makevar_prefix" "$cfgtest_pkg" \
+ | tr '[[:lower:]]' '[[:upper:]]' \
+ | sed -e 's/-/_/g')
+
+ cfgtest_makevar_set "$cfgtest_pkgconf_path"
+
+ # --cflags
+ cfgtest_pkgconf_path=$("$mb_cfgtest_pkgconf" \
+ "$cfgtest_pkgconf_prefix" \
+ --cflags "${@}" \
+ | sed 's/[ \t]*$//')
+
+ mb_cfgtest_makevar=$(printf '%s_CFLAGS_%s' \
+ "$cfgtest_makevar_prefix" "$cfgtest_pkg" \
+ | tr '[[:lower:]]' '[[:upper:]]' \
+ | sed -e 's/-/_/g')
+
+ cfgtest_makevar_set "$cfgtest_pkgconf_path"
+
+ # --ldflags
+ cfgtest_pkgconf_path=$("$mb_cfgtest_pkgconf" \
+ "$cfgtest_pkgconf_prefix" \
+ --libs "${@}" \
+ | sed 's/[ \t]*$//')
+
+ mb_cfgtest_makevar=$(printf '%s_LDFLAGS_%s' \
+ "$cfgtest_makevar_prefix" "$cfgtest_pkg" \
+ | tr '[[:lower:]]' '[[:upper:]]' \
+ | sed -e 's/-/_/g')
+
+ cfgtest_makevar_set "$cfgtest_pkgconf_path"
+
+ return 0
+}
+
+
+cfgtest_compiler_switch()
+{
+ # init
+ cfgtest_switches=
+ cfgtest_spc=
+
+ for cfgtest_switch in $(printf '%s' "${@}"); do
+ cfgtest_switches="$cfgtest_switches$cfgtest_spc$cfgtest_switch"
+ cfgtest_spc=' '
+ done
+
+ if [ -n "${cfgtest_switch_arg:-}" ]; then
+ cfgtest_prolog 'compiler switch' "${cfgtest_switches%=*}"
+
+ elif [ "${1}" = "$cfgtest_switches" ]; then
+ cfgtest_prolog 'compiler switch' "$cfgtest_switches"
+
+ else
+ cfgtest_prolog 'compiler switch combination' "$cfgtest_switches"
+ fi
+
+ case "${1}" in
+ -Wl,*)
+ if [ "$mb_cfgtest_environment" = 'freestanding' ]; then
+ cfgtest_switches="$cfgtest_switches -nostdlib -nostartfiles"
+
+ if [ -z "ccenv_cc_underscore" ]; then
+ cfgtest_code_snippet='int start(void){return 0;}'
+ else
+ cfgtest_code_snippet='int _start(void){return 0;}'
+ fi
+ else
+ cfgtest_code_snippet='int main(void){return 0;}'
+ fi
+
+ cfgtest_common_init 'ldflag'
+ ;;
+
+ *)
+ cfgtest_code_snippet='int fn(void){return 0;}'
+ cfgtest_common_init 'switch'
+ ;;
+ esac
+
+ # execute
+ printf '%s\n' "$cfgtest_src" \
+ | eval $(printf '%s' "$cfgtest_cmd") \
+ > /dev/null 2>&3 \
+ || cfgtest_epilog 'switch' '(error)' "$@" \
+ || return 1
+
+ # result
+ printf 'cfgtest: the switch `%s was accepted by the compiler.\n' \
+ "$cfgtest_switches'" >&3
+ printf '%s\n' '------------------------' >&3
+
+ cfgtest_epilog 'switch' '(accepted)'
+
+ return 0
+}
+
+
+cfgtest_compiler_switch_arg()
+{
+ cfgtest_switch_arg='yes'
+
+ if cfgtest_compiler_switch "${@}"; then
+ cfgtest_ret=0
+ else
+ cfgtest_ret=1
+ fi
+
+ unset cfgtest_switch_arg
+
+ return $cfgtest_ret
+}
+
+
+cfgtest_unit_header_presence()
+{
+ cfgtest_internal_unit_test='unit_test'
+ cfgtest_header_presence "$@" || return 1
+ return 0
+}
+
+
+cfgtest_unit_header_absence()
+{
+ cfgtest_internal_unit_test='unit_test'
+ cfgtest_header_absence "$@" || return 1
+ return 0
+}
+
+
+cfgtest_unit_interface_presence()
+{
+ cfgtest_internal_unit_test='unit_test'
+ cfgtest_interface_presence "$@" || return 1
+ return 0
+}
+
+
+cfgtest_unit_decl_presence()
+{
+ cfgtest_internal_unit_test='unit_test'
+ cfgtest_decl_presence "$@" || return 1
+ return 0
+}
+
+
+cfgtest_unit_type_size()
+{
+ cfgtest_internal_unit_test='unit_test'
+ cfgtest_type_size "$@" || return 1
+ return 0
+}
diff --git a/sofort/config/cfgdefs.in b/sofort/config/cfgdefs.in
new file mode 100644
index 0000000..fd4b947
--- /dev/null
+++ b/sofort/config/cfgdefs.in
@@ -0,0 +1,6 @@
+# changes made to this file will be gone the next time
+# you run ./configure.
+
+# for persistent post-configure, ad-hoc changes to the
+# build project, use usrdefs.mk instead.
+
diff --git a/sofort/config/config.vars b/sofort/config/config.vars
new file mode 100644
index 0000000..38d5616
--- /dev/null
+++ b/sofort/config/config.vars
@@ -0,0 +1,151 @@
+package
+nickname
+project_dir
+source_dir
+git_reference_index
+custom_install_headers
+avoid_version
+
+ccenv
+ccenv_create_log
+ccenv_skip_native
+
+pkgname
+pkgdesc
+pkgusrc
+pkgrepo
+pkgpsrc
+pkgdurl
+pkgbugs
+pkghome
+pkgdefs
+pkglibs
+
+srcinfo
+srcsite
+
+pgprkey
+pgpskey
+
+rawball
+rawball_url
+rawball_sha256
+modball
+modball_url
+modball_sha256
+srcball
+srcball_url
+srcball_sha256
+
+
+make
+makefile
+makemode
+
+build
+host
+cchost
+cfghost
+target
+arch
+compiler
+toolchain
+zealous
+sysroot
+freestanding
+cross_compile
+config_shell
+shell
+
+pkgconf
+pkgconfig
+
+prefix
+exec_prefix
+bindir
+sbindir
+libdir
+includedir
+oldincludedir
+mandir
+docdir
+libexecdir
+
+sysconfdir
+sharedstatedir
+localstatedir
+runstatedir
+datarootdir
+datadir
+infodir
+localedir
+htmldir
+dvidir
+pdfdir
+psdir
+
+cflags
+cflags_common
+cflags_debug
+cflags_cmdline
+cflags_config
+cflags_sysroot
+cflags_os
+cflags_site
+cflags_path
+cflags_strict
+cflags_util
+cflags_last
+cflags_once
+
+ldflags
+ldflags_common
+ldflags_debug
+ldflags_cmdline
+ldflags_config
+ldflags_sysroot
+ldflags_path
+ldflags_strict
+ldflags_util
+ldflags_last
+ldflags_once
+
+cc
+cpp
+cxx
+
+user_cc
+user_cpp
+user_cxx
+
+pe_subsystem
+pe_image_base
+
+native_cc
+native_cpp
+native_cxx
+
+native_host
+native_cfghost
+native_cflags
+native_ldflags
+
+native_pkgconf
+native_pkgconfig
+
+native_pe_subsystem
+native_pe_image_base
+
+all_shared
+all_static
+disable_frontend
+disable_shared
+disable_static
+
+use_custom_cfgdefs
+use_custom_cfginit
+use_custom_cfgfini
+use_custom_usrdefs
+
+shared_lib_cmd
+shared_lib_ldflags
diff --git a/sofort/config/flag.vars b/sofort/config/flag.vars
new file mode 100644
index 0000000..4229e3e
--- /dev/null
+++ b/sofort/config/flag.vars
@@ -0,0 +1,25 @@
+# configure
+mb_config
+mb_debug
+
+mb_ccstrict
+mb_ldstrict
+
+mb_program_prefix
+mb_require_source_dir
+
+mb_prefix_set
+mb_bindir_set
+mb_exec_prefix_set
+
+mb_bindir_basename
+
+# ccenv
+mb_agnostic
+
+# cfgtest
+mb_cfgtest_cc
+mb_cfgtest_cflags
+mb_cfgtest_cfgtype
+mb_cfgtest_makevar
+mb_cfgtest_headers
diff --git a/sofort/config/opt.vars b/sofort/config/opt.vars
new file mode 100644
index 0000000..e71ea56
--- /dev/null
+++ b/sofort/config/opt.vars
@@ -0,0 +1,9 @@
+version_opt
+
+shared_library_opt
+static_library_opt
+
+app_frontend_opt
+app_linking_opt
+
+install_headers_opt
diff --git a/sofort/core/_flavor/flavor_app_frontend_disabled.mk b/sofort/core/_flavor/flavor_app_frontend_disabled.mk
new file mode 100644
index 0000000..31ad23a
--- /dev/null
+++ b/sofort/core/_flavor/flavor_app_frontend_disabled.mk
@@ -0,0 +1,6 @@
+# flavor_app_frontend_disabled.mk: handling of frontend build options.
+# this file is covered by COPYING.SOFORT.
+
+app-tag:
+package-install-app:
+package-install-extras:
diff --git a/sofort/core/_flavor/flavor_app_frontend_enabled.mk b/sofort/core/_flavor/flavor_app_frontend_enabled.mk
new file mode 100644
index 0000000..ebbc256
--- /dev/null
+++ b/sofort/core/_flavor/flavor_app_frontend_enabled.mk
@@ -0,0 +1,6 @@
+# flavor_app_frontend_enabled.mk: handling of frontend build options.
+# this file is covered by COPYING.SOFORT.
+
+app-tag: package-app app.tag
+package-install-app: install-app
+package-install-extras: install-extras
diff --git a/sofort/core/_flavor/flavor_app_linking_all_shared.mk b/sofort/core/_flavor/flavor_app_linking_all_shared.mk
new file mode 100644
index 0000000..fe89318
--- /dev/null
+++ b/sofort/core/_flavor/flavor_app_linking_all_shared.mk
@@ -0,0 +1,7 @@
+# flavor_app_linking_all_shared.mk: handling of frontend linking options.
+# this file is covered by COPYING.SOFORT.
+
+PACKAGE_APP = $(SHARED_APP)
+
+package-app: shared-app
+app.tag: $(SHARED_APP)
diff --git a/sofort/core/_flavor/flavor_app_linking_all_static.mk b/sofort/core/_flavor/flavor_app_linking_all_static.mk
new file mode 100644
index 0000000..7a5f620
--- /dev/null
+++ b/sofort/core/_flavor/flavor_app_linking_all_static.mk
@@ -0,0 +1,7 @@
+# flavor_app_linking_all_static.mk: handling of frontend linking options.
+# this file is covered by COPYING.SOFORT.
+
+PACKAGE_APP = $(STATIC_APP)
+
+package-app: static-app
+app.tag: $(STATIC_APP)
diff --git a/sofort/core/_flavor/flavor_app_linking_default.mk b/sofort/core/_flavor/flavor_app_linking_default.mk
new file mode 100644
index 0000000..b0c1d34
--- /dev/null
+++ b/sofort/core/_flavor/flavor_app_linking_default.mk
@@ -0,0 +1,7 @@
+# flavor_app_linking_default.mk: handling of frontend linking options.
+# this file is covered by COPYING.SOFORT.
+
+PACKAGE_APP = $(DEFAULT_APP)
+
+package-app: default-app
+app.tag: $(DEFAULT_APP)
diff --git a/sofort/core/_flavor/flavor_install_headers_custom.mk b/sofort/core/_flavor/flavor_install_headers_custom.mk
new file mode 100644
index 0000000..4f8da97
--- /dev/null
+++ b/sofort/core/_flavor/flavor_install_headers_custom.mk
@@ -0,0 +1,4 @@
+# flavor_install_headers_custom.mk: handling of header installation option.
+# this file is covered by COPYING.SOFORT.
+
+install-headers:install-headers-custom
diff --git a/sofort/core/_flavor/flavor_install_headers_default.mk b/sofort/core/_flavor/flavor_install_headers_default.mk
new file mode 100644
index 0000000..f8b49c4
--- /dev/null
+++ b/sofort/core/_flavor/flavor_install_headers_default.mk
@@ -0,0 +1,4 @@
+# flavor_install_headers_default.mk: handling of header installation option.
+# this file is covered by COPYING.SOFORT.
+
+install-headers:install-headers-default
diff --git a/sofort/core/_flavor/flavor_shared_library_disabled.mk b/sofort/core/_flavor/flavor_shared_library_disabled.mk
new file mode 100644
index 0000000..9846e1b
--- /dev/null
+++ b/sofort/core/_flavor/flavor_shared_library_disabled.mk
@@ -0,0 +1,5 @@
+# flavor_shared_library_disabled.mk: handling of shared library dependencies.
+# this file is covered by COPYING.SOFORT.
+
+package-shared:
+package-install-shared:
diff --git a/sofort/core/_flavor/flavor_shared_library_enabled.mk b/sofort/core/_flavor/flavor_shared_library_enabled.mk
new file mode 100644
index 0000000..2e54d21
--- /dev/null
+++ b/sofort/core/_flavor/flavor_shared_library_enabled.mk
@@ -0,0 +1,5 @@
+# flavor_shared_library_enabled.mk: handling of shared library dependencies.
+# this file is covered by COPYING.SOFORT.
+
+package-shared: shared
+package-install-shared: install-shared
diff --git a/sofort/core/_flavor/flavor_static_library_disabled.mk b/sofort/core/_flavor/flavor_static_library_disabled.mk
new file mode 100644
index 0000000..e46d186
--- /dev/null
+++ b/sofort/core/_flavor/flavor_static_library_disabled.mk
@@ -0,0 +1,5 @@
+# flavor_static_library_disabled.mk: handling of static library dependencies.
+# this file is covered by COPYING.SOFORT.
+
+package-static:
+package-install-static:
diff --git a/sofort/core/_flavor/flavor_static_library_enabled.mk b/sofort/core/_flavor/flavor_static_library_enabled.mk
new file mode 100644
index 0000000..20d4bd8
--- /dev/null
+++ b/sofort/core/_flavor/flavor_static_library_enabled.mk
@@ -0,0 +1,5 @@
+# flavor_static_library_enabled.mk: handling of static library dependencies.
+# this file is covered by COPYING.SOFORT.
+
+package-static: static
+package-install-static: install-static
diff --git a/sofort/core/_infer/infer_modern.mk b/sofort/core/_infer/infer_modern.mk
new file mode 100644
index 0000000..aaf3361
--- /dev/null
+++ b/sofort/core/_infer/infer_modern.mk
@@ -0,0 +1,22 @@
+# infer_modern.mk: modern make target- and inference rules.
+# this file is covered by COPYING.SOFORT.
+
+src/%.ao: $(SOURCE_DIR)/src/%.c
+ $(CC) -c -o $@ $< $(CFLAGS_APP)
+
+src/%.lo: $(SOURCE_DIR)/src/%.c
+ $(CC) -c -o $@ $< $(CFLAGS_SHARED)
+
+src/%.o: $(SOURCE_DIR)/src/%.c
+ $(CC) -c -o $@ $< $(CFLAGS_STATIC)
+
+$(SHARED_LIB):
+ $(SHARED_LIB_CMD) $@ $^ $(SHARED_LIB_LDFLAGS) $(LDFLAGS_IMPLIB)
+
+lib/%$(OS_ARCHIVE_EXT):
+ mkdir -p lib
+ rm -f $@
+ $(AR) rcs $@ $^
+
+srcs.tag:
+ touch $@
diff --git a/sofort/core/_infer/infer_posix.mk b/sofort/core/_infer/infer_posix.mk
new file mode 100644
index 0000000..ae990e8
--- /dev/null
+++ b/sofort/core/_infer/infer_posix.mk
@@ -0,0 +1,27 @@
+# infer_posix.mk: posix make target- and inference rules.
+# this file is covered by COPYING.SOFORT.
+
+.c.ao:
+ $(CC) -c -o $@ $< $(CFLAGS_APP)
+
+.c.lo:
+ $(CC) -c -o $@ $< $(CFLAGS_SHARED)
+
+.c.o:
+ $(CC) -c -o $@ $< $(CFLAGS_STATIC)
+
+$(SHARED_LIB):
+ $(SHARED_LIB_CMD) $@ $(SHARED_OBJS) $(SHARED_LIB_LDFLAGS) $(LDFLAGS_IMPLIB)
+
+$(STATIC_LIB):
+ mkdir -p lib
+ rm -f $@
+ $(AR) rcs $@ $(STATIC_OBJS)
+
+srcs.tag: tree.tag
+
+srcs.tag:
+ $(PROJECT_DIR)/sofort/tools/srctree.sh \
+ --srctree=$(SOURCE_DIR) -- \
+ $(COMMON_SRCS) $(APP_SRCS)
+ touch $@
diff --git a/sofort/core/_version/_soname/version_soname_copy.mk b/sofort/core/_version/_soname/version_soname_copy.mk
new file mode 100644
index 0000000..c176d5a
--- /dev/null
+++ b/sofort/core/_version/_soname/version_soname_copy.mk
@@ -0,0 +1,8 @@
+# version_soname_copy.mk: handling of shared library versioning schemes.
+# this file is covered by COPYING.SOFORT.
+
+install-soname: install-lib
+ cp $(SHARED_LIB) $(DESTDIR)$(LIBDIR)/$(DSO_SONAME)
+
+$(SHARED_SONAME): $(SHARED_LIB)
+ cp $(SHARED_LIB) $(SHARED_SONAME)
diff --git a/sofort/core/_version/_soname/version_soname_symlink.mk b/sofort/core/_version/_soname/version_soname_symlink.mk
new file mode 100644
index 0000000..963b891
--- /dev/null
+++ b/sofort/core/_version/_soname/version_soname_symlink.mk
@@ -0,0 +1,12 @@
+# version_soname_symlink.mk: handling of shared library versioning schemes.
+# this file is covered by COPYING.SOFORT.
+
+$(SHARED_SONAME): $(SHARED_LIB)
+ rm -f $@.tmp
+ ln -s $(DSO_VER) $@.tmp
+ mv $@.tmp $@
+
+install-soname: install-lib
+ rm -f $(SHARED_SONAME).tmp
+ ln -s $(DSO_VER) $(SHARED_SONAME).tmp
+ mv $(SHARED_SONAME).tmp $(DESTDIR)$(LIBDIR)/$(DSO_SONAME)
diff --git a/sofort/core/_version/version_none.mk b/sofort/core/_version/version_none.mk
new file mode 100644
index 0000000..d8fc570
--- /dev/null
+++ b/sofort/core/_version/version_none.mk
@@ -0,0 +1,10 @@
+# version_none.mk: handling of shared library versioning schemes.
+# this file is covered by COPYING.SOFORT.
+
+VER_XYZ =
+VER_SONAME =
+
+package-shared-soname:
+package-shared-solink:
+package-install-soname:
+package-install-solink:
diff --git a/sofort/core/_version/version_used.mk b/sofort/core/_version/version_used.mk
new file mode 100644
index 0000000..4724cee
--- /dev/null
+++ b/sofort/core/_version/version_used.mk
@@ -0,0 +1,26 @@
+# version_used.mk: handling of shared library versioning schemes.
+# this file is covered by COPYING.SOFORT.
+
+VER_XYZ = .$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)
+VER_SONAME = .$(VER_MAJOR)
+
+package-shared-soname: shared-soname
+package-shared-solink: shared-solink
+package-install-soname: install-soname
+package-install-solink: install-solink
+
+
+
+# libfoo.so (common)
+install-solink: install-lib
+ rm -f $(SHARED_SOLINK).tmp
+ ln -s $(DSO_VER) $(SHARED_SOLINK).tmp
+ mv $(SHARED_SOLINK).tmp $(DESTDIR)$(LIBDIR)/$(DSO_SOLINK)
+
+$(SHARED_SOLINK): $(SHARED_LIB)
+ rm -f $@.tmp
+ ln -s $(DSO_VER) $@.tmp
+ mv $@.tmp $@
+
+# libfoo.so.x (symlink or copy)
+include $(PROJECT_DIR)/sofort/core/_version/_soname/version_soname_$(OS_SONAME).mk
diff --git a/sofort/core/defs.mk b/sofort/core/defs.mk
new file mode 100644
index 0000000..2622cff
--- /dev/null
+++ b/sofort/core/defs.mk
@@ -0,0 +1,66 @@
+SHARED_LIB_DEPS +=
+SHARED_APP_DEPS +=
+STATIC_APP_DEPS +=
+
+COMMON_LOBJS += $(COMMON_SRCS:.c=.lo)
+COMMON_OBJS += $(COMMON_SRCS:.c=.o)
+
+ARCH_LOBJS += $(ARCH_SRCS:.c=.lo)
+ARCH_OBJS += $(ARCH_SRCS:.c=.o)
+
+APP_LOBJS += $(APP_SRCS:.c=.lo)
+APP_OBJS += $(APP_SRCS:.c=.ao)
+
+SHARED_OBJS += $(COMMON_LOBJS) $(ARCH_LOBJS)
+STATIC_OBJS += $(COMMON_OBJS) $(ARCH_OBJS)
+
+STATIC_LIB_NAME = $(OS_LIB_PREFIX)$(PACKAGE)$(OS_ARCHIVE_EXT)
+STATIC_LIB = lib/$(STATIC_LIB_NAME)
+
+DSO_VER = $(OS_LIB_PREFIX)$(PACKAGE)$(OS_LIB_PREFIXED_SUFFIX)$(VER_XYZ)$(OS_LIB_SUFFIXED_SUFFIX)
+DSO_SONAME = $(OS_LIB_PREFIX)$(PACKAGE)$(OS_LIB_PREFIXED_SUFFIX)$(VER_SONAME)$(OS_LIB_SUFFIXED_SUFFIX)
+DSO_SOLINK = $(OS_LIB_PREFIX)$(PACKAGE)$(OS_LIB_SUFFIX)
+
+SHARED_LIB = lib/$(DSO_VER)
+SHARED_SONAME = lib/$(DSO_SONAME)
+SHARED_SOLINK = lib/$(DSO_SOLINK)
+
+IMP_DEF = $(OS_LIB_PREFIX)$(PACKAGE)$(VER_XYZ)$(OS_LIBDEF_EXT)
+IMP_VER = $(OS_LIB_PREFIX)$(PACKAGE)$(VER_XYZ)$(OS_IMPLIB_EXT)
+IMP_SONAME = $(OS_LIB_PREFIX)$(PACKAGE)$(VER_SONAME)$(OS_IMPLIB_EXT)
+IMP_SOLINK = $(OS_LIB_PREFIX)$(PACKAGE)$(OS_IMPLIB_EXT)
+
+IMPLIB_DEF = lib/$(IMP_DEF)
+IMPLIB_VER = lib/$(IMP_VER)
+IMPLIB_SONAME = lib/$(IMP_SONAME)
+IMPLIB_SOLINK = lib/$(IMP_SOLINK)
+
+APP = bin/$(OS_APP_PREFIX)$(NICKNAME)$(OS_APP_SUFFIX)
+DEFAULT_APP = bin/$(OS_APP_PREFIX)$(NICKNAME)-default$(OS_APP_SUFFIX)
+SHARED_APP = bin/$(OS_APP_PREFIX)$(NICKNAME)-shared$(OS_APP_SUFFIX)
+STATIC_APP = bin/$(OS_APP_PREFIX)$(NICKNAME)-static$(OS_APP_SUFFIX)
+
+CFLAGS = $(CFLAGS_DEBUG) $(CFLAGS_CONFIG) $(CFLAGS_SYSROOT) \
+ $(CFLAGS_COMMON) $(CFLAGS_CMDLINE) $(CFLAGS_HOST) \
+ $(CFLAGS_PATH) $(CFLAGS_OS) $(CFLAGS_SITE) \
+ $(CFLAGS_VERSION) $(CFLAGS_STRICT) \
+ $(CFLAGS_LAST) $(CFLAGS_ONCE)
+
+CFLAGS_SHARED = $(CFLAGS) $(CFLAGS_PIC) $(CFLAGS_SHARED_ATTR)
+CFLAGS_STATIC = $(CFLAGS) $(CFLAGS_OBJ) $(CFLAGS_STATIC_ATTR)
+CFLAGS_APP = $(CFLAGS) $(CFLAGS_OBJ) $(CFLAGS_APP_ATTR) $(CFLAGS_UTIL)
+
+LDFLAGS_SHARED = $(LDFLAGS_DEBUG) $(LDFLAGS_CONFIG) $(LDFLAGS_SYSROOT) \
+ $(LDFLAGS_COMMON) $(LDFLAGS_CMDLINE) $(LDFLAGS_HOST) \
+ $(LDFLAGS_PATH) $(SHARED_LIB_DEPS) $(LDFLAGS_STRICT) \
+ $(LDFLAGS_LAST) $(LDFLAGS_ONCE)
+
+LDFLAGS_APP = $(LDFLAGS_DEBUG) $(LDFLAGS_CONFIG) $(LDFLAGS_SYSROOT) \
+ $(LDFLAGS_COMMON) $(LDFLAGS_CMDLINE) $(LDFLAGS_HOST) \
+ $(LDFLAGS_PATH) $(SHARED_APP_DEPS) $(LDFLAGS_STRICT) \
+ $(LDFLAGS_UTIL) $(LDFLAGS_LAST) $(LDFLAGS_ONCE)
+
+LDFLAGS_STATIC = $(LDFLAGS_DEBUG) $(LDFLAGS_CONFIG) $(LDFLAGS_SYSROOT) \
+ $(LDFLAGS_COMMON) $(LDFLAGS_CMDLINE) $(LDFLAGS_HOST) \
+ $(LDFLAGS_PATH) $(STATIC_APP_DEPS) $(LDFLAGS_STRICT) \
+ $(LDFLAGS_LAST) $(LDFLAGS_ONCE)
diff --git a/sofort/core/flavor.mk b/sofort/core/flavor.mk
new file mode 100644
index 0000000..6a7c97a
--- /dev/null
+++ b/sofort/core/flavor.mk
@@ -0,0 +1,12 @@
+# flavor.mk: top-level handling of build flavors.
+# this file is covered by COPYING.SOFORT.
+
+include $(PROJECT_DIR)/sofort/exrules/$(OS_DSO_EXRULES).mk
+
+include $(PROJECT_DIR)/sofort/core/_flavor/flavor_static_library_$(STATIC_LIBRARY_OPT).mk
+include $(PROJECT_DIR)/sofort/core/_flavor/flavor_shared_library_$(SHARED_LIBRARY_OPT).mk
+
+include $(PROJECT_DIR)/sofort/core/_flavor/flavor_app_frontend_$(APP_FRONTEND_OPT).mk
+include $(PROJECT_DIR)/sofort/core/_flavor/flavor_app_linking_$(APP_LINKING_OPT).mk
+
+include $(PROJECT_DIR)/sofort/core/_flavor/flavor_install_headers_$(INSTALL_HEADERS_OPT).mk
diff --git a/sofort/core/infer.mk b/sofort/core/infer.mk
new file mode 100644
index 0000000..8a1c6dd
--- /dev/null
+++ b/sofort/core/infer.mk
@@ -0,0 +1,4 @@
+# infer.mk: top-level handling of inference rules.
+# this file is covered by COPYING.SOFORT.
+
+include $(PROJECT_DIR)/sofort/core/_infer/infer_$(MAKEMODE).mk
diff --git a/sofort/core/modern.m4 b/sofort/core/modern.m4
new file mode 100644
index 0000000..ad75ca9
--- /dev/null
+++ b/sofort/core/modern.m4
@@ -0,0 +1,117 @@
+dnl modern.m4: a modern and simple framework for using the m4 macro language
+dnl
+dnl This file is covered by COPYING.SOFORT.
+dnl
+dnl 1) make all standard m4 builtins m4_ prefixed.
+dnl 2) set the left-bracket and right-bracket symbols the begin-quote and end-quote strings.
+dnl 3) make a single underscore symbol the equivalent of the standard dnl builtin.
+dnl 4) provide the m4_toupper(), m4_tolower(), and m4_pathvar() macros.
+dnl 5) provide the m4_srclist() and m4_srcitem() macros.
+dnl 6) provide the m4_fillerdots(), m4_fillerdash(), and m4_fillerline() macros.
+dnl 7) provide the m4_whitespace() and m4_spacealign() macros.
+dnl 8) provide the m4_alignlen(), m4_leftalign(), and m4_rightalign() macros.
+dnl 9) provide the m4_tab(), m4_tabtab(), and m4_tabtabtab() macros.
+dnl
+divert(-1)
+
+define(m4_changecom,defn(`changecom'))
+define(m4_changequote,defn(`changequote'))
+define(m4_decr,defn(`decr'))
+define(m4_define,defn(`define'))
+define(m4_defn,defn(`defn'))
+define(m4_divert,defn(`divert'))
+define(m4_divnum,defn(`divnum'))
+define(m4_dnl,defn(`dnl'))
+define(m4_dumpdef,defn(`dumpdef'))
+define(m4_errprint,defn(`errprint'))
+define(m4_eval,defn(`eval'))
+define(m4_ifdef,defn(`ifdef'))
+define(m4_ifelse,defn(`ifelse'))
+define(m4_include,defn(`include'))
+define(m4_incr,defn(`incr'))
+define(m4_index,defn(`index'))
+define(m4_len,defn(`len'))
+define(m4_m4exit,defn(`m4exit'))
+define(m4_m4wrap,defn(`m4wrap'))
+define(m4_maketemp,defn(`maketemp'))
+define(m4_mkstemp,defn(`mkstemp'))
+define(m4_popdef,defn(`popdef'))
+define(m4_pushdef,defn(`pushdef'))
+define(m4_shift,defn(`shift'))
+define(m4_sinclude,defn(`sinclude'))
+define(m4_substr,defn(`substr'))
+define(m4_syscmd,defn(`syscmd'))
+define(m4_sysval,defn(`sysval'))
+define(m4_traceoff,defn(`traceoff'))
+define(m4_traceon,defn(`traceon'))
+define(m4_translit,defn(`translit'))
+define(m4_undefine,defn(`undefine'))
+define(m4_undivert,defn(`undivert'))
+
+m4_changequote([,])
+
+m4_undefine([changecom])
+m4_undefine([changequote])
+m4_undefine([decr])
+m4_undefine([define])
+m4_undefine([defn])
+m4_undefine([divert])
+m4_undefine([divnum])
+m4_undefine([dnl])
+m4_undefine([dumpdef])
+m4_undefine([errprint])
+m4_undefine([eval])
+m4_undefine([ifdef])
+m4_undefine([ifelse])
+m4_undefine([include])
+m4_undefine([incr])
+m4_undefine([index])
+m4_undefine([len])
+m4_undefine([m4exit])
+m4_undefine([m4wrap])
+m4_undefine([maketemp])
+m4_undefine([mkstemp])
+m4_undefine([popdef])
+m4_undefine([pushdef])
+m4_undefine([shift])
+m4_undefine([sinclude])
+m4_undefine([substr])
+m4_undefine([syscmd])
+m4_undefine([sysval])
+m4_undefine([traceoff])
+m4_undefine([traceon])
+m4_undefine([translit])
+m4_undefine([undefine])
+m4_undefine([undivert])
+
+m4_define([_],m4_defn([m4_dnl]))
+
+m4_define([m4_toupper],[m4_translit([[$1]],[[abcdefghijklmnopqrstuvwxyz]],[[ABCDEFGHIJKLMNOPQRSTUVWXYZ]])])
+m4_define([m4_tolower],[m4_translit([[$1]],[[ABCDEFGHIJKLMNOPQRSTUVWXYZ]],[[abcdefghijklmnopqrstuvwxyz]])])
+m4_define([m4_pathvar],[m4_translit(m4_toupper([[$1]]),[/-],[__])])
+
+m4_define([m4_srclist],[[$1] = \])
+m4_define([m4_srcitem],[m4_tab[$1] \])
+
+m4_define([m4_fillerdots],[................................])
+m4_define([m4_fillerdash],[--------------------------------])
+m4_define([m4_fillerline],[m4_fillerdots[]m4_fillerdots[]m4_fillerdots[]])
+
+m4_define([m4_whitespace],[m4_translit(m4_fillerdots,[[.]],[[ ]])])
+m4_define([m4_spacealign],[m4_translit(m4_fillerline,[[.]],[[ ]])])
+
+m4_define([m4_alignlen],[m4_eval([$1]-m4_len([$2]))])
+m4_define([m4_leftalign],[m4_substr(m4_spacealign,0,m4_alignlen([$1],[$2]))[$2]])
+m4_define([m4_rightalign],[[$2]m4_substr(m4_spacealign,0,m4_alignlen([$1],[$2]))])
+
+
+m4_define([m4_tab],_
+ [$1]))
+
+m4_define([m4_tabtab],_
+ [$1])
+
+m4_define([m4_tabtabtab],_
+ [$1])
+
+m4_divert(0)_
diff --git a/sofort/core/pkgconf.mk b/sofort/core/pkgconf.mk
new file mode 100644
index 0000000..5ada069
--- /dev/null
+++ b/sofort/core/pkgconf.mk
@@ -0,0 +1,39 @@
+# pkgconf.mk: rules for pkgconf manifest generation.
+# this file is covered by COPYING.SOFORT.
+
+PKGCONF_VERSION = $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)
+
+.pkgconf:
+
+build/$(PACKAGE).pc: .pkgconf dirs.tag
+
+build/$(PACKAGE).pc:
+ @touch $@
+ @chmod 0644 $@
+ PKGCONF_NAME='$(PKGNAME)' \
+ PKGCONF_DESC='$(PKGDESC)' \
+ PKGCONF_USRC='$(PKGUSRC)' \
+ PKGCONF_REPO='$(PKGREPO)' \
+ PKGCONF_PSRC='$(PKGPSRC)' \
+ PKGCONF_DURL='$(PKGDURL)' \
+ PKGCONF_BUGS='$(PKGBUGS)' \
+ PKGCONF_HOME='$(PKGHOME)' \
+ PKGCONF_DEFS='$(PKGDEFS)' \
+ PKGCONF_LIBS='$(PKGLIBS)' \
+ \
+ PKGCONF_EXEC_PREFIX='$(EXEC_PREFIX)' \
+ PKGCONF_PREFIX='$(PREFIX)' \
+ PKGCONF_LIBDIR='$(LIBDIR)' \
+ PKGCONF_INCLUDEDIR='$(INCLUDEDIR)' \
+ PKGCONF_VERSION='$(PKGCONF_VERSION)' \
+ $(PROJECT_DIR)/sofort/tools/pkgconf.sh > $@
+
+install-pkgconf: build/$(PACKAGE).pc
+ mkdir -p $(DESTDIR)$(LIBDIR)/pkgconfig
+ cp -p build/$(PACKAGE).pc $(DESTDIR)$(LIBDIR)/pkgconfig
+
+install-shared: install-pkgconf
+
+install-static: install-pkgconf
+
+.PHONY: .pkgconf install-pkgconf
diff --git a/sofort/core/version.mk b/sofort/core/version.mk
new file mode 100644
index 0000000..ad693ab
--- /dev/null
+++ b/sofort/core/version.mk
@@ -0,0 +1,10 @@
+# version.mk: handling of shared library versioning schemes.
+# this file is covered by COPYING.SOFORT.
+
+include $(PROJECT_DIR)/project/tagver.mk
+
+CFLAGS_VERSION += -D$(VER_NAMESPACE)_TAG_VER_MAJOR=$(VER_MAJOR)
+CFLAGS_VERSION += -D$(VER_NAMESPACE)_TAG_VER_MINOR=$(VER_MINOR)
+CFLAGS_VERSION += -D$(VER_NAMESPACE)_TAG_VER_PATCH=$(VER_PATCH)
+
+include $(PROJECT_DIR)/sofort/core/_version/version_$(VERSION_OPT).mk
diff --git a/sofort/exrules/_pe/pe_mdso_version_none.mk b/sofort/exrules/_pe/pe_mdso_version_none.mk
new file mode 100644
index 0000000..cf5e350
--- /dev/null
+++ b/sofort/exrules/_pe/pe_mdso_version_none.mk
@@ -0,0 +1,2 @@
+# pe_mdso_version_none.mk: PE shared library rules for targets using mdso.
+# this file is covered by COPYING.SOFORT.
diff --git a/sofort/exrules/_pe/pe_mdso_version_used.mk b/sofort/exrules/_pe/pe_mdso_version_used.mk
new file mode 100644
index 0000000..fac0246
--- /dev/null
+++ b/sofort/exrules/_pe/pe_mdso_version_used.mk
@@ -0,0 +1,5 @@
+# pe_mdso_version_used.mk: PE shared library rules for targets using mdso.
+# this file is covered by COPYING.SOFORT.
+
+$(IMPLIB_SONAME): $(IMPLIB_DEF)
+ $(MDSO) -m $(CC_BITS) -i $(IMPLIB_SONAME) -n $(DSO_SONAME) $(IMPLIB_DEF)
diff --git a/sofort/exrules/_pe/pe_version_none.mk b/sofort/exrules/_pe/pe_version_none.mk
new file mode 100644
index 0000000..df33976
--- /dev/null
+++ b/sofort/exrules/_pe/pe_version_none.mk
@@ -0,0 +1,7 @@
+# pe_version_none.mk: handling of PE shared library versioning schemes.
+# this file is covered by COPYING.SOFORT.
+
+package-implib-soname:
+package-implib-solink:
+package-install-implib-soname:
+package-install-implib-solink:
diff --git a/sofort/exrules/_pe/pe_version_used.mk b/sofort/exrules/_pe/pe_version_used.mk
new file mode 100644
index 0000000..8710dae
--- /dev/null
+++ b/sofort/exrules/_pe/pe_version_used.mk
@@ -0,0 +1,23 @@
+# pe_version_used.mk: handling of PE shared library versioning schemes.
+# this file is covered by COPYING.SOFORT.
+
+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)
diff --git a/sofort/exrules/default.mk b/sofort/exrules/default.mk
new file mode 100644
index 0000000..9844f37
--- /dev/null
+++ b/sofort/exrules/default.mk
@@ -0,0 +1,17 @@
+# default.mk: default shared library rules.
+# this file is covered by COPYING.SOFORT.
+
+DSO_REF_VER = $(SHARED_LIB)
+DSO_REF_SONAME = $(SHARED_SONAME)
+DSO_REF_SOLINK = $(SHARED_SOLINK)
+
+LDFLAGS_SHARED += -Wl,-soname
+LDFLAGS_SHARED += -Wl,$(DSO_SONAME)
+
+implib:
+
+install-implib:
+
+clean-implib:
+
+.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..3e132a9
--- /dev/null
+++ b/sofort/exrules/pe-common.mk
@@ -0,0 +1,42 @@
+# pe-common.mk: common PE shared library rules.
+# this file is covered by COPYING.SOFORT.
+
+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..0fc1adf
--- /dev/null
+++ b/sofort/exrules/pe-dlltool.mk
@@ -0,0 +1,18 @@
+# pe-dlltool.mk: PE shared library rules for targets using dlltool.
+# this file is covered by COPYING.SOFORT.
+
+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..0c380e0
--- /dev/null
+++ b/sofort/exrules/pe-mdso.mk
@@ -0,0 +1,11 @@
+# pe-mdso.mk: PE shared library rules for targets using mdso.
+# this file is covered by COPYING.SOFORT.
+
+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) $(IMPLIB_DEF)
+
+include $(PROJECT_DIR)/sofort/exrules/_pe/pe_mdso_version_$(VERSION_OPT).mk
+
+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..7f5b658
--- /dev/null
+++ b/sofort/exrules/pe-version.mk
@@ -0,0 +1,4 @@
+# pe-version.mk: handling of PE shared library versioning schemes.
+# this file is covered by COPYING.SOFORT.
+
+include $(PROJECT_DIR)/sofort/exrules/_pe/pe_version_$(VERSION_OPT).mk
diff --git a/sofort/tools/pkgconf.sh b/sofort/tools/pkgconf.sh
new file mode 100755
index 0000000..a69c25b
--- /dev/null
+++ b/sofort/tools/pkgconf.sh
@@ -0,0 +1,136 @@
+#!/bin/sh
+
+# pkgconf.sh: generate a pkgconf manifest file.
+# this file is covered by COPYING.SOFORT.
+
+set -eu
+
+# prefix, exec_prefix
+if [ "$PKGCONF_PREFIX" = "$PKGCONF_EXEC_PREFIX" ]; then
+ pkgconf_prefix="${PKGCONF_PREFIX}"
+ pkgconf_exec_prefix='${prefix}'
+else
+ pkgconf_prefix="${PKGCONF_PREFIX}"
+ pkgconf_exec_prefix="${PKGCONF_EXEC_PREFIX}"
+fi
+
+
+# (relative) includedir
+if [ -z "$PKGCONF_INCLUDEDIR" ]; then
+ pkgconf_includedir=
+ pkgconf_cflags=
+else
+ prefix=$(dirname "$PKGCONF_INCLUDEDIR")
+ base=$(basename "$PKGCONF_INCLUDEDIR")
+
+ if [ "$prefix" = '/' ]; then
+ prefix=
+ fi
+
+ if [ "$prefix/$base" = "$PKGCONF_PREFIX/$base" ]; then
+ pkgconf_includedir='${prefix}/'"${base}"
+ pkgconf_cflags='-I${includedir}'
+ else
+ pkgconf_includedir="${PKGCONF_INCLUDEDIR}"
+ pkgconf_cflags='-I${includedir}'
+ fi
+fi
+
+
+# (relative) libdir (blank unless needed)
+if [ -z "$PKGCONF_LIBDIR" ]; then
+ pkgconf_libdir=
+else
+ prefix=$(dirname "$PKGCONF_LIBDIR")
+ base=$(basename "$PKGCONF_LIBDIR")
+
+ if [ "$prefix" = '/' ]; then
+ prefix=
+ fi
+
+ if [ "$prefix/$base" = "$PKGCONF_EXEC_PREFIX/$base" ]; then
+ pkgconf_libdir='${exec_prefix}/'"${base}"
+ else
+ pkgconf_libdir='${prefix}/'"${PKGCONF_LIBDIR}"
+ fi
+fi
+
+
+# ldflags (--libs)
+if [ -n "$pkgconf_libdir" ] && [ -n "${PKGCONF_NAME}" ]; then
+ pkgconf_ldflags='-L${libdir}'" -l${PKGCONF_NAME}"
+elif [ -n "${PKGCONF_NAME}" ]; then
+ pkgconf_ldflags="-l${PKGCONF_NAME}"
+else
+ pkgconf_ldflags='-L${libdir}'
+fi
+
+
+# cflags
+if [ -n "$pkgconf_cflags" ] || [ -n "${PKGCONF_DEFS}" ]; then
+ pkgconf_cflags="$pkgconf_cflags ${PKGCONF_DEFS}"
+ pkgconf_cflags=$(printf '%s' "$pkgconf_cflags" | sed -e 's/^[ \t]*//g')
+fi
+
+
+# repo (optional)
+if [ -z "${PKGCONF_REPO}" ]; then
+ pkgconf_repo='#'
+else
+ pkgconf_repo="Repo: ${PKGCONF_REPO}"
+fi
+
+# patches (optional)
+if [ -z "${PKGCONF_PSRC}" ]; then
+ pkgconf_psrc='#'
+else
+ pkgconf_psrc="Patches: ${PKGCONF_PSRC}"
+fi
+
+# distro (optional)
+if [ -z "${PKGCONF_DURL}" ]; then
+ pkgconf_durl='#'
+else
+ pkgconf_durl="Distro: ${PKGCONF_DURL}"
+fi
+
+# bug reports (optional)
+if [ -z "${PKGCONF_BUGS}" ]; then
+ pkgconf_bugs='#'
+else
+ pkgconf_bugs="Bug reports: ${PKGCONF_BUGS}"
+fi
+
+# project home page (optional)
+if [ -z "${PKGCONF_HOME}" ]; then
+ pkgconf_home='#'
+else
+ pkgconf_home="Home page: ${PKGCONF_HOME}"
+fi
+
+
+# output (without trailing spaces)
+cat << _EOF | grep -v '^#' | sed 's/[ \t]*$//'
+###
+prefix=$pkgconf_prefix
+exec_prefix=$pkgconf_exec_prefix
+includedir=$pkgconf_includedir
+libdir=$pkgconf_libdir
+
+Name: ${PKGCONF_NAME}
+Description: ${PKGCONF_DESC}
+URL: ${PKGCONF_USRC}
+Version: ${PKGCONF_VERSION}
+$pkgconf_repo
+$pkgconf_psrc
+$pkgconf_durl
+$pkgconf_bugs
+$pkgconf_home
+
+Cflags: $pkgconf_cflags
+Libs: $pkgconf_ldflags
+###
+_EOF
+
+# all done
+exit 0
diff --git a/sofort/tools/srctree.sh b/sofort/tools/srctree.sh
new file mode 100755
index 0000000..90a1d89
--- /dev/null
+++ b/sofort/tools/srctree.sh
@@ -0,0 +1,83 @@
+#!/bin/sh
+
+# srctree.sh: support for out-of-tree builds in posix make mode.
+# this file is covered by COPYING.SOFORT.
+
+set -eu
+
+usage()
+{
+cat << EOF >&2
+
+Usage:
+ --help show this HELP message
+ --srctree=SRCTREE set source directory
+
+EOF
+exit 1
+}
+
+
+# one
+workdir=$(pwd -P)
+srctree=
+argloop=
+
+
+for arg ; do
+ case "$arg" in
+ --help)
+ usage
+ ;;
+
+ --srctree=*)
+ srctree=${arg#*=}
+ ;;
+
+ --)
+ argloop='done'
+ ;;
+
+ *)
+ if [ -z "$argloop" ]; then
+ printf 'Invalid option: %s\n' "$arg" >&2
+ usage
+ fi
+ ;;
+ esac
+done
+
+
+# two
+if [ -z "$srctree" ] ; then
+ usage
+fi
+
+cd -- "$srctree"
+srctree=$(pwd -P)
+cd -- "$workdir"
+
+if [ "$srctree" = "$workdir" ]; then
+ exit 0
+fi
+
+
+# three
+for arg ; do
+ case "$arg" in
+ --srctree=*)
+ ;;
+
+ --)
+ ;;
+
+ *)
+ stat "$arg" > /dev/null 2>&1 \
+ || ln -s -- "$srctree/$arg" "$arg"
+ ;;
+ esac
+done
+
+
+# all done
+exit 0
diff --git a/sofort/tools/version.sh b/sofort/tools/version.sh
new file mode 100755
index 0000000..8c49cb3
--- /dev/null
+++ b/sofort/tools/version.sh
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+# version.sh: detect git repository info, output defs as a C header.
+# this file is covered by COPYING.SOFORT.
+
+set -eu
+
+usage()
+{
+cat << EOF >&2
+
+Usage:
+ -h show this HELP message
+ -s SRCDIR set source directory
+ -o OUTPUT set output header
+ -p PREFIX set macro prefix
+
+EOF
+exit 1
+}
+
+
+# one
+workdir=$(pwd -P)
+srcdir=
+output=
+prefix=
+
+
+while getopts "hs:o:p:" opt; do
+ case $opt in
+ h)
+ usage
+ ;;
+ s)
+ srcdir="$OPTARG"
+ ;;
+ o)
+ output="$OPTARG"
+ ;;
+ p)
+ prefix="$OPTARG"
+ ;;
+ \?)
+ printf 'Invalid option: -%s' "$OPTARG" >&2
+ usage
+ ;;
+ esac
+done
+
+
+# two
+if [ -z "$srcdir" ] || [ -z "$output" ] || [ -z "$prefix" ]; then
+ usage
+fi
+
+cd -- "$srcdir"
+
+gitver=$(git rev-parse --verify HEAD 2>/dev/null) || gitver="unknown"
+cvdate=$(git show -s --format=%ci $gitver 2>/dev/null) || cvdate=$(date)
+
+vmacro=$(printf '%s' "$prefix"'_GIT_VERSION' | tr '[:lower:]' '[:upper:]')
+dmacro=$(printf '%s' "$prefix"'_GIT_DATE ' | tr '[:lower:]' '[:upper:]')
+
+cd -- "$workdir"
+
+
+# three
+printf '#define %s "%s"\n#define %s "%s"\n' \
+ "$vmacro" "$gitver" \
+ "$dmacro" "$cvdate" \
+ > "$output"
+
+# all done
+exit 0