[f5c58361] | 1 | dnl $Id$ |
---|
| 2 | |
---|
| 3 | dnl |
---|
| 4 | dnl Misc utility macros for subdir handling to work around missing abilities |
---|
| 5 | dnl in autoconf, automake and structural issues with RTEMS |
---|
| 6 | dnl |
---|
| 7 | dnl Contains parts derived from autoconf-2.13 AC_OUTPUT_SUBDIRS and Cygnus' |
---|
| 8 | dnl configure.in. |
---|
| 9 | dnl |
---|
| 10 | |
---|
| 11 | dnl |
---|
| 12 | dnl _RTEMS_PUSH_BUILDDIR(SUBDIR) |
---|
| 13 | dnl |
---|
| 14 | AC_DEFUN(_RTEMS_PUSH_BUILDDIR, |
---|
| 15 | [ |
---|
| 16 | # _RTEMS_PUSH_BUILDDIR |
---|
| 17 | echo configuring in $1 |
---|
| 18 | ## We use mkinstalldirs below as a workaround to mkdir -p not being |
---|
| 19 | ## available everywhere, but us wanting to support deep directories. |
---|
| 20 | case "$srcdir" in |
---|
| 21 | .) ;; |
---|
| 22 | *) |
---|
| 23 | if ${ac_aux_dir}/mkinstalldirs $1; |
---|
| 24 | then :; |
---|
| 25 | else |
---|
| 26 | AC_MSG_ERROR([can not create `pwd`/$1]) |
---|
| 27 | fi |
---|
| 28 | ;; |
---|
| 29 | esac |
---|
| 30 | |
---|
| 31 | ac_popdir=`pwd` |
---|
| 32 | cd $1 |
---|
| 33 | ]) |
---|
| 34 | |
---|
| 35 | dnl |
---|
| 36 | dnl _RTEMS_POP_BUILDDIR |
---|
| 37 | dnl |
---|
| 38 | AC_DEFUN(_RTEMS_POP_BUILDDIR, |
---|
| 39 | [ |
---|
| 40 | cd $ac_popdir |
---|
| 41 | ]) |
---|
| 42 | |
---|
| 43 | dnl |
---|
| 44 | dnl _RTEMS_GIVEN_INSTALL |
---|
| 45 | dnl |
---|
| 46 | AC_DEFUN(_RTEMS_GIVEN_INSTALL, |
---|
| 47 | [ |
---|
| 48 | ifdef([AC_PROVIDE_AC_PROG_INSTALL], |
---|
| 49 | [ case "$ac_given_INSTALL" in |
---|
| 50 | changequote(, )dnl |
---|
| 51 | [/$]*) INSTALL="$ac_given_INSTALL" ;; |
---|
| 52 | changequote([, ])dnl |
---|
| 53 | *) INSTALL="$ac_dots$ac_given_INSTALL" ;; |
---|
| 54 | esac |
---|
| 55 | ])dnl |
---|
| 56 | ]) |
---|
| 57 | |
---|
| 58 | dnl |
---|
| 59 | dnl _AC_DOTS(PATH) |
---|
| 60 | dnl |
---|
| 61 | AC_DEFUN(_AC_DOTS,[ |
---|
| 62 | # A "../" for each directory in $1. |
---|
| 63 | ac_dots=`echo $1 | \ |
---|
| 64 | sed -e 's%^\./%%' -e 's%[[^/]]$%&/%' -e 's%[[^/]]*/%../%g'` |
---|
| 65 | ]) |
---|
| 66 | |
---|
| 67 | dnl |
---|
| 68 | dnl _RTEMS_ADJUST_SRCDIR(REVAR,CONFIG_DIR[,TARGET_SUBDIR]) |
---|
| 69 | dnl |
---|
| 70 | AC_DEFUN(_RTEMS_ADJUST_SRCDIR,[ |
---|
| 71 | _AC_DOTS(ifelse([$3], ,[$2],[$3/$2])) |
---|
| 72 | |
---|
| 73 | case "$srcdir" in |
---|
| 74 | .) # No --srcdir option. We are building in place. |
---|
| 75 | $1=$srcdir ;; |
---|
| 76 | /*) # Absolute path. |
---|
| 77 | $1=$srcdir/$2 ;; |
---|
| 78 | *) # Relative path. |
---|
| 79 | $1=$ac_dots$srcdir/$2 ;; |
---|
| 80 | esac |
---|
| 81 | ]) |
---|
| 82 | |
---|
| 83 | dnl |
---|
| 84 | dnl _RTEMS_SUB_SRCDIR(AC_CONFIG_DIR[,TARGET_SUBDIR]) |
---|
| 85 | dnl |
---|
| 86 | AC_DEFUN(_RTEMS_SUB_SRCDIR,[ |
---|
| 87 | # _RTEMS_SUB_SRCDIR |
---|
| 88 | _RTEMS_ADJUST_SRCDIR(ac_sub_srcdir,$1,$2) |
---|
| 89 | |
---|
| 90 | # Check for configure |
---|
| 91 | if test -f $ac_sub_srcdir/configure; then |
---|
| 92 | ac_sub_configure=$ac_sub_srcdir/configure |
---|
| 93 | else |
---|
| 94 | AC_MSG_WARN([no configuration information is in $1]) |
---|
| 95 | ac_sub_configure= |
---|
| 96 | fi |
---|
| 97 | ]) |
---|
| 98 | |
---|
| 99 | AC_DEFUN(RTEMS_TARGET_CONFIG_PREPARE,[ |
---|
| 100 | # Record target_configdirs and the configure arguments in Makefile. |
---|
| 101 | targargs=`echo "${ac_configure_args}" | \ |
---|
| 102 | sed -e 's/--no[[^ ]]*//' \ |
---|
| 103 | -e 's/--cache[[a-z-]]*=[[^ ]]*//' \ |
---|
| 104 | -e 's/--ho[[a-z-]]*=[[^ ]]*//' \ |
---|
| 105 | -e 's/--bu[[a-z-]]*=[[^ ]]*//' \ |
---|
| 106 | -e 's/--ta[[a-z-]]*=[[^ ]]*//'`; |
---|
| 107 | |
---|
| 108 | targargs="--host=${target_alias} --build=${build} ${targargs}" |
---|
| 109 | AC_SUBST(targargs) |
---|
| 110 | ]) |
---|
| 111 | |
---|
| 112 | AC_DEFUN(RTEMS_TARGET_CONFIG_SUBDIRS,[ |
---|
| 113 | # |
---|
| 114 | # TARGET_CONFIG_SUBDIRS |
---|
| 115 | # |
---|
| 116 | if test "$no_recursion" != yes; then |
---|
| 117 | if test $target != $build; then |
---|
| 118 | # Remove --srcdir arguments so they do not pile up. |
---|
| 119 | ac_sub_configure_args= |
---|
| 120 | ac_prev= |
---|
| 121 | for ac_arg in $targargs; do |
---|
| 122 | if test -n "$ac_prev"; then |
---|
| 123 | ac_prev= |
---|
| 124 | continue |
---|
| 125 | fi |
---|
| 126 | case "$ac_arg" in |
---|
| 127 | -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) |
---|
| 128 | ac_prev=srcdir ;; |
---|
| 129 | -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) |
---|
| 130 | ;; |
---|
| 131 | *) ac_sub_configure_args="$ac_sub_configure_args $ac_arg" ;; |
---|
| 132 | esac |
---|
| 133 | done |
---|
| 134 | |
---|
| 135 | test -n "$target_configdirs" && test -d $target_subdir || mkdir $target_subdir |
---|
| 136 | |
---|
| 137 | for ac_config_dir in $target_configdirs; do |
---|
| 138 | # Do not complain, so a configure script can configure whichever |
---|
| 139 | # parts of a large source tree are present. |
---|
| 140 | if test ! -d $srcdir/$ac_config_dir; then |
---|
| 141 | continue |
---|
| 142 | fi |
---|
| 143 | |
---|
| 144 | _RTEMS_PUSH_BUILDDIR([$target_subdir/$ac_config_dir]) |
---|
| 145 | |
---|
| 146 | _RTEMS_SUB_SRCDIR([$ac_config_dir],[$target_subdir]) |
---|
| 147 | |
---|
| 148 | # The recursion is here. |
---|
| 149 | if test -n "$ac_sub_configure"; then |
---|
| 150 | |
---|
| 151 | # Make the cache file name correct relative to the subdirectory. |
---|
| 152 | ac_sub_cache_file=$cache_file |
---|
| 153 | _RTEMS_GIVEN_INSTALL |
---|
| 154 | |
---|
| 155 | echo "[running ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file] --srcdir=$ac_sub_srcdir" |
---|
| 156 | # The eval makes quoting arguments work. |
---|
| 157 | CC=${CC_FOR_TARGET}; export CC; |
---|
| 158 | if eval ${CONFIG_SHELL-/bin/sh} $ac_sub_configure \ |
---|
| 159 | $ac_sub_configure_args --srcdir=$ac_sub_srcdir \ |
---|
| 160 | --with-target-subdir=$target_subdir \ |
---|
| 161 | --cache-file=$ac_sub_cache_file \ |
---|
| 162 | --exec-prefix="\${prefix}/$target_subdir" |
---|
| 163 | then : |
---|
| 164 | else |
---|
| 165 | AC_MSG_ERROR([$ac_sub_configure failed for $ac_config_dir]) |
---|
| 166 | fi |
---|
| 167 | fi |
---|
| 168 | |
---|
| 169 | _RTEMS_POP_BUILDDIR |
---|
| 170 | done |
---|
| 171 | fi |
---|
| 172 | fi |
---|
| 173 | ]) |
---|
| 174 | |
---|
| 175 | AC_DEFUN(RTEMS_HOST_CONFIG_PREPARE,[ |
---|
| 176 | # Record host_configdirs and the configure arguments in Makefile. |
---|
| 177 | hostargs=`echo "${ac_configure_args}" | \ |
---|
| 178 | sed -e 's/--no[[^ ]]*//' \ |
---|
| 179 | -e 's/--cache[[a-z-]]*=[[^ ]]*//' \ |
---|
| 180 | -e 's/--ho[[a-z-]]*=[[^ ]]*//' \ |
---|
| 181 | -e 's/--bu[[a-z-]]*=[[^ ]]*//' \ |
---|
| 182 | -e 's/--ta[[a-z-]]*=[[^ ]]*//'`; |
---|
| 183 | |
---|
| 184 | hostargs="--host=${host_alias} --build=${build} --target=${target_alias} ${hostargs}" |
---|
| 185 | AC_SUBST(hostargs) |
---|
| 186 | ]) |
---|
| 187 | |
---|
| 188 | AC_DEFUN(RTEMS_HOST_CONFIG_SUBDIRS,[ |
---|
| 189 | # |
---|
| 190 | # HOST_CONFIG_SUBDIRS |
---|
| 191 | # |
---|
| 192 | if test "$no_recursion" != yes; then |
---|
| 193 | |
---|
| 194 | if test $build != $host; then |
---|
| 195 | # Remove --srcdir arguments so they do not pile up. |
---|
| 196 | ac_sub_configure_args= |
---|
| 197 | ac_prev= |
---|
| 198 | for ac_arg in $hostargs; do |
---|
| 199 | if test -n "$ac_prev"; then |
---|
| 200 | ac_prev= |
---|
| 201 | continue |
---|
| 202 | fi |
---|
| 203 | case "$ac_arg" in |
---|
| 204 | -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) |
---|
| 205 | ac_prev=srcdir ;; |
---|
| 206 | -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) |
---|
| 207 | ;; |
---|
| 208 | *) ac_sub_configure_args="$ac_sub_configure_args $ac_arg" ;; |
---|
| 209 | esac |
---|
| 210 | done |
---|
| 211 | |
---|
| 212 | test -n "$host_configdirs" && test -d $host_subdir || mkdir $host_subdir |
---|
| 213 | |
---|
| 214 | for ac_config_dir in $host_configdirs; do |
---|
| 215 | # Do not complain, so a configure script can configure whichever |
---|
| 216 | # parts of a large source tree are present. |
---|
| 217 | if test ! -d $srcdir/$ac_config_dir; then |
---|
| 218 | continue |
---|
| 219 | fi |
---|
| 220 | |
---|
| 221 | _RTEMS_PUSH_BUILDDIR([$host_subdir/$ac_config_dir]) |
---|
| 222 | |
---|
| 223 | _RTEMS_SUB_SRCDIR([$ac_config_dir],[$host_subdir]) |
---|
| 224 | |
---|
| 225 | # The recursion is here. |
---|
| 226 | if test -n "$ac_sub_configure"; then |
---|
| 227 | |
---|
| 228 | # Make the cache file name correct relative to the subdirectory. |
---|
| 229 | ac_sub_cache_file=$cache_file |
---|
| 230 | _RTEMS_GIVEN_INSTALL |
---|
| 231 | |
---|
| 232 | echo "[running ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file] --srcdir=$ac_sub_srcdir" |
---|
| 233 | CC=${CC_FOR_HOST}; export CC; |
---|
| 234 | # The eval makes quoting arguments work. |
---|
| 235 | if eval ${CONFIG_SHELL-/bin/sh} $ac_sub_configure \ |
---|
| 236 | $ac_sub_configure_args --srcdir=$ac_sub_srcdir \ |
---|
| 237 | --with-target-subdir=$host_subdir \ |
---|
| 238 | --cache-file=$ac_sub_cache_file |
---|
| 239 | then : |
---|
| 240 | else |
---|
| 241 | AC_MSG_ERROR([$ac_sub_configure failed for $ac_config_dir]) |
---|
| 242 | fi |
---|
| 243 | fi |
---|
| 244 | |
---|
| 245 | _RTEMS_POP_BUILDDIR |
---|
| 246 | done |
---|
| 247 | fi |
---|
| 248 | fi |
---|
| 249 | ]) |
---|