bug-gnulib
[Top][All Lists]
Advanced

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

AC_LIBSOURCES considered harmful


From: Bruno Haible
Subject: AC_LIBSOURCES considered harmful
Date: Fri, 2 Sep 2005 13:31:52 +0200
User-agent: KMail/1.5

Hi Paul, Jim, Alexandre,

gnulib-tool now supports multiple gnulib directories with a single
configure.ac. Simon needs this in GnuTLS. I need this in libglocale.
But half of gnulib doesn't work with gnulib-tool.

Due to AC_LIBSOURCES.

Paul and Jim, you pushed towards using AC_LIBSOURCES. Could you please
help solving the problem?

To reproduce it:
  - Take and unpack GNU hello-2.1.1.
  - In the hello-2.1.1 directory, do
    $ gnulib-tool --import \
        --source-base=1lib --m4-base=1m4 --lib=lib1 --macro-prefix=gl1 \
        obstack
    $ gnulib-tool --import \
        --source-base=2lib --m4-base=2m4 --lib=lib2 --macro-prefix=gl2 \
        --avoid=exit --avoid=exitfail \
        quote
    and follow the Makefile.am + configure.ac advices that it prints.

    (The idea is that lib1 will be LGPLed and used in a library, while
    lib2 is GPLed and will be used by the bundled programs.)

  - Then
    $ autoreconf

It says:
1lib/Makefile.am:18: required file `1lib/quotearg.h' not found
1lib/Makefile.am:18: required file `1lib/quote.h' not found
1lib/Makefile.am:18: required file `1lib/error.c' not found
1lib/Makefile.am:18: required file `1lib/error.h' not found
1lib/Makefile.am:18: required file `1lib/quote.c' not found
1lib/Makefile.am:18: required file `1lib/quotearg.c' not found
1lib/Makefile.am:18: required file `1lib/xalloc.h' not found
1lib/Makefile.am:18: required file `1lib/xmalloc.c' not found
2lib/Makefile.am:18: required file `2lib/obstack.h' not found
2lib/Makefile.am:18: required file `2lib/exitfail.h' not found
2lib/Makefile.am:18: required file `2lib/obstack.c' not found
2lib/Makefile.am:18: required file `2lib/exitfail.c' not found
autoreconf: automake failed with exit status: 1

The reason is, as Simon explained, that the LIBOBJS are combined, and
automake expects to see the source files of both libraries in _each_
directory.

  - Try to trick out automake by overriding AC_LIBSOURCES, like this:


============================ 1m4/gnulib-comp.m4 ============================
# Copyright (C) 2004 Free Software Foundation, Inc.
# This file is free software, distributed under the terms of the GNU
# General Public License.  As a special exception to the GNU General
# Public License, this file may be distributed as part of a program
# that contains a configuration script generated by Autoconf, under
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
#
# This file represents the compiled summary of the specification in
# gnulib-cache.m4. It lists the computed macro invocations that need
# to be invoked from configure.ac.
# In projects using CVS, this file can be treated like other built files.


# This macro should be invoked from ./configure.ac, in the section
# "Checks for programs", right after AC_PROG_CC, and certainly before
# any checks for libraries, header files, types and library functions.
AC_DEFUN([gl1_EARLY],
[
])

# This macro should be invoked from ./configure.ac, in the section
# "Check for header files, types and library functions".
AC_DEFUN([gl1_INIT],
[
  dnl Like AC_LIBOBJ, except that the module name goes into gl1_OBJS
  dnl instead of into LIBOBJS.
  AC_DEFUN([gt_gl1__OBJ],
    [gl1_OBJS="$gl1_OBJS $1.$ac_objext"])

  dnl Like AC_REPLACE_FUNCS, except that the module name goes into gl1_OBJS
  dnl instead of into LIBOBJS.
  AC_DEFUN([gt_gl1__REPLACE_FUNCS],
    [AC_CHECK_FUNCS([$1], , [gt_gl1__OBJ($ac_func)])])

  dnl Like AC_LIBSOURCES, except that it does nothing. This is needed to
  dnl silence automake errors "required file `lib/error.h' not found" and
  dnl "required file `lib/error.c' not found" that are triggered by the
  dnl AC_LIBSOURCES invocation inside AC_FUNC_ERROR_AT_LINE.
  AC_DEFUN([gt_gl1__SOURCES], [])

  m4_pushdef([AC_LIBOBJ], m4_defn([gt_gl1__OBJ]))
  m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gt_gl1__REPLACE_FUNCS]))
  m4_pushdef([AC_LIBSOURCES], m4_defn([gt_gl1__SOURCES]))

  gl_EXITFAIL
  gl_OBSTACK

  m4_popdef([AC_LIBSOURCES])
  m4_popdef([AC_REPLACE_FUNCS])
  m4_popdef([AC_LIBOBJ])
  AC_SUBST([gl1_OBJS])
])

