bug-automake
[Top][All Lists]
Advanced

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

missing warning about absence of AM_PROG_CC_C_O


From: Bruno Haible
Subject: missing warning about absence of AM_PROG_CC_C_O
Date: Sat, 3 Oct 2009 14:42:08 +0200
User-agent: KMail/1.9.9

Hi,

Here is a situation where automake 1.9.6 errs out because of a missing
invocation of AM_PROG_CC_C_O in a configure.ac, but automake >= 1.10 don't
err out any more and instead produces a Makefile.in that fails when the
C compiler does not support -c and -o in the same command line.

How to reproduce:

0) Check out a recent gnulib.
$ git checkout 881b91b9b370b4b6f26eb44efb5c048ca3783b83

1) Put automake 1.9.6 in your PATH.
$ ./gnulib-tool --create-testdir --with-tests --dir=/tmp/testdir1 mbscasestr
...
executing aclocal -I ../glm4
executing autoconf
executing autoheader
executing automake --add-missing --copy
Makefile.am: C objects in subdir but `AM_PROG_CC_C_O' not in `configure.ac'

2) Put automake 1.10 in your PATH.

$ ./gnulib-tool --create-testdir --with-tests --dir=/tmp/testdir2 mbscasestr
...
executing aclocal -I ../glm4
executing autoconf
executing autoheader
executing automake --add-missing --copy

So automake succeeded.

Now try to compile this directory with a compiler that does not understand
-c with -o:
$ cd /tmp
$ cat > oldcc <<\EOF
#!/bin/sh
case " $* " in
  *" -c "*)
    case " $* " in
      *" -o "*)
        echo "oldcc: -o and -c incompatible" 1>&2
        exit 1
        ;;
    esac
    ;;
esac
exec gcc "$@"
EOF
$ chmod a+x oldcc
$ cd /tmp/testdir2
$ ./configure CC=/tmp/oldcc
...
checking whether /tmp/oldcc and cc understand -c and -o together... no
...
$ make
...
make[4]: Entering directory `/tmp/testdir2/gllib'
source='localcharset.c' object='localcharset.o' libtool=no \
        DEPDIR=.deps depmode=none /bin/sh ../build-aux/depcomp \
        /tmp/testdir2/build-aux/compile /tmp/oldcc -DHAVE_CONFIG_H -I. -I..     
-g -O2 -c -o localcharset.o localcharset.c
mv: `localcharset.o' and `localcharset.o' are the same file
...
make[4]: Entering directory `/tmp/testdir2/gltests'
source='test-alloca-opt.c' object='test-alloca-opt.o' libtool=no \
        DEPDIR=.deps depmode=none /bin/sh ./../build-aux/depcomp \
        /tmp/oldcc -DHAVE_CONFIG_H -I.  -I. -I. -I.. -I./.. -I../gllib 
-I./../gllib   -g -O2 -c -o test-alloca-opt.o test-alloca-opt.c
oldcc: -o and -c incompatible
make[4]: *** [test-alloca-opt.o] Error 1

Both generated directories testdir1 and testdir2 have the same gnulib-tool
generated files.

There is a configure.ac for Makefile.am and gllib/Makefile.am. The latter
contains the automake option 'subdir-objects'. configure.ac contains an
AM_PROG_CC_C_O call, so all is fine. If that call is commented out, automake
errs out:
  1) in testdir1, automake 1.9.6:
     gllib/Makefile.am: C objects in subdir but `AM_PROG_CC_C_O' not in 
`configure.ac'
  2) in testdir2, automake 1.10:
     gllib/Makefile.am:33: compiling `uniwidth/width.c' in subdir requires 
`AM_PROG_CC_C_O' in `configure.ac'

There is a gltests/configure.ac for gltests/Makefile.am. The latter also
contains the automake option 'subdir-objects'. But here gltests/configure.ac
does not invoke AM_PROG_CC_C_O. Why does automake 1.9.6 err out in this
situation, but automake 1.10 does not do it any more?

The relevant code in automake 1.9.6 looks like this:

  if (option 'subdir-objects')
    {
      $r = LANG_SUBDIR;
      $base = $directory . '/' . $base
        unless $directory eq '.' || $directory eq '';

      err_am ("C objects in subdir but `AM_PROG_CC_C_O' "
              . "not in `$configure_ac'",
              uniq_scope => US_GLOBAL)
        unless $seen_cc_c_o;

      require_conf_file ("$am_file.am", FOREIGN, 'compile');

      # In this case we already have the directory information, so
      # don't add it again.
      $de_ansi_files{$base} = '';
    }

whereas in automake 1.10 it is like this:

  if (option 'subdir-objects')
    {
      $r = LANG_SUBDIR;
      if ($directory && $directory ne '.')
        {
          $base = $directory . '/' . $base;

          # libtool is always able to put the object at the proper place,
          # so we do not have to require AM_PROG_CC_C_O when building .lo files.
          msg_var ('portability', $var,
                   "compiling `$base.c' in subdir requires "
                   . "`AM_PROG_CC_C_O' in `$configure_ac'",
                   uniq_scope => US_GLOBAL,
                   uniq_part => 'AM_PROG_CC_C_O subdir')
            unless $seen_cc_c_o || $nonansi_obj eq '.lo';
        }

      # In this case we already have the directory information, so
      # don't add it again.
      $de_ansi_files{$base} = '';
    }

In case it matters: I use autoconf 2.64.

This issue was brought up by Ian Beckwith on bug-gnulib.

Bruno




reply via email to

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