gdb/
[platform/upstream/binutils.git] / gdb / acx_configure_dir.m4
1 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
2 # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Free Software
3 # Foundation, Inc.
4 #
5 # This file is free software; the Free Software Foundation gives
6 # unlimited permission to copy and/or distribute it, with or without
7 # modifications, as long as this notice is preserved.
8
9 # ACX_CONFIGURE_DIR(SRC-DIR-NAME, BUILD-DIR-NAME)
10 # ---------------------------
11 #
12 # Configure a subdirectory.  This is an alternative to
13 # AC_CONFIG_SUBDIRS that allows pointing the source directory
14 # somewhere else.  The build directory is always a subdirectory of the
15 # top build directory.  This is heavilly based on Autoconf 2.64's
16 # _AC_OUTPUT_SUBDIRS.
17 #
18 # Inputs:
19 #   - SRC-DIR-NAME is the source directory, relative to $srcdir.
20 #   - BUILD-DIR-NAME is `top-build -> build'
21
22 AC_DEFUN([ACX_CONFIGURE_DIR],
23 [
24   in_src=$1
25   in_build=$2
26
27   # Remove --cache-file, --srcdir, and --disable-option-checking arguments
28   # so they do not pile up.
29   ac_sub_configure_args=
30   ac_prev=
31   eval "set x $ac_configure_args"
32   shift
33   for ac_arg
34   do
35     if test -n "$ac_prev"; then
36       ac_prev=
37       continue
38     fi
39     case $ac_arg in
40     -cache-file | --cache-file | --cache-fil | --cache-fi \
41     | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
42       ac_prev=cache_file ;;
43     -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
44     | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
45     | --c=*)
46       ;;
47     --config-cache | -C)
48       ;;
49     -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
50       ac_prev=srcdir ;;
51     -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
52       ;;
53     -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
54       ac_prev=prefix ;;
55     -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
56       ;;
57     --disable-option-checking)
58       ;;
59     *)
60       case $ac_arg in
61       *\'*) ac_arg=`AS_ECHO(["$ac_arg"]) | sed "s/'/'\\\\\\\\''/g"` ;;
62       esac
63       AS_VAR_APPEND([ac_sub_configure_args], [" '$ac_arg'"]) ;;
64     esac
65   done
66
67   # Always prepend --prefix to ensure using the same prefix
68   # in subdir configurations.
69   ac_arg="--prefix=$prefix"
70   case $ac_arg in
71   *\'*) ac_arg=`AS_ECHO(["$ac_arg"]) | sed "s/'/'\\\\\\\\''/g"` ;;
72   esac
73   ac_sub_configure_args="'$ac_arg' $ac_sub_configure_args"
74
75   # Pass --silent
76   if test "$silent" = yes; then
77     ac_sub_configure_args="--silent $ac_sub_configure_args"
78   fi
79
80   # Always prepend --disable-option-checking to silence warnings, since
81   # different subdirs can have different --enable and --with options.
82   ac_sub_configure_args="--disable-option-checking $ac_sub_configure_args"
83
84   ac_popdir=`pwd`
85   ac_dir=$in_build
86
87   ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)"
88   _AS_ECHO_LOG([$ac_msg])
89   _AS_ECHO([$ac_msg])
90   AS_MKDIR_P(["$ac_dir"])
91
92   case $srcdir in
93   [[\\/]]* | ?:[[\\/]]* )
94     ac_srcdir=$srcdir/$in_src ;;
95   *) # Relative name.
96     ac_srcdir=../$srcdir/$in_src ;;
97   esac
98
99   cd "$ac_dir"
100
101   ac_sub_configure=$ac_srcdir/configure
102
103   # Make the cache file name correct relative to the subdirectory.
104   case $cache_file in
105   [[\\/]]* | ?:[[\\/]]* ) ac_sub_cache_file=$cache_file ;;
106   *) # Relative name.
107     ac_sub_cache_file=$ac_top_build_prefix$cache_file ;;
108   esac
109
110   AC_MSG_NOTICE([running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir])
111   # The eval makes quoting arguments work.
112   eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
113        --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
114     AC_MSG_ERROR([$ac_sub_configure failed for $ac_dir])
115
116   cd "$ac_popdir"
117 ])# ACX_CONFIGURE_DIR