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