source: rtems/acinclude.m4 @ 55837f7

4.104.114.84.9
Last change on this file since 55837f7 was 55837f7, checked in by Ralf Corsepius <ralf.corsepius@…>, on Mar 25, 2003 at 8:55:26 AM

Merger from rtems-4-6-branch.

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