automake
[Top][All Lists]
Advanced

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

Re: not breaking "make" after m4 macros and source files changed


From: Bruno Haible
Subject: Re: not breaking "make" after m4 macros and source files changed
Date: Sun, 3 Apr 2011 21:44:47 +0200
User-agent: KMail/1.9.9

Hi Ralf, Stefano,

> I'll make amend by writing the new testcases, if you can wait some more
> time (maybe a couple of days).

Thanks. You can take this as input (I have copyright assignment on file with
Automake):

>   - A renamed m4 macro.
>     Before: m4/foo.m4 defines FOO1, configure.ac depends on m4/macros.m4 that
>             invokes FOO1.
>     After:  m4/foo.m4 defines FOO2, configure.ac depends on m4/macros.m4 that
>             invokes FOO2.

============================== configure.ac ==============================
AC_INIT([dummy], [0])
AM_INIT_AUTOMAKE([foreign])
MYMACROS
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
============================== macros.m4 =================================
AC_DEFUN([MYMACROS], [
  FOO1
])
============================== foo.m4 ====================================
AC_DEFUN([FOO1], [
  foovar=42
  AC_SUBST([foovar])
])
============================== Makefile.am ===============================
ACLOCAL_AMFLAGS = -I .
all :
        test $(foovar) = 42
==========================================================================
$ aclocal -I .
$ automake -a -c
$ autoconf
$ ./configure
$ make
$ mv macros.m4 macros.m4~ && sed -e 's/FOO1/FOO2/' < macros.m4~ > macros.m4
$ mv foo.m4 foo.m4~ && sed -e 's/FOO1/FOO2/' < foo.m4~ > foo.m4
$ make

>   - A removed m4 file.
>     Before: m4/foo.m4 defines FOO, configure.ac depends on m4/macros.m4 that
>             invokes FOO.
>     After:  m4/foo.m4 is gone, configure.ac depends on m4/macros.m4 that
>             does not invoke FOO any more.

============================== configure.ac ==============================
AC_INIT([dummy], [0])
AM_INIT_AUTOMAKE([foreign])
MYMACROS
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
============================== macros.m4 =================================
AC_DEFUN([MYMACROS], [
  FOO
])
============================== foo.m4 ====================================
AC_DEFUN([FOO], [
  foovar=42
  AC_SUBST([foovar])
])
============================== Makefile.am ===============================
ACLOCAL_AMFLAGS = -I .
all :
        test $(foovar) = 42
==========================================================================
$ aclocal -I .
$ automake -a -c
$ autoconf
$ ./configure
$ make
$ mv macros.m4 macros.m4~ && sed -e 's/FOO/foovar=42; AC_SUBST([foovar])/' < 
macros.m4~ > macros.m4
$ rm foo.m4
$ make

>   - A renamed m4 file.
>     Before: m4/foo1.m4 defines FOO, configure.ac depends on m4/macros.m4 that
>             invokes FOO.
>     After:  m4/foo2.m4 defines FOO, configure.ac depends on m4/macros.m4 that
>             invokes FOO.

============================== configure.ac ==============================
AC_INIT([dummy], [0])
AM_INIT_AUTOMAKE([foreign])
MYMACROS
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
============================== macros.m4 =================================
AC_DEFUN([MYMACROS], [
  FOO
])
============================== foo.m4 ====================================
AC_DEFUN([FOO], [
  foovar=42
  AC_SUBST([foovar])
])
============================== Makefile.am ===============================
ACLOCAL_AMFLAGS = -I .
all :
        test $(foovar) = 42
==========================================================================
$ aclocal -I .
$ automake -a -c
$ autoconf
$ ./configure
$ make
$ mv foo1.m4 foo2.m4
$ make

>   - A renamed m4 macro in a renamed m4 file.
>     Before: m4/foo1.m4 defines FOO1, configure.ac depends on m4/macros.m4 that
>             invokes FOO1.
>     After:  m4/foo2.m4 defines FOO2, configure.ac depends on m4/macros.m4 that
>             invokes FOO2.

