[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: simple autoconf question
From: |
Eric Gorr |
Subject: |
Re: simple autoconf question |
Date: |
Tue, 20 Dec 2011 15:35:25 -0500 |
On Dec 20, 2011, at 2:57 PM, Nick Bowler <address@hidden> wrote:
> Hi Eric,
>
> First, some general comments (not specific to your problem):
>
> On 2011-12-20 14:28 -0500, 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" configure.ac
>> 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)
>
> It's generally good form to quote (with [brackets]) all the arguments to
> macros unless you have a good reason not to. It shouldn't matter for
> the above, but further down...
Thanks for the tip. In most of the searching I've done, this style choice only
seems to be followed occasionally, but I can certainly understand why it would
be important to use.
>> # EG_MY_MACRO
>> # -----------------------------
>> AC_DEFUN( [EG_MY_MACRO],
>> m4_warn( [all], [hello world] )
>> ) # EG_MY_MACRO
>
> Assuming that it actually worked, this m4_warn is not quoted so it will
> be executed (and the warning printed) _before_ the AC_DEFUN is. This is
> probably not what you want, since this means the warning will be printed
> unconditionally (whether or not the script actually uses EG_MY_MACRO
> anywhere else).
Ok. I have changed my code to
AC_DEFUN( [EG_MY_MACRO],
[m4_warn( [obsolete], [hello world] )]
) # EG_MY_MACRO
EG_MY_MACRO
With the intent of defining and then calling the macro. You are correct, using
a category other then 'all' allows the file to be processes without error and I
do get a configure script. However, running this configure script does not
result in "hello world" being printed.
>> However, when I execute autoconf, I get the following error message:
>>
>> ~/depot/autoconf_test $autoconf
>> unknown channel all at /usr/bin/../share/autoconf/Autom4te/Channels.pm
>> line 546
>> Autom4te::Channels::msg('all', 'configure.ac:8', 'warning: hello world
>> ') called at /usr/bin/autom4te line 1012
>
> Interesting! The autoconf manual suggests that this should work.
> Indeed, if you use any of the other documented categories instead of
> "all" (i.e., cross, obsolete or syntax), the above works fine.
Well, I'm glad I was able to interpret the manual correctly ... that's always
nice. I will report the apparent bug soon lest anyone else fall prey to it.
However, it is possible I am using an out-of-date version of autoconf and this
bug has already been fixed...the version I am using is 2.61 according to
'autoconf --version'.
>> Furthermore, what prompted this question is one I posted to
>> stackoverflow...if you know the answer to this, I would be interested.
>>
>> http://stackoverflow.com/questions/8578181/using-the-pkg-config-macro-pkg-check-modules-failing
>>
>> I'm sure this is a fairly simple problem. I have a very simple
>> configure.ac file which I am using to just learn how autoconf &
>> pkg-config work together. The confgure.ac file looks like:
>>
>> AC_PREREQ(2.61)
>> AC_INIT(autoconf_test, 1.0,address@hidden)
>>
>> 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)'
>
> The problem here is that the PKG_CHECK_MODULES macro is not defined at
> autoconf time. Perhaps aclocal needs to be run with an appropriate -I
> option to find the macro (maybe it's installed in a nonstandard path, or
> not installed at all?).
I had considered this, but wasn't quite sure what do to about it.
I did see
/usr/local/share/aclocal/pkg.m4
If I do
aclocal --print-ac-dir
I get:
/usr/bin/../share/aclocal
What appears to work is the
following...
aclocal -I /usr/local/share/aclocal
autoconf
What I am not sure of is how to confirm just what directories will be searched
for autoconf macros...? 'aclocal --print-ac-dir' still only outputs
'/usr/bin/../share/aclocal'
What is the appropriate way to make my additional search location perminant?
Add the call to one of the bash init files, like .bashrc?
> Hope that helps,
It helps a lot. Thank you.