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