summaryrefslogtreecommitdiffstats
path: root/aclocal/config-subdirs.m4
blob: 0dbcc5f63b4e2fed51076bf67640e6f767feba9d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
dnl $Id$

dnl
dnl Misc utility macros for subdir handling to work around missing abilities
dnl in autoconf, automake and structural issues with RTEMS
dnl
dnl Contains parts derived from autoconf-2.13 AC_OUTPUT_SUBDIRS and Cygnus'
dnl configure.in.
dnl

dnl
dnl _RTEMS_PUSH_BUILDDIR(SUBDIR)
dnl
AC_DEFUN(_RTEMS_PUSH_BUILDDIR,
[
# _RTEMS_PUSH_BUILDDIR
    echo configuring in $1
## We use mkinstalldirs below as a workaround to mkdir -p not being
## available everywhere, but us wanting to support deep directories.
    case "$srcdir" in
    .) ;;
    *)
      if ${ac_aux_dir}/mkinstalldirs $1; 
      then :;
      else
        AC_MSG_ERROR([can not create `pwd`/$1])
      fi
      ;;
    esac

    ac_popdir=`pwd`
    cd $1
])

dnl
dnl _RTEMS_POP_BUILDDIR
dnl
AC_DEFUN(_RTEMS_POP_BUILDDIR,
[
  cd $ac_popdir
])

dnl
dnl _RTEMS_GIVEN_INSTALL
dnl
AC_DEFUN(_RTEMS_GIVEN_INSTALL,
[
ifdef([AC_PROVIDE_AC_PROG_INSTALL],
      [  case "$ac_given_INSTALL" in
changequote(, )dnl
        [/$]*) INSTALL="$ac_given_INSTALL" ;;
changequote([, ])dnl
        *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
        esac
])dnl
])

dnl
dnl _AC_DOTS(PATH)
dnl
AC_DEFUN(_AC_DOTS,[
# A "../" for each directory in $1.
    ac_dots=`echo $1 | \
             sed -e 's%^\./%%' -e 's%[[^/]]$%&/%' -e 's%[[^/]]*/%../%g'`
])

