summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Makefile.in475
-rw-r--r--config.project57
-rw-r--r--config.usage167
-rwxr-xr-xconfigure752
-rw-r--r--project/arch.mk0
-rw-r--r--project/common.mk7
-rw-r--r--project/depends.mk0
-rw-r--r--project/extras.mk0
-rw-r--r--project/headers.mk5
-rw-r--r--project/osforce.mk0
-rw-r--r--project/overrides.mk0
-rw-r--r--project/tagver.mk5
-rw-r--r--project/tree.mk3
-rw-r--r--sofort/ccenv/ccenv.in85
-rw-r--r--sofort/ccenv/ccenv.sh1067
-rw-r--r--sofort/ccenv/ccenv.usage78
-rw-r--r--sofort/ccenv/ccenv.vars82
-rw-r--r--sofort/cfgtest/cfgtest.sh332
-rw-r--r--sofort/config/cfgdefs.in6
-rw-r--r--sofort/config/config.vars117
-rw-r--r--sofort/config/flag.vars25
-rw-r--r--sofort/core/defs.mk66
-rw-r--r--sofort/core/flavor.mk70
-rw-r--r--sofort/core/pkgconf.mk40
-rw-r--r--sofort/core/version.mk63
-rw-r--r--sofort/exrules/default.mk8
-rw-r--r--sofort/exrules/pe-common.mk39
-rw-r--r--sofort/exrules/pe-dlltool.mk15
-rw-r--r--sofort/exrules/pe-mdso.mk15
-rw-r--r--sofort/exrules/pe-version.mk31
-rwxr-xr-xsofort/tools/pkgconf.sh109
-rwxr-xr-xsofort/tools/version.sh72
32 files changed, 3791 insertions, 0 deletions
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000..77882ae
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,475 @@
+PACKAGE = @package@
+NICKNAME = @nickname@
+PROJECT_DIR = @project_dir@
+SOURCE_DIR = @source_dir@
+GIT_REFERENCE_INDEX = @git_reference_index@
+CUSTOM_INSTALL_HEADERS = @custom_install_headers@
+AVOID_VERSION = @avoid_version@
+
+PKGNAME = @pkgname@
+PKGDESC = @pkgdesc@
+PKGUSRC = @pkgusrc@
+PKGREPO = @pkgrepo@
+PKGPSRC = @pkgpsrc@
+PKGDURL = @pkgdurl@
+PKGDEFS = @pkgdefs@
+PKGLIBS = @pkglibs@
+
+BUILD = @build@
+HOST = @host@
+CCHOST = @cchost@
+CFGHOST = @cfghost@
+TARGET = @target@
+ARCH = @arch@
+COMPILER = @compiler@
+TOOLCHAIN = @toolchain@
+SYSROOT = @sysroot@
+CROSS_COMPILE = @cross_compile@
+SHELL = @shell@
+
+PREFIX = @prefix@
+EXEC_PREFIX = @exec_prefix@
+BINDIR = @bindir@
+SBINDIR = @sbindir@
+LIBDIR = @libdir@
+INCLUDEDIR = @includedir@
+OLDINCLUDEDIR = @oldincludedir@
+MANDIR = @mandir@
+DOCDIR = @docdir@
+LIBEXECDIR = @libexecdir@
+
+SYSCONFDIR = @sysconfdir@
+SHAREDSTATEDIR = @sharedstatedir@
+LOCALSTATEDIR = @localstatedir@
+RUNSTATEDIR = @runstatedir@
+DATAROOTDIR = @datarootdir@
+DATADIR = @datadir@
+INFODIR = @infodir@
+LOCALEDIR = @localedir@
+HTMLDIR = @htmldir@
+DVIDIR = @dvidir@
+PDFDIR = @pdfdir@
+PSDIR = @psdir@
+
+CFLAGS_COMMON += @cflags_common@
+CFLAGS_DEBUG += @cflags_debug@
+CFLAGS_CMDLINE += @cflags_cmdline@
+CFLAGS_CONFIG += @cflags_config@
+CFLAGS_SYSROOT += @cflags_sysroot@
+CFLAGS_OS += @cflags_os@
+CFLAGS_SITE += @cflags_site@
+CFLAGS_PATH += @cflags_path@
+CFLAGS_STRICT += @cflags_strict@
+CFLAGS_UTIL += @cflags_util@
+CFLAGS_LAST += @cflags_last@
+CFLAGS_ONCE += @cflags_once@
+
+LDFLAGS_COMMON += @ldflags_common@
+LDFLAGS_DEBUG += @ldflags_debug@
+LDFLAGS_CMDLINE += @ldflags_cmdline@
+LDFLAGS_CONFIG += @ldflags_config@
+LDFLAGS_SYSROOT += @ldflags_sysroot@
+LDFLAGS_PATH += @ldflags_path@
+LDFLAGS_STRICT += @ldflags_strict@
+LDFLAGS_UTIL += @ldflags_util@
+LDFLAGS_LAST += @ldflags_last@
+LDFLAGS_ONCE += @ldflags_once@
+
+USER_CC = @user_cc@
+USER_CPP = @user_cpp@
+USER_CXX = @user_cxx@
+
+PE_SUBSYSTEM = @pe_subsystem@
+PE_IMAGE_BASE = @pe_image_base@
+PE_CONFIG_DEFS = @pe_config_defs@
+
+ELF_EH_FRAME = @elf_eh_frame@
+ELF_HASH_STYLE = @elf_hash_style@
+ELF_CONFIG_DEFS = @elf_config_defs@
+
+NATIVE_HOST = @native_host@
+NATIVE_CFGHOST = @native_cfghost@
+NATIVE_CFLAGS = @native_cflags@
+NATIVE_LDFLAGS = @native_ldflags@
+
+ALL_SHARED = @all_shared@
+ALL_STATIC = @all_static@
+DISABLE_FRONTEND = @disable_frontend@
+DISABLE_SHARED = @disable_shared@
+DISABLE_STATIC = @disable_static@
+
+USE_CUSTOM_CFGDEFS = @use_custom_cfgdefs@
+USE_CUSTOM_USRDEFS = @use_custom_usrdefs@
+
+all:
+install:
+shared:
+static:
+
+install-extras:
+install-app-extras:
+
+include ./ccenv/host.mk
+include ./ccenv/native.mk
+
+include ./cfgdefs.mk
+include ./usrdefs.mk
+
+include $(PROJECT_DIR)/sofort/core/defs.mk
+include $(PROJECT_DIR)/sofort/core/pkgconf.mk
+include $(PROJECT_DIR)/sofort/core/version.mk
+include $(PROJECT_DIR)/sofort/core/flavor.mk
+
+include $(PROJECT_DIR)/project/osforce.mk
+include $(PROJECT_DIR)/project/tree.mk
+include $(PROJECT_DIR)/project/depends.mk
+include $(PROJECT_DIR)/project/headers.mk
+include $(PROJECT_DIR)/project/common.mk
+include $(PROJECT_DIR)/project/arch.mk
+include $(PROJECT_DIR)/project/extras.mk
+include $(PROJECT_DIR)/project/overrides.mk
+
+
+$(APP_SRCS:%.c=%.o): CFLAGS_STATIC = $(CFLAGS_APP)
+
+src/%.lo: $(SOURCE_DIR)/src/%.c $(ALL_HEADERS) host.tag tree.tag
+ $(CC) -c -o $@ $< $(CFLAGS_SHARED)
+
+src/%.o: $(SOURCE_DIR)/src/%.c $(ALL_HEADERS) host.tag tree.tag
+ $(CC) -c -o $@ $< $(CFLAGS_STATIC)
+
+lib/%$(OS_LIB_PREFIXED_SUFFIX)$(VER_XYZ)$(OS_LIB_SUFFIXED_SUFFIX):
+ $(CC) -shared -o $@ $^ $(LDFLAGS_SHARED)
+
+lib/%$(OS_ARCHIVE_EXT):
+ rm -f $@
+ $(AR) rcs $@ $^
+
+
+
+all: package-shared package-static app
+
+install: package-install-app
+install: package-install-extras
+install: install-libs
+
+app: app-tag
+
+app.tag:
+ cp $(PACKAGE_APP) $(APP)
+ touch app.tag
+
+install-libs: package-install-shared
+install-libs: package-install-static
+
+install-headers-default:
+ mkdir -p $(DESTDIR)$(INCLUDEDIR)/$(PACKAGE)
+ cp $(API_HEADERS) $(DESTDIR)$(INCLUDEDIR)/$(PACKAGE)
+
+install-shared: shared install-lib install-implib
+install-shared: package-install-soname package-install-solink
+install-shared: install-headers
+
+install-lib: shared
+ mkdir -p $(DESTDIR)$(LIBDIR)
+ cp $(SHARED_LIB) $(DESTDIR)$(LIBDIR)
+
+install-static: static install-headers
+ mkdir -p $(DESTDIR)$(LIBDIR)
+ cp $(STATIC_LIB) $(DESTDIR)$(LIBDIR)
+
+install-app: app install-app-extras
+ mkdir -p $(DESTDIR)$(BINDIR)
+ cp $(APP) $(DESTDIR)$(BINDIR)
+
+install-static-app: static-app install-app-extras
+ mkdir -p $(DESTDIR)$(BINDIR)
+ cp $(STATIC_APP) $(DESTDIR)$(BINDIR)/$(NICKNAME)$(OS_APP_SUFFIX)
+
+
+
+shared: shared-lib implib
+shared: package-shared-soname package-shared-solink
+
+static: static-lib
+
+shared-lib: shared-objs $(SHARED_LIB)
+
+shared-soname: shared-lib $(SHARED_SONAME)
+
+shared-solink: shared-lib $(SHARED_SOLINK)
+
+static-lib: static-objs $(STATIC_LIB)
+
+
+
+default-app: version.tag static-objs $(DEFAULT_APP)
+
+shared-app: version.tag shared $(SHARED_APP)
+
+static-app: version.tag static-objs $(STATIC_APP)
+
+
+
+shared-objs: dirs $(SHARED_OBJS)
+
+static-objs: dirs $(STATIC_OBJS)
+
+app-objs: dirs $(APP_OBJS)
+
+
+
+$(SHARED_LIB): $(SHARED_OBJS)
+$(SHARED_LIB): LDFLAGS_SHARED += $(LDFLAGS_IMPLIB)
+
+$(STATIC_LIB): $(STATIC_OBJS)
+
+$(APP): $(PACKAGE_APP)
+
+$(DEFAULT_APP): $(STATIC_OBJS) $(APP_OBJS)
+ rm -f app.tag
+ $(CC) -o $@ $^ $(LDFLAGS_APP)
+
+$(SHARED_APP): $(DSO_REF_SOLINK) $(APP_OBJS) $(SHARED_SOLINK)
+ rm -f app.tag
+ $(CC) -o $@ $(APP_OBJS) $(LDFLAGS_APP) -l$(PACKAGE)
+
+$(STATIC_APP): $(STATIC_OBJS) $(APP_OBJS)
+ rm -f app.tag
+ $(CC) -static -o $@ $^ $(LDFLAGS_STATIC)
+
+
+dirs: dirs.tag
+
+dirs.tag:
+ mkdir -p build
+ mkdir -p bin
+ mkdir -p lib
+ touch dirs.tag
+
+host.tag: Makefile
+ $(CC) $(CFLAGS) -dumpmachine > host.tmp
+ mv host.tmp host.tag
+
+version.tag: $(GIT_REFERENCE_INDEX) dirs.tag
+ $(PROJECT_DIR)/sofort/tools/version.sh \
+ -s $(SOURCE_DIR) \
+ -o build/$(PACKAGE)_version.h \
+ -p $(PACKAGE)
+ touch version.tag
+
+distclean: clean
+ rm -f cfgdefs.mk
+ rm -f usrdefs.mk
+ rm -f Makefile
+
+clean: clean-implib
+ rm -f tree.tag
+ rm -f dirs.tag
+ rm -f host.tag
+ rm -f host.tmp
+ rm -f version.tag
+ rm -f app.tag
+ rm -f $(SHARED_OBJS)
+ rm -f $(STATIC_OBJS)
+ rm -f $(APP_OBJS)
+ rm -f $(SHARED_LIB)
+ rm -f $(SHARED_SONAME)
+ rm -f $(SHARED_SOLINK)
+ rm -f $(STATIC_LIB)
+ rm -f $(APP)
+ rm -f $(DEFAULT_APP)
+ rm -f $(SHARED_APP)
+ rm -f $(STATIC_APP)
+ rm -f build/$(PACKAGE)_version.h
+ rm -f build/$(PACKAGE).pc
+
+
+.display: .display-project .display-pkgconf .display-env \
+ .display-tools .display-flags .display-pe .display-elf \
+ .display-dirs .display-build .display-config
+
+.conf: PAGER ?= less
+.conf:
+ $(MAKE) .display | $(PAGER)
+
+.display-project:
+ @echo PACKAGE:' '$(PACKAGE)
+ @echo NICKNAME:' '$(NICKNAME)
+ @echo PROJECT_DIR:' '$(PROJECT_DIR)
+ @echo SOURCE_DIR:' '$(SOURCE_DIR)
+ @echo BUILD_DIR:' '$(CURDIR)
+ @echo
+
+.display-pkgconf:
+ @echo PKGNAME:' '$(PKGNAME)
+ @echo PKGDESC:' '$(PKGDESC)
+ @echo PKGUSRC:' '$(PKGUSRC)
+ @echo PKGREPO:' '$(PKGREPO)
+ @echo PKGPSRC:' '$(PKGPSRC)
+ @echo PKGDURL:' '$(PKGDURL)
+ @echo PKGDEFS:' '$(PKGDEFS)
+ @echo PKGLIBS:' '$(PKGLIBS)
+ @echo
+
+.display-env:
+ @echo BUILD:' '$(BUILD)
+ @echo HOST:' '$(HOST)
+ @echo CCHOST:' '$(CCHOST)
+ @echo CFGHOST:' '$(CFGHOST)
+ @echo TARGET:' '$(TARGET)
+ @echo ARCH:' '$(ARCH)
+ @echo COMPILER:' '$(COMPILER)
+ @echo TOOLCHAIN:' '$(TOOLCHAIN)
+ @echo SYSROOT:' '$(SYSROOT)
+ @echo CROSS_COMPILE:' '$(CROSS_COMPILE)
+ @echo SHELL:' '$(SHELL)
+ @echo
+
+.display-tools:
+ @echo CC:' '$(CC)
+ @echo CPP:' '$(CPP)
+ @echo CXX:' '$(CXX)
+ @echo
+ @echo AS:' '$(AS)
+ @echo AR:' '$(AR)
+ @echo LD:' '$(LD)
+ @echo NM:' '$(NM)
+ @echo OBJDUMP:' '$(OBJDUMP)
+ @echo RANLIB:' '$(RANLIB)
+ @echo SIZE:' '$(SIZE)
+ @echo STRIP:' '$(STRIP)
+ @echo STRINGS:' '$(STRINGS)
+ @echo
+ @echo ADDR2LINE:' '$(ADDR2LINE)
+ @echo COV:' '$(COV)
+ @echo CXXFILT' '$(CXXFILT)
+ @echo ELFEDIT:' '$(ELFEDIT)
+ @echo OBJCOPY:' '$(OBJCOPY)
+ @echo READELF:' '$(READELF)
+ @echo
+
+.display-flags:
+ @echo CFLAGS_COMMON:' '$(CFLAGS_COMMON)
+ @echo CFLAGS_DEBUG:' '$(CFLAGS_DEBUG)
+ @echo CFLAGS_VERSION:' '$(CFLAGS_VERSION)
+ @echo CFLAGS_CMDLINE:' '$(CFLAGS_CMDLINE)
+ @echo CFLAGS_CONFIG:' '$(CFLAGS_CONFIG)
+ @echo CFLAGS_SYSROOT:' '$(CFLAGS_SYSROOT)
+ @echo CFLAGS_OS:' '$(CFLAGS_OS)
+ @echo CFLAGS_SITE:' '$(CFLAGS_SITE)
+ @echo CFLAGS_PATH:' '$(CFLAGS_PATH)
+ @echo CFLAGS_STRICT:' '$(CFLAGS_STRICT)
+ @echo CFLAGS_UTIL:' '$(CFLAGS_UTIL)
+ @echo CFLAGS_LAST:' '$(CFLAGS_LAST)
+ @echo CFLAGS_ONCE:' '$(CFLAGS_ONCE)
+ @echo
+ @echo LDFLAGS_COMMON:' '$(LDFLAGS_COMMON)
+ @echo LDFLAGS_DEBUG:' '$(LDFLAGS_DEBUG)
+ @echo LDFLAGS_CMDLINE:' '$(LDFLAGS_CMDLINE)
+ @echo LDFLAGS_CONFIG:' '$(LDFLAGS_CONFIG)
+ @echo LDFLAGS_SYSROOT:' '$(LDFLAGS_SYSROOT)
+ @echo LDFLAGS_PATH:' '$(LDFLAGS_PATH)
+ @echo LDFLAGS_STRICT:' '$(LDFLAGS_STRICT)
+ @echo LDFLAGS_UTIL:' '$(LDFLAGS_UTIL)
+ @echo LDFLAGS_LAST:' '$(LDFLAGS_LAST)
+ @echo LDFLAGS_ONCE:' '$(LDFLAGS_ONCE)
+ @echo
+
+.display-pe:
+ @echo PE_SUBSYSTEM:' '$(PE_SUBSYSTEM)
+ @echo PE_IMAGE_BASE:' '$(PE_IMAGE_BASE)
+ @echo PE_CONFIG_DEFS:' '$(PE_CONFIG_DEFS)
+ @echo
+
+.display-elf:
+ @echo ELF_EH_FRAME:' '$(ELF_EH_FRAME)
+ @echo ELF_HASH_STYLE:' '$(ELF_HASH_STYLE)
+ @echo ELF_CONFIG_DEFS:' '$(ELF_CONFIG_DEFS)
+ @echo
+
+.display-dirs:
+ @echo PREFIX:' '$(PREFIX)
+ @echo EXEC_PREFIX:' '$(EXEC_PREFIX)
+ @echo BINDIR:' '$(BINDIR)
+ @echo SBINDIR:' '$(SBINDIR)
+ @echo LIBDIR:' '$(LIBDIR)
+ @echo INCLUDEDIR:' '$(INCLUDEDIR)
+ @echo OLDINCLUDEDIR:' '$(OLDINCLUDEDIR)
+ @echo MANDIR:' '$(MANDIR)
+ @echo DOCDIR:' '$(DOCDIR)
+ @echo LIBEXECDIR:' '$(LIBEXECDIR)
+ @echo
+
+.display-exdirs:
+ @echo SYSCONFDIR' '$(SYSCONFDIR)
+ @echo SHAREDSTATEDIR' '$(SHAREDSTATEDIR)
+ @echo LOCALSTATEDIR' '$(LOCALSTATEDIR)
+ @echo RUNSTATEDIR' '$(RUNSTATEDIR)
+ @echo DATAROOTDIR' '$(DATAROOTDIR)
+ @echo DATADIR' '$(DATADIR)
+ @echo INFODIR' '$(INFODIR)
+ @echo LOCALEDIR' '$(LOCALEDIR)
+ @echo HTMLDIR' '$(HTMLDIR)
+ @echo DVIDIR' '$(DVIDIR)
+ @echo PDFDIR' '$(PDFDIR)
+ @echo PSDIR' '$(PSDIR)
+
+.display-build:
+ @echo NATIVE_CC:' '$(NATIVE_CC)
+ @echo NATIVE_CPP:' '$(NATIVE_CPP)
+ @echo NATIVE_CXX:' '$(NATIVE_CXX)
+
+ @echo NATIVE_HOST:' '$(NATIVE_HOST)
+ @echo NATIVE_CFGHOST:' '$(NATIVE_CFGHOST)
+ @echo NATIVE_CFLAGS:' '$(NATIVE_CFLAGS)
+ @echo NATIVE_LDFLAGS:' '$(NATIVE_LDFLAGS)
+ @echo
+ @echo NATIVE_OS:' '$(NATIVE_OS)
+ @echo NATIVE_OS_BITS:' '$(NATIVE_OS_BITS)
+ @echo NATIVE_OS_UNDERSCORE:' '$(NATIVE_OS_UNDERSCORE)
+ @echo
+ @echo USER_CC:' '$(USER_CC)
+ @echo USER_CPP:' '$(USER_CPP)
+ @echo USER_CXX:' '$(USER_CXX)
+ @echo
+
+.display-config:
+ @echo ALL_SHARED:' '$(ALL_SHARED)
+ @echo ALL_STATIC:' '$(ALL_STATIC)
+ @echo DISABLE_FRONTEND:' '$(DISABLE_FRONTEND)
+ @echo DISABLE_SHARED:' '$(DISABLE_SHARED)
+ @echo DISABLE_STATIC:' '$(DISABLE_STATIC)
+ @echo
+ @echo USE_CUSTOM_CFGDEFS:' '$(USE_CUSTOM_CFGDEFS)
+ @echo USE_CUSTOM_USRDEFS:' '$(USE_CUSTOM_USRDEFS)
+
+.display-host:
+ @$(CC) $(CFLAGS) -dumpmachine
+
+.display-cc:
+ @echo $(CC)
+
+.display-cflags:
+ @echo $(CFLAGS)
+
+
+.PHONY: package-app \
+ all install shared static app \
+ shared-objs shared-lib \
+ shared-soname shared-solink \
+ package-shared-soname package-shared-solink \
+ static-objs static-lib \
+ default-app shared-app static-app \
+ install-shared install-static \
+ install-soname install-solink \
+ package-install-soname package-install-solink \
+ install-headers install-app \
+ install-headers-default install-headers-custom \
+ clean distclean clean-implib version \
+ .display .conf \
+ .display-project .display-env .display-tools .display-flags \
+ .display-pe .display-elf .display-dirs .display-build \
+ implib implib-ver implib-soname implib-solink \
+ install-implib install-implib-ver \
+ install-implib-soname install-implib-solink
diff --git a/config.project b/config.project
new file mode 100644
index 0000000..2d19645
--- /dev/null
+++ b/config.project
@@ -0,0 +1,57 @@
+# project
+mb_package=c
+mb_require_out_of_tree=no
+mb_custom_install_headers=no
+mb_avoid_version=no
+
+# config
+mb_all_static=
+mb_all_shared=
+mb_disable_frontend=yes
+mb_disable_static=yes
+mb_disable_shared=yes
+
+# custom config step
+mb_use_custom_cfgdefs=no
+mb_use_custom_cfgtest=no
+
+# pkgconfig
+mb_pkgname='mmglue'
+mb_pkgdesc='mmglue'
+mb_pkgusrc=
+mb_pkgrepo='git://midipix.org/mmglue'
+mb_pkgpsrc=
+mb_pkgdurl=
+mb_pkgdefs=
+mb_pkglibs=
+
+# ccenv
+mb_ccenv_create_log=
+mb_ccenv_skip_native=
+
+# switches
+mb_default_cflags_common="-std=c99 -D_XOPEN_SOURCE=700"
+mb_default_cflags_common="$mb_default_cflags_common -I\$(SOURCE_DIR)/src/internal"
+mb_default_cflags_common="$mb_default_cflags_common -I\$(SOURCE_DIR)/include"
+mb_default_cflags_common="$mb_default_cflags_common -Ibuild"
+
+mb_default_cflags_debug=
+mb_default_cflags_cmdline=
+mb_default_cflags_config=
+mb_default_cflags_sysroot=
+mb_default_cflags_path=
+mb_default_cflags_strict=
+mb_default_cflags_util=
+mb_default_cflags_last=
+mb_default_cflags_once=
+
+mb_default_ldflags_common="-Llib"
+mb_default_ldflags_debug=
+mb_default_ldflags_cmdline=
+mb_default_ldflags_config=
+mb_default_ldflags_sysroot=
+mb_default_ldflags_path=
+mb_default_ldflags_strict=
+mb_default_ldflags_util=
+mb_default_ldflags_last=
+mb_default_ldflags_once=
diff --git a/config.usage b/config.usage
new file mode 100644
index 0000000..f4c9446
--- /dev/null
+++ b/config.usage
@@ -0,0 +1,167 @@
+configure: common usage
+
+supported switches:
+-------------------
+ --help
+
+ --nickname
+ --program-prefix
+ --avoid-version
+ --source-dir
+
+ --pkgname
+ --pkgdesc
+ --pkgusrc
+ --pkgrepo
+ --pkgpsrc
+ --pkgdurl
+ --pkgdefs
+ --pkglibs
+
+ --prefix
+ --exec-prefix
+ --bindir
+ --sbindir
+ --libdir
+ --includedir
+ --oldincludedir
+ --mandir
+ --docdir
+ --libexecdir
+
+ --sysconfdir
+ --sharedstatedir
+ --localstatedir
+ --runstatedir
+ --datarootdir
+ --datadir
+ --infodir
+ --localedir
+ --htmldir
+ --dvidir
+ --pdfdir
+ --psdir
+
+ --build
+ --host
+ --cchost
+ --cfghost
+ --target
+ --arch
+ --compiler
+ --toolchain
+ --sysroot
+ --cross-compile
+ --shell
+ --debug
+
+ --strict
+ --ccstrict
+ --ldstrict
+
+ --all-static
+ --all-shared
+ --enable-static
+ --enable-shared
+ --disable-static
+ --disable-shared
+
+ --enable-app
+ --enable-frontend
+ --disable-app
+ --disable-frontend
+
+ --enable-dependency-tracking
+ --disable-dependency-tracking
+
+
+supported variables:
+--------------------
+ NICKNAME
+ SOURCE_DIR
+
+ PREFIX
+ EXEC_PREFIX
+ BINDIR
+ SBINDIR
+ LIBDIR
+ INCLUDEDIR
+ MANDIR
+ DOCDIR
+ LIBEXECDIR
+
+ SYSCONFDIR
+ SHAREDSTATEDIR
+ LOCALSTATEDIR
+ RUNSTATEDIR
+ DATAROOTDIR
+ DATADIR
+ INFODIR
+ LOCALEDIR
+ HTMLDIR
+ DVIDIR
+ PDFDIR
+ PSDIR
+
+ CC
+ CPP
+ CXX
+
+ BUILD
+ HOST
+ CCHOST
+ CFGHOST
+ TARGET
+ ARCH
+ COMPILER
+ TOOLCHAIN
+ SYSROOT
+ CROSS_COMPILE
+ SHELL
+
+ CFLAGS
+ CFLAGS_DEBUG
+ CFLAGS_COMMON
+ CFLAGS_CMDLINE
+ CFLAGS_CONFIG
+ CFLAGS_SYSROOT
+ CFLAGS_OS
+ CFLAGS_SITE
+ CFLAGS_PATH
+ CFLAGS_STRICT
+ CFLAGS_UTIL
+ CFLAGS_LAST
+ CFLAGS_ONCE
+
+ LDFLAGS
+ LDFLAGS_DEBUG
+ LDFLAGS_COMMON
+ LDFLAGS_CMDLINE
+ LDFLAGS_CONFIG
+ LDFLAGS_SYSROOT
+ LDFLAGS_PATH
+ LDFLAGS_STRICT
+ LDFLAGS_UTIL
+ LDFLAGS_LAST
+ LDFLAGS_ONCE
+
+ PE_SUBSYSTEM
+ PE_IMAGE_BASE
+ PE_CONFIG_DEFS
+
+ ELF_EH_FRAME
+ ELF_HASH_STYLE
+ ELF_CONFIG_DEFS
+
+ NATIVE_CC
+ NATIVE_CPP
+ NATIVE_CXX
+
+ NATIVE_HOST
+ NATIVE_CFGHOST
+ NATIVE_CFLAGS
+ NATIVE_LDFLAGS
+
+ NATIVE_OS
+ NATIVE_OS_BITS
+ NATIVE_OS_UNDERSCORE
diff --git a/configure b/configure
new file mode 100755
index 0000000..ba3985b
--- /dev/null
+++ b/configure
@@ -0,0 +1,752 @@
+#!/bin/sh
+
+set -eu
+
+trap config_failure 1 2 EXIT
+
+usage()
+{
+ cat "$mb_project_dir"/config.usage
+
+ if [ _$mb_use_custom_cfgdefs = _yes ]; then
+ printf '\n\n%s%s\n' \
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" \
+ "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
+
+ printf '%s%s\n' \
+ "| Listed above are configure's common switches " \
+ "and environment variables. |"
+
+ printf '%s%s\n' \
+ "| Found below are project-specific variables " \
+ "and other customization options. |"
+
+ printf '%s%s\n\n\n' \
+ " ___________________________________________" \
+ "__________________________________"
+
+ cat "$mb_project_dir"/project/config/cfgdefs.usage
+ fi
+
+ exit 0
+}
+
+error_msg()
+{
+ echo "$@" >&2
+}
+
+warning_msg()
+{
+ echo "$@" >&2
+}
+
+
+init_vars()
+{
+ mb_project_dir=$(cd "$(dirname $0)" ; pwd)
+ mb_pwd=$(pwd)
+
+ mb_custom_cfgdefs_args=''
+ mb_custom_cfgdefs_space=''
+
+ sfrt_impl_dir=$mb_project_dir/sofort
+ sfrt_config_dir=$sfrt_impl_dir/config
+ sfrt_core_dir=$sfrt_impl_dir/core
+ sfrt_config_vars=$sfrt_config_dir/config.vars
+ sfrt_flag_vars=$sfrt_config_dir/flag.vars
+ sfrt_cfgdefs_in=$sfrt_config_dir/cfgdefs.in
+
+ mb_make_vars=$(cat $sfrt_config_vars \
+ | grep -v -e '^#' -e '^$' | tr '[:lower:]' '[:upper:]')
+
+ mb_impl_vars=$(cat $sfrt_config_vars \
+ | grep -v -e '^#' -e '^$' | sed 's/^/mb_/g')
+
+ mb_proj_vars=$(cat $sfrt_config_vars \
+ | grep -v -e '^#' -e '^$' | sed 's/^/mb_default_/g')
+
+ mb_flag_vars=$(cat $sfrt_flag_vars \
+ | grep -v -e '^#' -e '^$')
+
+ mb_vars="$mb_make_vars $mb_impl_vars $mb_proj_vars $mb_flag_vars"
+
+ for mb_var in $mb_vars ; do
+ mb_expr=$mb_var='${'$mb_var':-}'
+ eval "$mb_expr"
+ done
+
+ # ccenv
+ . $mb_project_dir/sofort/ccenv/ccenv.sh
+
+ if ! [ -L ./ccenv ]; then
+ if [ -d ./ccenv ]; then
+ rm -f ./ccenv/host.mk
+ rm -f ./ccenv/native.mk
+ rmdir ./ccenv
+ fi
+ fi
+
+ # config.project
+ if [ -z "$mb_config" ]; then
+ . $mb_project_dir/config.project
+ else
+ . "$mb_config"
+ fi
+
+ # project-specific config definitions
+ if [ _$mb_use_custom_cfgdefs = _yes ]; then
+ cat $sfrt_cfgdefs_in > cfgdefs.mk
+ else
+ printf '%s %s\n\n' \
+ '# this project does not include' \
+ 'a custom config step.' \
+ > cfgdefs.mk
+ cat $sfrt_cfgdefs_in >> cfgdefs.mk
+
+ if [ -f $mb_project_dir/project/cfgdefs.in ]; then
+ cat $mb_project_dir/project/cfgdefs.in >> cfgdefs.mk
+ fi
+ fi
+
+ # user build-time overrides
+ touch usrdefs.mk
+
+ # project
+ mb_nickname=$NICKNAME
+ mb_source_dir=$SOURCE_DIR
+
+ # dirs
+ mb_prefix=$PREFIX
+ mb_exec_prefix=$EXEC_PREFIX
+ mb_bindir=$BINDIR
+ mb_sbindir=$SBINDIR
+ mb_libdir=$LIBDIR
+ mb_includedir=$INCLUDEDIR
+ mb_oldincludedir=$OLDINCLUDEDIR
+ mb_mandir=$MANDIR
+ mb_docdir=$DOCDIR
+ mb_libexecdir=$LIBEXECDIR
+
+ mb_sysconfdir=$SYSCONFDIR
+ mb_sharedstatedir=$SHAREDSTATEDIR
+ mb_localstatedir=$LOCALSTATEDIR
+ mb_runstatedir=$RUNSTATEDIR
+ mb_datarootdir=$DATAROOTDIR
+ mb_datadir=$DATADIR
+ mb_infodir=$INFODIR
+ mb_localedir=$LOCALEDIR
+ mb_htmldir=$HTMLDIR
+ mb_dvidir=$DVIDIR
+ mb_pdfdir=$PDFDIR
+ mb_psdir=$PSDIR
+
+
+ # build
+ mb_build=$BUILD
+ mb_host=$HOST
+ mb_cchost=$CCHOST
+ mb_cfghost=$CFGHOST
+ mb_target=$TARGET
+ mb_arch=$ARCH
+ mb_compiler=$COMPILER
+ mb_toolchain=$TOOLCHAIN
+ mb_sysroot=$SYSROOT
+ mb_cross_compile=$CROSS_COMPILE
+ mb_shell=$SHELL
+
+ # switches
+ mb_cflags=$CFLAGS
+ mb_cflags_debug=$CFLAGS_DEBUG
+ mb_cflags_common=$CFLAGS_COMMON
+ mb_cflags_cmdline=$CFLAGS_CMDLINE
+ mb_cflags_config=$CFLAGS_CONFIG
+ mb_cflags_sysroot=$CFLAGS_SYSROOT
+ mb_cflags_os=$CFLAGS_OS
+ mb_cflags_site=$CFLAGS_SITE
+ mb_cflags_path=$CFLAGS_PATH
+ mb_cflags_strict=$CFLAGS_STRICT
+ mb_cflags_util=$CFLAGS_UTIL
+ mb_cflags_last=$CFLAGS_LAST
+ mb_cflags_once=$CFLAGS_ONCE
+
+ mb_ldflags=$LDFLAGS
+ mb_ldflags_debug=$LDFLAGS_DEBUG
+ mb_ldflags_common=$LDFLAGS_COMMON
+ mb_ldflags_cmdline=$LDFLAGS_CMDLINE
+ mb_ldflags_config=$LDFLAGS_CONFIG
+ mb_ldflags_sysroot=$LDFLAGS_SYSROOT
+ mb_ldflags_path=$LDFLAGS_PATH
+ mb_ldflags_strict=$LDFLAGS_STRICT
+ mb_ldflags_util=$LDFLAGS_UTIL
+ mb_ldflags_last=$LDFLAGS_LAST
+ mb_ldflags_once=$LDFLAGS_ONCE
+
+ mb_pe_subsystem=$PE_SUBSYSTEM
+ mb_pe_image_base=$PE_IMAGE_BASE
+ mb_pe_config_defs=$PE_CONFIG_DEFS
+
+ mb_elf_eh_frame=$ELF_EH_FRAME
+ mb_elf_hash_style=$ELF_HASH_STYLE
+ mb_elf_config_defs=$ELF_CONFIG_DEFS
+
+ # overrides
+ mb_user_cc=$CC
+ mb_user_cpp=$CPP
+ mb_user_cxx=$CXX
+
+ mb_native_cc=$NATIVE_CC
+ mb_native_cpp=$NATIVE_CPP
+ mb_native_cxx=$NATIVE_CXX
+
+ mb_native_host=$NATIVE_HOST
+ mb_native_cfghost=$NATIVE_CFGHOST
+ mb_native_cflags=$NATIVE_CFLAGS
+ mb_native_ldflags=$NATIVE_LDFLAGS
+}
+
+
+verify_build_directory()
+{
+ if [ "$mb_project_dir" = "$mb_pwd" ]; then
+ if [ _$mb_require_out_of_tree = _yes ]; then
+ error_msg "$mb_package: out-of-tree builds are required."
+ error_msg "please invoke configure again from a clean build directory."
+ exit 1
+ else
+ mb_project_dir='.'
+ fi
+ fi
+
+ rm -f Makefile Makefile.host Makefile.tmp Makefile.failed
+}
+
+
+verify_source_directory()
+{
+ if [ -z "$mb_source_dir" ]; then
+ if [ _$mb_require_source_dir = _yes ]; then
+ error_msg "$mb_package: specifying an external source directory is required."
+ error_msg "you can set the source directory either via --source-dir=<path>,"
+ error_msg "or by setting the SOURCE_DIR variable."
+ exit 1
+ fi
+ fi
+}
+
+
+common_defaults()
+{
+ # git
+ if [ -n "$mb_source_dir" ]; then
+ if [ -d "$mb_source_dir/.git" ]; then
+ mb_git_reference_index="\$(SOURCE_DIR)/.git/index"
+ fi
+ elif [ -d "$mb_project_dir/.git" ]; then
+ mb_git_reference_index="\$(PROJECT_DIR)/.git/index"
+ fi
+
+ # project
+ [ -z "$mb_nickname" ] && mb_nickname=$mb_package
+ [ -z "$mb_source_dir" ] && mb_source_dir=$mb_project_dir
+ [ -z "$mb_avoid_version" ] && mb_avoid_version='no'
+
+ # pkgconfig
+ [ -z "$mb_pkgname" ] && mb_pkgname="$mb_default_pkgname"
+ [ -z "$mb_pkgdesc" ] && mb_pkgdesc="$mb_default_pkgdesc"
+ [ -z "$mb_pkgusrc" ] && mb_pkgusrc="$mb_default_pkgusrc"
+ [ -z "$mb_pkgrepo" ] && mb_pkgrepo="$mb_default_pkgrepo"
+ [ -z "$mb_pkgpsrc" ] && mb_pkgpsrc="$mb_default_pkgpsrc"
+ [ -z "$mb_pkgdurl" ] && mb_pkgdurl="$mb_default_pkgdurl"
+ [ -z "$mb_pkgdefs" ] && mb_pkgdefs="$mb_default_pkgdefs"
+ [ -z "$mb_pkglibs" ] && mb_pkglibs="$mb_default_pkglibs"
+
+ # dirs
+ [ -z "$mb_prefix" ] && [ -z "$mb_prefix_set" ] \
+ && mb_prefix='/usr/local'
+
+ [ -z "$mb_exec_prefix" ] && [ -z "$mb_exec_prefix_set" ] \
+ && mb_exec_prefix=$mb_prefix
+
+ [ -z "$mb_bindir" ] && [ -z "$mb_bindir_set" ] \
+ && [ -z "$mb_bindir_basename" ] \
+ && mb_bindir=$mb_exec_prefix/bin
+
+ [ -z "$mb_bindir" ] && [ -z "$mb_bindir_set" ] \
+ && mb_bindir=$mb_exec_prefix/$mb_bindir_basename
+
+ [ -z "$mb_sbindir" ] && mb_sbindir=$mb_exec_prefix/sbin
+ [ -z "$mb_libdir" ] && mb_libdir=$mb_exec_prefix/lib
+ [ -z "$mb_includedir" ] && mb_includedir=$mb_prefix/include
+ [ -z "$mb_oldincludedir" ] && mb_oldincludedir=$mb_prefix/include
+ [ -z "$mb_datarootdir" ] && mb_datarootdir=$mb_prefix/share
+ [ -z "$mb_mandir" ] && mb_mandir=$mb_datarootdir/man
+ [ -z "$mb_docdir" ] && mb_docdir=$mb_datarootdir/doc
+ [ -z "$mb_libexecdir" ] && mb_libexecdir=$mb_exec_prefix/libexec
+
+ [ -z "$mb_sysconfdir" ] && mb_sysconfdir=$mb_exec_prefix/etc
+ [ -z "$mb_sharedstatedir" ] && mb_sharedstatedir=$mb_prefix/com
+ [ -z "$mb_localstatedir" ] && mb_localstatedir=$mb_prefix/var
+ [ -z "$mb_runstatedir" ] && mb_runstatedir=$mb_localstatedir/run
+ [ -z "$mb_datarootdir" ] && mb_datarootdir=$mb_prefix/share
+ [ -z "$mb_datadir" ] && mb_datadir=$mb_datarootdir
+ [ -z "$mb_infodir" ] && mb_infodir=$mb_datarootdir/info
+ [ -z "$mb_localedir" ] && mb_localedir=$mb_datarootdir/locale
+ [ -z "$mb_htmldir" ] && mb_htmldir=$mb_docdir
+ [ -z "$mb_dvidir" ] && mb_dvidir=$mb_docdir
+ [ -z "$mb_pdfdir" ] && mb_pdfdir=$mb_docdir
+ [ -z "$mb_psdir" ] && mb_psdir=$mb_docdir
+
+ # switches
+ [ -z "$mb_cflags_debug" ] && mb_cflags_debug=$mb_default_cflags_debug
+ [ -z "$mb_cflags_common" ] && mb_cflags_common=$mb_default_cflags_common
+ [ -z "$mb_cflags_cmdline" ] && mb_cflags_cmdline=$mb_default_cflags_cmdline
+ [ -z "$mb_cflags_config" ] && mb_cflags_config=$mb_default_cflags_config
+ [ -z "$mb_cflags_sysroot" ] && mb_cflags_sysroot=$mb_default_cflags_sysroot
+ [ -z "$mb_cflags_os" ] && mb_cflags_os=$mb_default_cflags_os
+ [ -z "$mb_cflags_site" ] && mb_cflags_site=$mb_default_cflags_site
+ [ -z "$mb_cflags_path" ] && mb_cflags_path=$mb_default_cflags_path
+ [ -z "$mb_cflags_strict" ] && mb_cflags_strict=$mb_default_cflags_strict
+ [ -z "$mb_cflags_util" ] && mb_cflags_util=$mb_default_cflags_util
+ [ -z "$mb_cflags_last" ] && mb_cflags_last=$mb_default_cflags_last
+ [ -z "$mb_cflags_once" ] && mb_cflags_once=$mb_default_cflags_once
+
+ [ -z "$mb_ldflags_debug" ] && mb_ldflags_debug=$mb_default_ldflags_debug
+ [ -z "$mb_ldflags_common" ] && mb_ldflags_common=$mb_default_ldflags_common
+ [ -z "$mb_ldflags_cmdline" ] && mb_ldflags_cmdline=$mb_default_ldflags_cmdline
+ [ -z "$mb_ldflags_config" ] && mb_ldflags_config=$mb_default_ldflags_config
+ [ -z "$mb_ldflags_sysroot" ] && mb_ldflags_sysroot=$mb_default_ldflags_sysroot
+ [ -z "$mb_ldflags_path" ] && mb_ldflags_path=$mb_default_ldflags_path
+ [ -z "$mb_ldflags_strict" ] && mb_ldflags_strict=$mb_default_ldflags_strict
+ [ -z "$mb_ldflags_util" ] && mb_ldflags_util=$mb_default_ldflags_util
+ [ -z "$mb_ldflags_last" ] && mb_ldflags_last=$mb_default_ldflags_last
+ [ -z "$mb_ldflags_once" ] && mb_ldflags_once=$mb_default_ldflags_once
+
+ # config
+ [ -z "$mb_all_static" ] && mb_all_static='no'
+ [ -z "$mb_all_shared" ] && mb_all_shared='no'
+ [ -z "$mb_disable_frontend" ] && mb_disable_frontend='no'
+ [ -z "$mb_disable_static" ] && mb_disable_static='no'
+ [ -z "$mb_disable_shared" ] && mb_disable_shared='no'
+
+ # host/target
+ [ -z "$mb_host" ] && mb_host=$mb_target
+ [ -z "$mb_target" ] && mb_target=$mb_host
+
+ # sysroot
+ if [ -n "$mb_sysroot" ]; then
+ if [ -z "$mb_cflags_sysroot" ]; then
+ mb_cflags_sysroot="--sysroot=$mb_sysroot"
+ fi
+
+ if [ -z "$mb_ldflags_sysroot" ]; then
+ mb_ldflags_sysroot="--sysroot=$mb_sysroot"
+ fi
+ fi
+
+ # debug
+ if [ _$mb_debug = _yes ]; then
+ if [ -z "$mb_cflags_debug" ]; then
+ mb_cflags_debug='-g3 -O0'
+ fi
+ fi
+
+ # inherited cflags & ldflags
+ mb_cflags_cmdline="$mb_cflags_cmdline $mb_cflags"
+ mb_ldflags_cmdline="$mb_ldflags_cmdline $mb_ldflags"
+}
+
+
+config_flags()
+{
+ mb_ldflags_tmp=" $mb_ldflags "
+ mb_ldflags_libs=$(echo "$mb_ldflags_tmp" | sed 's/ -static / /g')
+
+ if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then
+ mb_ldflags="$mb_ldflags_libs"
+ mb_ldflags_util="$mb_ldflags_util -static"
+ fi
+
+ # ccstrict
+ if [ _$mb_ccstrict = _yes ]; then
+ mb_cflags_strict='-Wall -Werror -Wextra -Wundef'
+ fi
+
+ # ldstrict
+ if [ _$mb_ldstrict = _yes ]; then
+ mb_ldflags_strict='-Wl,--no-undefined'
+ fi
+}
+
+
+config_copy()
+{
+ mb_vars=$(cut -d'=' -f1 $sfrt_config_vars \
+ | grep -v '^#')
+
+ mb_sed_substs=" \
+ $(for __var in $mb_vars; do \
+ printf '%s"$%s"%s' "-e 's^@$__var@^'" \
+ "mb_$__var" "'^g' "; \
+ done)"
+
+ eval sed $mb_sed_substs \
+ $mb_project_dir/Makefile.in \
+ | sed -e 's/[ \t]*$//g' \
+ > $mb_pwd/Makefile.tmp
+}
+
+
+config_ccenv()
+{
+ mkdir -p ./ccenv
+ touch ./ccenv/host.mk
+ touch ./ccenv/native.mk
+
+ ccenv_set_host_variables
+ ccenv_set_native_variables
+
+ config_copy
+}
+
+config_custom()
+{
+ if [ _$mb_use_custom_cfgdefs = _yes ]; then
+ eval . $mb_project_dir/project/config/cfgdefs.sh \
+ "$mb_custom_cfgdefs_args"
+ config_copy
+ fi
+
+ if [ _$mb_use_custom_usrdefs = _yes ]; then
+ . $mb_project_dir/project/usrdefs.sh
+ fi
+}
+
+
+config_cfghost()
+{
+ if [ -z "$mb_cfghost" ]; then
+ mb_cfghost=$mb_cchost
+ fi
+
+ sed -e 's^@cchost@^'"$mb_cchost"'^g' \
+ -e 's^@cfghost@^'"$mb_cfghost"'^g' \
+ $mb_pwd/Makefile.tmp > $mb_pwd/Makefile.host
+
+ rm $mb_pwd/Makefile.tmp
+ mv $mb_pwd/Makefile.host $mb_pwd/Makefile
+}
+
+
+config_host()
+{
+ make -s host.tag && return 0
+
+ error_msg "configure was able to generate a Makefile for the selected host,"
+ error_msg "however the host-targeting compiler was found to be missing"
+ error_msg "at least one of the required headers or features."
+ exit 2
+}
+
+
+config_status()
+{
+ printf "\n\n"
+ make .display
+ printf "\nconfiguration completed successfully.\n\n"
+}
+
+
+config_failure()
+{
+ if [ -f Makefile ]; then
+ mb_error='failed to use the generated Makefile.'
+ printf '\n%s: error: %s\n' "${0}" "$mb_error" >&2
+ mv Makefile Makefile.failed
+ fi
+
+ exit 2
+}
+
+
+config_success()
+{
+ trap '' EXIT
+ exit 0
+}
+
+
+# one: init
+init_vars
+verify_build_directory
+
+
+# two: args
+for arg ; do
+ case "$arg" in
+ --help)
+ usage
+ ;;
+ --help=ccenv)
+ ccenv_usage
+ ;;
+
+ # ccenv
+ --cross-compile=*)
+ mb_cross_compile=${arg#*=}
+ ;;
+ --compiler=*)
+ mb_compiler=${arg#*=}
+ ;;
+ --toolchain=*)
+ mb_toolchain=${arg#*=}
+ ;;
+ --zealous)
+ mb_agnostic=yes
+ mb_zealous=
+ ;;
+ --zealous=*)
+ mb_zealous=${arg#*=}
+ ;;
+ --ccenv=*)
+ mb_ccenv=${arg#*=}
+ ;;
+
+ # dirs
+ --prefix=*)
+ mb_prefix_set=yes
+ mb_prefix=${arg#*=}
+ ;;
+ --exec-prefix=*)
+ mb_exec_prefix_set=yes
+ mb_exec_prefix=${arg#*=}
+ ;;
+ --bindir=*)
+ mb_bindir_set=yes
+ mb_bindir=${arg#*=}
+ ;;
+ --sbindir=*)
+ mb_sbindir=${arg#*=}
+ ;;
+ --libdir=*)
+ mb_libdir=${arg#*=}
+ ;;
+ --includedir=*)
+ mb_includedir=${arg#*=}
+ ;;
+ --oldincludedir=*)
+ mb_oldincludedir=${arg#*=}
+ ;;
+ --mandir=*)
+ mb_mandir=${arg#*=}
+ ;;
+ --libexecdir=*)
+ mb_libexecdir=${arg#*=}
+ ;;
+
+
+ --sysconfdir=*)
+ mb_sysconfdir=${arg#*=}
+ ;;
+ --sharedstatedir=*)
+ mb_sharedstatedir=${arg#*=}
+ ;;
+ --localstatedir=*)
+ mb_localstatedir=${arg#*=}
+ ;;
+ --runstatedir=*)
+ mb_runstatedir=${arg#*=}
+ ;;
+ --datarootdir=*)
+ mb_datarootdir=${arg#*=}
+ ;;
+ --datadir=*)
+ mb_datadir=${arg#*=}
+ ;;
+ --infodir=*)
+ mb_infodir=${arg#*=}
+ ;;
+ --localedir=*)
+ mb_localedir=${arg#*=}
+ ;;
+ --htmldir=*)
+ mb_htmldir=${arg#*=}
+ ;;
+ --dvidir=*)
+ mb_dvidir=${arg#*=}
+ ;;
+ --pdfdir=*)
+ mb_pdfdir=${arg#*=}
+ ;;
+ --psdir=*)
+ mb_psdir=${arg#*=}
+ ;;
+
+
+ # build
+ --build=*)
+ mb_build=${arg#*=}
+ ;;
+ --host=*)
+ mb_host=${arg#*=}
+ ;;
+ --cchost=*)
+ mb_cchost=${arg#*=}
+ ;;
+ --cfghost=*)
+ mb_cfghost=${arg#*=}
+ ;;
+ --target=*)
+ mb_target=${arg#*=}
+ ;;
+ --arch=*)
+ mb_arch=${arg#*=}
+ ;;
+ --sysroot=*)
+ mb_sysroot=${arg#*=}
+ ;;
+ --shell=*)
+ mb_shell=${arg#*=}
+ ;;
+ --debug)
+ mb_debug=yes
+ ;;
+
+ # config
+ --all-static)
+ mb_all_static=yes
+ ;;
+ --all-shared)
+ mb_all_shared=yes
+ ;;
+ --disable-frontend)
+ mb_disable_frontend=yes
+ ;;
+ --disable-app)
+ mb_disable_frontend=yes
+ ;;
+ --enable-frontend)
+ mb_disable_frontend='no'
+ ;;
+ --enable-app)
+ mb_disable_frontend='no'
+ ;;
+ --disable-static)
+ mb_disable_static=yes
+ ;;
+ --disable-shared)
+ mb_disable_shared=yes
+ ;;
+ --enable-static)
+ mb_disable_static='no'
+ ;;
+ --enable-shared)
+ mb_disable_shared='no'
+ ;;
+
+ # convenience
+ --strict)
+ mb_ccstrict=yes
+ mb_ldstrict=yes
+ ;;
+ --ccstrict)
+ mb_ccstrict=yes
+ ;;
+ --ldstrict)
+ mb_ldstrict=yes
+ ;;
+
+ # project
+ --nickname=*)
+ mb_nickname=${arg#*=}
+ ;;
+ --program-prefix=*)
+ mb_program_prefix=${arg#*=}
+ ;;
+ --avoid-version)
+ mb_avoid_version=yes
+ ;;
+ --source-dir=*)
+ mb_source_dir=${arg#*=}
+ ;;
+
+ # pkgconfig
+ --pkgname=*)
+ mb_pkgname=${arg#*=}
+ ;;
+
+ --pkgdesc=*)
+ mb_pkgdesc=${arg#*=}
+ ;;
+
+ --pkgusrc=*)
+ mb_pkgusrc=${arg#*=}
+ ;;
+
+ --pkgrepo=*)
+ mb_pkgrepo=${arg#*=}
+ ;;
+
+ --pkgpsrc=*)
+ mb_pkgpsrc=${arg#*=}
+ ;;
+
+ --pkgdurl=*)
+ mb_pkgdurl=${arg#*=}
+ ;;
+
+ --pkgdefs=*)
+ mb_pkgdefs=${arg#*=}
+ ;;
+
+ --pkglibs=*)
+ mb_pkglibs=${arg#*=}
+ ;;
+
+ # compatibility
+ --enable-dependency-tracking)
+ ;;
+ --disable-dependency-tracking)
+ ;;
+
+ *)
+ if [ _$mb_use_custom_cfgdefs = _yes ]; then
+ mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
+ mb_escaped_arg="$mb_custom_cfgdefs_space$mb_escaped_arg"
+ mb_custom_cfgdefs_args="$mb_custom_cfgdefs_args$mb_escaped_arg"
+ mb_custom_cfgdefs_space=' '
+ else
+ error_msg ${arg#}: "unsupported config argument."
+ exit 2
+ fi
+ ;;
+ esac
+done
+
+
+
+# three: validation
+verify_source_directory
+
+if ! [ -z "$mb_program_prefix" ]; then
+ error_msg "--program-prefix is not yet fully support (must be null)."
+fi
+
+
+
+# four: defaults
+common_defaults
+
+
+# five: config
+config_flags
+config_copy
+config_ccenv
+config_custom
+config_cfghost
+config_host
+config_status
+
+
+# all done
+config_success
diff --git a/project/arch.mk b/project/arch.mk
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/project/arch.mk
diff --git a/project/common.mk b/project/common.mk
new file mode 100644
index 0000000..4b72987
--- /dev/null
+++ b/project/common.mk
@@ -0,0 +1,7 @@
+API_SRCS = \
+
+INTERNAL_SRCS = \
+
+APP_SRCS = \
+
+COMMON_SRCS = $(API_SRCS) $(INTERNAL_SRCS)
diff --git a/project/depends.mk b/project/depends.mk
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/project/depends.mk
diff --git a/project/extras.mk b/project/extras.mk
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/project/extras.mk
diff --git a/project/headers.mk b/project/headers.mk
new file mode 100644
index 0000000..9d50ee3
--- /dev/null
+++ b/project/headers.mk
@@ -0,0 +1,5 @@
+API_HEADERS = \
+
+INTERNAL_HEADERS = \
+
+ALL_HEADERS = $(API_HEADERS) $(INTERNAL_HEADERS)
diff --git a/project/osforce.mk b/project/osforce.mk
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/project/osforce.mk
diff --git a/project/overrides.mk b/project/overrides.mk
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/project/overrides.mk
diff --git a/project/tagver.mk b/project/tagver.mk
new file mode 100644
index 0000000..6a5d8d6
--- /dev/null
+++ b/project/tagver.mk
@@ -0,0 +1,5 @@
+VER_NAMESPACE =
+
+VER_MAJOR = 0
+VER_MINOR = 0
+VER_PATCH = 0
diff --git a/project/tree.mk b/project/tree.mk
new file mode 100644
index 0000000..20f0861
--- /dev/null
+++ b/project/tree.mk
@@ -0,0 +1,3 @@
+tree.tag:
+ mkdir -p src
+ touch tree.tag
diff --git a/sofort/ccenv/ccenv.in b/sofort/ccenv/ccenv.in
new file mode 100644
index 0000000..531a7dd
--- /dev/null
+++ b/sofort/ccenv/ccenv.in
@@ -0,0 +1,85 @@
+# @ccenv_cfgtype@ system flavor
+OS = @ccenv_os@
+OS_SEMANTICS = @ccenv_os_semantics@
+
+OS_DSO_EXRULES = @ccenv_os_dso_exrules@
+OS_DSO_LINKAGE = @ccenv_os_dso_linkage@
+
+OS_APP_PREFIX = @ccenv_os_app_prefix@
+OS_APP_SUFFIX = @ccenv_os_app_suffix@
+
+OS_LIB_PREFIX = @ccenv_os_lib_prefix@
+OS_LIB_SUFFIX = @ccenv_os_lib_suffix@
+
+OS_IMPLIB_EXT = @ccenv_os_implib_ext@
+OS_LIBDEF_EXT = @ccenv_os_libdef_ext@
+
+OS_ARCHIVE_EXT = @ccenv_os_archive_ext@
+OS_SONAME = @ccenv_os_soname@
+
+OS_LIB_PREFIXED_SUFFIX = @ccenv_os_lib_prefixed_suffix@
+OS_LIB_SUFFIXED_SUFFIX = @ccenv_os_lib_suffixed_suffix@
+
+# @ccenv_cfgtype@ characteristics
+CC_HOST = @ccenv_cc_host@
+CC_BITS = @ccenv_cc_bits@
+
+CC_BINFMT = @ccenv_cc_binfmt@
+CC_UNDERSCORE = @ccenv_cc_underscore@
+
+CC_ARCH_BFD = @ccenv_cc_arch_bfd@
+CC_ARCH_LLVM = @ccenv_cc_arch_llvm@
+
+# incompatible tool variants
+AS_ASM = @ccenv_as_asm@
+AS_LL = @ccenv_as_ll@
+AS_MC = @ccenv_as_mc@
+
+LD_BFD = @ccenv_ld_bfd@
+LD_GOLD = @ccenv_ld_gold@
+LD_LLD = @ccenv_ld_lld@
+
+OBJDUMP_BFD = @ccenv_objdump_bfd@
+OBJDUMP_LLVM = @ccenv_objdump_llvm@
+
+READELF_BFD = @ccenv_readelf_bfd@
+READELF_LLVM = @ccenv_readelf_llvm@
+
+# @ccenv_cfgtype@ primary tools
+CC = @ccenv_cc@
+CPP = @ccenv_cpp@
+CXX = @ccenv_cxx@
+
+AR = @ccenv_ar@
+NM = @ccenv_nm@
+OBJDUMP = @ccenv_objdump@
+RANLIB = @ccenv_ranlib@
+SIZE = @ccenv_size@
+STRIP = @ccenv_strip@
+STRINGS = @ccenv_strings@
+
+ADDR2LINE = @ccenv_addr2line@
+COV = @ccenv_cov@
+CXXFILT = @ccenv_cxxfilt@
+OBJCOPY = @ccenv_objcopy@
+
+ELFEDIT = @ccenv_elfedit@
+READELF = @ccenv_readelf@
+READOBJ = @ccenv_readobj@
+
+PERK = @ccenv_perk@
+MDSO = @ccenv_mdso@
+DLLTOOL = @ccenv_dlltool@
+
+WINDMC = @ccenv_windmc@
+WINDRC = @ccenv_windrc@
+
+# @ccenv_cfgtype@ secondary tools
+# note: the direct use of $(@ccenv_makevar_prefix@LD) is highly discouraged
+AS = @ccenv_as@
+LD = @ccenv_ld@
+
+# @ccenv_cfgtype@ cflags
+CFLAGS_OS += @ccenv_cflags_os@
+CFLAGS_PIC += @ccenv_cflags_pic@
+
diff --git a/sofort/ccenv/ccenv.sh b/sofort/ccenv/ccenv.sh
new file mode 100644
index 0000000..d6876c7
--- /dev/null
+++ b/sofort/ccenv/ccenv.sh
@@ -0,0 +1,1067 @@
+# ccenv.sh: sofort's tool-finding bits,
+# invoked from within the project-agnostic configure script.
+
+# invocation and names of binary tools:
+# agnostic names (ar, nm, objdump, ...);
+# target-prefixed agnostic names (x86_64-nt64-midipix-ar, ...);
+# branded names (llvm-ar, llvm-nm, llvm-objdump, ...);
+# target-prefixed branded names (x86_64-linux-gnu-gcc-ar, ...);
+# target-specifying branded tools (llvm-ar --target=x86_64-linux, ...).
+
+# cross-compilation: default search order:
+# target-prefixed agnostic tools;
+# target-prefixed branded tools, starting with the prefix
+# most commonly associated with the selected compiler (that is,
+# ``gcc'' when using gcc, and ``llvm'' when using clang);
+# target-speficying branded tools, starting once again with the
+# prefix most commonly associated with the selected compiler.
+
+# internal variables of interest:
+# ccenv_cfgtype: the type of host being tested (host/native)
+# ccenv_cfgfile: the configuration file for the host being tested
+# ccenv_cflags: the comprehensive cflags for the host being tested
+# ccenv_cchost: the host being tested, as reported by -dumpmachine
+
+
+ccenv_usage()
+{
+ cat "$mb_project_dir"/sofort/ccenv/ccenv.usage
+ exit 0
+}
+
+
+ccenv_newline()
+{
+ printf '\n' >> "$ccenv_cfgfile"
+}
+
+
+ccenv_comment()
+{
+ ccenv_internal_str='#'
+
+ for ccenv_internal_arg ; do
+ ccenv_internal_str="$ccenv_internal_str $ccenv_internal_arg"
+ done
+
+ printf '%s\n' "$ccenv_internal_str" >> "$ccenv_cfgfile"
+}
+
+
+ccenv_find_tool()
+{
+ if [ -z "$ccenv_prefixes" ]; then
+ for ccenv_tool in $ccenv_candidates; do
+ command -v "$ccenv_tool" > /dev/null && return 0
+ done
+
+ ccenv_tool=false
+
+ return 0
+ fi
+
+ for ccenv_prefix in $ccenv_prefixes; do
+ for ccenv_candidate in $ccenv_candidates; do
+ ccenv_tool="$ccenv_prefix$ccenv_candidate"
+ command -v "$ccenv_tool" > /dev/null && return 0
+ done
+ done
+
+ for ccenv_tool in $ccenv_candidates; do
+ command -v "$ccenv_tool" > /dev/null && return 0
+ done
+
+ ccenv_tool=false
+
+ return 0
+}
+
+
+ccenv_set_primary_tools()
+{
+ ccenv_core_tools="ar nm objdump ranlib size strip strings objcopy"
+ ccenv_hack_tools="addr2line cov elfedit readelf readobj"
+ ccenv_peep_tools="perk mdso dlltool windmc windres"
+
+ for __tool in $ccenv_core_tools $ccenv_hack_tools $ccenv_peep_tools; do
+ if [ -n "$mb_agnostic" ]; then
+ ccenv_candidates=" $__tool"
+
+ elif [ -n "$mb_zealous" ]; then
+ ccenv_candidates="$mb_zealous-$__tool"
+
+ elif [ "$mb_toolchain" = 'gcc' ]; then
+ ccenv_candidates="gcc-$__tool"
+ ccenv_candidates="$ccenv_candidates $__tool"
+ ccenv_candidates="$ccenv_candidates llvm-$__tool"
+
+ elif [ "$mb_toolchain" = 'llvm' ]; then
+ ccenv_candidates="llvm-$__tool"
+ ccenv_candidates="$ccenv_candidates $__tool"
+ ccenv_candidates="$ccenv_candidates gcc-$__tool"
+
+ elif [ -n "$mb_toolchain" ]; then
+ ccenv_candidates="$mb_toolchain-$__tool"
+ ccenv_candidates="$ccenv_candidates $__tool"
+ ccenv_candidates="$ccenv_candidates gcc-$__tool"
+ ccenv_candidates="$ccenv_candidates llvm-$__tool"
+
+ else
+ ccenv_candidates="$__tool"
+ ccenv_candidates="$ccenv_candidates gcc-$__tool"
+ ccenv_candidates="$ccenv_candidates llvm-$__tool"
+ fi
+
+ if [ "$ccenv_cfgtype" = 'host' ]; then
+ ccenv_var_prefix='mb_'
+ else
+ ccenv_var_prefix='mb_native_'
+ fi
+
+ ccenv_var_name=$ccenv_var_prefix$__tool
+ ccenv_var_expr='${'$ccenv_var_name':-}'
+ eval ccenv_var_val=$ccenv_var_expr
+
+ if [ -n "$ccenv_var_val" ]; then
+ eval ccenv_$__tool="$ccenv_var_val"
+ else
+ ccenv_find_tool
+ eval ccenv_$__tool="$ccenv_tool"
+ fi
+ done
+
+ # windrc
+ ccenv_windrc="$ccenv_windres"
+}
+
+ccenv_set_tool_variants()
+{
+ # as (asm)
+ ccenv_candidates=as
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" = false ]; then
+ ccenv_as_asm=
+ else
+ $ccenv_tool --help | grep -i '.bc assembler' \
+ || ccenv_as_asm="$ccenv_tool"
+ fi
+
+ # as (ll)
+ ccenv_candidates=llvm-as
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" != false ]; then
+ ccenv_as_ll="$ccenv_tool"
+ fi
+
+ # as (mc)
+ ccenv_candidates=llvm-mc
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" != false ]; then
+ ccenv_as_mc="$ccenv_tool"
+ fi
+
+ # ld (bfd)
+ ccenv_candidates=ld.bfd
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" != false ]; then
+ ccenv_ld_bfd="$ccenv_tool"
+ fi
+
+ # ld (gold)
+ ccenv_candidates=ld.gold
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" != false ]; then
+ ccenv_ld_gold="$ccenv_tool"
+ fi
+
+ # ld (lld)
+ ccenv_candidates=lld
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" != false ]; then
+ ccenv_ld_lld="$ccenv_tool"
+ fi
+
+ # objdump (bfd)
+ ccenv_candidates=objdump
+ ccenv_find_tool
+
+ $ccenv_tool --version | grep -i Binutils \
+ > /dev/null \
+ && ccenv_objdump_bfd="$ccenv_tool"
+
+ # objdump (llvm)
+ ccenv_candidates=llvm-objdump
+ ccenv_find_tool
+
+ $ccenv_tool --version | grep -i LLVM \
+ > /dev/null \
+ && ccenv_objdump_llvm="$ccenv_tool"
+
+ # readelf (bfd)
+ ccenv_candidates=readelf
+ ccenv_find_tool
+
+ $ccenv_tool --version | grep -i Binutils \
+ > /dev/null \
+ && ccenv_readelf_bfd="$ccenv_tool"
+
+ # readelf (llvm)
+ ccenv_candidates=llvm-readelf
+ ccenv_find_tool
+
+ $ccenv_tool --version | grep -i LLVM \
+ > /dev/null \
+ && ccenv_readelf_llvm="$ccenv_tool"
+
+ # as
+ if [ -n "$ccenv_cc" ]; then
+ ccenv_as='$('"$ccenv_makevar_prefix"'CC) -x assembler'
+ elif [ -n "$mb_agnostic" ]; then
+ ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
+ elif [ "$mb_zealous" = 'gcc' ]; then
+ ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
+ elif [ -n "$mb_zealous" = 'llvm' ]; then
+ ccenv_as='$('"$ccenv_makevar_prefix"'AS_MC)'
+ elif [ "$mb_toolchain" = 'gcc' ]; then
+ ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
+ elif [ "$mb_toolchain" = 'llvm' ]; then
+ ccenv_as='$('"$ccenv_makevar_prefix"'AS_MC)'
+ fi
+
+ # ld
+ if [ -n "$ccenv_cc" ]; then
+ ccenv_ld='$('"$ccenv_makevar_prefix"'CC) -nostdlib -nostartfiles'
+ fi
+}
+
+ccenv_set_c_compiler_candidates()
+{
+ if [ -n "$mb_compiler" ]; then
+ ccenv_candidates="$mb_compiler"
+
+ elif [ -n "$mb_agnostic" ]; then
+ ccenv_candidates="c99 c11 cc"
+
+ elif [ "$mb_zealous" = 'gcc' ]; then
+ ccenv_candidates="gcc"
+
+ elif [ "$mb_zealous" = 'llvm' ]; then
+ ccenv_candidates="clang"
+
+ elif [ "$mb_toolchain" = 'gcc' ]; then
+ ccenv_candidates="gcc c99 c11 cc clang"
+
+ elif [ "$mb_toolchain" = 'llvm' ]; then
+ ccenv_candidates="clang c99 c11 cc gcc"
+
+ elif [ -n "$mb_toolchain" ]; then
+ ccenv_candidates="$mb_toolchain c99 c11 cc gcc clang"
+
+ else
+ ccenv_candidates="c99 c11 cc gcc clang"
+ fi
+}
+
+
+ccenv_set_cc()
+{
+ if [ -z "$ccenv_cc" ]; then
+ ccenv_set_c_compiler_candidates
+ ccenv_find_tool
+ ccenv_cc="$ccenv_tool"
+ fi
+
+ if [ "$ccenv_cc" = false ] && [ -n "$mb_compiler" ]; then
+ ccenv_cc="$mb_compiler"
+ fi
+
+ ccenv_cc_cmd="$ccenv_cc"
+
+ if [ "$ccenv_cfgtype" = 'native' ]; then
+ ccenv_host=$($ccenv_cc $ccenv_cflags -dumpmachine 2>/dev/null)
+ 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" ]; then
+ ccenv_host=$($ccenv_cc $ccenv_cflags -dumpmachine 2>/dev/null)
+ ccenv_cchost=$ccenv_host
+ else
+ ccenv_tmp=$(mktemp)
+ ccenv_cmd="$ccenv_cc --target=$ccenv_host -E -xc -"
+
+ if [ -z "$mb_user_cc" ]; then
+ $ccenv_cmd < /dev/null > /dev/null \
+ 2>"$ccenv_tmp" || true
+
+ ccenv_errors=$(cat "$ccenv_tmp")
+
+ if [ -z "$ccenv_errors" ]; then
+ ccenv_tflags="--target=$ccenv_host"
+ ccenv_cc="$ccenv_cc $ccenv_tflags"
+ fi
+ fi
+
+ ccenv_cchost=$($ccenv_cc $ccenv_cflags -dumpmachine 2>/dev/null)
+ fi
+
+ if [ "$ccenv_cchost" != "$ccenv_host" ]; then
+ printf 'ccenv:\n' >&2
+ printf 'ccenv: ccenv_host: %s \n' $ccenv_host >&2
+ printf 'ccenv: ccenv_cchost: %s \n' $ccenv_cchost >&2
+
+ if [ -z "$ccenv_tflags" ]; then
+ printf 'ccenv:\n' >&2
+ printf 'ccenv: ccenv_host and ccenv_cchost do not match, most likely because:\n' >&2
+ printf 'ccenv: (1) you explicitly set CC (or passed --compiler=...)\n' >&2
+ printf 'ccenv: (2) the selected compiler does not accept --target=...\n' >&2
+ printf 'ccenv: (3) the host reported by -dumpmachine differs from the one you requested.\n' >&2
+ fi
+
+ if [ -n "$ccenv_errors" ]; then
+ printf 'ccenv:\n' >&2
+ printf 'ccenv: something went wrong, see the command and compiler message below.\n\n' >&2
+ printf 'cmd: %s < /dev/null > /dev/null\n' "$ccenv_cmd" >&2
+ printf '%s\n\n' "$ccenv_errors" >&2
+ else
+ printf 'ccenv:\n' >&2
+ printf 'ccenv: something went wrong, bailing out.\n\n' >&2
+ fi
+
+ return 2
+ fi
+}
+
+ccenv_set_cpp()
+{
+ case "$ccenv_cc_cmd" in
+ cc | c99 | c11 | gcc)
+ ccenv_cpp_prefix=
+ ccenv_candidates="cpp" ;;
+
+ clang )
+ ccenv_cpp_prefix=
+ ccenv_candidates="clang-cpp" ;;
+
+ *-cc )
+ ccenv_cpp_prefix=${ccenv_cc_cmd%-cc*}-
+ ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
+
+ *-c99 )
+ ccenv_cpp_prefix=${ccenv_cc_cmd%-c99*}-
+ ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
+
+ *-c11 )
+ ccenv_cpp_prefix=${ccenv_cc_cmd%-c11*}-
+ ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
+
+ *-gcc )
+ ccenv_cpp_prefix=${ccenv_cc_cmd%-gcc*}-
+ ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
+
+ *-clang )
+ ccenv_cpp_prefix=${ccenv_cc_cmd%-clang*}-
+ ccenv_candidates="${ccenv_cpp_prefix}clang-cpp" ;;
+
+ * )
+ ccenv_cpp="$ccenv_cc -E"
+ return 0
+ esac
+
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" = false ]; then
+ ccenv_cpp="$ccenv_cc -E"
+ elif [ -n "$ccenv_tflags" ]; then
+ ccenv_cpp="$ccenv_tool $ccenv_tflags"
+ else
+ ccenv_cpp="$ccenv_tool"
+ fi
+}
+
+ccenv_set_cxx()
+{
+ case "$ccenv_cc_cmd" in
+ cc | c99 | c11 )
+ ccenv_cxx_prefix=
+ ccenv_candidates="cxx c++" ;;
+
+ gcc )
+ ccenv_cxx_prefix=
+ ccenv_candidates="g++" ;;
+
+ clang )
+ ccenv_cxx_prefix=
+ ccenv_candidates="clang++" ;;
+
+ *-gcc )
+ ccenv_cpp_prefix=${ccenv_cc_cmd%-gcc*}-
+ ccenv_candidates="${ccenv_cpp_prefix}g++" ;;
+
+ *-clang )
+ ccenv_cpp_prefix=${ccenv_cc_cmd%-clang*}-
+ ccenv_candidates="${ccenv_cpp_prefix}clang++" ;;
+
+ *cc )
+ ccenv_cxx_prefix=${ccenv_cc_cmd%cc*}
+ ccenv_candidates="${ccenv_cpp_prefix}++" ;;
+
+ * )
+ ccenv_cxx="$ccenv_cc -xc++"
+ return 0
+ esac
+
+ ccenv_find_tool
+
+ if [ "$ccenv_tool" = false ]; then
+ ccenv_cxx="$ccenv_cc -xc++"
+ elif [ -n "$ccenv_tflags" ]; then
+ ccenv_cxx="$ccenv_tool $ccenv_tflags"
+ else
+ ccenv_cxx="$ccenv_tool"
+ fi
+}
+
+ccenv_set_cc_host()
+{
+ ccenv_cc_host="$ccenv_cchost"
+}
+
+ccenv_set_cc_bits()
+{
+ ccenv_internal_size=
+ ccenv_internal_type='void *'
+ ccenv_internal_test='char x[(sizeof(%s) == %s/8) ? 1 : -1];'
+
+ for ccenv_internal_guess in 64 32 128; do
+ if [ -z $ccenv_internal_size ]; then
+ ccenv_internal_str=$(printf "$ccenv_internal_test" \
+ "$ccenv_internal_type" \
+ "$ccenv_internal_guess")
+
+ printf '%s' "$ccenv_internal_str" \
+ | $ccenv_cc -S -xc - -o - \
+ $ccenv_cflags \
+ > /dev/null 2>/dev/null \
+ && ccenv_internal_size=$ccenv_internal_guess
+ fi
+ done
+
+ ccenv_cc_bits=$ccenv_internal_size
+}
+
+ccenv_set_cc_underscore()
+{
+ ccenv_fn_name='ZmYaXyWbVe_UuTnSdReQrPsOcNoNrLe'
+ ccenv_fn_code='int %s(void){return 0;}'
+
+ printf "$ccenv_fn_code" $ccenv_fn_name \
+ | $ccenv_cc -xc - -S -o - \
+ | grep "^_$ccenv_fn_name:" \
+ > /dev/null \
+ && ccenv_cc_underscore='_'
+
+ return 0
+}
+
+ccenv_create_framework_executable()
+{
+ if [ -f $ccenv_image ]; then
+ mv $ccenv_image $ccenv_image.tmp
+ rm -f $ccenv_image.tmp
+ fi
+
+ printf 'int main(void){return 0;}' \
+ | $ccenv_cc -xc - \
+ -o $ccenv_image \
+ || return 1
+
+ return 0
+}
+
+ccenv_create_freestanding_executable()
+{
+ if [ -f $ccenv_image ]; then
+ mv $ccenv_image $ccenv_image.tmp
+ rm -f $ccenv_image.tmp
+ fi
+
+ if [ -z "ccenv_cc_underscore" ]; then
+ ccenv_start_fn='_start'
+ else
+ ccenv_start_fn='start'
+ fi
+
+ printf 'int %s(void){return 0;}' "$ccenv_start_fn" \
+ | $ccenv_cc -xc - \
+ -ffreestanding \
+ -nostdlib -nostartfiles \
+ -o $ccenv_image \
+ || return 1
+
+ ccenv_freestd=yes
+
+ return 0
+}
+
+ccenv_set_cc_binfmt()
+{
+ ccenv_use_perk=
+ ccenv_use_readelf=
+ ccenv_use_readobj=
+ ccenv_use_bfd_objdump=
+ ccenv_use_llvm_objdump=
+
+ ccenv_create_framework_executable \
+ || ccenv_create_freestanding_executable \
+ || return 0
+
+ # PE / perk
+ if [ -n "$ccenv_perk" ]; then
+ $ccenv_perk $ccenv_image 2>/dev/null \
+ && ccenv_cc_binfmt='PE' \
+ && ccenv_use_perk=yes
+ fi
+
+ # ELF / readelf
+ if [ -n "$ccenv_readelf" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ $ccenv_readelf -h $ccenv_image 2>/dev/null \
+ | grep 'Magic:' | sed -e 's/[ ]*//g' \
+ | grep 'Magic:7f454c46' \
+ > /dev/null \
+ && ccenv_cc_binfmt='ELF' \
+ && ccenv_use_readelf=yes
+ fi
+
+ # a marble of astonishing design:
+ # llvm-readelf also parses PE and Mach-O
+
+ if [ -n "$ccenv_readelf_llvm" ]; then
+ ccenv_readany="$ccenv_readelf_llvm"
+ else
+ ccenv_readany="$ccenv_readelf"
+ fi
+
+ # PE / readelf
+ if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ $ccenv_readany -h $ccenv_image 2>/dev/null \
+ | grep 'Magic:' | sed -e 's/[ ]*//g' \
+ | grep 'Magic:MZ' \
+ > /dev/null \
+ && ccenv_cc_binfmt='PE' \
+ && ccenv_use_readelf=yes
+ fi
+
+ # MACHO-64 / readelf
+ if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ $ccenv_readany -h $ccenv_image 2>/dev/null \
+ | grep -i 'Magic:' | sed -e 's/[ ]*//g' \
+ | grep -i '(0xfeedfacf)' \
+ > /dev/null \
+ && ccenv_cc_binfmt='MACHO' \
+ && ccenv_use_readelf=yes
+ fi
+
+ # MACHO-32 / readelf
+ if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ $ccenv_readany -h $ccenv_image 2>/dev/null \
+ | grep -i 'Magic:' | sed -e 's/[ ]*//g' \
+ | grep -i '(0xcafebabe)' \
+ > /dev/null \
+ && ccenv_cc_binfmt='MACHO' \
+ && ccenv_use_readelf=yes
+ fi
+
+ # MACHO / readobj
+ if [ -n "$ccenv_readobj" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ $ccenv_readobj $ccenv_image 2>/dev/null \
+ | grep -i 'Format:' | sed 's/ /_/g' \
+ | grep -i '_Mach-O_' \
+ > /dev/null \
+ && ccenv_cc_binfmt='MACHO' \
+ && ccenv_use_readobj=yes
+ fi
+
+ # MACHO / objdump (llvm)
+ if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ $ccenv_objdump -section-headers $ccenv_image \
+ 2>/dev/null \
+ | grep -i 'file format Mach-O' \
+ > /dev/null \
+ && ccenv_cc_binfmt='MACHO' \
+ && ccenv_use_objdump=yes
+ fi
+
+ # MACHO / objdump (bfd)
+ if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ $ccenv_objdump -h $ccenv_image 2>/dev/null \
+ | grep -i 'file format Mach-O' \
+ > /dev/null \
+ && ccenv_cc_binfmt='MACHO' \
+ && ccenv_use_objdump=yes
+ fi
+
+ # PE / objdump (bfd)
+ if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
+ $ccenv_objdump -h $ccenv_image 2>/dev/null \
+ | grep -i 'file format pei-' \
+ > /dev/null \
+ && ccenv_cc_binfmt='PE' \
+ && ccenv_use_bfd_objdump=yes
+ fi
+}
+
+ccenv_set_os_pe()
+{
+ if [ -n "$ccenv_freestd" ]; then
+ case "$ccenv_cchost" in
+ *-midipix | *-midipix-* )
+ ccenv_os='midipix' ;;
+ *-mingw | *-mingw32 | *-mingw64 )
+ ccenv_os='mingw' ;;
+ *-mingw-* | *-mingw32-* | *-mingw64 )
+ ccenv_os='mingw' ;;
+ *-msys | *-msys2 | *-msys-* | *-msys2-* )
+ ccenv_os='msys' ;;
+ *-cygwin | *-cygwin-* )
+ ccenv_os='cygwin' ;;
+ esac
+ fi
+
+ if [ -n "$ccenv_os" ]; then
+ return 0
+ fi
+
+ if [ -n "$ccenv_use_perk" ]; then
+ ccenv_framework=$($ccenv_perk -y $ccenv_image)
+ ccenv_os=${ccenv_framework#*-*-*-*}
+ fi
+
+ if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
+ $ccenv_objdump_bfd -x $ccenv_image | grep -i 'DLL Name' \
+ | grep 'cygwin1.dll' > /dev/null \
+ && ccenv_os='cygwin'
+ fi
+
+ if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
+ $ccenv_objdump_bfd -x $ccenv_image | grep -i 'DLL Name' \
+ | grep 'msys-2.0.dll' > /dev/null \
+ && ccenv_os='msys'
+ fi
+
+ if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
+ $ccenv_objdump_bfd -x $ccenv_image \
+ | grep -i 'DLL Name' | grep '.CRT' \
+ > /dev/null \
+ && $ccenv_objdump_bfd -x $ccenv_image \
+ | grep -i 'DLL Name' | grep '.bss' \
+ > /dev/null \
+ && $ccenv_objdump_bfd -x $ccenv_image \
+ | grep -i 'DLL Name' | grep '.tls' \
+ > /dev/null \
+ && ccenv_os='mingw'
+ fi
+}
+
+ccenv_set_os_macho()
+{
+ case "$ccenv_cchost" in
+ *-apple-darwin* )
+ ccenv_os='darwin' ;;
+ esac
+}
+
+ccenv_set_os()
+{
+ case "$ccenv_cc_binfmt" in
+ PE )
+ ccenv_set_os_pe ;;
+ MACHO )
+ ccenv_set_os_macho ;;
+ esac
+
+ if [ -n "$ccenv_os" ]; then
+ return 0
+ fi
+
+ case "$ccenv_cchost" in
+ *-*-*-* )
+ ccenv_tip=${ccenv_cchost%-*}
+ ccenv_os=${ccenv_tip#*-*-}
+ ;;
+ *-*-musl | *-*-gnu )
+ 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_set_os_flags()
+{
+ case "$ccenv_os" in
+ darwin )
+ ccenv_cflags_os='-D_DARWIN_C_SOURCE'
+ ccenv_cflags_pic='-fPIC'
+ ;;
+ midipix )
+ ccenv_cflags_os=
+ ccenv_cflags_pic='-fPIC'
+ ;;
+ cygwin )
+ ccenv_cflags_os=
+ ccenv_cflags_pic=
+ ;;
+ msys | msys* | mingw | mingw* )
+ ccenv_cflags_os='-U__STRICT_ANSI__'
+ ccenv_cflags_pic=
+ ;;
+ * )
+ ccenv_cflags_os=
+ ccenv_cflags_pic='-fPIC'
+ ;;
+ esac
+}
+
+ccenv_set_os_semantics()
+{
+ # binary_format - core_api - ex_api - dependency_resolution
+
+ case "$ccenv_os" in
+ linux )
+ ccenv_os_semantics='elf-posix-linux-ldso'
+ ;;
+ bsd )
+ ccenv_os_semantics='elf-posix-bsd-ldso'
+ ;;
+ darwin )
+ ccenv_os_semantics='macho-posix-osx-ldso'
+ ;;
+ midipix )
+ ccenv_os_semantics='pe-posix-winnt-ldso'
+ ;;
+ cygwin )
+ ccenv_os_semantics='pe-hybrid-winnt-unsafe'
+ ;;
+ msys )
+ ccenv_os_semantics='pe-hybrid-winnt-unsafe'
+ ;;
+ mingw )
+ ccenv_os_semantics='pe-win32-winnt-unsafe'
+ ;;
+ esac
+
+ if [ -n "$ccenv_os_semantics" ]; then
+ return 0
+ fi
+
+ if [ -n "$ccenv_cc_binfmt" ]; then
+ ccenv_os_semantics_pattern='%s-posix-anyos-unknown'
+ ccenv_os_semantics=$(printf \
+ "$ccenv_os_semantics_pattern" \
+ "$ccenv_cc_binfmt" \
+ | tr '[:upper:]' '[:lower:]')
+ else
+ ccenv_os_semantics='unknown-posix-anyos-unknown'
+ fi
+}
+
+ccenv_set_os_dso_exrules()
+{
+ case "$ccenv_os" in
+ midipix )
+ ccenv_os_dso_exrules='pe-mdso'
+ ;;
+ * )
+ if [ "$ccenv_cc_binfmt" = 'PE' ]; then
+ ccenv_os_dso_exrules='pe-dlltool'
+ else
+ ccenv_os_dso_exrules='default'
+ fi
+ esac
+}
+
+ccenv_set_os_dso_linkage()
+{
+ # todo: PIC, PIE, and friends
+ ccenv_os_dso_linkage='default'
+}
+
+ccenv_set_os_dso_patterns_darwin()
+{
+ ccenv_os_app_prefix=
+ ccenv_os_app_suffix=
+
+ ccenv_os_lib_prefix=lib
+ ccenv_os_lib_suffix=.dylib
+
+ ccenv_os_implib_ext=.invalid
+ ccenv_os_libdef_ext=.invalid
+
+ ccenv_os_archive_ext=.a
+ ccenv_os_soname=symlink
+
+ ccenv_os_lib_prefixed_suffix=
+ ccenv_os_lib_suffixed_suffix='$(OS_LIB_SUFFIX)'
+}
+
+ccenv_set_os_dso_patterns_mdso()
+{
+ ccenv_os_app_prefix=
+ ccenv_os_app_suffix=
+
+ ccenv_os_lib_prefix=lib
+ ccenv_os_lib_suffix=.so
+
+ ccenv_os_implib_ext=.lib.a
+ ccenv_os_libdef_ext=.so.def
+
+ ccenv_os_archive_ext=.a
+ ccenv_os_soname=symlink
+
+ ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
+ ccenv_os_lib_suffixed_suffix=
+}
+
+ccenv_set_os_dso_patterns_dlltool()
+{
+ ccenv_os_app_prefix=
+ ccenv_os_app_suffix=.exe
+
+ ccenv_os_lib_prefix=lib
+ ccenv_os_lib_suffix=.dll
+
+ ccenv_os_implib_ext=.dll.a
+ ccenv_os_libdef_ext=.def
+
+ ccenv_os_archive_ext=.a
+ ccenv_os_soname=copy
+
+ ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
+ ccenv_os_lib_suffixed_suffix=
+}
+
+ccenv_set_os_dso_patterns_default()
+{
+ ccenv_os_app_prefix=
+ ccenv_os_app_suffix=
+
+ ccenv_os_lib_prefix=lib
+ ccenv_os_lib_suffix=.so
+
+ ccenv_os_implib_ext=.invalid
+ ccenv_os_libdef_ext=.invalid
+
+ ccenv_os_archive_ext=.a
+ ccenv_os_soname=symlink
+
+ ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
+ ccenv_os_lib_suffixed_suffix=
+}
+
+ccenv_set_os_dso_patterns()
+{
+ # sover: .so.x.y.z
+ # verso: .x.y.z.so
+
+ case "$ccenv_os" in
+ darwin )
+ ccenv_set_os_dso_patterns_darwin
+ ;;
+ midipix )
+ ccenv_set_os_dso_patterns_mdso
+ ;;
+ cygwin | msys | mingw )
+ ccenv_set_os_dso_patterns_dlltool
+ ;;
+ * )
+ ccenv_set_os_dso_patterns_default
+ ;;
+ esac
+}
+
+ccenv_output_defs()
+{
+ ccenv_in="$mb_project_dir/sofort/ccenv/ccenv.in"
+ ccenv_mk="$mb_pwd/ccenv/$ccenv_cfgtype.mk"
+
+ if [ $ccenv_cfgtype = 'native' ]; then
+
+ ccenv_tmp=$(mktemp)
+
+ sed \
+ -e 's/^\s*$/@/g' \
+ -e 's/^/NATIVE_/' \
+ -e 's/NATIVE_@//g' \
+ -e 's/NATIVE_#/#/g' \
+ -e 's/ =/=/g' \
+ -e 's/ +=/+=/g' \
+ "$ccenv_in" > "$ccenv_tmp"
+
+ ccenv_in="$ccenv_tmp"
+ fi
+
+ ccenv_vars=$(cut -d'=' -f1 "$mb_project_dir/sofort/ccenv/ccenv.vars" \
+ | grep -v '^#')
+
+ ccenv_exvars="ccenv_cfgtype ccenv_makevar_prefix"
+
+ ccenv_sed_substs=" \
+ $(for __var in $ccenv_vars $ccenv_exvars; do \
+ printf '%s"$%s"%s' "-e 's/@$__var@/'" \
+ "$__var" "'/g' "; \
+ done)"
+
+ eval sed $ccenv_sed_substs "$ccenv_in" \
+ | sed -e 's/[ \t]*$//g' \
+ > "$ccenv_mk"
+
+ if [ "$ccenv_cfgtype" = 'host' ]; then
+ for __var in $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 $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
+}
+
+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" | $ccenv_cmd \
+ > /dev/null 2>/dev/null \
+ || 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_freestd=
+ 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=$(make -s -f "$mb_pwd/Makefile.tmp" .display-cflags)
+ ccenv_cc="$mb_user_cc"
+ ccenv_cpp="$mb_user_cpp"
+ ccenv_cxx="$mb_user_cxx"
+ else
+ ccenv_tflags=
+ ccenv_cflags="$mb_native_cflags"
+ ccenv_cc="$mb_native_cc"
+ ccenv_cpp="$mb_native_cpp"
+ ccenv_cxx="$mb_native_cxx"
+ fi
+}
+
+ccenv_set_characteristics()
+{
+ ccenv_set_cc_host
+ ccenv_set_cc_bits
+ ccenv_set_cc_underscore
+ ccenv_set_cc_binfmt
+}
+
+ccenv_set_toolchain_variables()
+{
+ ccenv_common_init $1
+ ccenv_set_cc
+ ccenv_set_cpp
+ ccenv_set_cxx
+ ccenv_set_primary_tools
+ ccenv_set_tool_variants
+ ccenv_set_characteristics
+
+ ccenv_set_os
+ ccenv_set_os_flags
+ ccenv_set_os_semantics
+ ccenv_set_os_dso_exrules
+ ccenv_set_os_dso_linkage
+ ccenv_set_os_dso_patterns
+
+ ccenv_output_defs
+ ccenv_clean_up
+}
+
+ccenv_set_host_variables()
+{
+ ccenv_set_toolchain_variables 'host'
+ ccenv_dso_verify
+}
+
+ccenv_set_native_variables()
+{
+ 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..1d68357
--- /dev/null
+++ b/sofort/ccenv/ccenv.vars
@@ -0,0 +1,82 @@
+# system flavor
+ccenv_os=
+ccenv_os_semantics=
+
+ccenv_os_dso_exrules=
+ccenv_os_dso_linkage=
+
+ccenv_os_app_prefix=
+ccenv_os_app_suffix=
+
+ccenv_os_lib_prefix=
+ccenv_os_lib_suffix=
+
+ccenv_os_implib_ext=
+ccenv_os_libdef_ext=
+
+ccenv_os_archive_ext=
+ccenv_os_soname=
+
+ccenv_os_lib_prefixed_suffix=
+ccenv_os_lib_suffixed_suffix=
+
+# characteristics
+ccenv_cc_host=
+ccenv_cc_bits=
+
+ccenv_cc_binfmt=
+ccenv_cc_underscore=
+
+ccenv_cc_arch_bfd=
+ccenv_cc_arch_llvm=
+
+# incompatible tool variants
+ccenv_as_asm=
+ccenv_as_ll=
+ccenv_as_mc=
+
+ccenv_ld_bfd=
+ccenv_ld_gold=
+ccenv_ld_lld=
+
+ccenv_objdump_bfd=
+ccenv_objdump_llvm=
+
+ccenv_readelf_bfd=
+ccenv_readelf_llvm=
+
+# tool variables
+ccenv_cc=
+ccenv_cpp=
+ccenv_cxx=
+
+ccenv_as=
+ccenv_ld=
+
+ccenv_ar=
+ccenv_nm=
+ccenv_objdump=
+ccenv_ranlib=
+ccenv_size=
+ccenv_strip=
+ccenv_strings=
+
+ccenv_addr2line=
+ccenv_cov=
+ccenv_cxxfilt=
+ccenv_objcopy=
+
+ccenv_elfedit=
+ccenv_readelf=
+ccenv_readobj=
+
+ccenv_perk=
+ccenv_mdso=
+ccenv_dlltool=
+
+ccenv_windmc=
+ccenv_windrc=
+
+# cflags
+ccenv_cflags_os=
+ccenv_cflags_pic=
diff --git a/sofort/cfgtest/cfgtest.sh b/sofort/cfgtest/cfgtest.sh
new file mode 100644
index 0000000..d1e3b1b
--- /dev/null
+++ b/sofort/cfgtest/cfgtest.sh
@@ -0,0 +1,332 @@
+# cfgtest.sh: sofort's config test framework,
+# for use from within a project's custom cfgdefs.sh.
+
+# in the common scenario, target-specific tests are preceded
+# by a single invocation of cfgtest_target_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_cflags: the compiler flags used for the current test
+# mb_cfgtest_cfgtype: the type of the current test (target/native)
+# mb_cfgtest_makevar: the make variable affected by the current test
+# mb_cfgtest_headers: headers for ad-hoc inclusion with the current test
+
+
+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_target_section()
+{
+ mb_cfgtest_cc=$(make -s -f "$mb_pwd/Makefile.tmp" .display-cc)
+ mb_cfgtest_cflags=$(make -s -f "$mb_pwd/Makefile.tmp" .display-cflags)
+ mb_cfgtest_cfgtype='target'
+
+ cfgtest_comment 'target-specific tests'
+}
+
+
+cfgtest_native_section()
+{
+ mb_cfgtest_cc="$mb_native_cc"
+ mb_cfgtest_cflags="$mb_native_cflags"
+ mb_cfgtest_cfgtype='native'
+
+ cfgtest_comment 'native system tests'
+}
+
+
+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 = 'target' ]; 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 = 'target' ]; 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_header_presence()
+{
+ $mb_cfgtest_cc -E -xc - \
+ $mb_cfgtest_cflags \
+ --include="$@" \
+ < /dev/null \
+ > /dev/null 2>/dev/null \
+ || return
+
+ mb_internal_str=$(printf '%s%s' '-DHAVE_' "$@" \
+ | 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
+}
+
+
+cfgtest_header_absence()
+{
+ $mb_cfgtest_cc -E -xc - \
+ $mb_cfgtest_cflags \
+ --include="$@" \
+ < /dev/null \
+ > /dev/null 2>/dev/null \
+ && return
+
+ 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
+}
+
+
+cfgtest_interface_presence()
+{
+ mb_internal_cflags=''
+
+ for mb_header in $mb_cfgtest_headers; do
+ mb_internal_cflags="$mb_internal_cflags --include=$mb_header"
+ done
+
+ printf 'void * addr = &%s;' "$@" \
+ | $mb_cfgtest_cc -S -xc - -o - \
+ $mb_cfgtest_cflags \
+ $mb_internal_cflags \
+ > /dev/null 2>/dev/null \
+ || return 1
+
+ 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
+
+ return 0
+}
+
+
+cfgtest_decl_presence()
+{
+ mb_internal_cflags=''
+
+ for mb_header in $mb_cfgtest_headers; do
+ mb_internal_cflags="$mb_internal_cflags --include=$mb_header"
+ done
+
+ printf 'void * any = (void *)%s;' "$@" \
+ | $mb_cfgtest_cc -S -xc - -o - \
+ $mb_cfgtest_cflags \
+ $mb_internal_cflags \
+ > /dev/null 2>/dev/null \
+ || return 1
+
+ # 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
+ return 0
+ fi
+
+ 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
+
+ return 0
+}
+
+
+cfgtest_type_size()
+{
+ mb_internal_cflags=''
+ mb_internal_size=''
+ mb_internal_test='char x[(sizeof(%s) == %s) ? 1 : -1];'
+
+ for mb_header in $mb_cfgtest_headers; do
+ mb_internal_cflags="$mb_internal_cflags --include=$mb_header"
+ done
+
+ for mb_internal_guess in 8 4 2 1 16 32 64 128; do
+ if [ -z $mb_internal_size ]; then
+ mb_internal_type="$@"
+
+ mb_internal_str=$(printf "$mb_internal_test" \
+ "$mb_internal_type" \
+ "$mb_internal_guess")
+
+ printf '%s' "$mb_internal_str" \
+ | $mb_cfgtest_cc -S -xc - -o - \
+ $mb_cfgtest_cflags \
+ $mb_internal_cflags \
+ > /dev/null 2>/dev/null \
+ && mb_internal_size=$mb_internal_guess
+ fi
+ done
+
+ # unrecognized type, or type size not within range
+ if [ -z $mb_internal_size ]; then
+ 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
+
+ return 0
+}
+
+
+cfgtest_code_snippet()
+{
+ mb_internal_cflags=''
+ mb_internal_test="$@"
+
+ for mb_header in $mb_cfgtest_headers; do
+ mb_internal_cflags="$mb_internal_cflags --include=$mb_header"
+ done
+
+ printf '%s' "$mb_internal_test" \
+ | $mb_cfgtest_cc -S -xc - -o - \
+ $mb_cfgtest_cflags \
+ $mb_internal_cflags \
+ > /dev/null 2>/dev/null \
+ || return 1
+
+ return 0
+}
+
+
+cfgtest_library_presence()
+{
+ printf 'int main(void){return 0;}' \
+ | $mb_cfgtest_cc -o a.out -xc - \
+ $mb_cfgtest_cflags \
+ $@ \
+ > /dev/null 2>/dev/null \
+ || return 1
+
+ rm -f a.out
+
+ return 0
+}
+
+
+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..17f6cd2
--- /dev/null
+++ b/sofort/config/config.vars
@@ -0,0 +1,117 @@
+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
+pkgdefs
+pkglibs
+
+build
+host
+cchost
+cfghost
+target
+arch
+compiler
+toolchain
+zealous
+sysroot
+cross_compile
+shell
+
+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
+pe_config_defs
+
+elf_eh_frame
+elf_hash_style
+elf_config_defs
+
+native_cc
+native_cpp
+native_cxx
+
+native_host
+native_cfghost
+native_cflags
+native_ldflags
+
+all_shared
+all_static
+disable_frontend
+disable_shared
+disable_static
+
+use_custom_cfgdefs
+use_custom_usrdefs
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/core/defs.mk b/sofort/core/defs.mk
new file mode 100644
index 0000000..151bc3d
--- /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=.o)
+
+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..bd9ab06
--- /dev/null
+++ b/sofort/core/flavor.mk
@@ -0,0 +1,70 @@
+ifneq ($(OS_DSO_EXRULES),)
+include $(PROJECT_DIR)/sofort/exrules/$(OS_DSO_EXRULES).mk
+endif
+
+ifeq ($(DISABLE_STATIC),yes)
+package-static:
+package-install-static:
+else
+package-static: static
+package-install-static: install-static
+endif
+
+ifeq ($(DISABLE_SHARED),yes)
+package-shared:
+package-install-shared:
+else
+package-shared: shared
+package-install-shared: install-shared
+endif
+
+
+
+ifeq ($(DISABLE_FRONTEND),yes)
+app-tag:
+package-install-app:
+package-install-extras:
+else
+app-tag: package-app app.tag
+package-install-app: install-app
+package-install-extras: install-extras
+endif
+
+
+
+ifeq ($(ALL_STATIC),yes)
+
+package-app: static-app
+app: PACKAGE_APP = $(STATIC_APP)
+app-tag: PACKAGE_APP = $(STATIC_APP)
+app.tag: $(STATIC_APP)
+
+
+else ifeq ($(ALL_SHARED),yes)
+
+package-app: shared-app
+app: PACKAGE_APP = $(SHARED_APP)
+app-tag: PACKAGE_APP = $(SHARED_APP)
+app.tag: $(SHARED_APP)
+
+
+else
+
+package-app: default-app
+app: PACKAGE_APP = $(DEFAULT_APP)
+app-tag: PACKAGE_APP = $(DEFAULT_APP)
+app.tag: $(DEFAULT_APP)
+
+endif
+
+
+
+ifeq ($(CUSTOM_INSTALL_HEADERS),yes)
+
+install-headers:install-headers-custom
+
+else
+
+install-headers:install-headers-default
+
+endif
diff --git a/sofort/core/pkgconf.mk b/sofort/core/pkgconf.mk
new file mode 100644
index 0000000..f266b9f
--- /dev/null
+++ b/sofort/core/pkgconf.mk
@@ -0,0 +1,40 @@
+ifeq ($(PKGCONF),no)
+
+install-pkgconf:
+
+else
+
+PKGCONF_VERSION = $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)
+
+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_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
+
+endif
diff --git a/sofort/core/version.mk b/sofort/core/version.mk
new file mode 100644
index 0000000..5ef0ee2
--- /dev/null
+++ b/sofort/core/version.mk
@@ -0,0 +1,63 @@
+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)
+
+ifeq ($(AVOID_VERSION),yes)
+
+VER_XYZ =
+VER_SONAME =
+
+package-shared-soname:
+package-shared-solink:
+package-install-soname:
+package-install-solink:
+
+else
+
+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)
+ifeq ($(OS_SONAME),symlink)
+$(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)
+endif
+
+
+# libfoo.so.x (copy)
+ifeq ($(OS_SONAME),copy)
+install-soname: install-lib
+ cp $(SHARED_LIB) $(DESTDIR)$(LIBDIR)/$(DSO_SONAME)
+
+$(SHARED_SONAME): $(SHARED_LIB)
+ cp $(SHARED_LIB) $(SHARED_SONAME)
+endif
+
+endif
diff --git a/sofort/exrules/default.mk b/sofort/exrules/default.mk
new file mode 100644
index 0000000..ad1c11c
--- /dev/null
+++ b/sofort/exrules/default.mk
@@ -0,0 +1,8 @@
+DSO_REF_VER = $(SHARED_LIB)
+DSO_REF_SONAME = $(SHARED_SONAME)
+DSO_REF_SOLINK = $(SHARED_SOLINK)
+
+LDFLAGS_SHARED += -Wl,-soname
+LDFLAGS_SHARED += -Wl,$(DSO_SONAME)
+
+.PHONY: $(IMPLIB_DEF) $(IMPLIB_VER) $(IMPLIB_SONAME) $(IMPLIB_SOLINK)
diff --git a/sofort/exrules/pe-common.mk b/sofort/exrules/pe-common.mk
new file mode 100644
index 0000000..be19ab3
--- /dev/null
+++ b/sofort/exrules/pe-common.mk
@@ -0,0 +1,39 @@
+DSO_REF_VER = $(IMPLIB_VER)
+DSO_REF_SONAME = $(IMPLIB_SONAME)
+DSO_REF_SOLINK = $(IMPLIB_SOLINK)
+
+LDFLAGS_IMPLIB += -Wl,--output-def
+LDFLAGS_IMPLIB += -Wl,$(IMPLIB_DEF)
+
+LDFLAGS_SONAME += -Wl,-soname
+LDFLAGS_SONAME += -Wl,$(DSO_SONAME)
+LDFLAGS_SHARED += $(LDFLAGS_SONAME)
+
+DSO_LIBPATH ?= loader
+PE_SUBSYSTEM ?= windows
+LDFLAGS_COMMON += -Wl,--subsystem=$(PE_SUBSYSTEM)
+
+implib: implib-ver package-implib-soname package-implib-solink
+
+implib-ver: shared-lib $(IMPLIB_VER)
+
+implib-soname: shared-lib $(IMPLIB_SONAME)
+
+implib-solink: shared-lib $(IMPLIB_SOLINK)
+
+$(IMPLIB_DEF): shared-lib
+
+install-implib: install-implib-ver \
+ package-install-implib-soname \
+ package-install-implib-solink
+
+install-implib-ver: implib-ver
+ mkdir -p $(DESTDIR)$(LIBDIR)
+ cp $(IMPLIB_VER) $(DESTDIR)$(LIBDIR)
+
+clean-implib:
+ rm -f $(SHARED_LIB)
+ rm -f $(IMPLIB_DEF)
+ rm -f $(IMPLIB_VER)
+ rm -f $(IMPLIB_SONAME)
+ rm -f $(IMPLIB_SOLINK)
diff --git a/sofort/exrules/pe-dlltool.mk b/sofort/exrules/pe-dlltool.mk
new file mode 100644
index 0000000..6694ed5
--- /dev/null
+++ b/sofort/exrules/pe-dlltool.mk
@@ -0,0 +1,15 @@
+include $(PROJECT_DIR)/sofort/exrules/pe-common.mk
+
+$(IMPLIB_VER): $(IMPLIB_DEF)
+ $(DLLTOOL) -l $(IMPLIB_VER) -d $(IMPLIB_DEF) -D $(DSO_VER)
+
+ifeq ($(AVOID_VERSION),yes)
+
+else
+
+$(IMPLIB_SONAME): $(IMPLIB_DEF)
+ $(DLLTOOL) -l $(IMPLIB_SONAME) -d $(IMPLIB_DEF) -D $(DSO_SONAME)
+
+endif
+
+include $(PROJECT_DIR)/sofort/exrules/pe-version.mk
diff --git a/sofort/exrules/pe-mdso.mk b/sofort/exrules/pe-mdso.mk
new file mode 100644
index 0000000..b5e2dba
--- /dev/null
+++ b/sofort/exrules/pe-mdso.mk
@@ -0,0 +1,15 @@
+include $(PROJECT_DIR)/sofort/exrules/pe-common.mk
+
+$(IMPLIB_VER): $(IMPLIB_DEF)
+ $(MDSO) -m $(CC_BITS) -i $(IMPLIB_VER) -n $(DSO_VER) -l $(DSO_LIBPATH) $<
+
+ifeq ($(AVOID_VERSION),yes)
+
+else
+
+$(IMPLIB_SONAME): $(IMPLIB_DEF)
+ $(MDSO) -m $(CC_BITS) -i $(IMPLIB_SONAME) -n $(DSO_SONAME) $(IMPLIB_DEF)
+
+endif
+
+include $(PROJECT_DIR)/sofort/exrules/pe-version.mk
diff --git a/sofort/exrules/pe-version.mk b/sofort/exrules/pe-version.mk
new file mode 100644
index 0000000..38714b4
--- /dev/null
+++ b/sofort/exrules/pe-version.mk
@@ -0,0 +1,31 @@
+ifeq ($(AVOID_VERSION),yes)
+
+package-implib-soname:
+package-implib-solink:
+package-install-implib-soname:
+package-install-implib-solink:
+
+else
+
+package-implib-soname: implib-soname
+package-implib-solink: implib-solink
+package-install-implib-soname: install-implib-soname
+package-install-implib-solink: install-implib-solink
+
+
+$(IMPLIB_SOLINK): $(IMPLIB_SONAME)
+ rm -f $(IMPLIB_SOLINK).tmp
+ ln -s $(IMP_SONAME) $(IMPLIB_SOLINK).tmp
+ mv $(IMPLIB_SOLINK).tmp $(IMPLIB_SOLINK)
+
+install-implib-soname: implib-soname
+ mkdir -p $(DESTDIR)$(LIBDIR)
+ cp $(IMPLIB_SONAME) $(DESTDIR)$(LIBDIR)
+
+install-implib-solink: implib-soname
+ mkdir -p $(DESTDIR)$(LIBDIR)
+ rm -f $(IMPLIB_SOLINK).tmp
+ ln -s $(IMP_SONAME) $(IMPLIB_SOLINK).tmp
+ mv $(IMPLIB_SOLINK).tmp $(DESTDIR)$(LIBDIR)/$(IMP_SOLINK)
+
+endif
diff --git a/sofort/tools/pkgconf.sh b/sofort/tools/pkgconf.sh
new file mode 100755
index 0000000..614fdec
--- /dev/null
+++ b/sofort/tools/pkgconf.sh
@@ -0,0 +1,109 @@
+#!/bin/sh
+
+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/$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/$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="$pkgconf_libdir -l${PKGCONF_NAME}"
+elif [ -n "${PKGCONF_NAME}" ]; then
+ pkgconf_ldflags="-l${PKGCONF_NAME}"
+else
+ pkgconf_ldflags="$pkgconf_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
+
+
+# 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
+
+Cflags: $pkgconf_cflags
+Libs: $pkgconf_ldflags
+###
+_EOF
+
+# all done
+exit 0
diff --git a/sofort/tools/version.sh b/sofort/tools/version.sh
new file mode 100755
index 0000000..f510a32
--- /dev/null
+++ b/sofort/tools/version.sh
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+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)
+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