1#!/bin/sh 2 3# 4# config.rpath - get linker flags 5# 6# Written by 7# Marco van den Heuvel <blackystardust68@yahoo.com> 8# 9# This file is part of VICE, the Versatile Commodore Emulator. 10# See README for copyright notice. 11# 12# This program is free software; you can redistribute it and/or modify 13# it under the terms of the GNU General Public License as published by 14# the Free Software Foundation; either version 2 of the License, or 15# (at your option) any later version. 16# 17# This program is distributed in the hope that it will be useful, 18# but WITHOUT ANY WARRANTY; without even the implied warranty of 19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20# GNU General Public License for more details. 21# 22# You should have received a copy of the GNU General Public License 23# along with this program; if not, write to the Free Software 24# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 25# 02111-1307 USA. 26# 27# Usage: config.rpath <CC> <GCC> <LDFLAGS> <LD> <with_gnu_ld> <host> <VICELIBDIR> 28# $1 $2 $3 $4 $5 $6 $7 29# 30 31CC="$1" 32GCC="$2" 33LDFLAGS="$3" 34LD="$4" 35with_gnu_ld="$5" 36host="$6" 37VICELIBDIR="$7" 38 39libext=a 40shrext=.so 41 42host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` 43host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` 44host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` 45 46# Code taken from libtool.m4's _LT_CC_BASENAME. 47 48for cc_temp in $CC""; do 49 case $cc_temp in 50 compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; 51 distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; 52 \-*) ;; 53 *) break;; 54 esac 55done 56cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` 57 58# Code taken from libtool.m4's _LT_COMPILER_PIC. 59 60wl= 61if test "$GCC" = yes; then 62 wl='-Wl,' 63else 64 case "$host_os" in 65 aix*) 66 wl='-Wl,' 67 ;; 68 mingw* | cygwin* | pw32* | os2* | cegcc*) 69 ;; 70 hpux9* | hpux10* | hpux11*) 71 wl='-Wl,' 72 ;; 73 irix5* | irix6* | nonstopux*) 74 wl='-Wl,' 75 ;; 76 linux* | k*bsd*-gnu | kopensolaris*-gnu) 77 case $cc_basename in 78 ecc*) 79 wl='-Wl,' 80 ;; 81 icc* | ifort*) 82 wl='-Wl,' 83 ;; 84 lf95*) 85 wl='-Wl,' 86 ;; 87 nagfor*) 88 wl='-Wl,-Wl,,' 89 ;; 90 pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) 91 wl='-Wl,' 92 ;; 93 ccc*) 94 wl='-Wl,' 95 ;; 96 xl* | bgxl* | bgf* | mpixl*) 97 wl='-Wl,' 98 ;; 99 como) 100 wl='-lopt=' 101 ;; 102 *) 103 case `$CC -V 2>&1 | sed 5q` in 104 *Sun\ F* | *Sun*Fortran*) 105 wl= 106 ;; 107 *Sun\ C*) 108 wl='-Wl,' 109 ;; 110 esac 111 ;; 112 esac 113 ;; 114 newsos6) 115 ;; 116 *nto* | *qnx*) 117 ;; 118 osf3* | osf4* | osf5*) 119 wl='-Wl,' 120 ;; 121 rdos*) 122 ;; 123 solaris*) 124 case $cc_basename in 125 f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) 126 wl='-Qoption ld ' 127 ;; 128 *) 129 wl='-Wl,' 130 ;; 131 esac 132 ;; 133 sunos4*) 134 wl='-Qoption ld ' 135 ;; 136 sysv4 | sysv4.2uw2* | sysv4.3*) 137 wl='-Wl,' 138 ;; 139 sysv4*MP*) 140 ;; 141 sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) 142 wl='-Wl,' 143 ;; 144 unicos*) 145 wl='-Wl,' 146 ;; 147 uts4*) 148 ;; 149 esac 150fi 151 152# Code taken from libtool.m4's _LT_LINKER_SHLIBS. 153 154hardcode_libdir_flag_spec= 155hardcode_libdir_separator= 156hardcode_direct=no 157hardcode_minus_L=no 158 159case "$host_os" in 160 cygwin* | mingw* | pw32* | cegcc*) 161 # FIXME: the MSVC++ port hasn't been tested in a loooong time 162 # When not using gcc, we currently assume that we are using 163 # Microsoft Visual C++. 164 if test "$GCC" != yes; then 165 with_gnu_ld=no 166 fi 167 ;; 168 interix*) 169 # we just hope/assume this is gcc and not c89 (= MSVC++) 170 with_gnu_ld=yes 171 ;; 172 openbsd*) 173 with_gnu_ld=no 174 ;; 175esac 176 177ld_shlibs=yes 178if test "$with_gnu_ld" = yes; then 179 # Set some defaults for GNU ld with shared library support. These 180 # are reset later if shared libraries are not supported. Putting them 181 # here allows them to be overridden if necessary. 182 # Unlike libtool, we use -rpath here, not --rpath, since the documented 183 # option of GNU ld is called -rpath, not --rpath. 184 hardcode_libdir_flag_spec="$wl-rpath $wl$VICELIBDIR" 185 case "$host_os" in 186 aix[3-9]*) 187 # On AIX/PPC, the GNU linker is very broken 188 if test "$host_cpu" != ia64; then 189 ld_shlibs=no 190 fi 191 ;; 192 amigaos*) 193 case "$host_cpu" in 194 powerpc) 195 ;; 196 m68k) 197 hardcode_libdir_flag_spec="-L$VICELIBDIR" 198 hardcode_minus_L=yes 199 ;; 200 esac 201 ;; 202 beos*) 203 if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then 204 : 205 else 206 ld_shlibs=no 207 fi 208 ;; 209 cygwin* | mingw* | pw32* | cegcc*) 210 # hardcode_libdir_flag_spec is actually meaningless, as there is 211 # no search path for DLLs. 212 hardcode_libdir_flag_spec="-L$VICELIBDIR" 213 if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then 214 : 215 else 216 ld_shlibs=no 217 fi 218 ;; 219 haiku*) 220 ;; 221 interix[3-9]*) 222 hardcode_direct=no 223 hardcode_libdir_flag_spec="${wl}-rpath,$VICELIBDIR" 224 ;; 225 gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) 226 if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then 227 : 228 else 229 ld_shlibs=no 230 fi 231 ;; 232 netbsd*) 233 ;; 234 solaris*) 235 if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then 236 ld_shlibs=no 237 elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then 238 : 239 else 240 ld_shlibs=no 241 fi 242 ;; 243 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) 244 case `$LD -v 2>&1` in 245 *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) 246 ld_shlibs=no 247 ;; 248 *) 249 if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then 250 hardcode_libdir_flag_spec=`test -z '$SCOABSPATH' && echo "${wl}-rpath,$VICELIBDIR"` 251 else 252 ld_shlibs=no 253 fi 254 ;; 255 esac 256 ;; 257 sunos4*) 258 hardcode_direct=yes 259 ;; 260 *) 261 if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then 262 : 263 else 264 ld_shlibs=no 265 fi 266 ;; 267 esac 268 if test "$ld_shlibs" = no; then 269 hardcode_libdir_flag_spec= 270 fi 271else 272 case "$host_os" in 273 aix3*) 274 # Note: this linker hardcodes the directories in LIBPATH if there 275 # are no directories specified by -L. 276 hardcode_minus_L=yes 277 if test "$GCC" = yes; then 278 # Neither direct hardcoding nor static linking is supported with a 279 # broken collect2. 280 hardcode_direct=unsupported 281 fi 282 ;; 283 aix[4-9]*) 284 if test "$host_cpu" = ia64; then 285 # On IA64, the linker does run time linking by default, so we don't 286 # have to do anything special. 287 aix_use_runtimelinking=no 288 else 289 aix_use_runtimelinking=no 290 # Test if we are trying to use run time linking or normal 291 # AIX style linking. If -brtl is somewhere in LDFLAGS, we 292 # need to do runtime linking. 293 case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) 294 for ld_flag in $LDFLAGS; do 295 if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then 296 aix_use_runtimelinking=yes 297 break 298 fi 299 done 300 ;; 301 esac 302 fi 303 hardcode_direct=yes 304 hardcode_libdir_separator=':' 305 if test "$GCC" = yes; then 306 case $host_os in aix4.[012]|aix4.[012].*) 307 collect2name=`${CC} -print-prog-name=collect2` 308 if test -f "$collect2name" && \ 309 strings "$collect2name" | grep resolve_lib_name >/dev/null 310 then 311 # We have reworked collect2 312 : 313 else 314 # We have old collect2 315 hardcode_direct=unsupported 316 hardcode_minus_L=yes 317 hardcode_libdir_flag_spec="-L$VICELIBDIR" 318 hardcode_libdir_separator= 319 fi 320 ;; 321 esac 322 fi 323 # Begin _LT_AC_SYS_LIBPATH_AIX. 324 echo 'int main () { return 0; }' > conftest.c 325 ${CC} ${LDFLAGS} conftest.c -o conftest 326 aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } 327}'` 328 if test -z "$aix_libpath"; then 329 aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } 330}'` 331 fi 332 if test -z "$aix_libpath"; then 333 aix_libpath="/usr/lib:/lib" 334 fi 335 rm -f conftest.c conftest 336 # End _LT_AC_SYS_LIBPATH_AIX. 337 if test "$aix_use_runtimelinking" = yes; then 338 hardcode_libdir_flag_spec="${wl}-blibpath:$VICELIBDIR:$aix_libpath" 339 else 340 if test "$host_cpu" = ia64; then 341 hardcode_libdir_flag_spec="${wl}-R $VICELIBDIR:/usr/lib:/lib" 342 else 343 hardcode_libdir_flag_spec="${wl}-blibpath:$VICELIBDIR:$aix_libpath" 344 fi 345 fi 346 ;; 347 amigaos*) 348 case "$host_cpu" in 349 powerpc) 350 ;; 351 m68k) 352 hardcode_libdir_flag_spec="-L$VICELIBDIR" 353 hardcode_minus_L=yes 354 ;; 355 esac 356 ;; 357 bsdi[45]*) 358 ;; 359 cygwin* | mingw* | pw32* | cegcc*) 360 # When not using gcc, we currently assume that we are using 361 # Microsoft Visual C++. 362 # hardcode_libdir_flag_spec is actually meaningless, as there is 363 # no search path for DLLs. 364 hardcode_libdir_flag_spec=' ' 365 libext=lib 366 ;; 367 darwin* | rhapsody*) 368 hardcode_direct=no 369 if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then 370 : 371 else 372 ld_shlibs=no 373 fi 374 ;; 375 dgux*) 376 hardcode_libdir_flag_spec="-L$VICELIBDIR" 377 ;; 378 freebsd2.2*) 379 hardcode_libdir_flag_spec="-R$VICELIBDIR" 380 hardcode_direct=yes 381 ;; 382 freebsd2*) 383 hardcode_direct=yes 384 hardcode_minus_L=yes 385 ;; 386 freebsd* | dragonfly*) 387 hardcode_libdir_flag_spec="-R$VICELIBDIR" 388 hardcode_direct=yes 389 ;; 390 hpux9*) 391 hardcode_libdir_flag_spec="${wl}+b ${wl}$VICELIBDIR" 392 hardcode_libdir_separator=: 393 hardcode_direct=yes 394 # hardcode_minus_L: Not really in the search PATH, 395 # but as the default location of the library. 396 hardcode_minus_L=yes 397 ;; 398 hpux10*) 399 if test "$with_gnu_ld" = no; then 400 hardcode_libdir_flag_spec="${wl}+b ${wl}$VICELIBDIR" 401 hardcode_libdir_separator=: 402 hardcode_direct=yes 403 # hardcode_minus_L: Not really in the search PATH, 404 # but as the default location of the library. 405 hardcode_minus_L=yes 406 fi 407 ;; 408 hpux11*) 409 if test "$with_gnu_ld" = no; then 410 hardcode_libdir_flag_spec="${wl}+b ${wl}$VICELIBDIR" 411 hardcode_libdir_separator=: 412 case $host_cpu in 413 hppa*64*|ia64*) 414 hardcode_direct=no 415 ;; 416 *) 417 hardcode_direct=yes 418 # hardcode_minus_L: Not really in the search PATH, 419 # but as the default location of the library. 420 hardcode_minus_L=yes 421 ;; 422 esac 423 fi 424 ;; 425 irix5* | irix6* | nonstopux*) 426 hardcode_libdir_flag_spec="${wl}-rpath ${wl}$VICELIBDIR" 427 hardcode_libdir_separator=: 428 ;; 429 netbsd*) 430 hardcode_libdir_flag_spec="-R$VICELIBDIR" 431 hardcode_direct=yes 432 ;; 433 newsos6) 434 hardcode_direct=yes 435 hardcode_libdir_flag_spec="${wl}-rpath ${wl}$VICELIBDIR" 436 hardcode_libdir_separator=: 437 ;; 438 *nto* | *qnx*) 439 ;; 440 openbsd*) 441 if test -f /usr/libexec/ld.so; then 442 hardcode_direct=yes 443 if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then 444 hardcode_libdir_flag_spec="${wl}-rpath,$VICELIBDIR" 445 else 446 case "$host_os" in 447 openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) 448 hardcode_libdir_flag_spec="-R$VICELIBDIR" 449 ;; 450 *) 451 hardcode_libdir_flag_spec="${wl}-rpath,$VICELIBDIR" 452 ;; 453 esac 454 fi 455 else 456 ld_shlibs=no 457 fi 458 ;; 459 os2*) 460 hardcode_libdir_flag_spec="-L$VICELIBDIR" 461 hardcode_minus_L=yes 462 ;; 463 osf3*) 464 hardcode_libdir_flag_spec="${wl}-rpath ${wl}$VICELIBDIR" 465 hardcode_libdir_separator=: 466 ;; 467 osf4* | osf5*) 468 if test "$GCC" = yes; then 469 hardcode_libdir_flag_spec="${wl}-rpath ${wl}$VICELIBDIR" 470 else 471 # Both cc and cxx compiler support -rpath directly 472 hardcode_libdir_flag_spec="-rpath $VICELIBDIR" 473 fi 474 hardcode_libdir_separator=: 475 ;; 476 solaris*) 477 hardcode_libdir_flag_spec="-R$VICELIBDIR" 478 ;; 479 sunos4*) 480 hardcode_libdir_flag_spec="-L$VICELIBDIR" 481 hardcode_direct=yes 482 hardcode_minus_L=yes 483 ;; 484 sysv4) 485 case $host_vendor in 486 sni) 487 hardcode_direct=yes # is this really true??? 488 ;; 489 siemens) 490 hardcode_direct=no 491 ;; 492 motorola) 493 hardcode_direct=no #Motorola manual says yes, but my tests say they lie 494 ;; 495 esac 496 ;; 497 sysv4.3*) 498 ;; 499 sysv4*MP*) 500 if test -d /usr/nec; then 501 ld_shlibs=yes 502 fi 503 ;; 504 sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) 505 ;; 506 sysv5* | sco3.2v5* | sco5v6*) 507 hardcode_libdir_flag_spec=`test -z '$SCOABSPATH' && echo "${wl}-R,$VICELIBDIR"` 508 hardcode_libdir_separator=':' 509 ;; 510 uts4*) 511 hardcode_libdir_flag_spec="-L$VICELIBDIR" 512 ;; 513 *) 514 ld_shlibs=no 515 ;; 516 esac 517fi 518 519# Check dynamic linker characteristics 520# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER. 521# Unlike libtool.m4, here we don't care about _all_ names of the library, but 522# only about the one the linker finds when passed -lNAME. This is the last 523# element of library_names_spec in libtool.m4, or possibly two of them if the 524# linker has special search rules. 525library_names_spec= # the last element of library_names_spec in libtool.m4 526libname_spec='lib$name' 527case "$host_os" in 528 aix3*) 529 library_names_spec='$libname.a' 530 ;; 531 aix[4-9]*) 532 library_names_spec='$libname$shrext' 533 ;; 534 amigaos*) 535 case "$host_cpu" in 536 powerpc*) 537 library_names_spec='$libname$shrext' ;; 538 m68k) 539 library_names_spec='$libname.a' ;; 540 esac 541 ;; 542 beos*) 543 library_names_spec='$libname$shrext' 544 ;; 545 bsdi[45]*) 546 library_names_spec='$libname$shrext' 547 ;; 548 cygwin* | mingw* | pw32* | cegcc*) 549 shrext=.dll 550 library_names_spec='$libname.dll.a $libname.lib' 551 ;; 552 darwin* | rhapsody*) 553 shrext=.dylib 554 library_names_spec='$libname$shrext' 555 ;; 556 dgux*) 557 library_names_spec='$libname$shrext' 558 ;; 559 freebsd* | dragonfly*) 560 case "$host_os" in 561 freebsd[123]*) 562 library_names_spec='$libname$shrext$versuffix' ;; 563 *) 564 library_names_spec='$libname$shrext' ;; 565 esac 566 ;; 567 gnu*) 568 library_names_spec='$libname$shrext' 569 ;; 570 haiku*) 571 library_names_spec='$libname$shrext' 572 ;; 573 hpux9* | hpux10* | hpux11*) 574 case $host_cpu in 575 ia64*) 576 shrext=.so 577 ;; 578 hppa*64*) 579 shrext=.sl 580 ;; 581 *) 582 shrext=.sl 583 ;; 584 esac 585 library_names_spec='$libname$shrext' 586 ;; 587 interix[3-9]*) 588 library_names_spec='$libname$shrext' 589 ;; 590 irix5* | irix6* | nonstopux*) 591 library_names_spec='$libname$shrext' 592 case "$host_os" in 593 irix5* | nonstopux*) 594 libsuff= shlibsuff= 595 ;; 596 *) 597 case $LD in 598 *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; 599 *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; 600 *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; 601 *) libsuff= shlibsuff= ;; 602 esac 603 ;; 604 esac 605 ;; 606 linux*oldld* | linux*aout* | linux*coff*) 607 ;; 608 linux* | k*bsd*-gnu | kopensolaris*-gnu) 609 library_names_spec='$libname$shrext' 610 ;; 611 knetbsd*-gnu) 612 library_names_spec='$libname$shrext' 613 ;; 614 netbsd*) 615 library_names_spec='$libname$shrext' 616 ;; 617 newsos6) 618 library_names_spec='$libname$shrext' 619 ;; 620 *nto* | *qnx*) 621 library_names_spec='$libname$shrext' 622 ;; 623 openbsd*) 624 library_names_spec='$libname$shrext$versuffix' 625 ;; 626 os2*) 627 libname_spec='$name' 628 shrext=.dll 629 library_names_spec='$libname.a' 630 ;; 631 osf3* | osf4* | osf5*) 632 library_names_spec='$libname$shrext' 633 ;; 634 rdos*) 635 ;; 636 solaris*) 637 library_names_spec='$libname$shrext' 638 ;; 639 sunos4*) 640 library_names_spec='$libname$shrext$versuffix' 641 ;; 642 sysv4 | sysv4.3*) 643 library_names_spec='$libname$shrext' 644 ;; 645 sysv4*MP*) 646 library_names_spec='$libname$shrext' 647 ;; 648 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) 649 library_names_spec='$libname$shrext' 650 ;; 651 tpf*) 652 library_names_spec='$libname$shrext' 653 ;; 654 uts4*) 655 library_names_spec='$libname$shrext' 656 ;; 657esac 658 659sed_quote_subst='s/\(["`$\\]\)/\\\1/g' 660escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` 661shlibext=`echo "$shrext" | sed -e 's,^\.,,'` 662escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` 663escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` 664escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` 665 666if test x"$escaped_hardcode_libdir_flag_spec" = "x"; then 667 case "$host_os" in 668 solaris*) 669 escaped_hardcode_libdir_flag_spec="-R$VICELIBDIR" 670 esac 671fi 672 673echo "$escaped_hardcode_libdir_flag_spec" 674