Skip to content

Commit 4013bfa

Browse files
committed
configure: Add autoconf check for libopusfile.
This check is being added to make it easier for end-users of third party open source Opus modules. This was removed by ASTERISK-26426 but only the module needed to be removed. Change-Id: I62b9cd0c4fa8a77596ab0e042948a643a1152677
1 parent 325b5dd commit 4013bfa

File tree

5 files changed

+163
-0
lines changed

5 files changed

+163
-0
lines changed

build_tools/menuselect-deps.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ NEON29=@PBX_NEON29@
4545
OGG=@PBX_OGG@
4646
OPENH323=@PBX_OPENH323@
4747
OPUS=@PBX_OPUS@
48+
OPUSFILE=@PBX_OPUSFILE@
4849
OSPTK=@PBX_OSPTK@
4950
OSS=@PBX_OSS@
5051
PGSQL=@PBX_PGSQL@

configure

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,10 @@ PBX_OSPTK
10081008
OSPTK_DIR
10091009
OSPTK_INCLUDE
10101010
OSPTK_LIB
1011+
PBX_OPUSFILE
1012+
OPUSFILE_DIR
1013+
OPUSFILE_INCLUDE
1014+
OPUSFILE_LIB
10111015
PBX_OPUS
10121016
OPUS_DIR
10131017
OPUS_INCLUDE
@@ -1435,6 +1439,7 @@ with_newt
14351439
with_ogg
14361440
with_openr2
14371441
with_opus
1442+
with_opusfile
14381443
with_osptk
14391444
with_oss
14401445
with_postgres
@@ -2191,6 +2196,7 @@ Optional Packages:
21912196
--with-ogg=PATH use OGG files in PATH
21922197
--with-openr2=PATH use MFR2 files in PATH
21932198
--with-opus=PATH use Opus files in PATH
2199+
--with-opusfile=PATH use Opusfile files in PATH
21942200
--with-osptk=PATH use OSP Toolkit files in PATH
21952201
--with-oss=PATH use Open Sound System files in PATH
21962202
--with-postgres=PATH use PostgreSQL files in PATH
@@ -11357,6 +11363,38 @@ fi
1135711363

1135811364

1135911365

11366+
OPUSFILE_DESCRIP="Opusfile"
11367+
OPUSFILE_OPTION="opusfile"
11368+
PBX_OPUSFILE=0
11369+
11370+
# Check whether --with-opusfile was given.
11371+
if test "${with_opusfile+set}" = set; then :
11372+
withval=$with_opusfile;
11373+
case ${withval} in
11374+
n|no)
11375+
USE_OPUSFILE=no
11376+
# -1 is a magic value used by menuselect to know that the package
11377+
# was disabled, other than 'not found'
11378+
PBX_OPUSFILE=-1
11379+
;;
11380+
y|ye|yes)
11381+
ac_mandatory_list="${ac_mandatory_list} OPUSFILE"
11382+
;;
11383+
*)
11384+
OPUSFILE_DIR="${withval}"
11385+
ac_mandatory_list="${ac_mandatory_list} OPUSFILE"
11386+
;;
11387+
esac
11388+
11389+
fi
11390+
11391+
11392+
11393+
11394+
11395+
11396+
11397+
1136011398
OSPTK_DESCRIP="OSP Toolkit"
1136111399
OSPTK_OPTION="osptk"
1136211400
PBX_OSPTK=0
@@ -30426,6 +30464,116 @@ _ACEOF
3042630464
fi
3042730465

3042830466

