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 | # kind is shlib or dll. OpenScientist specific. |
---|
33 | kind=`${CMTROOT}/mgr/cmt show macro_value ${lib}_kind -tag=${tag}` |
---|
34 | |
---|
35 | build_shlib=yes |
---|
36 | build_dll=no |
---|
37 | if [ `uname` = Darwin ] ; then |
---|
38 | if [ "${kind}" = dll ] ; then |
---|
39 | build_shlib=no |
---|
40 | build_dll=yes |
---|
41 | fi |
---|
42 | fi |
---|
43 | |
---|
44 | ld=`${CMTROOT}/mgr/cmt show macro_value shlibbuilder -tag=${tag}` |
---|
45 | ldflags=`${CMTROOT}/mgr/cmt show macro_value shlibflags -tag=${tag}` |
---|
46 | suffix=`${CMTROOT}/mgr/cmt show macro_value shlibsuffix -tag=${tag}` |
---|
47 | libprefix=`${CMTROOT}/mgr/cmt show macro_value library_prefix -tag=${tag}` |
---|
48 | libsuffix=`${CMTROOT}/mgr/cmt show macro_value library_suffix -tag=${tag}` |
---|
49 | |
---|
50 | if test "${ld}" = "" ; then |
---|
51 | exit 1 |
---|
52 | fi |
---|
53 | |
---|
54 | libname=${libprefix}${lib}${libsuffix} |
---|
55 | /bin/rm -f ${libname}.${suffix} |
---|
56 | |
---|
57 | result=0 |
---|
58 | |
---|
59 | temp_shlib=${lib}temp_shlib |
---|
60 | |
---|
61 | if 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 | |
---|
97 | else |
---|
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 | |
---|
106 | fi |
---|
107 | |
---|
108 | |
---|
109 | |
---|
110 | |
---|