source: rtems/acinclude.m4 @ d0d73ec

4.104.114.84.95
Last change on this file since d0d73ec was b4cde04, checked in by Ralf Corsepius <ralf.corsepius@…>, on 07/22/02 at 16:07:34

2002-07-22 Ralf Corsepius <corsepiu@…>

  • aclocal/subdirs.m4: Remove.
  • acinclude.m4: New (Replaces aclocal/subdirs.m4).
  • Property mode set to 100644
File size: 11.7 KB
Line 
1## All directories belong in one of 3 categories.
2## ${HOST_CONFIGDIRS_LIST} is directories we build using the host tools.
3## ${TARGET_CONFIGDIRS_LIST} is directories we build using the target tools.
4## ${BUILD_CONFIGDIRS_LIST} is directories we build using the build tools
5
6
7dnl RTEMS_ARG_VAR(VAR,HELP-STRING)
8dnl An internal macros to have help strings pretty
9dnl printed with configure --help, without letting autoconf spoil config subdir
10dnl environments by trying to propagate them
11dnl Stripped down version of autoconf-2.52's AC_ARG_VAR.
12
13AC_DEFUN([_RTEMS_ARG_VAR],
14[
15m4_expand_once([m4_divert_once([HELP_VAR],
16[AC_HELP_STRING([$1], [$2], [              ])])],
17      [$0($1)])dnl
18])
19
20AC_DEFUN([_RTEMS_SUBST_IFNOT],
21[AS_IF([`echo " [$]$1 " | grep " $2 " > /dev/null`],
22  [],
23  [AC_SUBST([$1],["[$]$1 $2"])])
24])
25
26AC_DEFUN([_RTEMS_COMMANDS_POST_CONFIG_SUBDIRS],
27[
28AC_CONFIG_COMMANDS_PRE([
29_RTEMS_BUILD_CONFIG_PREPARE
30_RTEMS_HOST_CONFIG_PREPARE
31_RTEMS_TARGET_CONFIG_PREPARE
32
33AS_IF([test $build = $host],
34[
35  AS_IF([test $host = $target],
36  [dnl b=h, h=t, t=b
37    BUILD_SUBDIRS="${build_configdirs}"
38    build_configdirs="${build_configdirs}"
39    HOST_SUBDIRS=""
40    host_configdirs=""
41    TARGET_SUBDIRS=""
42    target_configdirs=""],
43  [dnl b=h, h!=t, t!=b
44    BUILD_SUBDIRS="${build_configdirs}"
45    build_configdirs="${build_configdirs}"
46    HOST_SUBDIRS=""
47    host_configdirs=""
48    TARGET_SUBDIRS=`echo "${target_configdirs}" | \
49      sed -e "s%\([[^ ]][[^ ]]*\)%$target_alias/\1%g"`
50    target_configdirs="${target_configdirs}"
51  ])
52],[
53  AS_IF([test $host = $target],
54  [ dnl b!=h, h=t, b!=t
55    BUILD_SUBDIRS="${build_configdirs}"
56    build_configdirs="${build_configdirs}"
57    HOST_SUBDIRS=`echo "${host_configdirs}" | \
58      sed -e "s%\([[^ ]][[^ ]]*\)%$host_alias/\1%g"`
59    host_configdirs="${host_configdirs}"
60    TARGET_SUBDIRS=""
61    target_configdirs=""],
62  [
63    AS_IF([test $build = $target],
64    [dnl b!=h, h!=t, b=t
65      BUILD_SUBDIRS="${build_configdirs}"
66      build_configdirs="${build_configdirs}"
67      HOST_SUBDIRS=`echo "${host_configdirs}" | \
68        sed -e "s%\([[^ ]][[^ ]]*\)%$host_alias/\1%g"`
69      host_configdirs="${host_configdirs}"
70      TARGET_SUBDIRS=""
71      target_configdirs=""],
72    [dnl b!=h, h!=t, b!=t
73      BUILD_SUBDIRS="${build_configdirs}"
74      build_configdirs="${build_configdirs}"
75      HOST_SUBDIRS=`echo "${host_configdirs}" | \
76        sed -e "s%\([[^ ]][[^ ]]*\)%$host_alias/\1%g"`
77      host_configdirs="${host_configdirs}"
78      TARGET_SUBDIRS=`echo "${target_configdirs}" | \
79        sed -e "s%\([[^ ]][[^ ]]*\)%$target_alias/\1%g"`
80      target_configdirs="${target_configdirs}"
81    ])
82  ])
83])
84
85AC_SUBST(HOST_SUBDIRS)
86AC_SUBST(TARGET_SUBDIRS)
87AC_SUBST(BUILD_SUBDIRS)
88])
89
90  AC_CONFIG_COMMANDS_POST([
91    _RTEMS_OUTPUT_SUBDIRS([build],[BUILD])
92    _RTEMS_OUTPUT_SUBDIRS([host],[HOST])
93    _RTEMS_OUTPUT_SUBDIRS([target],[TARGET])
94  ])
95])
96
97dnl _RTEMS_SRCPATHS(BUILD-DIR-NAME)
98dnl ----------------------------
99dnl Inputs:
100dnl   - BUILD-DIR-NAME is `top-build -> build' and `top-src -> src'
101dnl   - `$srcdir' is `top-build -> top-src'
102dnl
103dnl Outputs:
104dnl - `ac_builddir' is `.', for symmetry only.
105dnl - `ac_top_builddir' is `build -> top_build'.
106dnl      If not empty, has a trailing slash.
107dnl - `ac_srcdir' is `build -> src'.
108dnl - `ac_top_srcdir' is `build -> top-src'.
109dnl
110dnl and `ac_buildpath' etc., the absolute paths.
111m4_define([_RTEMS_SRCPATHS],
112[
113m4_if([$2],,
114[dstdir=$1],
115[case "$2" in
116"." | "" )      # No subdir was given
117  dstdir=$1;;
118* )             # A subdir was given
119  dstdir=$2/$1;;
120esac])
121ac_builddir=.
122
123AS_IF([test $dstdir != .],
124[ # Strip off leading ./
125  ac_builddir_suffix=/`echo $dstdir | sed 's,^\.[[\\/]],,'`
126  ac_srcdir_suffix=/`echo $1 | sed 's,^\.[[\\/]],,'`
127  # A "../" for each directory in $ac_dir_suffix.
128  ac_top_builddir=`echo "$ac_builddir_suffix" | sed 's,/[[^\\/]]*,../,g'`
129],[
130  ac_dir_suffix= ac_top_builddir=
131])
132
133case $srcdir in
134  .)  # No --srcdir option.  We are building in place.
135    ac_srcdir=.
136    if test -z "$ac_top_builddir"; then
137       ac_top_srcdir=.
138    else
139       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
140    fi ;;
141  [[\\/]]* | ?:[[\\/]]* )  # Absolute path.
142    ac_srcdir=$srcdir$ac_srcdir_suffix;
143    ac_top_srcdir=$srcdir;
144    ;;
145  *) # Relative path.
146    ac_srcdir=$ac_top_builddir$srcdir$ac_srcdir_suffix;
147    ac_top_srcdir=$ac_top_builddir$srcdir;
148    ;;
149esac
150dnl Don't blindly perform a `cd $1/$ac_foo && pwd` since $ac_foo can be
151dnl absolute.
152
153ac_buildpath=`cd $dstdir && cd $ac_builddir && pwd`
154ac_top_buildpath=`cd $dstdir && cd $ac_top_builddir && pwd`
155ac_srcpath=`cd $dstdir && cd $ac_srcdir && pwd`
156ac_top_srcpath=`cd $dstdir && cd $ac_top_srcdir && pwd`
157])# _AC_SRCPATHS
158
159dnl _RTEMS_OUTPUT_SUBDIRS([host|target|build],[HOST|TARGET|BUILD])
160AC_DEFUN([_RTEMS_OUTPUT_SUBDIRS],[
161m4_ifdef([_RTEMS_$2_CONFIGDIRS_LIST],
162[
163_RTEMS_ARG_VAR([CC_FOR_$2],
164  [c-compiler to be used for $1 subdirs (default: auto-detected)])
165_RTEMS_ARG_VAR([CFLAGS_FOR_$2],
166  [c-flags to be used for $1 subdirs (default: provided by autoconf)])
167if test "$no_recursion" != yes; then
168
169 if test -n "${$2_SUBDIRS}"; then
170  ac_sub_configure_args=
171  ac_prev=
172  for ac_arg in $$1args; do
173    if test -n "$ac_prev"; then
174      ac_prev=
175      continue
176    fi
177    case $ac_arg in
178    -cache-file | --cache-file | --cache-fil | --cache-fi \
179    | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
180      ac_prev=cache_file ;;
181    -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
182    | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
183    | --c=*)
184      ;;
185    --config-cache | -C)
186      ;;
187    -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
188      ac_prev=srcdir ;;
189    -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
190      ;;
191    -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
192      ac_prev=prefix ;;
193    -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
194      ;;
195    *) ac_sub_configure_args="$ac_sub_configure_args $ac_arg" ;;
196    esac
197  done
198
199  # Always prepend --prefix to ensure using the same prefix
200  # in subdir configurations.
201  ac_sub_configure_args="--prefix=$prefix $ac_sub_configure_args"
202
203  case "$$1_subdir" in
204  "." ) ;;
205  * )
206    ac_sub_configure_args="$ac_sub_configure_args --with-target-subdir=$$1_subdir --exec-prefix=${prefix}/$$1_subdir"
207    ;;
208  esac
209
210  # make sure that $1_subdir is not empty
211  test -n "$$1_subdir" || $1_subdir="."
212
213  ac_popdir=`pwd`
214  for ac_dir in $$1_configdirs; do
215
216    # Do not complain, so a configure script can configure whichever
217    # parts of a large source tree are present.
218    test -d $srcdir/$ac_dir || continue
219
220    AC_MSG_NOTICE([configuring in $$1_subdir/$ac_dir])
221    AS_MKDIR_P(["$$1_subdir/$ac_dir"])
222    _RTEMS_SRCPATHS(["$ac_dir"],["$$1_subdir"])
223
224    cd $$1_subdir/$ac_dir
225
226    # Check for guested configure; otherwise get Cygnus style configure.
227    if test -f $ac_srcdir/configure.gnu; then
228      ac_sub_configure="$SHELL '$ac_srcdir/configure.gnu'"
229    elif test -f $ac_srcdir/configure; then
230      ac_sub_configure="$SHELL '$ac_srcdir/configure'"
231    elif test -f $ac_srcdir/configure.in; then
232      ac_sub_configure=$ac_configure
233    else
234      AC_MSG_WARN([no configuration information is in $ac_dir])
235      ac_sub_configure=
236    fi
237
238    # The recursion is here.
239    if test -n "$ac_sub_configure"; then
240      # Make the cache file name correct relative to the subdirectory.
241      case $cache_file in
242      [[\\/]]* | ?:[[\\/]]* ) ac_sub_cache_file=$cache_file ;;
243      *) # Relative path.
244        ac_sub_cache_file=$ac_top_builddir$cache_file ;;
245      esac
246
247      AC_MSG_NOTICE([running $ac_sub_configure $ac_sub_configure_args \
248           --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir])
249      # The eval makes quoting arguments work.
250      ac_sub_configure_vars=
251      test -n "[$]CC_FOR_$2" && \
252        ac_sub_configure_vars="CC='[$]CC_FOR_$2'"
253      test -n "[$]CFLAGS_FOR_$2" && \
254        ac_sub_configure_vars="$ac_sub_configure_vars CFLAGS='[$]CFLAGS_FOR_$2'"
255      eval $ac_sub_configure_vars \
256        $ac_sub_configure $ac_sub_configure_args \
257          --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir ||
258        AC_MSG_ERROR([$ac_sub_configure failed for $ac_dir])
259    fi
260
261    cd $ac_popdir
262  done
263 fi
264fi
265])
266])
267
268## PUBLIC: RTEMS_BUILD_CONFIG_SUBDIRS(build_subdir)
269# subdirs to be built for the build environment
270AC_DEFUN([RTEMS_BUILD_CONFIG_SUBDIRS],[
271m4_append([_RTEMS_BUILD_CONFIGDIRS_LIST],[ $1])
272dnl Always append to build_configdirs
273AC_SUBST(build_configdirs,"$build_configdirs $1")
274
275m4_divert_text([DEFAULTS],
276               [ac_subdirs_all="$ac_subdirs_all m4_normalize([$1])"])
277m4_expand_once([_RTEMS_COMMANDS_POST_CONFIG_SUBDIRS])
278])
279
280AC_DEFUN(_RTEMS_BUILD_CONFIG_PREPARE,[
281# Record the configure arguments in Makefile.
282m4_ifdef([_RTEMS_BUILD_CONFIGDIRS_LIST],
283[
284buildargs=`echo "${ac_configure_args}" | \
285        sed -e 's/--no[[^       ]]*//' \
286            -e 's/--cache[[a-z-]]*=[[^  ]]*//' \
287            -e 's/--ho[[a-z-]]*=[[^     ]]*//' \
288            -e 's/--bu[[a-z-]]*=[[^     ]]*//' \
289            -e 's/--ta[[a-z-]]*=[[^     ]]*//' \
290            -e 's/[[^   ]]*alias=[[^    ]]*//g'` ;
291
292buildargs="--host=${build} --build=${build} --target=${target_alias} ${buildargs}"
293AC_SUBST(buildargs)
294
295build_subdir="."
296],[])
297])
298
299## PUBLIC: RTEMS_HOST_CONFIG_SUBDIRS(host_subdir)
300# subdirs to be build for the host environment
301AC_DEFUN([RTEMS_HOST_CONFIG_SUBDIRS],[
302m4_append([_RTEMS_HOST_CONFIGDIRS_LIST],[ $1])dnl
303
304if test $build = $host;
305then
306  if test $host = $target;
307  then
308    _RTEMS_SUBST_IFNOT([build_configdirs],[$1])
309  else
310    _RTEMS_SUBST_IFNOT([build_configdirs],[$1])
311  fi
312else
313  if test $host = $target;
314  then
315    _RTEMS_SUBST_IFNOT([host_configdirs],[$1])
316  else
317    if test $build = $target;
318    then
319      _RTEMS_SUBST_IFNOT([host_configdirs],[$1])
320    else
321      _RTEMS_SUBST_IFNOT([host_configdirs],[$1])
322    fi
323  fi
324fi
325
326m4_divert_text([DEFAULTS],
327               [ac_subdirs_all="$ac_subdirs_all m4_normalize([$1])"])
328m4_expand_once([_RTEMS_COMMANDS_POST_CONFIG_SUBDIRS])
329])
330
331AC_DEFUN(_RTEMS_HOST_CONFIG_PREPARE,[
332m4_ifdef([_RTEMS_HOST_CONFIGDIRS_LIST],
333[
334# Record configure arguments in Makefile.
335hostargs=`echo "${ac_configure_args}" | \
336        sed -e 's/--no[[^       ]]*//' \
337            -e 's/--cache[[a-z-]]*=[[^  ]]*//' \
338            -e 's/--ho[[a-z-]]*=[[^     ]]*//' \
339            -e 's/--bu[[a-z-]]*=[[^     ]]*//' \
340            -e 's/--ta[[a-z-]]*=[[^     ]]*//' \
341            -e 's/[[^   ]]*alias=[[^    ]]*//g'` ;
342
343hostargs="--host=${host_alias} --build=${build} --target=${target_alias} ${hostargs}"
344AC_SUBST(hostargs)
345
346host_subdir="${host_alias}"
347],[])
348])
349
350## PUBLIC: RTEMS_TARGET_CONFIG_SUBDIRS(target_subdir)
351# subdirs to be build for the target environment
352AC_DEFUN([RTEMS_TARGET_CONFIG_SUBDIRS],[
353m4_append([_RTEMS_TARGET_CONFIGDIRS_LIST],[ $1])
354
355if test $build = $host;
356then
357  if test $host = $target;
358  then
359    _RTEMS_SUBST_IFNOT([build_configdirs],[$1])
360  else
361    _RTEMS_SUBST_IFNOT([target_configdirs],[$1])
362  fi
363else
364  if test $host = $target;
365  then
366    _RTEMS_SUBST_IFNOT([host_configdirs],[$1])
367  else
368    if test $build = $target;
369    then
370      _RTEMS_SUBST_IFNOT([build_configdirs],[$1])
371    else
372      _RTEMS_SUBST_IFNOT([target_configdirs],[$1])
373    fi
374  fi
375fi
376
377m4_divert_text([DEFAULTS],
378               [ac_subdirs_all="$ac_subdirs_all m4_normalize([$1])"])
379m4_expand_once([_RTEMS_COMMANDS_POST_CONFIG_SUBDIRS])
380])
381
382AC_DEFUN(_RTEMS_TARGET_CONFIG_PREPARE,[
383m4_ifdef([_RTEMS_TARGET_CONFIGDIRS_LIST],
384[
385# Record the configure arguments in Makefile.
386targetargs=`echo "${ac_configure_args}" | \
387        sed -e 's/--no[[^       ]]*//' \
388            -e 's/--cache[[a-z-]]*=[[^  ]]*//' \
389            -e 's/--ho[[a-z-]]*=[[^     ]]*//' \
390            -e 's/--bu[[a-z-]]*=[[^     ]]*//' \
391            -e 's/--ta[[a-z-]]*=[[^     ]]*//' \
392            -e 's/[[^   ]]*alias=[[^    ]]*//g'` ;
393
394targetargs="--host=${target_alias} --build=${build} --target=${target_alias} ${targetargs}"
395AC_SUBST(targetargs)
396
397target_subdir="${target_alias}"
398],[])
399])
Note: See TracBrowser for help on using the repository browser.