## $Id$ # # Copyright (C) 2009, 2010, 2012, 2013, 2014 Peter Johansson # # This file is part of the yat library, http://dev.thep.lu.se/yat # # The yat library is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 3 of the # License, or (at your option) any later version. # # The yat library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with yat. If not, see . # # # This file contains some small useful macros. # # serial 3 (yat 0.11) # # YAT_ECHO_LOG(STRING) # ==================== # print STRING to config.log AC_DEFUN([YAT_ECHO_LOG], [ AC_PREREQ([2.58]) AS_ECHO(["$as_me:${as_lineno-$LINENO}: $1"]) >&AS_MESSAGE_LOG_FD ]) #YAT_ECHO_LOG # YAT_RUN_LOG(COMMAND, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) # ========================================================= # run COMMAND and log the output, set status in $yat_status and log # it. If status is zero execute ACTION-IF-TRUE, else execute # ACTION-IF-FALSE and log stderror from COMMAND AC_DEFUN([YAT_RUN_LOG], [ AC_PREREQ([2.58]) m4_pushdef([COMMAND], [$1]) YAT_ECHO_LOG([COMMAND]) COMMAND >&AS_MESSAGE_LOG_FD 2>conftest.err yat_status=$? YAT_ECHO_LOG([status: $yat_status]) AS_IF([test $yat_status = 0], [$2], [test -f conftest.err && cat conftest.err >&AS_MESSAGE_LOG_FD; $3]) m4_popdef([COMMAND]) ]) #YAT_RUN_LOG # YAT_SET_CONTAINS(set, value, [if-present], [if-not-present]) # ============================================================ # Loop over set (space-separated) and if value exists, execute # if-present. otherwise execute if-not-present AC_DEFUN([YAT_SET_CONTAINS], [ AS_IF([AS_ECHO([$1]) | tr ' ' '\n' | grep '^$2$' > /dev/null], [$3], [$4]) ]) #YAT_SET_CONTAINS # YAT_VAR_REMOVE(VAR, LIST) # ========================== # Loop over LIST (space-separated) and for each value, remove value from VAR. AC_DEFUN([YAT_VAR_REMOVE], [ AS_IF([test x"$2" != x], [ for value in $2; do APR_REMOVEFROM([$1], [$value]) done ]) ]) # YAT_CHECK_LA_LIBS(CODE, LIBS, VALUE, VAR) # ============================================ # Check if we can create a libtool archive based on CODE linking with # LIBS. If not, add VALUE to VAR. AC_DEFUN([YAT_CHECK_LA_LIBS], [ save_LIBS=$LIBS LIBS="$2" AC_MSG_CHECKING([if libtool archive can be created with $LIBS]) YAT_LT_LINK_LA_IFELSE([$1], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) $4="$$4 $3"]) LIBS=$save_LIBS ])