Blame confdb/aclocal_runlog.m4

Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_RUN_LOG mimics _AC_RUN_LOG which is autoconf internal routine.
Packit Service c5cf8c
dnl We also make sure PAC_RUN_LOG can be used in AS_IF, so the last
Packit Service c5cf8c
dnl test command should have terminating ]), i.e. without newline before ]).
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_RUNLOG],[
Packit Service c5cf8c
{ AS_ECHO(["$as_me:$LINENO: $1"]) >&AS_MESSAGE_LOG_FD
Packit Service c5cf8c
  (eval $1) 2>&AS_MESSAGE_LOG_FD
Packit Service c5cf8c
  ac_status=$?
Packit Service c5cf8c
  AS_ECHO(["$as_me:$LINENO: \$? = $ac_status"]) >&AS_MESSAGE_LOG_FD
Packit Service c5cf8c
  test $ac_status = 0; }])
Packit Service c5cf8c
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_COMMAND_IFELSE is written to replace AC_TRY_EVAL with added logging
Packit Service c5cf8c
dnl to config.log, i.e. AC_TRY_EVAL does not log anything to config.log.
Packit Service c5cf8c
dnl If autoconf provides AC_COMMAND_IFELSE or AC_EVAL_IFELSE,
Packit Service c5cf8c
dnl AC_COMMAND_IFELSE dnl should be replaced by the official autoconf macros.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_COMMAND_IFELSE(COMMMAND,[ACTION-IF-RUN-OK],[ACTION-IF-RUN-FAIL])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_COMMAND_IFELSE],[
Packit Service c5cf8c
AS_IF([PAC_RUNLOG([$1])],[
Packit Service c5cf8c
    $2
Packit Service c5cf8c
],[
Packit Service c5cf8c
    AS_ECHO(["$as_me: program exited with status $ac_status"]) >&AS_MESSAGE_LOG_FD
Packit Service c5cf8c
    m4_ifvaln([$3],[
Packit Service c5cf8c
        (exit $ac_status)
Packit Service c5cf8c
        $3
Packit Service c5cf8c
    ])
Packit Service c5cf8c
])
Packit Service c5cf8c
])
Packit Service c5cf8c
Packit Service c5cf8c
AC_DEFUN([PAC_RUNLOG_IFELSE],[
Packit Service c5cf8c
dnl pac_TESTLOG is the internal temporary logfile for this macro.
Packit Service c5cf8c
pac_TESTLOG="pac_test.log"
Packit Service c5cf8c
rm -f $pac_TESTLOG
Packit Service c5cf8c
PAC_COMMAND_IFELSE([$1 > $pac_TESTLOG],[
Packit Service c5cf8c
    ifelse([$2],[],[],[$2])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    AS_ECHO(["*** $1 :"]) >&AS_MESSAGE_LOG_FD
Packit Service c5cf8c
    cat $pac_TESTLOG >&AS_MESSAGE_LOG_FD
Packit Service c5cf8c
    ifelse([$3],[],[],[$3])
Packit Service c5cf8c
])
Packit Service c5cf8c
rm -f $pac_TESTLOG
Packit Service c5cf8c
])
Packit Service c5cf8c
Packit Service c5cf8c
Packit Service c5cf8c
dnl PAC_VAR_PUSHVAL(VARNAME, [LastSavedValue]))
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Save the content of the shell variable, VARNAME, onto a stack.
Packit Service c5cf8c
dnl The saved value of VARNAME is restorable with respect to the nesting
Packit Service c5cf8c
dnl of the macro.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl The Last saved value of VARNAME on the stack is stored in shell variable
Packit Service c5cf8c
dnl pac_LastSavedValueOf_$VARNAME if the 2nd argument is NOT supplied.
Packit Service c5cf8c
dnl If the 2nd argument is present, the last saved value will be stored
Packit Service c5cf8c
dnl in the 2nd argument instead.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl The First saved value of VARNAME on the stack is stored in shell variable
Packit Service c5cf8c
dnl dnl pac_FirstSavedValueOf_$VARNAME.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_VAR_PUSHVAL],[
Packit Service c5cf8c
# START of PUSHVAL
Packit Service c5cf8c
dnl define local m4-name pac_stk_level.
Packit Service c5cf8c
AS_VAR_PUSHDEF([pac_stk_level], [pac_stk_$1_level])
Packit Service c5cf8c
AS_VAR_SET_IF([pac_stk_level],[
Packit Service c5cf8c
    AS_VAR_ARITH([pac_stk_level], [$pac_stk_level + 1])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    AS_VAR_SET([pac_stk_level], [0])
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl AS_ECHO_N(["PUSHVAL: pac_stk_level = $pac_stk_level, "])
Packit Service c5cf8c
dnl Save the content of VARNAME, i.e. $VARNAME, onto the stack.
Packit Service c5cf8c
AS_VAR_SET([pac_stk_$1_$pac_stk_level],[$$1])
Packit Service c5cf8c
AS_VAR_IF([pac_stk_level], [0], [
Packit Service c5cf8c
    dnl Save the 1st pushed value of VARNAME as pac_FirstSavedValueOf_$VARNAME
Packit Service c5cf8c
    AS_VAR_COPY([pac_FirstSavedValueOf_$1],[pac_stk_$1_$pac_stk_level])
Packit Service c5cf8c
])
Packit Service c5cf8c
ifelse([$2],[],[
Packit Service c5cf8c
    dnl Save the last pushed value of VARNAME as pac_LastSavedValueOf_$VARNAME
Packit Service c5cf8c
    AS_VAR_COPY([pac_LastSavedValueOf_$1],[pac_stk_$1_$pac_stk_level])
Packit Service c5cf8c
    dnl AS_ECHO(["pac_LastSavedValueOf_$1 = $pac_LastSavedValueOf_$1"])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    dnl Save the last pushed value of VARNAME as $2
Packit Service c5cf8c
    AS_VAR_COPY([$2],[pac_stk_$1_$pac_stk_level])
Packit Service c5cf8c
    dnl AS_ECHO(["$2 = $$2"])
Packit Service c5cf8c
])
Packit Service c5cf8c
AS_VAR_POPDEF([pac_stk_level])
Packit Service c5cf8c
# END of PUSHVAL
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_VAR_POPVAL(VARNAME)
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Restore variable, VARNAME, from the stack.
Packit Service c5cf8c
dnl This macro is safe with respect to the nesting.
Packit Service c5cf8c
dnl Some minimal checking of nesting balance of PAC_VAR_PUSH[POP]VAL()
Packit Service c5cf8c
dnl is done here.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_VAR_POPVAL],[
Packit Service c5cf8c
# START of POPVAL
Packit Service c5cf8c
dnl define local m4-name pac_stk_level.
Packit Service c5cf8c
AS_VAR_PUSHDEF([pac_stk_level], [pac_stk_$1_level])
Packit Service c5cf8c
AS_VAR_SET_IF([pac_stk_level],[
Packit Service c5cf8c
    AS_VAR_IF([pac_stk_level],[-1],[
Packit Service c5cf8c
        AC_MSG_WARN(["Imbalance of PUSHVAL/POPVAL of $1"])
Packit Service c5cf8c
    ],[
Packit Service c5cf8c
        dnl AS_ECHO_N(["POPVAL: pac_stk_level = $pac_stk_level, "])
Packit Service c5cf8c
        AS_VAR_COPY([$1],[pac_stk_$1_$pac_stk_level])
Packit Service c5cf8c
        dnl AS_ECHO(["popped_val = $$1"])
Packit Service c5cf8c
        AS_VAR_ARITH([pac_stk_level], [ $pac_stk_level - 1 ])
Packit Service c5cf8c
    ])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    AC_MSG_WARN(["Uninitialized PUSHVAL/POPVAL of $1"])
Packit Service c5cf8c
])
Packit Service c5cf8c
AS_VAR_POPDEF([pac_stk_level])
Packit Service c5cf8c
# END of POPVAL
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_COMPILE_IFELSE_LOG is a wrapper around AC_COMPILE_IFELSE with the
Packit Service c5cf8c
dnl output of ac_compile to a specified logfile instead of AS_MESSAGE_LOG_FD
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_COMPILE_IFELSE_LOG(logfilename, input,
Packit Service c5cf8c
dnl                        [action-if-true], [action-if-false])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl where input, [action-if-true] and [action-if-false] are used
Packit Service c5cf8c
dnl in AC_COMPILE_IFELSE(input, [action-if-true], [action-if-false]).
Packit Service c5cf8c
dnl This macro is nesting safe.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_COMPILE_IFELSE_LOG],[
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Instead of defining our own ac_compile and do AC_TRY_EVAL
Packit Service c5cf8c
dnl on these variables.  We modify ac_compile used by AC_*_IFELSE
Packit Service c5cf8c
dnl by piping the output of the command to a logfile.  The reason is that
Packit Service c5cf8c
dnl 1) AC_TRY_EVAL is discouraged by Autoconf. 2) defining our ac_compile
Packit Service c5cf8c
dnl could mess up the usage and order of *CFLAGS, LDFLAGS and LIBS in
Packit Service c5cf8c
dnl these commands, i.e. deviate from how GNU standard uses these variables.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Replace ">&AS_MESSAGE_LOG_FD" by "> FILE 2>&1" in ac_compile.
Packit Service c5cf8c
dnl Save a copy of ac_compile on a stack
Packit Service c5cf8c
dnl which is safe through nested invocations of this macro.
Packit Service c5cf8c
PAC_VAR_PUSHVAL([ac_compile])
Packit Service c5cf8c
dnl Modify ac_compile based on the unmodified ac_compile.
Packit Service c5cf8c
ac_compile="`echo $pac_FirstSavedValueOf_ac_compile | sed -e 's|>.*$|> $1 2>\&1|g'`"
Packit Service c5cf8c
AC_COMPILE_IFELSE([$2],[
Packit Service c5cf8c
    ifelse([$3],[],[:],[$3])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    ifelse([$4],[],[:],[$4])
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl Restore the original ac_compile from the stack.
Packit Service c5cf8c
PAC_VAR_POPVAL([ac_compile])
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_LINK_IFELSE_LOG is a wrapper around AC_LINK_IFELSE with the
Packit Service c5cf8c
dnl output of ac_link to a specified logfile instead of AS_MESSAGE_LOG_FD
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_LINK_IFELSE_LOG(logfilename, input,
Packit Service c5cf8c
dnl                     [action-if-true], [action-if-false])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl where input, [action-if-true] and [action-if-false] are used
Packit Service c5cf8c
dnl in AC_LINK_IFELSE(input, [action-if-true], [action-if-false]).
Packit Service c5cf8c
dnl This macro is nesting safe.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_LINK_IFELSE_LOG],[
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Instead of defining our own ac_link and do AC_TRY_EVAL
Packit Service c5cf8c
dnl on these variables.  We modify ac_link used by AC_*_IFELSE
Packit Service c5cf8c
dnl by piping the output of the command to a logfile.  The reason is that
Packit Service c5cf8c
dnl 1) AC_TRY_EVAL is discouraged by Autoconf. 2) defining our ac_link
Packit Service c5cf8c
dnl could mess up the usage and order of *CFLAGS, LDFLAGS and LIBS in
Packit Service c5cf8c
dnl these commands, i.e. deviate from how GNU standard uses these variables.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Replace ">&AS_MESSAGE_LOG_FD" by "> FILE 2>&1" in ac_link.
Packit Service c5cf8c
dnl Save a copy of ac_link on a stack
Packit Service c5cf8c
dnl which is safe through nested invocations of this macro.
Packit Service c5cf8c
PAC_VAR_PUSHVAL([ac_link])
Packit Service c5cf8c
dnl Modify ac_link based on the unmodified ac_link.
Packit Service c5cf8c
ac_link="`echo $pac_FirstSavedValueOf_ac_link | sed -e 's|>.*$|> $1 2>\&1|g'`"
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_LINK_IFELSE([$2],[
Packit Service c5cf8c
    ifelse([$3],[],[:],[$3])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    ifelse([$4],[],[:],[$4])
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl Restore the original ac_link from the stack.
Packit Service c5cf8c
PAC_VAR_POPVAL([ac_link])
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_COMPLINK_IFELSE (input1, input2, [action-if-true], [action-if-false])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl where input1 and input2 are either AC_LANG_SOURCE or AC_LANG_PROGRAM
Packit Service c5cf8c
dnl enclosed input programs.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl The macro first compiles input1 and uses the object file created
Packit Service c5cf8c
dnl as part of LIBS during linking.  This macro is nesting safe.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_COMPLINK_IFELSE],[
Packit Service c5cf8c
AC_COMPILE_IFELSE([$1],[
Packit Service c5cf8c
    PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
Packit Service c5cf8c
    PAC_VAR_PUSHVAL([LIBS])
Packit Service c5cf8c
    LIBS="pac_conftest.$OBJEXT $pac_FirstSavedValueOf_LIBS"
Packit Service c5cf8c
    AC_LINK_IFELSE([$2],[
Packit Service c5cf8c
        ifelse([$3],[],[:],[$3])
Packit Service c5cf8c
    ],[
Packit Service c5cf8c
        ifelse([$4],[],[:],[$4])
Packit Service c5cf8c
    ])
Packit Service c5cf8c
    PAC_VAR_POPVAL([LIBS])
Packit Service c5cf8c
    rm -f pac_conftest.$OBJEXT
Packit Service c5cf8c
],[
Packit Service c5cf8c
    ifelse([$4],[],[:],[$4])
Packit Service c5cf8c
])
Packit Service c5cf8c
])