home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / DEV.Z / libtool < prev    next >
Encoding:
Text File  |  1996-09-08  |  3.5 KB  |  227 lines

  1. #!/bin/sh
  2. #
  3. # libtool
  4. #
  5. # written by Mike Gobbi
  6. # created July 10, 1995
  7. #
  8. # Copyright (C) 1995 NeXT Computer, Inc.
  9. # All Rights Reserved
  10. #
  11.  
  12. mode=dynamic
  13. ifiles=
  14. soptions=""
  15. doptions=""
  16. output_specified=no
  17. output_file=
  18. arch=
  19. deffile=
  20. verbose=no
  21. CC=gcc
  22. LIB="lib /nologo"
  23.  
  24. while true
  25. do
  26.     case $1 in
  27.     
  28.     -static )
  29.         mode=static
  30.         shift
  31.         ;;
  32.         
  33.     -dynamic )
  34.         mode=dynamic
  35.         shift
  36.         ;;
  37.         
  38.     -o )
  39.         soptions="$soptions /OUT:$2"
  40.         doptions="$doptions -o $2"
  41.         output_specified=yes
  42.         output_file="$2"
  43.         shift
  44.         shift
  45.         ;;
  46.         
  47.     -[sac] | -[sac][sac] | -[sac][sac][sac] )
  48.         echo "libtool: warning: -sac options ignored" 1>&2
  49.         shift
  50.         ;;
  51.  
  52.     -g )
  53.         doptions="$doptions -g"
  54.         shift
  55.         ;;
  56.  
  57.     -def )
  58.         deffile="$2"
  59.         shift
  60.         shift
  61.         ;;
  62.         
  63.     -file[lL]ist )
  64.         if [ "$mode" = "dynamic" ]
  65.         then
  66.             doptions="$doptions -filelist $2"
  67.         else
  68.             file=`echo $2 | sed "s/,.*//g"`
  69.             if echo $2 | grep -s ,
  70.             then
  71.             dir=`echo $2 | sed "s/.*,//g"`
  72.             else
  73.             dir=
  74.             fi
  75.             if [ ! -r "$file" ]
  76.             then
  77.             echo "libtool: error: filelist '$2' not found" 1>&2
  78.             exit 1
  79.             elif [ -n "$dir" ]
  80.             then
  81.             ifiles="$ifiles `cat $file | sed "s@^@$dir/@" | tr -s '\012\015 ' ' '`"
  82.             else
  83.             ifiles="$ifiles `cat $file | tr -s '\012\015 ' ' '`"
  84.             fi
  85.         fi
  86.         shift
  87.         shift
  88.         ;;
  89.         
  90.     -install_name )
  91.         echo "libtool: warning: -install_name ignored" 1>&2
  92.         shift
  93.         shift
  94.         ;;
  95.         
  96.     -compatibility_version )
  97.         echo "libtool: warning: -compatibility_version ignored" 1>&2
  98.         shift
  99.         shift
  100.         ;;
  101.         
  102.     -current_version )
  103.         echo "libtool: warning: -current_version ignored" 1>&2
  104.         shift
  105.         shift
  106.         ;;
  107.         
  108.     -v )
  109.         verbose=yes
  110.         soptions="$soptions /VERBOSE"
  111.         doptions="$doptions"
  112.         shift
  113.         ;;
  114.         
  115.     -seg1addr | -undefined )
  116.         echo "libtool: warning: option '$1 $2' suppressed" 1>&2
  117.         shift
  118.         shift
  119.         ;;
  120.         
  121.     -image_base )
  122.         doptions="$doptions -Xlinker /BASE:$2"
  123.         shift
  124.         shift
  125.         ;;
  126.  
  127.     -sectorder )
  128.         echo "libtool: warning: option '$1 $2 $3 $4' suppressed" 1>&2
  129.         shift
  130.         shift
  131.         shift
  132.         shift
  133.         ;;
  134.         
  135.     -sectorder_detail )
  136.         echo "libtool: warning: option '$1' suppressed" 1>&2
  137.         shift
  138.         ;;
  139.         
  140.     -t )
  141.         shift
  142.         ;;
  143.         
  144.     - )
  145.         shift
  146.         break
  147.         ;;
  148.  
  149.         -framework )
  150.         doptions="$doptions -framework $2"
  151.         shift
  152.         shift
  153.         ;;
  154.  
  155.         -F* )
  156.         doptions="$doptions $1"
  157.         shift
  158.         ;;
  159.  
  160.     -arch* )
  161.         doptions="$doptions -arch $2"
  162.         arch="$2"
  163.         shift
  164.         shift
  165.         ;;
  166.         
  167.     -* )
  168.         soptions="$soptions $1"
  169.         doptions="$doptions $1"
  170.         shift
  171.         ;;
  172.         
  173.     * )
  174.         break
  175.         ;;
  176.     
  177.     esac
  178. done
  179.  
  180. if [ -n "$deffile" ]
  181. then
  182.   if [ ! -r "$deffile" ]
  183.   then
  184.     echo "libtool: error: definition file $deffile is missing" 1>&2
  185.     exit 1
  186.   fi
  187. elif [ -n "$output_file" -a -n "$arch" ]; then
  188.   deffile=`echo $output_file | sed -e 's/\.dll$//' -e "s/\.$arch//" -e "s@.*/@@"`.def
  189. else
  190.   deffile=`echo $output_file | sed -e 's/\.dll$//'`.def
  191.   #deffile="$output_file"
  192. fi
  193.  
  194. ifiles="$ifiles $*"
  195.  
  196. if [ "$output_specified" = "no" ]
  197. then
  198.     echo "libtool: error: -o option is required" 1>&2
  199.     exit 1
  200. elif [ "$mode" = "static" ]
  201. then
  202.     if [ "$verbose" = "yes" ]
  203.     then
  204.         echo $LIB $soptions $ifiles
  205.     fi
  206.     $LIB $soptions $ifiles
  207.     exit $?
  208. elif [ "$mode" = "dynamic" ]
  209. then
  210.     if [ -r $deffile ]
  211.     then
  212.         cmd="$CC -dll $doptions $ifiles -Xlinker -DEF:$deffile"
  213.     else
  214.         echo "libtool: warning: default definition file $deffile is missing" 1>&2
  215.         cmd="$CC -dll $doptions $ifiles"
  216.     fi
  217.     if [ "$verbose" = "yes" ]
  218.     then
  219.         echo $cmd
  220.     fi
  221.     $cmd
  222.     exit $?
  223. else
  224.     echo "libtool: error: unknown mode $mode" 1>&2
  225.     exit 1
  226. fi
  227.