In configure.ac I have the following test:
dnl $1 = MSG_CHECKING
dnl Assemble and link assembly source $2 with extra $AS options $3
dnl and extra $LD options $4. When pattern $5 is found in `objdump -h`,
dnl then run $6, else run $7.
AC_DEFUN([CHECK_OBJDUMP_MINUS_H],[dnl
AC_MSG_CHECKING($1)
rm -f conftest.s conftest.o conftest.elf conftest.lst
cat > conftest.s <<EOF
$2
EOF
AC_TRY_COMMAND([$AS conftest.s $3 -o conftest.o])
AC_TRY_COMMAND([$LD conftest.o $4 -o conftest.elf])
AC_TRY_COMMAND([$OBJDUMP -h conftest.elf > conftest.lst])
AS_IF([grep $5 conftest.lst > /dev/null],has_pat=yes,has_pat=no)
AC_MSG_RESULT($has_pat)
AS_IF([test "x$has_pat" = "xyes"], [$6], [$7])
rm -f conftest.s conftest.o conftest.elf conftest.lst
])
CHECK_OBJDUMP_MINUS_H([whether have feature],dnl
[.data],dnl
[], [--defsym some_symbol=0x800066],
['.data.*00800066'],
AC_DEFINE([HAVE_FEATURE], 1,
[Define if have feature]),
)
At the place of invocation, $AS is the target assembler, $LD is the target linker, and $OBJDUMP is the target objdump.
Questions:
- Is there a better more robust way to specify the assembly source? I could not find anything like AC_LANG_PROGRAM for assembly (and such a thing might not make much sense because assembly is not standardized in any way).
- Is there a documantation of
AC_TRY_COMMAND
? I couldn’t find a mention in the autoconf v2.63 documentaton, also not in autoconf 2.71. I found that macro in the GCC configure scripts, so should work to some degree. What’s the proper way of running such commands? - My impression is that the portability of the test can be improved, but I am not familiar enough with autotools to know how to achieve that. Any notes on improving the test are welcome.
The exact configure version is not known because autoconf
(and autoheader
, automake
etc.) are usually run in user land, i.e. configure
etc. are not part of the source distribution.