-
Notifications
You must be signed in to change notification settings - Fork 319
/
configure.in
249 lines (216 loc) · 6.89 KB
/
configure.in
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
dnl init
dnl AC_REVISION($Revision: 1.30 $)
AC_PREREQ([2.60])
AC_INIT([chan_dongle],[1.1],[https://github.com/bg111/asterisk-chan-dongle/issues],[chan_dongle],[https://github.com/bg111/asterisk-chan-dongle/])
PACKAGE_REVISION="43gh=47cg"
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([chan_dongle.c])
AC_CANONICAL_SYSTEM
AC_CANONICAL_HOST
dnl AM_INIT_AUTOMAKE
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
dnl Checks for user settings.
dnl Set asterisk headers patch
AC_ARG_WITH(
[asterisk],
AS_HELP_STRING([--with-asterisk=path], [set asterisk headers location]),
[ if test "x$with_asterisk" = "xyes" -o "x$with_asterisk" = "xno" ; then AC_MSG_ERROR([Invalid --with-asterisk=path value]); fi ],
[ with_asterisk="../include /usr/include /usr/local/include /opt/local/include" ]
)
AC_ARG_ENABLE(
[debug],
AS_HELP_STRING([--enable-debug], [enable code debugging]),
[ if test "x$enable_debug" != "xyes" ; then enable_debug="no" ; fi],
[ enable_debug="no"]
)
dnl Optionally disable manager.
AC_ARG_ENABLE(
[manager],
AS_HELP_STRING([--enable-manager], [enable manager code]),
[ if test "x$enable_manager" != "xyes" ; then enable_manager="no" ; fi ],
[ enable_manager="yes" ]
)
dnl Optionally disable applications
AC_ARG_ENABLE(
[apps],
AS_HELP_STRING([--enable-apps], [enable applications code]),
[ if test "x$enable_apps" != "xyes" ; then enable_apps="no" ; fi],
[ enable_apps="yes" ]
)
dnl Checks for programs.
AC_PROG_CC([gcc cl cc])
AC_PROG_CPP
AC_PROG_INSTALL
AC_CHECK_PROG(STRIP,strip,strip)
if test -z "$STRIP" ; then
AC_MSG_ERROR([Can't find strip])
fi
AC_CHECK_PROG(RM,rm,rm)
if test -z "$RM" ; then
AC_MSG_ERROR([Can't find rm])
fi
dnl Checks for libraries.
dnl AC_CHECK_LIB([pthread], [pthread_create])
dnl AC_CHECK_LIB([iconv], [iconv])
AC_SEARCH_LIBS([iconv], [c iconv])
dnl Checks for header files.
AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h termios.h])
AC_DEFUN([AC_HEADER_FIND], [
file=$1
for path in $2 ; do
AC_MSG_CHECKING([whether $file in $path])
if test -f $path/$file ; then
found="yes"
CPPFLAGS="$CPPFLAGS -I${path}"
AC_MSG_RESULT([yes])
AC_CHECK_HEADER([$file])
break;
else
AC_MSG_RESULT([no])
fi
done
if test -z "$found" ; then
AC_MSG_ERROR([Can't find "$file"])
fi
]
)
AC_HEADER_FIND([asterisk.h], $with_asterisk)
AC_HEADER_FIND([iconv.h], /usr/include /usr/local/include /opt/local/include)
AC_DEFINE([ICONV_CONST],[], [Define to const if you has iconv() const declaration of input buffer])
AC_MSG_CHECKING([for iconv use const inbuf])
AC_EGREP_HEADER([^extern.+iconv[[:space:]]*\(.+const], [iconv.h],
[
AC_DEFINE([ICONV_CONST],[const])
AC_MSG_RESULT([yes])
],
[AC_MSG_RESULT([no])]
)
AC_MSG_CHECKING([for iconv_t in iconv.h])
AC_EGREP_HEADER([iconv_t], [iconv.h],
[
AC_DEFINE([ICONV_T], [iconv_t], , [Define to iconv_t if you has iconv_t in iconv.h])
AC_MSG_RESULT(yes)
],
[
AC_DEFINE([ICONV_T], [int], [Define to iconv_t if you has iconv_t in iconv.h])
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING([for AST_CONTROL_SRCCHANGE in asterisk/frame.h])
AC_EGREP_HEADER([AST_CONTROL_SRCCHANGE], [asterisk/frame.h],
[
AC_DEFINE([HAVE_AST_CONTROL_SRCCHANGE], [], [Define to 1 if you have HAVE_AST_CONTROL_SRCCHANGE in asterisk/frame.h])
AC_MSG_RESULT([yes])
],
[AC_MSG_RESULT([no])]
)
dnl Checking for library options
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT64_T
dnl AC_CHECK_TYPE(size_t, unsigned long)
dnl AC_CHECK_TYPE(ssize_t, long)
dnl AC_CHECK_TYPE(uint64_t, unsigned long long)
dnl checking compiler options
AC_DEFUN([AC_CC_OPT], [
my_save_cflags="$CFLAGS"
CFLAGS="$1"
AC_MSG_CHECKING([whether CC supports $1])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[AC_CFLAGS="$AC_CFLAGS $2"],
[AC_MSG_RESULT([no])]
)
CFLAGS="$my_save_cflags"]
)
AC_CFLAGS=
my_save_cflags="$CFLAGS"
CFLAGS=-fvisibility=hidden
AC_MSG_CHECKING([whether CC supports -fvisibility=hidden])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[TARGET="chan_dongle.so"]
[AC_CFLAGS="$AC_CFLAGS -fvisibility=hidden"],
[AC_MSG_RESULT([no])]
[TARGET="chan_dongles.so"]
)
CFLAGS="$my_save_cflags"
AC_SUBST([TARGET])
AC_CC_OPT([-fPIC],[-fPIC])
AC_CC_OPT([-Wall],[-Wall])
AC_CC_OPT([-Wextra],[-Wextra])
AC_CC_OPT([-MD -MT conftest.o -MF /dev/null -MP],[-MD -MT \$@ -MF .\$(subst /,_,\$@).d -MP])
AC_DEFUN([AC_CHECK_DESTDIR], [
if test -z "$DESTDIR" ; then
for path in $1 ; do
AC_MSG_CHECKING([whether DESTDIR is $path])
if test -f $path/pbx_config.so ; then
AC_MSG_RESULT([yes])
found="yes"
DESTDIR=$path
break;
else
AC_MSG_RESULT([no])
fi
done
if test -z "$found" ; then
AC_MSG_ERROR(DESTDIR is unknown, please explicite set like DESTDIR=/usr/lib/asterisk/modules ./configure)
fi
fi
])
AC_CHECK_DESTDIR([/usr/lib/asterisk/modules /usr/local/lib/asterisk/modules /opt/local/lib/asterisk/modules])
dnl Checks for library functions.
AC_FUNC_MEMCMP
AC_CHECK_FUNCS([memchr memmove memset memmem strcasecmp strchr strncasecmp strtol realpath])
dnl Apply options to defines
if test "x$enable_debug" = "xyes" ; then
CFLAGS="$CFLAGS -O0 -g"
AC_DEFINE([__DEBUG__], [1], [Build with debugging])
else
CFLAGS="$CFLAGS -O6"
fi
if test "x$enable_manager" = "xyes" ; then
AC_DEFINE([BUILD_MANAGER],[1], [Build Manager extentions])
fi
if test "x$enable_apps" = "xyes" ; then
AC_DEFINE([BUILD_APPLICATIONS],[1],[Build extention applications])
fi
case "$target_os" in
linux*)
SOLINK="-shared -Xlinker -x"
DC_LDFLAGS=""
;;
freebsd*)
SOLINK="-shared -Xlinker -x"
DC_LDFLAGS="-L/usr/local/lib"
;;
openbsd*)
SOLINK="-shared -Xlinker -x"
DC_LDFLAGS="-L/usr/local/lib -pthread"
AC_CFLAGS="$AC_CFLAGS -pthread"
;;
darwin*)
SOLINK="-dynamic -bundle -Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace"
DC_LDFLAGS="-L/opt/local/lib"
[ `/usr/bin/sw_vers -productVersion | cut -c1-4` == "10.6" ] && SOLINK="$SOLINK /usr/lib/bundle1.o"
esac
LDFLAGS="$LDFLAGS $DC_LDFLAGS"
dnl AC_DEFINE_UNQUOTED([MODULE_], "$PACKAGE_", [])
dnl AC_DEFINE_UNQUOTED([MODULE_], "$PACKAGE_", [])
AC_DEFINE_UNQUOTED([MODULE_BUGREPORT], "$PACKAGE_BUGREPORT", [Define to the address where bug reports for this package should be sent])
AC_DEFINE_UNQUOTED([MODULE_URL], "$PACKAGE_URL", [Define to the home page for this package])
AC_DEFINE_UNQUOTED([MODULE_VERSION], "$PACKAGE_VERSION", [Define to the version of this package])
AC_DEFINE_UNQUOTED([AST_MODULE],"$PACKAGE_NAME",[name of asterisk module])
AC_DEFINE_UNQUOTED([PACKAGE_REVISION], "$PACKAGE_REVISION",[Revision of package])
AC_SUBST([SOLINK])
AC_SUBST([PACKAGE_TARNAME])
AC_SUBST([PACKAGE_REVISION])
AC_SUBST([PACKAGE_VERSION])
AC_SUBST([DESTDIR])
AC_SUBST([AC_CFLAGS])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT