-
Notifications
You must be signed in to change notification settings - Fork 32
/
configure.ac
440 lines (401 loc) · 17.2 KB
/
configure.ac
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
# This program is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program.
# If not, see <https://www.gnu.org/licenses/>.
#
# SPDX-FileCopyrightText: 2024 Arkadi Shishlov <arkadi.shishlov@gmail.com>
# SPDX-FileCopyrightText: 2008 Michael Kromer
# SPDX-License-Identifier: GPL-3.0-or-later
# targeting native build, cross-compile is surely broken
AC_INIT(codec_g72x, 1.4.4, http://groups.google.com/group/asterisk-g729)
saved_cflags="$CFLAGS"
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])
AC_CANONICAL_HOST
AC_PROG_INSTALL
AM_INIT_AUTOMAKE
AC_PROG_CC
AM_PROG_CC_C_O
AC_DISABLE_STATIC
LT_INIT
AC_CONFIG_MACRO_DIR([m4])
#echo cflags: "${saved_cflags}"
#echo host_os: "${host_os}"
#echo build_cpu: "${build_cpu}"
#echo prefix: "${prefix}"
#echo default_prefix: "${ac_default_prefix}"
case "${host_os}" in
freebsd*)
ac_default_prefix=/usr/local
;;
*)
ac_default_prefix=/usr
;;
esac
# tested on raspberry Pi, may be not valid for other ARM devices
case "${host}" in
armv6l-*-linux-gnueabihf*)
cflags="-mcpu=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp -O3 -Wall"
march="armv6zk"
;;
esac
if test "${prefix}" = "NONE"; then
prefix="${ac_default_prefix}"
fi
if test "${prefix}" != "/usr"; then
CPPFLAGS="$CPPFLAGS -I${prefix}/include"
fi
#echo new prefix: "${prefix}"
ASTERISK_VERSION="160";
AC_ARG_WITH(asterisk-includes,
AS_HELP_STRING([--with-asterisk-includes=PATH], [Path to Asterisk includes (defaults to PREFIX/include, so try --prefix first)]),
[ASTERISK_CFLAGS="-I\"$withval\""])
AC_ARG_WITH(asterisk14,
AS_HELP_STRING([--with-asterisk14], [Build for Asterisk 1.4]),
[ASTERISK_VERSION="14"])
AC_ARG_WITH(asterisk16,
AS_HELP_STRING([--with-asterisk16], [Build for Asterisk 1.6]),
[ASTERISK_VERSION="16"])
AC_ARG_WITH(asterisk18,
AS_HELP_STRING([--with-asterisk18], [Build for Asterisk 1.8]),
[ASTERISK_VERSION="18"])
AC_ARG_WITH(asterisk100,
AS_HELP_STRING([--with-asterisk100], [Build for Asterisk 10, 11, 12]),
[ASTERISK_VERSION="100"])
AC_ARG_WITH(asterisk130,
AS_HELP_STRING([--with-asterisk130], [Build for Asterisk 13]),
[ASTERISK_VERSION="130"])
AC_ARG_WITH(asterisk140,
AS_HELP_STRING([--with-asterisk140], [Build for Asterisk 14]),
[ASTERISK_VERSION="140"])
AC_ARG_WITH(asterisk150,
AS_HELP_STRING([--with-asterisk150], [Build for Asterisk 15]),
[ASTERISK_VERSION="150"])
AC_ARG_WITH(asterisk160,
AS_HELP_STRING([--with-asterisk160], [Build for Asterisk 16+ (the default)]),
[ASTERISK_VERSION="160"])
AC_ARG_WITH(ipp,
AS_HELP_STRING([--with-ipp=PATH], [Path to Intel IPP (/path/to/ipp)]),
[ipp_root="$withval"])
AC_ARG_WITH(g729nofp,
AS_HELP_STRING([--with-g729nofp], [Use integer (no floating point) version of G.729 IPP codec (marginally faster on AMD Geode CPU)]),
[G72X_9_NOFP="-DG72X_9_NOFP"])
AC_ARG_WITH(bcg729,
AS_HELP_STRING([--with-bcg729], [Build against Bcg729 library; without G.723.1]),
[G72X_BCG729="-DG72X_BCG729"; CPPFLAGS="$CPPFLAGS -I/usr/local/include"; LDFLAGS="$LDFLAGS -L/usr/local/lib"])
# http://software.intel.com/en-us/articles/intel-integrated-performance-primitives-intel-ipp-understanding-cpu-optimized-code-used-in-intel-ipp/
# http://software.intel.com/sites/products/documentation/doclib/ipp_sa/71/ipp_userguide_lnx/GUID-BABCDBB5-E674-4ECF-AE3A-4945274FDA80.htm
# IPP cores are:
# 32-bit
# px - pentium mmx
# a6 - pentium3 sse (removed in IPP 6.0)
# w7 - pentium4 sse2
# t7 - pentium4 prescott sse3 (removed in IPP 7.0)
# v8 - core2 ssse3
# p8 - core2 penryn sse4.1, core i7 nehalem sse4.2 & westmere aes-ni mini-dispatcher
# s8 - atom ssse3
# g9 - sandy bridge avx
# h9 - haswell avx2
# 64-bit
# mx - older amd64 w/o sse3?
# m7 - pentium4 prescott sse3 em64t
# u8 - core2 ssse3
# y8 - core2 penryn sse4.1, core i7 nehalem sse4.2 & westmere aes-ni mini-dispatcher
# n8 - atom ssse3
# e9 - sandy bridge avx
# l9 - haswell avx2
# i7 - itanium
# sse3 ssse3 sse4.1
# k8 w/o sse3
# k8 +
# k10 +
# prescott +
# core2 + +
# penryn + + +
# atom + + +
AC_CHECK_HEADERS([asterisk/asterisk.h], [ASTERISK_ASTERISK_H=-DASTERISK_ASTERISK_H])
AX_CHECK_COMPILER_FLAGS(-march=native, [march=native])
AX_CHECK_COMPILER_FLAGS(-mavx, [mavx=-mavx], [mavx=""])
AX_CHECK_COMPILER_FLAGS(-march=core2, [march_core2=core2], [march_core2=nocona])
AX_CHECK_COMPILER_FLAGS(-march=atom, [march_atom=atom], [march_core2=$march_core2; mtune_generic=-mtune=generic])
AX_CHECK_COMPILER_FLAGS(-march=k8-sse3, [march_k8_sse3=k8-sse3], [march_k8_sse3=k8])
AX_CHECK_COMPILER_FLAGS(-march=barcelona, [march_k10=barcelona], [march_k10=$march_k8_sse3])
AX_CHECK_COMPILER_FLAGS(-march=geode, [march_geode=geode], [march_geode=k6-3; mtune_generic=-mtune=generic])
if test "$CC" = "icc"; then
if test -z "$CFLAGS"; then
AC_MSG_ERROR([For ICC please set CFLAGS])
fi
flto=-ipo
else
AX_CHECK_COMPILER_FLAGS(-flto, [flto="-flto"; fwholeprg="-fwhole-program"])
fi
AC_ARG_ENABLE([barcelona],
AS_HELP_STRING([--enable-barcelona],
[Optimize for AMD K10/Opteron/Phenom (enables SSE3)]),
[march=$march_k10; ipp_core=t7; ipp_core64=m7; cflags="-msse3 -mfpmath=sse"])
AC_ARG_ENABLE([opteron-sse3],
AS_HELP_STRING([--enable-opteron-sse3],
[Optimize for AMD K8/Opteron/Athlon64 (enables SSE3)]),
[march=$march_k8_sse3; ipp_core=t7; ipp_core64=m7; cflags="-msse3 -mfpmath=sse"])
AC_ARG_ENABLE([opteron],
AS_HELP_STRING([--enable-opteron],
[Optimize for AMD K8/Opteron/Athlon64 (enables SSE2)]),
[march=k8; ipp_core=w7; ipp_core64=mx; cflags="-msse2 -mfpmath=sse"])
AC_ARG_ENABLE([athlon],
AS_HELP_STRING([--enable-athlon], [Optimize for AMD K7/Athlon-XP (enables SSE)]),
[march=athlon-xp; ipp_core=a6; cflags="-msse -mfpmath=sse"])
AC_ARG_ENABLE([geode],
AS_HELP_STRING([--enable-geode], [Optimize for AMD Geode LX]),
[march=$march_geode; ipp_core=px; ipp_cdefs=-DIPPCORE_NO_SSE; cflags="$mtune_generic"])
AC_ARG_ENABLE([avx],
AS_HELP_STRING([--enable-avx], [Optimize for Intel Sandy Bridge (enables AVX)]),
[march=$march_core2; ipp_core=g9; ipp_core64=e9; cflags="$mavx"])
AC_ARG_ENABLE([penryn],
AS_HELP_STRING([--enable-penryn], [Optimize for Intel Core2 Penryn and Core i7 Nehalem/Westmere (enables SSE4.1)]),
[march=$march_core2; ipp_core=p8; ipp_core64=y8; cflags="-msse3 -mfpmath=sse"])
AC_ARG_ENABLE([core2],
AS_HELP_STRING([--enable-core2], [Optimize for Intel Core2 (enables SSE3 and SSSE3)]),
[march=$march_core2; ipp_core=v8; ipp_core64=u8; cflags="-msse3 -mfpmath=sse"])
AC_ARG_ENABLE([atom],
AS_HELP_STRING([--enable-atom], [Optimize for Intel Atom (enables SSE4.1)]),
[march=$march_core2; ipp_core=s8; ipp_core64=n8; cflags="-mtune=generic -msse3 -mfpmath=sse"])
AC_ARG_ENABLE([nocona],
AS_HELP_STRING([--enable-nocona], [Optimize for Intel Pentium4 Prescott and Nocona (enables SSE3)]),
[march=nocona; ipp_core=t7; ipp_core64=m7; cflags="-msse3 -mfpmath=sse"])
AC_ARG_ENABLE([pentium4],
AS_HELP_STRING([--enable-pentium4], [Optimize for Intel Pentium4 (enables SSE2)]),
[march=pentium4; ipp_core=w7; cflags="-msse2 -mfpmath=sse"])
AC_ARG_ENABLE([pentiumm],
AS_HELP_STRING([--enable-pentiumm], [Optimize for Intel PentiumM (enables SSE2)]),
[march=pentium-m; ipp_core=w7; cflags="-msse2 -mfpmath=sse"])
AC_ARG_ENABLE([pentium3],
AS_HELP_STRING([--enable-pentium3], [Optimize for Intel Pentium3 (enables SSE)]),
[march=pentium3; ipp_core=a6; cflags="-msse -mfpmath=sse"])
AC_ARG_ENABLE([pentium2],
AS_HELP_STRING([--enable-pentium2], [Optimize for Intel Pentium2]),
[march=pentium2; ipp_core=px; ipp_cdefs=-DIPPCORE_NO_SSE; cflags=""])
AC_ARG_ENABLE([pentium],
AS_HELP_STRING([--enable-pentium], [Optimize for Intel Pentium]),
[march=pentium-mmx; ipp_core=px; ipp_cdefs=-DIPPCORE_NO_SSE; cflags=""])
if test -z "$G72X_BCG729"; then
if test -z "$ipp_core"; then
AC_CHECK_FILE([/proc/cpuinfo],
[cpu_features="`grep -iE ^flags /proc/cpuinfo|cut -f2 -d:|head -1`"],
[AC_MSG_ERROR([unable to determine CPU features, use --enable-pentium/etc. to choose the core])])
for f in $cpu_features; do
eval "cpu_feature_$f=1"
done
AC_MSG_CHECKING([host CPU features])
if grep -iE '^model name.* Atom' /proc/cpuinfo >/dev/null; then
ipp_core=s8; ipp_core64=n8;
elif test -n "$cpu_feature_avx"; then
ipp_core=g9; ipp_core64=e9;
elif test -n "$cpu_feature_sse4_1"; then
ipp_core=p8; ipp_core64=y8;
elif test -n "$cpu_feature_ssse3"; then
ipp_core=v8; ipp_core64=u8;
elif test -n "$cpu_feature_pni"; then
ipp_core=t7; ipp_core64=m7;
elif test -n "$cpu_feature_sse2"; then
ipp_core=w7; ipp_core64=mx;
elif test -n "$cpu_feature_sse"; then
ipp_core=a6;
elif test -n "$cpu_feature_mmx"; then
ipp_core=px;
else
AC_MSG_ERROR([unable to choose IPP core, use --enable-pentium/etc. to select one])
fi
if test "$ipp_core" = "px"; then
ipp_cdefs=-DIPPCORE_NO_SSE
fi
AC_MSG_RESULT([$cpu_features])
fi
if test -z "$saved_cflags" -a -z "$march"; then
AC_MSG_ERROR([compiler does not support -march=native, use --enable-pentium/etc. to choose the core, or set CFLAGS])
fi
case "$build_cpu" in
i?86)
ipp_arch=ia32;
;;
x86_64|amd64)
ipp_arch=em64t;
;;
esac
if test -z "$ipp_root"; then
AC_MSG_CHECKING([location of IPP libraries])
with_ipp_to_override=" (use --with-ipp=/path/to/ipp to override)"
ipp_dir="/opt/intel/ipp"
if test -d "$ipp_dir/"; then
ipp_root="$ipp_dir"
fi
if test -z "$ipp_root"; then
# IPP 7.0, 8.0
ipp_dir="/opt/intel/composerxe/ipp"
if test -d "$ipp_dir/"; then
ipp_root="$ipp_dir"
fi
fi
if test -z "$ipp_root"; then
# 5.3-6.1
case $ipp_core in
# Pentium-Pentium3 prefer IPP 5.3
px|a6)
ipp_versions="5.3 6.1 6.0"
;;
*)
ipp_versions="6.1 6.0 5.3"
;;
esac
for ipp_ver in $ipp_versions; do
ipp_dir="`echo /opt/intel/ipp/${ipp_ver}*/$ipp_arch`"
if test -d "$ipp_dir"; then
ipp_root="$ipp_dir"
break
fi
done
fi
AC_MSG_RESULT([$ipp_root])
if test -z "$ipp_root"; then
AC_MSG_ERROR([IPP not found - use --with-ipp=/path/to/ipp to specify])
fi
fi
ipp_version_h="$ipp_root"/include/ippversion.h
if test ! -f "$ipp_version_h"; then
AC_MSG_ERROR([IPP $ipp_version_h not found])
fi
AC_MSG_CHECKING([version of IPP libraries])
ipp_major=$(grep IPP_VERSION_MAJOR "$ipp_version_h" | awk '{print $3}')
ipp_minor=$(grep IPP_VERSION_MINOR "$ipp_version_h" | awk '{print $3}')
ipp_ver=$ipp_major.$ipp_minor
AC_MSG_RESULT([$ipp_ver])
if test $ipp_major -ge 7 -a "$ipp_arch" = "em64t"; then
ipp_arch=intel64
fi
case $ipp_core in
# Pentium3 a6 removed in IPP 6.0
a6)
if test "$ipp_ver" != "5.3"; then
if test "$ipp_ver" != "6.0" -a "$ipp_ver" != "6.1"; then
AC_MSG_ERROR([Use IPP 5.3 (preferred) or 6.1 for Pentium3])
fi
ipp_core=px
use_ipp53=" (slower MMX core used, use IPP 5.3 for SSE instead)"
fi
;;
s8)
if test "$ipp_ver" = "5.3"; then
ipp_core=v8; ipp_core64=u8
use_ipp60=" (Core2 scheduling used, IPP $ipp_ver does not support Atom, use IPP 6.0 or later instead)"
fi
;;
# 32-bit SSE3 removed in 7.0
t7)
if test $ipp_major -ge 7; then
ipp_core=w7;
case "$build_cpu" in
i?86)
use_ipp60=" (SSE2 core, use IPP 6.1 for SSE3)"
;;
esac;
fi
;;
# check missing staticlib/ include
g9)
if test $ipp_major -lt 7; then
AC_MSG_ERROR([Use IPP 7.0+ for Sandy Bridge AVX])
fi
case "$build_cpu" in
i?86)
staticlib_inc="$ipp_root/tools/$ipp_arch/staticlib/ipp_$ipp_core.h"
;;
x86_64|amd64)
staticlib_inc="$ipp_root/tools/$ipp_arch/staticlib/ipp_$ipp_core64.h"
;;
esac;
if ! test -f "$staticlib_inc"; then
AC_MSG_ERROR([Create "$staticlib_inc" manually as described in http://software.intel.com/en-us/articles/How-to-call-AVX-based-code-in-IPP-v-6-1/])
fi
;;
esac
IPP_CFLAGS="-I\"$ipp_root/include\" $ipp_cdefs";
if test $ipp_major -ge 9; then
# need IPP Legacy to build speech codecs
AC_MSG_CHECKING([for legacy IPP 9.0 libraries])
ipp_legacy_h="$ipp_root"/legacy/include/ipps90legacy.h
if test ! -f "$ipp_legacy_h"; then
AC_MSG_ERROR([IPP $ipp_legacy_h not found])
fi
ipp_legacy_libsvml="$ipp_root"/legacy/lib/$ipp_arch/libsvml.a
if test ! -f "$ipp_legacy_libsvml"; then
AC_MSG_ERROR([IPP $ipp_legacy_libsvml not found])
fi
AC_MSG_RESULT([$ipp_legacy_h $ipp_legacy_libsvml])
IPP_CFLAGS="$IPP_CFLAGS -DG72X_IPP_LEGACY -I\"$ipp_root/legacy/include\" -Wno-deprecated-declarations";
IPP_LIBS="$ipp_root/legacy/lib/$ipp_arch/libippsc90lgc.a $ipp_root/legacy/lib/$ipp_arch/libipps90lgc.a $ipp_root/lib/$ipp_arch/libipps.a $ipp_root/lib/$ipp_arch/libippvm.a $ipp_root/lib/$ipp_arch/libippcore.a $ipp_root/legacy/lib/$ipp_arch/libirc.a $ipp_root/legacy/lib/$ipp_arch/libsvml.a"
elif test $ipp_major -eq 8; then
IPP_LIBS="$ipp_root/lib/$ipp_arch/libippsc.a $ipp_root/lib/$ipp_arch/libipps.a $ipp_root/lib/$ipp_arch/libippvm.a $ipp_root/lib/$ipp_arch/libippcore.a $ipp_root/../compiler/lib/$ipp_arch/libirc.a $ipp_root/../compiler/lib/$ipp_arch/libsvml.a"
elif test $ipp_major -eq 7; then
IPP_LIBS="-lippsc_l -lipps_l -lippcore_l"
IPP_LDFLAGS="-L\"$ipp_root/lib/$ipp_arch\"";
else
IPP_LDFLAGS="-L\"$ipp_root/lib\"";
fi
case "$build_cpu" in
i?86)
if test $ipp_major -ge 7; then
IPP_CFLAGS="$IPP_CFLAGS -include \"$ipp_root/tools/$ipp_arch/staticlib/ipp_$ipp_core.h\""
else
IPP_CFLAGS="$IPP_CFLAGS -include \"$ipp_root/tools/staticlib/ipp_$ipp_core.h\""
IPP_LIBS="-lippscmerged -lippsrmerged -lippsmerged -lippcore"
fi
;;
x86_64|amd64)
# IPP 5.3 does not have tools/staticlib helpers
if test "$ipp_ver" = "5.3"; then
IPP_CFLAGS="$IPP_CFLAGS -DIPPCORE_STATIC_INIT"
IPP_LIBS="-lippscemergedem64t -lippsremergedem64t -lippsemergedem64t -lippscmergedem64t -lippsrmergedem64t -lippsmergedem64t -lippcoreem64t"
elif test $ipp_major -ge 7; then
IPP_CFLAGS="$IPP_CFLAGS -include \"$ipp_root/tools/$ipp_arch/staticlib/ipp_$ipp_core64.h\""
else # 6.x
IPP_CFLAGS="$IPP_CFLAGS -include \"$ipp_root/tools/staticlib/ipp_$ipp_core64.h\""
IPP_LIBS="-lippscmergedem64t -lippsrmergedem64t -lippsmergedem64t -lippcoreem64t"
fi
ipp_core=$ipp_core64 # for output
;;
esac
else # G72X_BCG729 is defined
AC_CHECK_LIB([bcg729], [initBcg729EncoderChannel], [], [AC_MSG_ERROR([unable to find Bcg729 library])])
fi
if test -z "$saved_cflags"; then
CFLAGS="-O3 -fomit-frame-pointer -march=$march $flto $cflags"
FLTO_LDFLAGS="$fwholeprg"
fi
AM_CONDITIONAL([BCG729], [test -n "$G72X_BCG729"])
AM_CONDITIONAL([G729_NOFP], [test -n "$G72X_9_NOFP" -a -z "$G72X_BCG729"])
AC_SUBST([ASTERISK_ASTERISK_H])
AC_SUBST([ASTERISK_CFLAGS])
AC_SUBST([ASTERISK_VERSION])
AC_SUBST([IPP_CFLAGS])
AC_SUBST([IPP_LDFLAGS])
AC_SUBST([IPP_LIBS])
AC_SUBST([FLTO_LDFLAGS])
AC_SUBST([G72X_BCG729])
AC_SUBST([G72X_9_NOFP])
AC_OUTPUT()
echo
echo "Architecture: $build_cpu"
echo " CPU -march: $march"
echo " CFLAGS: $CFLAGS $IPP_CFLAGS $ASTERISK_CFLAGS"
echo " LDFLAGS: $FLTO_LDFLAGS" $IPP_LDFLAGS $IPP_LIBS
echo " Codecs impl:" $(test -z "$G72X_BCG729" && echo IPP || echo Bcg729) $(test -z "$G729_NOFP_TRUE" && echo "/ G.729 integer codec")
if test -z "$G72X_BCG729"; then
echo " IPP path: $ipp_root$with_ipp_to_override"
echo " IPP ver.: $ipp_ver"
echo " IPP core: $ipp_core$use_ipp53$use_ipp60"
fi