summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Makefile.in251
-rw-r--r--config.project49
-rwxr-xr-xconfigure385
-rw-r--r--project/arch.mk13
-rw-r--r--project/common.mk103
-rw-r--r--project/defs.mk31
-rw-r--r--project/depends.mk0
-rw-r--r--project/extras.mk16
-rw-r--r--project/headers.mk77
-rw-r--r--project/overrides.mk0
-rw-r--r--project/tree.mk26
-rw-r--r--src/internal/ntapi_entry_point.c (renamed from src/internal/ntapi_lib_entry_point.c)2
-rwxr-xr-xsysinfo/host/host.sh49
-rw-r--r--sysinfo/host/i686-nt32-midipix.mk5
-rw-r--r--sysinfo/host/i686-unknown-linux.mk5
-rw-r--r--sysinfo/host/i686-w64-mingw32.mk5
-rw-r--r--sysinfo/host/native.mk46
-rw-r--r--sysinfo/host/x86_64-nt64-midipix.mk5
-rw-r--r--sysinfo/host/x86_64-unknown-linux.mk5
-rw-r--r--sysinfo/host/x86_64-w64-mingw32.mk5
-rw-r--r--sysinfo/os/bsd.mk10
-rw-r--r--sysinfo/os/darwin.mk10
-rw-r--r--sysinfo/os/linux.mk10
-rw-r--r--sysinfo/os/midipix.mk12
-rw-r--r--sysinfo/os/mingw.mk14
-rw-r--r--sysinfo/toolchain/clang.mk34
-rw-r--r--sysinfo/toolchain/gcc.mk25
27 files changed, 1192 insertions, 1 deletions
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000..e0f29dc
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,251 @@
+PACKAGE = @package@
+PROJECT_DIR = @project_dir@
+
+BUILD = @build@
+HOST = @host@
+TARGET = @target@
+ARCH = @arch@
+TOOLCHAIN = @toolchain@
+SYSROOT = @sysroot@
+CROSS_COMPILE = @cross_compile@
+SHELL = @shell@
+
+CFLAGS_DEBUG = @cflags_debug@
+CFLAGS_COMMON = @cflags_common@
+CFLAGS_CMDLINE = @cflags_cmdline@
+CFLAGS_CONFIG = @cflags_config@
+CFLAGS_SYSROOT = @cflags_sysroot@
+CFLAGS_PATH = @cflags_path@
+
+LDFLAGS_DEBUG = @ldflags_debug@
+LDFLAGS_COMMON = @ldflags_common@
+LDFLAGS_CMDLINE = @ldflags_cmdline@
+LDFLAGS_CONFIG = @ldflags_config@
+LDFLAGS_SYSROOT = @ldflags_sysroot@
+LDFLAGS_PATH = @ldflags_path@
+
+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@
+
+PREFIX = @prefix@
+BINDIR = @bindir@
+LIBDIR = @libdir@
+INCLUDEDIR = @includedir@
+SYSLIBDIR = @syslibdir@
+MANDIR = @mandir@
+DOCDIR = @docdir@
+LIBEXECDIR = @libexecdir@
+
+NATIVE_CC = @native_cc@
+NATIVE_OS = @native_os@
+NATIVE_OS_BITS = @native_os_bits@
+NATIVE_OS_UNDERSCORE = @native_os_underscore@
+
+
+
+all:
+install:
+shared:
+static:
+
+
+
+include $(PROJECT_DIR)/sysinfo/toolchain/$(TOOLCHAIN).mk
+include $(PROJECT_DIR)/sysinfo/host/$(HOST).mk
+
+include $(PROJECT_DIR)/project/defs.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
+
+
+
+src/%.lo: $(PROJECT_DIR)/src/%.c $(ALL_HEADERS) host.tag
+ $(CC) -c -o $@ $< $(CFLAGS_SHARED)
+
+src/%.o: $(PROJECT_DIR)/src/%.c $(ALL_HEADERS) host.tag
+ $(CC) -c -o $@ $< $(CFLAGS_STATIC)
+
+$(LIBDIR)/%$(OS_LIB_SUFFIX):
+ $(LD) -shared -o $@ $^ $(LDFLAGS_SHARED)
+
+$(LIBDIR)/%$(OS_ARCHIVE_EXT):
+ rm -f $@
+ $(AR) -rcs $@ $^
+
+
+
+all: shared static
+
+install: install-libs install-headers
+
+
+install-libs: install-shared install-static install-implib
+
+install-headers:shared static
+ mkdir -p $(DESTDIR)/./$(PREFIX)/./$(INCLUDEDIR)/$(PACKAGE)
+ mkdir -p $(DESTDIR)/./$(PREFIX)/./$(INCLUDEDIR)/$(PACKAGE)/bits
+ mkdir -p $(DESTDIR)/./$(PREFIX)/./$(INCLUDEDIR)/$(PACKAGE)/bits/i386
+ mkdir -p $(DESTDIR)/./$(PREFIX)/./$(INCLUDEDIR)/$(PACKAGE)/bits/x86_64
+ cp $(API_HEADERS) $(DESTDIR)/./$(PREFIX)/./$(INCLUDEDIR)/$(PACKAGE)
+ cp $(API_HEADERS_BITS) $(DESTDIR)/./$(PREFIX)/./$(INCLUDEDIR)/$(PACKAGE)/bits
+ cp $(API_HEADERS_I386) $(DESTDIR)/./$(PREFIX)/./$(INCLUDEDIR)/$(PACKAGE)/bits/i386
+ cp $(API_HEADERS_X86_64) $(DESTDIR)/./$(PREFIX)/./$(INCLUDEDIR)/$(PACKAGE)/bits/x86_64
+
+install-shared: shared install-implib
+ mkdir -p $(DESTDIR)/./$(PREFIX)/./$(LIBDIR)
+ cp $(SHARED_LIB) $(DESTDIR)/./$(PREFIX)/./$(LIBDIR)
+
+install-static: static
+ mkdir -p $(DESTDIR)/./$(PREFIX)/./$(LIBDIR)
+ cp $(STATIC_LIB) $(DESTDIR)/./$(PREFIX)/./$(LIBDIR)
+
+
+
+shared: shared-lib shared-implib
+
+static: static-lib
+
+shared-lib: shared-objs $(SHARED_LIB)
+
+static-lib: static-objs $(STATIC_LIB)
+
+shared-implib: shared-lib
+
+
+
+shared-objs: dirs $(SHARED_OBJS)
+
+static-objs: dirs $(STATIC_OBJS)
+
+
+
+$(SHARED_LIB): $(SHARED_OBJS)
+
+$(STATIC_LIB): $(STATIC_OBJS)
+
+
+dirs: dirs.tag tree.tag
+
+dirs.tag:
+ mkdir -p $(LIBDIR)
+ touch dirs.tag
+
+host.tag: Makefile
+ $(PROJECT_DIR)/sysinfo/host/host.sh --compiler="$(CC)" --cflags="$(CFLAGS)"
+ touch host.tag
+
+distclean: clean
+ rm -f Makefile
+
+clean:
+ rm -f tree.tag
+ rm -f dirs.tag
+ rm -f host.tag
+ rm -f $(SHARED_OBJS)
+ rm -f $(STATIC_OBJS)
+ rm -f $(SHARED_LIB)
+ rm -f $(STATIC_LIB)
+ rm -f $(SHARED_IMPLIB)
+
+
+.display: .display-env .display-tools .display-flags \
+ .display-pe .display-elf .display-dirs .display-build
+
+.display-env:
+ @echo BUILD:' '$(BUILD)
+ @echo HOST:' '$(HOST)
+ @echo TARGET:' '$(TARGET)
+ @echo ARCH:' '$(ARCH)
+ @echo TOOLCHAIN:' '$(TOOLCHAIN)
+ @echo SYSROOT:' '$(SYSROOT)
+ @echo XCOMPILE:' '$(CROSS_COMPILE)
+ @echo SHELL:' '$(SHELL)
+
+.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_DEBUG:' '$(CFLAGS_DEBUG)
+ @echo CFLAGS_COMMON:' '$(CFLAGS_COMMON)
+ @echo CFLAGS_CMDLINE:' '$(CFLAGS_CMDLINE)
+ @echo CFLAGS_CONFIG:' '$(CFLAGS_CONFIG)
+ @echo CFLAGS_SYSROOT:' '$(CFLAGS_SYSROOT)
+ @echo CFLAGS_PATH:' '$(CFLAGS_PATH)
+ @echo
+ @echo LDFLAGS_DEBUG:' '$(LDFLAGS_DEBUG)
+ @echo LDFLAGS_COMMON:' '$(LDFLAGS_COMMON)
+ @echo LDFLAGS_CMDLINE:' '$(LDFLAGS_CMDLINE)
+ @echo LDFLAGS_CONFIG:' '$(LDFLAGS_CONFIG)
+ @echo LDFLAGS_SYSROOT:' '$(LDFLAGS_SYSROOT)
+ @echo LDFLAGS_PATH:' '$(LDFLAGS_PATH)
+ @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 BINDIR:' '$(BINDIR)
+ @echo LIBDIR:' '$(LIBDIR)
+ @echo INCLUDEDIR:' '$(INCLUDEDIR)
+ @echo SYSLIBDIR:' '$(SYSLIBDIR)
+ @echo MANDIR:' '$(MANDIR)
+ @echo DOCDIR:' '$(DOCDIR)
+ @echo LIBEXECDIR:' '$(LIBEXECDIR)
+ @echo
+
+.display-build:
+ @echo NATIVE_CC:' '$(NATIVE_CC)
+ @echo NATIVE_OS:' '$(NATIVE_OS)
+ @echo NATIVE_OS_BITS:' '$(NATIVE_OS_BITS)
+ @echo NATIVE_OS_USCORE:' '$(NATIVE_OS_UNDERSCORE)
+ @echo
+
+
+.PHONY: all install shared static .display \
+ shared-objs shared-lib shared-implib \
+ static-objs static-lib \
+ install-shared install-static install-implib \
+ install-headers \
+ clean distclean \
+ .display-env .display-tools .display-flags \
+ .display-pe .display-elf .display-dirs .display-build
diff --git a/config.project b/config.project
new file mode 100644
index 0000000..1bb2c87
--- /dev/null
+++ b/config.project
@@ -0,0 +1,49 @@
+# project
+mb_package=ntapi
+mb_require_out_of_tree=no
+
+
+# dirs
+mb_default_prefix=
+mb_default_bindir=bin
+mb_default_libdir=lib
+mb_default_includedir=include
+mb_default_syslibdir=lib
+mb_default_mandir=man
+mb_default_docdir=doc
+mb_default_libexecdir=libexec
+
+
+# build
+mb_default_build=
+mb_default_host=
+mb_default_target=
+mb_default_arch=
+mb_default_toolchain=
+mb_default_sysroot=
+mb_default_cross_compile=
+mb_default_shell=sh
+
+
+# switches
+mb_default_cflags_debug=
+mb_default_cflags_common="-I\$(PROJECT_DIR)/src/internal -I\$(PROJECT_DIR)/include -Ibuild"
+mb_default_cflags_cmdline=
+mb_default_cflags_config=
+mb_default_cflags_sysroot=
+mb_default_cflags_path=
+
+mb_default_ldflags_debug=
+mb_default_ldflags_common="-Llib"
+mb_default_ldflags_cmdline=
+mb_default_ldflags_config=
+mb_default_ldflags_sysroot=
+mb_default_ldflags_path=
+
+mb_default_pe_subsystem=windows
+mb_default_pe_image_base=
+mb_default_pe_config_defs=
+
+mb_default_elf_eh_frame=
+mb_default_elf_hash_style=
+mb_default_elf_config_defs=
diff --git a/configure b/configure
new file mode 100755
index 0000000..e1651d0
--- /dev/null
+++ b/configure
@@ -0,0 +1,385 @@
+#!/bin/sh
+# we are no longer lazy.
+
+# this script respects both CFLAGS and CFLAGS_CMDLINE,
+# as well as both LDFLAGS and LDFLAGS_CMDLINE, however
+# the latter variable of each pair should be preferred.
+
+error_msg()
+{
+ echo $@ >&2
+}
+
+
+init_vars()
+{
+ mb_project_dir=$(cd `dirname $0` ; pwd)
+ mb_pwd=`pwd`
+
+ if [ x"$mb_config" = x ]; then
+ . $mb_project_dir/config.project || exit 2
+ else
+ . "$mb_config" || exit 2
+ fi
+
+ # dirs
+ mb_prefix=$PREFIX
+ mb_bindir=$BINDIR
+ mb_libdir=$LIBDIR
+ mb_includedir=$INCLUDEDIR
+ mb_syslibdir=$LIBDIR
+ mb_mandir=$MANDIR
+ mb_docdir=$DOCDIR
+ mb_libexecdir=$LIBEXECDIR
+
+
+ # build
+ mb_build=$BUILD
+ mb_host=$HOST
+ mb_target=$TARGET
+ mb_arch=$ARCH
+ 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_path=$CFLAGS_PATH
+
+ 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_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_native_cc=$NATIVE_CC
+ mb_native_os=$NATIVE_OS
+ mb_native_os_bits=$NATIVE_OS_BITS
+ mb_native_os_underscore=$NATIVE_OS_UNDERSCORE
+}
+
+
+verify_build_directory()
+{
+ if [ x"$mb_project_dir" = x"$mb_pwd" ]; then
+ if [ x"$mb_require_out_of_tree" = xyes ]; then
+ error_msg "$mb_package: out-of-tree builds are required."
+ error_msg "please invoke configure again from a clean build directory."
+ exit 2
+ else
+ mb_project_dir='.'
+ fi
+ fi
+}
+
+
+common_defaults()
+{
+ # dirs
+ [ -z "$mb_prefix" ] && mb_prefix=$mb_default_prefix
+ [ -z "$mb_bindir" ] && mb_bindir=$mb_default_bindir
+ [ -z "$mb_libdir" ] && mb_libdir=$mb_default_libdir
+ [ -z "$mb_includedir" ] && mb_includedir=$mb_default_includedir
+ [ -z "$mb_syslibdir" ] && mb_syslibdir=$mb_default_syslibdir
+ [ -z "$mb_mandir" ] && mb_mandir=$mb_default_mandir
+ [ -z "$mb_docdir" ] && mb_docdir=$mb_default_docdir
+ [ -z "$mb_libexecdir" ] && mb_libexecdir=$mb_default_libexecdir
+
+ # build
+ [ -z "$mb_build" ] && mb_build=$mb_default_build
+ [ -z "$mb_host" ] && mb_host=$mb_default_host
+ [ -z "$mb_target" ] && mb_target=$mb_default_target
+ [ -z "$mb_arch" ] && mb_arch=$mb_default_arch
+ [ -z "$mb_toolchain" ] && mb_toolchain=$mb_default_toolchain
+ [ -z "$mb_sysroot" ] && mb_sysroot=$mb_default_sysroot
+ [ -z "$mb_cross_compile" ] && mb_cross_compile=$mb_default_cross_compile
+ [ -z "$mb_shell" ] && mb_shell=$mb_default_shell
+
+ # 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_path" ] && mb_cflags_path=$mb_default_cflags_path
+
+ [ -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_pe_subsystem" ] && mb_pe_subsystem=$mb_default_pe_subsystem
+ [ -z "$mb_pe_image_base" ] && mb_pe_image_base=$mb_default_pe_image_base
+ [ -z "$mb_pe_config_defs" ] && mb_pe_config_defs=$mb_default_pe_config_defs
+
+ [ -z "$mb_elf_eh_frame" ] && mb_elf_eh_frame=$mb_default_elf_eh_frame
+ [ -z "$mb_elf_hash_style" ] && mb_elf_hash_style=$mb_default_elf_hash_style
+ [ -z "$mb_elf_config_defs" ] && mb_elf_config_defs=$mb_default_elf_config_defs
+
+ # host/target
+ [ -z "$mb_host" ] && mb_host=$mb_target
+
+ # sysroot
+ if [ x"$mb_sysroot" != x ]; then
+ if [ x"$mb_cflags_sysroot" = x ]; then
+ mb_cflags_sysroot="--sysroot=$mb_sysroot"
+ fi
+
+ if [ x"$mb_ldflags_sysroot" = x ]; then
+ mb_ldflags_sysroot="-Wl,--sysroot,$mb_sysroot"
+ fi
+ fi
+
+ # debug
+ if [ x"$mb_debug" = xyes ]; then
+ if [ x"$mb_cflags_debug" = x ]; then
+ mb_cflags_debug='-g3 -O0'
+ fi
+ fi
+
+ # toolchain
+ if [ x"$mb_toolchain" != x ]; then
+ if [ x"$mb_native_cc" = x ]; then
+ mb_native_cc=$mb_toolchain
+ fi
+ fi
+}
+
+
+native_defaults()
+{
+ # CC (when set, must be valid)
+ if [ x"$CC" != x ]; then
+ $CC -dM -E - < /dev/null > /dev/null || exit 2
+ fi
+
+ # toolchain
+ [ -z "$mb_native_cc" ] && mb_native_cc=$CC
+ [ -z "$mb_native_cc" ] && mb_native_cc='cc'
+ $mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
+
+ [ -z "$mb_native_cc" ] && mb_native_cc='gcc'
+ $mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
+
+ [ -z "$mb_native_cc" ] && mb_native_cc='clang'
+ $mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
+
+ if [ x"$mb_native_cc" = x ]; then
+ error_msg "config error: could not find a working native compiler."
+ exit 2
+ fi
+
+ if [ x"$mb_toolchain" = x ]; then
+ $mb_native_cc -dM -E - < /dev/null | grep '__clang__' > /dev/null && mb_toolchain='clang'
+ fi
+
+ if [ x"$mb_toolchain" = x ]; then
+ $mb_native_cc -dM -E - < /dev/null | grep '__GCC' > /dev/null && mb_toolchain='gcc'
+ fi
+
+ if [ x"$mb_toolchain" = x ]; then
+ error_msg "config error: could not identify the native compiler."
+ exit 2
+ fi
+
+
+ # host
+ if [ x"$mb_host" = x ]; then
+ mb_host='native'
+ fi
+
+
+ # os
+ mb_native_os=`uname | tr '[:upper:]' '[:lower:]'`
+
+ mb_native_os_sizeof_pointer=`$mb_native_cc -dM -E - < /dev/null \
+ | grep __SIZEOF_POINTER__ \
+ | cut -d ' ' -f3`
+
+ mb_native_os_bits=`expr '8' '*' '0'"$mb_native_os_sizeof_pointer"`
+
+ if [ $mb_native_os_bits = 32 ]; then
+ mb_native_os_underscore='_'
+ else
+ mb_native_os_underscore=''
+ fi
+
+ if [ x"$mb_native_os_sizeof_pointer" = x ]; then
+ error_msg "config error: could not determine size of pointer on native system."
+ exit 2
+ fi
+
+ [ -z "$mb_native_os" ] && mb_native_os=$mb_native_os
+ [ -z "$mb_native_os_bits" ] && mb_native_os_bits=$mb_native_os_bits
+ [ -z "$mb_native_os_underscore" ] && mb_native_os_underscore=$mb_native_os_underscore
+}
+
+
+cross_defaults()
+{
+ if [ x"$mb_cross_compile" = x ] && [ x"$mb_host" != xnative ]; then
+ mb_cross_compile=$mb_host'-'
+ fi
+}
+
+
+config_copy()
+{
+ sed -e 's^@package@^'"$mb_package"'^g' \
+ -e 's^@project_dir@^'"$mb_project_dir"'^g' \
+ \
+ -e 's^@build@^'"$mb_build"'^g' \
+ -e 's^@host@^'"$mb_host"'^g' \
+ -e 's^@target@^'"$mb_target"'^g' \
+ -e 's^@arch@^'"$mb_arch"'^g' \
+ -e 's^@toolchain@^'"$mb_toolchain"'^g' \
+ -e 's^@sysroot@^'"$mb_sysroot"'^g' \
+ -e 's^@cross_compile@^'"$mb_cross_compile"'^g' \
+ -e 's^@shell@^'"$mb_shell"'^g' \
+ \
+ -e 's^@cflags@^'"$mb_cflags"'^g' \
+ -e 's^@cflags_debug@^'"$mb_cflags_debug"'^g' \
+ -e 's^@cflags_common@^'"$mb_cflags_common"'^g' \
+ -e 's^@cflags_cmdline@^'"$mb_cflags $mb_cflags_cmdline"'^g' \
+ -e 's^@cflags_config@^'"$mb_cflags_config"'^g' \
+ -e 's^@cflags_sysroot@^'"$mb_cflags_sysroot"'^g' \
+ -e 's^@cflags_path@^'"$mb_cflags_path"'^g' \
+ \
+ -e 's^@ldflags@^'"$mb_ldflags"'^g' \
+ -e 's^@ldflags_debug@^'"$mb_ldflags_debug"'^g' \
+ -e 's^@ldflags_common@^'"$mb_ldflags_common"'^g' \
+ -e 's^@ldflags_cmdline@^'"$mb_ldflags $mb_ldflags_cmdline"'^g' \
+ -e 's^@ldflags_config@^'"$mb_ldflags_config"'^g' \
+ -e 's^@ldflags_sysroot@^'"$mb_ldflags_sysroot"'^g' \
+ -e 's^@ldflags_path@^'"$mb_ldflags_path"'^g' \
+ \
+ -e 's^@pe_subsystem@^'"$mb_pe_subsystem"'^g' \
+ -e 's^@pe_image\_base@^'"$mb_pe_image_base"'^g' \
+ -e 's^@pe_config\_defs@^'"$mb_pe_config_defs"'^g' \
+ \
+ -e 's^@elf_eh\_frame@^'"$mb_elf_eh_frame"'^g' \
+ -e 's^@elf_hash\_style@^'"$mb_elf_hash_style"'^g' \
+ -e 's^@elf_config\_defs@^'"$mb_elf_config_defs"'^g' \
+ \
+ -e 's^@prefix@^'"$mb_prefix"'^g' \
+ -e 's^@bindir@^'"$mb_bindir"'^g' \
+ -e 's^@libdir@^'"$mb_libdir"'^g' \
+ -e 's^@includedir@^'"$mb_includedir"'^g' \
+ -e 's^@syslibdir@^'"$mb_syslibdir"'^g' \
+ -e 's^@mandir@^'"$mb_mandir"'^g' \
+ -e 's^@docdir@^'"$mb_docdir"'^g' \
+ -e 's^@libexecdir@^'"$mb_libexecdir"'^g' \
+ \
+ -e 's^@native_cc@^'"$mb_native_cc"'^g' \
+ -e 's^@native_os@^'"$mb_native_os"'^g' \
+ -e 's^@native_os_bits@^'"$mb_native_os_bits"'^g' \
+ -e 's^@native_os_underscore@^'"$mb_native_os_underscore"'^g' \
+ $mb_project_dir/Makefile.in > $mb_pwd/Makefile
+}
+
+
+
+# one: init
+init_vars
+verify_build_directory
+
+
+# two: args
+for arg ; do
+ case "$arg" in
+ --help) usage
+ ;;
+
+ # dirs
+ --prefix=*)
+ mb_prefix=${arg#*=}
+ ;;
+ --bindir=*)
+ mb_bindir=${arg#*=}
+ ;;
+ --libdir=*)
+ mb_libdir=${arg#*=}
+ ;;
+ --includedir=*)
+ mb_includedir=${arg#*=}
+ ;;
+ --syslibdir=*)
+ mb_syslibdir=${arg#*=}
+ ;;
+ --mandir=*)
+ mb_mandir=${arg#*=}
+ ;;
+ --libexecdir=*)
+ mb_libexecdir=${arg#*=}
+ ;;
+
+
+ # build
+ --build=*)
+ mb_build=${arg#*=}
+ ;;
+ --host=*)
+ mb_host=${arg#*=}
+ ;;
+ --target=*)
+ mb_target=${arg#*=}
+ ;;
+ --arch=*)
+ mb_arch=${arg#*=}
+ ;;
+ --toolchain=*)
+ mb_toolchain=${arg#*=}
+ ;;
+ --sysroot=*)
+ mb_sysroot=${arg#*=}
+ ;;
+ --cross-compile=*)
+ mb_cross_compile=${arg#*=}
+ ;;
+ --shell=*)
+ mb_shell=${arg#*=}
+ ;;
+ --debug)
+ mb_debug='yes'
+ ;;
+ *)
+ error_msg ${arg#}: "unsupported config argument."
+ exit 2
+ ;;
+ esac
+done
+
+
+
+# three: defaults
+common_defaults
+native_defaults
+cross_defaults
+
+
+
+# four: config
+config_copy
+
+
+# all done
+exit 0
diff --git a/project/arch.mk b/project/arch.mk
new file mode 100644
index 0000000..36202e2
--- /dev/null
+++ b/project/arch.mk
@@ -0,0 +1,13 @@
+# mingw
+ifeq ($(ARCH),w32)
+ ARCH = nt32
+else ifeq ($(ARCH),w64)
+ ARCH = nt64
+endif
+
+# process
+src/process/%.lo: $(PROJECT_DIR)/src/process/$(ARCH)/%.s $(ALL_HEADERS) host.tag
+ $(CC) -c -o $@ $<
+
+src/process/%.o: $(PROJECT_DIR)/src/process/$(ARCH)/%.s $(ALL_HEADERS) host.tag
+ $(CC) -c -o $@ $<
diff --git a/project/common.mk b/project/common.mk
new file mode 100644
index 0000000..abbbb20
--- /dev/null
+++ b/project/common.mk
@@ -0,0 +1,103 @@
+COMMON_SRCS = \
+ src/argv/ntapi_tt_argv_envp.c \
+ src/argv/ntapi_tt_array_utf16.c \
+ src/argv/ntapi_tt_array_utf8.c \
+ src/argv/ntapi_tt_env_vars.c \
+ src/argv/ntapi_tt_get_option.c \
+ src/blitter/ntapi_blt_alloc.c \
+ src/blitter/ntapi_blt_block.c \
+ src/blitter/ntapi_blt_free.c \
+ src/daemon/ntapi_dsr_init.c \
+ src/daemon/ntapi_dsr_internal_connection.c \
+ src/fs/ntapi_tt_get_file_handle_type.c \
+ src/fs/ntapi_tt_istat.c \
+ src/fs/ntapi_tt_mount.c \
+ src/fs/ntapi_tt_open_logical_parent_directory.c \
+ src/fs/ntapi_tt_open_physical_parent_directory.c \
+ src/fs/ntapi_tt_stat.c \
+ src/fs/ntapi_tt_statfs.c \
+ src/guid/ntapi_tt_guid.c \
+ src/hash/ntapi_tt_crc32.c \
+ src/hash/ntapi_tt_populate_hashed_import_table.c \
+ src/internal/ntapi.c \
+ src/internal/ntapi_debug.c \
+ src/internal/ntapi_entry_point.c \
+ src/ipc/ntapi_tt_create_pipe_v1.c \
+ src/ipc/ntapi_tt_create_pipe_v2.c \
+ src/ldr/ntapi_ldr_create_state_snapshot.c \
+ src/ldr/ntapi_ldr_load_system_dll.c \
+ src/ldr/ntapi_ldr_revert_state_to_snapshot.c \
+ src/object/ntapi_tt_keyed_object_directory.c \
+ src/port/ntapi_port_name_helper.c \
+ src/process/ntapi_tt_create_native_process_v1.c \
+ src/process/ntapi_tt_create_native_process_v2.c \
+ src/process/ntapi_tt_create_remote_process_params.c \
+ src/process/ntapi_tt_create_remote_runtime_data.c \
+ src/process/ntapi_tt_fork_v1.c \
+ src/process/ntapi_tt_fork_v2.c \
+ src/process/ntapi_tt_get_runtime_data.c \
+ src/process/ntapi_tt_init_runtime_data.c \
+ src/process/ntapi_tt_map_image_as_data.c \
+ src/process/tt_fork_v1.c \
+ src/pty/ntapi_pty_cancel.c \
+ src/pty/ntapi_pty_fd.c \
+ src/pty/ntapi_pty_io.c \
+ src/pty/ntapi_pty_ioctl.c \
+ src/pty/ntapi_pty_query.c \
+ src/pty/ntapi_pty_set.c \
+ src/section/ntapi_tt_get_section_name.c \
+ src/socket/ntapi_sc_accept.c \
+ src/socket/ntapi_sc_bind_v1.c \
+ src/socket/ntapi_sc_bind_v2.c \
+ src/socket/ntapi_sc_connect_v1.c \
+ src/socket/ntapi_sc_connect_v2.c \
+ src/socket/ntapi_sc_getsockname_v1.c \
+ src/socket/ntapi_sc_getsockname_v2.c \
+ src/socket/ntapi_sc_listen.c \
+ src/socket/ntapi_sc_recv.c \
+ src/socket/ntapi_sc_send.c \
+ src/socket/ntapi_sc_server_accept_connection_v1.c \
+ src/socket/ntapi_sc_server_accept_connection_v2.c \
+ src/socket/ntapi_sc_server_duplicate_socket.c \
+ src/socket/ntapi_sc_shutdown.c \
+ src/socket/ntapi_sc_socket_v1.c \
+ src/socket/ntapi_sc_socket_v2.c \
+ src/socket/ntapi_sc_wait.c \
+ src/string/ntapi_tt_aligned_block_memcpy.c \
+ src/string/ntapi_tt_aligned_block_memset.c \
+ src/string/ntapi_tt_aligned_memcpy_utf16.c \
+ src/string/ntapi_tt_hex_utf16_to_uintptr.c \
+ src/string/ntapi_tt_init_unicode_string_from_utf16.c \
+ src/string/ntapi_tt_memcpy_utf16.c \
+ src/string/ntapi_tt_string_null_offset.c \
+ src/string/ntapi_tt_uintptr_to_hex_utf16.c \
+ src/string/ntapi_tt_uintptr_to_hex_utf8.c \
+ src/sync/ntapi_tt_create_event.c \
+ src/sync/ntapi_tt_sync_block.c \
+ src/sync/ntapi_tt_wait_for_dummy_event.c \
+ src/system/ntapi_tt_get_csr_port_handle_addr_by_logic.c \
+ src/system/ntapi_tt_get_system_directory.c \
+ src/system/ntapi_tt_get_system_info_snapshot.c \
+ src/thread/ntapi_tt_create_thread.c \
+ src/tty/ntapi_tty_client_process_register.c \
+ src/tty/ntapi_tty_client_session_query.c \
+ src/tty/ntapi_tty_client_session_set.c \
+ src/tty/ntapi_tty_connect.c \
+ src/tty/ntapi_tty_create_session.c \
+ src/tty/ntapi_tty_join_session.c \
+ src/tty/ntapi_tty_query_information_server.c \
+ src/tty/ntapi_tty_request_peer.c \
+ src/tty/ntapi_tty_vms_query.c \
+ src/tty/ntapi_tty_vms_request.c \
+ src/unicode/ntapi_uc_unicode_conversion_from_utf16.c \
+ src/unicode/ntapi_uc_unicode_conversion_from_utf8.c \
+ src/unicode/ntapi_uc_unicode_validation.c \
+ src/vfd/ntapi_vfd_helper.c \
+ src/vmount/ntapi_vms_cache.c \
+ src/vmount/ntapi_vms_client_connect.c \
+ src/vmount/ntapi_vms_client_disconnect.c \
+ src/vmount/ntapi_vms_helper.c \
+ src/vmount/ntapi_vms_point_attach.c \
+ src/vmount/ntapi_vms_ref_count.c \
+ src/vmount/ntapi_vms_table_query.c \
+
diff --git a/project/defs.mk b/project/defs.mk
new file mode 100644
index 0000000..1f352be
--- /dev/null
+++ b/project/defs.mk
@@ -0,0 +1,31 @@
+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)
+
+SHARED_OBJS = $(COMMON_LOBJS) $(ARCH_LOBJS)
+STATIC_OBJS = $(COMMON_OBJS) $(ARCH_OBJS)
+
+SHARED_LIB = $(LIBDIR)/$(OS_LIB_PREFIX)$(PACKAGE)$(OS_LIB_SUFFIX)
+STATIC_LIB = $(LIBDIR)/$(OS_LIB_PREFIX)$(PACKAGE)$(OS_ARCHIVE_EXT)
+SHARED_IMPLIB = $(LIBDIR)/$(OS_LIB_PREFIX)$(PACKAGE)$(OS_IMPLIB_EXT)
+
+CFLAGS = $(CFLAGS_DEBUG) $(CFLAGS_CONFIG) $(CFLAGS_SYSROOT) \
+ $(CFLAGS_COMMON) $(CFLAGS_CMDLINE) $(CFLAGS_HOST) \
+ $(CFLAGS_PATH)
+
+CFLAGS_SHARED = $(CFLAGS) $(CFLAGS_PIC) $(CFLAGS_SHARED_ATTR)
+CFLAGS_STATIC = $(CFLAGS) $(CFLAGS_OBJ) $(CFLAGS_STATIC_ATTR)
+
+LDFLAGS_SHARED = $(LDFLAGS_DEBUG) $(LDFLAGS_CONFIG) $(LDFLAGS_SYSROOT) \
+ $(LDFLAGS_COMMON) $(LDFLAGS_CMDLINE) $(LDFLAGS_HOST) \
+ $(LDFLAGS_PATH) $(SHARED_LIB_DEPS) $(LDFLAGS_LAST)
+
+LDFLAGS_STATIC = $(LDFLAGS_DEBUG) $(LDFLAGS_CONFIG) $(LDFLAGS_SYSROOT) \
+ $(LDFLAGS_COMMON) $(LDFLAGS_CMDLINE) $(LDFLAGS_HOST) \
+ $(LDFLAGS_PATH) $(STATIC_APP_DEPS) $(LDFLAGS_LAST)
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..338d3ac
--- /dev/null
+++ b/project/extras.mk
@@ -0,0 +1,16 @@
+CFLAGS_SHARED_ATTR += -DNTAPI_BUILD
+CFLAGS_STATIC_ATTR += -DNTAPI_STATIC
+
+CFLAGS_CONFIG += -DMIDIPIX_FREESTANDING -ffreestanding -D__NT$(HOST_BITS)
+CFLAGS_CONFIG += -UWIN32 -U_WIN32 -U__WIN32 -U__WIN32__
+CFLAGS_CONFIG += -UWIN64 -U_WIN64 -U__WIN64 -U__WIN64__
+
+LDFLAGS_SHARED += --out-implib $(SHARED_IMPLIB)
+LDFLAGS_SHARED += --exclude-all-symbols
+LDFLAGS_SHARED += -lpemagine -ldalist
+
+ifeq ($(HOST_BITS),32)
+ LDFLAGS_SHARED += --entry $(HOST_UNDERSCORE)__ntapi_entry_point@12
+else
+ LDFLAGS_SHARED += --entry $(HOST_UNDERSCORE)__ntapi_entry_point
+endif
diff --git a/project/headers.mk b/project/headers.mk
new file mode 100644
index 0000000..09b3e7c
--- /dev/null
+++ b/project/headers.mk
@@ -0,0 +1,77 @@
+API_HEADERS = \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_acl.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_argv.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_atom.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_atomic.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_auxv.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_blitter.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_crc32.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_daemon.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_debug.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_device.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_exception.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_file.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_fsctl.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_guid.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_hash.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_ioctl.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_ipc.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_istat.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_job.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_ldr.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_locale.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_memory.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_mount.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_object.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_os.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_pnp.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_port.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_process.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_profiling.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_registry.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_section.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_security.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_slist.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_socket.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_stat.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_statfs.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_status.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_string.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_sync.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_sysinfo.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_termios.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_thread.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_time.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_token.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_tty.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_unicode.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_uuid.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_vfd.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./nt_vmount.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./ntapi.h \
+
+API_HEADERS_BITS = \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./bits/nt_atomic_inline_asm.h \
+
+API_HEADERS_I386 = \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./bits/i386/nt_atomic_i386_asm__gcc.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./bits/i386/nt_atomic_i386_asm__msvc.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./bits/i386/nt_thread_i386.h \
+
+API_HEADERS_X86_64 = \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./bits/x86_64/nt_atomic_x86_64_asm__gcc.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./bits/x86_64/nt_atomic_x86_64_asm__msvc.h \
+ $(PROJECT_DIR)/include/$(PACKAGE)/./bits/x86_64/nt_thread_x86_64.h \
+
+INTERNAL_HEADERS = \
+ $(PROJECT_DIR)/src/internal/./ntapi_blitter.h \
+ $(PROJECT_DIR)/src/internal/./ntapi_context.h \
+ $(PROJECT_DIR)/src/internal/./ntapi_fnapi.h \
+ $(PROJECT_DIR)/src/internal/./ntapi_hash_table.h \
+ $(PROJECT_DIR)/src/internal/./ntapi_impl.h \
+ $(PROJECT_DIR)/src/internal/./ntapi_pty.h \
+
+ALL_HEADERS = $(API_HEADERS) $(INTERNAL_HEADERS) \
+ $(API_HEADERS_BITS) \
+ $(API_HEADERS_I386) \
+ $(API_HEADERS_X86_64) \
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/tree.mk b/project/tree.mk
new file mode 100644
index 0000000..fd5144a
--- /dev/null
+++ b/project/tree.mk
@@ -0,0 +1,26 @@
+tree.tag:
+ mkdir -p src
+ mkdir -p src/argv
+ mkdir -p src/blitter
+ mkdir -p src/daemon
+ mkdir -p src/fs
+ mkdir -p src/guid
+ mkdir -p src/hash
+ mkdir -p src/internal
+ mkdir -p src/ipc
+ mkdir -p src/ldr
+ mkdir -p src/object
+ mkdir -p src/port
+ mkdir -p src/process
+ mkdir -p src/pty
+ mkdir -p src/section
+ mkdir -p src/socket
+ mkdir -p src/string
+ mkdir -p src/sync
+ mkdir -p src/system
+ mkdir -p src/thread
+ mkdir -p src/tty
+ mkdir -p src/unicode
+ mkdir -p src/vfd
+ mkdir -p src/vmount
+ touch tree.tag
diff --git a/src/internal/ntapi_lib_entry_point.c b/src/internal/ntapi_entry_point.c
index 8b857c8..bca857d 100644
--- a/src/internal/ntapi_lib_entry_point.c
+++ b/src/internal/ntapi_entry_point.c
@@ -6,7 +6,7 @@
#include <psxtypes/psxtypes.h>
-int __stdcall __ntapi_entry(void * hinstance, uint32_t reason, void * reserved)
+int __stdcall __ntapi_entry_point(void * hinstance, uint32_t reason, void * reserved)
{
return 1;
}
diff --git a/sysinfo/host/host.sh b/sysinfo/host/host.sh
new file mode 100755
index 0000000..1fe2515
--- /dev/null
+++ b/sysinfo/host/host.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+error_msg()
+{
+ echo $@ >&2
+}
+
+host_test()
+{
+ mb_hdrdir=$(pwd)/build
+ mkdir -p $mb_hdrdir || exit 2
+
+ if [ x"$mb_compiler" = x ]; then
+ echo "config error: compiler not set."
+ exit 2
+ fi
+
+ $mb_compiler -dM -E - < /dev/null > /dev/null && return 0
+
+ error_msg "config error: invalid compiler."
+ exit 2
+}
+
+
+# one: args
+for arg ; do
+ case "$arg" in
+ --help) usage
+ ;;
+ --compiler=*)
+ mb_compiler=${arg#*=}
+ ;;
+ --cflags=*)
+ mb_cflags=${arg#*=}
+ ;;
+ *)
+ error_msg ${arg#}: "unsupported config argument."
+ exit 2
+ ;;
+ esac
+done
+
+
+# two: test
+host_test
+
+
+# all done
+exit 0
diff --git a/sysinfo/host/i686-nt32-midipix.mk b/sysinfo/host/i686-nt32-midipix.mk
new file mode 100644
index 0000000..df3185b
--- /dev/null
+++ b/sysinfo/host/i686-nt32-midipix.mk
@@ -0,0 +1,5 @@
+include $(PROJECT_DIR)/sysinfo/os/midipix.mk
+
+ARCH = nt32
+HOST_BITS = 32
+HOST_UNDERSCORE = '_'
diff --git a/sysinfo/host/i686-unknown-linux.mk b/sysinfo/host/i686-unknown-linux.mk
new file mode 100644
index 0000000..79d497b
--- /dev/null
+++ b/sysinfo/host/i686-unknown-linux.mk
@@ -0,0 +1,5 @@
+include $(PROJECT_DIR)/sysinfo/os/linux.mk
+
+ARCH = i386
+HOST_BITS = 32
+HOST_UNDERSCORE = '_'
diff --git a/sysinfo/host/i686-w64-mingw32.mk b/sysinfo/host/i686-w64-mingw32.mk
new file mode 100644
index 0000000..b8ba461
--- /dev/null
+++ b/sysinfo/host/i686-w64-mingw32.mk
@@ -0,0 +1,5 @@
+include $(PROJECT_DIR)/sysinfo/os/mingw.mk
+
+ARCH = w32
+HOST_BITS = 32
+HOST_UNDERSCORE = '_'
diff --git a/sysinfo/host/native.mk b/sysinfo/host/native.mk
new file mode 100644
index 0000000..465a01b
--- /dev/null
+++ b/sysinfo/host/native.mk
@@ -0,0 +1,46 @@
+include $(PROJECT_DIR)/sysinfo/os/$(NATIVE_OS).mk
+
+CC = $(CROSS_COMPILE)$(NATIVE_CC)
+OS = $(NATIVE_OS)
+HOST_BITS = $(NATIVE_OS_BITS)
+HOST_UNDERSCORE = $(NATIVE_OS_UNDERSCORE)
+
+ifeq ($(OS),linux)
+ ifeq ($(HOST_BITS),32)
+ ARCH = i386
+ else ifeq ($(HOST_BITS),64)
+ ARCH = x86_64
+ endif
+endif
+
+ifeq ($(OS),midipix)
+ ifeq ($(HOST_BITS),32)
+ ARCH = nt32
+ else ifeq ($(HOST_BITS),64)
+ ARCH = nt64
+ endif
+endif
+
+ifeq ($(OS),mingw)
+ ifeq ($(HOST_BITS),32)
+ ARCH = w32
+ else ifeq ($(HOST_BITS),64)
+ ARCH = w64
+ endif
+endif
+
+ifeq ($(OS),bsd)
+ ifeq ($(HOST_BITS),32)
+ ARCH = bsd32
+ else ifeq ($(HOST_BITS),64)
+ ARCH = bsd64
+ endif
+endif
+
+ifeq ($(OS),darwin)
+ ifeq ($(HOST_BITS),32)
+ ARCH = dw32
+ else ifeq ($(HOST_BITS),64)
+ ARCH = dw64
+ endif
+endif
diff --git a/sysinfo/host/x86_64-nt64-midipix.mk b/sysinfo/host/x86_64-nt64-midipix.mk
new file mode 100644
index 0000000..fef6345
--- /dev/null
+++ b/sysinfo/host/x86_64-nt64-midipix.mk
@@ -0,0 +1,5 @@
+include $(PROJECT_DIR)/sysinfo/os/midipix.mk
+
+ARCH = nt64
+HOST_BITS = 64
+HOST_UNDERSCORE = ''
diff --git a/sysinfo/host/x86_64-unknown-linux.mk b/sysinfo/host/x86_64-unknown-linux.mk
new file mode 100644
index 0000000..76afb56
--- /dev/null
+++ b/sysinfo/host/x86_64-unknown-linux.mk
@@ -0,0 +1,5 @@
+include $(PROJECT_DIR)/sysinfo/os/linux.mk
+
+ARCH = x86_64
+HOST_BITS = 64
+HOST_UNDERSCORE = ''
diff --git a/sysinfo/host/x86_64-w64-mingw32.mk b/sysinfo/host/x86_64-w64-mingw32.mk
new file mode 100644
index 0000000..7cded15
--- /dev/null
+++ b/sysinfo/host/x86_64-w64-mingw32.mk
@@ -0,0 +1,5 @@
+include $(PROJECT_DIR)/sysinfo/os/mingw.mk
+
+ARCH = w64
+HOST_BITS = 64
+HOST_UNDERSCORE = ''
diff --git a/sysinfo/os/bsd.mk b/sysinfo/os/bsd.mk
new file mode 100644
index 0000000..3fe6711
--- /dev/null
+++ b/sysinfo/os/bsd.mk
@@ -0,0 +1,10 @@
+OS = bsd
+OS_APP_PREFIX =
+OS_APP_SUFFIX =
+OS_LIB_PREFIX = lib
+OS_LIB_SUFFIX = .so
+OS_IMPLIB_EXT = .invalid
+OS_LIBDEF_EXT = .invalid
+OS_ARCHIVE_EXT = .a
+
+.PHONY: $(SHARED_IMPLIB)
diff --git a/sysinfo/os/darwin.mk b/sysinfo/os/darwin.mk
new file mode 100644
index 0000000..b27a486
--- /dev/null
+++ b/sysinfo/os/darwin.mk
@@ -0,0 +1,10 @@
+OS = darwin
+OS_APP_PREFIX =
+OS_APP_SUFFIX =
+OS_LIB_PREFIX = lib
+OS_LIB_SUFFIX = .dylib
+OS_IMPLIB_EXT = .invalid
+OS_LIBDEF_EXT = .invalid
+OS_ARCHIVE_EXT = .a
+
+.PHONY: $(SHARED_IMPLIB)
diff --git a/sysinfo/os/linux.mk b/sysinfo/os/linux.mk
new file mode 100644
index 0000000..d6221cf
--- /dev/null
+++ b/sysinfo/os/linux.mk
@@ -0,0 +1,10 @@
+OS = linux
+OS_APP_PREFIX =
+OS_APP_SUFFIX =
+OS_LIB_PREFIX = lib
+OS_LIB_SUFFIX = .so
+OS_IMPLIB_EXT = .invalid
+OS_LIBDEF_EXT = .invalid
+OS_ARCHIVE_EXT = .a
+
+.PHONY: $(SHARED_IMPLIB)
diff --git a/sysinfo/os/midipix.mk b/sysinfo/os/midipix.mk
new file mode 100644
index 0000000..4e197b9
--- /dev/null
+++ b/sysinfo/os/midipix.mk
@@ -0,0 +1,12 @@
+OS = midipix
+OS_APP_PREFIX =
+OS_APP_SUFFIX =
+OS_LIB_PREFIX = lib
+OS_LIB_SUFFIX = .so
+OS_IMPLIB_EXT = .lib.a
+OS_LIBDEF_EXT = .so.def
+OS_ARCHIVE_EXT = .a
+
+install-implib: shared-implib
+ mkdir -p $(DESTDIR)/./$(PREFIX)/./$(LIBDIR)
+ cp $(SHARED_IMPLIB) $(DESTDIR)/./$(PREFIX)/./$(LIBDIR)
diff --git a/sysinfo/os/mingw.mk b/sysinfo/os/mingw.mk
new file mode 100644
index 0000000..196dbd8
--- /dev/null
+++ b/sysinfo/os/mingw.mk
@@ -0,0 +1,14 @@
+OS = mingw
+OS_APP_PREFIX =
+OS_APP_SUFFIX = .exe
+OS_LIB_PREFIX = lib
+OS_LIB_SUFFIX = .dll
+OS_IMPLIB_EXT = .dll.a
+OS_LIBDEF_EXT = .def
+OS_ARCHIVE_EXT = .a
+
+CFLAGS_PIC =
+
+install-implib: shared-implib
+ mkdir -p $(DESTDIR)/./$(PREFIX)/./$(LIBDIR)
+ cp $(SHARED_IMPLIB) $(DESTDIR)/./$(PREFIX)/./$(LIBDIR)
diff --git a/sysinfo/toolchain/clang.mk b/sysinfo/toolchain/clang.mk
new file mode 100644
index 0000000..d239319
--- /dev/null
+++ b/sysinfo/toolchain/clang.mk
@@ -0,0 +1,34 @@
+ifeq ($(CROSS_COMPILE)x,x)
+ CROSS_HOST =
+ CROSS_HOST_SPEC =
+else
+ CROSS_HOST = $(HOST)
+ CROSS_HOST_SPEC = --target=$(HOST)
+endif
+
+
+CC = $(NATIVE_CC) $(CROSS_HOST_SPEC)
+CPP = $(NATIVE_CC) $(CROSS_HOST_SPEC)
+CXX = $(NATIVE_CC)++ $(CROSS_HOST_SPEC)
+
+
+AS = $(CROSS_COMPILE)as
+AR = $(CROSS_COMPILE)ar
+LD = $(CROSS_COMPILE)ld
+NM = $(CROSS_COMPILE)nm
+OBJDUMP = $(CROSS_COMPILE)objdump
+RANLIB = $(CROSS_COMPILE)ranlib
+SIZE = $(CROSS_COMPILE)size
+STRIP = $(CROSS_COMPILE)strip
+STRINGS = $(CROSS_COMPILE)strings
+
+
+ADDR2LINE = $(CROSS_COMPILE)addr2line
+COV = $(CROSS_COMPILE)gcov
+CXXFILT = $(CROSS_COMPILE)c++filt
+ELFEDIT = $(CROSS_COMPILE)elfedit
+OBJCOPY = $(CROSS_COMPILE)objcopy
+READELF = $(CROSS_COMPILE)readelf
+
+
+CFLAGS_PIC = -fPIC
diff --git a/sysinfo/toolchain/gcc.mk b/sysinfo/toolchain/gcc.mk
new file mode 100644
index 0000000..441a2ca
--- /dev/null
+++ b/sysinfo/toolchain/gcc.mk
@@ -0,0 +1,25 @@
+CC = $(CROSS_COMPILE)gcc
+CPP = $(CROSS_COMPILE)cpp
+CXX = $(CROSS_COMPILE)c++
+
+
+AS = $(CROSS_COMPILE)as
+AR = $(CROSS_COMPILE)ar
+LD = $(CROSS_COMPILE)ld
+NM = $(CROSS_COMPILE)nm
+OBJDUMP = $(CROSS_COMPILE)objdump
+RANLIB = $(CROSS_COMPILE)ranlib
+SIZE = $(CROSS_COMPILE)size
+STRIP = $(CROSS_COMPILE)strip
+STRINGS = $(CROSS_COMPILE)strings
+
+
+ADDR2LINE = $(CROSS_COMPILE)addr2line
+COV = $(CROSS_COMPILE)gcov
+CXXFILT = $(CROSS_COMPILE)c++filt
+ELFEDIT = $(CROSS_COMPILE)elfedit
+OBJCOPY = $(CROSS_COMPILE)objcopy
+READELF = $(CROSS_COMPILE)readelf
+
+
+CFLAGS_PIC = -fPIC