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