Blame m4/slibtool.m4

ad93f0
###############################################################################
ad93f0
#                                                                             #
ad93f0
#   slibtool.m4: native slibtool integration for autoconf-based projects      #
ad93f0
#                                                                             #
bb281c
#   Copyright (C) 2021  SysDeer Technologies, LLC                             #
ad93f0
#                                                                             #
ad93f0
#   Permission is hereby granted, free of charge, to any person obtaining     #
ad93f0
#   a copy of this software and associated documentation files (the           #
ad93f0
#   "Software"), to deal in the Software without restriction, including       #
ad93f0
#   without limitation the rights to use, copy, modify, merge, publish,       #
ad93f0
#   distribute, sublicense, and/or sell copies of the Software, and to        #
ad93f0
#   permit persons to whom the Software is furnished to do so, subject to     #
ad93f0
#   the following conditions:                                                 #
ad93f0
#                                                                             #
ad93f0
#   The above copyright notice and this permission notice shall be included   #
ad93f0
#   in all copies or substantial portions of the Software.                    #
ad93f0
#                                                                             #
ad93f0
#   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS   #
ad93f0
#   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF                #
ad93f0
#   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.    #
ad93f0
#   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY      #
ad93f0
#   CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,      #
ad93f0
#   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE         #
ad93f0
#   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                    #
ad93f0
#                                                                             #
ad93f0
###############################################################################
ad93f0
ad93f0
ad93f0
ad93f0
# _SLIBTOOL_DEFAULTS
ad93f0
# ------------------
ad93f0
AC_DEFUN([_SLIBTOOL_DEFAULTS],[
ad93f0
AC_BEFORE([$0],[SLIBTOOL_INIT])
ad93f0
AC_BEFORE([$0],[_SLIBTOOL_ARGUMENT_HANDLING])
ad93f0
ad93f0
# slibtool: implementation defaults
ad93f0
# ---------------------------------
ad93f0
slibtool_enable_shared_default='yes'
ad93f0
slibtool_enable_static_default='yes'
ad93f0
slibtool_enable_dlopen_default='yes'
ad93f0
slibtool_enable_win32_dll_default='yes'
ad93f0
slibtool_enable_fast_install_default='yes'
ad93f0
slibtool_pic_mode_default='default'
5a20d9
slibtool_sysroot_default=
ad93f0
])
ad93f0
ad93f0
ad93f0
# _SLIBTOOL_ARGUMENT_HANDLING
ad93f0
# ---------------------------
ad93f0
AC_DEFUN([_SLIBTOOL_ARGUMENT_HANDLING],[
ad93f0
AC_BEFORE([$0],[_SLIBTOOL_ARG_ENABLE])
ad93f0
AC_BEFORE([$0],[_SLIBTOOL_ARG_WITH])
ad93f0
ad93f0
# slibtool: argument handling
ad93f0
# ---------------------------
ad93f0
slibtool_arg_enable()
ad93f0
{
ad93f0
	case "${enableval}" in
ad93f0
		'yes')
ad93f0
			slbt_eval_expr="${slbt_var}='yes'"
ad93f0
			eval $slbt_eval_expr
ad93f0
			;;
ad93f0
ad93f0
		'no')
ad93f0
			slbt_eval_expr="${slbt_var}='no'"
ad93f0
			eval $slbt_eval_expr
ad93f0
			;;
ad93f0
ad93f0
		*)
ad93f0
			slbt_package="${PACKAGE:-default}"
ad93f0
ad93f0
			slbt_eval_expr="${slbt_var}='no'"
ad93f0
			eval $slbt_eval_expr
ad93f0
ad93f0
			slbt_cfg_ifs="${IFS}"
ad93f0
			IFS="${PATH_SEPARATOR}${IFS}"
ad93f0
ad93f0
			for slbt_pkg in ${enableval}; do
b23a2f
				if [[ "_${slbt_pkg}" = "_${slbt_package}" ]]; then
ad93f0
					slbt_eval_expr="${slbt_var}='yes'"
ad93f0
					eval $slbt_eval_expr
ad93f0
				fi
ad93f0
			done
ad93f0
ad93f0
			IFS="${slbt_cfg_ifs}"
ad93f0
			unset slbt_cfg_ifs
ad93f0
			;;
ad93f0
	esac
ad93f0
}
ad93f0
ad93f0
ad93f0
slibtool_arg_with()
ad93f0
{
5a20d9
	case "${slbt_var}" in
5a20d9
		'slibtool_sysroot')
5a20d9
			case "${withval}" in
5a20d9
				'yes')
