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