1dnl Process this file with autoconf to produce a configure script. -*-m4-*- 2 3dnl %CopyrightBegin% 4dnl 5dnl Copyright Ericsson AB 1997-2021. 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% 20 21dnl The string "FIXME convbreak" means that there is a break of 22dnl autoconf convention that should be cleaned up. 23 24AC_INIT(vsn.mk) 25AC_PREREQ(2.59) 26 27LM_PRECIOUS_VARS 28 29dnl We check if -Werror was given on command line and if so 30dnl we disable it for the configure and only use it when 31dnl actually building erts 32no_werror_CFLAGS=$(echo "$CFLAGS" | sed 's/-Werror\([[^=]]\|$\)/ /g') 33if test "$CFLAGS" != "$no_werror_CFLAGS"; then 34 CFLAGS="$no_werror_CFLAGS" 35 WERRORFLAGS=-Werror 36fi 37 38dnl How to set srcdir absolute is taken from the GNU Emacs distribution 39#### Make srcdir absolute, if it isn't already. It's important to 40#### avoid running the path through pwd unnecessary, since pwd can 41#### give you automounter prefixes, which can go away. 42case "${srcdir}" in 43 /* ) ;; 44 . ) 45 ## We may be able to use the $PWD environment variable to make this 46 ## absolute. But sometimes PWD is inaccurate. 47 ## Make sure CDPATH doesn't affect cd (in case PWD is relative). 48 CDPATH= 49 if test "${PWD}" != "" && test "`(cd ${PWD} ; sh -c pwd)`" = "`pwd`" ; 50 then 51 srcdir="$PWD" 52 else 53 srcdir="`(cd ${srcdir}; pwd)`" 54 fi 55 ;; 56 * ) srcdir="`(cd ${srcdir}; pwd)`" ;; 57esac 58 59## Now, make sure that ERL_TOP is set and is the same as srcdir 60## 61if test -z "$ERL_TOP" || test ! -d $ERL_TOP ; then 62 AC_MSG_ERROR(You need to set the environment variable ERL_TOP!) 63fi 64if test x"${ERL_TOP}/erts" != x"$srcdir"; then 65 AC_MSG_ERROR([You need to run configure with argument --srcdir=${ERL_TOP}/erts]) 66fi 67erl_top=${ERL_TOP} 68 69# echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 70# echo X 71# echo "X srcdir = $srcdir" 72# echo "X ERL_TOP = $ERL_TOP" 73# echo X 74# echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 75 76AC_CONFIG_AUX_DIRS($srcdir/autoconf) 77 78dnl ---------------------------------------------------------------------- 79dnl Figure out what system we are running on. 80dnl ---------------------------------------------------------------------- 81 82# 83# To configure for free source run ./configure --host=free_source 84# 85dnl 86dnl AC_CANONICAL_HOST does not like free_source as a host specification, 87dnl so we make a little special case. 88dnl 89if test "X$host" != "Xfree_source" -a "X$host" != "Xwin32"; then 90 AC_CANONICAL_HOST 91else 92 host_os=$host 93fi 94 95if test "$cross_compiling" = "yes"; then 96 CROSS_COMPILING=yes 97else 98 CROSS_COMPILING=no 99fi 100AC_SUBST(CROSS_COMPILING) 101 102ERL_XCOMP_SYSROOT_INIT 103 104AC_ISC_POSIX 105 106AC_CONFIG_HEADER($host/config.h:config.h.in include/internal/$host/ethread_header_config.h:include/internal/ethread_header_config.h.in include/$host/erl_int_sizes_config.h:include/erl_int_sizes_config.h.in) 107dnl ---------------------------------------------------------------------- 108dnl Optional features. 109dnl ---------------------------------------------------------------------- 110ENABLE_ALLOC_TYPE_VARS= 111AC_SUBST(ENABLE_ALLOC_TYPE_VARS) 112 113AC_ARG_ENABLE(bootstrap-only, 114AS_HELP_STRING([--enable-bootstrap-only], 115 [enable bootstrap only configuration]), 116[ if test "X$enableval" = "Xyes"; then 117 # Disable stuff not necessary in a bootstrap only system in order 118 # to speed up things by reducing the amount of stuff needing to be 119 # built... 120 with_termcap=no 121 with_ssl=no 122 with_ssl_zlib=no 123 enable_jit=no 124 enable_sctp=no 125 fi 126]) 127 128AC_ARG_ENABLE(dirty-schedulers-test, 129AS_HELP_STRING([--enable-dirty-schedulers-test], [enable dirty scheduler test (for debugging purposes)]), 130[ case "$enableval" in 131 yes) enable_dirty_schedulers_test=yes ;; 132 *) enable_dirty_schedulers_test=no ;; 133 esac ], enable_dirty_schedulers_test=no) 134 135AC_ARG_ENABLE(smp-require-native-atomics, 136 AS_HELP_STRING([--disable-smp-require-native-atomics], 137 [disable the SMP requirement of a native atomic implementation]), 138[ case "$enableval" in 139 no) smp_require_native_atomics=no ;; 140 *) smp_require_native_atomics=yes ;; 141 esac ], smp_require_native_atomics=yes) 142 143AC_ARG_WITH(termcap, 144AS_HELP_STRING([--with-termcap], [use termcap (default)]) 145AS_HELP_STRING([--without-termcap], 146 [do not use any termcap libraries (ncurses,curses,termcap,termlib)]), 147[], 148[with_termcap=yes]) 149 150AC_ARG_ENABLE(lock-checking, 151AS_HELP_STRING([--enable-lock-checking], [enable lock checking]), 152[ case "$enableval" in 153 no) enable_lock_check=no ;; 154 *) enable_lock_check=yes ;; 155 esac 156], 157 enable_lock_check=no) 158 159AC_ARG_ENABLE(lock-counter, 160AS_HELP_STRING([--enable-lock-counter], [enable lock counters]), 161[ case "$enableval" in 162 no) enable_lock_count=no ;; 163 *) enable_lock_count=yes ;; 164 esac ], enable_lock_count=no) 165 166AC_ARG_ENABLE(kernel-poll, 167AS_HELP_STRING([--enable-kernel-poll], [enable kernel poll support]) 168AS_HELP_STRING([--disable-kernel-poll], [disable kernel poll support]), 169[ case "$enableval" in 170 no) enable_kernel_poll=no ;; 171 *) enable_kernel_poll=yes ;; 172 esac ], enable_kernel_poll=unknown) 173 174 175AC_ARG_ENABLE(sctp, 176AS_HELP_STRING([--enable-sctp], [enable sctp support (default) to on demand load the SCTP library in runtime if needed]) 177AS_HELP_STRING([--enable-sctp=lib], [enable sctp support to link against the SCTP library]) 178AS_HELP_STRING([--disable-sctp], [disable sctp support]), 179[ case "x$enableval" in 180 xno|xyes|xlib|x) 181 ;; 182 x*) 183 AC_MSG_ERROR("invalid value --enable-sctp=$enableval") 184 ;; 185 esac ]) 186 187AC_ARG_ENABLE(jit, 188AS_HELP_STRING([--enable-jit], [enable JIT support]) 189AS_HELP_STRING([--disable-jit], [disable JIT support]), 190 [ case "$enableval" in 191 no) enable_jit=no ;; 192 *) enable_jit=yes ;; 193 esac 194],enable_jit=auto) 195 196AC_ARG_ENABLE(m64-build, 197AS_HELP_STRING([--enable-m64-build], 198 [build 64bit binaries using the -m64 flag to (g)cc]), 199[ case "$enableval" in 200 no) enable_m64_build=no ;; 201 *) enable_m64_build=yes ;; 202 esac 203],enable_m64_build=no) 204 205AC_ARG_ENABLE(m32-build, 206AS_HELP_STRING([--enable-m32-build], 207 [build 32bit binaries using the -m32 flag to (g)cc]), 208[ case "$enableval" in 209 no) enable_m32_build=no ;; 210 *) enable_m32_build=yes ;; 211 esac 212],enable_m32_build=no) 213 214AC_ARG_WITH(dynamic-trace, 215AS_HELP_STRING([--with-dynamic-trace={dtrace|lttng|systemtap}], 216 [specify use of dynamic trace framework, dtrace, lttng or systemtap]) 217AS_HELP_STRING([--without-dynamic-trace], 218 [don't enable any dynamic tracing (default)])) 219 220if test X"$with_dynamic_trace" = X""; then 221 with_dynamic_trace=no 222fi 223 224case "$with_dynamic_trace" in 225 no) DYNAMIC_TRACE_FRAMEWORK=;; 226 lttng) 227 AC_DEFINE(USE_LTTNG,[1], 228 [Define if you want to use lttng for dynamic tracing]) 229 DYNAMIC_TRACE_FRAMEWORK=lttng;; 230 dtrace) 231 AC_DEFINE(USE_DTRACE,[1], 232 [Define if you want to use dtrace for dynamic tracing]) 233 DYNAMIC_TRACE_FRAMEWORK=dtrace;; 234 systemtap) 235 AC_DEFINE(USE_SYSTEMTAP,[1], 236 [Define if you want to use systemtap for dynamic tracing]) 237 DYNAMIC_TRACE_FRAMEWORK=systemtap;; 238 *) 239 AC_MSG_ERROR(Unknown dynamic tracing framework specified with --with-dynamic-trace!);; 240esac 241 242if test X"$DYNAMIC_TRACE_FRAMEWORK" != X""; then 243 AC_DEFINE(USE_DYNAMIC_TRACE,[1], 244 [Define if you want to use dynamic tracing]) 245fi 246 247AC_ARG_ENABLE(vm-probes, 248AS_HELP_STRING([--enable-vm-probes], 249 [add dynamic trace probes to the Beam VM (only possible if --with-dynamic-trace is enabled, and then default)]), 250 [ case "$enableval" in 251 no) use_vm_probes=no ;; 252 *) 253 if test X"$DYNAMIC_TRACE_FRAMEWORK" != X""; then 254 use_vm_probes=yes ; 255 else 256 AC_MSG_ERROR(Can not enable VM probes without any dynamic tracing framework!); 257 fi;; 258 esac ], if test X"$DYNAMIC_TRACE_FRAMEWORK" != X""; then 259 use_vm_probes=yes ; 260 else 261 use_vm_probes=no 262 fi) 263 264AC_SUBST(USE_VM_PROBES) 265if test X"$DYNAMIC_TRACE_FRAMEWORK" != X"lttng"; then 266 if test X"$use_vm_probes" = X"yes"; then 267 USE_VM_PROBES=yes 268 AC_DEFINE(USE_VM_PROBES,[1], 269 [Define to enable VM dynamic trace probes]) 270 fi 271fi 272 273AC_ARG_WITH(assumed-cache-line-size, 274AS_HELP_STRING([--with-assumed-cache-line-size=SIZE], 275 [specify assumed cache line size in bytes (valid values are powers of two between and including 16 and 8192; default is 64)])) 276 277dnl Require the assumed cache-line size to be a power of two between 16 and 8192 278case "$with_assumed_cache_line_size" in 279 ""|no|yes) 280 with_assumed_cache_line_size=64;; 281 16|32|64|128|256|512|1024|2048|4096|8192) 282 ;; 283 *) 284 AC_MSG_ERROR([Invalid assumed cache-line size of $with_assumed_cache_line_size bytes]) 285 ;; 286esac 287 288AC_DEFINE_UNQUOTED(ASSUMED_CACHE_LINE_SIZE, 289 $with_assumed_cache_line_size, 290 [Assumed cache-line size (in bytes)]) 291 292AC_ARG_ENABLE(systemd, 293AS_HELP_STRING([--enable-systemd], [enable systemd support in epmd]), 294[], 295[enable_systemd=no]) 296 297AC_ARG_ENABLE(saved-compile-time, 298AS_HELP_STRING([--disable-saved-compile-time], [disable saved compile time]), 299[ case "$enableval" in 300 no) save_compile_time=0 ;; 301 *) save_compile_time=1 ;; 302 esac ], save_compile_time=1) 303 304AC_DEFINE_UNQUOTED(ERTS_SAVED_COMPILE_TIME, $save_compile_time, [Save compile time?]) 305 306AC_ARG_WITH(microstate-accounting, 307AS_HELP_STRING([--with-microstate-accounting={yes|extra}], 308 [enable microstate account, possibly with extra detailed states]) 309AS_HELP_STRING([--without-microstate-accounting], 310 [don't enable microstate accounting]), 311[],[with_microstate_accounting=yes]) 312 313case "$with_microstate_accounting" in 314 yes) AC_DEFINE(ERTS_ENABLE_MSACC,[1], 315 [Define as 1 if you want to enable microstate accounting, 2 if you want extra states]) ;; 316 extra) AC_DEFINE(ERTS_ENABLE_MSACC,[2], 317 [Define as 1 if you want to enable microstate accounting, 2 if you want extra states]) ;; 318 *) ;; 319esac 320 321dnl Magic test for clearcase. 322OTP_RELEASE= 323if test "${ERLANG_COMMERCIAL_BUILD}" != ""; then 324 OTP_EXTRA_FLAGS=-DOTP_RELEASE 325 OTP_RELEASE=yes 326else 327 OTP_EXTRA_FLAGS= 328fi 329AC_SUBST(OTP_RELEASE) 330 331AC_MSG_CHECKING([OTP release]) 332[SYSTEM_VSN=`cat $ERL_TOP/OTP_VERSION | sed "s|\([0-9]*\).*|\1|"`] 333AC_MSG_RESULT([$SYSTEM_VSN]) 334AC_SUBST(SYSTEM_VSN) 335 336AC_MSG_CHECKING([OTP version]) 337[OTP_VERSION=`cat $ERL_TOP/OTP_VERSION`] 338AC_MSG_RESULT([$OTP_VERSION]) 339AC_SUBST(OTP_VERSION) 340 341if test X${enable_m64_build} = Xyes; then 342 case $CFLAGS in 343 *-m64*) 344 ;; 345 *) 346 CFLAGS="-m64 $CFLAGS" 347 ;; 348 esac 349else 350 if test X${enable_m32_build} = Xyes; 351 then 352 case $CFLAGS in 353 *-m32*) 354 ;; 355 *) 356 CFLAGS="-m32 $CFLAGS" 357 ;; 358 esac ; 359 fi 360fi 361 362AC_ARG_ENABLE(static-nifs, 363AS_HELP_STRING([--enable-static-nifs], [link nifs statically. If yes then all nifs in all Erlang/OTP applications will be statically linked into the main binary. It is also possible to give a list of nifs that should be linked statically. The list should be a comma separated and contain the absolute path to a .a archive for each nif that is to be statically linked. The name of the .a archive has to be the same as the name of the nif. Note that you have to link any external dependencies that the nifs have to the main binary, so for the crypto nif you want to pass LIBS=-lcrypto to configure.]), 364 STATIC_NIFS="$enableval", 365 STATIC_NIFS=no) 366AC_SUBST(STATIC_NIFS) 367 368AC_ARG_ENABLE(static-drivers, 369AS_HELP_STRING([--enable-static-drivers], [comma separated list of linked-in drivers to link statically with the main binary. The list should contain the absolute path to a .a archive for each driver that is to be statically linked. The name of the .a archive has to be the same as the name of the driver.]), 370 STATIC_DRIVERS="$enableval", 371 STATIC_DRIVERS=no) 372AC_SUBST(STATIC_DRIVERS) 373 374AC_ARG_WITH(ets-write-concurrency-locks, 375AS_HELP_STRING([--with-ets-write-concurrency-locks={8|16|32|64|128|256}], 376 [specify how many locks the write_concurrency option for ets should use.]) 377AS_HELP_STRING([--without-ets-write-concurrency-locks], 378 [use the default number of write_concurrency locks (default)])) 379 380if test X"$with_ets_write_concurrency_locks" != X""; then 381 AC_DEFINE_UNQUOTED(ERTS_DB_HASH_LOCK_CNT,$with_ets_write_concurrency_locks, 382 [Define to override the default number of write_concurrency locks]) 383fi 384 385AC_ARG_WITH(spectre-mitigation, 386 AS_HELP_STRING([--with-spectre-mitigation={yes|incomplete}], 387 [enable spectre mitigation, either fully or with mitigations 388 disabled in a handful places like the interpreter]) 389 AS_HELP_STRING([--without-spectre-mitigation], 390 [build without spectre mitigation]), 391 [],[with_spectre_mitigation=no]) 392 393case "$with_spectre_mitigation" in 394 no) ;; 395 yes) ;; 396 incomplete) ;; 397 *) AC_MSG_ERROR([Invalid spectre mitigation setting]) ;; 398esac 399 400i_noretpoline_attr="" 401 402if test X"$with_spectre_mitigation" != X"no"; then 403 CFLAGS="$CFLAGS -mindirect-branch=thunk" 404 405 AC_MSG_CHECKING([for spectre mitigation]) 406 AC_COMPILE_IFELSE( 407 [AC_LANG_PROGRAM([],[return 0;])], 408 [AC_MSG_RESULT([yes])], 409 [AC_MSG_ERROR([no])]) 410 411 if test X"$with_spectre_mitigation" = X"incomplete"; then 412 # gcc and clang support this attribute if they're recent enough. Note 413 # that we must compile with -Werror to check for actual support as they 414 # warn rather than error out on unsupported attributes. 415 416 i_noretpoline_attr='__attribute__((__indirect_branch__("keep")))' 417 i_preserve_cflags="$CFLAGS" 418 CFLAGS="$CFLAGS -Werror" 419 420 AC_MSG_CHECKING([whether spectre mitigation can be disabled on a per-function basis]) 421 AC_COMPILE_IFELSE( 422 [AC_LANG_PROGRAM([$i_noretpoline_attr],[return 0;])], 423 [AC_MSG_RESULT([yes])], 424 [AC_MSG_ERROR([no])]) 425 426 CFLAGS="$i_preserve_cflags" 427 fi 428fi 429 430AC_DEFINE_UNQUOTED(ERTS_NO_RETPOLINE, $i_noretpoline_attr, 431 [Per-function attribute for disabling retpoline. This is 432 *only* defined when --with-spectre-mitigation=incomplete 433 and has no effects otherwise]) 434 435dnl ---------------------------------------------------------------------- 436dnl Checks for programs. 437dnl ---------------------------------------------------------------------- 438 439AC_PROG_CC 440AC_SUBST(GCC) 441 442dnl --------------------------------------------------------------------- 443dnl Special stuff regarding CFLAGS and details in the environment... 444dnl --------------------------------------------------------------------- 445 446dnl NOTE: CPPFLAGS will be included in CFLAGS at the end 447case $host_os in 448 linux*) CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE";; 449 aix*|os400*) 450 # * _ALL_SOURCE: Required to get the winsize structure for TIOCSWINSZ. 451 # * _LINUX_SOURCE_COMPAT: Not required, but makes some libc functions 452 # behave closer to glibc assumptions. 453 CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE -D_LINUX_SOURCE_COMPAT" 454 ;; 455 win32) 456 # The ethread library requires _WIN32_WINNT of at least 0x0403. 457 # -D_WIN32_WINNT=* from CPPFLAGS is saved in ETHR_DEFS. 458 CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0600 -DWINVER=0x0600" 459 ;; 460 *) 461 ;; 462esac 463 464 465LM_WINDOWS_ENVIRONMENT 466 467dnl 468dnl Flags to the C compiler 469dnl 470dnl Make sure we find config.h 471dnl 472 473ERTS_CONFIG_H_IDIR="-I${ERL_TOP}/erts/$host" 474AC_SUBST(ERTS_CONFIG_H_IDIR) 475 476extra_flags="$ERTS_CONFIG_H_IDIR $OTP_EXTRA_FLAGS" 477CFLAGS="$CFLAGS $extra_flags" 478DEBUG_CFLAGS="-g $CPPFLAGS $extra_flags $DEBUG_CFLAGS" 479DEBUG_FLAGS=-g 480 481dnl 482dnl Adjust DEBUG_CFLAGS to match CFLAGS in terms of -m 483dnl 484 485case $CFLAGS in 486 *-m64*) 487 case $DEBUG_CFLAGS in 488 *-m64*) 489 ;; 490 *) 491 DEBUG_CFLAGS="-m64 $DEBUG_CFLAGS" 492 ;; 493 esac 494 ;; 495 *-m32*) 496 case $DEBUG_CFLAGS in 497 *-m32*) 498 ;; 499 *) 500 DEBUG_CFLAGS="-m32 $DEBUG_CFLAGS" 501 ;; 502 esac 503 ;; 504 *) 505 ;; 506esac 507 508lfs_conf=ok 509lfs_source=none 510if test "${LFS_CFLAGS+set}" = "set" || \ 511 test "${LFS_LDFLAGS+set}" = "set" || \ 512 test "${LFS_LIBS+set}" = "set"; then 513 lfs_source=user 514else 515 LM_CHECK_GETCONF 516 test "$GETCONF" = "false" || lfs_source=getconf 517fi 518 519if test "$lfs_source" = "none"; then 520 AC_MSG_WARN([Do not know how to check for large file support flags; no getconf is available]) 521else 522 for var in CFLAGS LDFLAGS LIBS; do 523 AC_MSG_CHECKING([for large file support $var]) 524 if test $lfs_source = user; then 525 eval "lfs_val=\"\$LFS_$var\"" 526 else 527 eval "lfs_var=LFS_$var" 528 lfs_val=`$GETCONF $lfs_var 2>/dev/null` || lfs_conf=failed 529 if test $lfs_conf = failed; then 530 AC_MSG_RESULT([failed]) 531 break 532 fi 533 eval "$lfs_var=\"$lfs_val\"" 534 fi 535 test "$lfs_val" != "" || lfs_val=none 536 AC_MSG_RESULT([$lfs_val]) 537 done 538 if test $lfs_conf = failed; then 539 AC_MSG_WARN([Check for large file support flags failed; $GETCONF failed]) 540 else 541 CFLAGS="$CFLAGS $LFS_CFLAGS" 542 DEBUG_CFLAGS="$DEBUG_CFLAGS $LFS_CFLAGS" 543 LDFLAGS="$LDFLAGS $LFS_LDFLAGS" 544 LIBS="$LIBS $LFS_LIBS" 545 fi 546fi 547 548if test "x$GCC" = xyes; then 549 # Treat certain GCC warnings as errors 550 LM_TRY_ENABLE_CFLAG([-Werror=return-type], [WERRORFLAGS]) 551 LM_TRY_ENABLE_CFLAG([-Werror=implicit], [WERRORFLAGS]) 552 LM_TRY_ENABLE_CFLAG([-Werror=undef], [WERRORFLAGS]) 553 554 # until the emulator can handle this, I suggest we turn it off! 555 #WFLAGS="-Wall -Wshadow -Wcast-qual -Wmissing-declarations" 556 WFLAGS="-Wall -Wstrict-prototypes -Wpointer-arith" 557 558 case "$host_cpu" in 559 tile*) 560 # tile-gcc is a bit stricter with -Wmissing-prototypes than other gccs, 561 # and too strict for our taste. 562 ;; 563 *) 564 WFLAGS="$WFLAGS -Wmissing-prototypes";; 565 esac 566 567 saved_CFLAGS=$CFLAGS 568 CFLAGS="$CFLAGS -Wdeclaration-after-statement" 569 AC_TRY_COMPILE([],[;], warn_decl_after_st=true, warn_decl_after_st=false) 570 if test "X$warn_decl_after_st" = "Xtrue"; then 571 WFLAGS="$WFLAGS -Wdeclaration-after-statement" 572 fi 573 CFLAGS=$saved_CFLAGS 574 575 # Use -fno-common for gcc, that is link error if multiple definitions of 576 # global variables are encountered. This is ISO C compliant. 577 # Until version 10, gcc has had -fcommon as default, which allows and merges 578 # such dubious duplicates. 579 LM_TRY_ENABLE_CFLAG([-fno-common], [CFLAGS]) 580else 581 WFLAGS="" 582 WERRORFLAGS=${WERRORFLAGS:-""} 583fi 584 585AC_MSG_CHECKING([C99 support]) 586 587AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[ 588#if __STDC_VERSION__ < 199901L 589 #error "Not C99" 590#endif])], 591 [AC_MSG_RESULT([yes])], 592 [AC_MSG_RESULT([no]) 593 CFLAGS="-std=gnu99 $CFLAGS" 594 DEBUG_CFLAGS="-std=gnu99 $DEBUG_CFLAGS"]) 595 596AC_MSG_CHECKING([CFLAGS for -O switch]) 597case "$CFLAGS" in 598 *-O*) AC_MSG_RESULT([yes]) ;; 599 *) 600 AC_MSG_ERROR([ 601 CFLAGS must contain a -O flag. If you need to edit the CFLAGS you probably 602 also want to add the default CFLAGS. The default CFLAGS are "-O2 -g". 603 If you want to build erts without any optimization, pass -O0 to CFLAGS.]) ;; 604esac 605 606dnl DEBUG_FLAGS is obsolete (I hope) 607AC_SUBST(DEBUG_FLAGS) 608AC_SUBST(DEBUG_CFLAGS) 609AC_SUBST(WFLAGS) 610AC_SUBST(WERRORFLAGS) 611 612## Check if we can do profile guided optimization of beam_emu 613LM_CHECK_RUN_CFLAG([-fprofile-generate -Werror],[PROFILE_GENERATE]) 614LM_CHECK_RUN_CFLAG([-fprofile-use -Werror],[PROFILE_USE]) 615LM_CHECK_RUN_CFLAG([-fprofile-use -fprofile-correction -Werror],[PROFILE_CORRECTION]) 616 617if test "X$PROFILE_CORRECTION" = "Xtrue"; then 618 saved_CFLAGS=$CFLAGS 619 saved_LDFLAGS=$LDFLAGS 620 CFLAGS="-fprofile-generate $saved_CFLAGS" 621 LDFLAGS="-fprofile-generate $saved_LDFLAGS" 622 AC_MSG_CHECKING([whether $CC links with -fprofile-generate]) 623 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[return 0;])], 624 [AC_MSG_RESULT([yes]) 625 PROFILE_GENERATE=true], 626 [AC_MSG_RESULT([no]) 627 PROFILE_GENERATE=false]) 628 CFLAGS=$saved_CFLAGS 629 LDFLAGS=$saved_LDFLAGS 630fi 631 632## Check if this is clang 633LM_CHECK_ENABLE_CFLAG([-fprofile-instr-generate -Werror],[PROFILE_INSTR_GENERATE]) 634if test "X$PROFILE_INSTR_GENERATE" = "Xtrue"; then 635 # It was clang, now we also have to check if we have llvm-profdata and that 636 # we can link programs with -fprofile-instr-use 637 saved_CFLAGS=$CFLAGS; 638 CFLAGS="-fprofile-instr-generate -Werror $saved_CFLAGS" 639 AC_RUN_IFELSE([AC_LANG_PROGRAM([],[])], 640 [AC_PATH_PROG([LLVM_PROFDATA], [llvm-profdata],[],[$PATH:/Library/Developer/CommandLineTools/usr/bin]) 641 AC_CHECK_PROGS([XCRUN], [xcrun]) 642 if test "X$XCRUN" != "X" -a "X$LLVM_PROFDATA" = "X"; then 643 AC_MSG_CHECKING([for $XCRUN $LLVM_PROFDATA]) 644 if $XCRUN $LLVM_PROFDATA --help 2>& AS_MESSAGE_LOG_FD >& AS_MESSAGE_LOG_FD; then 645 LLVM_PROFDATA="$XCRUN $LLVM_PROFDATA" 646 AC_MSG_RESULT([yes]) 647 else 648 AC_MSG_RESULT([no]) 649 fi 650 fi 651 AC_SUBST(LLVM_PROFDATA) 652 if test "X$LLVM_PROFDATA" != "X"; then 653 CFLAGS="-fprofile-instr-use=default.profdata $saved_CFLAGS"; 654 $LLVM_PROFDATA merge -output=default.profdata *.profraw; 655 AC_MSG_CHECKING([whether $CC accepts -fprofile-instr-use=default.profdata -Werror]) 656 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[return 0;])], 657 [AC_MSG_RESULT([yes]) 658 PROFILE_INSTR_USE=true], 659 [AC_MSG_RESULT([no]) 660 PROFILE_INSTR_USE=false]) 661 rm -f default.profdata 662 fi], 663 [], 664 [AC_MSG_NOTICE([Disabling PGO when cross-compiling])]) 665 rm -f *.profraw 666 CFLAGS=$saved_CFLAGS; 667fi 668 669AC_ARG_ENABLE(pgo, 670AS_HELP_STRING([--enable-pgo], 671 [build erts using PGO (profile guided optimization)]), 672[ case "$enableval" in 673 no) enable_pgo=no ;; 674 *) enable_pgo=yes ;; 675 esac 676],enable_pgo=default) 677 678USE_PGO=false 679AC_MSG_CHECKING([whether to do PGO of erts]) 680if test $enable_pgo = no; then 681 AC_MSG_RESULT([no, disabled by user]) 682elif test $CROSS_COMPILING = yes; then 683 if test $enable_pgo = yes; then 684 AC_MSG_ERROR(cannot use PGO when cross-compiling) 685 else 686 AC_MSG_RESULT([no, cross compiling]) 687 fi 688elif test "X$host" = "Xwin32"; then 689 AC_MSG_RESULT([no, not supported in windows]) 690elif test "X$PROFILE_GENERATE" = "Xtrue" -a "X$PROFILE_USE" = "Xtrue" -a "X$PROFILE_CORRECTION" = "Xtrue"; then 691 ## We need -fprofile-generate and -fprofile-correction support to use PGO with 692 ## gcc as multiple threads run within the executed object files 693 USE_PGO=true 694 PROFILE_COMPILER=gcc 695 AC_MSG_RESULT([yes, using -fprofile-generate -fprofile-correction]) 696elif test "X$PROFILE_INSTR_GENERATE" = "Xtrue" -a "X$PROFILE_INSTR_USE" = "Xtrue"; then 697 USE_PGO=true 698 PROFILE_COMPILER=clang 699 AC_MSG_RESULT([yes, using -fprofile-instr-generate]) 700else 701 if test $enable_pgo = yes; then 702 AC_MSG_ERROR(cannot use PGO with this compiler) 703 else 704 AC_MSG_RESULT([no]) 705 fi 706fi 707 708dnl Disable pgo for now 709USE_PGO=false 710 711AC_SUBST(USE_PGO) 712AC_SUBST(PROFILE_COMPILER) 713 714AC_CHECK_SIZEOF(void *) # Needed for ARCH and smp checks below 715if test "x$ac_cv_sizeof_void_p" = x8; then 716 AC_SUBST(EXTERNAL_WORD_SIZE, 64) 717else 718 AC_SUBST(EXTERNAL_WORD_SIZE, 32) 719fi 720 721dnl 722dnl Figure out operating system and cpu architecture 723dnl 724 725if test "x$host_alias" != "x"; then 726 chk_opsys_=$host_os 727else 728 chk_opsys_=`uname -s` 729 if test "x$chk_opsys_" = "xSunOS"; then 730 chk_opsys_=$chk_opsys_`uname -r` 731 fi 732fi 733case $chk_opsys_ in 734 win32) OPSYS=win32;; 735 solaris2.*|SunOS5.*) OPSYS=sol2;; 736 linux*|Linux) OPSYS=linux;; 737 darwin|Darwin) OPSYS=darwin;; 738 freebsd|FreeBSD) OPSYS=freebsd;; 739 dragonfly|DragonFly) OPSYS=dragonfly;; 740 *) OPSYS=noopsys 741esac 742 743AC_SUBST(OPSYS) 744 745LM_HARDWARE_ARCH 746 747dnl Check consistency of os and darwin-switches 748 749 750dnl Take care of LDFLAGS on darwin, and disable common_test as it 751dnl has a build/configure system re rx-lib that is not compatible 752dnl First remove common_tests skip file. 753 754dnl Adjust LDFLAGS to allow 64bit linkage on DARWIN 755case $ARCH-$OPSYS in 756 amd64-darwin*|arm64-darwin*) 757 AC_MSG_NOTICE([Adjusting LDFLAGS to cope with 64bit Darwin]) 758 case $LDFLAGS in 759 *-m64*) 760 ;; 761 *) 762 LDFLAGS="-m64 $LDFLAGS" 763 ;; 764 esac 765 ;; 766 *-darwin*) 767 case $LDFLAGS in 768 *-m32*) 769 ;; 770 *) 771 LDFLAGS="-m32 $LDFLAGS" 772 ;; 773 esac 774 ;; 775 *) 776 if test X${enable_m64_build} = Xyes; then 777 AC_MSG_NOTICE([Adjusting LDFLAGS to use -m64]) 778 case $LDFLAGS in 779 *-m64*) 780 ;; 781 *) 782 LDFLAGS="-m64 $LDFLAGS" 783 ;; 784 esac 785 fi; 786 if test X${enable_m32_build} = Xyes; then 787 AC_MSG_NOTICE([Adjusting LDFLAGS to use -m32]) ; 788 case $LDFLAGS in 789 *-m32*) 790 ;; 791 *) 792 LDFLAGS="-m32 $LDFLAGS" 793 ;; 794 esac ; 795 fi 796 ;; 797esac 798 799AC_MSG_CHECKING(if VM has to be linked with Carbon framework) 800case $ARCH-$OPSYS in 801 *-darwin*) 802 LIBCARBON="-framework Carbon -framework Cocoa" 803 AC_MSG_RESULT([yes]) 804 ;; 805 *) 806 LIBCARBON= 807 AC_MSG_RESULT([no]) 808 ;; 809esac 810 811AC_SUBST(LIBCARBON) 812 813_search_path=/bin:/usr/bin:/usr/local/bin:$PATH 814 815AC_PATH_PROG(MKDIR, mkdir, false, $_search_path) 816if test "$ac_cv_path_MKDIR" = false; then 817 AC_MSG_ERROR([No 'mkdir' command found]) 818fi 819 820AC_PATH_PROG(CP, cp, false, $_search_path) 821if test "$ac_cv_path_CP" = false; then 822 AC_MSG_ERROR([No 'cp' command found]) 823fi 824 825_search_path= 826 827 828# Remove old configuration information. 829# Next line should be before first output to CONN_INFO. So this is 830# just the right place. 831rm -f "$ERL_TOP/erts/CONF_INFO" 832 833dnl Check if we should/can build a sharing-preserving emulator 834AC_MSG_CHECKING(if we are building a sharing-preserving emulator) 835if test "$enable_sharing_preserving" = "yes"; then 836 AC_DEFINE(SHCOPY, [1], 837 [Define if building a sharing-preserving emulator]) 838 AC_MSG_RESULT([yes]) 839else 840 AC_MSG_RESULT([no]) 841fi 842 843 844dnl some tests below will call this if we haven't already - and autoconf 845dnl can't handle those tests being done conditionally at runtime 846AC_PROG_CPP 847 848AC_PROG_RANLIB 849 850AC_PROG_YACC 851LM_PROG_PERL5 852if test "$ac_cv_path_PERL" = false; then 853 AC_MSG_ERROR([Perl version 5 is required to build the emulator!]) 854fi 855AC_PROG_LN_S 856 857 858AC_CHECK_TOOL([AR], [ar], [false]) 859if test "$ac_cv_prog_AR" = false; then 860 AC_MSG_ERROR([No 'ar' command found in PATH]) 861fi 862 863# 864# Get programs needed for building the documentation 865# 866 867## Delete previous failed configure results 868if test -f doc/CONF_INFO; then 869 rm -f doc/CONF_INFO 870fi 871 872AC_CHECK_PROGS(XSLTPROC, xsltproc) 873if test -z "$XSLTPROC"; then 874 echo "xsltproc" >> doc/CONF_INFO 875 AC_MSG_WARN([No 'xsltproc' command found: the documentation cannot be built]) 876fi 877 878AC_CHECK_PROGS(FOP, fop) 879if test -z "$FOP"; then 880 FOP="$ERL_TOP/make/fakefop" 881 echo "fop" >> doc/CONF_INFO 882 AC_MSG_WARN([No 'fop' command found: going to generate placeholder PDF files]) 883fi 884 885AC_CHECK_PROGS(XMLLINT, xmllint) 886if test -z "$XMLLINT"; then 887 echo "xmllint" >> doc/CONF_INFO 888 AC_MSG_WARN([No 'xmllint' command found: can't run the xmllint target for the documentation]) 889fi 890 891dnl 892dnl We can live with Solaris /usr/ucb/install 893dnl 894case $host in 895 *-*-solaris*|free_source) 896 if test -x /usr/ucb/install; then 897 INSTALL="/usr/ucb/install -c" 898 fi 899 ;; 900 *) 901 ;; 902esac 903AC_PROG_INSTALL 904LM_PROG_INSTALL_DIR 905 906case $host_os in 907 darwin*) 908 dnl Need to preserve modification time on archives; 909 dnl otherwise, ranlib has to be run on archives 910 dnl again after installation. 911 INSTALL_DATA="$INSTALL_DATA -p";; 912 *) 913 ;; 914esac 915 916dnl 917dnl Fix for Tilera install permissions 918dnl 919 920case $build in 921 *tile*) 922 INSTALL_PROGRAM="$INSTALL_PROGRAM -m755" 923 INSTALL_SCRIPT="$INSTALL_SCRIPT -m755" 924 ;; 925 *) 926 ;; 927esac 928 929dnl ---------------------------------------------------------------------- 930dnl Misc. things (some of them should go away) 931dnl ---------------------------------------------------------------------- 932 933dnl 934dnl An attempt to allow cross compiling. This is not the right way, 935dnl nor does it work currently. Some makefiles still needs these 936dnl variables, so we leave them in for now. 937dnl 938HCC='$(CC)' AC_SUBST(HCC) 939HCFLAGS="" AC_SUBST(HCFLAGS) 940HCFLAGS="$HCFLAGS -I${ERL_TOP}/erts/$host" 941 942dnl We want to use $(CC) as linker for the emulator regardless of 943dnl what the user say. This might not be the right way to do it, but 944dnl for now that is the way we do it. 945LD='$(CC)' 946LD_MAY_BE_WEAK=no 947AC_SUBST(LD) 948 949dnl Check for cygwin and object/exe files extension 950dnl AC_CYGWIN is deprecated 951AC_EXEEXT 952AC_OBJEXT 953 954dnl This is the os flavour, should be unix or win32 955case $host in 956 win32) 957 ERLANG_OSTYPE=win32 ;; 958 *) 959 ERLANG_OSTYPE=unix ;; 960esac 961 962AC_SUBST(ERLANG_OSTYPE) 963 964# Check how to export functions from the emulator executable, needed 965# when dynamically loaded drivers are loaded (so that they can find 966# emulator functions). 967# OS'es with ELF executables using the GNU linker (Linux and recent *BSD, 968# in rare cases Solaris) typically need '-Wl,-export-dynamic' (i.e. pass 969# -export-dynamic to the linker - also known as -rdynamic and some other 970# variants); some sysVr4 system(s) instead need(s) '-Wl,-Bexport'. 971# AIX 4.x (perhaps only for x>=2) wants -Wl,-bexpall,-brtl and doesn't 972# reliably return an error for others, thus we separate it out. 973# Otherwise we assume that if the linker accepts the flag, it is needed. 974AC_MSG_CHECKING(for extra flags needed to export symbols) 975DEXPORT="" 976case $host_os in 977 aix*|os400*) 978 DEXPORT=-Wl,-bexpall,-brtl 979 ;; 980 bsdi*) 981 DEXPORT="-rdynamic " 982 ;; 983 win32) 984 DEXPORT="" 985 ;; 986 *) 987 save_ldflags="$LDFLAGS" 988 LDFLAGS=-Wl,-export-dynamic 989 AC_TRY_LINK(,,[DEXPORT=-Wl,-export-dynamic], [ 990 LDFLAGS=-Wl,-Bexport 991 AC_TRY_LINK(,,[DEXPORT=-Wl,-Bexport],)]) 992 LDFLAGS="$save_ldflags" 993 ;; 994esac 995AC_SUBST(DEXPORT) 996case "x$DEXPORT" in 997 "x") 998 AC_MSG_RESULT([none]);; 999 *) 1000 AC_MSG_RESULT([$DEXPORT]);; 1001esac 1002 1003# Check for Solaris/ultrasparc /dev/perfmon interface 1004# (also needs gcc specific asm instructions) 1005case "${host}:${GCC}" in 1006 sparc-*-solaris*:yes) 1007 AC_DEFINE(HAVE_SOLARIS_SPARC_PERFMON,[1], 1008 [define if you have the Solaris/ultrasparc /dev/perfmon interface]) 1009 ;; 1010 *) 1011 ;; 1012esac 1013 1014 1015case $host_os in 1016 darwin19*) 1017 # Disable stack checking to avoid crashing with a segment fault 1018 # in macOS Catalina. 1019 AC_MSG_NOTICE([Turning off stack check on macOS 10.15 (Catalina)]) 1020 CFLAGS="-fno-stack-check $CFLAGS" 1021 ;; 1022 *) 1023 ;; 1024esac 1025 1026 1027dnl ---------------------------------------------------------------------- 1028dnl Checks for libraries. 1029dnl ---------------------------------------------------------------------- 1030 1031AC_CHECK_LIB(m, sin) 1032AC_CHECK_LIB(dl, dlopen) 1033AC_CHECK_LIB(inet, main) 1034AC_CHECK_LIB(util, openpty) 1035 1036dnl Try to find a thread library. 1037dnl 1038dnl ETHR_LIB_NAME, ETHR_LIBS, ETHR_X_LIBS, ETHR_THR_LIB_BASE and ETHR_DEFS 1039dnl are set by ERL_FIND_ETHR_LIB 1040ERL_FIND_ETHR_LIB 1041 1042if test "X$ETHR_LIB_NAME" = "X"; then 1043 AC_MSG_ERROR([cannot build emulator since no thread library was found]) 1044fi 1045 1046TYPES=opt 1047 1048DIRTY_SCHEDULER_TEST=$enable_dirty_schedulers_test 1049AC_SUBST(DIRTY_SCHEDULER_TEST) 1050test $DIRTY_SCHEDULER_TEST != yes || { 1051 test -f "$ERL_TOP/erts/CONF_INFO" || echo "" > "$ERL_TOP/erts/CONF_INFO" 1052 cat >> $ERL_TOP/erts/CONF_INFO <<EOF 1053 1054 WARNING: 1055 Dirty Scheduler Test has been enabled. This 1056 feature is for debugging purposes only. 1057 Poor performance as well as strange system 1058 characteristics is expected! 1059 1060EOF 1061} 1062 1063test "X$smp_require_native_atomics" = "Xyes" && 1064 AC_DEFINE(ETHR_SMP_REQUIRE_NATIVE_IMPLS, 1, [Define if you want to enable check for native ethread implementations]) 1065 1066case "$ethr_have_native_atomics-$smp_require_native_atomics-$ethr_have_native_spinlock" in 1067 yes-*) 1068 if test "$ethr_native_atomic_implementation" = "gcc_sync"; then 1069 test -f "$ERL_TOP/erts/CONF_INFO" || 1070 echo "" > "$ERL_TOP/erts/CONF_INFO" 1071 cat >> $ERL_TOP/erts/CONF_INFO <<EOF 1072 1073 WARNING: 1074 Only gcc's __sync_* builtins available for 1075 atomic memory access. This will cause lots 1076 of expensive and unnecessary memory barrier 1077 instructions to be issued which will make 1078 the performance of the runtime system 1079 suffer. You are *strongly* advised to 1080 upgrade to a gcc version that supports the 1081 __atomic_* builtins (at least gcc version 1082 4.7) or build with libatomic_ops. See the 1083 "Atomic Memory Operations and the VM" 1084 chapter of \$ERL_TOP/HOWTO/INSTALL.md for 1085 more information. 1086 1087EOF 1088 fi 1089 ;; 1090 1091 no-yes-*) 1092 AC_MSG_ERROR([No native atomic implementation found. See the \"Atomic Memory Operations and the VM\" chapter of \$ERL_TOP/HOWTO/INSTALL.md for more information.]) 1093 ;; 1094 1095 no-no-yes) 1096 1097 test -f "$ERL_TOP/erts/CONF_INFO" || 1098 echo "" > "$ERL_TOP/erts/CONF_INFO" 1099 cat >> $ERL_TOP/erts/CONF_INFO <<EOF 1100 1101 No native atomic implementation available. 1102 Fallbacks implemented using spinlocks will be 1103 used. Note that the performance of the SMP 1104 runtime system will suffer immensely due to 1105 this. 1106 1107EOF 1108 ;; 1109 1110 no-no-no) 1111 test -f "$ERL_TOP/erts/CONF_INFO" || 1112 echo "" > "$ERL_TOP/erts/CONF_INFO" 1113 cat >> "$ERL_TOP/erts/CONF_INFO" <<EOF 1114 1115 No native atomic implementation, nor no native 1116 spinlock implementation available. Fallbacks 1117 implemented using mutexes will be used. Note 1118 that the performance of the SMP runtime system 1119 will suffer immensely due to this. 1120 1121EOF 1122 ;; 1123 1124esac 1125AC_SUBST(TYPES) 1126 1127AC_CHECK_FUNCS([posix_fadvise closefrom]) 1128AC_CHECK_HEADERS([linux/falloc.h]) 1129dnl * Old glibcs have broken fallocate64(). Make sure not to use it. 1130AC_CACHE_CHECK([whether fallocate() works],i_cv_fallocate_works,[ 1131 AC_TRY_LINK([ 1132 #include <stdio.h> 1133 #include <stdlib.h> 1134 #include <fcntl.h> 1135 #include <unistd.h> 1136 #include <fcntl.h> 1137 #include <linux/falloc.h> 1138 ], 1139 [ 1140 int fd = creat("conftest.temp", 0600); 1141 fallocate(fd, FALLOC_FL_KEEP_SIZE,(off_t) 1024,(off_t) 1024); 1142 ], i_cv_fallocate_works=yes, i_cv_fallocate_works=no) 1143]) 1144if test $i_cv_fallocate_works = yes; then 1145 AC_DEFINE(HAVE_FALLOCATE, 1, Define if you have a working fallocate()) 1146fi 1147 1148dnl * Old glibcs have broken posix_fallocate(). Make sure not to use it. 1149dnl * It may also be broken in AIX. 1150AC_CACHE_CHECK([whether posix_fallocate() works],i_cv_posix_fallocate_works,[ 1151 AC_TRY_RUN([ 1152 #if !defined(__sun) && !defined(__sun__) 1153 #define _XOPEN_SOURCE 600 1154 #endif 1155 #include <stdio.h> 1156 #include <stdlib.h> 1157 #include <fcntl.h> 1158 #include <unistd.h> 1159 #if defined(__GLIBC__) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 7)) 1160 possibly broken posix_fallocate 1161 #endif 1162 int main() { 1163 int fd = creat("conftest.temp", 0600); 1164 int ret; 1165 if (-1 == fd) { 1166 perror("creat()"); 1167 return 2; 1168 } 1169 ret = posix_fallocate(fd, 1024, 1024) < 0 ? 1 : 0; 1170 unlink("conftest.temp"); 1171 return ret; 1172 } 1173 ], [ 1174 i_cv_posix_fallocate_works=yes 1175 ], [ 1176 i_cv_posix_fallocate_works=no 1177 ], [ 1178 i_cv_posix_fallocate_works=no 1179 ]) 1180]) 1181if test $i_cv_posix_fallocate_works = yes; then 1182 AC_DEFINE(HAVE_POSIX_FALLOCATE,, Define if you have a working posix_fallocate()) 1183fi 1184 1185# 1186# EMU_THR_LIB_NAME, EMU_THR_LIBS, EMU_THR_X_LIBS, and EMU_THR_DEFS is 1187# used by the emulator, and can (but should not) be used by applications 1188# that only require thread support when the emulator has thread support. 1189# Other applications should use ETHR_LIB_NAME, ETHR_LIBS, ETHR_X_LIBS, 1190# and ETHR_DEFS. 1191# 1192 1193EMU_THR_LIB_NAME= 1194EMU_THR_X_LIBS= 1195EMU_THR_LIBS= 1196EMU_THR_DEFS= 1197 1198# Threads enabled for emulator 1199EMU_THR_LIB_NAME=$ETHR_LIB_NAME 1200EMU_THR_X_LIBS=$ETHR_X_LIBS 1201EMU_THR_LIBS=$ETHR_LIBS 1202EMU_THR_DEFS=$ETHR_DEFS 1203ENABLE_ALLOC_TYPE_VARS="$ENABLE_ALLOC_TYPE_VARS threads" 1204AC_MSG_CHECKING(whether lock checking should be enabled) 1205AC_MSG_RESULT($enable_lock_check) 1206if test "x$enable_lock_check" != "xno"; then 1207 EMU_THR_DEFS="$EMU_THR_DEFS -DERTS_ENABLE_LOCK_CHECK" 1208fi 1209 1210AC_MSG_CHECKING(whether lock counters should be enabled) 1211AC_MSG_RESULT($enable_lock_count) 1212if test "x$enable_lock_count" != "xno"; then 1213 TYPES="$TYPES lcnt" 1214fi 1215 1216case $host_os in 1217 linux*) 1218 AC_MSG_CHECKING([whether dlopen() needs to be called before first call to dlerror()]) 1219 if test "x$ETHR_THR_LIB_BASE_TYPE" != "xposix_nptl"; then 1220 AC_DEFINE(ERTS_NEED_DLOPEN_BEFORE_DLERROR,[1], 1221 [Define if dlopen() needs to be called before first call to dlerror()]) 1222 AC_MSG_RESULT(yes) 1223 else 1224 AC_MSG_RESULT(no) 1225 fi 1226 ;; 1227 *) 1228 ;; 1229esac 1230 1231# Remove -D_WIN32_WINNT*, -DWINVER* and -D_GNU_SOURCE from EMU_THR_DEFS 1232# (defined in CFLAGS). Note that we want to keep these flags 1233# in ETHR_DEFS, but not in EMU_THR_DEFS. 1234new_emu_thr_defs= 1235for thr_def in $EMU_THR_DEFS; do 1236 case $thr_def in 1237 -D_GNU_SOURCE*|-D_WIN32_WINNT*|-DWINVER*) 1238 ;; 1239 *) 1240 new_emu_thr_defs="$new_emu_thr_defs $thr_def" 1241 ;; 1242 esac 1243done 1244EMU_THR_DEFS=$new_emu_thr_defs 1245 1246AC_SUBST(EMU_THR_LIB_NAME) 1247AC_SUBST(EMU_THR_X_LIBS) 1248AC_SUBST(EMU_THR_LIBS) 1249AC_SUBST(EMU_THR_DEFS) 1250 1251if test "x$enable_lock_check" = "xno"; then 1252 EMU_LOCK_CHECKING=no 1253else 1254 EMU_LOCK_CHECKING=yes 1255fi 1256 1257AC_SUBST(EMU_LOCK_CHECKING) 1258 1259ERL_INTERNAL_LIBS 1260 1261dnl THR_LIBS and THR_DEFS are only used by odbc 1262THR_LIBS=$ETHR_X_LIBS 1263THR_DEFS=$ETHR_DEFS 1264 1265AC_SUBST(THR_LIBS) 1266AC_SUBST(THR_DEFS) 1267 1268dnl ---------------------------------------------------------------------- 1269dnl Try to figure out where to get the termcap functions from. 1270dnl We use tgetent(), tgetflag(), tgetnum(), tgetstr() and tputs() 1271dnl ---------------------------------------------------------------------- 1272 1273TERMCAP_LIB= 1274 1275if test "x$with_termcap" != "xno" && 1276 test "X$host" != "Xwin32"; then 1277 # try these libs 1278 termcap_libs="tinfo ncurses curses termcap termlib" 1279 1280 for termcap_lib in $termcap_libs; do 1281 AC_CHECK_LIB($termcap_lib, tgetent, TERMCAP_LIB="-l$termcap_lib") 1282 if test "x$TERMCAP_LIB" != "x"; then 1283 break 1284 fi 1285 done 1286 1287 if test "x$TERMCAP_LIB" = "x"; then 1288 AC_MSG_ERROR([No curses library functions found]) 1289 fi 1290fi 1291 1292AC_SUBST(TERMCAP_LIB) 1293 1294if test "x$TERMCAP_LIB" != "x"; then 1295 1296 AC_DEFINE(HAVE_TERMCAP, 1, [Define if termcap functions exists]) 1297fi 1298 1299if test "X$host" != "Xwin32"; then 1300 AC_MSG_CHECKING(for wcwidth) 1301 AC_TRY_LINK([#include <wchar.h>], [wcwidth(0);], 1302 have_wcwidth=yes, have_wcwidth=no) 1303 if test $have_wcwidth = yes; then 1304 AC_MSG_RESULT([yes]) 1305 AC_DEFINE(HAVE_WCWIDTH, [1], 1306 [Define to 1 if you have a `wcwidth' function.]) 1307 fi 1308fi 1309 1310dnl ------------- 1311dnl zlib 1312dnl ------------- 1313 1314AC_ARG_ENABLE(builtin-zlib, 1315 AS_HELP_STRING([--enable-builtin-zlib], 1316 [force use of our own built-in zlib]), 1317 [ case "$enableval" in 1318 no) enable_builtin_zlib=no ;; 1319 *) enable_builtin_zlib=yes ;; 1320 esac ], enable_builtin_zlib=no) 1321 1322Z_LIB= 1323 1324if test "x$enable_builtin_zlib" = "xyes"; then 1325 AC_DEFINE(HAVE_ZLIB_INFLATEGETDICTIONARY, 1, 1326 [Define if your zlib version defines inflateGetDictionary.]) 1327 AC_MSG_NOTICE([Using our own built-in zlib source]) 1328else 1329AC_MSG_CHECKING(for zlib 1.2.5 or higher) 1330zlib_save_LIBS=$LIBS 1331LIBS="-lz $LIBS" 1332AC_LINK_IFELSE( 1333 [AC_LANG_PROGRAM([[ 1334#include "zlib.h" 1335]],[[ 1336#if ZLIB_VERNUM >= 0x1250 1337 Bytef s[1]; 1338 s[0] = 0; 1339 (void) adler32((uLong)0, s, 1); 1340#else 1341#error "No zlib 1.2.5 or higher found" 1342error 1343#endif 1344]])], 1345[ 1346 Z_LIB="-lz" 1347 AC_DEFINE(HAVE_LIBZ, 1, [Define to 1 if you have the `z' library (-lz).]) 1348 AC_MSG_RESULT(yes) 1349],[ 1350 AC_MSG_RESULT(no) 1351]) 1352 1353if test "$Z_LIB" != ""; then 1354 AC_SEARCH_LIBS(inflateGetDictionary, [z], 1355 AC_DEFINE(HAVE_ZLIB_INFLATEGETDICTIONARY, 1, 1356 [Define if your zlib version defines inflateGetDictionary.])) 1357fi 1358 1359LIBS=$zlib_save_LIBS 1360 1361fi 1362AC_SUBST(Z_LIB) 1363 1364 1365dnl ------------- 1366dnl esock 1367dnl ------------- 1368 1369AC_ARG_ENABLE(esock, 1370AS_HELP_STRING([--enable-esock], [enable builtin experimental socket (as a nif) support (default)]) 1371AS_HELP_STRING([--disable-esock], [disable builtin experimental socket (as a nif) support])) 1372 1373dnl Default value 1374USE_ESOCK=yes 1375 1376if test "x$enable_esock" = "xyes"; then 1377 USE_ESOCK=yes 1378else 1379 if test "x$enable_esock" = "xno"; then 1380 USE_ESOCK=no 1381 fi 1382fi 1383 1384if test "x$USE_ESOCK" = "xyes"; then 1385 if test "x$USE_ESOCK" = "xyes"; then 1386 AC_CHECK_FUNCS([localtime_r strftime getprotoent setprotoent endprotoent]) 1387 fi 1388fi 1389 1390AC_SUBST(USE_ESOCK) 1391 1392 1393dnl *** ESOCK_USE_RCVSNDTIMEO *** 1394 1395AC_ARG_ENABLE(esock_use_rcvsndtimeo, 1396AS_HELP_STRING([--enable-esock-rcvsndtimeo], [enable use of the option(s) rcvtimeo and sndtimeo]) 1397AS_HELP_STRING([--disable-esock-rcvsndtimeo], [disable use of the option(s) rcvtimeo and sndtimeo (default)])) 1398 1399if test "x$enable_esock_rcvsndtimeo" = "xyes"; then 1400 AC_DEFINE(ESOCK_USE_RCVSNDTIMEO, [1], [Use SO_[RCV|SND]TMIEO]) 1401fi 1402 1403 1404dnl *** ESOCK_COUNTER_SIZE *** 1405 1406AC_ARG_WITH(esock-counter-size, 1407AS_HELP_STRING([--with-esock-counter-size=SZ], 1408 [Size of the esock counters, in number of bits: 16 | 24 | 32 | 48 | 64; default is 64]), 1409[], 1410[with_esock_counter_size=64]) 1411 1412case "$with_esock_counter_size" in 1413 16) 1414 AC_DEFINE(ESOCK_COUNTER_SIZE, [16], [ESOCK counter size]) 1415 ;; 1416 24) 1417 AC_DEFINE(ESOCK_COUNTER_SIZE, [24], [ESOCK counter size]) 1418 ;; 1419 32) 1420 AC_DEFINE(ESOCK_COUNTER_SIZE, [32], [ESOCK counter size]) 1421 ;; 1422 48) 1423 AC_DEFINE(ESOCK_COUNTER_SIZE, [48], [ESOCK counter size]) 1424 ;; 1425 64) 1426 AC_DEFINE(ESOCK_COUNTER_SIZE, [64], [ESOCK counter size]) 1427 ;; 1428 *) 1429 AC_MSG_WARN([Invalid esock counter size ($with_esock_counter_size), using default (64)]) 1430 AC_DEFINE(ESOCK_COUNTER_SIZE, [64], [ESOCK counter size]) 1431 dnl with_esock_counter_size=64 1432 ;; 1433esac 1434dnl ESOCK_COUNTER_SIZE=$with_esock_counter_size 1435 1436dnl We don't actually (currently) use this in erlang 1437dnl AC_SUBST(ESOCK_COUNTER_SIZE) 1438 1439dnl Checks for the net nif 1440AC_CHECK_FUNC([if_nametoindex], 1441 [AC_DEFINE(HAVE_IF_NAMETOINDEX, [1], 1442 [Define as 1 if function exists])] 1443 []) 1444AC_CHECK_FUNC([if_indextoname], 1445 [AC_DEFINE(HAVE_IF_INDEXTONAME, [1], 1446 [Define as 1 if function exists])], 1447 []) 1448AC_CHECK_FUNC([if_nameindex], 1449 [AC_DEFINE(HAVE_IF_NAMEINDEX, [1], 1450 [Define as 1 if function exists])], 1451 []) 1452AC_CHECK_FUNC([if_freenameindex], 1453 [AC_DEFINE(HAVE_IF_FREENAMEINDEX, [1], 1454 [Define as 1 if function exists])] 1455 []) 1456AC_CHECK_FUNC([gethostname], 1457 [AC_DEFINE(HAVE_GETHOSTNAME, [1], 1458 [Define as 1 if function exists])] 1459 []) 1460 1461 1462dnl *** ESOCK_USE_SOCKET_REGISTRY *** 1463dnl At this time we *enable* use of the socket registry by default 1464dnl since we want to be able to have as much debug info as possible. 1465 1466AC_ARG_ENABLE(esock-socket-registry, 1467 AS_HELP_STRING([--enable-esock-socket-registry], 1468 [enable use of the socket registry by default (default)]) 1469 AS_HELP_STRING([--disable-esock-socket-registry], 1470 [disable use of the socket registry by default])) 1471 1472AS_IF([test "x$enable_esock_socket_registry" = "xno"], [ 1473 AC_DEFINE(ESOCK_USE_SOCKET_REGISTRY, [0], 1474 [Don't use socket registry by default])], [ 1475 AC_DEFINE(ESOCK_USE_SOCKET_REGISTRY, [1], 1476 [Use socket registry by default])]) 1477 1478 1479 1480dnl 1481dnl This test kindly borrowed from Tcl 1482dnl 1483#-------------------------------------------------------------------- 1484# Check for the existence of the -lsocket and -lnsl libraries. 1485# The order here is important, so that they end up in the right 1486# order in the command line generated by make. Here are some 1487# special considerations: 1488# 1. Use "connect" and "accept" to check for -lsocket, and 1489# "gethostbyname" to check for -lnsl. 1490# 2. Use each function name only once: can't redo a check because 1491# autoconf caches the results of the last check and won't redo it. 1492# 3. Use -lnsl and -lsocket only if they supply procedures that 1493# aren't already present in the normal libraries. This is because 1494# IRIX 5.2 has libraries, but they aren't needed and they're 1495# bogus: they goof up name resolution if used. 1496# 4. On some SVR4 systems, can't use -lsocket without -lnsl too. 1497# To get around this problem, check for both libraries together 1498# if -lsocket doesn't work by itself. 1499#-------------------------------------------------------------------- 1500 1501tk_oldLibs=$LIBS 1502erl_checkBoth=0 1503SOCKET_LIBS="" 1504AC_CHECK_FUNC(connect, erl_checkSocket=0, erl_checkSocket=1) 1505if test "$erl_checkSocket" = 1; then 1506 AC_CHECK_LIB(socket, main, SOCKET_LIBS="-lsocket", erl_checkBoth=1) 1507fi 1508 1509if test "$erl_checkBoth" = 1; then 1510 LIBS="$LIBS -lsocket -lnsl" 1511 AC_CHECK_FUNC(accept, SOCKET_LIBS="-lsocket -lnsl") 1512fi 1513 1514LIBS="$tk_oldLibs $SOCKET_LIBS" 1515AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [SOCKET_LIBS="$SOCKET_LIBS -lnsl"])) 1516AC_CHECK_FUNC(gethostbyname_r,have_gethostbyname_r=yes) 1517 1518LIBS="$tk_oldLibs $SOCKET_LIBS" 1519 1520AC_SUBST(SOCKET_LIBS) 1521 1522dnl 1523dnl These gethostbyname thingies use old style AC_DEFINE for BC with ancient 1524dnl autoconf... 1525dnl 1526 1527if test "$have_gethostbyname_r" = yes; then 1528 # OK, so we have gethostbyname_r() - but do we know how to call it...? 1529 # (if not, HAVE_GETHOSTBYNAME_R will not be defined at all) 1530 case $host_os in 1531 solaris2*) 1532 AC_DEFINE(HAVE_GETHOSTBYNAME_R, GHBN_R_SOLARIS, 1533 [Define to flavour of gethostbyname_r]) 1534 ;; 1535 aix*|os400*) 1536 # AIX version also needs "struct hostent_data" defn 1537 AC_TRY_COMPILE([#include <netdb.h>], 1538 [struct hostent_data hd;], 1539 AC_DEFINE(HAVE_GETHOSTBYNAME_R, GHBN_R_AIX, 1540 [Define to flavour of gethostbyname_r])) 1541 ;; 1542 *) 1543 AC_EGREP_CPP(^yes$,[ 1544#include <stdio.h> 1545#ifdef __GLIBC__ 1546yes 1547#endif 1548 ], AC_DEFINE(HAVE_GETHOSTBYNAME_R, GHBN_R_GLIBC, 1549 [Define to flavour of gethostbyname_r])) 1550 ;; 1551 esac 1552fi 1553 1554AC_MSG_CHECKING(for working posix_openpt implementation) 1555AC_TRY_LINK([ 1556#define _XOPEN_SOURCE 600 1557#include <stdlib.h> 1558#include <fcntl.h> 1559], 1560[ 1561 int mfd = posix_openpt(O_RDWR); 1562 ptsname(mfd); 1563 grantpt(mfd); 1564 unlockpt(mfd); 1565 return mfd; 1566], working_posix_openpt=yes, working_posix_openpt=no) 1567 1568if test "X$working_posix_openpt" = "Xyes"; then 1569 AC_DEFINE(HAVE_WORKING_POSIX_OPENPT, [1], 1570 [Define if you have a working posix_openpt implementation]) 1571 AC_MSG_RESULT(yes) 1572else 1573 AC_MSG_RESULT(no) 1574fi 1575 1576dnl Check for usage of sockaddr_in in netdb.h 1577dnl somewhat ugly check, I check for presence of the string and that 1578dnl compilation works. If either fails I assume it's not needed. 1579dnl Seems only to be needed on a patched version of solaris2.5.1, with 1580dnl netdb.h version 1.18. 1581AC_MSG_CHECKING([if netdb.h requires netinet/in.h to be previously included]) 1582AC_EGREP_CPP(sockaddr_in, 1583 [#include <netdb.h>], 1584 AC_TRY_COMPILE([#include <netinet/in.h> 1585 #include <netdb.h>], 1586 [return 0;], 1587 need_in_h=yes, 1588 need_in_h=no), 1589 need_in_h=no) 1590 1591if test $need_in_h = yes; then 1592 AC_DEFINE(NETDB_H_NEEDS_IN_H,[1], 1593 [Define if netdb.h needs struct sockaddr_in ans in.h CAN be included before]) 1594 AC_MSG_RESULT(yes) 1595else 1596 AC_MSG_RESULT(no) 1597fi 1598 1599dnl Check for type socklen_t 1600dnl 1601AC_MSG_CHECKING([for socklen_t]) 1602AC_TRY_COMPILE( [#include <sys/socket.h>], 1603 [socklen_t test;], 1604 have_socklen_t=yes, 1605 have_socklen_t=no), 1606 1607if test $have_socklen_t = yes; then 1608 AC_DEFINE(HAVE_SOCKLEN_T,[1],[Define if we have socklen_t]) 1609 AC_MSG_RESULT(yes) 1610else 1611 AC_MSG_RESULT(no) 1612fi 1613 1614 1615dnl h_errno isn't always declared in netdb.h, and with some definitions 1616dnl (e.g. function call for thread-safe) a simple 'extern int' may conflict 1617dnl (we do assume that h_errno exists at all...) 1618AC_CACHE_CHECK([for h_errno declaration in netdb.h], 1619 ac_cv_decl_h_errno, 1620[AC_TRY_COMPILE([#include <netdb.h>], [int err = h_errno;], 1621 ac_cv_decl_h_errno=yes, ac_cv_decl_h_errno=no)]) 1622if test $ac_cv_decl_h_errno = yes; then 1623 AC_DEFINE(H_ERRNO_DECLARED,[1], 1624 [define if h_errno is declared (in some way) in a system header file]) 1625fi 1626 1627 1628dnl ---------------------------------------------------------------------- 1629dnl Checks for header files. 1630dnl ---------------------------------------------------------------------- 1631 1632dnl We sometimes need EMU_THR_DEFS in order to find certain headers. 1633saved_cppflags=$CPPFLAGS 1634CPPFLAGS="$CPPFLAGS $EMU_THR_DEFS" 1635 1636AC_HEADER_DIRENT 1637AC_HEADER_STDC 1638AC_HEADER_SYS_WAIT 1639AC_HEADER_TIME 1640 1641dnl Interactive UX needs <net/errno.h> for socket related error codes. 1642dnl Some Linuxes needs <sys/socketio.h> instead of <sys/sockio.h> 1643dnl 1644AC_CHECK_HEADERS(fcntl.h limits.h unistd.h syslog.h dlfcn.h ieeefp.h \ 1645 sys/types.h sys/stropts.h sys/sysctl.h \ 1646 sys/ioctl.h sys/time.h sys/uio.h sys/mman.h \ 1647 sys/socket.h sys/sockio.h sys/socketio.h \ 1648 net/errno.h malloc.h arpa/nameser.h libdlpi.h \ 1649 pty.h util.h libutil.h utmp.h langinfo.h poll.h sdkddkver.h \ 1650 elf.h) 1651 1652AC_CHECK_MEMBERS([struct ifreq.ifr_hwaddr], [], [], 1653 [#ifdef __WIN32__ 1654 #else 1655 #include <net/if.h> 1656 #endif 1657 ]) 1658 1659AC_CHECK_MEMBERS([struct ifreq.ifr_enaddr], [], [], 1660 [#ifdef __WIN32__ 1661 #else 1662 #include <net/if.h> 1663 #endif 1664 ]) 1665 1666dnl ---------------------------------------------------------------------- 1667dnl Check the availability of systemd 1668dnl ---------------------------------------------------------------------- 1669if test x"$enable_systemd" != x"no"; then 1670 1671systemd_daemon_save_LIBS=$LIBS 1672LIBS= 1673AC_SEARCH_LIBS(sd_listen_fds,[systemd systemd-daemon], 1674 [have_sd_listen_fds=yes],[have_sd_listen_fds=no],$systemd_daemon_save_LIBS) 1675AC_SEARCH_LIBS(sd_notify,[systemd systemd-daemon], 1676 [have_sd_notify=yes],[have_sd_notify=no],$systemd_daemon_save_LIBS) 1677AC_CHECK_HEADERS(systemd/sd-daemon.h, 1678 [have_systemd_sd_daemon_h=yes],[have_systemd_sd_daemon_h=no]) 1679 1680if test x"$have_sd_listen_fds" = x"yes" && \ 1681 test x"$have_sd_notify" = x"yes" && \ 1682 test x"$have_systemd_sd_daemon_h" = x"yes"; then 1683 AC_DEFINE([HAVE_SYSTEMD_DAEMON],[1],[Define if you have systemd daemon]) 1684 SYSTEMD_DAEMON_LIBS=$LIBS 1685elif test x"$enable_systemd" = x"yes"; then 1686 AC_MSG_FAILURE([--enable-systemd was given, but test for systemd failed]) 1687fi 1688LIBS=$systemd_daemon_save_LIBS 1689fi 1690AC_SUBST(SYSTEMD_DAEMON_LIBS) 1691 1692 1693dnl ---------------------------------------------------------------------- 1694dnl Check the availability for libdlpi 1695dnl ---------------------------------------------------------------------- 1696AC_CHECK_LIB(dlpi, dlpi_open) 1697if test x"$ac_cv_lib_dlpi_dlpi_open" = x"no"; then 1698 unset -v ac_cv_lib_dlpi_dlpi_open 1699 dnl Try again now with -L/lib (or ditto 64) as argument to linker since 1700 dnl gcc makes /usr/ccs/bin/ld ignore the crle configured linker default paths 1701 dnl typically causing dlpi not being found on Solaris et.al 1702 save_ldflags="$LDFLAGS" 1703 try_dlpi_lib=/lib 1704 if test x"$ac_cv_sizeof_void_p" = x"8"; then 1705 if test -d /lib64; then 1706 try_dlpi_lib=/lib64 1707 elif test -d /lib/64; then 1708 try_dlpi_lib=/lib/64 1709 fi 1710 fi 1711 if test ! -f "$try_dlpi_lib/libdlpi.so" && \ 1712 test -f "$try_dlpi_lib/libdlpi.so.1" 1713 then 1714 dnl It looks like there is a missing symlink 1715 dnl - let's be helpful and notify the user 1716 dnl NOTE this help is far from perfect e.g if there would be no 1717 dnl *.so.1 but a *.so.1.123 or *.so.2 this will be no help 1718 AC_MSG_ERROR( 1719 [Your OS installation is missing a symbolic link. 1720 Maybe it lacks some development package(s)... 1721 It can anyhow be fixed with the following command: 1722 # ln -s libdlpi.so.1 $try_dlpi_lib/libdlpi.so 1723 ]) 1724 fi 1725 LDFLAGS="-L$try_dlpi_lib -R$try_dlpi_lib $LDFLAGS" 1726 unset -v try_dlpi_lib 1727 AC_MSG_NOTICE([Extending the search to include /lib]) 1728 AC_CHECK_LIB(dlpi, dlpi_open) 1729 if test x"$ac_cv_lib_dlpi_dlpi_open" = x"no"; then 1730 LDFLAGS="$save_ldflags" 1731 fi 1732 unset -v save_ldflags 1733fi 1734 1735AC_CHECK_HEADER(sys/resource.h, 1736 [AC_DEFINE(HAVE_SYS_RESOURCE_H, 1, 1737 [Define to 1 if you have the <sys/resource.h> header file]) 1738 AC_CHECK_DECLS([getrlimit, setrlimit, RLIMIT_STACK], 1739 [],[], 1740 [#include <sys/resource.h>])], 1741 [],[]) 1742 1743AC_CHECK_FUNCS([getrusage]) 1744 1745dnl Check if we have kernel poll support 1746have_kernel_poll=no 1747AC_CHECK_HEADER(sys/event.h, have_kernel_poll=kqueue) 1748AC_CHECK_HEADER(sys/epoll.h, have_kernel_poll=epoll) 1749AC_CHECK_HEADER(sys/devpoll.h, have_kernel_poll=/dev/poll) 1750 1751dnl Check if we have timerfds to be used for high accuracy 1752dnl epoll_wait timeouts 1753AC_CHECK_HEADERS([sys/timerfd.h]) 1754 1755dnl Check if we have the header file 'netpacket/packat.h' in which 1756dnl type 'struct sockaddr_ll' is defined. 1757AC_CHECK_HEADERS([netpacket/packet.h], 1758 have_netpacket_packet_h=yes, 1759 have_netpacket_packet_h=no) 1760 1761dnl Check for kernel SCTP support 1762AC_SUBST(LIBSCTP) 1763if test "x$enable_sctp" != "xno" ; then 1764 AC_CHECK_HEADER(netinet/sctp.h, 1765 [LIBSCTP=libsctp.so.1 1766 AC_DEFINE(HAVE_SCTP_H, [1], 1767 [Define to 1 if you have the <netinet/sctp.h> header file])], 1768 [], 1769 [#if HAVE_SYS_SOCKET_H 1770 #include <sys/socket.h> 1771 #endif 1772 ]) 1773fi 1774 1775case "x$enable_sctp" in 1776 xno|x) 1777 ;; 1778 *) 1779 if test "x$LIBSCTP" = "x" ; then 1780 AC_MSG_ERROR([sctp support requested, but cannot be enabled since 'netinet/sctp.h' is missing]) 1781 fi;; 1782esac 1783 1784if test x"$ac_cv_header_netinet_sctp_h" = x"yes"; then 1785 AS_IF([test "x$enable_sctp" = "xlib"], 1786 AC_CHECK_LIB(sctp, sctp_bindx)) 1787 AC_CHECK_FUNCS([sctp_bindx sctp_peeloff sctp_getladdrs sctp_freeladdrs sctp_getpaddrs sctp_freepaddrs]) 1788 AC_CHECK_MEMBERS([struct sctp_accoc_value.assoc_id], [], [], 1789 [#if HAVE_SYS_SOCKET_H 1790 #include <sys/socket.h> 1791 #endif 1792 #include <netinet/sctp.h> 1793 ]) 1794 AC_CHECK_DECLS([SCTP_UNORDERED, SCTP_ADDR_OVER, SCTP_ABORT, 1795 SCTP_EOF, SCTP_SENDALL, SCTP_ADDR_CONFIRMED, 1796 SCTP_DELAYED_ACK_TIME, 1797 SCTP_EMPTY, SCTP_UNCONFIRMED, 1798 SCTP_CLOSED, SCTPS_IDLE, 1799 SCTP_BOUND, SCTPS_BOUND, 1800 SCTP_LISTEN, SCTPS_LISTEN, 1801 SCTP_COOKIE_WAIT, SCTPS_COOKIE_WAIT, 1802 SCTP_COOKIE_ECHOED, SCTPS_COOKIE_ECHOED, 1803 SCTP_ESTABLISHED, SCTPS_ESTABLISHED, 1804 SCTP_SHUTDOWN_PENDING, SCTPS_SHUTDOWN_PENDING, 1805 SCTP_SHUTDOWN_SENT, SCTPS_SHUTDOWN_SENT, 1806 SCTP_SHUTDOWN_RECEIVED, SCTPS_SHUTDOWN_RECEIVED, 1807 SCTP_SHUTDOWN_ACK_SENT, SCTPS_SHUTDOWN_ACK_SENT], [], [], 1808 [#if HAVE_SYS_SOCKET_H 1809 #include <sys/socket.h> 1810 #endif 1811 #include <netinet/sctp.h> 1812 ]) 1813 AC_CHECK_MEMBERS([struct sctp_paddrparams.spp_pathmtu, 1814 struct sctp_paddrparams.spp_sackdelay, 1815 struct sctp_paddrparams.spp_flags, 1816 struct sctp_remote_error.sre_data, 1817 struct sctp_send_failed.ssf_data, 1818 struct sctp_event_subscribe.sctp_authentication_event, 1819 struct sctp_event_subscribe.sctp_sender_dry_event], [], [], 1820 [#if HAVE_SYS_SOCKET_H 1821 #include <sys/socket.h> 1822 #endif 1823 #include <netinet/sctp.h> 1824 ]) 1825fi 1826 1827dnl Check for setns 1828AC_CHECK_HEADERS(sched.h setns.h) 1829AC_CHECK_FUNCS([setns]) 1830 1831dnl Check for linux/errqueue 1832AC_CHECK_HEADERS([linux/types.h linux/errqueue.h], [], [], 1833[[#ifdef HAVE_SYS_TIME_H 1834# include <sys/time.h> 1835#endif 1836#ifdef HAVE_LINUX_TYPES_H 1837# include <linux/types.h> 1838#endif 1839]]) 1840 1841HAVE_VALGRIND=no 1842AC_CHECK_HEADER(valgrind/valgrind.h, HAVE_VALGRIND=yes) 1843AC_SUBST(HAVE_VALGRIND) 1844 1845LM_DECL_SO_BSDCOMPAT 1846LM_DECL_INADDR_LOOPBACK 1847LM_DECL_SYS_ERRLIST 1848 1849AC_CACHE_CHECK([if windows.h includes winsock2.h], 1850 erts_cv_windows_h_includes_winsock2_h, 1851 AC_TRY_COMPILE([#include <windows.h> 1852 ], 1853 [#ifndef _WINSOCK2API_ 1854 #error winsock2.h not included 1855 #endif 1856 int i = 1; 1857 ], 1858 erts_cv_windows_h_includes_winsock2_h=yes, 1859 erts_cv_windows_h_includes_winsock2_h=no)) 1860if test $erts_cv_windows_h_includes_winsock2_h = yes; then 1861 AC_DEFINE(WINDOWS_H_INCLUDES_WINSOCK2_H, 1, \ 1862[Define if windows.h includes winsock2.h]) 1863fi 1864 1865dnl restore CPPFLAGS 1866CPPFLAGS=$saved_cppflags 1867 1868dnl ---------------------------------------------------------------------- 1869dnl Checks for typedefs, structures, and compiler characteristics. 1870dnl ---------------------------------------------------------------------- 1871 1872AC_C_CONST 1873AC_TYPE_SIGNAL 1874AC_TYPE_OFF_T 1875AC_TYPE_PID_T 1876AC_TYPE_SIZE_T 1877 1878AC_STRUCT_TM 1879LM_STRUCT_SOCKADDR_SA_LEN 1880 1881AC_CHECK_SIZEOF(char, 1) 1882AC_CHECK_SIZEOF(short) 1883AC_CHECK_SIZEOF(int) 1884AC_CHECK_SIZEOF(long) 1885AC_CHECK_SIZEOF(void *) 1886AC_CHECK_SIZEOF(long long) 1887AC_CHECK_SIZEOF(size_t) 1888AC_CHECK_SIZEOF(off_t) 1889AC_CHECK_SIZEOF(time_t) 1890AC_CHECK_SIZEOF(suseconds_t) 1891AC_CHECK_SIZEOF(_Float16) 1892 1893BITS64= 1894 1895if test $ac_cv_sizeof_void_p = 8; then 1896 BITS64=yes 1897fi 1898AC_SUBST(BITS64) 1899 1900AC_MSG_CHECKING([for C compiler 'restrict' support]) 1901restrict_keyword="" 1902for x in restrict __restrict; do 1903 AC_TRY_COMPILE([int * $x foo(int * $x arg); 1904 int * $x foo(int * $x arg) 1905 { int * $x var=arg; return var;} 1906 ],[], 1907 [restrict_keyword=$x],[]) 1908 if test "x$restrict_keyword" != "x"; then 1909 break 1910 fi 1911done 1912AC_DEFINE_UNQUOTED(ERTS_RESTRICT,[$restrict_keyword],[Type qualifier restrict]) 1913if test "x$restrict_keyword" != "x"; then 1914 AC_MSG_RESULT(yes) 1915else 1916 AC_MSG_RESULT(no) 1917fi 1918 1919if test "x$ac_compiler_gnu" = "xyes"; then 1920AC_MSG_CHECKING([if we should add -fno-tree-copyrename to CFLAGS for computed gotos to work properly]) 1921## tree-copyrename was broken in gcc 4.3 and then removed in gcc 6 1922AC_TRY_COMPILE([],[ 1923 #if (__GNUC__ > 4 && __GNUC__ < 6) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 1924 ; 1925 #else 1926 #error old and ok 1927 #endif 1928 ], 1929 no_tree_copyrename=yes, 1930 no_tree_copyrename=no) 1931 1932if test "x$no_tree_copyrename" = "xyes"; then 1933 CFLAGS="$CFLAGS -fno-tree-copyrename" 1934 AC_MSG_RESULT(yes, adjusting CFLAGS) 1935else 1936 AC_MSG_RESULT(no) 1937fi 1938 1939AC_MSG_CHECKING([for broken gcc-4.3.0 compiler]) 1940AC_TRY_RUN([ 1941/* pr36339.c */ 1942extern void abort (void); 1943 1944typedef unsigned long my_uintptr_t; 1945 1946int check_a(my_uintptr_t tagged_ptr); 1947 1948int __attribute__((noinline)) try_a(my_uintptr_t x) 1949{ 1950 my_uintptr_t heap[2]; 1951 my_uintptr_t *hp = heap; 1952 1953 hp[0] = x; 1954 hp[1] = 0; 1955 return check_a((my_uintptr_t)(void*)((char*)hp + 1)); 1956} 1957 1958int __attribute__((noinline)) check_a(my_uintptr_t tagged_ptr) 1959{ 1960 my_uintptr_t *hp = (my_uintptr_t*)(void*)((char*)tagged_ptr - 1); 1961 1962 if (hp[0] == 42 && hp[1] == 0) 1963 return 0; 1964 return -1; 1965} 1966 1967int main(void) 1968{ 1969 if (try_a(42) < 0) 1970 abort (); 1971 return 0; 1972} 1973], gcc_4_3_0_bug=no, gcc_4_3_0_bug=yes, gcc_4_3_0_bug=cross) 1974 1975case $gcc_4_3_0_bug in 1976 yes|no) 1977 gcc_4_3_0_bug_result=$gcc_4_3_0_bug;; 1978 cross) 1979 gcc_dumped_vsn=`$CC -dumpversion 2>/dev/null` 1980 case gcc-$gcc_dumped_vsn in 1981 gcc-4.3.0) gcc_4_3_0_bug=yes;; 1982 *) gcc_4_3_0_bug=no;; 1983 esac 1984 gcc_4_3_0_bug_result="$gcc_4_3_0_bug; could not run test since cross compiling, checked version number ($gcc_dumped_vsn) instead";; 1985esac 1986 1987AC_MSG_RESULT([$gcc_4_3_0_bug_result]) 1988if test $gcc_4_3_0_bug = yes; then 1989 AC_MSG_ERROR([This gcc miscompiles the Erlang runtime system; please use a different version]) 1990fi 1991 1992fi 1993 1994case X$erl_xcomp_bigendian in 1995 X) ;; 1996 Xyes|Xno) ac_cv_c_bigendian=$erl_xcomp_bigendian;; 1997 *) AC_MSG_ERROR([Bad erl_xcomp_bigendian value: $erl_xcomp_bigendian]);; 1998esac 1999 2000AC_C_BIGENDIAN( 2001 [ 2002 AC_DEFINE([WORDS_BIGENDIAN], [1], [Define if big-endian]) 2003 AC_DEFINE([ERTS_ENDIANNESS], [1], [Define > 0 if big-endian < 0 if little-endian, or 0 if unknown]) 2004 ], 2005 [ 2006 AC_DEFINE([ERTS_ENDIANNESS], [-1], [Define > 0 if big-endian < 0 if little-endian, or 0 if unknown]) 2007 ], 2008 [ 2009 case "$erl_xcomp_bigendian" in 2010 yes) 2011 AC_DEFINE([ERTS_ENDIANNESS], [1], [Define > 0 if big-endian < 0 if little-endian, or 0 if unknown]);; 2012 no) 2013 AC_DEFINE([ERTS_ENDIANNESS], [-1], [Define > 0 if big-endian < 0 if little-endian, or 0 if unknown]);; 2014 *) 2015 AC_DEFINE([ERTS_ENDIANNESS], [0], [Define > 0 if big-endian < 0 if little-endian, or 0 if unknown]);; 2016 esac 2017 ]) 2018 2019AC_C_DOUBLE_MIDDLE_ENDIAN 2020 2021dnl fdatasync syscall (Unix only) 2022AC_CHECK_FUNCS([fdatasync]) 2023 2024dnl Find which C libraries are required to use fdatasync 2025dnl TODO: Remove check once SunOS >= 5.11 is required by erts. 2026dnl fdatasync requires linking against -lrt on SunOS <= 5.10. 2027dnl OpenSolaris 2009.06 is SunOS 5.11 and does not require -lrt. 2028AC_SEARCH_LIBS(fdatasync, [rt]) 2029 2030 2031dnl sendfile syscall 2032case $host_os in 2033 linux*|freebsd*|dragonfly*|darwin*) 2034 AC_CHECK_FUNCS([sendfile]) 2035 ;; 2036 solaris*) 2037 AC_SEARCH_LIBS(sendfilev, sendfile, 2038 AC_DEFINE([HAVE_SENDFILEV],[1], 2039 [Define to 1 if you have the `sendfilev' function.])) 2040 ;; 2041 win32) 2042 LIBS="$LIBS -lmswsock" 2043 ;; 2044 *) 2045 ;; 2046esac 2047 2048dnl ---------------------------------------------------------------------- 2049dnl Checks for library functions. 2050dnl ---------------------------------------------------------------------- 2051 2052dnl We may need the thread library and thread flags in order to find right stuff 2053saved_cppflags=$CPPFLAGS 2054CPPFLAGS="$CPPFLAGS $EMU_THR_DEFS" 2055saved_libs=$LIBS 2056LIBS="$LIBS $EMU_THR_X_LIBS" 2057 2058dnl Check if we have these, in which case we'll try to build 2059dnl inet_gethost with ipv6 support. 2060AC_CHECK_HEADERS(windows.h) 2061AC_CHECK_HEADERS(winsock2.h) 2062AC_CHECK_HEADERS(ws2tcpip.h,[],[],[ 2063#ifdef HAVE_WINSOCK2_H 2064#include <winsock2.h> 2065#endif 2066#ifdef HAVE_WINDOWS_H 2067#include <windows.h> 2068#endif 2069]) 2070dnl AC_CHECK_FUNC(getaddrinfo, have_getaddrinfo=yes, have_getaddrinfo=no) 2071AC_MSG_CHECKING(for getaddrinfo) 2072AC_TRY_LINK([ 2073#include <stdlib.h> 2074#include <string.h> 2075#ifdef HAVE_WINSOCK2_H 2076#include <winsock2.h> 2077#endif 2078#ifdef HAVE_WINDOWS_H 2079#include <windows.h> 2080#endif 2081#ifdef HAVE_WS2TCPIP_H 2082#include <ws2tcpip.h> 2083#endif 2084#ifndef __WIN32__ 2085#include <sys/socket.h> 2086#include <netdb.h> 2087#endif 2088], 2089[ 2090getaddrinfo("","",NULL,NULL); 2091],have_getaddrinfo=yes, have_getaddrinfo=no) 2092if test $have_getaddrinfo = yes; then 2093 AC_MSG_RESULT([yes]) 2094 AC_MSG_CHECKING([whether getaddrinfo accepts enough flags]) 2095 AC_TRY_LINK([ 2096#include <stdlib.h> 2097#include <string.h> 2098#ifdef HAVE_WINSOCK2_H 2099#include <winsock2.h> 2100#endif 2101#ifdef HAVE_WINDOWS_H 2102#include <windows.h> 2103#endif 2104#ifdef HAVE_WS2TCPIP_H 2105#include <ws2tcpip.h> 2106#endif 2107#ifndef __WIN32__ 2108#include <sys/socket.h> 2109#include <netdb.h> 2110#endif 2111], 2112[ 2113 struct addrinfo hints, *ai; 2114 memset(&hints, 0, sizeof(hints)); 2115 hints.ai_flags = AI_CANONNAME; 2116 hints.ai_socktype = SOCK_STREAM; 2117 hints.ai_family = AF_INET6; 2118 if (getaddrinfo("::", NULL, &hints, &ai) == 0) { 2119 freeaddrinfo(ai); 2120 exit(0); 2121 } else { 2122 exit(1); 2123 } 2124],, have_getaddrinfo=no) 2125 AC_MSG_RESULT($have_getaddrinfo) 2126 case $have_getaddrinfo in 2127 yes) 2128 AC_DEFINE(HAVE_GETADDRINFO, [1], 2129 [Define to 1 if you have a good `getaddrinfo' function.]);; 2130 *) ;; 2131 esac 2132else 2133 AC_MSG_RESULT([no]) 2134fi 2135AC_MSG_CHECKING(for getnameinfo) 2136AC_TRY_LINK([ 2137#include <stdlib.h> 2138#include <string.h> 2139#ifdef HAVE_WINSOCK2_H 2140#include <winsock2.h> 2141#endif 2142#ifdef HAVE_WINDOWS_H 2143#include <windows.h> 2144#endif 2145#ifdef HAVE_WS2TCPIP_H 2146#include <ws2tcpip.h> 2147#endif 2148#ifndef __WIN32__ 2149#include <sys/socket.h> 2150#include <netdb.h> 2151#endif 2152], 2153[ 2154getnameinfo(NULL,0,NULL,0,NULL,0,0); 2155],have_getnameinfo=yes, have_getnameinfo=no) 2156if test $have_getnameinfo = yes; then 2157 AC_MSG_RESULT([yes]) 2158 AC_DEFINE(HAVE_GETNAMEINFO, [1], 2159 [Define to 1 if you have a good `getnameinfo' function.]) 2160else 2161 AC_MSG_RESULT([no]) 2162fi 2163 2164 2165AC_CHECK_FUNCS([getipnodebyname getipnodebyaddr gethostbyname2]) 2166 2167AC_CHECK_FUNCS([ieee_handler fpsetmask finite isnan isinf res_gethostbyname dlopen \ 2168 pread pwrite memmove strerror strerror_r strncasecmp \ 2169 gethrtime localtime_r gmtime_r mprotect madvise posix_madvise \ 2170 mmap mremap memcpy mallopt sbrk _sbrk __sbrk brk _brk __brk \ 2171 flockfile fstat strlcpy strlcat setsid posix2time time2posix \ 2172 setlocale nl_langinfo poll mlockall ppoll vsyslog]) 2173 2174## We have a special check for inet_pton as AC_CHECK_FUCNS does not work 2175## on windows 32-bit as there a macro is used to rename the symbol... 2176AC_MSG_CHECKING([for inet_pton]) 2177AC_TRY_LINK([ 2178#ifdef WIN32 2179#include <ws2tcpip.h> 2180#else 2181#include <arpa/inet.h> 2182#endif 2183],[inet_pton(2,"",(void*)0)], have_inet_pton=yes, have_inet_pton=no) 2184 2185if test $have_inet_pton = yes; then 2186 AC_DEFINE(HAVE_INET_PTON,[1], 2187 [Define to 1 if you have the `inet_pton' function.]) 2188 AC_MSG_RESULT(yes) 2189else 2190 AC_MSG_RESULT(no) 2191fi 2192 2193AC_MSG_CHECKING([for isfinite]) 2194AC_TRY_LINK([#include <math.h>], 2195 [isfinite(0);], have_isfinite=yes, have_isfinite=no) 2196 2197if test $have_isfinite = yes; then 2198 AC_DEFINE(HAVE_ISFINITE,[1], 2199 [Define to 1 if you have the `isfinite' function.]) 2200 AC_MSG_RESULT(yes) 2201else 2202 AC_MSG_RESULT(no) 2203fi 2204 2205case X$erl_xcomp_posix_memalign in 2206 Xno) ;; 2207 Xyes) have_posix_memalign=yes ;; 2208 *) 2209 AC_CHECK_FUNC( 2210 [posix_memalign], 2211 [if test "$cross_compiling" != yes; then 2212AC_TRY_RUN([ 2213#include <stdlib.h> 2214int main(void) { 2215 void *ptr = NULL; 2216 int error; 2217 size_t alignment = 0x40000, size = 0x20028; 2218 if ((error = posix_memalign(&ptr, alignment, size)) != 0 || ptr == NULL) 2219 return error; 2220 return 0; 2221} 2222],have_posix_memalign=yes 2223) 2224 else 2225 have_posix_memalign=yes 2226 fi]);; 2227esac 2228 2229if test "$have_posix_memalign" = "yes"; then 2230 AC_DEFINE(HAVE_POSIX_MEMALIGN,[1], 2231 [Define to 1 if you have the `posix_memalign' function.]) 2232fi 2233 2234 2235dnl writev on OS X snow leopard is broken for files > 4GB 2236case $host_os in 2237 darwin10.8.0) 2238 AC_MSG_CHECKING([for writev]) 2239 AC_MSG_RESULT(no, not stable on OS X Snow Leopard) ;; 2240 *) 2241 AC_CHECK_FUNCS([writev]) ;; 2242esac 2243 2244AC_CHECK_DECLS([posix2time, time2posix],,,[#include <time.h>]) 2245 2246AC_FUNC_VPRINTF 2247 2248dnl The AC_DEFINEs are necessary for autoheader to work. :-( 2249dnl for gzio 2250LM_CHECK_FUNC_DECL(fread, [extern int fread();],, 2251 AC_DEFINE(HAVE_CONFLICTING_FREAD_DECLARATION,[1],[Define if you have a decl of fread that conflicts with int fread])) 2252 2253dnl Checking with TRY_LINK since putc_unlocked might be (probably is) a macro 2254AC_CACHE_CHECK([for putc_unlocked], 2255 erts_cv_putc_unlocked, 2256 AC_TRY_LINK([#include <stdio.h>], 2257 [int res = putc_unlocked('x',stdout);], 2258 erts_cv_putc_unlocked=yes, 2259 erts_cv_putc_unlocked=no)) 2260if test $erts_cv_putc_unlocked = yes; then 2261 AC_DEFINE(HAVE_PUTC_UNLOCKED, 1, [Define if you have putc_unlocked]) 2262fi 2263 2264dnl Checking with TRY_LINK since fwrite_unlocked might be a macro 2265AC_CACHE_CHECK([for fwrite_unlocked], 2266 erts_cv_fwrite_unlocked, 2267 AC_TRY_LINK([#include <stdio.h>], 2268 [size_t res = fwrite_unlocked(NULL,sizeof(char),0,stdout);], 2269 erts_cv_fwrite_unlocked=yes, 2270 erts_cv_fwrite_unlocked=no)) 2271if test $erts_cv_fwrite_unlocked = yes; then 2272 AC_DEFINE(HAVE_FWRITE_UNLOCKED, 1, [Define if you have fwrite_unlocked]) 2273fi 2274 2275dnl Need by run_erl. 2276AC_CHECK_FUNCS([openpty]) 2277 2278AC_CHECK_HEADERS(net/if_dl.h ifaddrs.h netpacket/packet.h sys/un.h) 2279AC_CHECK_FUNCS([getifaddrs]) 2280AC_CHECK_MEMBERS([struct sockaddr_un.sun_path], [], [], 2281 [[#include <sys/un.h>]]) 2282 2283dnl Checks for variables in6addr_any and in6addr_loopback, 2284dnl 2285dnl They normally declared by netinet/in.h, according to POSIX, 2286dnl but not on Windows 7 (Windows SDK 7.1). I would have liked 2287dnl to just write AC_CHECK_DECL([in6addr_any], ...) but if doing so, 2288dnl the configure check fails erroneously on Linux with the error 2289dnl "cannot convert to a pointer type", on a line looking like 2290dnl "char *p = (char *) in6addr_any;", so work around that 2291dnl with some more code. 2292AC_CACHE_CHECK( 2293 [whether in6addr_any is declared], 2294 [erts_cv_have_in6addr_any], 2295 [AC_LINK_IFELSE( 2296 [AC_LANG_PROGRAM( 2297 [[ 2298 #include <sys/types.h> 2299 #include <sys/socket.h> 2300 #include <netinet/in.h> 2301 #include <stdio.h> 2302 ]], 2303 [[printf("%d", in6addr_any.s6_addr[16]);]] 2304 )], 2305 [erts_cv_have_in6addr_any=yes], 2306 [erts_cv_have_in6addr_any=no] 2307 )] 2308) 2309 2310case "$erts_cv_have_in6addr_any" in 2311 yes) 2312 AC_DEFINE([HAVE_IN6ADDR_ANY], [1], 2313 [Define to 1 if you have the variable in6addr_any declared.]) 2314esac 2315 2316AC_CACHE_CHECK( 2317 [whether in6addr_loopback is declared], 2318 [erts_cv_have_in6addr_loopback], 2319 [AC_LINK_IFELSE( 2320 [AC_LANG_PROGRAM( 2321 [[ 2322 #include <sys/types.h> 2323 #include <sys/socket.h> 2324 #include <netinet/in.h> 2325 #include <stdio.h> 2326 ]], 2327 [[printf("%d", in6addr_loopback.s6_addr[16]);]] 2328 )], 2329 [erts_cv_have_in6addr_loopback=yes], 2330 [erts_cv_have_in6addr_loopback=no] 2331 )] 2332) 2333 2334case "$erts_cv_have_in6addr_loopback" in 2335 yes) 2336 AC_DEFINE([HAVE_IN6ADDR_LOOPBACK], [1], 2337 [Define to 1 if you have the variable in6addr_loopback declared.]) 2338esac 2339 2340AC_CHECK_DECLS([IN6ADDR_ANY_INIT, IN6ADDR_LOOPBACK_INIT, IPV6_V6ONLY], [], [], 2341 [ 2342 #include <sys/types.h> 2343 #include <sys/socket.h> 2344 #include <netinet/in.h> 2345 ]) 2346 2347dnl ---------------------------------------------------------------------- 2348dnl Checks for features/quirks in the system that affects Erlang. 2349dnl ---------------------------------------------------------------------- 2350 2351AC_MSG_CHECKING([for sched_getaffinity/sched_setaffinity]) 2352AC_TRY_LINK([#include <sched.h>], 2353[ 2354#ifndef CPU_SETSIZE 2355#error no CPU_SETSIZE 2356#endif 2357 int res; 2358 cpu_set_t cpuset; 2359 CPU_ZERO(&cpuset); 2360 CPU_SET(1, &cpuset); 2361 res = sched_setaffinity(0, sizeof(cpu_set_t), &cpuset); 2362 res = sched_getaffinity(0, sizeof(cpu_set_t), &cpuset); 2363 res = CPU_ISSET(1, &cpuset); 2364 CPU_CLR(1, &cpuset); 2365], 2366 sched_xetaffinity=yes, 2367 sched_xetaffinity=no) 2368AC_MSG_RESULT([$sched_xetaffinity]) 2369if test $sched_xetaffinity = yes; then 2370 AC_DEFINE(HAVE_SCHED_xETAFFINITY, 1, [Define if you have sched_getaffinity/sched_setaffinity]) 2371fi 2372 2373 2374AC_MSG_CHECKING([for pset functionality]) 2375AC_TRY_LINK([#include <sys/pset.h>], 2376[ 2377 int res; 2378 psetid_t id = PS_MYID; 2379 int type = PS_PRIVATE; 2380 uint_t numcpus = 1024; 2381 processorid_t cpulist[1024]; 2382 2383 res = pset_info(id, &type, &numcpus, &cpulist[0]); 2384], 2385 pset_functionality=yes, 2386 pset_functionality=no) 2387AC_MSG_RESULT([$pset_functionality]) 2388if test $pset_functionality = yes; then 2389 AC_DEFINE(HAVE_PSET, 1, [Define if you have pset functionality]) 2390fi 2391 2392AC_MSG_CHECKING([for processor_bind functionality]) 2393AC_TRY_LINK([ 2394#include <sys/types.h> 2395#include <sys/processor.h> 2396#include <sys/procset.h> 2397], 2398[ 2399 int res = processor_bind(P_LWPID, P_MYID, PBIND_NONE, NULL); 2400], 2401 processor_bind_functionality=yes, 2402 processor_bind_functionality=no) 2403AC_MSG_RESULT([$processor_bind_functionality]) 2404if test $processor_bind_functionality = yes; then 2405 AC_DEFINE(HAVE_PROCESSOR_BIND, 1, [Define if you have processor_bind functionality]) 2406fi 2407 2408AC_MSG_CHECKING([for cpuset_getaffinity/cpuset_setaffinity]) 2409AC_TRY_LINK([ 2410#include <sys/param.h> 2411#include <sys/cpuset.h> 2412], 2413[ 2414 int res; 2415 cpuset_t cpuset; 2416 CPU_ZERO(&cpuset); 2417 CPU_SET(1, &cpuset); 2418 res = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(cpuset_t), &cpuset); 2419 res = cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(cpuset_t), &cpuset); 2420 res = CPU_ISSET(1, &cpuset); 2421 CPU_CLR(1, &cpuset); 2422], 2423 cpuset_xetaffinity=yes, 2424 cpuset_xetaffinity=no) 2425AC_MSG_RESULT([$cpuset_xetaffinity]) 2426if test $cpuset_xetaffinity = yes; then 2427 AC_DEFINE(HAVE_CPUSET_xETAFFINITY, 1, [Define if you have cpuset_getaffinity/cpuset_setaffinity]) 2428fi 2429 2430AC_CACHE_CHECK([for 'end' symbol], 2431 erts_cv_have_end_symbol, 2432 [AC_TRY_LINK([], 2433 [extern char end; {char *x = &end; *x= 0;}], 2434 erts_cv_have_end_symbol=yes, 2435 erts_cv_have_end_symbol=no)]) 2436if test $erts_cv_have_end_symbol = yes; then 2437 AC_DEFINE(HAVE_END_SYMBOL, 1, [Define if you have the 'end' symbol]) 2438fi 2439 2440AC_CACHE_CHECK([for '_end' symbol], 2441 erts_cv_have__end_symbol, 2442 [AC_TRY_LINK([], 2443 [extern char _end; {char *x = &_end; *x= 0;}], 2444 erts_cv_have__end_symbol=yes, 2445 erts_cv_have__end_symbol=no)]) 2446if test $erts_cv_have__end_symbol = yes; then 2447 AC_DEFINE(HAVE__END_SYMBOL, 1, [Define if you have the '_end' symbol]) 2448fi 2449 2450AC_CACHE_CHECK([if __after_morecore_hook can track malloc()s core memory use], 2451 erts_cv___after_morecore_hook_can_track_malloc, 2452 [AC_TRY_RUN([ 2453#include <stdlib.h> 2454#ifdef HAVE_MALLOC_H 2455# include <malloc.h> 2456#endif 2457#if defined(HAVE_END_SYMBOL) 2458extern char end; 2459#elif defined(HAVE__END_SYMBOL) 2460extern char _end; 2461#endif 2462 2463#ifdef ETHR_PTHREADS 2464# ifdef ETHR_HAVE_PTHREAD_H 2465# include <pthread.h> 2466# else 2467# ifdef ETHR_HAVE_MIT_PTHREAD_H 2468# include <pthread/mit/pthread.h> 2469# endif 2470# endif 2471# define N_THR 5 2472#else 2473# define N_THR 1 2474#endif 2475 2476static char *heap_start = NULL; 2477static char *heap_end = NULL; 2478 2479void update_heap_size(void) 2480{ 2481 heap_end = (char *) sbrk(0); 2482} 2483 2484void init_hook(void) 2485{ 2486#if defined(HAVE_END_SYMBOL) 2487 heap_start = &end; 2488#elif defined(HAVE__END_SYMBOL) 2489 heap_start = &_end; 2490#else 2491 heap_start = sbrk(0); 2492#endif 2493 __after_morecore_hook = update_heap_size; 2494} 2495 2496void (*__malloc_initialize_hook) (void) = init_hook; 2497 2498static int 2499check_malloc(int size) 2500{ 2501 char *p = (char *) malloc(size); 2502 if (!heap_start || !heap_end) return 0; 2503 if (!p) return 0; 2504 if (p < heap_start || heap_end <= p) return 0; 2505 if (p + size < heap_start || heap_end < p + size) return 0; 2506 return 1; 2507} 2508 2509#ifdef ETHR_PTHREADS 2510pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 2511#endif 2512 2513static void * 2514do_tests(void *vresp) 2515{ 2516 int i, ok = 0; 2517#ifdef ETHR_PTHREADS 2518 if (pthread_mutex_lock(&mutex) != 0) 2519 return NULL; 2520#endif 2521 2522 for (i = 0; i < 10; i++) 2523 if (!check_malloc(1000)) 2524 goto failed; 2525 for (i = 0; i < 100; i++) 2526 if (!check_malloc(1)) 2527 goto failed; 2528 if (!check_malloc(1024*1024+1)) 2529 goto failed; 2530 if (!check_malloc(10*1024*1024+1)) 2531 goto failed; 2532 ok = 1; 2533 2534 failed: 2535#ifdef ETHR_PTHREADS 2536 if (pthread_mutex_unlock(&mutex) != 0) 2537 return NULL; 2538#endif 2539 if (ok) 2540 *((int *) vresp) = 0; 2541 return NULL; 2542} 2543 2544 2545int main(void) 2546{ 2547 int res[N_THR], i; 2548#ifdef ETHR_PTHREADS 2549 pthread_t tid[N_THR]; 2550#endif 2551 2552#if defined(HAVE_MALLOPT) && defined(M_MMAP_MAX) 2553 (void) mallopt(M_MMAP_MAX, 0); 2554#endif 2555 2556 for (i = 0; i < N_THR; i++) 2557 res[i] = 1; 2558#ifdef ETHR_PTHREADS 2559 for (i = 1; i < N_THR; i++) 2560 if (pthread_create(&tid[i], NULL, do_tests, &res[i]) != 0) 2561 return 1; 2562#endif 2563 (void) do_tests(&res[0]); 2564#ifdef ETHR_PTHREADS 2565 for (i = 1; i < N_THR; i++) 2566 if (pthread_join(tid[i], NULL) != 0) 2567 return 1; 2568#endif 2569 for (i = 0; i < N_THR; i++) 2570 if (res[i]) 2571 return 1; 2572 return 0; 2573} 2574 ], 2575 erts_cv___after_morecore_hook_can_track_malloc=yes, 2576 erts_cv___after_morecore_hook_can_track_malloc=no, 2577 [ 2578 case X$erl_xcomp_after_morecore_hook in 2579 X) erts_cv___after_morecore_hook_can_track_malloc=cross;; 2580 Xyes|Xno) erts_cv___after_morecore_hook_can_track_malloc=$erl_xcomp_after_morecore_hook;; 2581 *) AC_MSG_ERROR([Bad erl_xcomp_after_morecore_hook value: $erl_xcomp_after_morecore_hook]);; 2582 esac 2583 ] 2584 )]) 2585 2586case $erts_cv___after_morecore_hook_can_track_malloc in 2587 yes) AC_DEFINE(ERTS___AFTER_MORECORE_HOOK_CAN_TRACK_MALLOC, 1, \ 2588[Define if __after_morecore_hook can track malloc()s core memory use.]);; 2589 cross) AC_MSG_WARN([result no guessed because of cross compilation]);; 2590 *) ;; 2591esac 2592 2593if test "x$ac_cv_func_sbrk" = "xyes"; then 2594 AC_CACHE_CHECK([types of sbrk()s return value and argument], 2595 erts_cv_sbrk_ret_arg_types, 2596 [ 2597 2598 erts_cv_sbrk_ret_arg_types=unknown 2599 ret_types="void *,char *" 2600 arg_types="intptr_t,ptrdiff_t,int,long" 2601 save_ifs="$IFS"; IFS="," 2602 for rtype in $ret_types; do 2603 for atype in $arg_types; do 2604 IFS=$save_ifs 2605 AC_TRY_LINK([#include <sys/types.h> 2606 #include <unistd.h>], 2607 [$rtype sbrk($atype incr);], 2608 [erts_cv_sbrk_ret_arg_types="$rtype,$atype"]) 2609 IFS="," 2610 if test "$erts_cv_sbrk_ret_arg_types" != "unknown"; then 2611 break 2 2612 fi 2613 done 2614 done 2615 IFS=$save_ifs]) 2616 2617 if test "$erts_cv_sbrk_ret_arg_types" != "unknown"; then 2618 save_ifs="$IFS"; IFS="," 2619 read ret_type arg_type <<EOF 2620$erts_cv_sbrk_ret_arg_types 2621EOF 2622 IFS=$save_ifs 2623 AC_DEFINE_UNQUOTED(SBRK_RET_TYPE, $ret_type, \ 2624[Define the sbrk() return type.]) 2625 AC_DEFINE_UNQUOTED(SBRK_ARG_TYPE, $arg_type, \ 2626[Define the sbrk() argument type.]) 2627 fi 2628fi 2629 2630if test $ac_cv_func_brk = yes; then 2631 AC_CACHE_CHECK([types of brk()s return value and argument], 2632 erts_cv_brk_ret_arg_types, 2633 [ 2634 2635 erts_cv_brk_ret_arg_types=unknown 2636 ret_types="int,long,char *,void *" 2637 arg_types="void *,const void *,char *,const char *" 2638 save_ifs="$IFS"; IFS="," 2639 for rtype in $ret_types; do 2640 for atype in $arg_types; do 2641 IFS=$save_ifs 2642 AC_TRY_LINK([#include <sys/types.h> 2643 #include <unistd.h>], 2644 [$rtype brk($atype endds);], 2645 [erts_cv_brk_ret_arg_types="$rtype,$atype"]) 2646 IFS="," 2647 if test "$erts_cv_brk_ret_arg_types" != "unknown"; then 2648 break 2 2649 fi 2650 done 2651 done 2652 IFS=$save_ifs]) 2653 2654 if test "$erts_cv_brk_ret_arg_types" != "unknown"; then 2655 save_ifs="$IFS"; IFS="," 2656 read ret_type arg_type <<EOF 2657$erts_cv_brk_ret_arg_types 2658EOF 2659 IFS=$save_ifs 2660 AC_DEFINE_UNQUOTED(BRK_RET_TYPE, $ret_type, \ 2661[Define the brk() return type.]) 2662 AC_DEFINE_UNQUOTED(BRK_ARG_TYPE, $arg_type, \ 2663[Define the brk() argument type.]) 2664 fi 2665 2666fi 2667 2668if test $ac_cv_func_sbrk = yes; then 2669 2670 AC_CACHE_CHECK([if sbrk()/brk() wrappers can track malloc()s core memory use], 2671 erts_cv_brk_wrappers_can_track_malloc, 2672 [AC_TRY_RUN([ 2673#include <stdlib.h> 2674#include <sys/types.h> 2675#include <unistd.h> 2676#ifdef HAVE_DLFCN_H 2677# include <dlfcn.h> 2678#endif 2679 2680/* 2681 * Our implementation requires that we have sbrk(), and 'end' or '_end'. 2682 */ 2683 2684#if !defined(HAVE_SBRK) 2685# error no sbrk() 2686#endif 2687#if defined(HAVE_END_SYMBOL) 2688extern char end; 2689#elif defined(HAVE__END_SYMBOL) 2690extern char _end; 2691#else 2692# error no 'end' nor '_end' 2693#endif 2694 2695#ifdef ETHR_PTHREADS 2696# ifdef ETHR_HAVE_PTHREAD_H 2697# include <pthread.h> 2698# else 2699# ifdef ETHR_HAVE_MIT_PTHREAD_H 2700# include <pthread/mit/pthread.h> 2701# endif 2702# endif 2703# define N_THR 5 2704#else 2705# define N_THR 1 2706#endif 2707 2708#define SBRK_IMPL(RET_TYPE, SBRK, ARG_TYPE) \ 2709RET_TYPE SBRK (ARG_TYPE); \ 2710static RET_TYPE (*real_ ## SBRK)(ARG_TYPE) = NULL; \ 2711RET_TYPE \ 2712SBRK (ARG_TYPE arg) \ 2713{ \ 2714 RET_TYPE res; \ 2715 if (!real_ ## SBRK) real_ ## SBRK = dlsym(RTLD_NEXT, #SBRK); \ 2716 res = (*real_ ## SBRK)(arg); \ 2717 if (res != (RET_TYPE) -1) heap_end = (char *) (*real_ ## SBRK)(0); \ 2718 return res; \ 2719} 2720 2721#define BRK_IMPL(RET_TYPE, BRK, ARG_TYPE) \ 2722RET_TYPE BRK (ARG_TYPE); \ 2723static RET_TYPE (*real_ ## BRK)(ARG_TYPE) = NULL; \ 2724RET_TYPE \ 2725BRK (ARG_TYPE arg) \ 2726{ \ 2727 RET_TYPE res; \ 2728 if (!real_ ## BRK) real_ ## BRK = dlsym(RTLD_NEXT, #BRK); \ 2729 res = (*real_ ## BRK)(arg); \ 2730 if (res != (RET_TYPE) -1) heap_end = (char *) arg; \ 2731 return res; \ 2732} 2733 2734static char *heap_start = NULL; 2735static char *heap_end = NULL; 2736 2737SBRK_IMPL(SBRK_RET_TYPE, sbrk, SBRK_ARG_TYPE) 2738#ifdef HAVE_BRK 2739 BRK_IMPL(BRK_RET_TYPE, brk, BRK_ARG_TYPE) 2740#endif 2741 2742#ifdef HAVE__SBRK 2743 SBRK_IMPL(SBRK_RET_TYPE, _sbrk, SBRK_ARG_TYPE) 2744#endif 2745#ifdef HAVE__BRK 2746 BRK_IMPL(BRK_RET_TYPE, _brk, BRK_ARG_TYPE) 2747#endif 2748 2749#ifdef HAVE___SBRK 2750 SBRK_IMPL(SBRK_RET_TYPE, __sbrk, SBRK_ARG_TYPE) 2751#endif 2752#ifdef HAVE___BRK 2753 BRK_IMPL(BRK_RET_TYPE, __brk, BRK_ARG_TYPE) 2754#endif 2755 2756static int 2757check_malloc(int size) 2758{ 2759 char *p = (char *) malloc(size); 2760 if (!heap_start || !heap_end) return 0; 2761 if (!p) return 0; 2762 if (p < heap_start || heap_end <= p) return 0; 2763 if (p + size < heap_start || heap_end < p + size) return 0; 2764 return 1; 2765} 2766 2767#ifdef ETHR_PTHREADS 2768pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 2769#endif 2770 2771static void * 2772do_tests(void *vresp) 2773{ 2774 int i, ok = 0; 2775#ifdef ETHR_PTHREADS 2776 if (pthread_mutex_lock(&mutex) != 0) 2777 return NULL; 2778#endif 2779 2780 for (i = 0; i < 10; i++) 2781 if (!check_malloc(1000)) 2782 goto failed; 2783 for (i = 0; i < 100; i++) 2784 if (!check_malloc(1)) 2785 goto failed; 2786 if (!check_malloc(1024*1024+1)) 2787 goto failed; 2788 if (!check_malloc(10*1024*1024+1)) 2789 goto failed; 2790 ok = 1; 2791 2792 failed: 2793#ifdef ETHR_PTHREADS 2794 if (pthread_mutex_unlock(&mutex) != 0) 2795 return NULL; 2796#endif 2797 if (ok) 2798 *((int *) vresp) = 0; 2799 return NULL; 2800} 2801 2802 2803int main(void) 2804{ 2805 int res[N_THR], i; 2806#ifdef ETHR_PTHREADS 2807 pthread_t tid[N_THR]; 2808#endif 2809#if defined(HAVE_END_SYMBOL) 2810 heap_start = &end; 2811#elif defined(HAVE__END_SYMBOL) 2812 heap_start = &_end; 2813#endif 2814 2815#if defined(HAVE_MALLOPT) && defined(M_MMAP_MAX) 2816 (void) mallopt(M_MMAP_MAX, 0); 2817#endif 2818 2819 for (i = 0; i < N_THR; i++) 2820 res[i] = 1; 2821#ifdef ETHR_PTHREADS 2822 for (i = 1; i < N_THR; i++) 2823 if (pthread_create(&tid[i], NULL, do_tests, &res[i]) != 0) 2824 return 1; 2825#endif 2826 (void) do_tests(&res[0]); 2827#ifdef ETHR_PTHREADS 2828 for (i = 1; i < N_THR; i++) 2829 if (pthread_join(tid[i], NULL) != 0) 2830 return 1; 2831#endif 2832 for (i = 0; i < N_THR; i++) 2833 if (res[i]) 2834 return 1; 2835 return 0; 2836} 2837 ], 2838 erts_cv_brk_wrappers_can_track_malloc=yes, 2839 erts_cv_brk_wrappers_can_track_malloc=no, 2840 [ 2841 case X$erl_xcomp_dlsym_brk_wrappers in 2842 X) erts_cv_brk_wrappers_can_track_malloc=cross;; 2843 Xyes|Xno) erts_cv_brk_wrappers_can_track_malloc=$erl_xcomp_dlsym_brk_wrappers;; 2844 *) AC_MSG_ERROR([Bad erl_xcomp_dlsym_brk_wrappers value: $erl_xcomp_dlsym_brk_wrappers]);; 2845 esac 2846 ])]) 2847 case $erts_cv_brk_wrappers_can_track_malloc in 2848 yes) 2849 AC_DEFINE(ERTS_BRK_WRAPPERS_CAN_TRACK_MALLOC, 1, \ 2850[Define if sbrk()/brk() wrappers can track malloc()s core memory use]);; 2851 cross) 2852 AC_MSG_WARN([result no guessed because of cross compilation]);; 2853 *) ;; 2854 esac 2855fi 2856 2857dnl Restore LIBS 2858LIBS=$saved_libs 2859dnl restore CPPFLAGS 2860CPPFLAGS=$saved_cppflags 2861 2862case $ARCH in 2863 x86|amd64) 2864 AC_DEFINE(ERTS_STRUCTURE_ALIGNED_ALLOC, 1, [Define if structure alignment is enough for allocators. If not defined, 64-bit alignment will be forced.]);; 2865 *) 2866 ;; 2867esac 2868 2869LM_SYS_IPV6 2870LM_SYS_MULTICAST 2871ERL_TIME_CORRECTION 2872AC_CHECK_PROG(M4, m4, m4) 2873 2874 2875dnl Test if JIT can be enabled 2876JIT_ARCH= 2877if test ${enable_jit} != no; then 2878 case "$ARCH" in 2879 amd64) 2880 JIT_ARCH=x86 2881 ;; 2882 *) 2883 if test ${enable_jit} = yes; then 2884 AC_MSG_ERROR([JIT only works on x86 64-bit]) 2885 else 2886 enable_jit=no 2887 AC_MSG_WARN([JIT disabled due to lack to support on $ARCH-$OPSYS]) 2888 fi 2889 ;; 2890 esac 2891 2892 if test ${enable_jit} != no; then 2893 if test "$CXX" != false; then 2894 AC_LANG_PUSH(C++) 2895 old_CXXFLAGS=$CXXFLAGS 2896 CXXFLAGS="$CXXFLAGS -std=c++17" 2897 AC_COMPILE_IFELSE( 2898 [AC_LANG_PROGRAM([], 2899 [#if __cplusplus < 201703L 2900 #error "Needs C++17 compiler" 2901 #endif])], 2902 [AC_MSG_CHECKING([for C++17 support]) 2903 AC_MSG_RESULT([yes]) 2904 HAVE_CXX17=true], 2905 [AC_MSG_CHECKING([for C++17 support]) 2906 AC_MSG_RESULT([no]) 2907 HAVE_CXX17=false]) 2908 AC_LANG_POP() 2909 fi 2910 if test "$CXX" = false -o "$HAVE_CXX17" = false; then 2911 if test ${enable_jit} = yes; then 2912 AC_MSG_ERROR([JIT needs a C++ compiler with C++17 support]) 2913 else 2914 enable_jit=no 2915 cat >> $ERL_TOP/erts/CONF_INFO <<EOF 2916 2917 JIT disabled due to lack of compiler with C++17 support 2918EOF 2919 AC_MSG_WARN([JIT disable due to lack of C++ compiler with C++17 support]) 2920 fi 2921 fi 2922 fi 2923 2924 if test ${enable_jit} != no; then 2925 enable_jit=yes 2926 fi 2927fi 2928 2929dnl Test if we can use the native stack for Erlang code 2930if test ${enable_jit} != no; then 2931 case $host_os in 2932 openbsd*) 2933 # Whenever the kernel is entered (page faults, system calls, etc), 2934 # OpenBSD checks whether the stack pointer is in an area allocated with 2935 # MAP_STACK, so we can't use the native stack for Erlang code. 2936 # 2937 # https://undeadly.org/cgi?action=article;sid=20180310000858 2938 enable_native_stack=no;; 2939 win32*) 2940 # Windows never messes with the stack, so it's safe by default. 2941 enable_native_stack=yes;; 2942 *) 2943 # Use the native stack if we can safely redirect OS signals to a 2944 # different stack. 2945 AC_MSG_CHECKING([for safe signal delivery]) 2946 AC_TRY_COMPILE( 2947 [#include <signal.h>], 2948 [#if defined(__APPLE__) && defined(__MACH__) && !defined(__DARWIN__) 2949 #define __DARWIN__ 1 2950 #endif 2951 #if !(defined(__GLIBC__) || defined(__DARWIN__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__sun__)) 2952 #error "Unknown libc. Assume musl, which does not allow safe signals" 2953 #endif], 2954 [AC_MSG_RESULT([yes]) 2955 enable_native_stack=yes], 2956 [AC_MSG_RESULT([no, disabling native stack in JIT]) 2957 enable_native_stack=no] 2958 );; 2959 esac 2960 2961 if test X${enable_native_stack} = Xyes; then 2962 AC_DEFINE(NATIVE_ERLANG_STACK, [], 2963 [Define if we can use the native stack for Erlang code]) 2964 fi 2965fi 2966 2967dnl 2968dnl Check if the `perf` profiler is supported. At the moment it assumes it 2969dnl always works on Linux as we're not dependent on it; this is only used to 2970dnl to control whether we generate `perf`-compatible memory maps. 2971dnl 2972case $OPSYS in 2973 linux*) 2974 AC_DEFINE(HAVE_LINUX_PERF_SUPPORT, 1, 2975 [Define if the targeted system supports the `perf` profiler]) 2976 ;; 2977 *) 2978 ;; 2979esac 2980 2981dnl 2982dnl Some operating systems allow you to redefine FD_SETSIZE to be able 2983dnl to select on more than the default number of file descriptors. 2984dnl We first discovered this in BSD/OS where the default is ridiculously 2985dnl low (256). But since we use a lot of file descriptors we found the 2986dnl need to go over the limit in other os's as well. Since FD_SETSIZE 2987dnl must be defined before pulling in sys/types.h the actual number 2988dnl of file descriptors is set in acconfig.h and will thus be in config.h 2989dnl which *always* should be included first. 2990dnl 2991 2992AC_MSG_CHECKING([whether to redefine FD_SETSIZE]) 2993case $host_os in 2994 bsdi*) 2995 AC_DEFINE(REDEFINE_FD_SETSIZE,[],[Define if you wish to redefine FD_SETSIZE to be able to select on more fd]) 2996 AC_MSG_RESULT(yes) 2997 ;; 2998 *) 2999 AC_MSG_RESULT(no) 3000 ;; 3001esac 3002 3003 3004 3005dnl ---------------------------------------------------------------------- 3006dnl Tests related to configurable options given on command line 3007dnl (using the --disable, --enable and --with switches). 3008dnl ---------------------------------------------------------------------- 3009 3010JIT_ENABLED= 3011FLAVORS="emu jit" 3012# Enable jit 3013if test X${enable_jit} = Xyes; then 3014 JIT_ENABLED=yes 3015 PRIMARY_FLAVOR=jit 3016else 3017 PRIMARY_FLAVOR=emu 3018fi 3019 3020AC_SUBST(JIT_ENABLED) 3021AC_SUBST(JIT_ARCH) 3022AC_SUBST(PRIMARY_FLAVOR) 3023AC_SUBST(FLAVORS) 3024 3025# 3026# Check for working poll(). 3027# 3028AC_MSG_CHECKING([for working poll()]) 3029if test "x$ac_cv_header_poll_h" != "xyes" -o "x$ac_cv_func_poll" != "xyes"; then 3030 3031poll_works=no 3032 3033else 3034 3035AC_TRY_RUN([ 3036#include <poll.h> 3037main() 3038{ 3039#ifdef _POLL_EMUL_H_ 3040 exit(1); /* Implemented using select() -- fail */ 3041#else 3042 struct pollfd fds[1]; 3043 int fd; 3044 fd = open("/dev/null", 1); 3045 fds[0].fd = fd; 3046 fds[0].events = POLLIN; 3047 fds[0].revents = 0; 3048 if (poll(fds, 1, 0) < 0 || (fds[0].revents & POLLNVAL) != 0) { 3049 exit(1); /* Does not work for devices -- fail */ 3050 } 3051 exit(0); 3052#endif 3053} 3054], 3055poll_works=yes, 3056poll_works=no, 3057[ 3058case X$erl_xcomp_poll in 3059 X) poll_works=cross;; 3060 Xyes|Xno) poll_works=$erl_xcomp_poll;; 3061 *) AC_MSG_ERROR([Bad erl_xcomp_poll value: $erl_xcomp_poll]);; 3062esac 3063]) 3064 3065fi 3066 3067case $poll_works-$host_os in 3068 no-*|cross-darwin*) 3069 # 3070 # The USE_SELECT define is used by the ssl application (should not 3071 # be used by erts). 3072 # 3073 AC_DEFINE(USE_SELECT, 1, [Define if select() should be used instead of poll()]) 3074 if test $poll_works = cross; then 3075 AC_MSG_RESULT(cross) 3076 AC_MSG_WARN([result no guessed based on OS ($host_os) because of cross compilation]) 3077 else 3078 AC_MSG_RESULT([no; non-existing, broken, or based on select()]) 3079 fi 3080 poll_works=no;; 3081 yes-*|cross-*) 3082 AC_DEFINE(ERTS_USE_POLL, 1, [Define if poll() should be used instead of select()]) 3083 if test $poll_works = cross; then 3084 AC_MSG_RESULT(cross) 3085 AC_MSG_WARN([result yes guessed based on OS ($host_os) because of cross compilation]) 3086 else 3087 AC_MSG_RESULT(yes) 3088 fi 3089 poll_works=yes;; 3090esac 3091 3092# 3093# If kqueue() found 3094# 3095if test $have_kernel_poll = kqueue; then 3096## Some OS X kernel version seems to have bugs in them with regards to kqueue 3097## Disable kernel poll on those versions 3098 AC_MSG_CHECKING([whether host os has known kqueue bugs]) 3099 case $host_os in 3100 # Any OS X version < 16 has known problems with using kqueue 3101 # so we don't use it there. See erl_poll.c for details. 3102 darwin[[0-9]].*|darwin1[[0-5]].*) 3103 AC_MSG_RESULT([yes, disabling kernel poll]) 3104 have_kernel_poll=no 3105 ;; 3106 *) 3107 AC_MSG_RESULT([no]) 3108 ;; 3109 esac 3110fi 3111# 3112# If epoll() found, check that it is level triggered. 3113# 3114if test $have_kernel_poll = epoll; then 3115 AC_MSG_CHECKING([whether epoll is level triggered]) 3116 AC_TRY_LINK([#include <sys/epoll.h>],[ 3117 #ifdef EPOLLET 3118 /* Edge triggered option exist, assume level triggered 3119 is default */ 3120 ; 3121 #else 3122 /* No edge triggered option exist; assume edge 3123 triggered only */ 3124 #error No EPOLLET 3125 #endif 3126 ], 3127 level_triggered_epoll=yes, 3128 [level_triggered_epoll=no 3129 have_kernel_poll=no]) 3130 AC_MSG_RESULT([$level_triggered_epoll]) 3131fi 3132# 3133# Check if we should enable kernel poll support 3134# 3135AC_MSG_CHECKING(whether kernel poll support should be enabled) 3136ERTS_ENABLE_KERNEL_POLL=no 3137ERTS_BUILD_FALLBACK_POLL=no 3138case $enable_kernel_poll-$have_kernel_poll in 3139 no-*) 3140 AC_MSG_RESULT(no; disabled by user);; 3141 yes-no) 3142 AC_MSG_ERROR(no; kernel poll support requested but not found);; 3143 *-no) 3144 AC_MSG_RESULT(no);; 3145 *) 3146 case $have_kernel_poll in 3147 epoll) 3148 AC_DEFINE(HAVE_SYS_EPOLL_H, 1, [Define if you have the <sys/epoll.h> header file.]) 3149 ERTS_BUILD_FALLBACK_POLL=yes 3150 ;; 3151 /dev/poll) 3152 AC_DEFINE(HAVE_SYS_DEVPOLL_H, 1, [Define if you have <sys/devpoll.h> header file.]) 3153 ;; 3154 kqueue) 3155 AC_DEFINE(HAVE_SYS_EVENT_H, 1, [Define if you have <sys/event.h> header file.]) 3156 ERTS_BUILD_FALLBACK_POLL=yes 3157 ;; 3158 *) 3159 AC_MSG_ERROR(configure.in need to be updated);; 3160 esac 3161 ERTS_ENABLE_KERNEL_POLL=yes 3162 AC_DEFINE(ERTS_ENABLE_KERNEL_POLL, 1, [Define if you have kernel poll and want to use it]) 3163 AC_MSG_RESULT([yes; $have_kernel_poll]);; 3164esac 3165AC_SUBST(ERTS_BUILD_FALLBACK_POLL) 3166 3167AC_MSG_CHECKING([whether putenv() stores a copy of the key-value pair]) 3168AC_TRY_RUN([ 3169#include <stdlib.h> 3170int main(void) { 3171 int i; 3172 char *env; 3173 char buf[10]; 3174 for (i = 0; i < 7; i++) 3175 buf[i] = 'X'; 3176 buf[i] = '\0'; 3177 buf[3] = '='; 3178 if (putenv(buf) != 0) 3179 return 1; 3180 for (i = 4; i < 7; i++) 3181 buf[i] = 'Y'; 3182 env = getenv("XXX"); 3183 if (!env) 3184 return 2; 3185 for (i = 0; i < 3; i++) 3186 if (env[i] != 'X') 3187 return 3; 3188 for (i = 0; i < 3; i++) 3189 buf[i] = 'Y'; 3190 env = getenv("XXX"); 3191 if (!env) 3192 return 4; 3193 for (i = 0; i < 3; i++) 3194 if (env[i] != 'X') 3195 return 5; 3196 return 0; 3197} 3198], 3199copying_putenv=yes, 3200copying_putenv=no, 3201[ 3202case X$erl_xcomp_putenv_copy in 3203 X) copying_putenv=cross;; 3204 Xyes|Xno) copying_putenv=$erl_xcomp_putenv_copy;; 3205 *) AC_MSG_ERROR([Bad erl_xcomp_putenv_copy value: $erl_xcomp_putenv_copy]);; 3206esac 3207]) 3208 3209AC_MSG_RESULT($copying_putenv) 3210case $copying_putenv in 3211 yes) 3212 AC_DEFINE(HAVE_COPYING_PUTENV,[1],\ 3213[Define if you have a putenv() that stores a copy of the key-value pair]);; 3214 cross) 3215 AC_MSG_WARN([result no guessed because of cross compilation]);; 3216 *) ;; 3217esac 3218 3219dnl ---------------------------------------------------------------------- 3220dnl Stuff that should be moved into their respective application 3221dnl ---------------------------------------------------------------------- 3222 3223dnl 3224dnl We should look for a compiler that handles jump tables, for beam_emu 3225dnl to be optimized 3226dnl 3227 3228LM_FIND_EMU_CC 3229 3230dnl 3231dnl DTrace & LTTNG 3232dnl 3233case $DYNAMIC_TRACE_FRAMEWORK in 3234 dtrace|systemtap) 3235 AC_CHECK_TOOL(DTRACE, dtrace, none) 3236 test "$DTRACE" = "none" && AC_MSG_ERROR([No dtrace utility found.]); 3237 enable_lttng_test=no 3238 enable_dtrace_test=yes;; 3239 lttng) 3240 enable_lttng_test=yes 3241 enable_dtrace_test=no;; 3242 *) 3243 enable_lttng_test=no 3244 enable_dtrace_test=no;; 3245esac 3246 3247AC_SUBST(DTRACE) 3248 3249AC_SUBST(DTRACE_CPP) 3250AC_SUBST(DTRACE_ENABLED) 3251AC_SUBST(DTRACE_ENABLED_2STEP) 3252DTRACE_CPP=-C 3253DTRACE_ENABLED= 3254DTRACE_ENABLED_2STEP= 3255DTRACE_2STEP_TEST=./dtrace-test.o 3256DTRACE_BITS_FLAG= 3257case $OPSYS in 3258 freebsd|dragonfly) 3259 if test "$BITS64" = "yes" ; then 3260 DTRACE_BITS_FLAG=-64 3261 else 3262 DTRACE_BITS_FLAG=-32 3263 fi 3264 ;; 3265 *) 3266 : # Nothing to do 3267 ;; 3268esac 3269if test "$enable_dtrace_test" = "yes" ; then 3270 if test "$DTRACE" = "dtrace" ; then 3271 AC_CHECK_HEADERS(sys/sdt.h) 3272 AC_MSG_CHECKING([for 1-stage DTrace precompilation]) 3273 # The OS X version of dtrace prints a spurious line here. 3274 if ! dtrace -h $DTRACE_CPP -Iemulator/beam -o ./foo-dtrace.h -s emulator/beam/erlang_dtrace.d; then 3275 AC_MSG_ERROR([Could not precompile erlang_dtrace.d: dtrace -h failed]) 3276 fi 3277 AC_MSG_RESULT([yes]) 3278 3279 AC_MSG_CHECKING([for 2-stage DTrace precompilation]) 3280 AC_TRY_COMPILE([ #include "foo-dtrace.h" ], 3281 [ERLANG_DIST_PORT_BUSY_ENABLED();], 3282 [rm -f $DTRACE_2STEP_TEST 3283 dtrace -G $DTRACE_CPP $DTRACE_BITS_FLAG -Iemulator/beam -o $DTRACE_2STEP_TEST -s emulator/beam/erlang_dtrace.d conftest.$OBJEXT 2>&AS_MESSAGE_LOG_FD 3284 if test -f $DTRACE_2STEP_TEST; then 3285 rm -f $DTRACE_2STEP_TEST 3286 DTRACE_ENABLED_2STEP=yes 3287 fi], 3288 []) 3289 rm -f foo-dtrace.h 3290 AS_IF([test "x$DTRACE_ENABLED_2STEP" = "xyes"], 3291 [AC_MSG_RESULT([yes])], 3292 [AC_MSG_RESULT([no])]) 3293 3294 DTRACE_ENABLED=yes 3295 case $OPSYS in 3296 linux) 3297 : # No extra libs to add to LIBS 3298 ;; 3299 freebsd) 3300 LIBS="$LIBS -lelf" 3301 ;; 3302 *) 3303 LIBS="$LIBS -ldtrace" 3304 ;; 3305 esac 3306 else 3307 AC_MSG_ERROR([Dtrace preprocessing test failed.]) 3308 fi 3309fi 3310 3311if test "$enable_lttng_test" = "yes" ; then 3312 AC_CHECK_HEADERS(lttng/tracepoint.h) 3313 AC_CHECK_HEADERS(lttng/tracepoint-event.h) 3314 dnl The macro tracepoint_enabled is not present in older lttng versions 3315 dnl checking for tracepoint_enabled 3316 AC_MSG_CHECKING([for tracepoint_enabled in lttng/tracepoint.h]) 3317 AC_COMPILE_IFELSE( 3318 [AC_LANG_PROGRAM( 3319 [#include <lttng/tracepoint.h> 3320 #define TRACEPOINT_PROVIDER org_erlang_otp 3321 TRACEPOINT_EVENT( 3322 org_erlang_otp, 3323 dummy, 3324 TP_ARGS(int, my_int), 3325 TP_FIELDS(ctf_integer(int, my_int, my_int))) 3326 #define TRACEPOINT_CREATE_PROBES 3327 #define TRACEPOINT_DEFINE], 3328 [if(tracepoint_enabled(org_erlang_otp,dummy)) do {} while(0)])], 3329 [AC_MSG_RESULT([yes])], 3330 [AC_MSG_ERROR([no (available in lttng-ust v2.7)])]) 3331 if test "x$ac_cv_header_lttng_tracepoint_h" = "xyes" \ 3332 -a "x$ac_cv_header_lttng_tracepoint_event_h" = "xyes"; then 3333 # No straight forward way to test for liblttng-ust when no public symbol exists, 3334 # just add the lib. 3335 LIBS="$LIBS -llttng-ust -ldl" 3336 else 3337 AC_MSG_ERROR([No LTTng support found.]) 3338 fi 3339fi 3340 3341 3342#-------------------------------------------------------------------- 3343# Os mon stuff. 3344#-------------------------------------------------------------------- 3345AC_SUBST(os_mon_programs) 3346AC_SUBST(CPU_SUP_LIBS) 3347 3348AC_CHECK_LIB(kstat, kstat_open, [ 3349 use_cpu_sup=yes 3350 CPU_SUP_LIBS="$CPU_SUP_LIBS -lkstat" 3351 ]) 3352 3353AC_CHECK_LIB(kvm, kvm_open, [ 3354 use_cpu_sup=yes 3355 CPU_SUP_LIBS="$CPU_SUP_LIBS -lkvm" 3356 ]) 3357 3358case $host_os in 3359 solaris2*) 3360 os_mon_programs="$os_mon_programs ferrule mod_syslog" ;; 3361 darwin*) 3362 use_cpu_sup=yes ;; 3363 openbsd*) 3364 use_cpu_sup=yes ;; 3365 linux*) 3366 use_cpu_sup=yes ;; 3367 freebsd*|dragonfly*) 3368 use_cpu_sup=yes ;; 3369esac 3370 3371if test "$use_cpu_sup" = "yes"; then 3372 os_mon_programs="$os_mon_programs cpu_sup" 3373fi 3374 3375AC_ARG_WITH(javac, 3376AS_HELP_STRING([--with-javac=JAVAC], [specify Java compiler to use]) 3377AS_HELP_STRING([--with-javac], [use a Java compiler if found (default)]) 3378AS_HELP_STRING([--without-javac], [don't use any Java compiler])) 3379 3380dnl 3381dnl Then there are a number of apps which needs a java compiler... 3382dnl 3383need_java="jinterface" 3384 3385if test -d $ERL_TOP/lib/ic; then 3386 need_java="$need_java ic/java_src" 3387fi 3388 3389# Remove all SKIP files from previous runs 3390for a in $need_java ; do 3391 rm -f $ERL_TOP/lib/$a/SKIP 3392done 3393 3394if test "X$with_javac" = "Xno"; then 3395 for a in $need_java ; do 3396 echo "Java compiler disabled by user" > $ERL_TOP/lib/$a/SKIP 3397 done 3398 3399else # begin - try to find javac 3400 3401if test "X$with_javac" != "Xyes" -a "X$with_javac" != "X"; then 3402 check_javac=$with_javac 3403else 3404 check_javac="javac.sh javac guavac gcj jikes bock" 3405fi 3406 3407AC_CHECK_PROGS(JAVAC, $check_javac) 3408if test -n "$JAVAC"; then 3409 dnl Make sure it's at least JDK 1.6 3410 AC_CACHE_CHECK(for JDK version 1.6, 3411 ac_cv_prog_javac_ver_1_6, 3412 [ERL_TRY_LINK_JAVA([], [for (String i : args);], 3413 ac_cv_prog_javac_ver_1_6=yes, ac_cv_prog_javac_ver_1_6=no)]) 3414 if test $ac_cv_prog_javac_ver_1_6 = no; then 3415 unset -v JAVAC 3416 fi 3417fi 3418if test -z "$JAVAC"; then 3419 3420 if test "X$with_javac" != "X"; then 3421 AC_MSG_ERROR([No java compiler found in PATH (checked for $check_javac)]) 3422 fi 3423 3424 AC_MSG_WARN([Could not find any usable java compiler, will skip: jinterface]) 3425 3426 for a in $need_java ; do 3427 echo "No Java compiler found" > $ERL_TOP/lib/$a/SKIP 3428 done 3429fi 3430 3431fi # end - try to find javac 3432 3433dnl 3434dnl Orber has a c++ example, this isn't the right way to check for 3435dnl it, but.... 3436dnl 3437AC_SUBST(CXXFLAGS) 3438dnl this deliberately does not believe that 'gcc' is a C++ compiler 3439AC_CHECK_TOOLS(CXX, [$CCC c++ g++ CC cxx cc++ cl], false) 3440 3441# Remove SKIP file from previous run 3442rm -f $ERL_TOP/lib/orber/SKIP 3443 3444if test "$CXX" = false; then 3445 echo "No C++ compiler found" > $ERL_TOP/lib/orber/SKIP 3446fi 3447 3448dnl ---------------------------------------------------------------------- 3449dnl Include CPPFLAGS in CFLAGS 3450dnl ---------------------------------------------------------------------- 3451CFLAGS="$CFLAGS $CPPFLAGS" 3452 3453# 3454# Currently if we compile for 64 bits we want to compile 3455# some external port programs using 32 bits 3456# 3457 3458# If not defined we trust the C compiler in $CC to do 32 bits 3459if test -z "$CC32"; then 3460 CC32="$CC" 3461fi 3462 3463if test -z "$CFLAGS32"; then 3464 if test $ac_cv_sizeof_void_p != 4; then 3465 # We are compiling default 64 bits and use -m32 for 32 bit compilations 3466 CFLAGS32="$CFLAGS -m32" 3467 else 3468 CFLAGS32="$CFLAGS" 3469 fi 3470fi 3471 3472AC_SUBST(CC32) 3473AC_SUBST(CFLAGS32) 3474 3475dnl 3476dnl ERTS_EMU_CMDLINE_FLAGS will force modification of config.h when 3477dnl the emulator command line flags are modified by configure, which 3478dnl in turn will make 'make' detect that files depending on config.h 3479dnl needs to be rebuilt. 3480dnl 3481 3482AC_DEFINE_UNQUOTED(ERTS_EMU_CMDLINE_FLAGS, 3483"$STATIC_CFLAGS $CFLAGS $DEBUG_CFLAGS $EMU_THR_DEFS $DEFS $WERRORFLAGS $WFLAGS", 3484[The only reason ERTS_EMU_CMDLINE_FLAGS exists is to force modification of config.h when the emulator command line flags are modified by configure]) 3485 3486AC_SUBST(STATIC_CFLAGS) 3487 3488dnl ---------------------------------------------------------------------- 3489dnl Directories needed for the build 3490dnl ---------------------------------------------------------------------- 3491 3492erts=${erl_top}/erts 3493 3494erts_dirs=" 3495 $erts/obj $erts/obj.debug 3496 3497 $erts/obj/$host 3498 $erts/obj.debug/$host 3499 3500" 3501for d in ${erl_top}/bin ${erl_top}/bin/$host $erts_dirs ; 3502do 3503 if test ! -d $d; then 3504 mkdir -p 1>/dev/null 2>&1 $d 3505 fi 3506done 3507 3508dnl --------------------------------------------------------------------- 3509dnl Autoheader macro for adding code at top and bottom of config.h.in 3510dnl --------------------------------------------------------------------- 3511AH_TOP([ 3512#ifndef __ERTS_CONFIG_H__ 3513#define __ERTS_CONFIG_H__ 3514 3515#define GHBN_R_SOLARIS 2 3516#define GHBN_R_AIX 3 3517#define GHBN_R_GLIBC 4 3518]) 3519 3520AH_BOTTOM([ 3521/* Redefine in6_addr. XXX this should be moved to the files where it's used? */ 3522#ifdef HAVE_IN_ADDR6_STRUCT 3523#define in6_addr in_addr6 3524#endif 3525 3526/* Define a reasonable default for INADDR_LOOPBACK */ 3527/* XXX this should be moved to the files where it's used? */ 3528#ifdef HAVE_NO_INADDR_LOOPBACK 3529#define INADDR_LOOPBACK (u_long)0x7F000001 3530#endif 3531 3532#ifdef REDEFINE_FD_SETSIZE 3533#define FD_SETSIZE 1024 3534#endif 3535 3536#ifdef HAVE_GETHRVTIME_PROCFS_IOCTL 3537#define HAVE_GETHRVTIME 3538#endif 3539 3540#if !defined(HAVE_ISFINITE) && !defined(HAVE_FINITE) 3541# if defined(HAVE_ISINF) && defined(HAVE_ISNAN) 3542# define USE_ISINF_ISNAN 3543# endif 3544#endif 3545 3546#if defined(DEBUG) && !defined(ERTS_ENABLE_LOCK_CHECK) 3547#define ERTS_ENABLE_LOCK_CHECK 1 3548#endif 3549 3550#endif /* __ERTS_CONFIG_H__ */ 3551]) 3552 3553dnl ---------------------------------------------------------------------- 3554dnl Check for log2 3555dnl ---------------------------------------------------------------------- 3556AC_CHECK_FUNCS([log2]) 3557 3558 3559dnl ---------------------------------------------------------------------- 3560dnl Check for GCC diagnostic ignored "-Waddress-of-packed-member" 3561dnl ---------------------------------------------------------------------- 3562saved_CFLAGS="$CFLAGS" 3563CFLAGS="-Werror $CFLAGS" 3564AC_TRY_COMPILE([], 3565 [_Pragma("GCC diagnostic push") 3566 _Pragma("GCC diagnostic ignored \"-Waddress-of-packed-member\"") 3567 _Pragma("GCC diagnostic pop") 3568 ], 3569 AC_DEFINE(HAVE_GCC_DIAG_IGNORE_WADDRESS_OF_PACKED_MEMBER,[1], 3570 [define if compiler support _Pragma('GCC diagnostic ignored '-Waddress-of-packed-member'')])) 3571CFLAGS="$saved_CFLAGS" 3572 3573 3574dnl ---------------------------------------------------------------------- 3575dnl Enable any -Werror flags 3576dnl ---------------------------------------------------------------------- 3577 3578if test "x$GCC" = xyes; then 3579 CFLAGS="$WERRORFLAGS $CFLAGS" 3580fi 3581 3582dnl ---------------------------------------------------------------------- 3583dnl Enable -fsanitize= flags. 3584dnl ---------------------------------------------------------------------- 3585 3586m4_define(DEFAULT_SANITIZERS, [address,undefined]) 3587AC_ARG_ENABLE( 3588 sanitizers, 3589 AS_HELP_STRING( 3590 [--enable-sanitizers@<:@=comma-separated list of sanitizers@:>@], 3591 [Default=DEFAULT_SANITIZERS]), 3592[ 3593case "$enableval" in 3594 no) sanitizers= ;; 3595 yes) sanitizers="-fsanitize=DEFAULT_SANITIZERS" ;; 3596 *) sanitizers="-fsanitize=$enableval" ;; 3597esac 3598CFLAGS="$CFLAGS $sanitizers" 3599LDFLAGS="$LDFLAGS $sanitizers" 3600]) 3601 3602dnl ---------------------------------------------------------------------- 3603dnl Output the result. 3604dnl ---------------------------------------------------------------------- 3605 3606dnl Note that the output files are relative to $srcdir 3607AC_CONFIG_FILES([ 3608 emulator/$host/Makefile:emulator/Makefile.in 3609 epmd/src/$host/Makefile:epmd/src/Makefile.in 3610 etc/common/$host/Makefile:etc/common/Makefile.in 3611 include/internal/$host/ethread.mk:include/internal/ethread.mk.in 3612 include/internal/$host/erts_internal.mk:include/internal/erts_internal.mk.in 3613 lib_src/$host/Makefile:lib_src/Makefile.in 3614 ../make/$host/otp.mk:../make/otp.mk.in 3615]) 3616 3617AC_CONFIG_FILES([../make/make_emakefile:../make/make_emakefile.in], 3618 [chmod +x ../make/make_emakefile]) 3619 3620dnl 3621dnl The ones below should be moved to their respective lib 3622dnl 3623AC_CONFIG_FILES([ 3624 ../lib/os_mon/c_src/$host/Makefile:../lib/os_mon/c_src/Makefile.in 3625 ../lib/runtime_tools/c_src/$host/Makefile:../lib/runtime_tools/c_src/Makefile.in 3626 ../lib/tools/c_src/$host/Makefile:../lib/tools/c_src/Makefile.in 3627 ]) 3628 3629AC_CONFIG_FILES([../make/install_dir_data.sh:../make/install_dir_data.sh.in], [chmod +x ../make/install_dir_data.sh]) 3630 3631AC_OUTPUT 3632