5a20d9
					slbt_eval_expr="${slbt_var}='yes'"
5a20d9
					eval $slbt_eval_expr
5a20d9
					;;
5a20d9
5a20d9
				'no')
5a20d9
					slbt_eval_expr="${slbt_var}='no'"
5a20d9
					eval $slbt_eval_expr
5a20d9
					;;
5a20d9
5a20d9
				*)
5a20d9
					slbt_eval_expr="${slbt_var}=${withval}"
5a20d9
					eval $slbt_eval_expr
5a20d9
					;;
5a20d9
			esac
5a20d9
5a20d9
			;;
5a20d9
5a20d9
		*)
5a20d9
			enableval="${withval}"
5a20d9
			slibtool_arg_enable
5a20d9
			;;
5a20d9
	esac
ad93f0
}
ad93f0
])
ad93f0
ad93f0
ad93f0
# _SLIBTOOL_ARG_ENABLE(_feature_,_help_string_,_var_)
ad93f0
# ---------------------------------------------------
ad93f0
AC_DEFUN([_SLIBTOOL_ARG_ENABLE],[
ad93f0
AC_ARG_ENABLE($1,
ad93f0
[AS_HELP_STRING([--enable-]$1[@<:@=PKGS@:>@],$2  @<:@default=[$]$3_default@:>@)],[
ad93f0
  slbt_var=$3
ad93f0
  slibtool_arg_enable],[dnl
ad93f0
$3=[$]$3_default])
ad93f0
])
ad93f0
ad93f0
ad93f0
# _SLIBTOOL_ARG_WITH(_feature_,_help_string_,_var_)
ad93f0
# -------------------------------------------------
ad93f0
AC_DEFUN([_SLIBTOOL_ARG_WITH],[
ad93f0
AC_ARG_WITH($1,
ad93f0
[AS_HELP_STRING([--with-]$1[@<:@=PKGS@:>@],$2  @<:@default=[$]$3_default@:>@)],[
ad93f0
  slbt_var=$3
ad93f0
  slibtool_arg_with],[dnl
ad93f0
$3=[$]$3_default])
ad93f0
])
ad93f0
ad93f0
ad93f0
# _SLIBTOOL_SET_FLAVOR
ad93f0
# --------------------
ad93f0
AC_DEFUN([_SLIBTOOL_SET_FLAVOR],[
ad93f0
AC_BEFORE([$0],[SLIBTOOL_INIT])
ad93f0
ad93f0
# slibtool: set SLIBTOOL to the default/package-default/user-requested flavor
ad93f0
# ---------------------------------------------------------------------------
ad93f0
slibtool_set_flavor()
ad93f0
{
ad93f0
	case "_${slibtool_enable_shared}_${slibtool_enable_static}" in
ad93f0
		'_yes_yes')
ad93f0
			SLIBTOOL='dlibtool'
ad93f0
			;;
ad93f0
ad93f0
		'_yes_no')
ad93f0
			SLIBTOOL='dlibtool-shared'
ad93f0
			;;
ad93f0
ad93f0
		'_no_yes')
ad93f0
			SLIBTOOL='dlibtool-static'
ad93f0
			;;
ad93f0
ad93f0
		'_no_no')
ad93f0
			SLIBTOOL='false'
ad93f0
			;;
ad93f0
ad93f0
		*)
ad93f0
			SLIBTOOL='false'
1ca682
			slibtool_enable_shared='no'
1ca682
			slibtool_enable_static='no'
ad93f0
			;;
ad93f0
	esac
ad93f0
5a20d9
	case "_${slibtool_sysroot}" in
5a20d9
		'_')
5a20d9
			;;
5a20d9
5a20d9
		'_yes'|'_no')
5a20d9
			slibtool_err_arg=[$with_sysroot]
5a20d9
			slibtool_err_msg='slibtool: the command-line --sysroot argument is always respected.'
5a20d9
			AC_MSG_RESULT([slibtool: --with-sysroot=$slibtool_err_arg])
5a20d9
			AC_MSG_ERROR([$slibtool_err_msg])
5a20d9
			;;
