-
Notifications
You must be signed in to change notification settings - Fork 2
/
libmerge.sh
executable file
·53 lines (42 loc) · 1009 Bytes
/
libmerge.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# Copyright 2018, Microsoft Research, Daan Leijen
# Merging static libraries using GNU ar or MacOSX libtool
echo "--- Merging libraries ---"
curdir="`pwd`"
targetdir="$1"
shift
library="$1"
echo "create library: $library"
shift
macosx=""
case "$OSTYPE" in
darwin*) macosx="true";;
esac
if test "$macosx" = "true"; then
# use libtool on MacOSX
echo "libtool combining: $*"
libtool -static -o $library $*
else
# otherwise assume we have GNU ar and combine using a MRI script
mri="$targetdir/$library.mri"
echo "create $library" > "$mri"
# Parse command-line arguments
while : ; do
case "$1" in
"") break;;
*) echo "add library: $1"
echo "addlib $1" >> "$mri";;
esac
shift
done
echo "save" >> "$mri"
echo "end" >> "$mri"
# and run ar on the script
echo "--- Invoking ar to merge..."
ar -M < "$mri"
rm "$mri"
fi
# move the library to the target directory
mv -f "$library" "$targetdir"
echo "--- Done merging"
#cd "$curdir"