[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ERROR: files left in build directory after distclean (solution)
From: |
Alexandre Duret-Lutz |
Subject: |
Re: ERROR: files left in build directory after distclean (solution) |
Date: |
Fri, 26 Mar 2004 21:41:13 +0100 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) |
>>> "Robin" == Robin Rowe <address@hidden> writes:
Robin> Alexandre said:
>> Please see the manual section I mentioned for discussion about
>> DIST_SUBDIRS or conditionals.
Robin> Tried setting DIST_SUBDIRS in plug-ins/Makefile.am but
Robin> didn't work for me.
Robin> DIST_SUBDIRS = $(SUBDIRS)
Please do tell me what in the manual let you think that setting
`DIST_SUBDIRS' to `$(SUBDIRS)' might fix your problem, so I can
fix the manual. I mean it. Whatever lead you to think that
`DIST_SUBDIRS = $(SUBDIRS)' was an option should be corrected.
| Conditional subdirectories
| ==========================
|
| It is possible to define the `SUBDIRS' variable conditionally if, like
| in the case of GNU `Inetutils', you want to only build a subset of the
| entire package.
|
| To illustrate how this works, let's assume we have two directories
| `src/' and `opt/'. `src/' should always be built, but we want to
| decide in `./configure' whether `opt/' will be built or not. (For this
| example we will assume that `opt/' should be built when the variable
| `$want_opt' was set to `yes'.)
|
| Running `make' should thus recurse into `src/' always, and then
| maybe in `opt/'.
|
| However `make dist' should always recurse into both `src/' and
| `opt/'. Because `opt/' should be distributed even if it is not needed
| in the current configuration. This means `opt/Makefile' should be
| created unconditionally. (1)
|
| There are two ways to setup a project like this. You can use
| Automake conditionals (*note Conditionals::) or use Autoconf `AC_SUBST'
| variables (*note Setting Output Variables: (autoconf)Setting Output
| Variables.). Using Automake conditionals is the preferred solution.
|
| Conditional subdirectories with `AM_CONDITIONAL'
| ------------------------------------------------
|
| `configure' should output the `Makefile' for each directory and define
| a condition into which `opt/' should be built.
|
| ...
| AM_CONDITIONAL([COND_OPT], [test "$want_opt" = yes])
| AC_CONFIG_FILES([Makefile src/Makefile opt/Makefile])
| ...
|
| Then `SUBDIRS' can be defined in the top-level `Makefile.am' as
| follows.
|
| if COND_OPT
| MAYBE_OPT = opt
| endif
| SUBDIRS = src $(MAYBE_OPT)
|
This translates to
if HAVE_OPENEXR
MAYBE_OPENEXR = openexr
endif
SUBDIRS = \
blur \
$(MAYBE_OPENEXR) \
unsharp
in your case.
| As you can see, running `make' will rightly recurse into `src/' and
| maybe `opt/'.
|
| As you can't see, running `make dist' will recurse into both `src/'
| and `opt/' directories because `make dist', unlike `make all', doesn't
| use the `SUBDIRS' variable. It uses the `DIST_SUBDIRS' variable.
|
| In this case Automake will define `DIST_SUBDIRS = src opt'
| automatically because it knows that `MAYBE_OPT' can contain `opt' in
| some condition.
|
| Conditional subdirectories with `AC_SUBST'
| ------------------------------------------
|
| Another idea is to define `MAYBE_OPT' from `./configure' using
| `AC_SUBST':
|
| ...
| if test "$want_opt" = yes; then
| MAYBE_OPT=opt
| else
| MAYBE_OPT=
| fi
| AC_SUBST([MAYBE_OPT])
| AC_CONFIG_FILES([Makefile src/Makefile opt/Makefile])
| ...
|
| In this case the top-level `Makefile.am' should look as follows.
|
|
| SUBDIRS = src $(MAYBE_OPT)
| DIST_SUBDIRS = src opt
|
| The drawback is that since Automake cannot guess what the possible
| values of `MAYBE_OPT' are, it is necessary to define `DIST_SUBDIRS'.
This of course becomes
SUBDIRS = \
blur \
@OPENEXR@ \
unsharp
DIST_SUBDIRS = \
blur \
openexr \
unsharp
| How `DIST_SUBDIRS' is used
| --------------------------
|
| As shown in the above examples, `DIST_SUBDIRS' is used in rules that
| need to recurse in all directories, even those which have been
| conditionally left out of the build.
|
| Precisely, `DIST_SUBDIRS' is used by `make dist', `make distclean',
| and `make maintainer-clean'. All other recursive rules use `SUBDIRS'.
|
| Automake will define `DIST_SUBDIRS' automatically from the possibles
| values of `SUBDIRS' in all conditions.
|
| If `SUBDIRS' contains `AC_SUBST' variables, `DIST_SUBDIRS' will not
| be defined correctly because Automake doesn't know the possible values
| of these variables. In this case `DIST_SUBDIRS' needs to be defined
| manually.
|
| ---------- Footnotes ----------
|
| (1) Don't try seeking a solution where `opt/Makefile' is created
| conditionally, this is a lot trickier than the solutions presented here.
--
Alexandre Duret-Lutz