1dnl Process this file with autoconf to produce a configure script. -*-m4-*- 2dnl 3dnl %CopyrightBegin% 4dnl 5dnl Copyright Ericsson AB 2001-2016. All Rights Reserved. 6dnl 7dnl Licensed under the Apache License, Version 2.0 (the "License"); 8dnl you may not use this file except in compliance with the License. 9dnl You may obtain a copy of the License at 10dnl 11dnl http://www.apache.org/licenses/LICENSE-2.0 12dnl 13dnl Unless required by applicable law or agreed to in writing, software 14dnl distributed under the License is distributed on an "AS IS" BASIS, 15dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16dnl See the License for the specific language governing permissions and 17dnl limitations under the License. 18dnl 19dnl %CopyrightEnd% 20dnl 21 22dnl define([AC_CACHE_LOAD], )dnl 23dnl define([AC_CACHE_SAVE], )dnl 24 25if test "x$no_recursion" != "xyes" -a "x$OVERRIDE_CONFIG_CACHE" = "x"; then 26 # We do not want to use a common cache! 27 cache_file=/dev/null 28fi 29 30AC_INIT(vsn.mk) 31 32if test -z "$ERL_TOP" || test ! -d $ERL_TOP ; then 33 AC_CONFIG_AUX_DIRS(autoconf) 34else 35 erl_top=${ERL_TOP} 36 AC_CONFIG_AUX_DIRS($erl_top/erts/autoconf) 37fi 38 39if test "X$host" != "Xfree_source" -a "X$host" != "Xwin32"; then 40 AC_CANONICAL_HOST 41else 42 host_os=win32 43fi 44 45 46dnl ---------------------------------------------------------------------- 47dnl Checks for programs. 48dnl ---------------------------------------------------------------------- 49 50AC_DEFUN(ERL_REENTRANT_FLEX, 51[flex_compile='$LEX -R -Pconftest -oconftest.c conftest.flex 1>&AC_FD_CC' 52changequote(253, 273)dnl 53cat > conftest.flex <<EOF 54/* 55 * This (reentrant) example code comes from the flex manual 56 */ 57 58%option reentrant stack noyywrap 59%x COMMENT 60 61%% 62 63"//" yy_push_state( COMMENT, yyscanner); 64.|\n 65 66<COMMENT>\n yy_pop_state( yyscanner ); 67<COMMENT>[^\n]+ fprintf( yyout, "%s\n", yytext); 68 69%% 70 71int main ( int argc, char * argv[] ) 72{ 73 yyscan_t scanner; 74 75 yylex_init ( &scanner ); 76 yylex ( scanner ); 77 yylex_destroy ( scanner ); 78 return 0; 79} 80EOF 81changequote([, ])dnl 82AC_MSG_CHECKING(for reentrant capable flex) 83if AC_TRY_EVAL(flex_compile) && test -s conftest.c; then 84 ifelse([$1], , :, [ 85 $1]) 86 AC_MSG_RESULT([yes]) 87else 88 echo "configure: failed program was:" 1>&AC_FD_CC 89 cat conftest.flex 1>&AC_FD_CC 90 echo "configure: PATH was $PATH" 1>&AC_FD_CC 91ifelse([$2], , , [ 92 $2 93])dnl 94 AC_MSG_RESULT([no]) 95fi 96]) 97 98 99dnl 100dnl Shall we attempt to use reentrant flex scanner or not 101dnl 102AC_ARG_ENABLE(megaco_reentrant_flex_scanner, 103[ --enable-megaco-reentrant-flex-scanner enable reentrant megaco flex scanner 104 --disable-megaco-reentrant-flex-scanner disable reentrant megaco flex scanner], 105 if test x${enable_megaco_reentrant_flex_scanner} = xno ; then 106 ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=false 107 else 108 ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=true 109 fi, 110 ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=true) 111 112 113dnl 114dnl flex is needed by megaco. lex wont do! 115dnl 116 117AC_PROG_LEX 118if test "$LEX" != flex; then 119 ENABLE_MEGACO_FLEX_SCANNER=false 120else 121 ENABLE_MEGACO_FLEX_SCANNER=true 122 dnl Check if we can generate a reentrant scanner 123 dnl ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=true 124 if ${ENABLE_REENTRANT_MEGACO_FLEX_SCANNER} = true ; then 125 ERL_REENTRANT_FLEX(ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=true, 126 ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=false) 127 fi 128fi 129AC_SUBST(ENABLE_MEGACO_FLEX_SCANNER) 130AC_SUBST(ENABLE_REENTRANT_MEGACO_FLEX_SCANNER) 131 132 133 134dnl 135dnl For increased performance it is possible to disable lineno 136dnl 137AC_ARG_ENABLE(megaco_flex_scanner_lineno, 138[ --enable-megaco-flex-scanner-lineno enable megaco flex scanner lineno 139 --disable-megaco-flex-scanner-lineno disable megaco flex scanner lineno], 140 if test x${enable_megaco_flex_scanner_lineno} = xno ; then 141 ENABLE_MEGACO_FLEX_SCANNER_LINENO=false 142 else 143 ENABLE_MEGACO_FLEX_SCANNER_LINENO=true 144 fi, 145 ENABLE_MEGACO_FLEX_SCANNER_LINENO=true) 146AC_SUBST(ENABLE_MEGACO_FLEX_SCANNER_LINENO) 147 148 149dnl This is the os flavour, should be unix or win32 150if test "X$host" = "Xwin32"; then 151 ERLANG_OSTYPE=win32 152else 153 ERLANG_OSTYPE=unix 154fi 155 156AC_SUBST(ERLANG_OSTYPE) 157 158dnl Magic test for clearcase. 159if test -d ../../system; then 160 OTP_EXTRA_FLAGS=-DOTP_RELEASE 161else 162 OTP_EXTRA_FLAGS= 163fi 164AC_SUBST(OTP_EXTRA_FLAGS) 165 166if test "x$GCC" = xyes; then 167 # Treat certain GCC warnings as errors 168 LM_TRY_ENABLE_CFLAG([-Werror=return-type], [CFLAGS]) 169fi 170 171dnl ---------------------------------------------------------------------- 172dnl Enable -fsanitize= flags. 173dnl ---------------------------------------------------------------------- 174 175m4_define(DEFAULT_SANITIZERS, [address,undefined]) 176AC_ARG_ENABLE( 177 sanitizers, 178 AS_HELP_STRING( 179 [--enable-sanitizers@<:@=comma-separated list of sanitizers@:>@], 180 [Default=DEFAULT_SANITIZERS]), 181[ 182case "$enableval" in 183 no) sanitizers= ;; 184 yes) sanitizers="-fsanitize=DEFAULT_SANITIZERS" ;; 185 *) sanitizers="-fsanitize=$enableval" ;; 186esac 187CFLAGS="$CFLAGS $sanitizers" 188LDFLAGS="$LDFLAGS $sanitizers" 189]) 190 191dnl 192dnl If ${ERL_TOP}/make/otp_ded.mk.in exists and contains DED_MK_VSN > 0, 193dnl every thing releted to compiling Dynamic Erlang Drivers can be found 194dnl in $(ERL_TOP)/make/$(TARGET)/ded.mk at compile time. If not, try to 195dnl figure these things out. 196dnl 197 198AC_MSG_CHECKING([for usable Dynamic Erlang Driver configuration]) 199[ 200 ded_mk_in="${ERL_TOP}/make/otp_ded.mk.in" 201 ded_mk_vsn= 202 test -r "$ded_mk_in" && 203 ded_mk_vsn=`sed -n "s/^DED_MK_VSN[ ]*=[ ]*\(.*\)/\1/p" < "$ded_mk_in"` 204 test "$ded_mk_vsn" != "" || ded_mk_vsn=0 205] 206 207if test $ded_mk_vsn -gt 0; then 208 209HAVE_USABLE_OTP_DED_MK=yes 210AC_MSG_RESULT([yes]) 211 212CC=false 213AC_SUBST(CC) 214DED_LD=false 215AC_SUBST(DED_LD) 216 217else dnl --- begin no usable otp_ded.mk.in --- 218 219HAVE_USABLE_OTP_DED_MK=no 220AC_MSG_RESULT([no]) 221 222dnl 223dnl C compiler (related) defs 224dnl 225 226AC_PROG_CC 227 228dnl 229dnl Flags to the C compiler 230dnl 231 232if test "X$host" = "Xwin32"; then 233 DED_CFLAGS="$CFLAGS" 234else 235 case $host_os in 236 darwin*) 237 CFLAGS="$CFLAGS -fno-common" 238 ;; 239 esac 240 241 if test "x$GCC" = xyes; then 242 DED_CFLAGS="$CFLAGS -fPIC $DED_CFLAGS" 243 else 244 DED_CFLAGS="$CFLAGS $DED_CFLAGS" 245 fi 246fi 247 248dnl emulator includes needed 249DED_INCLUDES="-I${ERL_TOP}/erts/emulator/beam -I${ERL_TOP}/erts/include -I${ERL_TOP}/erts/include/$host -I${ERL_TOP}/erts/include/internal -I${ERL_TOP}/erts/include/internal/$host -I${ERL_TOP}/erts/emulator/sys/$ERLANG_OSTYPE" 250 251DED_THR_DEFS="-D_THREAD_SAFE -D_REENTRANT" 252 253case $host_os in 254 win32) 255 DED_LDFLAGS="-dll" 256 ;; 257 solaris2*|sysv4*) 258 DED_LDFLAGS="-G" 259 ;; 260 aix4*) 261 DED_LDFLAGS="-G -bnoentry -bexpall" 262 ;; 263 freebsd2*) 264 # Non-ELF GNU linker 265 DED_LDFLAGS="-Bshareable" 266 ;; 267 darwin*) 268 # Mach-O linker, a shared lib and a loadable 269 # object file is not the same thing. 270 DED_LDFLAGS="-bundle -flat_namespace -undefined suppress" 271 DED_LD="$CC" 272 ;; 273 *) 274 # assume GNU linker and ELF 275 DED_LDFLAGS="-shared" 276 ;; 277esac 278 279AC_CHECK_PROGS(DED_LD, [$LD ld.sh]) 280AC_CHECK_TOOL(DED_LD, ld, no_ld) 281if test "$DED_LD" = no_ld; then 282 AC_MSG_ERROR([ld is required to build the flex scanner!]) 283fi 284 285AC_MSG_CHECKING(for linker flags for loadable drivers) 286DED_LDFLAGS="$LDFLAGS $DED_LDFLAGS" 287AC_MSG_RESULT([$DED_LDFLAGS]) 288 289fi dnl --- end no usable otp_ded.mk.in --- 290 291AC_SUBST(HAVE_USABLE_OTP_DED_MK) 292AC_SUBST(DED_CFLAGS) 293AC_SUBST(DED_INCLUDES) 294AC_SUBST(DED_THR_DEFS) 295AC_SUBST(DED_LDFLAGS) 296 297AC_CHECK_PROG(PERL, perl, perl, no_perl) 298if test "$PERL" = no_perl; then 299 AC_MSG_ERROR([Perl is required to build the flex scanner!]) 300fi 301 302AC_OUTPUT(examples/meas/Makefile:examples/meas/Makefile.in) 303AC_OUTPUT(src/flex/$host/Makefile:src/flex/Makefile.in) 304 305