From: Alexandre Duret-Lutz Date: Sun, 19 Jan 2003 15:19:26 +0000 (+0000) Subject: * automake.texi (Conditional Programs): Show a sample Makefile.am. X-Git-Tag: Release-1-7b~303 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=d73e2ee5295e2e0e5f2d5e2350a7d44c5efba061;p=automake.git * automake.texi (Conditional Programs): Show a sample Makefile.am. Remind $(EXEEXT) must be appended to configure substitutions. Show how Automake conditionals can be used instead. * tests/exeext.test (check_PROGRAMS): Make sure EXEEXT is also appended to conditionally defined programs. --- diff --git a/ChangeLog b/ChangeLog index fb07b35e..ce469c48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2003-01-19 Alexandre Duret-Lutz + + * automake.texi (Conditional Programs): Show a sample Makefile.am. + Remind $(EXEEXT) must be appended to configure substitutions. + Show how Automake conditionals can be used instead. + * tests/exeext.test (check_PROGRAMS): Make sure EXEEXT is also + appended to conditionally defined programs. + 2003-01-16 Jim Meyering Accept --help and --version, and lots of syntactic clean-up. diff --git a/automake.texi b/automake.texi index e01d300d..49505d5b 100644 --- a/automake.texi +++ b/automake.texi @@ -2252,12 +2252,16 @@ endif @node Conditional Programs, , Conditional Sources, A Program @subsection Conditional compilation of programs +@cindex Conditional programs +@cindex Programs, conditional -Sometimes it is useful to determine the programs that are to be built at -configure time. For instance, GNU @code{cpio} only builds @code{mt} and -@code{rmt} under special circumstances. +Sometimes it is useful to determine the programs that are to be built +at configure time. For instance, GNU @code{cpio} only builds +@code{mt} and @code{rmt} under special circumstances. The means to +achieve conditional compilation of programs are the same you can use +to compile source files conditionally: substitutions or conditionals. -@cindex EXTRA_PROGRAMS, defined +@subsubsection Conditional programs using @code{configure} substitutions In this case, you must notify Automake of all the programs that can possibly be built, but at the same time cause the generated @@ -2266,9 +2270,37 @@ This is done by having @code{configure} substitute values into each @samp{_PROGRAMS} definition, while listing all optionally built programs in @code{EXTRA_PROGRAMS}. @vindex EXTRA_PROGRAMS +@cindex EXTRA_PROGRAMS, defined + +@example +bin_PROGRAMS = cpio pax $(MT) +libexec_PROGRAMS = $(RMT) +EXTRA_PROGRAMS = mt rmt +@end example -Of course you can use Automake conditionals to determine the programs to -be built. +As explained in @ref{EXEEXT}, Automake will rewrite +@code{bin_PROGRAMS}, @code{libexec_PROGRAMS}, and +@code{EXTRA_PROGRAMS}, appending @code{$(EXEEXT)} to each binary. +Obviously it cannot rewrite values obtained at run-time through +@code{configure} substitutions, therefore you should take care of +appending @code{$(EXEEXT)} yourself, as in @code{AC_SUBST([MT], +['mt$@{EXEEXT@}'])}. + +@subsubsection Conditional programs using Automake conditionals + +You can also use Automake conditionals (@pxref{Conditionals}) to +select programs to be built. In this case you don't have to worry +about @code{$(EXEEXT)} or @code{EXTRA_PROGRAMS}. + +@example +bin_PROGRAMS = cpio pax +if WANT_MT + bin_PROGRAMS += mt +endif +if WANT_RMT + libexec_PROGRAMS = rmt +endif +@end example @node A Library, A Shared Library, A Program, Programs diff --git a/stamp-vti b/stamp-vti index d406b529..4aceec33 100644 --- a/stamp-vti +++ b/stamp-vti @@ -1,4 +1,4 @@ -@set UPDATED 9 January 2003 +@set UPDATED 19 January 2003 @set UPDATED-MONTH January 2003 @set EDITION 1.7a @set VERSION 1.7a diff --git a/tests/exeext.test b/tests/exeext.test index df4b74ec..f3b3ccd9 100755 --- a/tests/exeext.test +++ b/tests/exeext.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -20,21 +20,30 @@ # Test to make sure `.' in an exe name doesn't fool us. # Report from Robert Collins. +# Also make sure we rewrite conditionals variables. . ./defs || exit 1 cat >> configure.in << 'END' AC_PROG_CC -AC_EXEEXT +AM_CONDITIONAL([WANT_MT], [:]) +AM_CONDITIONAL([WANT_RMT], [:]) END cat > Makefile.am << 'END' ## Use a different dir for each to make grep easy. -bin_PROGRAMS = maude +bin_PROGRAMS = maude sbin_PROGRAMS = maude.static ## We don't define this one for now. Probably it is an error. ## noinst_PROGRAMS = maude2.exe check_PROGRAMS = maude3$(EXEEXT) + +if WANT_MT + bin_PROGRAMS += mt +endif +if WANT_RMT + libexec_PROGRAMS = rmt +endif END set -e @@ -50,3 +59,9 @@ grep 'sbin_PROGRAMS =.*maude\.static$(EXEEXT)' Makefile.in grep '^maude3$(EXEEXT):' Makefile.in grep 'check_PROGRAMS =.*maude3$(EXEEXT)' Makefile.in + +grep '^mt$(EXEEXT):' Makefile.in +grep '@WANT_MT_TRUE@bin_PROGRAMS =.* mt$(EXEEXT)' Makefile.in + +grep '^rmt$(EXEEXT):' Makefile.in +grep '@WANT_RMT_TRUE@libexec_PROGRAMS =.*rmt$(EXEEXT)' Makefile.in diff --git a/version.texi b/version.texi index d406b529..4aceec33 100644 --- a/version.texi +++ b/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 9 January 2003 +@set UPDATED 19 January 2003 @set UPDATED-MONTH January 2003 @set EDITION 1.7a @set VERSION 1.7a