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