30467+
# opusfile.h includes <opus_multistream.h> so we need to make sure that
30468+
# either $OPUS_INCLUDE or /usr/include/opus is added to the search path.
30469+
__opus_include=${OPUS_INCLUDE}
30470+
if test -z "$__opus_include" -o x"$__opus_include" = x" " ; then
30471+
__opus_include=-I/usr/include/opus
30472+
fi
30473+
30474+
if test "x${PBX_OPUSFILE}" != "x1" -a "${USE_OPUSFILE}" != "no"; then
30475+
pbxlibdir=""
30476+
# if --with-OPUSFILE=DIR has been specified, use it.
30477+
if test "x${OPUSFILE_DIR}" != "x"; then
30478+
if test -d ${OPUSFILE_DIR}/lib; then
30479+
pbxlibdir="-L${OPUSFILE_DIR}/lib"
30480+
else
30481+
pbxlibdir="-L${OPUSFILE_DIR}"
30482+
fi
30483+
fi
30484+
pbxfuncname="op_open_callbacks"
30485+
if test "x${pbxfuncname}" = "x" ; then # empty lib, assume only headers
30486+
AST_OPUSFILE_FOUND=yes
30487+
else
30488+
ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
30489+
CFLAGS="${CFLAGS} $__opus_include"
30490+
as_ac_Lib=`$as_echo "ac_cv_lib_opusfile_${pbxfuncname}" | $as_tr_sh`
30491+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${pbxfuncname} in -lopusfile" >&5
30492+
$as_echo_n "checking for ${pbxfuncname} in -lopusfile... " >&6; }
30493+
if eval \${$as_ac_Lib+:} false; then :
30494+
$as_echo_n "(cached) " >&6
30495+
else
30496+
ac_check_lib_save_LIBS=$LIBS
30497+
LIBS="-lopusfile ${pbxlibdir} $LIBS"
30498+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
30499+
/* end confdefs.h. */
30500+
30501+
/* Override any GCC internal prototype to avoid an error.
30502+
Use char because int might match the return type of a GCC
30503+
builtin and then its argument prototype would still apply. */
30504+
#ifdef __cplusplus
30505+
extern "C"
30506+
#endif
30507+
char ${pbxfuncname} ();
30508+
int
30509+
main ()
30510+
{
30511+
return ${pbxfuncname} ();
30512+
;
30513+
return 0;
30514+
}
30515+
_ACEOF
30516+
if ac_fn_c_try_link "$LINENO"; then :
30517+
eval "$as_ac_Lib=yes"
30518+
else
30519+
eval "$as_ac_Lib=no"
30520+
fi
30521+
rm -f core conftest.err conftest.$ac_objext \
30522+
conftest$ac_exeext conftest.$ac_ext
30523+
LIBS=$ac_check_lib_save_LIBS
30524+
fi
30525+
eval ac_res=\$$as_ac_Lib
30526+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
30527+
$as_echo "$ac_res" >&6; }
30528+
if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
30529+
AST_OPUSFILE_FOUND=yes
30530+
else
30531+
AST_OPUSFILE_FOUND=no
30532+
fi
30533+
30534+
CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
30535+
fi
30536+
30537+
# now check for the header.
30538+
if test "${AST_OPUSFILE_FOUND}" = "yes"; then
30539+
OPUSFILE_LIB="${pbxlibdir} -lopusfile "
30540+
# if --with-OPUSFILE=DIR has been specified, use it.
30541+
if test "x${OPUSFILE_DIR}" != "x"; then
30542+
OPUSFILE_INCLUDE="-I${OPUSFILE_DIR}/include"
30543+
fi
30544+
OPUSFILE_INCLUDE="${OPUSFILE_INCLUDE} $__opus_include"
30545+
if test "xopus/opusfile.h" = "x" ; then # no header, assume found
30546+
OPUSFILE_HEADER_FOUND="1"
30547+
else # check for the header
30548+
ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
30549+
CPPFLAGS="${CPPFLAGS} ${OPUSFILE_INCLUDE}"
30550+
ac_fn_c_check_header_mongrel "$LINENO" "opus/opusfile.h" "ac_cv_header_opus_opusfile_h" "$ac_includes_default"
30551+
if test "x$ac_cv_header_opus_opusfile_h" = xyes; then :
30552+
OPUSFILE_HEADER_FOUND=1
30553+
else
30554+
OPUSFILE_HEADER_FOUND=0
30555+
fi
30556+
30557+
30558+
CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
30559+
fi
30560+
if test "x${OPUSFILE_HEADER_FOUND}" = "x0" ; then
30561+
OPUSFILE_LIB=""
30562+
OPUSFILE_INCLUDE=""
30563+
else
30564+
if test "x${pbxfuncname}" = "x" ; then # only checking headers -> no library
30565+
OPUSFILE_LIB=""
30566+
fi
30567+
PBX_OPUSFILE=1
30568+
cat >>confdefs.h <<_ACEOF
30569+
#define HAVE_OPUSFILE 1
30570+
_ACEOF
30571+
30572+
fi
30573+
fi
30574+
fi
30575+
30576+
3042930577

3043030578
if test "${USE_PWLIB}" != "no"; then
3043130579
if test -n "${PWLIB_DIR}"; then

configure.ac

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ AST_EXT_LIB_SETUP([NEWT], [newt], [newt])
503503
AST_EXT_LIB_SETUP([OGG], [OGG], [ogg])
504504
AST_EXT_LIB_SETUP([OPENR2], [MFR2], [openr2])
505505
AST_EXT_LIB_SETUP([OPUS], [Opus], [opus])
506+
AST_EXT_LIB_SETUP([OPUSFILE], [Opusfile], [opusfile])
506507
AST_EXT_LIB_SETUP([OSPTK], [OSP Toolkit], [osptk])
507508
AST_EXT_LIB_SETUP([OSS], [Open Sound System], [oss])
508509
AST_EXT_LIB_SETUP([PGSQL], [PostgreSQL], [postgres])
@@ -2350,6 +2351,13 @@ AST_EXT_LIB_CHECK([SS7], [ss7], [ss7_set_isup_timer], [libss7.h])
23502351
AST_EXT_LIB_CHECK([OPENR2], [openr2], [openr2_chan_new], [openr2.h])
23512352

23522353
AST_EXT_LIB_CHECK([OPUS], [opus], [opus_encoder_create], [opus/opus.h])
2354+
# opusfile.h includes <opus_multistream.h> so we need to make sure that
2355+
# either $OPUS_INCLUDE or /usr/include/opus is added to the search path.
2356+
__opus_include=${OPUS_INCLUDE}
2357+
if test -z "$__opus_include" -o x"$__opus_include" = x" " ; then
2358+
__opus_include=-I/usr/include/opus
2359+
fi
2360+
AST_EXT_LIB_CHECK([OPUSFILE], [opusfile], [op_open_callbacks], [opus/opusfile.h], [], [$__opus_include])
23532361

23542362
if test "${USE_PWLIB}" != "no"; then
23552363
if test -n "${PWLIB_DIR}"; then

include/asterisk/autoconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,9 @@
588588
/* Define to 1 if you have the Opus library. */
589589
#undef HAVE_OPUS
590590

591+
/* Define to 1 if you have the Opusfile library. */
592+
#undef HAVE_OPUSFILE
593+
591594
/* Define this to indicate the ${OSPTK_DESCRIP} library */
592595
#undef HAVE_OSPTK
593596

makeopts.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ OGG_LIB=@OGG_LIB@
232232
OPUS_INCLUDE=@OPUS_INCLUDE@
233233
OPUS_LIB=@OPUS_LIB@
234234

235+
OPUSFILE_INCLUDE=@OPUSFILE_INCLUDE@
236+
OPUSFILE_LIB=@OPUSFILE_LIB@
237+
235238
OSPTK_INCLUDE=@OSPTK_INCLUDE@
236239
OSPTK_LIB=@OSPTK_LIB@
237240

0 commit comments

Comments
 (0)