source: CMT/v1r25/mgr/cmt_make_shlib_common.sh

Last change on this file was 591, checked in by rybkin, 13 years ago

See C.L. 468

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.4 KB
Line 
1#!/bin/sh
2
3#set -x
4
5#------------------------------------------------------
6#
7#  Syntax :
8#
9#  cmt_make_shlib_common.sh extract-arg tag library extra-args
10#
11#   with :
12#
13#      extract-arg  : either "extract" or "no_extract"
14#      tag          : the current tag(s)
15#      library      : the name of the library
16#      extra-args   : extra link options
17#
18#------------------------------------------------------
19
20extract=$1
21shift
22
23tag=$1
24shift
25
26lib=$1
27shift
28
29extra=$*
30
31if [ "${CMTDEBUG:-}" ]; then
32unset CMTDEBUG
33set -x
34fi
35
36[ -n "${ld:-}" ] || ld=`${CMTROOT}/mgr/cmt show macro_value shlibbuilder -tag=${tag}` || exit
37[ -n "${ldflags+CMT}" ] || ldflags=`${CMTROOT}/mgr/cmt show macro_value shlibflags -tag=${tag}` || exit
38[ -n "${suffix+CMT}" ] || suffix=`${CMTROOT}/mgr/cmt show macro_value shlibsuffix -tag=${tag}` || exit
39[ -n "${libprefix+CMT}" ] || libprefix=`${CMTROOT}/mgr/cmt show macro_value library_prefix -tag=${tag}` || exit
40[ -n "${libsuffix+CMT}" ] || libsuffix=`${CMTROOT}/mgr/cmt show macro_value library_suffix -tag=${tag}` || exit
41
42libname=${libprefix}${lib}${libsuffix}
43
44if test "${ld}" = "" ; then
45  exit 1
46fi
47
48if test "${bin}" = "" ; then
49  bin=`${CMTROOT}/mgr/cmt show macro_value bin -tag=${tag}` || exit
50fi
51
52here=`/bin/pwd`
53cd ${bin} || exit
54
55/bin/rm -f ${libname}.${suffix} || exit
56
57result=0
58
59temp_shlib=${lib}temp_shlib
60
61if test ${extract} = "extract"; then
62  trap '/bin/rm -rf ${temp_shlib}; cd ${here}; exit ${result}' 1 2 15
63
64  mkdir -p ${temp_shlib}
65  /bin/rm -f ${temp_shlib}/*
66
67  (cd ${temp_shlib}; ar x ../${libname}.a)
68  result=$?
69  if [ ${result} -ne 0 ]; then
70      \rm -rf ${temp_shlib}
71      cd ${here}
72      exit ${result}
73  fi
74
75  #
76  # Build a protected list of modules just extracted from
77  # the static library
78  #  Files containing space characters are accepted
79  #
80  test -z "$GREP_OPTIONS" || GREP_OPTIONS=
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
88
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
96else
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
105fi
106
107cd ${here}
108exit ${result}
Note: See TracBrowser for help on using the repository browser.