From: Alexandre Duret-Lutz Date: Thu, 31 Jul 2003 20:28:00 +0000 (+0000) Subject: * automake.texi (A Shared Library): Rewrite and split into X-Git-Tag: Release-1-7b~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=524cffcb28066181576cb55e5bd26a9b573f8aaf;p=thirdparty%2Fautomake.git * automake.texi (A Shared Library): Rewrite and split into subsections. Valuable comments from Norman Gray, Harlan Stenn, Tim Van Holder, and Guido Draheim. * tests/ltcond.test, tests/ltcond2.test, tests/ltconv.test: New files. * tests/Makefile.am (TESTS): Add them. --- diff --git a/ChangeLog b/ChangeLog index 59df3516c..bae8e5970 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2003-07-31 Alexandre Duret-Lutz + + * automake.texi (A Shared Library): Rewrite and split into + subsections. Valuable comments from Norman Gray, Harlan Stenn, + Tim Van Holder, and Guido Draheim. + * tests/ltcond.test, tests/ltcond2.test, tests/ltconv.test: New files. + * tests/Makefile.am (TESTS): Add them. + 2003-07-30 Alexandre Duret-Lutz * automake.in (handle_single_transform_list): Complain about diff --git a/THANKS b/THANKS index 629dfde38..6f89f431f 100644 --- a/THANKS +++ b/THANKS @@ -153,6 +153,7 @@ Nicolas Joly njoly@pasteur.fr Nicolas Thiery nthiery@Icare.mines.edu NISHIDA Keisuke knishida@nn.iij4u.or.jp Noah Friedman friedman@gnu.ai.mit.edu +Norman Gray norman@astro.gla.ac.uk Nyul Laszlo nyul@sol.cc.u-szeged.hu OKUJI Yoshinori okuji@kuicr.kyoto-u.ac.jp Olivier Louchart-Fletcher olivier@zipworld.com.au diff --git a/automake.texi b/automake.texi index 4ba36df97..4e310c15e 100644 --- a/automake.texi +++ b/automake.texi @@ -2175,7 +2175,7 @@ are part of it, and which libraries it should be linked with. This section also covers conditional compilation of sources or programs. Most of the comments about these also apply to libraries -(@pxref{A Library}) and Libtool libraries (@pxref{A Shared Library}). +(@pxref{A Library}) and libtool libraries (@pxref{A Shared Library}). @menu * Program Sources:: Defining program sources @@ -2475,7 +2475,7 @@ name of the primary is @samp{LIBRARIES}. Libraries can be installed in @code{libdir} or @code{pkglibdir}. @xref{A Shared Library}, for information on how to build shared -libraries using Libtool and the @samp{LTLIBRARIES} primary. +libraries using libtool and the @samp{LTLIBRARIES} primary. Each @samp{_LIBRARIES} variable is a list of the libraries to be built. For instance to create a library named @file{libcpio.a}, but not install @@ -2526,71 +2526,384 @@ variable (@pxref{Program and Library Variables}). @cindex Shared libraries, support for -Building shared libraries is a relatively complex matter. For this -reason, GNU Libtool (@pxref{Top, , Introduction, libtool, The +Building shared libraries portably is a relatively complex matter. +For this reason, GNU Libtool (@pxref{Top, , Introduction, libtool, The Libtool Manual}) was created to help build shared libraries in a platform-independent way. +@menu +* Libtool Concept:: Introducing Libtool +* Libtool Libraries:: Declaring Libtool Libraries +* Conditional Libtool Libraries:: Building Libtool Libraries Conditionally +* Conditional Libtool Sources:: Choosing Library Sources Conditionally +* Libtool Convenience Libraries:: Building Convenience Libtool Libraries +* Libtool Modules:: Building Libtool Modules +* Libtool Flags:: Using _LIBADD and _LDFLAGS +* LTLIBOBJ:: Using $(LTLIBOBJ) +* Libtool Issues:: Common Issues Related to Libtool's Use +@end menu + +@node Libtool Concept +@subsection The Libtool Concept + +@cindex libtool, introduction +@cindex libtool library, definition +@cindex suffix .la, defined +@cindex .la suffix, defined + +Libtool abstracts shared and static libraries into a unified +concept henceforth called @dfn{libtool libraries}. Libtool libraries +are files using the @file{.la} suffix, and can designate a static +library, a shared library, or maybe both. Their exact nature cannot +be determined until @file{./configure} is run: not all platforms +support all kinds of libraries, and users can explicitly select which +libraries should be built. (However the package's maintainers can +tune the default, @xref{AC_PROG_LIBTOOL, , The @code{AC_PROG_LIBTOOL} +macro, libtool, The Libtool Manual}.) + +@cindex suffix .lo, defined +Because object files for shared and static libraries must be compiled +differently, libtool is also used during compilation. Object files +built by libtool are called @dfn{libtool objects}: these are files +using the @file{.lo} suffix. Libtool libraries are built from these +libtool objects. + +You should not assume anything about the structure of @file{.la} or +@file{.lo} files and how libtool constructs them: this is libtool's +concern, and the last thing one wants is to learn about libtool's +guts. However the existence of these files matters, because they are +used as targets and dependencies in @file{Makefile}s when building +libtool libraries. There are situations where you may have to refer +to these, for instance when expressing dependencies for building +source files conditionally (@pxref{Conditional Libtool Sources}). + +@cindex libltdl, introduction + +People considering writing a plug-in system, with dynamically loaded +modules, should look into @file{libltdl}: libtool's dlopening library +(@pxref{Using libltdl, , Using libltdl, libtool, The Libtool Manual}). +This offers a portable dlopening facility to load libtool libraries +dynamically, and can also achieve static linking where unavoidable. + +Before we discuss how to use libtool with Automake in details, it +should be noted that the libtool manual also has a section about how +to use Automake with libtool (@pxref{Using Automake, , Using Automake +with Libtool, libtool, The Libtool Manual}). + +@node Libtool Libraries +@subsection Building Libtool Libraries + @cindex _LTLIBRARIES primary, defined @cindex LTLIBRARIES primary, defined @cindex Primary variable, LTLIBRARIES @cindex Example of shared libraries +@vindex lib_LTLIBRARIES +@vindex pkglib_LTLIBRARIES -@cindex suffix .la, defined - -Automake uses Libtool to build libraries declared with the -@samp{LTLIBRARIES} primary. Each @samp{_LTLIBRARIES} variable is a list -of shared libraries to build. For instance, to create a library named -@file{libgettext.a} and its corresponding shared libraries, and install -them in @samp{libdir}, write: +Automake uses libtool to build libraries declared with the +@samp{LTLIBRARIES} primary. Each @samp{_LTLIBRARIES} variable is a +list of libtool libraries to build. For instance, to create a libtool +library named @file{libgettext.la}, and install it in @samp{libdir}, +write: @example lib_LTLIBRARIES = libgettext.la +libgettext_la_SOURCES = gettext.c gettext.h @dots{} @end example -@vindex lib_LTLIBRARIES -@vindex pkglib_LTLIBRARIES +Automake predefines the variable @samp{pkglibdir}, so you can use +@code{pkglib_LTLIBRARIES} to install libraries in +@code{$(libdir)/@@PACKAGE@@/}. + +@node Conditional Libtool Libraries +@subsection Building Libtool Libraries Conditionally +@cindex libtool libraries, conditional +@cindex conditional libtool libraries + +Like conditional programs (@pxref{Conditional Programs}), there are +two main ways to build conditional libraries: using Automake +conditionals or using Autoconf @code{AC_SUBST}itutions. + +The important implementation detail you have to be aware of is that +the place where a library will be installed matters to libtool: it +needs to be indicated @emph{at link-time} using the @code{-rpath} +option. + +For libraries whose destination directory is known when Automake runs, +Automake will automatically supply the appropriate @samp{-rpath} +option to libtool. This is the case for libraries listed explicitly in +some installable @code{_LTLIBRARIES} variables such as +@code{lib_LTLIBRARIES}. + +However, for libraries determined at configure time (and thus +mentioned in @code{EXTRA_LTLIBRARIES}), Automake does not know the +final installation directory. For such libraries you must add the +@samp{-rpath} option to the appropriate @samp{_LDFLAGS} variable by +hand. + +The examples below illustrate the differences between these two methods. + +Here is an example where @code{$(WANTEDLIBS)} is an @code{AC_SUBST}ed +variable set at @file{./configure}-time to either @file{libfoo.la}, +@file{libbar.la}, both, or none. Although @code{$(WANTEDLIBS)} +appears in the @code{lib_LTLIBRARIES}, Automake cannot guess it +relates to @file{libfoo.la} or @file{libbar.la} by the time it creates +the link rule for these two libraries. Therefore the @code{-rpath} +argument must be explicitly supplied. + +@example +EXTRA_LTLIBRARIES = libfoo.la libbar.la +lib_LTLIBRARIES = $(WANTEDLIBS) +libfoo_la_SOURCES = foo.c @dots{} +libfoo_la_LDFLAGS = -rpath '$(libdir)' +libbar_la_SOURCES = bar.c @dots{} +libbar_la_LDFLAGS = -rpath '$(libdir)' +@end example + +Here is how the same @file{Makefile.am} would look using Automake +conditionals named @code{WANT_LIBFOO} and @code{WANT_LIBBAR}. Now +Automake is able to compute the @code{-rpath} setting itself, because +it's clear that both libraries will end up in @code{$(libdir)} if they +are installed. + +@example +lib_LTLIBRARIES = +if WANT_LIBFOO +lib_LTLIBRARIES += libfoo.la +endif +if WANT_LIBBAR +lib_LTLIBRARIES += libbar.la +endif +libfoo_la_SOURCES = foo.c @dots{} +libbar_la_SOURCES = bar.c @dots{} +@end example + +@node Conditional Libtool Sources +@subsection Libtool Libraries with Conditional Sources + +Conditional compilation of sources in a library can be achieved in the +same way as conditional compilation of sources in a program +(@pxref{Conditional Sources}). The only difference is that +@code{_LIBADD} should be used instead of @code{_LDADD} and that it +should mention libtool objects (@file{.lo} files). + +So, to mimic the @file{hello} example from @ref{Conditional Sources}, +we could build a @file{libhello.la} library using either +@file{hello-linux.c} or @file{hello-generic.c} with the following +@file{Makefile.am}. + +@example +lib_LTLIBRARIES = libhello.la +libhello_la_SOURCES = hello-common.c +EXTRA_libhello_la_SOURCES = hello-linux.c hello-generic.c +libhello_la_LIBADD = $(HELLO_SYSTEM) +libhello_la_DEPENDENCIES = $(HELLO_SYSTEM) +@end example + +@noindent +And make sure @code{$(HELLO_SYSTEM)} is set to either +@file{hello-linux.lo} or @file{hello-generic.lo} in +@file{./configure}. + +Or we could simply use an Automake conditional as follows. + +@example +lib_LTLIBRARIES = libhello.la +libhello_la_SOURCES = hello-common.c +if LINUX +libhello_la_SOURCES += hello-linux.c +else +libhello_la_SOURCES += hello-generic.c +endif +@end example + +@node Libtool Convenience Libraries +@subsection Libtool Convenience Libraries +@cindex convenience libraries, libtool +@cindex libtool convenience libraries @vindex noinst_LTLIBRARIES @vindex check_LTLIBRARIES -@cindex check_LTLIBRARIES, not allowed +Sometimes you want to build libtool libraries which should not be +installed. These are called @dfn{libtool convenience libraries} and +are typically used to encapsulate many sublibraries, later gathered +into one big installed library. -Note that shared libraries @emph{must} be installed in order to work -properly, so @code{check_LTLIBRARIES} is not allowed. However, -@code{noinst_LTLIBRARIES} is allowed. This feature should be used for -libtool ``convenience libraries''. +Libtool convenience libraries are declared by +@code{noinst_LTLIBRARIES}, @code{check_LTLIBRARIES}, or even +@code{EXTRA_LTLIBRARIES}. Unlike installed libtool libraries they do +not need an @code{-rpath} flag at link time (actually this is the only +difference). -@cindex suffix .lo, defined +Convenience libraries listed in @code{noinst_LTLIBRARIES} are always +built. Those listed in @code{check_LTLIBRARIES} are built only upon +@code{make check}. Finally, libraries listed in +@code{EXTRA_LTLIBRARIES} are never built explicitly: Automake outputs +rules to build them, but if the library does not appear as a Makefile +dependency anywhere it won't be built (this is why +@code{EXTRA_LTLIBRARIES} is used for conditional compilation). + +Here is a sample setup merging libtool convenience libraries from +subdirectories into one main @file{libtop.la} library. + +@example +# -- Top-level Makefile.am -- +SUBDIRS = sub1 sub2 @dots{} +lib_LTLIBRARIES = libtop.la +libtop_la_SOURCES = +libtop_la_LIBADD = \ + sub1/libsub1.la \ + sub2/libsub2.la \ + @dots{} + +# -- sub1/Makefile.am -- +noinst_LTLIBRARIES = libsub1.la +libsub1_la_SOURCES = @dots{} + +# -- sub2/Makefile.am -- +# showing nested convenience libraries +SUBDIRS = sub2.1 sub2.2 @dots{} +noinst_LTLIBRARIES = libsub2.la +libsub2_la_SOURCES = +libsub2_la_LIBADD = \ + sub21/libsub21.la \ + sub22/libsub22.la \ + @dots{} +@end example + +@node Libtool Modules +@subsection Libtool Modules +@cindex modules, libtool +@cindex libtool modules +@cindex -module, libtool + +These are libtool libraries meant to be dlopened. They are +indicated to libtool by passing @code{-module} at link-time. + +@example +pkglib_LTLIBRARIES = mymodule.la +mymodule_la_SOURCES = doit.c +mymodule_LDFLAGS = -module +@end example + +Ordinarily, Automake requires that a Library's name starts with +@samp{lib}. However, when building a dynamically loadable module you +might wish to use a "nonstandard" name. + +@node Libtool Flags +@subsection _LIBADD and _LDFLAGS +@cindex _LIBADD, libtool +@cindex _LDFLAGS, libtool + +As shown in previous sections, the @samp{@var{library}_LIBADD} +variable should be used to list extra libtool objects (@file{.lo} +files) or libtool libraries (@file{.la}) to add to @var{library}. -For each library, the @samp{@var{library}_LIBADD} variable contains the -names of extra libtool objects (@file{.lo} files) to add to the shared -library. The @samp{@var{library}_LDFLAGS} variable contains any -additional libtool flags, such as @samp{-version-info} or -@samp{-static}. +The @samp{@var{library}_LDFLAGS} variable is the place to list +additional libtool flags, such as @samp{-version-info}, +@samp{-static}, and a lot more. See @xref{Link mode, , Using libltdl, +libtool, The Libtool Manual}. +@node LTLIBOBJ, Libtool Issues, Libtool Flags, A Shared Library +@subsection @code{LTLIBOBJS} @cindex @code{LTLIBOBJS}, special handling +@vindex LTLIBOBJS +@vindex LIBOBJS +@cvindex AC_LIBOBJ Where an ordinary library might include @code{$(LIBOBJS)}, a libtool library must use @code{$(LTLIBOBJS)}. This is required because the object files that libtool operates on do not necessarily end in -@file{.o}. The libtool manual contains more details on this topic. +@file{.o}. + +Nowadays, the computation of @code{LTLIBOBJS} from @code{LIBOBJS} is +performed automatically by Autoconf (@pxref{AC_LIBOBJ vs LIBOBJS, , +@code{AC_LIBOBJ} vs. @code{LIBOBJS}, autoconf, The Autoconf Manual}). + +@node Libtool Issues +@subsection Common Issues Related to Libtool's Use + +@subsubsection @code{required file `./ltmain.sh' not found} +@cindex ltmain.sh not found +@cindex libtoolize, no longer run by Automake +@cindex libtoolize and autoreconf +@cindex autoreconf and libtoolize +@cindex bootstrap.sh and autoreconf +@cindex autogen.sh and autoreconf + +Libtool comes with a tool called @command{libtoolize} that will +install libtool's supporting files into a package. Running this +command will install @file{ltmain.sh}. You should execute it before +@command{aclocal} and @command{automake}. + +People upgrading old packages to newer autotools are likely to face +this issue because older Automake versions used to call +@command{libtoolize}. Therefore old build scripts do not call +@command{libtoolize}. + +Since Automake 1.6, it has been decided that running +@command{libtoolize} was none of Automake's business. Instead, that +functionality has been moved into the @command{autoreconf} command +(@pxref{autoreconf Invocation, , Using @command{autoreconf}, autoconf, +The Autoconf Manual}). If you do not want to remember what to run and +when, just learn the @command{autoreconf} command. Hopefully, +replacing existing @file{bootstrap.sh} or @file{autogen.sh} scripts by +a call to @command{autoreconf} should also free you from any similar +incompatible change in the future. + +@subsubsection Objects @code{created with both libtool and without} + +Sometimes, the same source file is used both to build a libtool +library and to build another non-libtool target (be it a program or +another library). + +Let's consider the following @file{Makefile.am}. -For libraries installed in some directory, Automake will automatically -supply the appropriate @samp{-rpath} option. However, for libraries -determined at configure time (and thus mentioned in -@code{EXTRA_LTLIBRARIES}), Automake does not know the eventual -installation directory; for such libraries you must add the -@samp{-rpath} option to the appropriate @samp{_LDFLAGS} variable by -hand. +@example +bin_PROGRAMS = prog +prog_SOURCES = prog.c foo.c @dots{} -Ordinarily, Automake requires that a shared library's name start with -@samp{lib}. However, if you are building a dynamically loadable module -then you might wish to use a "nonstandard" name. In this case, put -@code{-module} into the @samp{_LDFLAGS} variable. +lib_LTLIBRARIES = libfoo.la +libfoo_la_SOURCES = foo.c @dots{} +@end example -@xref{Using Automake, Using Automake with Libtool, The Libtool Manual, -libtool, The Libtool Manual}, for more information. +@noindent +(In this trivial case the issue could be avoided by linking +@file{libfoo.la} with @file{prog} instead of listing @file{foo.c} in +@code{prog_SOURCES}. But let's assume we really want to keep +@file{prog} and @file{libfoo.la} separate.) + +Technically, it means that we should build @file{foo.$(OBJEXT)} for +@file{prog}, and @file{foo.lo} for @file{libfoo.la}. The problem is +that in the course of creating @file{foo.lo}, libtool may erase (or +replace) @file{foo.$(OBJEXT)} -- and this cannot be avoided. + +Therefore, when Automake detects this situation it will complain +with a message such as +@example +object `foo.$(OBJEXT)' created both with libtool and without +@end example +A workaround for this issue is to ensure that these two objects get +different basenames. As explained in @ref{renamed objects}, this +happens automatically when per-targets flags are used. + +@example +bin_PROGRAMS = prog +prog_SOURCES = prog.c foo.c @dots{} +prog_CFLAGS = $(AM_CFLAGS) + +lib_LTLIBRARIES = libfoo.la +libfoo_la_SOURCES = foo.c @dots{} +@end example + +@noindent +Adding @code{prog_CFLAGS = $(AM_CFLAGS)} is almost a no-op, because +when the @code{prog_CFLAGS} is defined, it is used instead of +@code{AM_CFLAGS}. However as a side effect it will cause +@file{prog.c} and @file{foo.c} to be compiled as +@file{prog-prog.$(OBJEXT)} and @file{prog-foo.$(OBJEXT)} which solves +the issue. @node Program and Library Variables @section Program and Library Variables @@ -5668,7 +5981,7 @@ development safer by ensuring a @file{configure} is never out-of-date with respect to @file{configure.in}. As generated files shipped in packages are up-to-date, and because -@command{tar} preserves timestamps, these rebuild rules are not +@command{tar} preserves times-tamps, these rebuild rules are not triggered when a user unpacks and builds a package. @subsection Background: CVS and timestamps @@ -5686,7 +5999,7 @@ However, during @command{cvs update}, files will have the date of the update, not the original timestamp of this revision. This is meant to make sure that @command{make} notices sources files have been updated. -This timestamp shift is troublesome when both sources and generated +This times tamp shift is troublesome when both sources and generated files are kept under CVS. Because CVS processes files in alphabetical order, @file{configure.in} will appear older than @file{configure} after a @command{cvs update} that updates both files, even if @@ -6209,7 +6522,7 @@ Note that the renaming of objects is also affected by the @c LocalWords: yylhs yylen yydefred yydgoto yysindex yyrindex yygindex yyname @c LocalWords: yytable yycheck yyrule byacc CXXCOMPILE CXXLINK FLINK cfortran @c LocalWords: Catalogue preprocessable FLIBS libfoo baz JAVACFLAGS java exe -@c LocalWords: SunOS fying basenames exeext uninstalled oldinclude kr +@c LocalWords: SunOS fying basenames exeext uninstalled oldinclude kr FSF's @c LocalWords: pkginclude oldincludedir sysconf sharedstate localstate gcc rm @c LocalWords: sysconfdir sharedstatedir localstatedir preexist CLEANFILES gz @c LocalWords: unnumberedsubsec depfile tmpdepfile depmode const interoperate @@ -6226,6 +6539,9 @@ Note that the renaming of objects is also affected by the @c LocalWords: ARGS taggable ETAGSFLAGS lang ctags CTAGSFLAGS GTAGS gtags idl @c LocalWords: foocc doit idlC multilibs ABIs cmindex defmac ARG enableval @c LocalWords: MSG xtrue DBG pathchk CYGWIN afile proglink versioned CVS's -@c LocalWords: wildcards Autoconfiscated subsubheading autotools Meyering -@c LocalWords: ois's wildcard Wportability cartouche vrindex printindex -@c LocalWords: DSOMEFLAG DVERSION +@c LocalWords: wildcards Autoconfiscated subsubheading autotools Meyering API +@c LocalWords: ois's wildcard Wportability cartouche vrindex printindex Duret +@c LocalWords: DSOMEFLAG DVERSION automake Lutz insertcopying versioning FAQ +@c LocalWords: LTLIBOBJ Libtool's libtool's libltdl dlopening itutions libbar +@c LocalWords: WANTEDLIBS libhello sublibraries libtop libsub dlopened Ratfor +@c LocalWords: mymodule timestamps timestamp diff --git a/stamp-vti b/stamp-vti index 24106ae96..03e1d2b64 100644 --- a/stamp-vti +++ b/stamp-vti @@ -1,4 +1,4 @@ -@set UPDATED 27 July 2003 +@set UPDATED 31 July 2003 @set UPDATED-MONTH July 2003 @set EDITION 1.7a @set VERSION 1.7a diff --git a/tests/Makefile.am b/tests/Makefile.am index a7b1490c8..e8e73d104 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -278,6 +278,9 @@ lisp4.test \ lisp5.test \ listval.test \ location.test \ +ltcond.test \ +ltcond2.test \ +ltconv.test \ ltdeps.test \ ltlibobjs.test \ maintclean.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index b879bb510..81a0b6e49 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -389,6 +389,9 @@ lisp4.test \ lisp5.test \ listval.test \ location.test \ +ltcond.test \ +ltcond2.test \ +ltconv.test \ ltdeps.test \ ltlibobjs.test \ maintclean.test \ diff --git a/tests/ltcond.test b/tests/ltcond.test new file mode 100755 index 000000000..449d22d0d --- /dev/null +++ b/tests/ltcond.test @@ -0,0 +1,108 @@ +#!/bin/sh +# Copyright (C) 2003 Free Software Foundation, Inc. +# +# This file is part of GNU Automake. +# +# GNU Automake is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# GNU Automake is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Automake; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# Test for conditional libtool libraries. +# This combines two examples from the manual. + +required='libtoolize gcc' +. ./defs || exit 1 + +set -e + +cat >>configure.in <<'END' +AM_CONDITIONAL([WANT_LIBFOO], [true]) +AM_CONDITIONAL([WANT_LIBBAR], [false]) +AC_SUBST([WANTEDLIBS], ['lib1foo.la lib1bar.la']) +AC_PROG_CC +AC_PROG_LIBTOOL +AC_OUTPUT +END + +cat >Makefile.am <<'END' +EXTRA_LTLIBRARIES = lib1foo.la lib1bar.la lib3bar.la +lib_LTLIBRARIES = $(WANTEDLIBS) +lib1foo_la_SOURCES = foo.c +lib1foo_la_LDFLAGS = -rpath '$(libdir)' +lib1bar_la_SOURCES = bar.c +lib1bar_la_LDFLAGS = -rpath '$(libdir)' +lib3bar_la_SOURCES = bar.c + +if WANT_LIBFOO +lib_LTLIBRARIES += lib2foo.la +check_LTLIBRARIES = lib3foo.la +endif +if WANT_LIBBAR +lib_LTLIBRARIES += lib2bar.la +endif +lib2foo_la_SOURCES = foo.c +lib2bar_la_SOURCES = bar.c +lib3foo_la_SOURCES = foo.c +END + +echo 'int one () { return 1; }' >foo.c +echo 'int two () { return 2; }' >bar.c + +mkdir empty + +libtoolize +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +# Install libraries in lib/, and the rest in empty/. +# (in fact there is no "rest", so as the name imply empty/ is +# expected to remain empty). +./configure --prefix=`pwd`/empty --libdir=`pwd`/lib + +$MAKE +test -f lib1foo.la +test -f lib1bar.la +test -f lib2foo.la +test ! -f lib2bar.la +test ! -f lib3foo.la +test ! -f lib3bar.la + +$MAKE check +test ! -f lib2bar.la +test -f lib3foo.la +test ! -f lib3bar.la + +$MAKE install +test -f lib/lib1foo.la +test -f lib/lib1bar.la +test -f lib/lib2foo.la +test -f lib/lib3foo.la +find empty -type f -print > empty.lst +cat empty.lst +test 0 = `wc -l < empty.lst` + +$MAKE uninstall +find lib -type f -print > lib.lst +test 0 = `wc -l < lib.lst` +test -f lib1foo.la +test -f lib1bar.la +test -f lib2foo.la +test -f lib3foo.la + +$MAKE clean +test ! -f lib1foo.la +test ! -f lib1bar.la +test ! -f lib2foo.la +test ! -f lib3foo.la diff --git a/tests/ltcond2.test b/tests/ltcond2.test new file mode 100755 index 000000000..de6d7beec --- /dev/null +++ b/tests/ltcond2.test @@ -0,0 +1,81 @@ +#! /bin/sh +# Copyright (C) 2003 Free Software Foundation, Inc. +# +# This file is part of GNU Automake. +# +# GNU Automake is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# GNU Automake is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Automake; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# Test for bug in conditionals. + +required='libtoolize gcc' +. ./defs || exit 1 + +set -e + +cat >> configure.in << 'END' +AC_PROG_CC +AC_PROG_LIBTOOL +AC_SUBST([HELLO_SYSTEM], [hello-generic.lo]) +AM_CONDITIONAL([LINUX], true) +AC_OUTPUT +END + +cat > Makefile.am << 'END' +lib_LTLIBRARIES = libhello.la +libhello_la_SOURCES = hello-common.c +EXTRA_libhello_la_SOURCES = hello-linux.c hello-generic.c +libhello_la_LIBADD = $(HELLO_SYSTEM) +libhello_la_DEPENDENCIES = $(HELLO_SYSTEM) + +lib_LTLIBRARIES += libhello2.la +libhello2_la_SOURCES = hello-common.c +if LINUX +libhello2_la_SOURCES += hello-linux.c +else +libhello2_la_SOURCES += hello-generic.c +endif + +bin_PROGRAMS = hello hello2 +hello_SOURCES = main.c +hello_LDADD = libhello.la +hello2_SOURCES = main.c +hello2_LDADD = libhello2.la + +check-local: + ./hello$(EXEEXT) | grep hello-generic + ./hello2$(EXEEXT) | grep hello-linux + : > check-ok +END + +echo 'char* str() { return "hello-linux"; }' >hello-linux.c +echo 'char* str() { return "hello-generic"; }' >hello-generic.c +cat >hello-common.c <<'END' +#include +char* str(); +void print() +{ + puts (str ()); +} +END +echo 'int main() { print(); return 0; }' >main.c + +libtoolize +$ACLOCAL +$AUTOCONF +$AUTOMAKE +./configure +$MAKE check +test -f check-ok diff --git a/tests/ltconv.test b/tests/ltconv.test new file mode 100755 index 000000000..a3f38ae7c --- /dev/null +++ b/tests/ltconv.test @@ -0,0 +1,159 @@ +#!/bin/sh +# Copyright (C) 2003 Free Software Foundation, Inc. +# +# This file is part of GNU Automake. +# +# GNU Automake is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# GNU Automake is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Automake; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# Test for libtool convenience libraries. +# This example is taken from the manual. + +required='libtoolize gcc' +. ./defs || exit 1 + +set -e + +cat >>configure.in <<'END' +AC_PROG_CC +AC_PROG_LIBTOOL +AC_CONFIG_FILES(sub1/Makefile + sub2/Makefile + sub2/sub21/Makefile + sub2/sub22/Makefile) +AC_OUTPUT +END + +mkdir sub1 +mkdir sub2 +mkdir sub2/sub21 +mkdir sub2/sub22 +mkdir empty + +cat >Makefile.am <<'END' +SUBDIRS = sub1 sub2 +lib_LTLIBRARIES = libtop.la +libtop_la_SOURCES = +libtop_la_LIBADD = \ + sub1/libsub1.la \ + sub2/libsub2.la + +bin_PROGRAMS = ltconvtest +ltconvtest_SOURCES = test.c +ltconvtest_LDADD = libtop.la + +check-local: + ./ltconvtest$(EXEEXT) + : > check-ok +installcheck-local: + $(bindir)/ltconvtest$(EXEEXT) + : > installcheck-ok +END + +cat >sub1/Makefile.am <<'END' +noinst_LTLIBRARIES = libsub1.la +libsub1_la_SOURCES = sub1.c +END + +echo 'int sub1 () { return 1; }' > sub1/sub1.c + +cat >sub2/Makefile.am <<'END' +SUBDIRS = sub21 sub22 +noinst_LTLIBRARIES = libsub2.la +libsub2_la_SOURCES = sub2.c +libsub2_la_LIBADD = \ + sub21/libsub21.la \ + sub22/libsub22.la +END + +echo 'int sub2 () { return 2; }' > sub2/sub2.c + +cat >sub2/sub21/Makefile.am <<'END' +noinst_LTLIBRARIES = libsub21.la +libsub21_la_SOURCES = sub21.c +END + +echo 'int sub21 () { return 21; }' > sub2/sub21/sub21.c + +cat >sub2/sub22/Makefile.am <<'END' +noinst_LTLIBRARIES = libsub22.la +libsub22_la_SOURCES = sub22.c +END + +echo 'int sub22 () { return 22; }' > sub2/sub22/sub22.c + +cat >test.c < +int main () +{ + if (1 != sub1 ()) + return 1; + if (2 != sub2 ()) + return 2; + if (21 != sub21 ()) + return 3; + if (22 != sub22 ()) + return 4; + return 0; +} +EOF + +libtoolize +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +# Install libraries in lib/, programs in bin/, and the rest in empty/. +# (in fact there is no "rest", so as the name imply empty/ is +# expected to remain empty). +./configure --prefix=`pwd`/empty --libdir=`pwd`/lib --bindir=`pwd`/bin + +$MAKE +test -f libtop.la +test -f sub1/libsub1.la +test -f sub2/libsub2.la +test -f sub2/sub21/libsub21.la +test -f sub2/sub22/libsub22.la +$MAKE check +test -f check-ok +rm check-ok + +$MAKE install +test -f lib/libtop.la +$MAKE installcheck +test -f installcheck-ok +rm installcheck-ok + +find empty -type f -print > empty.lst +cat empty.lst +test 0 = `wc -l < empty.lst` + +$MAKE clean +test ! -f libtop.la +test ! -f sub1/libsub1.la +test ! -f sub2/libsub2.la +test ! -f sub2/sub21/libsub21.la +test ! -f sub2/sub22/libsub22.la +test ! -f ltconvtest + +$MAKE installcheck +test -f installcheck-ok +rm installcheck-ok + +$MAKE uninstall +find lib -type f -print > lib.lst +test 0 = `wc -l < lib.lst` +find bin -type f -print > bin.lst +test 0 = `wc -l < bin.lst` diff --git a/version.texi b/version.texi index 24106ae96..03e1d2b64 100644 --- a/version.texi +++ b/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 27 July 2003 +@set UPDATED 31 July 2003 @set UPDATED-MONTH July 2003 @set EDITION 1.7a @set VERSION 1.7a