5a20d9
5a20d9
		_/*)
5a20d9
			SLIBTOOL_SYSROOT="--sysroot=${slibtool_sysroot}"
5a20d9
			SLIBTOOL="${SLIBTOOL} \$(SLIBTOOL_SYSROOT)"
5a20d9
			;;
5a20d9
5a20d9
		*)
5a20d9
			slibtool_err_arg=[$with_sysroot]
5a20d9
			slibtool_err_msg='slibtool: relative sysroot paths are not supported.'
5a20d9
			AC_MSG_RESULT([slibtool: --with-sysroot=$slibtool_err_arg])
5a20d9
			AC_MSG_ERROR([$slibtool_err_msg])
5a20d9
			;;
5a20d9
	esac
5a20d9
ad93f0
	# drop-in replacement
ad93f0
	enable_shared=${slibtool_enable_shared}
ad93f0
	enable_static=${slibtool_enable_static}
ad93f0
	enable_dlopen=${slibtool_enable_dlopen}
ad93f0
	enable_win32_dll=${slibtool_enable_win32_dll}
ad93f0
	enable_fast_install=${slibtool_enable_fast_install}
ad93f0
	pic_mode=${slibtool_pic_mode}
1ca682
1ca682
	# backward-compatible heuristics support
1ca682
	printf "%s\n%s=%s\n%s=%s\n" \
1ca682
		'#!/dev/null'        \
1ca682
		'build_libtool_libs' "${slibtool_enable_shared}" \
1ca682
		'build_old_libs'     "${slibtool_enable_static}"  \
1ca682
		> libtool
ad93f0
}
ad93f0
])
ad93f0
ad93f0
ba1cf4
# SLIBTOOL_ENABLE_SHARED
ba1cf4
# ----------------------
ba1cf4
AC_DEFUN([SLIBTOOL_ENABLE_SHARED],[
ba1cf4
AC_BEFORE([$0],[SLIBTOOL_INIT])
ba1cf4
ba1cf4
# slibtool: SLIBTOOL_ENABLE_SHARED
ba1cf4
# --------------------------------
ba1cf4
slibtool_options="${slibtool_options:-}"
ba1cf4
slibtool_options="${slibtool_options} shared"
ba1cf4
])
ba1cf4
ba1cf4
ba1cf4
# SLIBTOOL_ENABLE_STATIC
ba1cf4
# ----------------------
ba1cf4
AC_DEFUN([SLIBTOOL_ENABLE_STATIC],[
ba1cf4
AC_BEFORE([$0],[SLIBTOOL_INIT])
ba1cf4
ba1cf4
# slibtool: SLIBTOOL_ENABLE_STATIC
ba1cf4
# --------------------------------
ba1cf4
slibtool_options="${slibtool_options:-}"
ba1cf4
slibtool_options="${slibtool_options} static"
ba1cf4
])
ba1cf4
ba1cf4
ba1cf4
# SLIBTOOL_DISABLE_SHARED
ba1cf4
# -----------------------
ba1cf4
AC_DEFUN([SLIBTOOL_DISABLE_SHARED],[
ba1cf4
AC_BEFORE([$0],[SLIBTOOL_INIT])
ba1cf4
ba1cf4
# slibtool: SLIBTOOL_DISABLE_SHARED
ba1cf4
# ---------------------------------
ba1cf4
slibtool_options="${slibtool_options:-}"
ba1cf4
slibtool_options="${slibtool_options} disable-shared"
ba1cf4
])
ba1cf4
ba1cf4
ba1cf4
# SLIBTOOL_DISABLE_STATIC
ba1cf4
# -----------------------
ba1cf4
AC_DEFUN([SLIBTOOL_DISABLE_STATIC],[
ba1cf4
AC_BEFORE([$0],[SLIBTOOL_INIT])
ba1cf4
ba1cf4
# slibtool: SLIBTOOL_DISABLE_STATIC
ba1cf4
# ---------------------------------
ba1cf4
slibtool_options="${slibtool_options:-}"
ba1cf4
slibtool_options="${slibtool_options} disable-static"
ba1cf4
])
ba1cf4
ba1cf4
240d0f
# SLIBTOOL_PROG_NM
240d0f
# ----------------
240d0f
AC_DEFUN([SLIBTOOL_PROG_NM],[
240d0f
240d0f
# slibtool: SLIBTOOL_PROG_NM
240d0f
# --------------------------
240d0f
if [[ -z "${NM:-}" ]]; then
240d0f
	NM="${RANLIB%ranlib}nm"
240d0f
fi
240d0f
240d0f
AC_SUBST([NM])
240d0f
])
240d0f
240d0f
ad93f0
# SLIBTOOL_INIT(_options_)
ad93f0
# ------------------------
ad93f0
AC_DEFUN([SLIBTOOL_INIT],[
3db17d
AC_BEFORE([SLIBTOOL_LANG])
666643
AC_REQUIRE([SLIBTOOL_PREREQ])
ad93f0
AC_REQUIRE([_SLIBTOOL_DEFAULTS])
ad93f0
AC_REQUIRE([_SLIBTOOL_SET_FLAVOR])
ad93f0
AC_REQUIRE([_SLIBTOOL_ARGUMENT_HANDLING])
ad93f0
ad93f0
ad93f0
# slibtool: package defaults
ad93f0
# ---------------------
ad93f0
slbt_cfg_ifs="${IFS}"
ad93f0
IFS="${PATH_SEPARATOR}${IFS}"
ad93f0
ba1cf4
for slbt_opt in $@ ${slibtool_options:-}; do
ad93f0
	case "${slbt_opt}" in
ad93f0
		'shared')
ad93f0
			slibtool_enable_shared_default='yes'
ad93f0
			;;
ad93f0
ad93f0
		'disable-shared')
ad93f0
			slibtool_enable_shared_default='no'
ad93f0
			;;
ad93f0
ad93f0
		'static')
ad93f0
			slibtool_enable_static_default='yes'
ad93f0
			;;
ad93f0
ad93f0
		'disable-static')
ad93f0
			slibtool_enable_static_default='no'
ad93f0
			;;
ad93f0
ad93f0
		'dlopen')
ad93f0
			slibtool_enable_dlopen_default='yes'
ad93f0
			;;
ad93f0
ad93f0
		'disable-dlopen')
ad93f0
			slibtool_enable_dlopen_default='no'
ad93f0
			;;
ad93f0
ad93f0
		'win32-dll')
ad93f0
			slibtool_enable_win32_dll_default='yes'
ad93f0
			;;
ad93f0
ad93f0
		'disable-win32-dll')
ad93f0
			slibtool_enable_win32_dll_default='no'
ad93f0
			;;
ad93f0
ad93f0
		'fast-install')
ad93f0
			slibtool_enable_fast_install_default='yes'
ad93f0
			;;
ad93f0
ad93f0
		'disable-fast-install')
ad93f0
			slibtool_enable_fast_install_default='no'
ad93f0
			;;
ad93f0
ad93f0
		'pic-only')
ad93f0
			slibtool_pic_mode_default='yes'
ad93f0
			;;
ad93f0
ad93f0
		'no-pic')
ad93f0
			slibtool_pic_mode_default='no'
ad93f0
			;;
ad93f0
	esac
ad93f0
done
ad93f0
ad93f0
IFS="${slbt_cfg_ifs}"
ad93f0
unset slbt_cfg_ifs
ad93f0
ad93f0
ad93f0
# slibtool: features and argument handline
ad93f0
# ----------------------------------------
ad93f0
_SLIBTOOL_ARG_ENABLE([shared],[build shared libraries],[slibtool_enable_shared])
ad93f0
_SLIBTOOL_ARG_ENABLE([static],[build static libraries],[slibtool_enable_static])
ad93f0
_SLIBTOOL_ARG_ENABLE([dlopen],[allow -dlopen and -dlpreopen],[slibtool_enable_dlopen])
ad93f0
_SLIBTOOL_ARG_ENABLE([win32-dll],[natively support win32 dll's],[slibtool_enable_win32_dll])
ad93f0
_SLIBTOOL_ARG_ENABLE([fast-install],[optimize for fast installation],[slibtool_enable_fast_install])
ad93f0
_SLIBTOOL_ARG_WITH([pic],[override defaults for pic object usage],[slibtool_pic_mode])
5a20d9
_SLIBTOOL_ARG_WITH([sysroot],[absolute path to the target's sysroot],[slibtool_sysroot])
ad93f0
ad93f0
ad93f0
# slibtool: set flavor
ad93f0
# --------------------
ad93f0
slibtool_set_flavor
32cc7d
LIBTOOL='$(SLIBTOOL)'
ad93f0
ad93f0
AC_SUBST([LIBTOOL])
ad93f0
AC_SUBST([SLIBTOOL])
5a20d9
AC_SUBST([SLIBTOOL_SYSROOT])
ad93f0
m4_define([SLIBTOOL_INIT])
ad93f0
])
ad93f0
ad93f0
3db17d
# SLIBTOOL_LANG(_language_)
3db17d
# -------------------------
3db17d
AC_DEFUN([SLIBTOOL_LANG],[
3db17d
AC_REQUIRE([SLIBTOOL_PREREQ])
3db17d
])
3db17d
3db17d
49c143
# SLIBTOOL_PREREQ(_version_)
ad93f0
# --------------------------
ad93f0
AC_DEFUN([SLIBTOOL_PREREQ],[
666643
666643
AC_REQUIRE([AC_PROG_CC])
666643
AC_REQUIRE([AC_PROG_CPP])
666643
AC_REQUIRE([AC_PROG_CXX])
364947
AC_REQUIRE([AC_PROG_CXXCPP])
666643
666643
AC_REQUIRE([AC_PROG_OBJC])
666643
AC_REQUIRE([AC_PROG_OBJCPP])
666643
666643
AC_REQUIRE([AC_PROG_FC])
666643
AC_REQUIRE([AC_PROG_F77])
666643
666643
AC_REQUIRE([AC_PROG_AWK])
666643
AC_REQUIRE([AC_PROG_LEX])
666643
AC_REQUIRE([AC_PROG_SED])
666643
AC_REQUIRE([AC_PROG_YACC])
666643
666643
AC_REQUIRE([AC_PROG_RANLIB])
666643
666643
AC_REQUIRE([AC_PROG_LN_S])
666643
AC_REQUIRE([AC_PROG_MKDIR_P])
666643
7b8d49
m4_ifndef([AC_PROG_OBJCXX],     [AC_DEFUN([AC_PROG_OBJCXX],[AC_SUBST([OBJCXX])])])
7b8d49
m4_ifndef([AC_PROG_OBJCXXCPP],  [AC_DEFUN([AC_PROG_OBJCXXCPP],[AC_SUBST([OBJCXXCPP])])])
7b8d49
666643
AC_PROG_CC
666643
AC_PROG_CPP
666643
AC_PROG_CXX
364947
AC_PROG_CXXCPP
666643
666643
AC_PROG_OBJC
666643
AC_PROG_OBJCPP
666643
AC_PROG_OBJCXX
364947
AC_PROG_OBJCXXCPP
666643
666643
AC_PROG_FC
666643
AC_PROG_F77
666643
666643
AC_PROG_AWK
666643
AC_PROG_LEX
666643
AC_PROG_SED
666643
AC_PROG_YACC
666643
666643
AC_PROG_RANLIB
240d0f
AC_PROG_NM
666643
666643
AC_PROG_LN_S
666643
AC_PROG_MKDIR_P
ad93f0
])
ad93f0
ad93f0
ad93f0
# drop-in replacement
ad93f0
# -------------------
ad93f0
AC_DEFUN([LT_INIT],             [SLIBTOOL_INIT($@)])
3db17d
AC_DEFUN([LT_LANG],             [SLIBTOOL_LANG($@)])
ad93f0
AC_DEFUN([LT_PREREQ],           [SLIBTOOL_PREREQ($@)])
ad93f0
ad93f0
AC_DEFUN([AC_PROG_LIBTOOL],     [SLIBTOOL_INIT($@)])
ad93f0
AC_DEFUN([AM_PROG_LIBTOOL],     [SLIBTOOL_INIT($@)])
ba1cf4
240d0f
AC_DEFUN([AC_PROG_NM],          [SLIBTOOL_PROG_NM($@)])
240d0f
AC_DEFUN([AM_PROG_NM],          [SLIBTOOL_PROG_NM($@)])
240d0f
ba1cf4
AC_DEFUN([AC_ENABLE_SHARED],    [SLIBTOOL_ENABLE_SHARED($@)])
ba1cf4
AC_DEFUN([AM_ENABLE_SHARED],    [SLIBTOOL_ENABLE_SHARED($@)])
ba1cf4
ba1cf4
AC_DEFUN([AC_ENABLE_STATIC],    [SLIBTOOL_ENABLE_STATIC($@)])
ba1cf4
AC_DEFUN([AM_ENABLE_STATIC],    [SLIBTOOL_ENABLE_STATIC($@)])
ba1cf4
ba1cf4
AC_DEFUN([AC_DISABLE_SHARED],   [SLIBTOOL_DISABLE_SHARED($@)])
ba1cf4
AC_DEFUN([AM_DISABLE_SHARED],   [SLIBTOOL_DISABLE_SHARED($@)])
ba1cf4
ba1cf4
AC_DEFUN([AC_DISABLE_STATIC],   [SLIBTOOL_DISABLE_STATIC($@)])
ba1cf4
AC_DEFUN([AM_DISABLE_STATIC],   [SLIBTOOL_DISABLE_STATIC($@)])
129f8a
129f8a
129f8a
# deprecated and no-op macros
129f8a
# ---------------------------
129f8a
AC_DEFUN([AC_LIBTOOL_DLOPEN],[])
129f8a
AC_DEFUN([AC_LIBTOOL_WIN32_DLL],[])
129f8a
AC_DEFUN([AC_DISABLE_FAST_INSTALL],[])