acx_configure_dir.m4 3.8 KB

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