3dda02b260a016d59985b2341c0c301cc40b983a
[platform/upstream/automake.git] / m4 / auxdir.m4
1 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
2
3 # Copyright (C) 2001-2012 Free Software Foundation, Inc.
4 #
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # serial 2
10
11 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
12 # $ac_aux_dir to '$srcdir/foo'.  In other projects, it is set to
13 # '$srcdir', '$srcdir/..', or '$srcdir/../..'.
14 #
15 # Of course, Automake must honor this variable whenever it calls a
16 # tool from the auxiliary directory.  The problem is that $srcdir (and
17 # therefore $ac_aux_dir as well) can be either absolute or relative,
18 # depending on how configure is run.  This is pretty annoying, since
19 # it makes $ac_aux_dir quite unusable in subdirectories: in the top
20 # source directory, any form will work fine, but in subdirectories a
21 # relative path needs to be adjusted first.
22 #
23 # $ac_aux_dir/missing
24 #    fails when called from a subdirectory if $ac_aux_dir is relative
25 # $top_srcdir/$ac_aux_dir/missing
26 #    fails if $ac_aux_dir is absolute,
27 #    fails when called from a subdirectory in a VPATH build with
28 #          a relative $ac_aux_dir
29 #
30 # The reason of the latter failure is that $top_srcdir and $ac_aux_dir
31 # are both prefixed by $srcdir.  In an in-source build this is usually
32 # harmless because $srcdir is '.', but things will broke when you
33 # start a VPATH build or use an absolute $srcdir.
34 #
35 # So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
36 # iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
37 #   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
38 # and then we would define $MISSING as
39 #   MISSING="\${SHELL} $am_aux_dir/missing"
40 # This will work as long as MISSING is not called from configure, because
41 # unfortunately $(top_srcdir) has no meaning in configure.
42 # However there are other variables, like CC, which are often used in
43 # configure, and could therefore not use this "fixed" $ac_aux_dir.
44 #
45 # Another solution, used here, is to always expand $ac_aux_dir to an
46 # absolute PATH.  The drawback is that using absolute paths prevent a
47 # configured tree to be moved without reconfiguration.
48
49 AC_DEFUN([AM_AUX_DIR_EXPAND],
50 [dnl Rely on autoconf to set up CDPATH properly.
51 AC_PREREQ([2.50])dnl
52 # expand $ac_aux_dir to an absolute path
53 am_aux_dir=`cd $ac_aux_dir && pwd`
54 ])