============================== configure.ac ==============================
AC_INIT([dummy], [0])
AM_INIT_AUTOMAKE([foreign])
MYMACROS
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
============================== macros.m4 =================================
AC_DEFUN([MYMACROS], [
  FOO1
])
============================== foo1.m4 ===================================
AC_DEFUN([FOO1], [
  foovar=42
  AC_SUBST([foovar])
])
============================== Makefile.am ===============================
ACLOCAL_AMFLAGS = -I .
all :
        test $(foovar) = 42
==========================================================================
$ aclocal -I .
$ automake -a -c
$ autoconf
$ ./configure
$ make
$ mv macros.m4 macros.m4~ && sed -e 's/FOO1/FOO2/' < macros.m4~ > macros.m4
$ sed -e 's/FOO1/FOO2/' < foo1.m4 > foo2.m4
$ rm foo1.m4
$ make

>   - An added AC_SUBST.
>     Before: configure.ac depends on m4/macros.m4 that AC_SUBSTs FOO.
>             lib/foo.h is generated through lib/Makefile, substituting FOO.
>             lib/foo.c includes foo.h and needs to be compiled for 'all'.
>     After:  configure.ac depends on m4/macros.m4 that AC_SUBSTs FOO and BAR.
>             lib/foo.h is generated through lib/Makefile, substituting FOO and 
> BAR.
>             lib/foo.c includes foo.h and needs to be compiled for 'all'.

============================== configure.ac ==============================
AC_INIT([dummy], [0])
AM_INIT_AUTOMAKE([foreign])
AC_PROG_CC
MYMACROS
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
============================== macros.m4 =================================
AC_DEFUN([MYMACROS], [
  FOO
])
============================== foo.m4 ====================================
AC_DEFUN([FOO], [
  foovar=42
  AC_SUBST([foovar])
])
============================== Makefile.am ===============================
ACLOCAL_AMFLAGS = -I .
noinst_PROGRAMS = foo
foo_SOURCES = foo.c
BUILT_SOURCES = foo.h
foo.h: foo.in.h
        sed -e 's|@''foovar''@|@foovar@|g' $(srcdir)/foo.in.h > address@hidden 
&& \
        mv -f address@hidden $@
MOSTLYCLEANFILES = foo.h foo.h-t
============================== foo.in.h ==================================
#define foo @foovar@
============================== foo.c =====================================
#include "foo.h"
int main () { return 0; }
typedef int check[1 - 2 * (foo != 42)];
==========================================================================
$ aclocal -I .
$ automake -a -c
$ autoconf
$ ./configure
$ make
$ mv foo.m4 foo.m4~ && sed -e '${s/^/barvar=47; AC_SUBST([barvar])/}' < foo.m4~ 
> foo.m4
$ mv Makefile.am Makefile.am~ && sed -e "s/sed /sed -e 
's|@''barvar''@|@barvar@|g' /" < Makefile.am~ > Makefile.am
$ echo '#define bar @barvar@' >> foo.in.h
$ echo 'typedef int check2[1 - 2 * (bar != 47)];' >> foo.c
$ make


>   - An added .h file.
>     Before: configure.ac depends on m4/macros.m4 that AC_SUBSTs STDIO_H to 
> empty.
>             lib/stdio.h is generated through lib/Makefile if STDIO_H is 
> non-empty.
>             lib/foo.c includes stdio.h and needs to be compiled for 'all'.
>     After:  configure.ac depends on m4/macros.m4 that AC_SUBSTs STDIO_H to 
> stdio.h.
>             lib/stdio.h is generated through lib/Makefile if STDIO_H is 
> non-empty.
>             lib/foo.c includes stdio.h and needs to be compiled for 'all'.
>     Here you need to check that after "make", lib/stdio.h is present.

