| 1 | set -x |
| 2 | # Configure fragment invoked in the post-target section for subdirs |
| 3 | # wanting multilib support. |
| 4 | # |
| 5 | # It is advisable to support a few --enable/--disable options to let the |
| 6 | # user select which libraries s/he really wants. |
| 7 | # |
| 8 | # Subdirectories wishing to use multilib should put the following lines |
| 9 | # in the "post-target" section of configure.in. |
| 10 | # |
| 11 | # if [ "${srcdir}" = "." ] ; then |
| 12 | # if [ "${with_target_subdir}" != "." ] ; then |
| 13 | # . ${srcdir}/${with_multisrctop}../../config-ml.in |
| 14 | # else |
| 15 | # . ${srcdir}/${with_multisrctop}../config-ml.in |
| 16 | # fi |
| 17 | # else |
| 18 | # . ${srcdir}/../config-ml.in |
| 19 | # fi |
| 20 | # |
| 21 | # See librx/configure.in in the libg++ distribution for an example of how |
| 22 | # to handle autoconf'd libraries. |
| 23 | # |
| 24 | # Things are complicated because 6 separate cases must be handled: |
| 25 | # 2 (native, cross) x 3 (absolute-path, relative-not-dot, dot) = 6. |
| 26 | # |
| 27 | # srcdir=. is special. It must handle make programs that don't handle VPATH. |
| 28 | # To implement this, a symlink tree is built for each library and for each |
| 29 | # multilib subdir. |
| 30 | # |
| 31 | # The build tree is layed out as |
| 32 | # |
| 33 | # ./ |
| 34 | # libg++ |
| 35 | # newlib |
| 36 | # m68020/ |
| 37 | # libg++ |
| 38 | # newlib |
| 39 | # m68881/ |
| 40 | # libg++ |
| 41 | # newlib |
| 42 | # |
| 43 | # The nice feature about this arrangement is that inter-library references |
| 44 | # in the build tree work without having to care where you are. Note that |
| 45 | # inter-library references also work in the source tree because symlink trees |
| 46 | # are built when srcdir=. |
| 47 | # |
| 48 | # Configure variables: |
| 49 | # ${with_target_subdir} = "." for native, or ${target_alias} for cross. |
| 50 | # Set by top level Makefile. |
| 51 | # ${with_multisrctop} = how many levels of multilibs there are in the source |
| 52 | # tree. It exists to handle the case of configuring in the source tree: |
| 53 | # ${srcdir} is not constant. |
| 54 | # ${with_multisubdir} = name of multilib subdirectory (eg: m68020/m68881). |
| 55 | # |
| 56 | # Makefile variables: |
| 57 | # MULTISRCTOP = number of multilib levels in source tree (+1 if cross) |
| 58 | # MULITBUILDTOP = number of multilib levels in build tree |
| 59 | # MULTIDIRS = list of multilib subdirs (eg: m68000 m68020 ...) |
| 60 | # (only defined in each library's main Makefile). |
| 61 | # MULTISUBDIR = installed subdirectory name with leading '/' (eg: /m68000) |
| 62 | # (only defined in each multilib subdir). |
| 63 | |
| 64 | # FIXME: Multilib is currently disabled by default for everything other than |
| 65 | # newlib. It is up to each target to turn on multilib support for the other |
| 66 | # libraries as desired. |
| 67 | |
| 68 | # We have to handle being invoked by both Cygnus configure and Autoconf. |
| 69 | # We except both to define `srcdir' and `target' (we *could* figure them |
| 70 | # out, but we'd have to do work that they're already done to figure them out). |
| 71 | # We expect Cygnus configure to define `arguments' and Autoconf to define |
| 72 | # `ac_configure_args'. |
| 73 | |
| 74 | if [ -n "${ac_configure_args}" ]; then |
| 75 | Makefile=${ac_file-Makefile} |
| 76 | config_shell=${CONFIG_SHELL-/bin/sh} |
| 77 | arguments="${ac_configure_args}" |
| 78 | else |
| 79 | Makefile=${Makefile-Makefile} |
| 80 | config_shell=${config_shell-/bin/sh} |
| 81 | fi |
| 82 | |
| 83 | # Scan all the arguments and set all the ones we need. |
| 84 | |
| 85 | for option in $arguments |
| 86 | do |
| 87 | case $option in |
| 88 | --*) ;; |
| 89 | -*) option=-$option ;; |
| 90 | esac |
| 91 | |
| 92 | case $option in |
| 93 | --*=*) |
| 94 | optarg=`echo $option | sed -e 's/^[^=]*=//'` |
| 95 | ;; |
| 96 | esac |
| 97 | |
| 98 | case $option in |
| 99 | --disable-*) |
| 100 | enableopt=`echo ${option} | sed 's:^--disable-:enable_:;s:-:_:g'` |
| 101 | eval $enableopt=no |
| 102 | ;; |
| 103 | --enable-*) |
| 104 | case "$option" in |
| 105 | *=*) ;; |
| 106 | *) optarg=yes ;; |
| 107 | esac |
| 108 | enableopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'` |
| 109 | eval $enableopt="$optarg" |
| 110 | ;; |
| 111 | --norecursion | --no*) |
| 112 | norecursion=yes |
| 113 | ;; |
| 114 | --verbose | --v | --verb*) |
| 115 | verbose=--verbose |
| 116 | ;; |
| 117 | --with-*) |
| 118 | case "$option" in |
| 119 | *=*) ;; |
| 120 | *) optarg=yes ;; |
| 121 | esac |
| 122 | withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'` |
| 123 | eval $withopt="$optarg" |
| 124 | ;; |
| 125 | --without-*) |
| 126 | withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'` |
| 127 | eval $withopt=no |
| 128 | ;; |
| 129 | esac |
| 130 | done |
| 131 | |
| 132 | # Only do this if --enable-multilib. |
| 133 | if [ "${enable_multilib}" = yes ]; then |
| 134 | |
| 135 | # Compute whether this is the library's top level directory |
| 136 | # (ie: not a multilib subdirectory, and not a subdirectory like libg++/src). |
| 137 | # ${with_multisubdir} tells us we're in the right branch, but we could be |
| 138 | # in a subdir of that. |
| 139 | # ??? The previous version could void this test by separating the process into |
| 140 | # two files: one that only the library's toplevel configure.in ran (to |
| 141 | # configure the multilib subdirs), and another that all configure.in's ran to |
| 142 | # update the Makefile. It seemed reasonable to collapse all multilib support |
| 143 | # into one file, but it does leave us with having to perform this test. |
| 144 | ml_toplevel_p=no |
| 145 | if [ -z "${with_multisubdir}" ]; then |
| 146 | if [ "${srcdir}" = "." ]; then |
| 147 | # ${with_target_subdir} = "." for native, otherwise target alias. |
| 148 | if [ "${with_target_subdir}" = "." ]; then |
| 149 | if [ -f ../config-ml.in ]; then |
| 150 | ml_toplevel_p=yes |
| 151 | fi |
| 152 | else |
| 153 | if [ -f ../../config-ml.in ]; then |
| 154 | ml_toplevel_p=yes |
| 155 | fi |
| 156 | fi |
| 157 | else |
| 158 | if [ -f ${srcdir}/../config-ml.in ]; then |
| 159 | ml_toplevel_p=yes |
| 160 | fi |
| 161 | fi |
| 162 | fi |
| 163 | |
| 164 | # If this is the library's top level directory, set multidirs to the |
| 165 | # multilib subdirs to support. This lives at the top because we need |
| 166 | # `multidirs' set right away, and this section is subject to frequent |
| 167 | # editing (addition of new targets, etc.). |
| 168 | |
| 169 | if [ "${ml_toplevel_p}" = yes ]; then |
| 170 | |
| 171 | case "${target}" in |
| 172 | # start-sanitize-arc |
| 173 | arc-sbp-elf*) |
| 174 | if [ x$enable_biendian = xyes ] |
| 175 | then |
| 176 | multidirs="be host graphics audio be/host be/graphics be/audio" |
| 177 | else |
| 178 | multidirs="host graphics audio" |
| 179 | fi |
| 180 | ;; |
| 181 | arc-*-*) |
| 182 | multidirs="be" |
| 183 | ;; |
| 184 | # end-sanitize-arc |
| 185 | hppa*-*-*) |
| 186 | multidirs="soft-float" |
| 187 | ;; |
| 188 | #m68*-*-aout* | m68*-*-coff* | m68*-*-elf* | m68*-*-vxworks*) |
| 189 | # multidirs="m68000 m68020 m68881 msoft-float m68000/m68881 m68000/msoft-float m68020/m68881 m68020/msoft-float" |
| 190 | # ;; |
| 191 | m68*-*-aout* | m68*-*-coff* | m68*-*-elf* | m68*-*-vxworks*) |
| 192 | multidirs="m68000 m68000/m68881" |
| 193 | ;; |
| 194 | i960-*-*) |
| 195 | multidirs=float |
| 196 | ;; |
| 197 | sparclite-*-* | sparclitefrw*-*-*) |
| 198 | multidirs="mfpu msoft-float mflat mno-flat mfpu/mflat mfpu/mno-flat msoft-float/mflat msoft-float/mno-flat" |
| 199 | ;; |
| 200 | sparc-*-* | sparcfrw*-*-*) |
| 201 | multidirs="soft v8 soft/v8" |
| 202 | ;; |
| 203 | z8k-*-coff) |
| 204 | multidirs="z8001 std z8001/std" |
| 205 | ;; |
| 206 | h8300-*-*) |
| 207 | multidirs=h8300h |
| 208 | ;; |
| 209 | h8500-*-*) |
| 210 | multidirs="mbig msmall mcompact mmedium" |
| 211 | ;; |
| 212 | # start-sanitize-jaguar |
| 213 | jaguar-*-*) |
| 214 | multidirs="be" |
| 215 | ;; |
| 216 | # end-sanitize-jaguar |
| 217 | sh-*-*) |
| 218 | multidirs="ml m2 ml/m2" |
| 219 | # start-sanitize-sh3e |
| 220 | multidirs="ml m2 ml/m2 m3e ml/m3e" |
| 221 | # end-sanitize-sh3e |
| 222 | ;; |
| 223 | mips*-*-*) |
| 224 | # Note that not all of these will be built for a particular |
| 225 | # target; what is build depends upon the output gcc |
| 226 | # --print-multi-lib. We configure them all, to make our life |
| 227 | # simpler here. If somebody cares about configuration |
| 228 | # efficiency, they will need to switch off on the various |
| 229 | # targets to configure just the directories needed for that |
| 230 | # target. |
| 231 | # |
| 232 | # In the long run, it would be better to configure based on |
| 233 | # the output of gcc --print-multi-lib, but, to do that, we |
| 234 | # would have to build gcc before configuring newlib. |
| 235 | # |
| 236 | # Default to including the single-float directories. |
| 237 | if [ x$enable_single_float = x ]; then |
| 238 | enable_single_float=yes |
| 239 | fi |
| 240 | if [ x$enable_single_float = xyes ]; then |
| 241 | multidirs="soft-float single el eb mips1 mips3 soft-float/el soft-float/eb soft-float/mips1 soft-float/mips3 soft-float/el/mips1 soft-float/el/mips3 soft-float/eb/mips1 soft-float/eb/mips3 single/el single/eb single/mips1 single/mips3 single/el/mips1 single/el/mips3 single/eb/mips1 single/eb/mips3 el/mips1 el/mips3 eb/mips1 eb/mips3" |
| 242 | else |
| 243 | multidirs="soft-float el eb mips1 mips3 soft-float/el soft-float/eb soft-float/mips1 soft-float/mips3 soft-float/el/mips1 soft-float/el/mips3 soft-float/eb/mips1 soft-float/eb/mips3 el/mips1 el/mips3 eb/mips1 eb/mips3" |
| 244 | fi |
| 245 | if [ x$enable_biendian = xno ] |
| 246 | then |
| 247 | old_multidirs="${multidirs}" |
| 248 | multidirs="" |
| 249 | for x in ${old_multidirs}; do |
| 250 | case "$x" in |
| 251 | *endian* ) : ;; |
| 252 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 253 | esac |
| 254 | done |
| 255 | fi |
| 256 | if [ x$enable_softfloat = xno ] |
| 257 | then |
| 258 | old_multidirs="${multidirs}" |
| 259 | multidirs="" |
| 260 | for x in ${old_multidirs}; do |
| 261 | case "$x" in |
| 262 | *soft-float* ) : ;; |
| 263 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 264 | esac |
| 265 | done |
| 266 | fi |
| 267 | if [ x$enable_relocatable = xno ] |
| 268 | then |
| 269 | old_multidirs="${multidirs}" |
| 270 | multidirs="" |
| 271 | for x in ${old_multidirs}; do |
| 272 | case "$x" in |
| 273 | *relocatable* ) : ;; |
| 274 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 275 | esac |
| 276 | done |
| 277 | fi |
| 278 | if [ x$enable_sysv = xno ] |
| 279 | then |
| 280 | old_multidirs="${multidirs}" |
| 281 | multidirs="" |
| 282 | for x in ${old_multidirs}; do |
| 283 | case "$x" in |
| 284 | *sysv* ) : ;; |
| 285 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 286 | esac |
| 287 | done |
| 288 | fi |
| 289 | ;; |
| 290 | powerpc-ibm-aix* | rs6000-ibm-aix*) |
| 291 | multidirs="soft-float common soft-float/common" |
| 292 | if [ x$enable_softfloat = xno ] |
| 293 | then |
| 294 | old_multidirs="${multidirs}" |
| 295 | multidirs="" |
| 296 | for x in ${old_multidirs}; do |
| 297 | case "$x" in |
| 298 | *soft-float* ) : ;; |
| 299 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 300 | esac |
| 301 | done |
| 302 | fi |
| 303 | if [ x$enable_commoncpu = xno ] |
| 304 | then |
| 305 | old_multidirs="${multidirs}" |
| 306 | multidirs="" |
| 307 | for x in ${old_multidirs}; do |
| 308 | case "$x" in |
| 309 | *common* ) : ;; |
| 310 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 311 | esac |
| 312 | done |
| 313 | fi |
| 314 | ;; |
| 315 | powerpc-*-eabiaix*) |
| 316 | multidirs="soft-float relocatable little sysv little/sysv relocatable/little relocatable/sysv relocatable/little/sysv soft-float/relocatable soft-float/little soft-float/sysv soft-float/little/sysv soft-float/relocatable/little soft-float/relocatable/sysv soft-float/relocatable/little/sysv" |
| 317 | if [ x$enable_biendian = xno ] |
| 318 | then |
| 319 | old_multidirs="${multidirs}" |
| 320 | multidirs="" |
| 321 | for x in ${old_multidirs}; do |
| 322 | case "$x" in |
| 323 | *endian* ) : ;; |
| 324 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 325 | esac |
| 326 | done |
| 327 | fi |
| 328 | if [ x$enable_softfloat = xno ] |
| 329 | then |
| 330 | old_multidirs="${multidirs}" |
| 331 | multidirs="" |
| 332 | for x in ${old_multidirs}; do |
| 333 | case "$x" in |
| 334 | *soft-float* ) : ;; |
| 335 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 336 | esac |
| 337 | done |
| 338 | fi |
| 339 | if [ x$enable_relocatable = xno ] |
| 340 | then |
| 341 | old_multidirs="${multidirs}" |
| 342 | multidirs="" |
| 343 | for x in ${old_multidirs}; do |
| 344 | case "$x" in |
| 345 | *relocatable* ) : ;; |
| 346 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 347 | esac |
| 348 | done |
| 349 | fi |
| 350 | if [ x$enable_sysv = xno ] |
| 351 | then |
| 352 | old_multidirs="${multidirs}" |
| 353 | multidirs="" |
| 354 | for x in ${old_multidirs}; do |
| 355 | case "$x" in |
| 356 | *sysv* ) : ;; |
| 357 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 358 | esac |
| 359 | done |
| 360 | fi |
| 361 | ;; |
| 362 | powerpc-*-eabi* | powerpc-*-elf* | powerpc-*-sysv4*) |
| 363 | multidirs="soft-float relocatable little aix little/aix relocatable/little relocatable/aix relocatable/little/aix soft-float/relocatable soft-float/little soft-float/aix soft-float/little/aix soft-float/relocatable/little soft-float/relocatable/aix soft-float/relocatable/little/aix aixdesc soft-float/aixdesc" |
| 364 | if [ x$enable_biendian = xno ] |
| 365 | then |
| 366 | old_multidirs="${multidirs}" |
| 367 | multidirs="" |
| 368 | for x in ${old_multidirs}; do |
| 369 | case "$x" in |
| 370 | *endian* ) : ;; |
| 371 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 372 | esac |
| 373 | done |
| 374 | fi |
| 375 | if [ x$enable_softfloat = xno ] |
| 376 | then |
| 377 | old_multidirs="${multidirs}" |
| 378 | multidirs="" |
| 379 | for x in ${old_multidirs}; do |
| 380 | case "$x" in |
| 381 | *soft-float* ) : ;; |
| 382 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 383 | esac |
| 384 | done |
| 385 | fi |
| 386 | if [ x$enable_relocatable = xno ] |
| 387 | then |
| 388 | old_multidirs="${multidirs}" |
| 389 | multidirs="" |
| 390 | for x in ${old_multidirs}; do |
| 391 | case "$x" in |
| 392 | *relocatable* ) : ;; |
| 393 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 394 | esac |
| 395 | done |
| 396 | fi |
| 397 | if [ x$enable_aix = xno ] |
| 398 | then |
| 399 | old_multidirs="${multidirs}" |
| 400 | multidirs="" |
| 401 | for x in ${old_multidirs}; do |
| 402 | case "$x" in |
| 403 | *aix* ) : ;; |
| 404 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 405 | esac |
| 406 | done |
| 407 | fi |
| 408 | ;; |
| 409 | powerpcle-*-eabi* | powerpcle-*-elf* | powerpcle-*-sysv4*) |
| 410 | multidirs="soft-float relocatable big aix big/aix relocatable/big relocatable/aix relocatable/big/aix soft-float/relocatable soft-float/big soft-float/aix soft-float/big/aix soft-float/relocatable/big soft-float/relocatable/aix soft-float/relocatable/big/aix" |
| 411 | if [ x$enable_biendian = xno ] |
| 412 | then |
| 413 | old_multidirs="${multidirs}" |
| 414 | multidirs="" |
| 415 | for x in ${old_multidirs}; do |
| 416 | case "$x" in |
| 417 | *endian* ) : ;; |
| 418 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 419 | esac |
| 420 | done |
| 421 | fi |
| 422 | if [ x$enable_softfloat = xno ] |
| 423 | then |
| 424 | old_multidirs="${multidirs}" |
| 425 | multidirs="" |
| 426 | for x in ${old_multidirs}; do |
| 427 | case "$x" in |
| 428 | *soft-float* ) : ;; |
| 429 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 430 | esac |
| 431 | done |
| 432 | fi |
| 433 | if [ x$enable_relocatable = xno ] |
| 434 | then |
| 435 | old_multidirs="${multidirs}" |
| 436 | multidirs="" |
| 437 | for x in ${old_multidirs}; do |
| 438 | case "$x" in |
| 439 | *relocatable* ) : ;; |
| 440 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 441 | esac |
| 442 | done |
| 443 | fi |
| 444 | if [ x$enable_aix = xno ] |
| 445 | then |
| 446 | old_multidirs="${multidirs}" |
| 447 | multidirs="" |
| 448 | for x in ${old_multidirs}; do |
| 449 | case "$x" in |
| 450 | *aix* ) : ;; |
| 451 | *) if [ x"$multidirs" = x ]; then multidirs="$x"; else multidirs="${multidirs} ${x}"; fi ;; |
| 452 | esac |
| 453 | done |
| 454 | fi |
| 455 | ;; |
| 456 | *) |
| 457 | multidirs= |
| 458 | ;; |
| 459 | esac |
| 460 | |
| 461 | # Add code to library's top level makefile to handle building the multilib |
| 462 | # subdirs. |
| 463 | |
| 464 | cat > Multi.tem <<\EOF |
| 465 | |
| 466 | # FIXME: There should be an @-sign in front of the `if'. |
| 467 | # Leave out until this is tested a bit more. |
| 468 | multi-do: |
| 469 | if [ -z "$(MULTIDIRS)" ]; then \ |
| 470 | true; \ |
| 471 | else \ |
| 472 | rootpre=`pwd`/; export rootpre; \ |
| 473 | srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \ |
| 474 | lib=`echo $${rootpre} | sed -e 's,^.*/\([^/][^/]*\)/$$,\1,'`; \ |
| 475 | compiler="$(CC)"; \ |
| 476 | for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \ |
| 477 | dir=`echo $$i | sed -e 's/;.*$$//'`; \ |
| 478 | if [ "$${dir}" = "." ]; then \ |
| 479 | true; \ |
| 480 | else \ |
| 481 | if [ -d ../$${dir}/$${lib} ]; then \ |
| 482 | flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \ |
| 483 | if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) \ |
| 484 | CFLAGS="$(CFLAGS) $${flags}" \ |
| 485 | CXXFLAGS="$(CXXFLAGS) $${flags}" \ |
| 486 | LIBCFLAGS="$(LIBCFLAGS) $${flags}" \ |
| 487 | LIBCXXFLAGS="$(LIBCXXFLAGS) $${flags}" \ |
| 488 | $(DO)); then \ |
| 489 | true; \ |
| 490 | else \ |
| 491 | exit 1; \ |
| 492 | fi; \ |
| 493 | else true; \ |
| 494 | fi; \ |
| 495 | fi; \ |
| 496 | done; \ |
| 497 | fi |
| 498 | |
| 499 | # FIXME: There should be an @-sign in front of the `if'. |
| 500 | # Leave out until this is tested a bit more. |
| 501 | multi-clean: |
| 502 | if [ -z "$(MULTIDIRS)" ]; then \ |
| 503 | true; \ |
| 504 | else \ |
| 505 | lib=`pwd | sed -e 's,^.*/\([^/][^/]*\)/$$,\1,'`; \ |
| 506 | for dir in Makefile $(MULTIDIRS); do \ |
| 507 | if [ -f ../$${dir}/$${lib}/Makefile ]; then \ |
| 508 | if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \ |
| 509 | then true; \ |
| 510 | else exit 1; \ |
| 511 | fi; \ |
| 512 | else true; \ |
| 513 | fi; \ |
| 514 | done; \ |
| 515 | fi |
| 516 | EOF |
| 517 | |
| 518 | cat ${Makefile} Multi.tem > Makefile.tem |
| 519 | rm -f ${Makefile} Multi.tem |
| 520 | mv Makefile.tem ${Makefile} |
| 521 | |
| 522 | fi # ${ml_toplevel_p} = yes |
| 523 | |
| 524 | if [ "${verbose}" = --verbose ]; then |
| 525 | echo "Adding multilib support to Makefile in `pwd`" |
| 526 | if [ "${ml_toplevel_p}" = yes ]; then |
| 527 | echo "multidirs=${multidirs}" |
| 528 | fi |
| 529 | echo "with_multisubdir=${with_multisubdir}" |
| 530 | fi |
| 531 | |
| 532 | if [ "${srcdir}" = "." ]; then |
| 533 | if [ "${with_target_subdir}" != "." ]; then |
| 534 | ml_srcdotdot="../" |
| 535 | else |
| 536 | ml_srcdotdot="" |
| 537 | fi |
| 538 | else |
| 539 | ml_srcdotdot="" |
| 540 | fi |
| 541 | |
| 542 | if [ -z "${with_multisubdir}" ]; then |
| 543 | ml_subdir= |
| 544 | ml_builddotdot= |
| 545 | : # ml_srcdotdot= # already set |
| 546 | else |
| 547 | ml_subdir="/${with_multisubdir}" |
| 548 | # The '[^/][^/]*' appears that way to work around a SunOS sed bug. |
| 549 | ml_builddotdot=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`/ |
| 550 | if [ "$srcdir" = "." ]; then |
| 551 | ml_srcdotdot=${ml_srcdotdot}${ml_builddotdot} |
| 552 | else |
| 553 | : # ml_srcdotdot= # already set |
| 554 | fi |
| 555 | fi |
| 556 | |
| 557 | if [ "${ml_toplevel_p}" = yes ]; then |
| 558 | ml_do='$(MAKE)' |
| 559 | ml_clean='$(MAKE)' |
| 560 | else |
| 561 | ml_do=true |
| 562 | ml_clean=true |
| 563 | fi |
| 564 | |
| 565 | # TOP is used by newlib and should not be used elsewhere for this purpose. |
| 566 | # MULTI{SRC,BUILD}TOP are the proper ones to use. MULTISRCTOP is empty |
| 567 | # when srcdir != builddir. MULTIBUILDTOP is always some number of ../'s. |
| 568 | # FIXME: newlib needs to be updated to use MULTI{SRC,BUILD}TOP so we can |
| 569 | # delete TOP. Newlib may wish to continue to use TOP for its own purposes |
| 570 | # of course. |
| 571 | # MULTIDIRS is non-empty for the cpu top level Makefile (eg: newlib/Makefile) |
| 572 | # and lists the subdirectories to recurse into. |
| 573 | # MULTISUBDIR is non-empty in each cpu subdirectory's Makefile |
| 574 | # (eg: newlib/h8300h/Makefile) and is the installed subdirectory name with |
| 575 | # a leading '/'. |
| 576 | # MULTIDO is used for targets like all, install, and check where |
| 577 | # $(FLAGS_TO_PASS) augmented with the subdir's compiler option is needed. |
| 578 | # MULTICLEAN is used for the *clean targets. |
| 579 | # |
| 580 | # ??? It is possible to merge MULTIDO and MULTICLEAN into one. They are |
| 581 | # currently kept separate because we don't want the *clean targets to require |
| 582 | # the existence of the compiler (which MULTIDO currently requires) and |
| 583 | # therefore we'd have to record the directory options as well as names |
| 584 | # (currently we just record the names and use --print-multi-lib to get the |
| 585 | # options). |
| 586 | |
| 587 | sed -e "s:^TOP[ ]*=[ ]*\([./]*\)[ ]*$:TOP = ${ml_builddotdot}\1:" \ |
| 588 | -e "s:^MULTISRCTOP[ ]*=.*$:MULTISRCTOP = ${ml_srcdotdot}:" \ |
| 589 | -e "s:^MULTIBUILDTOP[ ]*=.*$:MULTIBUILDTOP = ${ml_builddotdot}:" \ |
| 590 | -e "s:^MULTIDIRS[ ]*=.*$:MULTIDIRS = ${multidirs}:" \ |
| 591 | -e "s:^MULTISUBDIR[ ]*=.*$:MULTISUBDIR = ${ml_subdir}:" \ |
| 592 | -e "s:^MULTIDO[ ]*=.*$:MULTIDO = $ml_do:" \ |
| 593 | -e "s:^MULTICLEAN[ ]*=.*$:MULTICLEAN = $ml_clean:" \ |
| 594 | ${Makefile} > Makefile.tem |
| 595 | rm -f ${Makefile} |
| 596 | mv Makefile.tem ${Makefile} |
| 597 | |
| 598 | # If this is the library's top level, configure each multilib subdir. |
| 599 | # This is done at the end because this is the loop that runs configure |
| 600 | # in each multilib subdir and it seemed reasonable to finish updating the |
| 601 | # Makefile before going on to configure the subdirs. |
| 602 | |
| 603 | if [ "${ml_toplevel_p}" = yes ]; then |
| 604 | |
| 605 | # We must freshly configure each subdirectory. This bit of code is |
| 606 | # actually partially stolen from the main configure script. FIXME. |
| 607 | |
| 608 | if [ -n "${multidirs}" ] && [ -z "${norecursion}" ]; then |
| 609 | |
| 610 | if [ "${verbose}" = --verbose ]; then |
| 611 | echo "Running configure in multilib subdirs ${multidirs}" |
| 612 | echo "pwd: `pwd`" |
| 613 | fi |
| 614 | |
| 615 | ml_origdir=`pwd` |
| 616 | ml_libdir=`echo $ml_origdir | sed -e 's,^.*/,,'` |
| 617 | # cd to top-level-build-dir/${with_target_subdir} |
| 618 | cd .. |
| 619 | |
| 620 | for dir in ${multidirs}; do |
| 621 | |
| 622 | if [ "${verbose}" = --verbose ]; then |
| 623 | echo "Running configure in multilib subdir ${dir}" |
| 624 | echo "pwd: `pwd`" |
| 625 | fi |
| 626 | |
| 627 | if [ -d ${dir} ]; then true; else mkdir ${dir}; fi |
| 628 | if [ -d ${dir}/${ml_libdir} ]; then true; else mkdir ${dir}/${ml_libdir}; fi |
| 629 | |
| 630 | # Eg: if ${dir} = m68000/m68881, dotdot = ../../ |
| 631 | dotdot=../`echo ${dir} | sed -e 's|[^/]||g' -e 's|/|../|g'` |
| 632 | |
| 633 | case ${srcdir} in |
| 634 | ".") |
| 635 | echo Building symlink tree in `pwd`/${dir}/${ml_libdir} |
| 636 | if [ "${with_target_subdir}" != "." ]; then |
| 637 | ml_unsubdir="../" |
| 638 | else |
| 639 | ml_unsubdir="" |
| 640 | fi |
| 641 | (cd ${dir}/${ml_libdir}; |
| 642 | ../${dotdot}${ml_unsubdir}symlink-tree ../${dotdot}${ml_unsubdir}${ml_libdir} "") |
| 643 | newsrcdir="." |
| 644 | srcdiroption= |
| 645 | multisrctop=${dotdot} |
| 646 | ;; |
| 647 | *) |
| 648 | case "${srcdir}" in |
| 649 | /*) # absolute path |
| 650 | newsrcdir=${srcdir} |
| 651 | ;; |
| 652 | *) # otherwise relative |
| 653 | newsrcdir=${dotdot}${srcdir} |
| 654 | ;; |
| 655 | esac |
| 656 | srcdiroption="-srcdir=${newsrcdir}" |
| 657 | multisrctop= |
| 658 | ;; |
| 659 | esac |
| 660 | |
| 661 | case "${progname}" in |
| 662 | /*) recprog=${progname} ;; |
| 663 | *) recprog=${dotdot}${progname} ;; |
| 664 | esac |
| 665 | |
| 666 | # FIXME: POPDIR=${PWD=`pwd`} doesn't work here. |
| 667 | ML_POPDIR=`pwd` |
| 668 | cd ${dir}/${ml_libdir} |
| 669 | |
| 670 | if [ -f ${newsrcdir}/configure ]; then |
| 671 | recprog=${newsrcdir}/configure |
| 672 | fi |
| 673 | if eval ${config_shell} -x ${recprog} \ |
| 674 | --with-multisubdir=${dir} --with-multisrctop=${multisrctop} \ |
| 675 | $arguments ${srcdiroption} ; then |
| 676 | true |
| 677 | else |
| 678 | exit 1 |
| 679 | fi |
| 680 | |
| 681 | cd ${ML_POPDIR} |
| 682 | |
| 683 | done |
| 684 | |
| 685 | cd ${ml_origdir} |
| 686 | fi |
| 687 | |
| 688 | fi # ${ml_toplevel_p} = yes |
| 689 | fi # ${enable_multilib} = yes |