1 | dnl $Id$ |
---|
2 | |
---|
3 | dnl |
---|
4 | dnl Misc utility macros for subdir handling to work around missing abilities |
---|
5 | dnl in autoconf, automake and structural issues with RTEMS |
---|
6 | dnl |
---|
7 | dnl Contains parts derived from autoconf-2.13 AC_OUTPUT_SUBDIRS and Cygnus' |
---|
8 | dnl configure.in. |
---|
9 | dnl |
---|
10 | |
---|
11 | dnl |
---|
12 | dnl _RTEMS_PUSH_BUILDDIR(SUBDIR) |
---|
13 | dnl |
---|
14 | AC_DEFUN(_RTEMS_PUSH_BUILDDIR, |
---|
15 | [ |
---|
16 | # _RTEMS_PUSH_BUILDDIR |
---|
17 | echo configuring in $1 |
---|
18 | ## We use mkinstalldirs below as a workaround to mkdir -p not being |
---|
19 | ## available everywhere, but us wanting to support deep directories. |
---|
20 | case "$srcdir" in |
---|
21 | .) ;; |
---|
22 | *) |
---|
23 | if ${ac_aux_dir}/mkinstalldirs $1; |
---|
24 | then :; |
---|
25 | else |
---|
26 | AC_MSG_ERROR([can not create `pwd`/$1]) |
---|
27 | fi |
---|
28 | ;; |
---|
29 | esac |
---|
30 | |
---|
31 | ac_popdir=`pwd` |
---|
32 | cd $1 |
---|
33 | ]) |
---|
34 | |
---|
35 | dnl |
---|
36 | dnl _RTEMS_POP_BUILDDIR |
---|
37 | dnl |
---|
38 | AC_DEFUN(_RTEMS_POP_BUILDDIR, |
---|
39 | [ |
---|
40 | cd $ac_popdir |
---|
41 | ]) |
---|
42 | |
---|
43 | dnl |
---|
44 | dnl _RTEMS_GIVEN_INSTALL |
---|
45 | dnl |
---|
46 | AC_DEFUN(_RTEMS_GIVEN_INSTALL, |
---|
47 | [ |
---|
48 | ifdef([AC_PROVIDE_AC_PROG_INSTALL],[ |
---|
49 | case "$ac_given_INSTALL" in |
---|
50 | [[\\/]]* | ?:[[\\/]]*) INSTALL="$ac_given_INSTALL" ;; |
---|
51 | *) INSTALL="$ac_dots$ac_given_INSTALL" ;; |
---|
52 | esac |
---|
53 | ])dnl |
---|
54 | ]) |
---|
55 | |
---|
56 | dnl |
---|
57 | dnl _AC_DOTS(PATH) |
---|
58 | dnl |
---|
59 | AC_DEFUN(_AC_DOTS,[ |
---|
60 | # A "../" for each directory in $1. |
---|
61 | ac_dots=`echo $1 | \ |
---|
62 | sed -e 's%^\./%%' -e 's%[[^/]]$%&/%' -e 's%[[^/]]*/%../%g'` |
---|
63 | ]) |
---|
64 | |
---|
65 | dnl |
---|
66 | dnl _RTEMS_ADJUST_SRCDIR(REVAR,CONFIG_DIR[,TARGET_SUBDIR]) |
---|
67 | dnl |
---|
68 | AC_DEFUN(_RTEMS_ADJUST_SRCDIR,[ |
---|
69 | _AC_DOTS(ifelse([$3], ,[$2],[$3/$2])) |
---|
70 | |
---|
71 | case "$srcdir" in |
---|
72 | .) # No --srcdir option. We are building in place. |
---|
73 | $1=$srcdir ;; |
---|
74 | [[\\/]]* | ?:[[\\/]]*) # Absolute path. |
---|
75 | $1=$srcdir/$2 ;; |
---|
76 | *) # Relative path. |
---|
77 | $1=$ac_dots$srcdir/$2 ;; |
---|
78 | esac |
---|
79 | ]) |
---|
80 | |
---|
81 | dnl |
---|
82 | dnl _RTEMS_SUB_SRCDIR(AC_CONFIG_DIR[,TARGET_SUBDIR]) |
---|
83 | dnl |
---|
84 | AC_DEFUN(_RTEMS_SUB_SRCDIR,[ |
---|
85 | # _RTEMS_SUB_SRCDIR |
---|
86 | _RTEMS_ADJUST_SRCDIR(ac_sub_srcdir,$1,$2) |
---|
87 | |
---|
88 | # Check for configure |
---|
89 | if test -f $ac_sub_srcdir/configure; then |
---|
90 | ac_sub_configure=$ac_sub_srcdir/configure |
---|
91 | else |
---|
92 | AC_MSG_WARN([no configuration information is in $1]) |
---|
93 | ac_sub_configure= |
---|
94 | fi |
---|
95 | ]) |
---|
96 | |
---|
97 | AC_DEFUN(RTEMS_TARGET_CONFIG_PREPARE,[ |
---|
98 | # Record target_configdirs and the configure arguments in Makefile. |
---|
99 | targargs=`echo "${ac_configure_args}" | \ |
---|
100 | sed -e 's/--no[[^ ]]*//' \ |
---|
101 | -e 's/--cache[[a-z-]]*=[[^ ]]*//' \ |
---|
102 | -e 's/--ho[[a-z-]]*=[[^ ]]*//' \ |
---|
103 | -e 's/--bu[[a-z-]]*=[[^ ]]*//' \ |
---|
104 | -e 's/--ta[[a-z-]]*=[[^ ]]*//'`; |
---|
105 | |
---|
106 | targargs="--host=${target_alias} --build=${build} ${targargs}" |
---|
107 | AC_SUBST(targargs) |
---|
108 | ]) |
---|
109 | |
---|
110 | AC_DEFUN(RTEMS_TARGET_CONFIG_SUBDIRS,[ |
---|
111 | # |
---|
112 | # TARGET_CONFIG_SUBDIRS |
---|
113 | # |
---|
114 | if test "$no_recursion" != yes; then |
---|
115 | if test $target != $build; then |
---|
116 | # Remove --srcdir arguments so they do not pile up. |
---|
117 | ac_sub_configure_args= |
---|
118 | ac_prev= |
---|
119 | for ac_arg in $targargs; do |
---|
120 | if test -n "$ac_prev"; then |
---|
121 | ac_prev= |
---|
122 | continue |
---|
123 | fi |
---|
124 | case "$ac_arg" in |
---|
125 | -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) |
---|
126 | ac_prev=srcdir ;; |
---|
127 | -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) |
---|
128 | ;; |
---|
129 | *) ac_sub_configure_args="$ac_sub_configure_args $ac_arg" ;; |
---|
130 | esac |
---|
131 | done |
---|
132 | |
---|
133 | test -n "$target_configdirs" && test -d $target_subdir || mkdir $target_subdir |
---|
134 | |
---|
135 | for ac_config_dir in $target_configdirs; do |
---|
136 | # Do not complain, so a configure script can configure whichever |
---|
137 | # parts of a large source tree are present. |
---|
138 | if test ! -d $srcdir/$ac_config_dir; then |
---|
139 | continue |
---|
140 | fi |
---|
141 | |
---|
142 | _RTEMS_PUSH_BUILDDIR([$target_subdir/$ac_config_dir]) |
---|
143 | |
---|
144 | _RTEMS_SUB_SRCDIR([$ac_config_dir],[$target_subdir]) |
---|
145 | |
---|
146 | # The recursion is here. |
---|
147 | if test -n "$ac_sub_configure"; then |
---|
148 | |
---|
149 | # Make the cache file name correct relative to the subdirectory. |
---|
150 | ac_sub_cache_file=$cache_file |
---|
151 | _RTEMS_GIVEN_INSTALL |
---|
152 | |
---|
153 | echo "[running ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file] --srcdir=$ac_sub_srcdir" |
---|
154 | # The eval makes quoting arguments work. |
---|
155 | CC=${CC_FOR_TARGET}; export CC; |
---|
156 | if eval ${CONFIG_SHELL-/bin/sh} $ac_sub_configure \ |
---|
157 | $ac_sub_configure_args --srcdir=$ac_sub_srcdir \ |
---|
158 | --with-target-subdir=$target_subdir \ |
---|
159 | --cache-file=$ac_sub_cache_file \ |
---|
160 | --exec-prefix="\${prefix}/$target_subdir" |
---|
161 | then : |
---|
162 | else |
---|
163 | AC_MSG_ERROR([$ac_sub_configure failed for $ac_config_dir]) |
---|
164 | fi |
---|
165 | fi |
---|
166 | |
---|
167 | _RTEMS_POP_BUILDDIR |
---|
168 | done |
---|
169 | fi |
---|
170 | fi |
---|
171 | ]) |
---|
172 | |
---|
173 | AC_DEFUN(RTEMS_HOST_CONFIG_PREPARE,[ |
---|
174 | # Record host_configdirs and the configure arguments in Makefile. |
---|
175 | hostargs=`echo "${ac_configure_args}" | \ |
---|
176 | sed -e 's/--no[[^ ]]*//' \ |
---|
177 | -e 's/--cache[[a-z-]]*=[[^ ]]*//' \ |
---|
178 | -e 's/--ho[[a-z-]]*=[[^ ]]*//' \ |
---|
179 | -e 's/--bu[[a-z-]]*=[[^ ]]*//' \ |
---|
180 | -e 's/--ta[[a-z-]]*=[[^ ]]*//'`; |
---|
181 | |
---|
182 | hostargs="--host=${host_alias} --build=${build} --target=${target_alias} ${hostargs}" |
---|
183 | AC_SUBST(hostargs) |
---|
184 | ]) |
---|
185 | |
---|
186 | AC_DEFUN(RTEMS_HOST_CONFIG_SUBDIRS,[ |
---|
187 | # |
---|
188 | # HOST_CONFIG_SUBDIRS |
---|
189 | # |
---|
190 | if test "$no_recursion" != yes; then |
---|
191 | |
---|
192 | if test $build != $host; then |
---|
193 | # Remove --srcdir arguments so they do not pile up. |
---|
194 | ac_sub_configure_args= |
---|
195 | ac_prev= |
---|
196 | for ac_arg in $hostargs; do |
---|
197 | if test -n "$ac_prev"; then |
---|
198 | ac_prev= |
---|
199 | continue |
---|
200 | fi |
---|
201 | case "$ac_arg" in |
---|
202 | -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) |
---|
203 | ac_prev=srcdir ;; |
---|
204 | -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) |
---|
205 | ;; |
---|
206 | *) ac_sub_configure_args="$ac_sub_configure_args $ac_arg" ;; |
---|
207 | esac |
---|
208 | done |
---|
209 | |
---|
210 | test -n "$host_configdirs" && test -d $host_subdir || mkdir $host_subdir |
---|
211 | |
---|
212 | for ac_config_dir in $host_configdirs; do |
---|
213 | # Do not complain, so a configure script can configure whichever |
---|
214 | # parts of a large source tree are present. |
---|
215 | if test ! -d $srcdir/$ac_config_dir; then |
---|
216 | continue |
---|
217 | fi |
---|
218 | |
---|
219 | _RTEMS_PUSH_BUILDDIR([$host_subdir/$ac_config_dir]) |
---|
220 | |
---|
221 | _RTEMS_SUB_SRCDIR([$ac_config_dir],[$host_subdir]) |
---|
222 | |
---|
223 | # The recursion is here. |
---|
224 | if test -n "$ac_sub_configure"; then |
---|
225 | |
---|
226 | # Make the cache file name correct relative to the subdirectory. |
---|
227 | ac_sub_cache_file=$cache_file |
---|
228 | _RTEMS_GIVEN_INSTALL |
---|
229 | |
---|
230 | echo "[running ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file] --srcdir=$ac_sub_srcdir" |
---|
231 | CC=${CC_FOR_HOST-$host_alias-gcc}; export CC; |
---|
232 | # The eval makes quoting arguments work. |
---|
233 | if eval ${CONFIG_SHELL-/bin/sh} $ac_sub_configure \ |
---|
234 | $ac_sub_configure_args --srcdir=$ac_sub_srcdir \ |
---|
235 | --with-target-subdir=$host_subdir \ |
---|
236 | --cache-file=$ac_sub_cache_file |
---|
237 | then : |
---|
238 | else |
---|
239 | AC_MSG_ERROR([$ac_sub_configure failed for $ac_config_dir]) |
---|
240 | fi |
---|
241 | fi |
---|
242 | |
---|
243 | _RTEMS_POP_BUILDDIR |
---|
244 | done |
---|
245 | fi |
---|
246 | fi |
---|
247 | ]) |
---|