1 | ## $Id: yat_common.m4 3114 2013-11-10 23:51:47Z peter $ |
---|
2 | # |
---|
3 | # Copyright (C) 2009, 2010, 2012, 2013 Peter Johansson |
---|
4 | # |
---|
5 | # This file is part of the yat library, http://dev.thep.lu.se/yat |
---|
6 | # |
---|
7 | # The yat library is free software; you can redistribute it and/or |
---|
8 | # modify it under the terms of the GNU General Public License as |
---|
9 | # published by the Free Software Foundation; either version 3 of the |
---|
10 | # License, or (at your option) any later version. |
---|
11 | # |
---|
12 | # The yat library is distributed in the hope that it will be useful, |
---|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
15 | # General Public License for more details. |
---|
16 | # |
---|
17 | # You should have received a copy of the GNU General Public License |
---|
18 | # along with yat. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | # |
---|
20 | |
---|
21 | # |
---|
22 | # This file contains some small useful macros. |
---|
23 | # |
---|
24 | # serial 3 (yat 0.11) |
---|
25 | # |
---|
26 | |
---|
27 | |
---|
28 | # YAT_ECHO_LOG(STRING) |
---|
29 | # ==================== |
---|
30 | # print STRING to config.log |
---|
31 | AC_DEFUN([YAT_ECHO_LOG], |
---|
32 | [ |
---|
33 | AC_PREREQ([2.58]) |
---|
34 | AS_ECHO(["$as_me:${as_lineno-$LINENO}: $1"]) >&AS_MESSAGE_LOG_FD |
---|
35 | ]) #YAT_ECHO_LOG |
---|
36 | |
---|
37 | |
---|
38 | # YAT_RUN_LOG(COMMAND, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) |
---|
39 | # ========================================================= |
---|
40 | # run COMMAND and log the output, set status in $yat_status and log |
---|
41 | # it. If status is zero execute ACTION-IF-TRUE, else execute |
---|
42 | # ACTION-IF-FALSE and log stderror from COMMAND |
---|
43 | AC_DEFUN([YAT_RUN_LOG], |
---|
44 | [ |
---|
45 | AC_PREREQ([2.58]) |
---|
46 | m4_pushdef([COMMAND], [$1]) |
---|
47 | YAT_ECHO_LOG([COMMAND]) |
---|
48 | COMMAND >&AS_MESSAGE_LOG_FD 2>conftest.err |
---|
49 | yat_status=$? |
---|
50 | YAT_ECHO_LOG([status: $yat_status]) |
---|
51 | AS_IF([test $yat_status = 0], [$2], |
---|
52 | [test -f conftest.err && cat conftest.err >&AS_MESSAGE_LOG_FD; $3]) |
---|
53 | m4_popdef([COMMAND]) |
---|
54 | ]) #YAT_RUN_LOG |
---|
55 | |
---|
56 | |
---|
57 | # YAT_VAR_REMOVE(VAR, LIST) |
---|
58 | # ========================== |
---|
59 | # Loop over LIST (space-separated) and for each value, remove value from VAR. |
---|
60 | AC_DEFUN([YAT_VAR_REMOVE], |
---|
61 | [ |
---|
62 | AS_IF([test x"$2" != x], [ |
---|
63 | for value in $2; do |
---|
64 | APR_REMOVEFROM([$1], [$value]) |
---|
65 | done |
---|
66 | ]) |
---|
67 | ]) |
---|
68 | |
---|
69 | # YAT_CHECK_LA_LIBS(CODE, LIBS, VALUE, VAR) |
---|
70 | # ============================================ |
---|
71 | # Check if we can create a libtool archive based on CODE linking with |
---|
72 | # LIBS. If not, add VALUE to VAR. |
---|
73 | AC_DEFUN([YAT_CHECK_LA_LIBS], |
---|
74 | [ |
---|
75 | save_LIBS=$LIBS |
---|
76 | LIBS="$2" |
---|
77 | AC_MSG_CHECKING([if libtool archive can be created with $LIBS]) |
---|
78 | YAT_LT_LINK_LA_IFELSE([$1], |
---|
79 | [AC_MSG_RESULT([yes])], |
---|
80 | [AC_MSG_RESULT([no]) |
---|
81 | $4="$$4 $3"]) |
---|
82 | LIBS=$save_LIBS |
---|
83 | ]) |
---|