source: snovis/trunk/cmt/cmt_make_shlib_common.sh @ 228

Last change on this file since 228 was 111, checked in by barrand, 17 years ago
  • 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 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
19extract=$1
20shift
21
22tag=$1
23shift
24
25lib=$1
26shift
27
28extra=$*
29
30here=`/bin/pwd`
31
32# kind is shlib or dll. OpenScientist specific.
33kind=`${CMTROOT}/mgr/cmt show macro_value ${lib}_kind -tag=${tag}`
34
35build_shlib=yes
36build_dll=no
37if [ `uname` = Darwin ] ; then
38  if [ "${kind}" = dll ] ; then
39    build_shlib=no
40    build_dll=yes
41  fi
42fi
43
44ld=`${CMTROOT}/mgr/cmt show macro_value shlibbuilder -tag=${tag}`
45ldflags=`${CMTROOT}/mgr/cmt show macro_value shlibflags -tag=${tag}`
46suffix=`${CMTROOT}/mgr/cmt show macro_value shlibsuffix -tag=${tag}`
47libprefix=`${CMTROOT}/mgr/cmt show macro_value library_prefix -tag=${tag}`
48libsuffix=`${CMTROOT}/mgr/cmt show macro_value library_suffix -tag=${tag}`
49
50if test "${ld}" = "" ; then
51  exit 1
52fi
53
54libname=${libprefix}${lib}${libsuffix}
55/bin/rm -f ${libname}.${suffix}
56
57result=0
58
59temp_shlib=${lib}temp_shlib
60
61if test ${extract} = "extract"; then
62  trap 'cd ${here}; /bin/rm -rf ${temp_shlib}; exit ${result}' 0 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
69  #
70  # Build a protected list of modules just extracted from
71  # the static library
72  #  Files containing space characters are accepted
73  #
74  modules=`ls -1 ${temp_shlib} | \
75           grep '[.]o$' | \
76           sed -e 's#^#'${temp_shlib}'/#' \
77               -e 's#^#"#g' \
78               -e 's#$#"#'`
79
80  if [ "${build_shlib}" = "yes" ] ; then
81    if test "${QUIET}" = ""; then set -v; fi
82    eval ${ld} ${ldflags} -o ${libname}.${suffix} ${modules} ${extra}
83    result=$?
84  fi
85
86  if [ "${build_dll}" = "yes" ] ; then
87    /bin/rm -f ${lib}.bundle
88    opts=" -Wl,-headerpad_max_install_names -Wl,-headerpad,800"
89    eval ${ld} -bundle -twolevel_namespace ${opts} -o ${lib}.bundle ${modules} ${extra}
90    result=$?
91  fi
92
93  if test "${QUIET}" = ""; then set +v; fi
94
95  /bin/rm -rf ${temp_shlib}
96
97else
98
99  if test "${QUIET}" = ""; then set -v; fi
100
101  eval ${ld} ${ldflags} -all ${libname}.a -o ${libname}.${suffix} ${extra} -rpath `/bin/pwd`
102  result=$?
103
104  if test "${QUIET}" = ""; then set +v; fi
105
106fi
107
108
109
110
Note: See TracBrowser for help on using the repository browser.