# This macro records the list of files which have been installed by
# gnulib-tool and may be removed by future gnulib-tool invocations.
AC_DEFUN([gl1_FILE_LIST], [
  lib/exit.h
  lib/exitfail.c
  lib/exitfail.h
  lib/gettext.h
  lib/obstack.c
  lib/obstack.h
  m4/exitfail.m4
  m4/inttypes_h.m4
  m4/obstack.m4
  m4/onceonly_2_57.m4
  m4/stdint_h.m4
  m4/uintmax_t.m4
  m4/ulonglong.m4
])

# gnulib-comp.m4 ends here
============================ 1m4/gnulib-comp.m4 ============================
# Copyright (C) 2004 Free Software Foundation, Inc.
# This file is free software, distributed under the terms of the GNU
# General Public License.  As a special exception to the GNU General
# Public License, this file may be distributed as part of a program
# that contains a configuration script generated by Autoconf, under
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
#
# This file represents the compiled summary of the specification in
# gnulib-cache.m4. It lists the computed macro invocations that need
# to be invoked from configure.ac.
# In projects using CVS, this file can be treated like other built files.


# This macro should be invoked from ./configure.ac, in the section
# "Checks for programs", right after AC_PROG_CC, and certainly before
# any checks for libraries, header files, types and library functions.
AC_DEFUN([gl2_EARLY],
[
])

# This macro should be invoked from ./configure.ac, in the section
# "Check for header files, types and library functions".
AC_DEFUN([gl2_INIT],
[
  dnl Like AC_LIBOBJ, except that the module name goes into gl2_OBJS
  dnl instead of into LIBOBJS.
  AC_DEFUN([gt_gl2__OBJ],
    [gl2_OBJS="$gl2_OBJS $1.$ac_objext"])

  dnl Like AC_REPLACE_FUNCS, except that the module name goes into gl2_OBJS
  dnl instead of into LIBOBJS.
  AC_DEFUN([gt_gl2__REPLACE_FUNCS],
    [AC_CHECK_FUNCS([$1], , [gt_gl2__OBJ($ac_func)])])

  dnl Like AC_LIBSOURCES, except that it does nothing. This is needed to
  dnl silence automake errors "required file `lib/error.h' not found" and
  dnl "required file `lib/error.c' not found" that are triggered by the
  dnl AC_LIBSOURCES invocation inside AC_FUNC_ERROR_AT_LINE.
  AC_DEFUN([gt_gl2__SOURCES], [])

  m4_pushdef([AC_LIBOBJ], m4_defn([gt_gl2__OBJ]))
  m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gt_gl2__REPLACE_FUNCS]))
  m4_pushdef([AC_LIBSOURCES], m4_defn([gt_gl2__SOURCES]))

  gl_ERROR
  gl_QUOTE
  gl_QUOTEARG
  AM_STDBOOL_H
  gl_XALLOC

  m4_popdef([AC_LIBSOURCES])
  m4_popdef([AC_REPLACE_FUNCS])
  m4_popdef([AC_LIBOBJ])
  AC_SUBST([gl2_OBJS])
])

# This macro records the list of files which have been installed by
# gnulib-tool and may be removed by future gnulib-tool invocations.
AC_DEFUN([gl2_FILE_LIST], [
  lib/error.c
  lib/error.h
  lib/gettext.h
  lib/quote.c
  lib/quote.h
  lib/quotearg.c
  lib/quotearg.h
  lib/stdbool_.h
  lib/xalloc-die.c
  lib/xalloc.h
  lib/xmalloc.c
  m4/error.m4
  m4/mbrtowc.m4
  m4/mbstate_t.m4
  m4/onceonly_2_57.m4
  m4/quote.m4
  m4/quotearg.m4
  m4/stdbool.m4
  m4/strerror_r.m4
  m4/xalloc.m4
])

# gnulib-comp.m4 ends here
============================================================================

  - "autoreconf" now works fine, but after configure:

  1) When you do "make", no quote.c is compiled in the 2lib/ directory.
     Instead:

make[3]: Entering directory `/dev/shm/tmp2/hello-2.1.1/2lib'
gcc -DHAVE_CONFIG_H -I. -I. -I..     -g -O2 -c xalloc-die.c
xalloc-die.c:29:22: exitfail.h: No such file or directory
xalloc-die.c: In function `xalloc_die':
xalloc-die.c:38: error: `exit_failure' undeclared (first use in this function)

  2) When you do "make dist", you see that 2lib/quote.[hc] are omitted
     from the tarball.

The reason for both is that most source files are not listed in Makefile.am.


How do you want to fix this? It is very hard because automake's
AC_LIBSOURCES treatment is the only way to move information from a *.m4
file to a Makefile.am file; this treatment is limited to a single
list of source files in a single directory; and automake offers no other,
similar means of moving information from *.m4 to Makefile.am.

Bruno





reply via email to

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