3865 |
19 Feb 20 |
peter |
## $Id$ |
3865 |
19 Feb 20 |
peter |
2 |
# |
4019 |
06 Nov 20 |
peter |
# serial 3 (yat 0.18) |
3865 |
19 Feb 20 |
peter |
4 |
# |
3865 |
19 Feb 20 |
peter |
# see http://www.gnu.org/software/automake/manual/automake.html#Serials |
3865 |
19 Feb 20 |
peter |
6 |
# |
3865 |
19 Feb 20 |
peter |
# SYNOPSIS |
3865 |
19 Feb 20 |
peter |
8 |
# |
3865 |
19 Feb 20 |
peter |
# YAT_CHECK_LIBS(MESSAGE, CACHE-ID, SEARCH-LIBS, INPUT, |
3865 |
19 Feb 20 |
peter |
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) |
3865 |
19 Feb 20 |
peter |
11 |
# |
3865 |
19 Feb 20 |
peter |
# DESCRIPTION |
3865 |
19 Feb 20 |
peter |
13 |
# |
3865 |
19 Feb 20 |
peter |
# Similar to AC_SEARCH_LIBS. |
3865 |
19 Feb 20 |
peter |
15 |
# |
3865 |
19 Feb 20 |
peter |
# First try compiling and linking code INPUT. If it fails, loop over |
3884 |
25 Mar 20 |
peter |
# libraries SEARCH-LIBS and try linking again. If there is no |
3865 |
19 Feb 20 |
peter |
# library that makes the code link, execute ACTION-IF-NOT-FOUND. If |
3865 |
19 Feb 20 |
peter |
# there is a library, prepend -llibrary to $LIBS. Result is saved in |
3865 |
19 Feb 20 |
peter |
# cache variable CACHE-ID, which must contain '_cv_' |
3865 |
19 Feb 20 |
peter |
21 |
# |
3865 |
19 Feb 20 |
peter |
# COPYLEFT |
3865 |
19 Feb 20 |
peter |
23 |
# |
3865 |
19 Feb 20 |
peter |
# Copyright (C) 2020 Peter Johansson |
3865 |
19 Feb 20 |
peter |
25 |
# |
3865 |
19 Feb 20 |
peter |
# This file is part of the yat library, http://dev.thep.lu.se/yat |
3865 |
19 Feb 20 |
peter |
27 |
# |
3865 |
19 Feb 20 |
peter |
# The yat library is free software; you can redistribute it and/or |
3865 |
19 Feb 20 |
peter |
# modify it under the terms of the GNU General Public License as |
3865 |
19 Feb 20 |
peter |
# published by the Free Software Foundation; either version 3 of the |
3865 |
19 Feb 20 |
peter |
# License, or (at your option) any later version. |
3865 |
19 Feb 20 |
peter |
32 |
# |
3865 |
19 Feb 20 |
peter |
# The yat library is distributed in the hope that it will be useful, |
3865 |
19 Feb 20 |
peter |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3865 |
19 Feb 20 |
peter |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3865 |
19 Feb 20 |
peter |
# General Public License for more details. |
3865 |
19 Feb 20 |
peter |
37 |
# |
3865 |
19 Feb 20 |
peter |
# You should have received a copy of the GNU General Public License |
3865 |
19 Feb 20 |
peter |
# along with yat. If not, see <http://www.gnu.org/licenses/>. |
3865 |
19 Feb 20 |
peter |
40 |
# |
3865 |
19 Feb 20 |
peter |
41 |
|
3865 |
19 Feb 20 |
peter |
42 |
AC_DEFUN([YAT_CHECK_LIBS], |
3865 |
19 Feb 20 |
peter |
43 |
[ |
4019 |
06 Nov 20 |
peter |
44 |
m4_pushdef([yat_MESSAGE], [$1]) |
4019 |
06 Nov 20 |
peter |
45 |
m4_pushdef([yat_CACHE], [$2]) |
4019 |
06 Nov 20 |
peter |
46 |
m4_pushdef([yat_SEARCH_LIBS], [$3]) |
4019 |
06 Nov 20 |
peter |
47 |
m4_pushdef([yat_DEFAULT_RESULT], ["none required"]) |
3865 |
19 Feb 20 |
peter |
48 |
AC_LANG_CONFTEST([$4]) |
4019 |
06 Nov 20 |
peter |
49 |
AC_CACHE_CHECK([yat_MESSAGE], [yat_CACHE], [ |
3865 |
19 Feb 20 |
peter |
50 |
save_LIBS=$LIBS |
4019 |
06 Nov 20 |
peter |
51 |
for yat_lib in '' yat_SEARCH_LIBS; do |
3865 |
19 Feb 20 |
peter |
52 |
AS_VAR_IF([yat_lib], [''],[ |
4019 |
06 Nov 20 |
peter |
53 |
yat_result=yat_DEFAULT_RESULT |
3865 |
19 Feb 20 |
peter |
54 |
], [ |
3865 |
19 Feb 20 |
peter |
55 |
yat_result=-l$yat_lib |
3865 |
19 Feb 20 |
peter |
56 |
LIBS="-l$yat_lib $save_LIBS" |
3865 |
19 Feb 20 |
peter |
57 |
]) |
4019 |
06 Nov 20 |
peter |
58 |
AC_LINK_IFELSE([], [yat_CACHE=$yat_result]) |
4019 |
06 Nov 20 |
peter |
59 |
AS_VAR_SET_IF([yat_CACHE], [break]) |
3865 |
19 Feb 20 |
peter |
60 |
done |
4019 |
06 Nov 20 |
peter |
61 |
AS_VAR_SET_IF([yat_CACHE], [], [yat_CACHE=no]) |
3865 |
19 Feb 20 |
peter |
62 |
rm conftest.$ac_ext |
3865 |
19 Feb 20 |
peter |
63 |
LIBS=$save_LIBS |
3865 |
19 Feb 20 |
peter |
64 |
]) |
4019 |
06 Nov 20 |
peter |
65 |
yat_result=$yat_CACHE |
3865 |
19 Feb 20 |
peter |
66 |
|
3865 |
19 Feb 20 |
peter |
# action |
3865 |
19 Feb 20 |
peter |
68 |
AS_VAR_IF([yat_result], [no], [$6], [ |
4019 |
06 Nov 20 |
peter |
69 |
AS_VAR_IF([yat_result], [yat_DEFAULT_RESULT], [], |
4019 |
06 Nov 20 |
peter |
70 |
[LIBS="$yat_result $LIBS"]) |
3865 |
19 Feb 20 |
peter |
71 |
$5 |
3865 |
19 Feb 20 |
peter |
72 |
]) |
3865 |
19 Feb 20 |
peter |
73 |
|
4019 |
06 Nov 20 |
peter |
74 |
m4_popdef([yat_MESSAGE]) |
4019 |
06 Nov 20 |
peter |
75 |
m4_popdef([yat_CACHE]) |
4019 |
06 Nov 20 |
peter |
76 |
m4_popdef([yat_SEARCH_LIBS]) |
4019 |
06 Nov 20 |
peter |
77 |
m4_popdef([yat_DEFAULT_RESULT]) |
3865 |
19 Feb 20 |
peter |
78 |
]) |