home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / octave-1.1.1p1-base.tgz / octave-1.1.1p1-base.tar / fsf / octave / flibs.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1995-01-25  |  3KB  |  141 lines

  1. #!/bin/sh
  2. #
  3. # flibs -- try to get the Fortran compiler to tell us what libraries
  4. # it expects to link to, and echo the result to the standard output.
  5. #
  6. # John W. Eaton
  7. # jwe@che.utexas.edu
  8. # Department of Chemical Engineering
  9. # The University of Texas at Austin
  10.  
  11. trap 'rm -f conftest* core; exit 1' 1 3 15
  12.  
  13. # Write a minimal program and compile it with -v.  I don't know what
  14. # to do if your compiler doesn't have -v...
  15.  
  16. echo "      END" > conftest.f
  17.  
  18. if test $# -eq 1
  19. then
  20.   foutput=`cat $1`
  21. else
  22.   foutput=`${F77-f77} -v -o conftest conftest.f 2>&1`
  23. fi
  24.  
  25. # The easiest thing to do for xlf output is to replace all the commas
  26. # with spaces.  Try to only do that if the output is really from xlf,
  27. # since doing that causes problems on other systems.
  28.  
  29. xlf_p=`echo $foutput | grep xlfentry`
  30. if test -n "$xlf_p"
  31. then
  32.   foutput=`echo $foutput | sed 's/,/ /g'`
  33. fi
  34.  
  35. ld_run_path=`echo $foutput | \
  36.   sed -n -e 's/.*\(LD_RUN_PATH *= *[^ ]*\).*/\1/p' | \
  37.   sed -e 's/LD_RUN_PATH *= *//'`
  38.  
  39. # We are only supposed to find this on Solaris systems, and this
  40. # substitution is probably only going to work with gcc on those
  41. # systems...
  42.  
  43. if test -n "$ld_run_path"
  44. then
  45.   ld_run_path="-Xlinker -R -Xlinker $ld_run_path"
  46. fi
  47.  
  48. flibs=
  49. lflags=
  50.  
  51. # If want_arg is set, we know we want the arg to be added to the list,
  52. # so we don't have to examine it.
  53. want_arg=
  54.  
  55. for arg in $foutput
  56. do
  57.   if test -z "$want_arg"
  58.   then
  59.     case $arg in
  60.       /*.a | /*values-*.o)
  61.         exists=false
  62.         for f in $lflags
  63.         do
  64.           if test x$arg = x$f
  65.           then
  66.             exists=true
  67.           fi
  68.         done
  69.     if $exists
  70.     then
  71.       arg=
  72.         else
  73.           lflags="$lflags $arg"
  74.     fi
  75.       ;;
  76.       -lang*)
  77.         arg=
  78.       ;;
  79.       -[lL]*)
  80.         exists=false
  81.         for f in $lflags
  82.         do
  83.           if test x$arg = x$f
  84.           then
  85.             exists=true
  86.           fi
  87.         done
  88.     if $exists || test x$arg = x-lm -o x$arg = x-lc
  89.     then
  90.       arg=
  91.         else
  92.           lflags="$lflags $arg"
  93.     fi
  94.       ;;
  95.       -u)
  96.         want_arg=$arg
  97.       ;;
  98.       -Y)
  99.         want_arg=$arg
  100.         arg=
  101.       ;;
  102.       *)
  103.         arg=
  104.       ;;
  105.     esac
  106.   else
  107.     if test x$want_arg = x-Y
  108.     then
  109.  
  110. # Should probably try to ensure unique directory options here too.
  111. # This probably only applies to Solaris systems, and then will only
  112. # work with gcc...
  113.  
  114.       arg=`echo $arg | sed -e 's%^P,%%'`
  115.       SAVE_IFS=$IFS
  116.       IFS=:
  117.       list=
  118.       for elt in $arg
  119.       do
  120.         list="$list -L $elt"
  121.       done
  122.       IFS=$SAVE_IFS
  123.       arg="$list"
  124.     fi
  125.     want_arg=
  126.   fi
  127.  
  128.   if test -n "$arg"
  129.   then
  130.     flibs="$flibs $arg"
  131.   fi
  132. done
  133.  
  134. echo "$ld_run_path $flibs"
  135.  
  136. rm -f conftest* core
  137.  
  138. # Bye-bye.
  139.  
  140. exit 0
  141.