bug-automake
[Top][All Lists]
Advanced

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

unesthetic build commands generated by automake


From: Bruno Haible
Subject: unesthetic build commands generated by automake
Date: Mon, 24 Feb 2003 12:53:31 +0100 (CET)

Hi,

The compilation commands printed to the console while compiling a package
with C sources are more complicated than necessary. Each time I track down
an error I have to get simplify this

     `test -f 'hello.c' || echo './'`hello.c

to a simple

     hello.c

or

     ./hello.c

This costs time during development.

Example:
========================= Makefile.am ===========================
AUTOMAKE_OPTIONS = 1.5 foreign no-dependencies

noinst_PROGRAMS = hello
hello_SOURCES = hello.c
========================= configure.ac ==========================
AC_INIT(configure.ac)
AM_INIT_AUTOMAKE(foobar, 0)
AM_CONFIG_HEADER(config.h)
AC_PROG_CC
AC_OUTPUT([Makefile])
========================= hello.c ===============================
#include <stdio.h>
int main ()
{
  printf("Hello, world.\n");
  return 0;
}
=================================================================

  $ aclocal
  $ autoconf
  $ autoheader
  $ automake
  $ ./configure
  $ make
...
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -c `test -f 'hello.c' || echo 
'./'`hello.c
...

When I apply this to Makefile.in:

  $ sed -e "s,\`test -f \\\$< || echo '\\\$(srcdir)/'\`\\\$<,\\\$<,"
        -e "s,\`test -f '\\\$<' || echo '\\\$(srcdir)/'\`\\\$<,\\\$<," \
      < Makefile.in > Makefile.in.tmp
  $ mv Makefile.in.tmp Makefile.in

the compilation command is short and sweet:

  $ make
...
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -c hello.c
...

I have tested this in GNU gettext for two years now, even in directories
containing BUILT_SOURCES, without any problems on any platform.

Why is it sufficient to write $< ?
  - If builddir = sourcedir, then $(srcdir) expands to ".", and the
    entire backquoted thing is redundant.
  - If builddir != sourcedir, then a "make" program supporting VPATH
    must be assumed, and this "make" program will set $< to the result
    of looking up the source file in . and in $(srcdir). In this case
    also, the entire backquoted thing is redundant.

Please make this simplification to depend2.am.

Bruno




reply via email to

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