Home | History | Annotate | Download | only in tools
      1 #!/bin/sh -e
      2 #
      3 # CDDL HEADER START
      4 #
      5 # The contents of this file are subject to the terms of the
      6 # Common Development and Distribution License (the "License").
      7 # You may not use this file except in compliance with the License.
      8 #
      9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10 # or http://www.opensolaris.org/os/licensing.
     11 # See the License for the specific language governing permissions
     12 # and limitations under the License.
     13 #
     14 # When distributing Covered Code, include this CDDL HEADER in each
     15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16 # If applicable, add the following below this CDDL HEADER, with the
     17 # fields enclosed by brackets "[]" replaced with your own identifying
     18 # information: Portions Copyright [yyyy] [name of copyright owner]
     19 #
     20 # CDDL HEADER END
     21 #
     22 #
     23 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     24 # Use is subject to license terms.
     25 #
     26 #ident	"@(#)install.subr	1.6	08/03/20 SMI"
     27 
     28 # XXX We would ideally inherit PERL from Makefile.master.
     29 #     For now, we just set it here.
     30 
     31 PERL=/usr/perl5/bin/perl
     32 
     33 _install()
     34 {
     35   _type=$1
     36   _src=$2
     37   _targ=$3
     38   _perm=$4
     39   
     40   case "$1" in
     41     L)
     42       # Install symbolic link file
     43       rm -f $_targ
     44       ln -s $_src $_targ
     45       ;;
     46     H)
     47       # Install hard link
     48       rm -f $_targ
     49       ln $_src $_targ
     50       ;;
     51 
     52     E)
     53       # Install executable ELF file
     54       rm -f $_targ
     55       cp $_src $_targ
     56       chmod u+w $_targ
     57       ${SRC}/tools/post_process $_targ
     58       /usr/ccs/bin/strip $_targ
     59       chmod $_perm $_targ
     60       ;;
     61 
     62     D)
     63       # Install dynamic executable ELF library
     64       rm -f $_targ
     65       cp $_src $_targ
     66       chmod u+w $_targ
     67       ${SRC}/tools/post_process_so $_targ
     68       chmod $_perm $_targ
     69       ;;
     70 
     71     N|S)
     72       # Install normal or executable script file
     73       rm -f $_targ
     74       cp $_src $_targ
     75       chmod $_perm $_targ
     76       ;;
     77 
     78     M)
     79       # Install man page file
     80       if [ -z "${MANSCRIPT}" ]
     81       then
     82           echo "MANSCRIPT not set"
     83           exit 1
     84       fi
     85       rm -f $_targ
     86       sed -f ${MANSCRIPT} $_src > $_targ
     87       chmod $_perm $_targ
     88       ;;
     89 
     90     P)
     91       # Install perl script file
     92       rm -f $_targ
     93       sed -e "1s|^#\!.*perl|#\!${PERL}|" <$_src >$_targ
     94       chmod $_perm $_targ
     95       ;;
     96   esac
     97 
     98   return
     99 }
    100 
    101 _fixup_perl()
    102 {
    103   _line="1"
    104   case $1 in
    105     -a) _line=""
    106 	shift ;;
    107   esac
    108 
    109   _file=$1
    110 
    111   cp ${_file} ${_file}.orig
    112   rm -f ${_file}
    113   sed -e "${_line}s|^#\!.*perl|#\!${PERL}|" <${_file}.orig >${_file}
    114   rm -f ${_file}.orig
    115 }
    116