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