summaryrefslogtreecommitdiff
path: root/acsite.m4
diff options
context:
space:
mode:
authorkx <kx@radix-linux.su>2026-10-09 18:00:15 +0300
committerkx <kx@radix-linux.su>2026-10-09 18:00:15 +0300
commit065da3509019b15dd0e678072e6be629e5330bef (patch)
tree69c934c9e786ac048b4fbe8f4c4c5571661521f4 /acsite.m4
parentd130fe27fa753be02ed76fd9b277aa3c3d928eb9 (diff)
downloadlibmcpu-0.4.0.tar.xz
Version 0.4.00.4.0
Diffstat (limited to 'acsite.m4')
-rw-r--r--acsite.m4417
1 files changed, 417 insertions, 0 deletions
diff --git a/acsite.m4 b/acsite.m4
new file mode 100644
index 0000000..8de5c55
--- /dev/null
+++ b/acsite.m4
@@ -0,0 +1,417 @@
+dnl ============================================================
+dnl Force configure to run under /bin/bash
+dnl ============================================================
+m4_define([AC_MCPU_REQUIRE_BASH], [dnl
+m4_divert_push([M4SH-SANITIZE])dnl
+
+if test ! -x /bin/bash; then
+ echo "configure: error: /bin/bash is required" >&2
+ exit 1
+fi
+
+CONFIG_SHELL=/bin/bash
+export CONFIG_SHELL
+
+m4_divert_pop([M4SH-SANITIZE])dnl
+])dnl
+
+
+dnl ============================================================
+dnl Support for Configuration Headers
+dnl
+dnl configure.ac:
+dnl AC_MCPU_HEADLINE(<short-name>, <long-name>,
+dnl <vers-var>, <copyright>)
+dnl ============================================================
+m4_define([AC_MCPU_HEADLINE], [dnl
+m4_divert_push([M4SH-INIT])dnl
+{
+ if test ".`echo dummy [$]@ | grep help`" = .; then
+
+ ####### Use a `Quadrigaph'. '@<:@' gives you [ and '@:>@' gives you ] :
+ TB=`echo -n -e '\033@<:@1m'`
+ TN=`echo -n -e '\033@<:@0m'`
+
+ ####### Get the short product version from AC_INIT().
+ $3="AC_PACKAGE_VERSION"
+ AC_SUBST($3)
+
+ ####### Print configuration headline.
+ echo "Configuring:"
+ echo ""
+ echo "${TB}$1${TN} ($2), Version ${TB}${$3}${TN}"
+ echo "$4"
+ echo ""
+ fi
+}
+m4_divert_pop([M4SH-INIT])dnl
+])dnl
+
+
+dnl ============================================================
+dnl Display Configuration Headers
+dnl
+dnl configure.ac:
+dnl AC_MSG_CFG_PART(<text>)
+dnl ============================================================
+AC_DEFUN([AC_MSG_CFG_PART],[dnl
+ AC_MSG_RESULT()
+ AC_MSG_RESULT([${TB}$1:${TN}])
+])dnl
+
+
+dnl ============================================================
+dnl GNU GCC is required by LibMCPU.
+dnl ============================================================
+AC_DEFUN([MCPU_REQUIRE_GCC], [dnl
+ AC_MSG_CHECKING([whether $CC is GNU GCC])
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([[
+#if !defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER)
+#error LibMCPU requires GNU GCC
+#endif
+int main( void ) { return 0; }
+ ]])
+ ], [
+ AC_MSG_RESULT([yes])
+ ], [
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([LibMCPU requires GNU GCC])
+ ])
+])
+
+
+dnl ============================================================
+dnl Provide the Autoconf state required by cpu/sysdeps/*/
+dnl preconfigure.ac fragments. The generated preconfigure files
+dnl are sourced by the top-level configure after AC_PROG_CC.
+dnl ============================================================
+define([MCPU_PROVIDES], [dnl
+AC_PROVIDE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+AC_PROVIDE([AC_CONFIG_SUBDIRS])dnl
+AC_PROVIDE([_AS_ECHO_N_PREPARE])dnl
+AC_PROVIDE([_AS_ECHO_PREPARE])dnl
+AC_PROVIDE([_AS_CR_PREPARE])dnl
+AC_PROVIDE([_AS_TR_SH_PREPARE])dnl
+AC_PROVIDE([_AS_VAR_ARITH_PREPARE])dnl
+AC_PROVIDE([AC_PROG_INSTALL])dnl
+AC_PROVIDE([AC_PROG_CC])dnl
+AC_PROVIDE([AC_PROG_CPP])dnl
+AC_PROVIDE([_AS_PATH_SEPARATOR_PREPARE])dnl
+AC_PROVIDE([_AS_TEST_PREPARE])dnl
+AC_PROVIDE([_AS_BASENAME_PREPARE])dnl
+AC_PROVIDE([_AS_ME_PREPARE])dnl
+AC_PROVIDE([_AS_LINENO_PREPARE])dnl
+AC_PROVIDE([AS_SHELL_FN_as_fn_set_status])dnl
+AC_PROVIDE([AS_SHELL_FN_as_fn_exit])dnl
+AC_PROVIDE([AS_SHELL_FN_as_fn_arith])dnl
+AC_PROVIDE([AS_SHELL_FN_ac_fn_c_try_compile])dnl
+define([AS_MESSAGE_LOG_FD],5)dnl
+define([AS_MESSAGE_FD],6)dnl
+m4_wrap([m4_divert_pop([BODY])[]])
+m4_divert_push([BODY])[]dnl
+# This file is generated from preconfigure.ac by Autoconf. DO NOT EDIT!
+define([_AC_LANG], [C])dnl
+])dnl
+
+
+dnl ============================================================
+dnl Find and source cpu/sysdeps/*/preconfigure fragments.
+dnl
+dnl MCPU_PRECONFIGURE([$srcdir], [for cpu/sysdeps])
+dnl ============================================================
+AC_DEFUN([MCPU_PRECONFIGURE], [dnl
+if frags=`ls -d $1/cpu/sysdeps/*/preconfigure 2> /dev/null`
+then
+ AC_MSG_CHECKING([$2 preconfigure fragments])
+ mcpu_frag_names=
+ for frag in $frags; do
+ name=`echo "$frag" | sed 's@/[[^/]]*[$]@@;s@^.*/@@'`
+ mcpu_frag_names="$mcpu_frag_names $name"
+ done
+ AC_MSG_RESULT([$mcpu_frag_names])
+ for frag in $frags; do
+ . "$frag"
+ done
+fi
+])
+
+
+dnl ============================================================
+dnl Build the ordered cpu/sysdeps search path for the configured
+dnl HOST. The algorithm follows the historical LibMPU sysdeps
+dnl model: architecture preconfigure fragments may refine MACHINE
+dnl (including the ABI/data model), existing OS/CPU directories are
+dnl discovered from the most specific to the most generic, and
+dnl Implies/Implies-before/Implies-after expand the inheritance
+dnl chain before cpu/sysdeps/generic is appended.
+dnl
+dnl Substitutions:
+dnl base_machine canonical base host architecture
+dnl submachine optional --with-cpu suffix
+dnl MCPU_HOST_MACHINE refined machine[/data-model]
+dnl MCPU_HOST_DATA_MODEL ILP32/LP64/... selected by preconfigure
+dnl sysnames ordered source lookup directories
+dnl ============================================================
+AC_DEFUN([MCPU_SYSDEP_DIR_NAMES], [dnl
+case "$host_os" in
+ linux*) ;;
+ gnu*) host_os=`echo "$host_os" | sed -e 's/gnu/gnu-gnu/'` ;;
+esac
+
+config_machine=$host_cpu
+config_vendor=$host_vendor
+config_os=$host_os
+
+test "$config_vendor" = unknown && config_vendor=
+config_os="`echo "$config_os" | sed 's/^unknown-//'`"
+
+machine=$config_machine
+vendor=$config_vendor
+os=$config_os
+base_os=''
+base_machine=
+MCPU_HOST_DATA_MODEL=
+
+submachine=
+AC_ARG_WITH([cpu],
+ AS_HELP_STRING([--with-cpu=CPU], [select host CPU variant for sysdeps]),
+ [dnl
+ case "$withval" in
+ yes | '') AC_MSG_ERROR([--with-cpu requires an argument]) ;;
+ no) ;;
+ *) submachine="$withval" ;;
+ esac
+ ])
+
+AC_ARG_ENABLE([debug-configure],
+ AS_HELP_STRING([--enable-debug-configure],
+ [show detailed cpu/sysdeps directory selection @<:@default=no@:>@]),
+ [enable_debug_configure=$enableval],
+ [enable_debug_configure=no])
+case "$enable_debug_configure" in
+ no) enable_debug_configure='' ;;
+ *) ;;
+esac
+
+MCPU_PRECONFIGURE([$srcdir], [for cpu/sysdeps])
+
+test -n "$base_machine" || base_machine=$machine
+AC_SUBST([base_machine])
+AC_SUBST([submachine])
+
+sysdep_dir=$srcdir/cpu/sysdeps
+AC_MSG_CHECKING([cpu sysdep dirs])
+os="`echo "$os" | sed 's/\([[0-9A-Z]]\)[[v_]]\([[0-9A-Z]]\)/\1.\2/g'`"
+
+test "x$base_os" != x || case "$os" in
+ linux*) base_os=unix/sysv ;;
+esac
+
+# OS candidates: linux-gnu, linux, etc.
+tail=$os
+ostry=$os
+while o=`echo "$tail" | sed 's/\.[[^.]]*$//'`; test "$o" != "$tail"; do
+ ostry="$ostry /$o"
+ tail=$o
+done
+o=`echo "$tail" | sed 's/[[0-9]]*$//'`
+if test "$o" != "$tail"; then
+ ostry="$ostry /$o"
+fi
+o=`echo "$tail" | sed 's/-.*$//'`
+if test "$o" != "$tail"; then
+ ostry="$ostry /$o"
+fi
+
+# Base OS hierarchy: unix/sysv -> unix/sysv, unix.
+base=
+tail=$base_os
+while b=`echo "$tail" | sed 's@^\(.*\)/\([[^/]]*\)[$]@& \1@'`; test -n "$b"; do
+ set $b
+ base="$base /[$]1"
+ tail="[$]2"
+done
+
+# Machine hierarchy: x86_64/64 -> x86_64/64, x86_64.
+mach=
+tail=$machine${submachine:+/$submachine}
+while m=`echo "$tail" | sed 's@^\(.*\)/\([[^/]]*\)[$]@& \1@'`; test -n "$m"; do
+ set $m
+ mach="$mach /[$]1"
+ tail="[$]2"
+done
+
+sysnames=
+os_used=
+machine_used=
+submachine_used=
+for b in $base ''; do
+ for m0 in $mach ''; do
+ for v in /$vendor ''; do
+ test "$v" = / && continue
+ for o in /$ostry ''; do
+ test "$o" = / && continue
+ for m in $mach ''; do
+ try_suffix="$m0$b$v$o$m"
+ if test -n "$try_suffix"; then
+ try="cpu/sysdeps$try_suffix"
+ test -n "$enable_debug_configure" && echo "configure: sysdeps try: $try" >&2
+ if test -d "$srcdir/$try"; then
+ case " $sysnames " in
+ *" $try "*) ;;
+ *) sysnames="$sysnames $try" ;;
+ esac
+ { test -n "$o" || test -n "$b"; } && os_used=t
+ { test -n "$m" || test -n "$m0"; } && machine_used=t
+ case x${m0:-$m} in
+ x*/$submachine) test -n "$submachine" && submachine_used=t ;;
+ esac
+ fi
+ fi
+ done
+ done
+ done
+ done
+done
+
+# The sysdeps layer is deliberately narrower than the generic C build.
+# If LibMPU itself was not usable AC_CHECK_LIBMPU has already stopped
+# configure. Here we additionally require a known LibMCPU host OS/CPU
+# hierarchy; generic alone never constitutes a supported HOST.
+if test -z "$os_used" && test "$os" != none; then
+ AC_MSG_ERROR([Not supported HOST $host: no cpu/sysdeps operating-system hierarchy for $os])
+fi
+if test -z "$machine_used" && test "$machine" != none; then
+ AC_MSG_ERROR([Not supported HOST $host: no cpu/sysdeps machine hierarchy for $machine])
+fi
+if test -n "$submachine" && test -z "$submachine_used"; then
+ AC_MSG_ERROR([Not supported HOST $host: CPU variant $submachine is not represented in cpu/sysdeps])
+fi
+
+# Expand existing names through parent directories and Implies files.
+set $sysnames
+names=
+while test [$]# -gt 0; do
+ name=[$]1
+ shift
+
+ case " $names " in
+ *" $name "*) continue ;;
+ esac
+
+ name_base=`echo "$name" | sed -e 's@\(.*cpu/sysdeps\)/.*@\1@'`
+
+ Implies=
+ Implies_before=
+ Implies_after=
+ for implies_file in Implies Implies-before Implies-after; do
+ implies_type=`echo "$implies_file" | sed 's/-/_/'`
+ eval ${implies_type}=
+ if test -f "$srcdir/$name/$implies_file"; then
+ implied_candidate="`sed 's/#.*$//' < "$srcdir/$name/$implies_file"`"
+ for x in $implied_candidate; do
+ found=no
+ try="$name_base/$x"
+ test -n "$enable_debug_configure" && echo "configure: $name/$implies_file -> $try" >&2
+ if test -d "$srcdir/$try"; then
+ eval "${implies_type}=\"\$${implies_type} \$try\""
+ found=yes
+ fi
+ if test "$found" = no; then
+ AC_MSG_WARN([$name/$implies_file specifies nonexistent $x])
+ fi
+ done
+ fi
+ done
+
+ names="$names $name"
+
+changequote(,)dnl
+ parent="`echo "$name" | sed -n -e 's=/[^/]*$==' -e '/cpu\/sysdeps$/q' -e p`"
+changequote([,])dnl
+
+ test -n "$enable_debug_configure" &&
+ echo "configure: sysdeps select: $name; implies='$Implies'; parent='$parent'; before='$Implies_before'; after='$Implies_after'" >&2
+
+ sysnames="`echo $Implies [$]* $Implies_before $parent $Implies_after`"
+ test -n "$sysnames" && set $sysnames
+done
+
+default_sysnames="cpu/sysdeps/generic"
+sysnames="`echo $names $default_sysnames`"
+MCPU_HOST_MACHINE=$machine
+
+AC_SUBST([MCPU_HOST_MACHINE])
+AC_SUBST([MCPU_HOST_DATA_MODEL])
+AC_SUBST([sysnames])
+
+AC_MSG_RESULT([$sysnames])
+])
+
+AC_DEFUN([AC_LIBMCPU_LT_VERSION_INFO],
+[AC_MSG_CHECKING(for MCPU Library Version Information)
+#
+# Made LT_VERSION_INFO (may be used libtool-next-version from libtool-2.6.2):
+#
+# LT_VERSION_INFO="current:revision:age"
+#
+info="$1"
+
+current=`echo ${info} | cut -f1 -d':'`
+revision=`echo ${info} | cut -f2 -d':'`
+age=`echo ${info} | cut -f3 -d':'`
+
+ac_cv_libmcpu_lt_release="${current}.${revision}"
+ac_cv_libmcpu_lt_current="${current}"
+ac_cv_libmcpu_lt_revision="${revision}"
+ac_cv_libmcpu_lt_age="${age}"
+
+ac_cv_libmcpu_lt_version_info="${current}:${revision}:${age}"
+
+AC_SUBST(LIBMCPU_LT_RELEASE, $ac_cv_libmcpu_lt_release)
+AC_SUBST(LIBMCPU_LT_VERSION_INFO, $ac_cv_libmcpu_lt_version_info)
+AC_SUBST(LIBMCPU_LT_CURRENT, $ac_cv_libmcpu_lt_current)
+AC_SUBST(LIBMCPU_LT_REVISION, $ac_cv_libmcpu_lt_revision)
+AC_SUBST(LIBMCPU_LT_AGE, $ac_cv_libmcpu_lt_age)
+
+AC_MSG_RESULT($ac_cv_libmcpu_lt_version_info)
+if test "$ac_cv_libmcpu_lt_version_info" = ""; then
+AC_MSG_ERROR([
+******** ${TB}The MCPU Library Version Information does not declared.${TN}])
+fi
+])
+
+
+dnl ============================================================
+dnl Test if LD_LIBRARY_PATH contains the notation for the
+dnl current directory since this would lead to problems
+dnl installing/building kxlibc .
+dnl
+dnl LD_LIBRARY_PATH contains the current directory if one
+dnl of the following is true:
+dnl - one of the terminals (":" and ";") is the first or
+dnl last sign;
+dnl - two terminals occur directly after each other;
+dnl - the path contains an element with a dot in it .
+dnl ============================================================
+AC_DEFUN([AC_LD_LIBRARY_PATH],
+[AC_MSG_CHECKING(for LD_LIBRARY_PATH does not contain current directory)
+changequote(,)dnl
+case ${LD_LIBRARY_PATH} in
+ [:\;]* | *[:\;] | *[:\;][:\;]* | *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
+ ld_library_path_setting="contains current directory"
+ ;;
+ *)
+ ld_library_path_setting="ok"
+ ;;
+esac
+changequote([,])dnl
+AC_MSG_RESULT($ld_library_path_setting)
+if test "$ld_library_path_setting" != "ok"; then
+AC_MSG_ERROR([
+******** ${TB}LD_LIBRARY_PATH shouldn't contain the current directory when${TN}
+******** ${TB}building MCPU Library. Please change the environment variable${TN}
+******** ${TB}and run configure again.${TN}])
+fi
+])