| 1 |
XCOMM!/bin/sh |
| 2 |
XCOMM |
| 3 |
XCOMM Copyright (c) 1989, 1998 The Open Group |
| 4 |
XCOMM |
| 5 |
XCOMM Permission to use, copy, modify, distribute, and sell this software and |
| 6 |
XCOMM its documentation for any purpose is hereby granted without fee, provided |
| 7 |
XCOMM that the above copyright notice appear in all copies and that both that |
| 8 |
XCOMM copyright notice and this permission notice appear in supporting |
| 9 |
XCOMM documentation. |
| 10 |
XCOMM |
| 11 |
XCOMM The above copyright notice and this permission notice shall be included in |
| 12 |
XCOMM all copies or substantial portions of the Software. |
| 13 |
XCOMM |
| 14 |
XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 |
XCOMM IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
XCOMM FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 |
XCOMM OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 18 |
XCOMM AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 19 |
XCOMM CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 20 |
XCOMM |
| 21 |
XCOMM Except as contained in this notice, the name of The Open Group shall not be |
| 22 |
XCOMM used in advertising or otherwise to promote the sale, use or other dealings |
| 23 |
XCOMM in this Software without prior written authorization from The Open Group. |
| 24 |
XCOMM |
| 25 |
XCOMM Author: Jim Fulton, MIT X Consortium |
| 26 |
XCOMM |
| 27 |
XCOMM mergelib - merge one library into another; this is commonly used by X |
| 28 |
XCOMM to add the extension library into the base Xlib. |
| 29 |
XCOMM |
| 30 |
|
| 31 |
usage="usage: $0 to-library from-library [object-filename-prefix]" |
| 32 |
objprefix=_ |
| 33 |
|
| 34 |
case $# in |
| 35 |
2) ;; |
| 36 |
3) objprefix=$3 ;; |
| 37 |
*) echo "$usage" 1>&2; exit 1 ;; |
| 38 |
esac |
| 39 |
|
| 40 |
tolib=$1 |
| 41 |
fromlib=$2 |
| 42 |
|
| 43 |
if [ ! -f $fromlib ]; then |
| 44 |
echo "$0: no such from-library $fromlib" 1>&2 |
| 45 |
exit 1 |
| 46 |
fi |
| 47 |
|
| 48 |
if [ ! -f $tolib ]; then |
| 49 |
echo "$0: no such to-library $tolib" 1>&2 |
| 50 |
exit 1 |
| 51 |
fi |
| 52 |
|
| 53 |
|
| 54 |
XCOMM |
| 55 |
XCOMM Create a temp directory, and figure out how to reference the |
| 56 |
XCOMM object files from it (i.e. relative vs. absolute path names). |
| 57 |
XCOMM |
| 58 |
|
| 59 |
tmpdir=tmp.$$ |
| 60 |
origdir=.. |
| 61 |
|
| 62 |
XCOMM Remove directory if we fail |
| 63 |
trap "rm -rf $tmpdir; exit 1" 1 2 15 |
| 64 |
trap "rm -rf $tmpdir; exit 0" 1 2 13 |
| 65 |
|
| 66 |
mkdir $tmpdir |
| 67 |
|
| 68 |
XCOMM Security: if $tmpdir exists before mkdir exit immediately |
| 69 |
if [ $? -gt 0 -o ! -d $tmpdir ]; then |
| 70 |
echo "$0: unable to create temporary directory $tmpdir" 1>&2 |
| 71 |
exit 1 |
| 72 |
fi |
| 73 |
|
| 74 |
case "$fromlib" in |
| 75 |
/?*) upfrom= ;; |
| 76 |
*) upfrom=../ ;; |
| 77 |
esac |
| 78 |
|
| 79 |
case "$tolib" in |
| 80 |
/?*) upto= ;; |
| 81 |
*) upto=../ ;; |
| 82 |
esac |
| 83 |
|
| 84 |
|
| 85 |
XCOMM |
| 86 |
XCOMM In the temp directory, extract all of the object files and prefix |
| 87 |
XCOMM them with some symbol to avoid name clashes with the base library. |
| 88 |
XCOMM |
| 89 |
cd $tmpdir || exit 1 |
| 90 |
ar x ${upfrom}$fromlib |
| 91 |
for i in *.o; do |
| 92 |
mv $i ${objprefix}$i |
| 93 |
done |
| 94 |
|
| 95 |
|
| 96 |
XCOMM |
| 97 |
XCOMM Merge in the object modules, ranlib (if appropriate) and cleanup |
| 98 |
XCOMM |
| 99 |
ARCMD ${upto}$tolib *.o |
| 100 |
RANLIB ${upto}$tolib |
| 101 |
cd $origdir |
| 102 |
rm -rf $tmpdir |
| 103 |
|