summaryrefslogtreecommitdiff
path: root/gdb/acx_configure_dir.m4
blob: e4318751478ddc603e41ae3a3fe74f1c7100a829 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Free Software
# Foundation, Inc.
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.

# ACX_CONFIGURE_DIR(SRC-DIR-NAME, BUILD-DIR-NAME)
# ---------------------------
#
# Configure a subdirectory.  This is an alternative to
# AC_CONFIG_SUBDIRS that allows pointing the source directory
# somewhere else.  The build directory is always a subdirectory of the
# top build directory.  This is heavilly based on Autoconf 2.64's
# _AC_OUTPUT_SUBDIRS.
#
# Inputs:
#   - SRC-DIR-NAME is the source directory, relative to $srcdir.
#   - BUILD-DIR-NAME is `top-build -> build'

AC_DEFUN([ACX_CONFIGURE_DIR],
[
  in_src=$1
  in_build=$2

  # Remove --cache-file, --srcdir, and --disable-option-checking arguments
  # so they do not pile up.
  ac_sub_configure_args=
  ac_prev=
  eval "set x $ac_configure_args"
  shift
  for ac_arg
  do
    if test -n "$ac_prev"; then
      ac_prev=
      continue
    fi
    case $ac_arg in
    -cache-file | --cache-file | --cache-fil | --cache-fi \
    | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
      ac_prev=cache_file ;;
    -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
    | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
    | --c=*)
      ;;
    --config-cache | -C)
      ;;
    -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
      ac_prev=srcdir ;;
    -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
      ;;
    -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
      ac_prev=prefix ;;
    -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
      ;;
    --disable-option-checking)
      ;;
    *)
      case $ac_arg in
      *\'*) ac_arg=`AS_ECHO(["$ac_arg"]) | sed "s/'/'\\\\\\\\''/g"` ;;
      esac
      AS_VAR_APPEND([ac_sub_configure_args], [" '$ac_arg'"]) ;;
    esac
  done

  # Always prepend --prefix to ensure using the same prefix
  # in subdir configurations.
  ac_arg="--prefix=$prefix"
  case $ac_arg in
  *\'*) ac_arg=`AS_ECHO(["$ac_arg"]) | sed "s/'/'\\\\\\\\''/g"` ;;
  esac
  ac_sub_configure_args="'$ac_arg' $ac_sub_configure_args"

  # Pass --silent
  if test "$silent" = yes; then
    ac_sub_configure_args="--silent $ac_sub_configure_args"
  fi

  # Always prepend --disable-option-checking to silence warnings, since
  # different subdirs can have different --enable and --with options.
  ac_sub_configure_args="--disable-option-checking $ac_sub_configure_args"

  ac_popdir=`pwd`
  ac_dir=$in_build

  ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)"
  _AS_ECHO_LOG([$ac_msg])
  _AS_ECHO([$ac_msg])
  AS_MKDIR_P(["$ac_dir"])

  case $srcdir in
  [[\\/]]* | ?:[[\\/]]* )
    ac_srcdir=$srcdir/$in_src ;;
  *) # Relative name.
    ac_srcdir=../$srcdir/$in_src ;;
  esac

  cd "$ac_dir"

  ac_sub_configure=$ac_srcdir/configure

  # Make the cache file name correct relative to the subdirectory.
  case $cache_file in
  [[\\/]]* | ?:[[\\/]]* ) ac_sub_cache_file=$cache_file ;;
  *) # Relative name.
    ac_sub_cache_file=$ac_top_build_prefix$cache_file ;;
  esac

  AC_MSG_NOTICE([running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir])
  # The eval makes quoting arguments work.
  eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
       --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
    AC_MSG_ERROR([$ac_sub_configure failed for $ac_dir])

  cd "$ac_popdir"
])# ACX_CONFIGURE_DIR