views:

177

answers:

2

I've copied libtool into my program's source tree to distribute it with the program. But when I run 'make distclean' libtool is deleted with the rest of the rest of the generated files. How do I stop that from happening?

I tried putting EXTRA_DIST = libtool in Makefile.am but that doesn't work.

Here is basically what my configure.ac looks like.

AC_PREREQ(2.53)
AC_INIT( [program], [0.16], [program] )
AC_CONFIG_SRCDIR([src/c/program.c])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_AUX_DIR(build-aux)
AM_INIT_AUTOMAKE( [-Wall -Werror foreign] )

m4_include(ax_pkg_swig.m4)

# Checks for programs.
AC_PROG_CC
AC_PROG_LIBTOOL
AC_ENABLE_SHARED
AC_PROG_SWIG

# Checks for libraries.

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h string.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T

# Checks for library functions.
AC_REPLACE_FNMATCH
AC_FUNC_MALLOC
AC_FUNC_STAT
AC_CHECK_FUNCS([regcomp strdup strtoull])

AC_CONFIG_FILES([
    Makefile
    src/c/Makefile
    src/perl/Makefile
    src/verilog/Makefile
])
AC_OUTPUT
+3  A: 

You're not supposed to copy 'libtool' into your program's directory by hand. You run libtoolize in your bootstrap script, which handles this for you. I suppose it's doing more than just copying libtool for you, such as informing automake that it shouldn't delete the file. Here's a sample bootstrap script:

#!/bin/sh
aclocal -I config &&
    libtoolize --force --copy &&
    autoheader &&
    automake --add-missing --copy --foreign &&
    autoconf &&
    ./configure --enable-maintainer-mode --cache-file=config.cache $*

Modern style is to call this script 'bootstrap', but you'll find older projects with similar scripts called autogen.sh.

This will likely need customization. The most important thing to leave as-is is the order of operations. Autotools is sensitive to that. Changing the flags given the programs is fine, though. -I config isn't universal, for instance. Also, there's documentation recommending against running 'configure' from the bootstrap script, but I disagree. :)

By the way, the AC_PROG_LIBTOOL macro is obsolete. You should be using LT_INIT instead.

Warren Young
'bootstrap' conventionally is for scripts that do everything *but* configure.ac'autogen.sh' conventionally does everything 'bootstrap' does, plus configure.
Thomas Vander Stichele
A: 

Actually, you do not need to call all that aclocal and libtoolize and autoheader and...

Just call

$ autoreconf -i

and autoreconf will run aclocal, libtoolize (if there are libtool macros in configure.ac), automake (if configure.ac involves automake) and autoconf. All the respective files that need to be added to your source tree will be copied there, among them ltmain.sh.2

I usually add some verbosity (-v) and instead of just copying the files, I symlink them, resulting in my standard call of

$ autoreconf -vis

The "libtool" file generated by a "configure" run is specific to the system the configure run happened on and thus will of course be cleaned again by "make distclean".

ndim