1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/memory/jemalloc/src/install-sh Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,250 @@ 1.4 +#! /bin/sh 1.5 +# 1.6 +# install - install a program, script, or datafile 1.7 +# This comes from X11R5 (mit/util/scripts/install.sh). 1.8 +# 1.9 +# Copyright 1991 by the Massachusetts Institute of Technology 1.10 +# 1.11 +# Permission to use, copy, modify, distribute, and sell this software and its 1.12 +# documentation for any purpose is hereby granted without fee, provided that 1.13 +# the above copyright notice appear in all copies and that both that 1.14 +# copyright notice and this permission notice appear in supporting 1.15 +# documentation, and that the name of M.I.T. not be used in advertising or 1.16 +# publicity pertaining to distribution of the software without specific, 1.17 +# written prior permission. M.I.T. makes no representations about the 1.18 +# suitability of this software for any purpose. It is provided "as is" 1.19 +# without express or implied warranty. 1.20 +# 1.21 +# Calling this script install-sh is preferred over install.sh, to prevent 1.22 +# `make' implicit rules from creating a file called install from it 1.23 +# when there is no Makefile. 1.24 +# 1.25 +# This script is compatible with the BSD install script, but was written 1.26 +# from scratch. It can only install one file at a time, a restriction 1.27 +# shared with many OS's install programs. 1.28 + 1.29 + 1.30 +# set DOITPROG to echo to test this script 1.31 + 1.32 +# Don't use :- since 4.3BSD and earlier shells don't like it. 1.33 +doit="${DOITPROG-}" 1.34 + 1.35 + 1.36 +# put in absolute paths if you don't have them in your path; or use env. vars. 1.37 + 1.38 +mvprog="${MVPROG-mv}" 1.39 +cpprog="${CPPROG-cp}" 1.40 +chmodprog="${CHMODPROG-chmod}" 1.41 +chownprog="${CHOWNPROG-chown}" 1.42 +chgrpprog="${CHGRPPROG-chgrp}" 1.43 +stripprog="${STRIPPROG-strip}" 1.44 +rmprog="${RMPROG-rm}" 1.45 +mkdirprog="${MKDIRPROG-mkdir}" 1.46 + 1.47 +transformbasename="" 1.48 +transform_arg="" 1.49 +instcmd="$mvprog" 1.50 +chmodcmd="$chmodprog 0755" 1.51 +chowncmd="" 1.52 +chgrpcmd="" 1.53 +stripcmd="" 1.54 +rmcmd="$rmprog -f" 1.55 +mvcmd="$mvprog" 1.56 +src="" 1.57 +dst="" 1.58 +dir_arg="" 1.59 + 1.60 +while [ x"$1" != x ]; do 1.61 + case $1 in 1.62 + -c) instcmd="$cpprog" 1.63 + shift 1.64 + continue;; 1.65 + 1.66 + -d) dir_arg=true 1.67 + shift 1.68 + continue;; 1.69 + 1.70 + -m) chmodcmd="$chmodprog $2" 1.71 + shift 1.72 + shift 1.73 + continue;; 1.74 + 1.75 + -o) chowncmd="$chownprog $2" 1.76 + shift 1.77 + shift 1.78 + continue;; 1.79 + 1.80 + -g) chgrpcmd="$chgrpprog $2" 1.81 + shift 1.82 + shift 1.83 + continue;; 1.84 + 1.85 + -s) stripcmd="$stripprog" 1.86 + shift 1.87 + continue;; 1.88 + 1.89 + -t=*) transformarg=`echo $1 | sed 's/-t=//'` 1.90 + shift 1.91 + continue;; 1.92 + 1.93 + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` 1.94 + shift 1.95 + continue;; 1.96 + 1.97 + *) if [ x"$src" = x ] 1.98 + then 1.99 + src=$1 1.100 + else 1.101 + # this colon is to work around a 386BSD /bin/sh bug 1.102 + : 1.103 + dst=$1 1.104 + fi 1.105 + shift 1.106 + continue;; 1.107 + esac 1.108 +done 1.109 + 1.110 +if [ x"$src" = x ] 1.111 +then 1.112 + echo "install: no input file specified" 1.113 + exit 1 1.114 +else 1.115 + true 1.116 +fi 1.117 + 1.118 +if [ x"$dir_arg" != x ]; then 1.119 + dst=$src 1.120 + src="" 1.121 + 1.122 + if [ -d $dst ]; then 1.123 + instcmd=: 1.124 + else 1.125 + instcmd=mkdir 1.126 + fi 1.127 +else 1.128 + 1.129 +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command 1.130 +# might cause directories to be created, which would be especially bad 1.131 +# if $src (and thus $dsttmp) contains '*'. 1.132 + 1.133 + if [ -f $src -o -d $src ] 1.134 + then 1.135 + true 1.136 + else 1.137 + echo "install: $src does not exist" 1.138 + exit 1 1.139 + fi 1.140 + 1.141 + if [ x"$dst" = x ] 1.142 + then 1.143 + echo "install: no destination specified" 1.144 + exit 1 1.145 + else 1.146 + true 1.147 + fi 1.148 + 1.149 +# If destination is a directory, append the input filename; if your system 1.150 +# does not like double slashes in filenames, you may need to add some logic 1.151 + 1.152 + if [ -d $dst ] 1.153 + then 1.154 + dst="$dst"/`basename $src` 1.155 + else 1.156 + true 1.157 + fi 1.158 +fi 1.159 + 1.160 +## this sed command emulates the dirname command 1.161 +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` 1.162 + 1.163 +# Make sure that the destination directory exists. 1.164 +# this part is taken from Noah Friedman's mkinstalldirs script 1.165 + 1.166 +# Skip lots of stat calls in the usual case. 1.167 +if [ ! -d "$dstdir" ]; then 1.168 +defaultIFS=' 1.169 +' 1.170 +IFS="${IFS-${defaultIFS}}" 1.171 + 1.172 +oIFS="${IFS}" 1.173 +# Some sh's can't handle IFS=/ for some reason. 1.174 +IFS='%' 1.175 +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` 1.176 +IFS="${oIFS}" 1.177 + 1.178 +pathcomp='' 1.179 + 1.180 +while [ $# -ne 0 ] ; do 1.181 + pathcomp="${pathcomp}${1}" 1.182 + shift 1.183 + 1.184 + if [ ! -d "${pathcomp}" ] ; 1.185 + then 1.186 + $mkdirprog "${pathcomp}" 1.187 + else 1.188 + true 1.189 + fi 1.190 + 1.191 + pathcomp="${pathcomp}/" 1.192 +done 1.193 +fi 1.194 + 1.195 +if [ x"$dir_arg" != x ] 1.196 +then 1.197 + $doit $instcmd $dst && 1.198 + 1.199 + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && 1.200 + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && 1.201 + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && 1.202 + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi 1.203 +else 1.204 + 1.205 +# If we're going to rename the final executable, determine the name now. 1.206 + 1.207 + if [ x"$transformarg" = x ] 1.208 + then 1.209 + dstfile=`basename $dst` 1.210 + else 1.211 + dstfile=`basename $dst $transformbasename | 1.212 + sed $transformarg`$transformbasename 1.213 + fi 1.214 + 1.215 +# don't allow the sed command to completely eliminate the filename 1.216 + 1.217 + if [ x"$dstfile" = x ] 1.218 + then 1.219 + dstfile=`basename $dst` 1.220 + else 1.221 + true 1.222 + fi 1.223 + 1.224 +# Make a temp file name in the proper directory. 1.225 + 1.226 + dsttmp=$dstdir/#inst.$$# 1.227 + 1.228 +# Move or copy the file name to the temp name 1.229 + 1.230 + $doit $instcmd $src $dsttmp && 1.231 + 1.232 + trap "rm -f ${dsttmp}" 0 && 1.233 + 1.234 +# and set any options; do chmod last to preserve setuid bits 1.235 + 1.236 +# If any of these fail, we abort the whole thing. If we want to 1.237 +# ignore errors from any of these, just make sure not to ignore 1.238 +# errors from the above "$doit $instcmd $src $dsttmp" command. 1.239 + 1.240 + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && 1.241 + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && 1.242 + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && 1.243 + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && 1.244 + 1.245 +# Now rename the file to the real destination. 1.246 + 1.247 + $doit $rmcmd -f $dstdir/$dstfile && 1.248 + $doit $mvcmd $dsttmp $dstdir/$dstfile 1.249 + 1.250 +fi && 1.251 + 1.252 + 1.253 +exit 0