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 | AC_PREREQ(2.57) |
---|
7 | |
---|
8 | dnl RTEMS_ARG_VAR(VAR,HELP-STRING) |
---|
9 | dnl An internal macros to have help strings pretty |
---|
10 | dnl printed with configure --help, without letting autoconf spoil config subdir |
---|
11 | dnl environments by trying to propagate them |
---|
12 | dnl Stripped down version of autoconf-2.52's AC_ARG_VAR. |
---|
13 | |
---|
14 | AC_DEFUN([_RTEMS_ARG_VAR], |
---|
15 | [ |
---|
16 | m4_expand_once([m4_divert_once([HELP_VAR], |
---|
17 | [AC_HELP_STRING([$1], [$2], [ ])])], |
---|
18 | [$0($1)])dnl |
---|
19 | ]) |
---|
20 | |
---|
21 | AC_DEFUN([_RTEMS_SUBST_IFNOT], |
---|
22 | [AS_IF([`echo " [$]$1 " | grep " $2 " > /dev/null`], |
---|
23 | [], |
---|
24 | [AC_SUBST([$1],["[$]$1 $2"])]) |
---|
25 | ]) |
---|
26 | |
---|
27 | AC_DEFUN([_RTEMS_TOOLS], |
---|
28 | [ |
---|
29 | m4_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 | |
---|
42 | AC_DEFUN([_RTEMS_COMMANDS_POST_CONFIG_SUBDIRS], |
---|
43 | [ |
---|
44 | AC_CONFIG_COMMANDS_PRE([ |
---|
45 | |
---|
46 | if 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 |
---|
64 | else |
---|
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 |
---|
82 | fi |
---|
83 | |
---|
84 | _RTEMS_BUILD_CONFIG_PREPARE |
---|
85 | _RTEMS_HOST_CONFIG_PREPARE |
---|
86 | _RTEMS_TARGET_CONFIG_PREPARE |
---|
87 | |
---|
88 | build_subdir="." |
---|
89 | build_SUBDIRS="${build_configdirs}" |
---|
90 | build_configdirs="${build_configdirs}" |
---|
91 | |
---|
92 | AS_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 | |
---|
103 | AS_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 | |
---|
114 | AC_SUBST(host_SUBDIRS) |
---|
115 | AC_SUBST(target_SUBDIRS) |
---|
116 | AC_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 | |
---|
126 | dnl _RTEMS_SRCPATHS(BUILD-DIR-NAME) |
---|
127 | dnl ---------------------------- |
---|
128 | dnl Inputs: |
---|
129 | dnl - BUILD-DIR-NAME is `top-build -> build' and `top-src -> src' |
---|
130 | dnl - `$srcdir' is `top-build -> top-src' |
---|
131 | dnl |
---|
132 | dnl Outputs: |
---|
133 | dnl - `ac_builddir' is `.', for symmetry only. |
---|
134 | dnl - `ac_top_builddir' is `build -> top_build'. |
---|
135 | dnl If not empty, has a trailing slash. |
---|
136 | dnl - `ac_srcdir' is `build -> src'. |
---|
137 | dnl - `ac_top_srcdir' is `build -> top-src'. |
---|
138 | dnl |
---|
139 | dnl and `ac_buildpath' etc., the absolute paths. |
---|
140 | m4_define([_RTEMS_SRCPATHS], |
---|
141 | [ |
---|
142 | m4_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;; |
---|
149 | esac]) |
---|
150 | ac_builddir=. |
---|
151 | |
---|
152 | AS_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 | |
---|
162 | case $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 | ;; |
---|
178 | esac |
---|
179 | dnl Don't blindly perform a `cd $1/$ac_foo && pwd` since $ac_foo can be |
---|
180 | dnl absolute. |
---|
181 | |
---|
182 | ac_buildpath=`cd $dstdir && cd $ac_builddir && pwd` |
---|
183 | ac_top_buildpath=`cd $dstdir && cd $ac_top_builddir && pwd` |
---|
184 | ac_srcpath=`cd $dstdir && cd $ac_srcdir && pwd` |
---|
185 | ac_top_srcpath=`cd $dstdir && cd $ac_top_srcdir && pwd` |
---|
186 | ])# _AC_SRCPATHS |
---|
187 | |
---|
188 | dnl _RTEMS_OUTPUT_SUBDIRS([host|target|build],[HOST|TARGET|BUILD]) |
---|
189 | AC_DEFUN([_RTEMS_OUTPUT_SUBDIRS],[ |
---|
190 | m4_ifdef([_RTEMS_$2_CONFIGDIRS_LIST], |
---|
191 | [ |
---|
192 | if 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 |
---|
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 |
---|
269 | fi |
---|
270 | ]) |
---|
271 | ]) |
---|
272 | |
---|
273 | AC_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 |
---|
327 | AC_DEFUN([RTEMS_BUILD_CONFIG_SUBDIRS],[ |
---|
328 | m4_append([_RTEMS_BUILD_CONFIGDIRS_LIST],[ $1]) |
---|
329 | dnl Always append to build_configdirs |
---|
330 | AC_SUBST(build_configdirs,"$build_configdirs $1") |
---|
331 | |
---|
332 | m4_divert_text([DEFAULTS], |
---|
333 | [ac_subdirs_all="$ac_subdirs_all m4_normalize([$1])"]) |
---|
334 | m4_expand_once([_RTEMS_COMMANDS_POST_CONFIG_SUBDIRS]) |
---|
335 | ]) |
---|
336 | |
---|
337 | AC_DEFUN([_RTEMS_BUILD_CONFIG_PREPARE],[ |
---|
338 | ## # Record the configure arguments in Makefile. |
---|
339 | m4_ifdef([_RTEMS_BUILD_CONFIGDIRS_LIST], |
---|
340 | [ |
---|
341 | m4_expand_once([_RTEMS_TOOLS([build],[BUILD])]) |
---|
342 | m4_expand_once([_RTEMS_CONFIGURE_ARGS_PRUNE([buildargs])]) |
---|
343 | eval buildargs_prune $ac_configure_args |
---|
344 | buildargs="'--host=${build_alias-$build}' '--build=${build_alias-$build}' ${buildargs}" |
---|
345 | buildargs="${buildargs} '--target=${target_alias-$target}'" |
---|
346 | ],[]) |
---|
347 | AC_SUBST(buildargs) |
---|
348 | AC_SUBST(build_subdir) |
---|
349 | ]) |
---|
350 | |
---|
351 | ## PUBLIC: RTEMS_HOST_CONFIG_SUBDIRS(host_subdir) |
---|
352 | # subdirs to be build for the host environment |
---|
353 | AC_DEFUN([RTEMS_HOST_CONFIG_SUBDIRS],[ |
---|
354 | m4_append([_RTEMS_HOST_CONFIGDIRS_LIST],[ $1])dnl |
---|
355 | |
---|
356 | _RTEMS_SUBST_IFNOT([host_configdirs],[$1]) |
---|
357 | |
---|
358 | m4_divert_text([DEFAULTS], |
---|
359 | [ac_subdirs_all="$ac_subdirs_all m4_normalize([$1])"]) |
---|
360 | m4_expand_once([_RTEMS_COMMANDS_POST_CONFIG_SUBDIRS]) |
---|
361 | ]) |
---|
362 | |
---|
363 | AC_DEFUN([_RTEMS_HOST_CONFIG_PREPARE],[ |
---|
364 | m4_ifdef([_RTEMS_HOST_CONFIGDIRS_LIST], |
---|
365 | [ |
---|
366 | m4_expand_once([_RTEMS_TOOLS([host],[HOST])]) |
---|
367 | m4_expand_once([_RTEMS_CONFIGURE_ARGS_PRUNE([hostargs])]) |
---|
368 | eval hostargs_prune $ac_configure_args |
---|
369 | hostargs="'--host=${host_alias-$host}' '--build=${build_alias-$build}' '--target=${target_alias-$target}' ${hostargs}" |
---|
370 | ],[]) |
---|
371 | AC_SUBST(hostargs) |
---|
372 | AC_SUBST(host_subdir) |
---|
373 | ]) |
---|
374 | |
---|
375 | ## PUBLIC: RTEMS_TARGET_CONFIG_SUBDIRS(target_subdir) |
---|
376 | # subdirs to be build for the target environment |
---|
377 | AC_DEFUN([RTEMS_TARGET_CONFIG_SUBDIRS],[ |
---|
378 | AS_IF([test -d ${srcdir}/$1],[ |
---|
379 | m4_append([_RTEMS_TARGET_CONFIGDIRS_LIST],[ $1]) |
---|
380 | |
---|
381 | _RTEMS_SUBST_IFNOT([target_configdirs],[$1]) |
---|
382 | |
---|
383 | m4_divert_text([DEFAULTS], |
---|
384 | [ac_subdirs_all="$ac_subdirs_all m4_normalize([$1])"]) |
---|
385 | m4_expand_once([_RTEMS_COMMANDS_POST_CONFIG_SUBDIRS]) |
---|
386 | ]) |
---|
387 | ]) |
---|
388 | |
---|
389 | AC_DEFUN([_RTEMS_TARGET_CONFIG_PREPARE],[ |
---|
390 | m4_ifdef([_RTEMS_TARGET_CONFIGDIRS_LIST], |
---|
391 | [ |
---|
392 | m4_expand_once([_RTEMS_TOOLS([target],[TARGET])]) |
---|
393 | m4_expand_once([_RTEMS_CONFIGURE_ARGS_PRUNE([targetargs])]) |
---|
394 | eval targetargs_prune $ac_configure_args |
---|
395 | targetargs="'--host=${target_alias-$target}' '--build=${build_alias-$build}' '--target=${target_alias-$target}' ${targetargs}" |
---|
396 | ],[]) |
---|
397 | AC_SUBST(targetargs) |
---|
398 | AC_SUBST(target_subdir) |
---|
399 | ]) |
---|