* {gdb.t01, gdb.t02, gdb.t03, gdb.t04, gdb.t05, gdb.t06, gdb.t07,
[deliverable/binutils-gdb.git] / install.sh
CommitLineData
bf168768
DZ
1#!/bin/sh
2set -e
3
4#
5# install - install a program, script, or datafile
6# This comes from X11R5; it is not part of GNU.
7#
8# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
9#
10# This script is compatible with the BSD install script, but was written
11# from scratch.
12#
13
14
15# set DOITPROG to echo to test this script
16
17# Don't use :- since 4.3BSD and earlier shells don't like it.
18doit="${DOITPROG-}"
19
20
21# put in absolute paths if you don't have them in your path; or use env. vars.
22
23mvprog="${MVPROG-mv}"
24cpprog="${CPPROG-cp}"
25chmodprog="${CHMODPROG-chmod}"
26chownprog="${CHOWNPROG-chown}"
27chgrpprog="${CHGRPPROG-chgrp}"
28stripprog="${STRIPPROG-strip}"
29rmprog="${RMPROG-rm}"
30mkdirprog="${MKDIRPROG-mkdir}"
31
32tranformbasename=""
33transform_arg=""
34instcmd="$mvprog"
35chmodcmd=""
36chowncmd=""
37chgrpcmd=""
38stripcmd=""
39rmcmd="$rmprog -f"
40mvcmd="$mvprog"
41src=""
42dst=""
43
44while [ x"$1" != x ]; do
45 case $1 in
46 -c) instcmd="$cpprog"
47 shift
48 continue;;
49
50 -m) chmodcmd="$chmodprog $2"
51 shift
52 shift
53 continue;;
54
55 -o) chowncmd="$chownprog $2"
56 shift
57 shift
58 continue;;
59
60 -g) chgrpcmd="$chgrpprog $2"
61 shift
62 shift
63 continue;;
64
65 -s) stripcmd="$stripprog"
66 shift
67 continue;;
68
69 -t=*) transformarg=`echo $1 | sed 's/-t=//'`
70 shift
71 continue;;
72
73 -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
74 shift
75 continue;;
76
77 *) if [ x"$src" = x ]
78 then
79 src=$1
80 else
81 dst=$1
82 fi
83 shift
84 continue;;
85 esac
86done
87
88if [ x"$src" = x ]
89then
90 echo "install: no input file specified"
91 exit 1
92else
93 true
94fi
95
96if [ x"$dst" = x ]
97then
98 echo "install: no destination specified"
99 exit 1
100else
101 true
102fi
103
104# If destination is a directory, append the input filename; if your system
105# does not like double slashes in filenames, you may need to add some logic
106
107if [ -d $dst ]
108then
109 dst="$dst"/`basename $src`
110else
111 true
112fi
113
114
115# Make a temp file name in the proper directory.
116
af864713
DZ
117## this sed command emulates the dirname command
118dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
bf168768
DZ
119dsttmp=$dstdir/#inst.$$#
120
121# Make sure that the destination directory exists.
122# this part is taken from Noah Friedman's mkinstalldirs script
123
124defaultIFS='
125'
126IFS="${IFS-${defaultIFS}}"
127
128oIFS="${IFS}"
129# Some sh's can't handle IFS=/ for some reason.
130IFS='%'
131set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
132IFS="${oIFS}"
133
134pathcomp=''
135
136while [ $# -ne 0 ] ; do
137 pathcomp="${pathcomp}${1}"
138 shift
139
140 if [ ! -d "${pathcomp}" ] ;
141 then
142 $mkdirprog "${pathcomp}"
143 else
144 true
145 fi
146
147 pathcomp="${pathcomp}/"
148done
149
150# If we're going to rename the final executable, determine the name now.
151
152if [ x"$transformarg" = x ]
153then
154 dstfile=`basename $dst`
155else
1a4874f7 156 dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename
bf168768
DZ
157fi
158
159# don't allow the sed command to completely eliminate the filename
160
161if [ x"$dstfile" = x ]
162then
163 dstfile=`basename $dst`
164else
165 true
166fi
167
168# Move or copy the file name to the temp name
169
170$doit $instcmd $src $dsttmp
171
172# and set any options; do chmod last to preserve setuid bits
173
174if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi
175if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi
176if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi
177if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi
178
179# Now rename the file to the real destination.
180
181$doit $rmcmd $dstdir/$dstfile
182$doit $mvcmd $dsttmp $dstdir/$dstfile
183
184
185exit 0
This page took 0.037707 seconds and 4 git commands to generate.