source: rtems/acinclude.m4 @ 16d5e394

Last change on this file since 16d5e394 was feb447e, checked in by Ralf Corsepius <ralf.corsepius@…>, on Jul 27, 2008 at 6:50:08 AM

Allow empty configdirs.

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