I have a check for a header file in configure.ac
in the source root
AC_CHECK_HEADER(log4c.h,
[],
[AC_MSG_ERROR([Couldn't find or include log4c.h])])
and I'd like to give different feedback on different platform to reflect different most straight forward ways of providing the header:
- on Debian it should error with the message
Couldn't find or include log4c.h. Install log4c using 'sudo apt-get install liblog4c-dev'
- on OpenSUSE it should error with
... Install log4c using 'sudo yum install log4c-devel'
(didn't research the package name, but you catch my drift) - on other systems (where I'm too lazy to research the package name) it should error with
... Install log4c by fetching ftp://.../log4c.tar.gz and installing with './configure && make && make install' in the source root
I
- checked the
AM_CONDITIONAL
macro, but I don't get how to use it inconfigure.ac
rather than inMakefile.am
(as described in autoconf/automake: conditional compilation based on presence of library?) - found the tip to run
esyscmd
in stackoverflow.com/questions/4627900/m4-executing-a-shell-command, but addingesyscmd (/bin/echo abc)
toconfigure.ac
doesn't print anything when I runautoreconf --install --verbose --force
.
Both answers describing the usage of conditional macros without the shell commands for the mentioned OS and links to predefined macros (like AC_CHECK_HEADER_DEBIAN
, AC_CHECK_HEADER_SUSE
, etc.) are appreciated.
The following configure.ac
doesn't work:
AC_INIT([cndrvcups-common], [2.90], [krichter722@aol.de])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign -Wall subdir-objects])
AC_PROG_CC
AM_PROG_AR
AM_PROG_CC_C_O
AC_MSG_NOTICE([Hello, world.])
AC_INCLUDES_DEFAULT
AC_CHECK_HEADER(check.h,
[],
[
AS_IF (test "$(lsb_release -cs)" = "vivid", [echo aaaaaa], [echo bbbbbb])
])
LT_INIT # needs to be after AM_PROGS_AR
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
because ./configure
fails with
checking check.h usability... no
checking check.h presence... no
checking for check.h... no
./configure: line 4433: syntax error near unexpected token `;'
./configure: line 4433: ` if ; then :'
There's also ./configure: line 4427: #include: command not found
which happens no matter whether AC_CHECK_HEADER
is specified.