1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
-
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
+
+
+
+
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
dnl Usage:
dnl DC_TEST_SHOBJFLAGS(shobjflags, shobjldflags, action-if-not-found)
dnl
AC_DEFUN(DC_TEST_SHOBJFLAGS, [
AC_DEFUN([DC_TEST_SHOBJFLAGS], [
AC_SUBST(SHOBJFLAGS)
AC_SUBST(SHOBJCPPFLAGS)
AC_SUBST(SHOBJLDFLAGS)
OLD_LDFLAGS="$LDFLAGS"
OLD_CFLAGS="$CFLAGS"
OLD_CPPFLAGS="$CPPFLAGS"
SHOBJFLAGS=""
SHOBJCPPFLAGS=""
SHOBJLDFLAGS=""
CFLAGS="$OLD_CFLAGS $1"
CPPFLAGS="$OLD_CPPFLAGS $2"
LDFLAGS="$OLD_LDFLAGS $1 $2"
LDFLAGS="$OLD_LDFLAGS $3"
AC_TRY_LINK([#include <stdio.h>
int unrestst(void);], [ printf("okay\n"); unrestst(); return(0); ], [ SHOBJFLAGS="$1"; SHOBJLDFLAGS="$2" ], [
LDFLAGS="$OLD_LDFLAGS"
$3
])
int unrestst(void);], [ printf("okay\n"); unrestst(); return(0); ], [ SHOBJFLAGS="$1"; SHOBJCPPFLAGS="$2"; SHOBJLDFLAGS="$3" ], [
LDFLAGS="$OLD_LDFLAGS"
CFLAGS="$OLD_CFLAGS"
CPPFLAGS="$OLD_CPPFLAGS"
$4
])
LDFLAGS="$OLD_LDFLAGS"
CFLAGS="$OLD_CFLAGS"
CPPFLAGS="$OLD_CPPFLAGS"
])
AC_DEFUN(DC_GET_SHOBJFLAGS, [
AC_DEFUN([DC_GET_SHOBJFLAGS], [
AC_SUBST(SHOBJFLAGS)
AC_SUBST(SHOBJCPPFLAGS)
AC_SUBST(SHOBJLDFLAGS)
DC_CHK_OS_INFO
AC_MSG_CHECKING(how to create shared objects)
if test -z "$SHOBJFLAGS" -a -z "$SHOBJLDFLAGS"; then
DC_TEST_SHOBJFLAGS([-fPIC -DPIC], [-shared -rdynamic], [
DC_TEST_SHOBJFLAGS([-fPIC -DPIC], [-shared], [
DC_TEST_SHOBJFLAGS([-fPIC -DPIC], [-shared -rdynamic -mimpure-text], [
DC_TEST_SHOBJFLAGS([-fPIC -DPIC], [-shared -mimpure-text], [
DC_TEST_SHOBJFLAGS([-fPIC -DPIC], [-shared -rdynamic -Wl,-G,-z,textoff], [
DC_TEST_SHOBJFLAGS([-fPIC -DPIC], [-shared -Wl,-G,-z,textoff], [
DC_TEST_SHOBJFLAGS([-fPIC -DPIC], [-shared -dynamiclib -flat_namespace -undefined suppress -bind_at_load], [
DC_TEST_SHOBJFLAGS([-fPIC -DPIC], [-dynamiclib -flat_namespace -undefined suppress -bind_at_load], [
DC_TEST_SHOBJFLAGS([-fPIC -DPIC], [-Wl,-dynamiclib -Wl,-flat_namespace -Wl,-undefined,suppress -Wl,-bind_at_load], [
DC_TEST_SHOBJFLAGS([-fPIC -DPIC], [-dynamiclib -flat_namespace -undefined suppress], [
DC_TEST_SHOBJFLAGS([-fPIC -DPIC], [-dynamiclib], [
AC_MSG_RESULT(cant)
AC_MSG_ERROR([We are unable to make shared objects.])
if test -z "$SHOBJFLAGS" -a -z "$SHOBJLDFLAGS" -a -z "$SHOBJCPPFLAGS"; then
DC_TEST_SHOBJFLAGS([-fPIC], [-DPIC], [-shared -rdynamic], [
DC_TEST_SHOBJFLAGS([-fPIC], [-DPIC], [-shared], [
DC_TEST_SHOBJFLAGS([-fPIC], [-DPIC], [-shared -rdynamic -mimpure-text], [
DC_TEST_SHOBJFLAGS([-fPIC], [-DPIC], [-shared -mimpure-text], [
DC_TEST_SHOBJFLAGS([-fPIC], [-DPIC], [-shared -rdynamic -Wl,-G,-z,textoff], [
DC_TEST_SHOBJFLAGS([-fPIC], [-DPIC], [-shared -Wl,-G], [
DC_TEST_SHOBJFLAGS([-fPIC], [-DPIC], [-shared -dynamiclib -flat_namespace -undefined suppress -bind_at_load], [
DC_TEST_SHOBJFLAGS([-fPIC], [-DPIC], [-dynamiclib -flat_namespace -undefined suppress -bind_at_load], [
DC_TEST_SHOBJFLAGS([-fPIC], [-DPIC], [-Wl,-dynamiclib -Wl,-flat_namespace -Wl,-undefined,suppress -Wl,-bind_at_load], [
DC_TEST_SHOBJFLAGS([-fPIC], [-DPIC], [-dynamiclib -flat_namespace -undefined suppress], [
DC_TEST_SHOBJFLAGS([-fPIC], [-DPIC], [-dynamiclib], [
AC_MSG_RESULT(cant)
AC_MSG_ERROR([We are unable to make shared objects.])
])
])
])
])
])
])
])
])
])
])
])
])
])
])
])
])
])
])
])
fi
AC_MSG_RESULT($SHOBJLDFLAGS $SHOBJFLAGS)
AC_MSG_RESULT($SHOBJCPPFLAGS $SHOBJFLAGS $SHOBJLDFLAGS)
DC_SYNC_SHLIBOBJS
])
AC_DEFUN([DC_SYNC_SHLIBOBJS], [
AC_SUBST(SHLIBOBJS)
SHLIBOBJS=""
for obj in $LIB@&t@OBJS; do
SHLIBOBJS="$SHLIBOBJS `echo $obj | sed 's/\.o$/_shr.o/g'`"
done
])
AC_DEFUN([DC_SYNC_RPATH], [
OLD_LDFLAGS="$LDFLAGS"
for tryrpath in "-Wl,-rpath" "-Wl,--rpath" "-Wl,-R"; do
LDFLAGS="$OLD_LDFLAGS $tryrpath -Wl,/tmp"
AC_LINK_IFELSE(AC_LANG_PROGRAM([], [ return(0); ]), [
rpathldflags="$tryrpath"
break
])
done
unset tryrpath
LDFLAGS="$OLD_LDFLAGS"
unset OLD_LDFLAGS
ADDLDFLAGS=""
for opt in $LDFLAGS; do
if echo "$opt" | grep '^-L' >/dev/null; then
rpathdir=`echo "$opt" | sed 's@^-L *@@'`
ADDLDFLAGS="$ADDLDFLAGS $rpathldflags -Wl,$rpathdir"
fi
done
unset opt rpathldflags
LDFLAGS="$LDFLAGS $ADDLDFLAGS"
unset ADDLDFLAGS
])
AC_DEFUN(DC_CHK_OS_INFO, [
AC_DEFUN([DC_CHK_OS_INFO], [
AC_CANONICAL_HOST
AC_SUBST(SHOBJEXT)
AC_SUBST(SHOBJFLAGS)
AC_SUBST(SHOBJCPPFLAGS)
AC_SUBST(SHOBJLDFLAGS)
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(AREXT)
AC_SUBST(SHOBJFLAGS)
AC_SUBST(SHOBJLDFLAGS)
if test "$dc_cv_dc_chk_os_info_called" != '1'; then
dc_cv_dc_chk_os_info_called='1'
AC_MSG_CHECKING(host operating system)
AC_MSG_RESULT($host_os)
AC_MSG_CHECKING(host operating system)
AC_MSG_RESULT($host_os)
SHOBJEXT="so"
AREXT="a"
SHOBJEXT="so"
AREXT="a"
case $host_os in
darwin*)
SHOBJEXT="dylib"
;;
hpux*)
SHOBJEXT="sl"
;;
mingw*)
SHOBJEXT="dll"
SHOBJFLAGS="-mms-bitfields -DPIC"
SHOBJLDFLAGS='-shared -Wl,--dll -Wl,--enable-auto-image-base -Wl,--output-def,$[@].def,--out-implib,$[@].a'
;;
esac
case $host_os in
darwin*)
SHOBJEXT="dylib"
;;
hpux*)
case "$host_cpu" in
ia64)
SHOBJEXT="so"
;;
*)
SHOBJEXT="sl"
;;
esac
;;
aix[0-9].*)
SHOBJEXT="a"
;;
mingw32|mingw32msvc*)
SHOBJEXT="dll"
CFLAGS="$CFLAGS -mms-bitfields"
CPPFLAGS="$CPPFLAGS -mms-bitfields"
SHOBJCPPFLAGS="-DPIC"
SHOBJLDFLAGS='-shared -Wl,--dll -Wl,--enable-auto-image-base -Wl,--output-def,$[@].def,--out-implib,$[@].a'
;;
msvc)
SHOBJEXT="dll"
CFLAGS="$CFLAGS -nologo"
SHOBJCPPFLAGS='-DPIC'
SHOBJLDFLAGS='/LD /LINK /NODEFAULTLIB:MSVCRT'
;;
cygwin*)
SHOBJEXT="dll"
SHOBJFLAGS="-fPIC"
SHOBJCPPFLAGS="-DPIC"
CFLAGS="$CFLAGS -mms-bitfields"
CPPFLAGS="$CPPFLAGS -mms-bitfields"
SHOBJLDFLAGS='-shared -Wl,--enable-auto-image-base -Wl,--output-def,$[@].def,--out-implib,$[@].a'
;;
esac
fi
])
AC_DEFUN(SHOBJ_SET_SONAME, [
SAVE_LDFLAGS="$LDFLAGS"
AC_MSG_CHECKING([how to specify soname])
for try in "-Wl,--soname,$1" "Wl,-install_name,$1" '__fail__'; do
LDFLAGS="$SAVE_LDFLAGS"
if test "${try}" = '__fail__'; then
AC_MSG_RESULT([can't])
break
fi
LDFLAGS="${LDFLAGS} ${try}"
AC_TRY_LINK([void TestTest(void) { return; }], [], [
LDFLAGS="${SAVE_LDFLAGS}"
SHOBJLDFLAGS="${SHOBJLDFLAGS} ${try}"
AC_MSG_RESULT([$try])
break
])
done
AC_SUBST(SHOBJLDFLAGS)
])
|