[PATCH] [wayland] configure: better check for the C++ compiler

Yann E. MORIN yann.morin.1998 at free.fr
Tue Mar 7 20:01:42 UTC 2017


Bill, All,

On 2017-03-07 10:12 -0800, Bill Spitzak spake thusly:
> Why not just check if $CXX is "false".
> 
> I really doubt anybody wants to run a C++ compiler named "false".

At least, that way it is robust to any future change in autoconf, which
could set it to "no" or "none" or whatever; it would work on virtually
any version and any setting of autoconf (unless it returns an actual
command that still works with those specific flags, but then we'd be
foobared anyway).

I'll wait a bit for others to comment before I switch to comparing
against "false".

Thanks for the feedback! :-)

Regards,
Yann E. MORIN.

> On Sun, Mar 5, 2017 at 6:17 AM, Yann E. MORIN <yann.morin.1998 at free.fr> wrote:
> > When a C++ compiler is not found, then AC_PROG_CXX will set CXX to
> > 'false'.
> >
> > However, we test that we can find $CXX, and idneed false exists in
> > the PATH, for virtually all systems we have a chance to be compiled
> > on. So we conclude that we do have a C++ compiler, when this is
> > clearly wrong.
> >
> > Improve our hack by trying to run the C++ compiler with a benign call,
> > that should succeed if the CXX is really a C++ compiler: tell it to dump
> > its pre-defined macros.
> >
> > Signed-off-by: "Yann E. MORIN" <yann.morin.1998 at free.fr>
> > ---
> > Note: this is not a replacement for the patch I sent earlier [0].
> > It is complementary.
> > ---
> >  configure.ac | 10 +++++-----
> >  1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/configure.ac b/configure.ac
> > index 96a5575..9939bf4 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -33,11 +33,11 @@ AM_PROG_AS
> >  # check if we have C++ compiler. This is hacky workaround,
> >  # for a reason why it is this way see
> >  # http://lists.gnu.org/archive/html/bug-autoconf/2010-05/msg00001.html
> > -have_cpp_compiler=yes
> > -
> > -if ! which "$CXX" &>/dev/null; then
> > -       have_cpp_compiler=no
> > -fi
> > +AS_IF([! which "$CXX" &>/dev/null];
> > +       [have_cpp_compiler=no],
> > +       [AS_IF([! $CXX -dM -E - < /dev/null >/dev/null],
> > +               [have_cpp_compiler=no],
> > +               [have_cpp_compiler=yes])])
> >
> >  AM_CONDITIONAL(ENABLE_CPP_TEST, test "x$have_cpp_compiler" = "xyes")
> >
> > --
> > 2.7.4
> >
> > _______________________________________________
> > wayland-devel mailing list
> > wayland-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/wayland-devel

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'


More information about the wayland-devel mailing list