1dnl Process this file with autoconf to produce a configure script for Erlang. 2dnl 3dnl %CopyrightBegin% 4dnl 5dnl Copyright Ericsson AB 1997-2020. All Rights Reserved. 6dnl 7dnl Licensed under the Apache License, Version 2.0 (the "License"); 8dnl you may not use this file except in compliance with the License. 9dnl You may obtain a copy of the License at 10dnl 11dnl http://www.apache.org/licenses/LICENSE-2.0 12dnl 13dnl Unless required by applicable law or agreed to in writing, software 14dnl distributed under the License is distributed on an "AS IS" BASIS, 15dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16dnl See the License for the specific language governing permissions and 17dnl limitations under the License. 18dnl 19dnl %CopyrightEnd% 20dnl 21 22AC_INIT(conf_vars.in) 23 24AC_CANONICAL_HOST 25 26dnl Checks for programs. 27AC_PROG_CC 28 29DEBUG_FLAGS="-g -DDEBUG" 30if test "$GCC" = yes; then 31 DEBUG_FLAGS="$DEBUG_FLAGS -Wall $CFLAGS" 32fi 33AC_SUBST(DEBUG_FLAGS) 34 35AC_ARG_ENABLE(debug-mode, 36[ --enable-debug-mode enable debug mode], 37[ case "$enableval" in 38 no) ;; 39 *) CFLAGS=$DEBUG_FLAGS ;; 40 esac ], ) 41 42AC_ARG_ENABLE(m64-build, 43AS_HELP_STRING([--enable-m64-build], 44 [build 64-bit binaries using the -m64 flag to (g)cc]), 45[ case "$enableval" in 46 no) enable_m64_build=no ;; 47 *) enable_m64_build=yes ;; 48 esac 49],enable_m64_build=no) 50 51AC_ARG_ENABLE(m32-build, 52AS_HELP_STRING([--enable-m32-build], 53 [build 32-bit binaries using the -m32 flag to (g)cc]), 54[ case "$enableval" in 55 no) enable_m32_build=no ;; 56 *) enable_m32_build=yes ;; 57 esac 58],enable_m32_build=no) 59 60no_mXX_LDFLAGS="$LDFLAGS" 61 62if test X${enable_m64_build} = Xyes; then 63 CFLAGS="-m64 $CFLAGS" 64 LDFLAGS="-m64 $LDFLAGS" 65fi 66if test X${enable_m32_build} = Xyes; then 67 CFLAGS="-m32 $CFLAGS" 68 LDFLAGS="-m32 $LDFLAGS" 69fi 70 71AC_CHECK_LIB(m, sin) 72 73#-------------------------------------------------------------------- 74# Interactive UNIX requires -linet instead of -lsocket, plus it 75# needs net/errno.h to define the socket-related error codes. 76#-------------------------------------------------------------------- 77 78AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"]) 79AC_CHECK_HEADER(net/errno.h, AC_DEFINE(HAVE_NET_ERRNO_H)) 80 81#-------------------------------------------------------------------- 82# Linux/tcp.h may be needed for sockopt test in kernel 83#-------------------------------------------------------------------- 84 85AC_CHECK_HEADER(linux/tcp.h, AC_DEFINE(HAVE_LINUX_TCP_H)) 86AC_MSG_CHECKING(for sane linux/tcp.h) 87AC_TRY_COMPILE([#include <stdio.h> 88 #include <stdlib.h> 89 #include <string.h> 90 #include <unistd.h> 91 #include <stdarg.h> 92 #include <sys/types.h> 93 #include <sys/socket.h> 94 #include <sys/wait.h> 95 #include <linux/tcp.h> 96 #include <netinet/in.h> 97 #include <netdb.h>], 98 [return 0;], 99 have_sane_linux_tcp_h=yes, 100 have_sane_linux_tcp_h=no) 101 102if test $have_sane_linux_tcp_h = yes; then 103 AC_DEFINE(HAVE_SANE_LINUX_TCP_H,[1], 104 [Define if we have sane linux/tcp.h]) 105 AC_MSG_RESULT(yes) 106else 107 AC_MSG_RESULT(no) 108fi 109 110 111 112#-------------------------------------------------------------------- 113# Linux requires sys/socketio.h instead of sys/sockio.h 114#-------------------------------------------------------------------- 115AC_CHECK_HEADER(sys/socketio.h, AC_DEFINE(HAVE_SOCKETIO_H)) 116 117 118#-------------------------------------------------------------------- 119# Misc 120#-------------------------------------------------------------------- 121AC_CHECK_HEADER(poll.h, AC_DEFINE(HAVE_POLL_H)) 122 123#-------------------------------------------------------------------- 124# The statements below define a collection of symbols related to 125# dynamic loading and shared libraries: 126# 127# SHLIB_CFLAGS - Flags to pass to cc when compiling the components 128# of a shared library (may request position-independent 129# code, among other things). 130# SHLIB_LD - Base command to use for combining object files 131# into a shared library. 132# SHLIB_SUFFIX - Suffix to use for the names of dynamically loadable 133# extensions. An empty string means we don't know how 134# to use shared libraries on this platform. 135#-------------------------------------------------------------------- 136 137# Step 1: set the variable "system" to hold the name and version number 138# for the system. 139 140AC_MSG_CHECKING([system version (for dynamic loading)]) 141system=`./config.sub $host` 142AC_MSG_RESULT($system) 143 144# Step 2: check for existence of -ldl library. This is needed because 145# Linux can use either -ldl or -ldld for dynamic loading. 146 147AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no) 148 149# Step 3: set configuration options based on system name and version. 150 151SHLIB_LDLIBS= 152fullSrcDir=`cd $srcdir; pwd` 153case $system in 154 *-linux-*) 155 SHLIB_CFLAGS="-fPIC" 156 SHLIB_SUFFIX=".so" 157 if test "$have_dl" = yes; then 158 SHLIB_LD="${CC}" 159 SHLIB_LDFLAGS="$LDFLAGS -shared" 160 LD_FLAGS="-rdynamic" 161 else 162 AC_CHECK_HEADER(dld.h, [ 163 SHLIB_LD="ld" 164 SHLIB_LDFLAGS="-shared"]) 165 if test X${enable_m64_build} = Xyes; then 166 AC_MSG_ERROR(don't know how to link 64-bit dynamic drivers) 167 fi 168 if test X${enable_m32_build} = Xyes; then 169 AC_MSG_ERROR(don't know how to link 32-bit dynamic drivers) 170 fi 171 fi 172 SHLIB_EXTRACT_ALL="" 173 ;; 174 *-openbsd*|*-netbsd*|*-freebsd*|*-dragonfly*) 175 # Not available on all versions: check for include file. 176 AC_CHECK_HEADER(dlfcn.h, [ 177 SHLIB_CFLAGS="-fpic" 178 SHLIB_LD="${CC}" 179 SHLIB_LDFLAGS="$LDFLAGS -shared" 180 SHLIB_SUFFIX=".so" 181 if test X${enable_m64_build} = Xyes; then 182 AC_MSG_ERROR(don't know how to link 64-bit dynamic drivers) 183 fi 184 if test X${enable_m32_build} = Xyes; then 185 AC_MSG_ERROR(don't know how to link 32-bit dynamic drivers) 186 fi 187 ], [ 188 # No dynamic loading. 189 SHLIB_CFLAGS="" 190 SHLIB_LD="ld" 191 SHLIB_LDFLAGS="" 192 SHLIB_SUFFIX="" 193 AC_MSG_ERROR(don't know how to compile and link dynamic drivers) 194 ]) 195 SHLIB_EXTRACT_ALL="" 196 ;; 197 *-solaris2*|*-sysv4*) 198 SHLIB_CFLAGS="-KPIC" 199 SHLIB_LD="/usr/ccs/bin/ld" 200 SHLIB_LDFLAGS="$no_mXX_LDFLAGS -G -z text" 201 if test X${enable_m64_build} = Xyes; then 202 SHLIB_LDFLAGS="-64 $SHLIB_LDFLAGS" 203 fi 204 if test X${enable_m32_build} = Xyes; then 205 AC_MSG_ERROR(don't know how to link 32-bit dynamic drivers) 206 fi 207 SHLIB_SUFFIX=".so" 208 SHLIB_EXTRACT_ALL="-z allextract" 209 ;; 210 *darwin*) 211 SHLIB_CFLAGS="-fno-common" 212 SHLIB_LD="cc" 213 SHLIB_LDFLAGS="$LDFLAGS -bundle -flat_namespace -undefined suppress" 214 SHLIB_SUFFIX=".so" 215 SHLIB_EXTRACT_ALL="" 216 ;; 217 *osf1*) 218 SHLIB_CFLAGS="-fPIC" 219 SHLIB_LD="ld" 220 SHLIB_LDFLAGS="$LDFLAGS -shared" 221 if test X${enable_m64_build} = Xyes; then 222 AC_MSG_ERROR(don't know how to link 64-bit dynamic drivers) 223 fi 224 if test X${enable_m32_build} = Xyes; then 225 AC_MSG_ERROR(don't know how to link 32-bit dynamic drivers) 226 fi 227 SHLIB_SUFFIX=".so" 228 SHLIB_EXTRACT_ALL="" 229 ;; 230 *osf5*) 231 SHLIB_CFLAGS="-fPIC" 232 SHLIB_LD="${CC} -shared" 233 SHLIB_LDFLAGS="$LDFLAGS" 234 SHLIB_SUFFIX=".so" 235 SHLIB_EXTRACT_ALL="" 236 ;; 237 *) 238 # No dynamic loading. 239 SHLIB_CFLAGS="" 240 SHLIB_LD="ld" 241 SHLIB_LDFLAGS="" 242 SHLIB_LDLIBS="" 243 SHLIB_SUFFIX="" 244 SHLIB_EXTRACT_ALL="" 245 AC_MSG_ERROR(don't know how to compile and link dynamic drivers) 246 ;; 247esac 248 249# If we're running gcc, then change the C flags for compiling shared 250# libraries to the right flags for gcc, instead of those for the 251# standard manufacturer compiler. 252 253if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then 254 case $system in 255 *-aix) 256 ;; 257 *-bsd*) 258 ;; 259 *-irix) 260 ;; 261 *-netbsd|*-freebsd|*-openbsd) 262 ;; 263 *-riscos) 264 ;; 265 *ultrix4.*) 266 ;; 267 *darwin*) 268 ;; 269 *) 270 SHLIB_CFLAGS="-fPIC" 271 ;; 272 esac 273fi 274 275# Make it possible for erl_interface to use it's own compiler options 276EI_CFLAGS="$CFLAGS" 277 278# Add thread-safety flags if requested 279AC_ARG_ENABLE(shlib-thread-safety, 280[ --enable-shlib-thread-safety enable thread safety for build shared libraries], 281[ case "$enableval" in 282 no) ;; 283 *) SHLIB_CFLAGS="$SHLIB_CFLAGS -D_THREAD_SAFE -D_REENTRANT" 284 CFLAGS="$CFLAGS -D_THREAD_SAFE -D_REENTRANT" 285 ;; 286 esac ], ) 287 288SHLIB_CFLAGS="$SHLIB_CFLAGS $CFLAGS" 289 290 291AC_SUBST(CFLAGS) 292AC_SUBST(SHLIB_LD) 293AC_SUBST(SHLIB_LDFLAGS) 294AC_SUBST(SHLIB_LDLIBS) 295AC_SUBST(SHLIB_CFLAGS) 296AC_SUBST(SHLIB_SUFFIX) 297AC_SUBST(SHLIB_EXTRACT_ALL) 298AC_SUBST(EI_CFLAGS) 299 300#-------------------------------------------------------------------- 301# Check for the existence of the -lsocket and -lnsl libraries. 302# The order here is important, so that they end up in the right 303# order in the command line generated by make. Here are some 304# special considerations: 305# 1. Use "connect" and "accept" to check for -lsocket, and 306# "gethostbyname" to check for -lnsl. 307# 2. Use each function name only once: can't redo a check because 308# autoconf caches the results of the last check and won't redo it. 309# 3. Use -lnsl and -lsocket only if they supply procedures that 310# aren't already present in the normal libraries. This is because 311# IRIX 5.2 has libraries, but they aren't needed and they're 312# bogus: they goof up name resolution if used. 313# 4. On some SVR4 systems, can't use -lsocket without -lnsl too. 314# To get around this problem, check for both libraries together 315# if -lsocket doesn't work by itself. 316#-------------------------------------------------------------------- 317 318erl_checkBoth=0 319AC_CHECK_FUNC(connect, erl_checkSocket=0, erl_checkSocket=1) 320if test "$erl_checkSocket" = 1; then 321 AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", erl_checkBoth=1) 322fi 323if test "$erl_checkBoth" = 1; then 324 tk_oldLibs=$LIBS 325 LIBS="$LIBS -lsocket -lnsl" 326 AC_CHECK_FUNC(accept, erl_checkNsl=0, [LIBS=$tk_oldLibs]) 327fi 328AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])) 329 330dnl Checks for library functions. 331AC_CHECK_FUNCS(strerror) 332AC_CHECK_FUNCS(vsnprintf) 333AC_CHECK_FUNCS(usleep) 334 335# First check if the library is available, then if we can choose between 336# two versions of gethostbyname 337AC_HAVE_LIBRARY(resolv) 338AC_CHECK_LIB(resolv, res_gethostbyname,[AC_DEFINE(HAVE_RES_GETHOSTBYNAME,1)]) 339 340#-------------------------------------------------------------------- 341# Check for isfinite 342#-------------------------------------------------------------------- 343 344AC_MSG_CHECKING([for isfinite]) 345AC_TRY_LINK([#include <math.h>], 346 [isfinite(0);], have_isfinite=yes, have_isfinite=no) 347 348if test $have_isfinite = yes; then 349 AC_DEFINE(HAVE_ISFINITE,1) 350 AC_MSG_RESULT(yes) 351else 352 AC_DEFINE(HAVE_FINITE,1) 353 AC_MSG_RESULT(no) 354fi 355 356#-------------------------------------------------------------------- 357# Emulator compatible flags (for drivers) 358#-------------------------------------------------------------------- 359 360ERTS_CFLAGS=$CFLAGS 361AC_SUBST(ERTS_CFLAGS) 362 363ERTS_LIBS=$LIBS 364AC_SUBST(ERTS_LIBS) 365 366#-------------------------------------------------------------------- 367# Special compiler macro to handle cross compiling 368# (HCC) is used to compile tools run in the HOST environment 369#-------------------------------------------------------------------- 370HCC='$(CC)' 371AC_SUBST(HCC) 372 373#-------------------------------------------------------------------- 374# ld 375#-------------------------------------------------------------------- 376LD='$(CC) $(CFLAGS)' 377AC_SUBST(LD) 378 379#-------------------------------------------------------------------- 380# object file suffix 381#-------------------------------------------------------------------- 382obj='.o' 383AC_SUBST(obj) 384 385#-------------------------------------------------------------------- 386# executable file suffix 387#-------------------------------------------------------------------- 388exe='' 389AC_SUBST(exe) 390 391#-------------------------------------------------------------------- 392# wsl command (if on windows using wsl) 393#-------------------------------------------------------------------- 394wsl='' 395AC_SUBST(wsl) 396 397#-------------------------------------------------------------------- 398# flags when linking for cross platform targets (yet 'tis useful with 399# native builds) 400#-------------------------------------------------------------------- 401CROSSLDFLAGS='' 402AC_SUBST(CROSSLDFLAGS) 403 404dnl 405dnl SSL and CRYPTO needs the library openSSL/ssleay 406dnl 407dnl Check flags --with-ssl, --without-ssl --with-ssl=PATH. 408dnl If no option is given or --with-ssl is set without a path then we 409dnl search for SSL libraries and header files in the standard locations. 410dnl If set to --without-ssl we disable the use of SSL 411dnl If set to --with-ssl=PATH we use that path as the prefix, i.e. we 412dnl use "PATH/include" and "PATH/lib". 413 414AC_SUBST(SSLEAY_ROOT) 415TARGET=$host 416 417# We search for SSL. First in the OTP team ClearCase standard location, 418# then in the common OS standard locations 419# No we do not. 420SSL_APP=ssl 421CRYPTO_APP=crypto 422SSLEAY_ROOT=$TARGET 423#for dir in /usr /usr/pkg /usr/local /usr/local/ssl /usr/lib/ssl /usr/ssl; do 424# AC_CHECK_HEADER($dir/include/openssl/opensslv.h, 425# ac_cv_openssl=yes, ac_cv_openssl=no) 426# if test $ac_cv_openssl = yes ; then 427# SSLEAY_ROOT="$dir" 428# ssl_found=yes 429# break 430# fi 431#done 432 433# Find a usable java compiler 434# 435# WARNING this code is copied from ERTS configure.in, and should be 436# updated if that code changes. I hate duplicating code, but what 437# can I do. 438# 439dnl ERL_TRY_LINK_JAVA(CLASSES, FUNCTION-BODY 440dnl [ACTION_IF_FOUND [, ACTION-IF-NOT-FOUND]]) 441dnl Freely inspired by AC_TRY_LINK. (Maybe better to create a 442dnl AC_LANG_JAVA instead...) 443AC_DEFUN(ERL_TRY_LINK_JAVA, 444[java_link='$JAVAC conftest.java 1>&AC_FD_CC' 445changequote(, )dnl 446cat > conftest.java <<EOF 447$1 448class conftest { public static void main(String[] args) { 449 $2 450 ; return; }} 451EOF 452changequote([, ])dnl 453if AC_TRY_EVAL(java_link) && test -s conftest.class; then 454 ifelse([$3], , :, [rm -rf conftest* 455 $3]) 456else 457 echo "configure: failed program was:" 1>&AC_FD_CC 458 cat conftest.java 1>&AC_FD_CC 459 echo "configure: PATH was $PATH" 1>&AC_FD_CC 460ifelse([$4], , , [ rm -rf conftest* 461 $4 462])dnl 463fi 464rm -f conftest*]) 465dnl 466AC_CHECK_PROGS(JAVAC, javac guavac gcj jikes bock) 467if test -n "$JAVAC"; then 468 dnl Make sure it's at least JDK 1.5 469 AC_CACHE_CHECK(for JDK version 1.5, 470 ac_cv_prog_javac_ver_1_5, 471 [ERL_TRY_LINK_JAVA([], [for (String i : args);], 472 ac_cv_prog_javac_ver_1_5=yes, ac_cv_prog_javac_ver_1_5=no)]) 473 if test $ac_cv_prog_javac_ver_1_5 = no; then 474 unset -v JAVAC 475 fi 476fi 477if test -n "$JAVAC"; then 478 AC_SUBST(JAVAC) 479 : 480fi 481 482AC_CHECK_PROGS([make_command], [make gmake], [false]) 483AC_SUBST(make_command) 484 485if test "$GCC" = yes; then 486 test_c_compiler="{gnuc, undefined}" 487else 488 test_c_compiler="undefined" 489fi 490AC_SUBST(test_c_compiler) 491 492AC_OUTPUT(conf_vars) 493