============================== configure.ac ==============================
AC_INIT([dummy], [0])
AM_INIT_AUTOMAKE([foreign])
AC_PROG_CC
MYMACROS
AC_CONFIG_FILES([Makefile])
AC_CONFIG_HEADERS([config.h])
AC_OUTPUT
============================== macros.m4 =================================
AC_DEFUN([MYMACROS], [
  if false; then
    STDIO_H=stdio.h
    use_dummies=1
  else
    STDIO_H=
    use_dummies=0
  fi
  AC_SUBST([STDIO_H])
  AC_DEFINE_UNQUOTED([USE_DUMMIES], [$use_dummies],
    [Whether to use dummy types.])
])
============================== Makefile.am ===============================
ACLOCAL_AMFLAGS = -I .
noinst_PROGRAMS = foo
foo_SOURCES = foo.c
BUILT_SOURCES = $(STDIO_H)
stdio.h: stdio.in.h
        cp $(srcdir)/stdio.in.h $@
MOSTLYCLEANFILES = stdio.h
============================== stdio.in.h ================================
typedef struct dummyfile { void *p; } DUMMYFILE;
============================== foo.c =====================================
#include <config.h>
#include <stdio.h>
#if USE_DUMMIES
DUMMYFILE *f;
#else
FILE *f;
#endif
int main () { return 0; }
==========================================================================
$ aclocal -I .
$ autoheader
$ automake -a -c
$ autoconf
$ ./configure
$ make
$ test ! -f stdio.h
$ mv macros.m4 macros.m4~ && sed -e 's/false/true/' < macros.m4~ > macros.m4
$ make
$ test -f stdio.h

>   - A removed .h file.
>     Before: configure.ac depends on m4/macros.m4 that AC_SUBSTs STDIO_H to 
> stdio.h.
>             lib/stdio.h is generated through lib/Makefile if STDIO_H is 
> non-empty.
>             lib/foo.c includes stdio.h and needs to be compiled for 'all'.
>     After:  configure.ac depends on m4/macros.m4 that AC_SUBSTs STDIO_H to 
> empty.
>             lib/stdio.h is generated through lib/Makefile if STDIO_H is 
> non-empty.
>             lib/foo.c includes stdio.h and needs to be compiled for 'all'.
>     Here you need to check that after "make", lib/stdio.h is gone.

============================== configure.ac ==============================
AC_INIT([dummy], [0])
AM_INIT_AUTOMAKE([foreign])
AC_PROG_CC
MYMACROS
AC_CONFIG_FILES([Makefile])
AC_CONFIG_HEADERS([config.h])
AC_OUTPUT
============================== macros.m4 =================================
AC_DEFUN([MYMACROS], [
  if true; then
    STDIO_H=stdio.h
    use_dummies=1
  else
    STDIO_H=
    use_dummies=0
  fi
  AC_SUBST([STDIO_H])
  AM_CONDITIONAL([REPLACE_STDIO_H], [test -n "$STDIO_H"])
  AC_DEFINE_UNQUOTED([USE_DUMMIES], [$use_dummies],
    [Whether to use dummy types.])
])
============================== Makefile.am ===============================
ACLOCAL_AMFLAGS = -I .
noinst_PROGRAMS = foo
foo_SOURCES = foo.c
BUILT_SOURCES = $(STDIO_H)
if REPLACE_STDIO_H
stdio.h: stdio.in.h $(top_builddir)/config.status
        cp $(srcdir)/stdio.in.h $@
else
stdio.h: $(top_builddir)/config.status
        rm -f $@
endif
MOSTLYCLEANFILES = stdio.h
============================== stdio.in.h ================================
typedef struct dummyfile { void *p; } DUMMYFILE;
============================== foo.c =====================================
#include <config.h>
#include <stdio.h>
#if USE_DUMMIES
DUMMYFILE *f;
#else
FILE *f;
#endif
int main () { return 0; }
==========================================================================
$ aclocal -I .
$ autoheader
$ automake -a -c
$ autoconf
$ ./configure
$ make
$ test -f stdio.h
$ mv macros.m4 macros.m4~ && sed -e 's/true/false/' < macros.m4~ > macros.m4
$ make
$ test ! -f stdio.h


Bruno
-- 
In memoriam Albert Merz <http://en.wikipedia.org/wiki/Albert_Merz>



reply via email to

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