dnl
dnl _RTEMS_ADJUST_SRCDIR(REVAR,CONFIG_DIR[,TARGET_SUBDIR])
dnl
AC_DEFUN(_RTEMS_ADJUST_SRCDIR,[
    _AC_DOTS(ifelse([$3], ,[$2],[$3/$2]))

    case "$srcdir" in
    .) # No --srcdir option.  We are building in place.
      $1=$srcdir ;;
    /*) # Absolute path.
      $1=$srcdir/$2 ;;
    *) # Relative path.
      $1=$ac_dots$srcdir/$2 ;;
    esac
])

dnl
dnl _RTEMS_SUB_SRCDIR(AC_CONFIG_DIR[,TARGET_SUBDIR])
dnl
AC_DEFUN(_RTEMS_SUB_SRCDIR,[
# _RTEMS_SUB_SRCDIR
    _RTEMS_ADJUST_SRCDIR(ac_sub_srcdir,$1,$2)

    # Check for configure
    if test -f $ac_sub_srcdir/configure; then
      ac_sub_configure=$ac_sub_srcdir/configure
    else
      AC_MSG_WARN([no configuration information is in $1])
      ac_sub_configure=
    fi
])

AC_DEFUN(RTEMS_TARGET_CONFIG_PREPARE,[
# Record target_configdirs and the configure arguments in Makefile.
targargs=`echo "${ac_configure_args}" | \
        sed -e 's/--no[[^ 	]]*//' \
            -e 's/--cache[[a-z-]]*=[[^ 	]]*//' \
            -e 's/--ho[[a-z-]]*=[[^ 	]]*//' \
            -e 's/--bu[[a-z-]]*=[[^ 	]]*//' \
            -e 's/--ta[[a-z-]]*=[[^ 	]]*//'`;

targargs="--host=${target_alias} --build=${build} ${targargs}"
AC_SUBST(targargs)
])

AC_DEFUN(RTEMS_TARGET_CONFIG_SUBDIRS,[
#
# TARGET_CONFIG_SUBDIRS
#
if test "$no_recursion" != yes; then
 if test $target != $build; then
  # Remove --srcdir arguments so they do not pile up.
  ac_sub_configure_args=
  ac_prev=
  for ac_arg in $targargs; do
    if test -n "$ac_prev"; then
      ac_prev=
      continue
    fi
    case "$ac_arg" in
    -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
      ac_prev=srcdir ;;
    -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
      ;;
    *) ac_sub_configure_args="$ac_sub_configure_args $ac_arg" ;;
    esac
  done

  test -n "$target_configdirs" && test -d $target_subdir || mkdir $target_subdir

  for ac_config_dir in $target_configdirs; do
    # Do not complain, so a configure script can configure whichever
    # parts of a large source tree are present.
    if test ! -d $srcdir/$ac_config_dir; then
      continue
    fi

    _RTEMS_PUSH_BUILDDIR([$target_subdir/$ac_config_dir])

    _RTEMS_SUB_SRCDIR([$ac_config_dir],[$target_subdir])

    # The recursion is here.
    if test -n "$ac_sub_configure"; then

      # Make the cache file name correct relative to the subdirectory.
      ac_sub_cache_file=$cache_file
      _RTEMS_GIVEN_INSTALL

      echo "[running ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file] --srcdir=$ac_sub_srcdir"
      # The eval makes quoting arguments work.
      CC=${CC_FOR_TARGET}; export CC;
      if eval ${CONFIG_SHELL-/bin/sh} $ac_sub_configure \
	$ac_sub_configure_args --srcdir=$ac_sub_srcdir \
	--with-target-subdir=$target_subdir \
	--cache-file=$ac_sub_cache_file \
        --exec-prefix="\${prefix}/$target_subdir"
      then :
      else
        AC_MSG_ERROR([$ac_sub_configure failed for $ac_config_dir])
      fi
    fi

    _RTEMS_POP_BUILDDIR
  done
 fi
fi
])

AC_DEFUN(RTEMS_HOST_CONFIG_PREPARE,[
# Record host_configdirs and the configure arguments in Makefile.
hostargs=`echo "${ac_configure_args}" | \
        sed -e 's/--no[[^ 	]]*//' \
            -e 's/--cache[[a-z-]]*=[[^ 	]]*//' \
            -e 's/--ho[[a-z-]]*=[[^ 	]]*//' \
            -e 's/--bu[[a-z-]]*=[[^ 	]]*//' \
            -e 's/--ta[[a-z-]]*=[[^ 	]]*//'`;

hostargs="--host=${host_alias} --build=${build} --target=${target_alias} ${hostargs}"
AC_SUBST(hostargs)
])

AC_DEFUN(RTEMS_HOST_CONFIG_SUBDIRS,[
#
# HOST_CONFIG_SUBDIRS
#
if test "$no_recursion" != yes; then

 if test $build != $host; then
  # Remove --srcdir arguments so they do not pile up.
  ac_sub_configure_args=
  ac_prev=
  for ac_arg in $hostargs; do
    if test -n "$ac_prev"; then
      ac_prev=
      continue
    fi
    case "$ac_arg" in
    -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
      ac_prev=srcdir ;;
    -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
      ;;
    *) ac_sub_configure_args="$ac_sub_configure_args $ac_arg" ;;
    esac
  done

  test -n "$host_configdirs" && test -d $host_subdir || mkdir $host_subdir

  for ac_config_dir in $host_configdirs; do
    # Do not complain, so a configure script can configure whichever
    # parts of a large source tree are present.
    if test ! -d $srcdir/$ac_config_dir; then
      continue
    fi

    _RTEMS_PUSH_BUILDDIR([$host_subdir/$ac_config_dir])

    _RTEMS_SUB_SRCDIR([$ac_config_dir],[$host_subdir])

    # The recursion is here.
    if test -n "$ac_sub_configure"; then

      # Make the cache file name correct relative to the subdirectory.
      ac_sub_cache_file=$cache_file
      _RTEMS_GIVEN_INSTALL

      echo "[running ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file] --srcdir=$ac_sub_srcdir"
      CC=${CC_FOR_HOST}; export CC;
      # The eval makes quoting arguments work.
      if eval ${CONFIG_SHELL-/bin/sh} $ac_sub_configure \
	$ac_sub_configure_args --srcdir=$ac_sub_srcdir \
	--with-target-subdir=$host_subdir \
	--cache-file=$ac_sub_cache_file
      then :
      else
        AC_MSG_ERROR([$ac_sub_configure failed for $ac_config_dir])
      fi
    fi

    _RTEMS_POP_BUILDDIR
  done
 fi
fi
])