diff options
Diffstat (limited to 'm4/slibtool.m4')
-rw-r--r-- | m4/slibtool.m4 | 284 |
1 files changed, 235 insertions, 49 deletions
diff --git a/m4/slibtool.m4 b/m4/slibtool.m4 index 024eecb..25c37a3 100644 --- a/m4/slibtool.m4 +++ b/m4/slibtool.m4 @@ -2,7 +2,7 @@ # # # slibtool.m4: native slibtool integration for autoconf-based projects # # # -# Copyright (C) 2021 Z. Gilboa # +# Copyright (C) 2016--2024 SysDeer Technologies, LLC # # # # Permission is hereby granted, free of charge, to any person obtaining # # a copy of this software and associated documentation files (the # @@ -44,6 +44,29 @@ slibtool_pic_mode_default='default' slibtool_sysroot_default= ]) +# slibtool: refined logic for ar, nm, ranlib, etc. +# +m4_ifdef([SLIBTOOL_INIT],[],[ +# +m4_ifdef([AC_PROG_AR], [m4_undefine([AC_PROG_AR])]) +m4_ifdef([AM_PROG_AR], [m4_undefine([AM_PROG_AR])]) + +m4_ifdef([AC_PROG_NM], [m4_undefine([AC_PROG_NM])]) +m4_ifdef([AM_PROG_NM], [m4_undefine([AM_PROG_NM])]) + +m4_ifdef([AC_PROG_RANLIB], [m4_undefine([AC_PROG_RANLIB])]) +m4_ifdef([AM_PROG_RANLIB], [m4_undefine([AM_PROG_RANLIB])]) + +m4_ifdef([AC_PROG_LEX], [m4_undefine([AC_PROG_LEX])]) +m4_ifdef([AM_PROG_LEX], [m4_undefine([AM_PROG_LEX])]) + +m4_ifdef([LT_LIB_M], [m4_undefine([LT_LIB_M])]) +m4_ifdef([LT_LIB_DLLOAD], [m4_undefine([LT_LIB_DLLOAD])]) +]) + +# _SLIBTOOL_CONVENIENCE +# --------------------- +AC_DEFUN([LT_DEVAL],[$1]=[$2]) # _SLIBTOOL_ARGUMENT_HANDLING # --------------------------- @@ -152,17 +175,47 @@ AC_BEFORE([$0],[SLIBTOOL_INIT]) # --------------------------------------------------------------------------- slibtool_set_flavor() { + if [[ -z "${SLIBTOOL:-}" ]]; then + SLIBTOOL="${LIBTOOL:-}" + fi + + _slibtool="${SLIBTOOL:-slibtool}" + + if [[ "${_slibtool%/*}" = "${_slibtool}" ]]; then + _slibtool_path= + else + _slibtool_path="${_slibtool%/*}/" + fi + + case "${_slibtool##*/}" in + 'rlibtool') + SLIBTOOL="${_slibtool_path}"'slibtool' + ;; + + 'rclibtool') + SLIBTOOL="${_slibtool_path}"'clibtool' + ;; + + 'rdlibtool') + SLIBTOOL="${_slibtool_path}"'dlibtool' + ;; + + 'rdclibtool') + SLIBTOOL="${_slibtool_path}"'dclibtool' + ;; + esac + case "_${slibtool_enable_shared}_${slibtool_enable_static}" in '_yes_yes') - SLIBTOOL='dlibtool' + SLIBTOOL="${SLIBTOOL:-slibtool}" ;; '_yes_no') - SLIBTOOL='dlibtool-shared' + SLIBTOOL="${SLIBTOOL:-slibtool}-shared" ;; '_no_yes') - SLIBTOOL='dlibtool-static' + SLIBTOOL="${SLIBTOOL:-slibtool}-static" ;; '_no_no') @@ -207,13 +260,6 @@ slibtool_set_flavor() enable_win32_dll=${slibtool_enable_win32_dll} enable_fast_install=${slibtool_enable_fast_install} pic_mode=${slibtool_pic_mode} - - # backward-compatible heuristics support - printf "%s\n%s=%s\n%s=%s\n" \ - '#!/dev/null' \ - 'build_libtool_libs' "${slibtool_enable_shared}" \ - 'build_old_libs' "${slibtool_enable_static}" \ - > libtool } ]) @@ -266,17 +312,119 @@ slibtool_options="${slibtool_options} disable-static" ]) +# SLIBTOOL_PROG_AR +# ---------------- +AC_DEFUN([SLIBTOOL_PROG_AR],[ + +# slibtool: SLIBTOOL_PROG_AR +# -------------------------- +if [[ -n "${host_alias}" ]]; then + AC_CHECK_PROG([AR],"${host_alias}-"[ar],"${host_alias}-"[ar]) +fi + +if [[ -n "${host}" ]] && [[ "${host}" != "${host_alias:-}" ]] && [[ -z "${AR}" ]]; then + AC_CHECK_PROG([AR],"${host}-"[ar],"${host}-"[ar]) +fi + +if [[ -n "${host}" ]] && [[ -z "${AR}" ]]; then + AC_CHECK_PROG([AR],[llvm-ar],[llvm-ar]) +fi + +if [[ -z "${host}" ]]; then + AC_CHECK_PROG([AR],[ar],[ar]) +fi +]) + + +# SLIBTOOL_PROG_RANLIB +# -------------------- +AC_DEFUN([SLIBTOOL_PROG_RANLIB],[ + +# slibtool: SLIBTOOL_PROG_RANLIB +# ------------------------------ +if [[ -n "${host_alias}" ]]; then + AC_CHECK_PROG([RANLIB],"${host_alias}-"[ranlib],"${host_alias}-"[ranlib]) +fi + +if [[ -n "${host}" ]] && [[ "${host}" != "${host_alias:-}" ]] && [[ -z "${RANLIB}" ]]; then + AC_CHECK_PROG([RANLIB],"${host}-"[ranlib],"${host}-"[ranlib]) +fi + +if [[ -n "${host}" ]] && [[ -z "${RANLIB}" ]]; then + AC_CHECK_PROG([RANLIB],[llvm-ranlib],[llvm-ranlib]) +fi + +if [[ -z "${host}" ]]; then + AC_CHECK_PROG([RANLIB],[ranlib],[ranlib]) +fi +]) + + # SLIBTOOL_PROG_NM # ---------------- AC_DEFUN([SLIBTOOL_PROG_NM],[ # slibtool: SLIBTOOL_PROG_NM # -------------------------- -if [[ -z "${NM:-}" ]]; then - NM="${RANLIB%ranlib}nm" +if [[ -n "${host_alias}" ]]; then + AC_CHECK_PROG([NM],"${host_alias}-"[nm],"${host_alias}-"[nm]) +fi + +if [[ -n "${host}" ]] && [[ "${host}" != "${host_alias:-}" ]] && [[ -z "${NM}" ]]; then + AC_CHECK_PROG([NM],"${host}-"[nm],"${host}-"[nm]) +fi + +if [[ -n "${host}" ]] && [[ -z "${NM}" ]]; then + AC_CHECK_PROG([NM],[llvm-nm],[llvm-nm]) fi -AC_SUBST([NM]) +if [[ -z "${host}" ]]; then + AC_CHECK_PROG([NM],[nm],[nm]) +fi +]) + + +# SLIBTOOL_PROG_LEX +# ----------------- +AC_DEFUN([SLIBTOOL_PROG_LEX],[ + +# slibtool: SLIBTOOL_PROG_LEX +# --------------------------- +if [[ -n "${LEX}" ]]; then + AC_CHECK_PROG([LEX],[flex]) +fi + +if [[ -z "${LEX}" ]]; then + AC_CHECK_PROG([LEX],[flex],[flex]) +fi + +if [[ -z "${LEX}" ]]; then + AC_CHECK_PROG([LEX],[lex],[lex]) +fi + +AC_SUBST([LEX]) +AC_SUBST([LEXLIB]) +]) + + +# SLIBTOOL_LFLAG_LIBM +# ------------------- +AC_DEFUN([SLIBTOOL_LFLAG_LIBM],[ + +# slibtool: SLIBTOOL_LFLAG_LIBM +# ----------------------------- +LT_DEVAL([LIBM],[-lm]) +AC_SUBST([LIBM]) +]) + + +# SLIBTOOL_LFLAG_LTDL +# ------------------- +AC_DEFUN([SLIBTOOL_LFLAG_LTDL],[ + +# slibtool: SLIBTOOL_LFLAG_LTDL +# ----------------------------- +# (always use the system lib[s]ltdl) ]) @@ -290,6 +438,14 @@ AC_REQUIRE([_SLIBTOOL_SET_FLAVOR]) AC_REQUIRE([_SLIBTOOL_ARGUMENT_HANDLING]) +# slibtool: tame legacy early invocation +AC_DEFUN([AC_PROG_LEX]) +AC_DEFUN([AM_PROG_LEX]) + +AC_DEFUN([AC_PROG_RANLIB]) +AC_DEFUN([AM_PROG_RANLIB]) + + # slibtool: package defaults # --------------------- slbt_cfg_ifs="${IFS}" @@ -366,11 +522,12 @@ _SLIBTOOL_ARG_WITH([sysroot],[absolute path to the target's sysroot],[slibtool_s # -------------------- slibtool_set_flavor LIBTOOL='$(SLIBTOOL)' +SLIBTOOL="${SLIBTOOL} \$(SLIBTOOL_FLAGS)" AC_SUBST([LIBTOOL]) AC_SUBST([SLIBTOOL]) +AC_SUBST([SLIBTOOL_FLAGS]) AC_SUBST([SLIBTOOL_SYSROOT]) -m4_define([SLIBTOOL_INIT]) ]) @@ -378,75 +535,94 @@ m4_define([SLIBTOOL_INIT]) # ------------------------- AC_DEFUN([SLIBTOOL_LANG],[ AC_REQUIRE([SLIBTOOL_PREREQ]) -]) - - -# SLIBTOOL_PREREQ(_version_) -# -------------------------- -AC_DEFUN([SLIBTOOL_PREREQ],[ - -AC_REQUIRE([AC_PROG_CC]) -AC_REQUIRE([AC_PROG_CPP]) -AC_REQUIRE([AC_PROG_CXX]) -AC_REQUIRE([AC_PROG_CXXCPP]) - -AC_REQUIRE([AC_PROG_OBJC]) -AC_REQUIRE([AC_PROG_OBJCPP]) -AC_REQUIRE([AC_PROG_FC]) -AC_REQUIRE([AC_PROG_F77]) - -AC_REQUIRE([AC_PROG_AWK]) -AC_REQUIRE([AC_PROG_LEX]) -AC_REQUIRE([AC_PROG_SED]) -AC_REQUIRE([AC_PROG_YACC]) - -AC_REQUIRE([AC_PROG_RANLIB]) - -AC_REQUIRE([AC_PROG_LN_S]) -AC_REQUIRE([AC_PROG_MKDIR_P]) +# slibtool: SLIBTOOL_LANG(C) +m4_if([$1],[C],[ +AC_PROG_CC +AC_PROG_CPP +]) -m4_ifndef([AC_PROG_OBJCXX], [AC_DEFUN([AC_PROG_OBJCXX],[AC_SUBST([OBJCXX])])]) -m4_ifndef([AC_PROG_OBJCXXCPP], [AC_DEFUN([AC_PROG_OBJCXXCPP],[AC_SUBST([OBJCXXCPP])])]) +m4_if([$1],[C++],[ +# slibtool: SLIBTOOL_LANG(C++) AC_PROG_CC AC_PROG_CPP AC_PROG_CXX AC_PROG_CXXCPP +]) -AC_PROG_OBJC -AC_PROG_OBJCPP -AC_PROG_OBJCXX -AC_PROG_OBJCXXCPP - +m4_if([$1],[Fortran 77],[ +# slibtool: SLIBTOOL_LANG(Fortran 77) AC_PROG_FC AC_PROG_F77 +]) +]) + + +# produce a backward compatible slibtool.cfg +AC_CONFIG_COMMANDS_PRE( + AC_CONFIG_FILES( + [slibtool.cfg:Makefile], + [rm -f slibtool.cfg || exit 2;] + [_slibtool="${SLIBTOOL:-slibtool}";] + [${_slibtool%% *} --mkvars=Makefile --config > slibtool.cfg])) + +# optionally create libtool as a symlink to slibtool.sh +AC_CONFIG_COMMANDS_PRE( + [if [[ -s slibtool.sh ]]; then + ln -f -s slibtool.sh libtool || exit 2 + fi]) + + +# SLIBTOOL_PREREQ(_version_) +# -------------------------- +AC_DEFUN([SLIBTOOL_PREREQ],[ AC_PROG_AWK AC_PROG_LEX AC_PROG_SED AC_PROG_YACC -AC_PROG_RANLIB +AC_PROG_AR AC_PROG_NM +AC_PROG_RANLIB AC_PROG_LN_S AC_PROG_MKDIR_P ]) +# SLIBTOOL_OUTPUT +# --------------- +AC_DEFUN([SLIBTOOL_OUTPUT],[ +_slibtool_cmd="${SLIBTOOL:-slibtool}" +_slibtool_cmd="${_slibtool_cmd%% *}" +_slibtool_aux_dir=$("${_slibtool_cmd}" -print-aux-dir) +cp -p "${_slibtool_aux_dir}/slibtool.sh" 'libtool' +]) + # drop-in replacement # ------------------- AC_DEFUN([LT_INIT], [SLIBTOOL_INIT($@)]) AC_DEFUN([LT_LANG], [SLIBTOOL_LANG($@)]) AC_DEFUN([LT_PREREQ], [SLIBTOOL_PREREQ($@)]) +AC_DEFUN([LT_OUTPUT], [SLIBTOOL_OUTPUT($@)]) AC_DEFUN([AC_PROG_LIBTOOL], [SLIBTOOL_INIT($@)]) AC_DEFUN([AM_PROG_LIBTOOL], [SLIBTOOL_INIT($@)]) +AC_DEFUN([AC_PROG_AR], [SLIBTOOL_PROG_AR($@)]) +AC_DEFUN([AM_PROG_AR], [SLIBTOOL_PROG_AR($@)]) + AC_DEFUN([AC_PROG_NM], [SLIBTOOL_PROG_NM($@)]) AC_DEFUN([AM_PROG_NM], [SLIBTOOL_PROG_NM($@)]) +AC_DEFUN([AC_PROG_RANLIB], [SLIBTOOL_PROG_RANLIB($@)]) +AC_DEFUN([AM_PROG_RANLIB], [SLIBTOOL_PROG_RANLIB($@)]) + +AC_DEFUN([AC_PROG_LEX], [SLIBTOOL_PROG_LEX($@)]) +AC_DEFUN([AM_PROG_LEX], [SLIBTOOL_PROG_LEX($@)]) + AC_DEFUN([AC_ENABLE_SHARED], [SLIBTOOL_ENABLE_SHARED($@)]) AC_DEFUN([AM_ENABLE_SHARED], [SLIBTOOL_ENABLE_SHARED($@)]) @@ -459,9 +635,19 @@ AC_DEFUN([AM_DISABLE_SHARED], [SLIBTOOL_DISABLE_SHARED($@)]) AC_DEFUN([AC_DISABLE_STATIC], [SLIBTOOL_DISABLE_STATIC($@)]) AC_DEFUN([AM_DISABLE_STATIC], [SLIBTOOL_DISABLE_STATIC($@)]) +AC_DEFUN([LT_LIB_M], [SLIBTOOL_LFLAG_LIBM($@)]) +AC_DEFUN([LT_LIB_DLLOAD], [SLIBTOOL_LFLAG_LTDL($@)]) + # deprecated and no-op macros # --------------------------- AC_DEFUN([AC_LIBTOOL_DLOPEN],[]) AC_DEFUN([AC_LIBTOOL_WIN32_DLL],[]) AC_DEFUN([AC_DISABLE_FAST_INSTALL],[]) +AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC],[]) + +AC_DEFUN([LT_PATH_AR],[]) +AC_DEFUN([LT_PATH_AS],[]) +AC_DEFUN([LT_PATH_LD],[]) +AC_DEFUN([LT_PATH_NM],[]) +AC_DEFUN([LT_PATH_RANLIB],[]) |