This is the mail archive of the automake@gnu.org mailing list for the automake project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: AC_CANONICAL_SYSTEM woes


>>>>> "Feiyi" == Feiyi Wang <fwang2@picard.mcnc.org> writes:

Feiyi> o I have a simple configure.in, the first thing I want to do is check
Feiyi> system type, so I called AC_CANONICAL_SYSTEM like the following ...
Feiyi> AC_INIT(something)
Feiyi> AM_INIT_AUTOMAKE(common, 1.1)
Feiyi> AM_CONFIG_HEADER(config.h)
Feiyi> dnl Checks for system type
Feiyi> AC_CANONICAL_SYSTEM

Feiyi> but it always returns "configure.in:9: AC_ARG_PROGRAM was
Feiyi> called before AC_CANONICAL_SYSTEM", have no clue what does it
Feiyi> mean?

AM_INIT_AUTOMAKE calls AC_ARG_PROGRAM.
But it is an error to run AC_ARG_PROGRAM before AC_CANONICAL_SYSTEM.

If you move AC_CANONICAL_SYSTEM up a few lines things will work.

I think autoconf ought to give a better error message in this case.
I could force a better error message by putting an AC_BEFORE into
AM_INIT_AUTOMAKE, but that would be wrong (if AC_ARG_PROGRAM changes
in the future, we'd have an unnecessary constraint).

Perhaps in this case autoconf could arrange to mention (or "also
mention") the outermost macro invocation?  A gcc-like "#include stack
trace" would be nice:

  configure.in:9: AC_ARG_PROGRAM was called before AC_CANONICAL_SYSTEM
  aclocal.m4:38: ... from AM_INIT_AUTOMAKE
  configure.in:9: ... from MY_PERSONAL_MACRO

... but perhaps difficult to implement.

Feiyi> o A related question is: if I want to deal with some source
Feiyi> code with "#ifdef LINUX...#include..." or "ifdef FREEBSD
Feiyi> ...#include ...", and I want to do run time checking of OS
Feiyi> type, then compile it with different setting, what is the best
Feiyi> way? is AC_CANONICAL_SYSTEM the only way?

You can always roll your own.  But AC_CANONICAL_SYSTEM is likely to be
more reliable.

Generally speaking, though, you don't want to do this.  Check
features, not operating systems.  Typically, over time, you'll find
that your LINUX define only works for one slice through the Linux
distribution history.  Things quickly get out of hand.

Of course, there are cases where it is unavoidable.  Perhaps you have
one of those.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]