dnl Process this file with autoconf to produce a configure script. -*-m4-*-
dnl
dnl %CopyrightBegin%
dnl
dnl Copyright Ericsson AB 2001-2016. All Rights Reserved.
dnl
dnl Licensed under the Apache License, Version 2.0 (the "License");
dnl you may not use this file except in compliance with the License.
dnl You may obtain a copy of the License at
dnl
dnl http://www.apache.org/licenses/LICENSE-2.0
dnl
dnl Unless required by applicable law or agreed to in writing, software
dnl distributed under the License is distributed on an "AS IS" BASIS,
dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dnl See the License for the specific language governing permissions and
dnl limitations under the License.
dnl
dnl %CopyrightEnd%
dnl
dnl define([AC_CACHE_LOAD], )dnl
dnl define([AC_CACHE_SAVE], )dnl
AC_INIT(vsn.mk)
if test -z "$ERL_TOP" || test ! -d $ERL_TOP ; then
AC_CONFIG_AUX_DIRS(autoconf)
else
erl_top=${ERL_TOP}
AC_CONFIG_AUX_DIRS($erl_top/erts/autoconf)
fi
if test "X$host" != "Xfree_source" -a "X$host" != "Xwin32"; then
AC_CANONICAL_HOST
else
host_os=win32
fi
dnl ----------------------------------------------------------------------
dnl Checks for programs.
dnl ----------------------------------------------------------------------
AC_PROG_CC
LM_WINDOWS_ENVIRONMENT
AC_DEFUN(ERL_REENTRANT_FLEX,
[flex_compile='$LEX -R -Pconftest -oconftest.c conftest.flex 1>&AC_FD_CC'
changequote(253, 273)dnl
cat > conftest.flex <<EOF
/*
* This (reentrant) example code comes from the flex manual
*/
%option reentrant stack noyywrap
%x COMMENT
%%
"//" yy_push_state( COMMENT, yyscanner);
.|\n
<COMMENT>\n yy_pop_state( yyscanner );
<COMMENT>[^\n]+ fprintf( yyout, "%s\n", yytext);
%%
int main ( int argc, char * argv[] )
{
yyscan_t scanner;
yylex_init ( &scanner );
yylex ( scanner );
yylex_destroy ( scanner );
return 0;
}
EOF
changequote([, ])dnl
AC_MSG_CHECKING(for reentrant capable flex)
if AC_TRY_EVAL(flex_compile) && test -s conftest.c; then
ifelse([$1], , :, [
$1])
AC_MSG_RESULT([yes])
else
echo "configure: failed program was:" 1>&AC_FD_CC
cat conftest.flex 1>&AC_FD_CC
echo "configure: PATH was $PATH" 1>&AC_FD_CC
ifelse([$2], , , [
$2
])dnl
AC_MSG_RESULT([no])
fi
])
dnl
dnl Shall we attempt to use reentrant flex scanner or not
dnl
AC_ARG_ENABLE(megaco_reentrant_flex_scanner,
[ --enable-megaco-reentrant-flex-scanner enable reentrant megaco flex scanner
--disable-megaco-reentrant-flex-scanner disable reentrant megaco flex scanner],
if test x${enable_megaco_reentrant_flex_scanner} = xno ; then
ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=false
else
ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=true
fi,
ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=true)
dnl
dnl flex is needed by megaco. lex wont do!
dnl
AC_PROG_LEX
if test "$LEX" != flex; then
ENABLE_MEGACO_FLEX_SCANNER=false
else
ENABLE_MEGACO_FLEX_SCANNER=true
dnl Check if we can generate a reentrant scanner
dnl ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=true
if ${ENABLE_REENTRANT_MEGACO_FLEX_SCANNER} = true ; then
ERL_REENTRANT_FLEX(ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=true,
ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=false)
fi
fi
AC_SUBST(ENABLE_MEGACO_FLEX_SCANNER)
AC_SUBST(ENABLE_REENTRANT_MEGACO_FLEX_SCANNER)
dnl
dnl For increased performance it is possible to disable lineno
dnl
AC_ARG_ENABLE(megaco_flex_scanner_lineno,
[ --enable-megaco-flex-scanner-lineno enable megaco flex scanner lineno
--disable-megaco-flex-scanner-lineno disable megaco flex scanner lineno],
if test x${enable_megaco_flex_scanner_lineno} = xno ; then
ENABLE_MEGACO_FLEX_SCANNER_LINENO=false
else
ENABLE_MEGACO_FLEX_SCANNER_LINENO=true
fi,
ENABLE_MEGACO_FLEX_SCANNER_LINENO=true)
AC_SUBST(ENABLE_MEGACO_FLEX_SCANNER_LINENO)
dnl This is the os flavour, should be unix or win32
if test "X$host" = "Xwin32"; then
ERLANG_OSTYPE=win32
else
ERLANG_OSTYPE=unix
fi
AC_SUBST(ERLANG_OSTYPE)
dnl Magic test for clearcase.
if test -d ../../system; then
OTP_EXTRA_FLAGS=-DOTP_RELEASE
else
OTP_EXTRA_FLAGS=
fi
AC_SUBST(OTP_EXTRA_FLAGS)
if test "x$GCC" = xyes; then
# Treat certain GCC warnings as errors
LM_TRY_ENABLE_CFLAG([-Werror=return-type], [CFLAGS])
fi
dnl ----------------------------------------------------------------------
dnl Enable -fsanitize= flags.
dnl ----------------------------------------------------------------------
m4_define(DEFAULT_SANITIZERS, [address,undefined])
AC_ARG_ENABLE(
sanitizers,
AS_HELP_STRING(
[--enable-sanitizers@<:@=comma-separated list of sanitizers@:>@],
[Default=DEFAULT_SANITIZERS]),
[
case "$enableval" in
no) sanitizers= ;;
yes) sanitizers="-fsanitize=DEFAULT_SANITIZERS" ;;
*) sanitizers="-fsanitize=$enableval" ;;
esac
CFLAGS="$CFLAGS $sanitizers"
LDFLAGS="$LDFLAGS $sanitizers"
])
ERL_DED
AC_CHECK_PROG(PERL, perl, perl, no_perl)
if test "$PERL" = no_perl; then
AC_MSG_ERROR([Perl is required to build the flex scanner!])
fi
AC_OUTPUT(examples/meas/Makefile:examples/meas/Makefile.in)
AC_OUTPUT(src/flex/$host/Makefile:src/flex/Makefile.in)