[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simple autoconf question

From: Eric Blake
Subject: Re: simple autoconf question
Date: Tue, 20 Dec 2011 13:22:45 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111115 Thunderbird/8.0

On 12/20/2011 12:28 PM, Eric Gorr wrote:
> I am just starting to experiment with build tools like autoconf, etc. and had 
> what I am sure is a silly/stupid/easy question, but one that I still don't 
> know the answer to.
> I am just trying to write a very simple, "hello, world" script 
> using a AC_DEFUN macro that I wrote to print "hello world". What I have is 
> the following:
>    AC_PREREQ(2.61)
>    AC_INIT(autoconf_test, 1.0,address@hidden)

Not related, but you should get in the habit of proper quoting.  This
should be:

AC_INIT([autoconf_test], [1.0], address@hidden)

>    # EG_MY_MACRO
>    # -----------------------------
>    m4_warn( [all], [hello world] )
>    ) # EG_MY_MACRO

And here, the quoting actually bit you.  Because you failed to quote the
m4_warn, it was expanded _prior_ to AC_DEFUN setting the definition of
EG_MY_MACRO, when in reality, it looks like you want the definition of
EG_MY_MACRO to be the quoted text so the m4_warn only triggers if you
expand EG_MY_MACRO later on.

Furthermore, 'all' is a special syntactic sugar for displaying all other
warning categories, but is not a warning category itself.  m4_warn can
only be used with the following warning categories (at least, as of
2.61, which is what you are targeting as your minimum version): cross,
obsolete, syntax

Also, while leading whitespace before [ is stripped, trailing whitespace
after ] is _not_ stripped (you can use dnl to strip trailing newlines,
but in general you should get used to putting the ] next to the ) with
no intervening space).

That is, you wanted something more like:

[m4_warn([syntax], [hello world])]dnl

> However, when I execute autoconf, I get the following error message:
>    ~/depot/autoconf_test $autoconf
>    unknown channel all at /usr/bin/../share/autoconf/Autom4te/ 
> line 546
>        Autom4te::Channels::msg('all', '', 'warning: hello world 
> ') called at /usr/bin/autom4te line 1012

Yes, this is a result of passing an invalid argument as the first
parameter to m4_warn.

> and there is no configure script generated.

Yes, this is a side-effect of your above mis-use being treated as a
parse error.

> I'm sure this is a fairly simple problem. I have a very simple 
> file which I am using to just learn how autoconf & pkg-config work together. 
> The file looks like:
>    AC_PREREQ(2.61)
>    AC_INIT(autoconf_test, 1.0,address@hidden)
>    PKG_CHECK_MODULES(libusbmuxd, libusbmuxd >= 0.1.4)

Again, underquoted:

PKG_CHECK_MODULES([libusbmuxd], [libusbmuxd >= 0.1.4])

> I can then execute autoconf from the command line and it does produce a 
> configure script. However, when I run the configure script, I get the 
> following error:
>    ./configure: line 1618: syntax error near unexpected token `libusbmuxd,'
>    ./configure: line 1618: `PKG_CHECK_MODULES(libusbmuxd, libusbmuxd >= 
> 0.1.4)'

This means you didn't define PKG_CHECK_MODULES as a macro; if you are
using automake, then you didn't point aclocal to look in the right
directories for pkg.m4; if you are not using automake, then you need to
manually inline the contents of pkg.m4 into your acinclude.m4.  Either
way, you're not the first to hit this problem:

Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]