Re: [sr #110215] AC_EGREP_HEADER appears to be broken in master

Nick Bowler <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.bugs
Message-ID <CADyTPEzzPzGuSqJk6uwY1rGPuZ2E6=Xe8Mco-JS_RimPnWPxJw@mail.gmail.com>
On 2020-03-23, Ross Burton <[email protected]> wrote:
> apt 1.2.31 builds fine with autoconf 2.69.  With git master:
>
> | checking for h_errno... configure: error: "not found."
>
> That code is:
>
> dnl HP-UX needs -d_XOPEN_SOURCE_EXTENDED for h_errno
> AC_MSG_CHECKING(for h_errno)
> AC_EGREP_HEADER(h_errno, netdb.h, [AC_MSG_RESULT(normal)],
>    [CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
>     AC_EGREP_HEADER(h_errno, netdb.h,
>        [AC_MSG_RESULT(needs _XOPEN_SOURCE_EXTENDED)],
>        [AC_MSG_ERROR("not found.")])
>    ])
>
> Obviously this is horrible, but it's out there.

Can you expand more on what is failing for you?  I just copy+pasted the
above code into the following configure script:

  % cat >configure.ac <<'EOF'
AC_INIT([test], [0])

dnl HP-UX needs -d_XOPEN_SOURCE_EXTENDED for h_errno
AC_MSG_CHECKING(for h_errno)
AC_EGREP_HEADER(h_errno, netdb.h, [AC_MSG_RESULT(normal)],
    [CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
     AC_EGREP_HEADER(h_errno, netdb.h,
        [AC_MSG_RESULT(needs _XOPEN_SOURCE_EXTENDED)],
        [AC_MSG_ERROR("not found.")])
    ])

AC_OUTPUT
EOF

This seems to work perfectly fine with current autoconf master (ignoring
the slightly mangled output due to the example being a bit contrived):

  % autoconf --version
  autoconf (GNU Autoconf) 2.69.209-8a09
  [...]

  % autoconf

  % cat >netdb.h <<'EOF'
#if GATE && _XOPEN_SOURCE_EXTENDED
int h_errno;
#endif
EOF

  % ./configure CPPFLAGS='-I.'
  [...]
  configure: error: "not found."

  % ./configure CPPFLAGS='-I. -DGATE'
  [...]
  needs _XOPEN_SOURCE_EXTENDED

  % ./configure CPPFLAGS='-I. -DGATE -D_XOPEN_SOURCE_EXTENDED'
  [...]
  normal

Which appears to be exactly as expected for this configure test.

Cheers,
  Nick
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.