1 | #!/bin/sh |
---|
2 | |
---|
3 | #set -x |
---|
4 | |
---|
5 | #------------------------------------------------------ |
---|
6 | # |
---|
7 | # Syntax : |
---|
8 | # |
---|
9 | # cmt_make_shlib_common.sh extract-arg package extra-args |
---|
10 | # |
---|
11 | # with : |
---|
12 | # |
---|
13 | # extract-arg : either "extract" or "no_extract" |
---|
14 | # package : the current package name |
---|
15 | # extra-args : extra link options |
---|
16 | # |
---|
17 | #------------------------------------------------------ |
---|
18 | |
---|
19 | extract=$1 |
---|
20 | shift |
---|
21 | |
---|
22 | tag=$1 |
---|
23 | shift |
---|
24 | |
---|
25 | lib=$1 |
---|
26 | shift |
---|
27 | |
---|
28 | extra=$* |
---|
29 | |
---|
30 | here=`/bin/pwd` |
---|
31 | |
---|
32 | ld=`${CMTROOT}/mgr/cmt show macro_value shlibbuilder -tag=${tag}` |
---|
33 | ldflags=`${CMTROOT}/mgr/cmt show macro_value shlibflags -tag=${tag}` |
---|
34 | suffix=`${CMTROOT}/mgr/cmt show macro_value shlibsuffix -tag=${tag}` |
---|
35 | libprefix=`${CMTROOT}/mgr/cmt show macro_value library_prefix -tag=${tag}` |
---|
36 | libsuffix=`${CMTROOT}/mgr/cmt show macro_value library_suffix -tag=${tag}` |
---|
37 | |
---|
38 | if test "${ld}" = "" ; then |
---|
39 | exit 1 |
---|
40 | fi |
---|
41 | |
---|
42 | libname=${libprefix}${lib}${libsuffix} |
---|
43 | /bin/rm -f ${libname}.${suffix} |
---|
44 | |
---|
45 | result=0 |
---|
46 | |
---|
47 | temp_shlib=${lib}temp_shlib |
---|
48 | |
---|
49 | if test ${extract} = "extract"; then |
---|
50 | trap 'cd ${here}; /bin/rm -rf ${temp_shlib}; exit ${result}' 0 1 2 15 |
---|
51 | |
---|
52 | mkdir -p ${temp_shlib} |
---|
53 | /bin/rm -f ${temp_shlib}/* |
---|
54 | |
---|
55 | (cd ${temp_shlib}; ar x ../${libname}.a) |
---|
56 | |
---|
57 | # |
---|
58 | # Build a protected list of modules just extracted from |
---|
59 | # the static library |
---|
60 | # Files containing space characters are accepted |
---|
61 | # |
---|
62 | modules=`ls -1 ${temp_shlib} | \ |
---|
63 | grep '[.]o$' | \ |
---|
64 | sed -e 's#^#'${temp_shlib}'/#' \ |
---|
65 | -e 's#^#"#g' \ |
---|
66 | -e 's#$#"#'` |
---|
67 | |
---|
68 | if test "${QUIET}" = ""; then set -v; fi |
---|
69 | eval ${ld} ${ldflags} -o ${libname}.${suffix} ${modules} ${extra} |
---|
70 | result=$? |
---|
71 | |
---|
72 | if test "${QUIET}" = ""; then set +v; fi |
---|
73 | |
---|
74 | /bin/rm -rf ${temp_shlib} |
---|
75 | |
---|
76 | else |
---|
77 | |
---|
78 | if test "${QUIET}" = ""; then set -v; fi |
---|
79 | |
---|
80 | eval ${ld} ${ldflags} -all ${libname}.a -o ${libname}.${suffix} ${extra} -rpath `/bin/pwd` |
---|
81 | result=$? |
---|
82 | |
---|
83 | if test "${QUIET}" = ""; then set +v; fi |
---|
84 | |
---|
85 | fi |
---|
86 | |
---|
87 | |
---|
88 | |
---|
89 | |
---|