diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-10-28 19:47:21 +0100 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-10-28 19:49:26 +0100 |
commit | c5da685240c4a9d85eae2ce34f4c1254c925c6f6 (patch) | |
tree | 7b4b401191e9c6fec10b18ed7352fd213084a4aa /m4 | |
parent | cbfe5edc9ade74b56c7cbf4b0a49831325ae6e22 (diff) |
Create an improved function search macro, and use it to look for res_query.
Instead of using AC_SEARCH_LIBS or AC_CHECK_LIB, create a new macro to
search for function in different libraries; this is needed since the
function name might just be a (preprocessor) macro for another symbol.
The new macro is released under GPL2 (or later) + exception, and
allows to provide a custom source code to use to test for the
function.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/search_function.m4 | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/m4/search_function.m4 b/m4/search_function.m4 new file mode 100644 index 0000000..53bfcad --- /dev/null +++ b/m4/search_function.m4 @@ -0,0 +1,82 @@ +dnl Copyright (c) 2008 Diego Pettenò <flameeyes@gmail.com> +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2, or (at your option) +dnl any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. +dnl +dnl As a special exception, the copyright owners of the +dnl macro gives unlimited permission to copy, distribute and modify the +dnl configure scripts that are the output of Autoconf when processing the +dnl Macro. You need not follow the terms of the GNU General Public +dnl License when using or distributing such scripts, even though portions +dnl of the text of the Macro appear in them. The GNU General Public +dnl License (GPL) does govern all other use of the material that +dnl constitutes the Autoconf Macro. +dnl +dnl This special exception to the GPL applies to versions of the +dnl Autoconf Macro released by this project. When you make and +dnl distribute a modified version of the Autoconf Macro, you may extend +dnl this special exception to the GPL to apply to your modified version as +dnl well. + +dnl ACF_SEARCH_FUNCTION([function name], +dnl [m4 list of libraries], +dnl [action if found], +dnl [action if not found], +dnl [test source]) +dnl +dnl Improved modified version of AC_SEARCH_LIBS, with some +dnl differences: +dnl - it accepts an m4 list for libraries to allow compound libraries +dnl instead of using the other-libraries parameter; +dnl - action if not found is only invoked when the function is not +dnl found at all; +dnl - an optional parameter allows for custom source code for testing +dnl (allowing to search for functions that are actually aliased). +AC_DEFUN([ACF_SEARCH_FUNCTION], [ + m4_pushdef([search_sourcecode], [ + m4_default([$5], [ + AC_LANG_CALL([], [$1]) + ]) + ]) + m4_pushdef([cache_variable], AS_TR_SH([acf_cv_library_$1])) + + m4_pushdef([action_if_found], + m4_default([$3], [LIBS="$LIBS $]cache_variable["])) + m4_pushdef([action_if_not_found], m4_default([$4], [:])) + + AC_CACHE_CHECK([for library containing $1], + cache_variable, + [while true; do + m4_foreach([library], [, $2], [ + save_libs=$LIBS + LIBS="$LIBS library" + AC_LINK_IFELSE(search_sourcecode, + cache_variable=" library") + LIBS=$save_libs + AS_IF(test -n "$cache_variable", [break]) + ]) + break + done + ]) + + m4_popdef([search_sourcecode]) + + AS_IF(test -n "$cache_variable", + m4_n([action_if_found]), + m4_n([action_if_not_found]) + ) + + m4_popdef([cache_variable]) +]) |