1## This is an -*- Autoconf -*- file to be processed with autoconf 2## to obtain a configure script. 3 4## Copyright (C) 2016, 2017, 2018, 2019, 2020, 2021 Luca Saiu 5## Written by Luca Saiu 6 7## This file is part of Jitter. 8 9## Jitter is free software: you can redistribute it and/or modify 10## it under the terms of the GNU General Public License as published by 11## the Free Software Foundation, either version 3 of the License, or 12## (at your option) any later version. 13 14## Jitter is distributed in the hope that it will be useful, 15## but WITHOUT ANY WARRANTY; without even the implied warranty of 16## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17## GNU General Public License for more details. 18 19## You should have received a copy of the GNU General Public License 20## along with Jitter. If not, see <http://www.gnu.org/licenses/>. 21 22 23# Global initialization. 24################################################################ 25 26AC_PREREQ([2.69]) 27AC_INIT([Jitter], 28 m4_esyscmd([build-aux/git-version-gen .tarball-version]), 29 [bug-epsilon@gnu.org], 30 [jitter], 31 [http://ageinghacker.net/jitter]) 32AC_CONFIG_SRCDIR([NO-WARRANTY]) 33AC_CONFIG_AUX_DIR([build-aux]) 34AC_CONFIG_MACRO_DIRS([build-aux]) 35AC_REQUIRE_AUX_FILE([trivial-source.c]) 36 37 38# Generated C headers. 39################################################################ 40 41# config.h is the typical header file generated by config.status . Here I am 42# just generating it in a directory different from the build directory, so that 43# in sub-package mode there will be no possible conflict between Jitter's 44# config.h (which the super-package will not be able to access) and the 45# super-package's own config.h . 46# 47# jitter/jitter-config.h is meant to be installed in non-sub-package mode (or 48# available to the super-package in sub-package mode) as it is required when 49# compiling generated VM code. 50# For this reason jitter/jitter-config.h requires JITTER_ prefixes to prevent 51# collisions with user macros. 52AC_CONFIG_HEADERS([config-private/config.h jitter/jitter-config.h]) 53 54 55# Autoconf macros for Jitter. 56################################################################ 57 58# We will not use AC_JITTER here, since we are building Jitter itself rather 59# than checking for an installed Jitter; however some of our Autoconf macros, 60# which of course are not installed yet, will come in handy. 61m4_include([autoconf/jitter.m4]) 62 63 64# Automake initialization. 65################################################################ 66 67AM_INIT_AUTOMAKE 68 69 70# Make the source and build directory names visible here. 71################################################################ 72 73# Define jitter_abs_top_builddir and jitter_abs_top_srcdir as ordinary 74# shell variables, for internal use here in configure. 75# 76# The equivalent variables ac_abs_top_srcddir and ac_abs_top_builddir 77# are defined very late in the generated configure script, and not 78# documented anyway. 79jitter_abs_top_builddir="$(pwd)" 80cd "${srcdir}" 81jitter_abs_top_srcdir="$(pwd)" 82cd "${jitter_abs_top_builddir}" 83 84 85# Utility functions for configure. 86################################################################ 87 88# Check for tr, using very early. 89AC_PATH_PROG([JITTER_TR], [tr]) 90if test "x$JITTER_TR" = "x"; then 91 AC_MSG_ERROR([you need the Unix tr utility]) 92fi 93 94# Output stdin, translating every lower-case ASCII character into its upper-case 95# version, and - into _; every other character is left unchanged. 96jitter_lowercase_characters='abcdefghijklmnopqrstuvwxyz-' 97jitter_uppercase_characters='ABCDEFGHIJKLMNOPQRSTUVWXYZ_' 98jitter_to_upper () 99{ 100 $JITTER_TR "$jitter_lowercase_characters" "$jitter_uppercase_characters" 101} 102 103# Perform a translation which is the reverse of the one in jitter_to_upper . 104jitter_to_lower () 105{ 106 $JITTER_TR "$jitter_uppercase_characters" "$jitter_lowercase_characters" 107} 108 109# If the given $CC command-line option is supported (its actual effect is not 110# tested) then append the option, after a space, to the named shell veriable. 111# Two arguments: the name of a shell variable to possibly modify, and a 112# candidate $CC option. 113jitter_check_cc_option () 114{ 115 jitter_flag_variable_name="$1" 116 jitter_compiler_option="$2" 117 118 # We cache the result of an option being supported (as "yes" or "no") in a 119 # shell variable named after the option. Read the appropriate variable for 120 # $jitter_compiler_option into jitter_cached_value . 121 jitter_variable_name="jitter_cc_option_supported_"AS_TR_SH($jitter_compiler_option) 122 AS_VAR_COPY([jitter_cached_value], [$jitter_variable_name]) 123 124 # If we lack a cached value then perform the test, and set jitter_result ; 125 # otherwise set jitter_result from the cached value. 126 if test "x$jitter_cached_value" = "x"; then 127 AC_MSG_CHECKING([if $CC supports the option $jitter_compiler_option]) 128 if $CC \ 129 -c -o conftest.o \ 130 "$jitter_compiler_option" \ 131 "$srcdir/build-aux/trivial-source.c" \ 132 > /dev/null \ 133 2> /dev/null; then 134 jitter_result=yes 135 rm conftest.o 136 else 137 jitter_result=no 138 fi 139 AS_VAR_SET([$jitter_variable_name], [$jitter_result]) 140 AC_MSG_RESULT([$jitter_result]) 141 else 142 jitter_result="$jitter_cached_value" 143 fi 144 145 # Now $jitter_result is either "yes" or "no". Use it to decide whether to 146 # append the option to the flag variable. 147 if test "x$jitter_result" = "xyes"; then 148 AS_VAR_COPY([jitter_flag_variable_old_value], [$jitter_flag_variable_name]) 149 AS_VAR_SET([$jitter_flag_variable_name], 150 "$jitter_flag_variable_old_value $jitter_compiler_option") 151 fi 152} 153 154# Like jitter_check_cc_option , but working on zero or more $CC candidate options. 155# One or more arguments: the first is the name of a shell variable, as in the 156# first argument of jitter_check_cc_option ; all the other arguments are individual 157# candidate $CC options. 158jitter_check_cc_options () 159{ 160 jitter_flag_variable_name="$1" 161 shift 162 163 for jitter_compiler_option in $@; do 164 jitter_check_cc_option "$jitter_flag_variable_name" "$jitter_compiler_option" 165 done 166} 167 168# Preprocess stdin into stdout using the C preprocessor. Cut out any line starting 169# with "#" and whitespace-only lines. 170# This is mostly intended to check the expansion of single macros. 171jitter_cpp_preprocess () 172{ 173 $CC -E - | grep -v '^@%:@' | grep -v '^@<:@ \t\n\r@:>@*$' 174} 175 176# Print the definition of the CPP macro given as the sole argument. Print 177# nothing if the macro has no defintion. 178# This may not work with compilers other than GCC. 179jitter_gcc_print_cpp_macro () 180{ 181 $CC -dM -E -P - < /dev/null \ 182 | grep "^#define $1 " \ 183 | sed "s/^#define $1 //" 184} 185 186 187# Sub-package mode support. 188################################################################ 189 190# Check whether we should configure Jitter in "sub-package mode". In 191# sub-package mode a copy of the Jitter source is distributed in the style of 192# Gnulib, as a subdirectory along with another software package using it, so 193# that the two are built together. 194# Sub-package mode is meant for users of Jitter, and not for developing Jitter 195# itself: in order to speed up Jitter's compilation and its test suite, only the 196# best available dispatch is enabled. 197 198# In sub-package mode installation does nothing, and both static and dynamic 199# libraries are always enabled, but only static libraries are actually used. 200# Libraries meant for the user are built as Libtool convenience libraries, 201# suitable to be integrated within other user libraries and compatible with 202# either kind; on modern platforms this means in practice that there is a PIC 203# version built for every compilation unit. 204 205# Sub-package mode is enabled if the environment variable JITTER_SUBPACKAGE is 206# defined to any non-empty value. This is meant to be defined, and exported, by 207# the configure script of the super-package using Jitter as a subpackage; the 208# value is meant to be the Jitter subdirectory name relative to the 209# super-package source directory, but the actual value is only useful for the 210# super-package configuration: here any non-empty value will do, and the source 211# and build directories are known in any case. 212 213# Define the feature macro and change the kind of libraries to build by default 214# if sub-package mode is enabled. 215# In case the command line contradicts the default, I will still force static 216# libraries to be enabled and shared libraries to be also enabled, just giving a 217# warning: see "Libtool support" below. 218 219# Define JITTER_SUBPACKAGE as a precious variable, so that it is described by 220# --help and, more importantly, its value at the time of the first configuration 221# is kept around in case of an automatic re-configuration. This is very useful 222# in case some Autoconf or Automake source in a sub-package Jitter source 223# directory is modified. 224AC_ARG_VAR([JITTER_SUBPACKAGE], 225 [define to a non-empty value to configure Jitter as a 226 sub-package rather than as a dependency]) 227 228# Change library defaults. 229if test "x$JITTER_SUBPACKAGE" != 'x'; then 230 AC_DEFINE_UNQUOTED([JITTER_SUBPACKAGE], [1], 231 [Jitter is configured in sub-package mode]) 232 AC_ENABLE_STATIC 233 AC_ENABLE_SHARED 234fi 235 236# Define an Automake conditional. 237AM_CONDITIONAL([JITTER_SUBPACKAGE], 238 [test "x$JITTER_SUBPACKAGE" != 'x']) 239 240# Provide feedback. 241AC_MSG_CHECKING([if we are configuring in sub-package mode]) 242if test "x$JITTER_SUBPACKAGE" != 'x'; then 243 AC_MSG_RESULT([yes: "$JITTER_SUBPACKAGE"]) 244else 245 AC_MSG_RESULT([no]) 246fi 247 248 249# Check for the C compiler and its features. 250################################################################ 251 252# Indeed, we rely on a C compiler. 253AC_PROG_CC 254 255# In order to benefit from LTO here we would need to define RANLIB and AR to the 256# host version of gcc-ranlib and gcc-ar -- and then assure that they actually 257# work (as Bruno Haible helfully reminded me, on some configurations gcc-ranlib 258# and gcc-ar may be non-functional and always respond with 259# sorry - this program has been built without plugin support 260# ). 261# All this said LTO, impressive as it is, is a bad match for Jitter and 262# arranging for special provisions for its sake feels unwarranted. 263 264# Run the early part of the Gnulib initialization. This is recommended 265# right after AC_PROG_CC . 266gl_EARLY 267 268# Make sure the compiler supports a recent version of C. Without this I 269# have problem on OpenBSD, which ships with a very old GCC. 270AC_PROG_CC_C99 271 272# Check that we can use -c and -o together with the compiler. I currently don't 273# bother supporting compilers lacking this basic feature, but I could if it were 274# actually needed. 275AC_PROG_CC_C_O 276if test "x$NO_MINUS_C_MINUS_O" != "x"; then 277 AC_MSG_NOTICE([your C compiler doesn't accept -c and -o together. 278 Such a compiler is currently not supported, but support would 279 be easy to add -- in case this were the only problem]) 280 AC_MSG_ERROR([please write to $PACKAGE_BUGREPORT if you want to help]) 281fi 282 283# We do support cross-compiling. 284AC_CANONICAL_BUILD 285AC_CANONICAL_HOST 286 287# Define a feature CPP macro if we are cross-compiling; also set a shell 288# variable holding "yes" or "no" to use in this script. 289AC_MSG_CHECKING([if we are cross-compiling]) 290if test "x$build" = "x$host"; then 291 AC_MSG_RESULT([no, native compiling on $host .]) 292 jitter_cross_compiling=no 293else 294 AC_DEFINE_UNQUOTED([JITTER_CROSS_COMPILING], [1], 295 [Defined if Jitter was cross-compiled.]) 296 AC_MSG_RESULT([yes, cross-compiling from $build to $host .]) 297 jitter_cross_compiling=yes 298fi 299 300# I never test on weird systems not supporting shebangs. 301AC_SYS_INTERPRETER 302if test "x$interpval" != "xyes"; then 303 AC_MSG_WARN([your system doesn't support shebang. Trying to go on anyway]) 304fi 305 306# Installed shell scripts will have to work with a Bourne shell on the host 307# system. In case of native compilation that is simply $SHELL as detected 308# here (AS_INIT , called by AC_INIT , sets SHELL to a sensible value), but 309# for cross-compiled installations we can only guess. 310AC_MSG_CHECKING([what shell scripts should use as their shebang line]) 311jitter_warn_about_shebang='no' 312jitter_shebang_prefix='#! ' 313if test "x$interpval" != "xyes"; then 314 AC_SUBST([JITTER_SHEBANG], [# Shebang unsupported on this system]) 315 jitter_comment_about_JITTER_SHEBANG=' (very primitive shell -- untested)' 316elif test "x$jitter_cross_compiling" = "xno"; then 317 if test "x$SHELL" != 'x'; then 318 AC_SUBST([JITTER_SHEBANG], [$jitter_shebang_prefix$SHELL]) 319 jitter_comment_about_JITTER_SHEBANG='' 320 else 321 # Fallback case for systems where AS_INIT for some reason fails to set 322 # $SHELL to a resaonable value. This should not happen. 323 AC_SUBST([JITTER_SHEBANG], [$jitter_shebang_prefix/bin/sh]) 324 jitter_comment_about_JITTER_SHEBANG=' (guessed, as $SHELL is empty)' 325 jitter_warn_about_shebang='yes' 326 fi 327else 328 AC_SUBST([JITTER_SHEBANG], [$jitter_shebang_prefix/bin/sh]) 329 jitter_comment_about_JITTER_SHEBANG=' (guessed, for cross-compiling)' 330fi 331AC_MSG_RESULT([$JITTER_SHEBANG$jitter_comment_about_JITTER_SHEBANG]) 332if test "x$jitter_warn_about_shebang" != 'xno'; then 333 AC_MSG_WARN([the Autoconf logic failed to find a sensible value for SHELL; 334this should never happen. Trying to proceed anyway with a guess]) 335fi 336 337# We have preprocessed assembly files (for some architectures). 338AM_PROG_AS 339 340# Can we actually run on something other than GCC? Probably, as long as the 341# compiler supports a recent version of the C standard. 342if test "x$GCC" = 'x'; then 343 AC_MSG_WARN([not using GCC. Going on anyway, but GCC is recommended]) 344fi 345 346# Checks for C type support. 347AC_TYPE_LONG_LONG_INT 348AC_TYPE_UNSIGNED_LONG_LONG_INT 349AC_TYPE_LONG_DOUBLE 350 351# Checks for C type sizes. 352AC_CHECK_SIZEOF([void *]) 353AC_CHECK_SIZEOF([short]) 354AC_CHECK_SIZEOF([int]) 355AC_CHECK_SIZEOF([long]) 356AC_CHECK_SIZEOF([long long]) 357AC_CHECK_SIZEOF([float]) 358AC_CHECK_SIZEOF([double]) 359AC_CHECK_SIZEOF([long double]) 360AC_TYPE_SIZE_T 361 362# Checks for C type alignment. Checking for those at configure time is more 363# convenient than checking for __alignof__ and then invent some default where 364# it is not supported. I think I could live with those not being constant at 365# CPP time, but why not. 366AC_CHECK_ALIGNOF([void *]) 367AC_CHECK_ALIGNOF([void * *]) 368AC_CHECK_ALIGNOF([short]) 369AC_CHECK_ALIGNOF([int]) 370AC_CHECK_ALIGNOF([long]) 371AC_CHECK_ALIGNOF([long long]) 372AC_CHECK_ALIGNOF([float]) 373AC_CHECK_ALIGNOF([double]) 374AC_CHECK_ALIGNOF([long double]) 375 376# By definition we will take the size of a pointer as the host machine "word 377# size". This information is also used in the test suite, so define a 378# substitution as well. 379AC_SUBST([SIZEOF_VOID_P], [$ac_cv_sizeof_void_p]) 380 381 382# Check for a compiler which is actually GCC, and for versions. 383################################################################ 384 385# This check for specific versions is not really in the spirit of Autoconf, 386# but is necessary on cross configuration and when the feature to test cannot 387# be observed in a simple or deterministic enough way. 388 389# Some compilers claim to be GCC in feature macro, but they actually lie. 390# Jitter's advanced dispatches require some features present in the actual GNU 391# Compiler Collection, and not its imitations. 392# Define a substitution ("yes" or "no"), CPP feature macro (1 or undefiend) and 393# Automake conditional, all named JITTER_HAVE_ACTUAL_GCC. 394AC_MSG_CHECKING([if the compiler is *really* GCC]) 395JITTER_HAVE_CLANG=no 396if test "x$GCC" = 'x'; then 397 JITTER_HAVE_ACTUAL_GCC=no 398 AC_MSG_RESULT([no]) 399elif ! ${CC} --version > /dev/null 2> /dev/null; then 400 AC_MSG_RESULT([no (something not supporting --version)]) 401 JITTER_HAVE_ACTUAL_GCC=no 402else 403 JITTER_CLAIMED_GCC_VERSION=$(${CC} --version | jitter_to_lower) 404 # Clang does not play well with inline Gas assembly the way it is used in 405 # Jitter. However it does support computed goto, which is enough for 406 # direct-threading dispatch. 407 if echo "$JITTER_CLAIMED_GCC_VERSION" | grep 'clang' > /dev/null 2> /dev/null; then 408 AC_MSG_RESULT([no (clang pretending to be GCC)]) 409 JITTER_HAVE_ACTUAL_GCC=no 410 JITTER_HAVE_CLANG=yes 411 # If other compilers lie in a way similar to Clang and cause problems in a 412 # similar way I can add checks here. 413 else 414 AC_MSG_RESULT([yes]) 415 JITTER_HAVE_ACTUAL_GCC=yes 416 fi 417fi 418AC_SUBST([JITTER_HAVE_ACTUAL_GCC]) 419if test "x$JITTER_HAVE_ACTUAL_GCC" = 'xyes'; then 420 AC_DEFINE_UNQUOTED([JITTER_HAVE_ACTUAL_GCC], [1], 421 [Defined if using GCC and not something "compatibile".]) 422elif test "x$JITTER_HAVE_CLANG" = 'xyes'; then 423 AC_DEFINE_UNQUOTED([JITTER_HAVE_CLANG], [1], 424 [Defined if using clang.]) 425fi 426AM_CONDITIONAL([JITTER_HAVE_ACTUAL_GCC], 427 [test "x$JITTER_HAVE_ACTUAL_GCC" = 'xyes']) 428 429# If the compiler is actually GCC I can check its version as well. 430if test "x$JITTER_HAVE_ACTUAL_GCC" = 'xyes'; then 431 AC_MSG_CHECKING([for GCC's version]) 432 JITTER_GCC_MAJOR_VERSION=$(echo '__GNUC__' | jitter_cpp_preprocess) 433 JITTER_GCC_MINOR_VERSION=$(echo '__GNUC_MINOR__' | jitter_cpp_preprocess) 434 JITTER_GCC_PATCHLEVEL_VERSION=$(echo '__GNUC_PATCHLEVEL__' | jitter_cpp_preprocess) 435 JITTER_GCC_COMBINED_VERSION=$(( ${JITTER_GCC_MAJOR_VERSION} * 10000 + ${JITTER_GCC_MINOR_VERSION} * 100 + ${JITTER_GCC_PATCHLEVEL_VERSION})) 436 AC_DEFINE_UNQUOTED([JITTER_GCC_MAJOR_VERSION], 437 [${JITTER_GCC_MAJOR_VERSION}], 438 [The GCC major version, if GCC is being used]) 439 AC_DEFINE_UNQUOTED([JITTER_GCC_MINOR_VERSION], 440 [${JITTER_GCC_MINOR_VERSION}], 441 [The GCC minor version, if GCC is being used]) 442 AC_DEFINE_UNQUOTED([JITTER_GCC_PATCHLEVEL_VERSION], 443 [${JITTER_GCC_PATCHLEVEL_VERSION}], 444 [The GCC patchlevel version, if GCC is being used]) 445 AC_DEFINE_UNQUOTED([JITTER_GCC_COMBINED_VERSION], 446 [${JITTER_GCC_COMBINED_VERSION}], 447 [The GCC version as a combined integer, if GCC is being 448 used]) 449 AC_MSG_RESULT([major ${JITTER_GCC_MAJOR_VERSION}, minor ${JITTER_GCC_MINOR_VERSION}, patchlevel ${JITTER_GCC_PATCHLEVEL_VERSION}, combined ${JITTER_GCC_COMBINED_VERSION}]) 450fi 451 452# If the compiler is clang I can check its version as well. 453if test "x$JITTER_HAVE_CLANG" = 'xyes'; then 454 AC_MSG_CHECKING([for clang's version]) 455 JITTER_CLANG_MAJOR_VERSION=$(echo '__clang_major__' | jitter_cpp_preprocess) 456 JITTER_CLANG_MINOR_VERSION=$(echo '__clang_minor__' | jitter_cpp_preprocess) 457 JITTER_CLANG_PATCHLEVEL_VERSION=$(echo '__clang_patchlevel__' | jitter_cpp_preprocess) 458 JITTER_CLANG_COMBINED_VERSION=$(( ${JITTER_CLANG_MAJOR_VERSION} * 10000 + ${JITTER_CLANG_MINOR_VERSION} * 100 + ${JITTER_CLANG_PATCHLEVEL_VERSION})) 459 AC_DEFINE_UNQUOTED([JITTER_CLANG_MAJOR_VERSION], 460 [${JITTER_CLANG_MAJOR_VERSION}], 461 [The clang major version, if clang is being used]) 462 AC_DEFINE_UNQUOTED([JITTER_CLANG_MINOR_VERSION], 463 [${JITTER_CLANG_MINOR_VERSION}], 464 [The clang minor version, if clang is being used]) 465 AC_DEFINE_UNQUOTED([JITTER_CLANG_PATCHLEVEL_VERSION], 466 [${JITTER_CLANG_PATCHLEVEL_VERSION}], 467 [The clang patchlevel version, if clang is being used]) 468 AC_DEFINE_UNQUOTED([JITTER_CLANG_COMBINED_VERSION], 469 [${JITTER_CLANG_COMBINED_VERSION}], 470 [The clang version as a combined integer, if clang is being 471 used]) 472 AC_MSG_RESULT([major ${JITTER_CLANG_MAJOR_VERSION}, minor ${JITTER_CLANG_MINOR_VERSION}, patchlevel ${JITTER_CLANG_PATCHLEVEL_VERSION}, combined ${JITTER_CLANG_COMBINED_VERSION}]) 473fi 474 475# FIXME: the GCC version will be useful in advanced dispatches to enable or 476# disable features which are too difficult to check for at configure time, 477# particularly when cross-compiling. 478 479 480# Check for the GNU assembler. 481################################################################ 482 483# Jitter can use Gas features, and ideally I would like to disable them when 484# some other assembler is being used, even if this is low-priority. 485AC_CHECK_TOOL([JITTER_GNU_ASSEMBLER], [as], [no]) 486if test "x$JITTER_GNU_ASSEMBLER" != "xno"; then 487 if $JITTER_GNU_ASSEMBLER --version > /dev/null \ 488 && $JITTER_GNU_ASSEMBLER --version \ 489 | grep 'GNU [aA]ssembler' > /dev/null; then 490 # We found an asembler, but it either doesn't accept --version or the output 491 # of --version does not say anything similar to "GNU assembler". I am 492 # accepting a capitalized variant as an alternative and not requiring the 493 # string to occur at the beginning of a line just to account for some 494 # possible future changes in the format of gas --version . 495 JITTER_GNU_ASSEMBLER=no 496 fi 497fi 498if test "x$JITTER_GNU_ASSEMBLER" = "xno"; then 499 AC_MSG_WARN([the host assembler is not the GNU assembler. Going on anyway.]) 500else 501 AC_DEFINE_UNQUOTED([JITTER_HOST_ASSEMBLER_IS_GNU], [1], 502 [Defined if the host assembler is the GNU assembler.]) 503 AC_MSG_NOTICE([the host assembler is the GNU assembler. Good.]) 504fi 505 506 507# Check for system characteristics. 508################################################################ 509 510# I never test on systems limiting file name length to 14 characters. 511AC_SYS_LONG_FILE_NAMES 512if test "x$ac_cv_sys_long_file_names" != "xyes"; then 513 AC_MSG_WARN([file names are limited to 14 characters. Things may break]) 514fi 515 516 517# Check for programs. 518################################################################ 519 520# mkdir -p is convenient. It is currently used in the makefile and in 521# vm/generate-instructions.in . 522AC_PROG_MKDIR_P 523 524# We call objdump at runtime when disassembling. Even not having it installed 525# is not fatal, and the problem is easy to fix anyway after compiling Jitter. 526AC_PATH_PROG([JITTER_OBJDUMP], [objdump]) 527if test "x$jitter_cross_compiling" = "xyes"; then 528 AC_DEFINE_UNQUOTED([JITTER_OBJDUMP], 529 ["objdump"], 530 [name of the native objdump utility on the host system]) 531elif test "$JITTER_OBJDUMP" = ""; then 532 AC_MSG_WARN([no native objdump found. \ 533Assuming it will be installed and called "objdump", if disassembling is \ 534desired]) 535 AC_DEFINE_UNQUOTED([JITTER_OBJDUMP], 536 ["objdump"], 537 [name of the native objdump utility (not actually found)]) 538else 539 AC_DEFINE_UNQUOTED([JITTER_OBJDUMP], 540 ["$JITTER_OBJDUMP"], 541 [name of the native objdump utility]) 542fi 543 544# We also check for a cross-objdump, which is very convenient when debugging and 545# can be invoked from cross-compiled programs run on the build machine thru 546# qemu-user. 547AC_CHECK_TOOLS([JITTER_CROSS_OBJDUMP], [objdump]) 548if test "x$JITTER_CROSS_OBJDUMP" = "x"; then 549 AC_MSG_WARN([no cross-objdump found]) 550else 551 AC_DEFINE_UNQUOTED([JITTER_CROSS_OBJDUMP], 552 ["$JITTER_CROSS_OBJDUMP"], 553 [name of the cross-objdump utility from GNU binutils]) 554fi 555 556# Check for flex. 557AM_PROG_LEX 558if test "x$LEX" != "xflex"; then 559 if test -e "$srcdir/jitterc/jitterc-scanner.c"; then 560 AC_MSG_WARN([you will need flex (instead of $LEX) if you modify the 561 distributed C scanners]) 562 else 563 AC_MSG_ERROR([you need flex (instead of $LEX) to generate scanners, 564 if you compile from git]) 565 fi 566fi 567 568# Check for Bison. 569AC_PROG_YACC 570if ! (echo "x$YACC" | grep bison > /dev/null); then 571 if test -e "$srcdir/jitterc/jitterc-parser.c"; then 572 AC_MSG_WARN([you will need GNU Bison (instead of $YACC) if you modify 573 the distributed C parsers]) 574 else 575 AC_MSG_ERROR([you need GNU Bison (instead of $YACC) to generate parsers, 576 if you compile from git]) 577 fi 578fi 579 580# Check for Texinfo commands. In practice makeinfo is more important than 581# texi2dvi, as Info is the default format. 582AC_PATH_PROG([JITTER_MAKEINFO], [makeinfo]) 583if test "x$JITTER_MAKEINFO" = "x"; then 584 if test -e "$srcdir/doc/jitter.info"; then 585 AC_MSG_WARN([you will need GNU Texinfo to regenerate the Info \ 586documentation, in case you change the Texinfo source]) 587 else 588 AC_MSG_ERROR([you need GNU Texinfo to generate the Info documentation, if \ 589you compile from git; release tarballs contain the documentation \ 590pre-generated]) 591 fi 592fi 593AC_PATH_PROG([JITTER_TEXI2DVI], [texi2dvi]) 594if test "x$JITTER_TEXI2DVI" = "x"; then 595 AC_MSG_WARN([you will need texi2dvi, from GNU Texinfo, if you want to \ 596generate DVI, PostScript or PDF documentation]) 597fi 598# Define an Automake conditional saying whether it is possible to generate 599# hardcopy documentation. This way failures will be cleaner. 600AM_CONDITIONAL([JITTER_HAVE_TEXI2DVI], 601 [test "x$JITTER_TEXI2DVI" != "x"]) 602 603# Check for GNU help2man. That is not required for the user: pre-generated man 604# pages are included in the distribution. 605AC_CHECK_PROG(HAS_HELP2MAN, help2man, yes, no) 606if test "x$HAS_HELP2MAN" != "xyes"; then 607 jitter_has_help2man="no" 608 if test -e "$srcdir/jitterc/jitterc.1"; then 609 AC_MSG_WARN([You need GNU help2man if you want to rebuild manual pages]) 610 else 611 AC_MSG_WARN([You need GNU help2man to build manual pages if you compile 612 from git and you are not content with just man page stubs]) 613 fi 614else 615 jitter_has_help2man="yes" 616fi 617AM_MISSING_PROG(HELP2MAN, help2man) 618 619 620# Check for programs only used in the test suite. 621################################################################ 622 623# JITTER_CHECK_TESTSUITE_PROGS 624# ---------------------------- 625# Check the availability of a program only used for the test suite in the 626# predefined binary paths. The first program is the name of the substitution to 627# define (empty if the program is not found, otherwise its pathname); the second 628# argument is a list of possible basenames. If the program is not found then 629# the first argument is added to the shell variable , and a warning message is 630# printed. 631# jitter_test_suite_missing_progs. 632# Example: 633# JITTER_CHECK_TESTSUITE_PROG([JITTER_CMP], [some-other-weird-cmp cmp]) 634AC_DEFUN([JITTER_CHECK_TESTSUITE_PROGS], 635 [AC_PATH_PROGS([$1], [$2]) 636 if test "x$$1" = "x"; then 637 AC_MSG_WARN([none of {$2} found. Cannot run the test suite]) 638 jitter_test_suite_missing_progs="$jitter_test_suite_missing_progs $1" 639 fi]) 640 641# Check for optional programs only used by the test suite. 642JITTER_CHECK_TESTSUITE_PROGS([JITTER_AWK], [gawk mawk nawk awk]) 643JITTER_CHECK_TESTSUITE_PROGS([JITTER_CMP], [cmp]) 644JITTER_CHECK_TESTSUITE_PROGS([JITTER_BASENAME], [basename]) 645JITTER_CHECK_TESTSUITE_PROGS([JITTER_DIRNAME], [dirname]) 646#JITTER_CHECK_TESTSUITE_PROGS([JITTER_SEQ], [seq]) # not currently used. 647 648# Some other programs we can live without, still useful (but not mandatory) for 649# the test suite: 650AC_PATH_PROGS([JITTER_TIMEOUT], [timeout]) 651 652 653# Libtool support. 654################################################################ 655 656# In case this is a sub-package build force static libraries to be enabled and 657# shared libraries to be also enabled, even if this is different from what the 658# user asked. See "Sub-package mode support" above for an explanation. 659# This is reasonable in a sub-package: of course the super-package remains free 660# to choose differently. 661# REMARK: enable_static and enable_shared are not explicitly documented. 662if test "x$JITTER_SUBPACKAGE" != 'x'; then 663 if test "x${enable_static}" = 'xno'; then 664 AC_MSG_WARN([forcing static libraries to be enabled in sub-package mode]) 665 enable_static=yes 666 fi 667 if test "x${enable_shared}" = 'xno'; then 668 AC_MSG_WARN([forcing shared library compilation to be enabled in sub-package 669mode, for compatibility's sake, even if they will not be used]) 670 enable_shared=yes 671 fi 672fi 673 674# Initialize Libtool. 675LT_INIT 676 677# Update the libtool script if it becomes out of date. 678AC_SUBST([LIBTOOL_DEPS]) 679 680 681# Initialize Gnulib. 682################################################################ 683 684gl_INIT 685 686 687# Emacs Lisp support. 688################################################################ 689 690# Check for the Emacs Lisp installation path. 691AM_PATH_LISPDIR 692 693 694# Check for headers. 695################################################################ 696 697 698# Check for C language features. 699################################################################ 700 701# Check for mixed declarations and statements, which have been standards in C 702# since 1999 and widely supported even earlier. 703AC_CACHE_CHECK([for C99 mixed declarations and statements], 704 [ac_cv_have_mixed_declarations_and_statements], 705 [AC_COMPILE_IFELSE( 706 [AC_LANG_PROGRAM( 707 [], 708 [[int a = 10; 709 a ++; 710 int b = 7; 711 b += a; 712 return a + b;]])], 713 [ac_cv_have_mixed_declarations_and_statements=yes], 714 [ac_cv_have_mixed_declarations_and_statements=no])]) 715if test "x$ac_cv_have_mixed_declarations_and_statements" = "xyes"; then 716 AC_DEFINE([JITTER_HAVE_MIXED_DECLARATIONS_AND_STATEMENTS], [1], 717 [Define if the compiler supports mixing declarations and statements]) 718else 719 AC_MSG_WARN([This compiler does not support mixing C declarations and 720statements. It must be extremely old, and it will probably never be 721supported by Jitter. Trying to go on anyway, but expect disasters.]) 722fi 723 724# Check for statement expressions in the style of GNU C. 725AC_CACHE_CHECK([for GNU C statement expressions], 726 [ac_cv_have_gnu_c_statement_expressions], 727 [AC_COMPILE_IFELSE( 728 [AC_LANG_PROGRAM( 729 [], 730 [[return ({int a = 10; a -= 10; a;});]])], 731 [ac_cv_have_gnu_c_statement_expressions=yes], 732 [ac_cv_have_gnu_c_statement_expressions=no])]) 733if test "x$ac_cv_have_gnu_c_statement_expressions" = "xyes"; then 734 AC_DEFINE([JITTER_HAVE_GNU_C_STATEMENT_EXPRESSIONS], [1], 735 [Define if the compiler supports GNU C's statement expressions.]) 736fi 737 738# Check for computed goto in the style of GNU C. 739AC_CACHE_CHECK([for GNU C computed goto], [ac_cv_have_gnu_c_computed_goto], 740 [AC_COMPILE_IFELSE( 741 [AC_LANG_PROGRAM( 742 [], 743 [[ goto * && there; 744 there: 745 return 0;]])], 746 [ac_cv_have_gnu_c_computed_goto=yes], 747 [ac_cv_have_gnu_c_computed_goto=no])]) 748if test "x$ac_cv_have_gnu_c_computed_goto" = "xyes"; then 749 AC_DEFINE([JITTER_HAVE_GNU_C_COMPUTED_GOTO], [1], 750 [Define if the compiler supports GNU C's computed goto .]) 751fi 752 753# Check for (GNU C) label address difference constantness. 754AC_CACHE_CHECK([for GNU label address differences being constant], 755 [ac_cv_have_gnu_c_constant_label_difference], 756 [AC_COMPILE_IFELSE( 757 [AC_LANG_PROGRAM( 758 [], 759 [[ goto * && somewhere_else_again; 760 static int difference = && there - && somewhere_else_again; 761 there: 762 return 0; 763 elsewhere: 764 return 1; 765 somewhere_else_again: 766 return difference; 767 ]])], 768 [ac_cv_have_gnu_c_constant_label_difference=yes], 769 [ac_cv_have_gnu_c_constant_label_difference=no])]) 770if test "x$ac_cv_have_gnu_c_constant_label_difference" = "xyes"; then 771 AC_DEFINE([JITTER_HAVE_GNU_C_CONSTANT_LABEL_DIFFERENCE], [1], 772 [Define if the compiler supports GNU C's computed goto and the 773 difference between two label addresses (in the same function) is 774 a constant expression; unfortunately some compilers support GNU 775 C's computed goto without label address differences being 776 constant.]) 777fi 778 779# Check for alignas. 780AC_CACHE_CHECK([for alignas], [ac_cv_have_alignas], 781 [AC_COMPILE_IFELSE( 782 [AC_LANG_PROGRAM( 783 [#include <stdalign.h>], 784 [[struct s { alignas(16) int i; } foo; 785 return foo.i = 42;]])], 786 [ac_cv_have_alignas=yes], 787 [ac_cv_have_alignas=no])]) 788if test "x$ac_cv_have_alignas" = "xyes"; then 789 AC_DEFINE([JITTER_HAVE_ALIGNAS], [1], 790 [Define if the compiler supports alignas .]) 791fi 792 793# Check for offsetof. 794AC_CACHE_CHECK([for offsetof], [ac_cv_have_offsetof], 795 [AC_COMPILE_IFELSE( 796 [AC_LANG_PROGRAM( 797 [#include <stddef.h>], 798 [[struct s { int i; char c; float f; }; 799 return (int) offsetof (struct s, f);]])], 800 [ac_cv_have_offsetof=yes], 801 [ac_cv_have_offsetof=no])]) 802if test "x$ac_cv_have_offsetof" = "xyes"; then 803 AC_DEFINE([JITTER_HAVE_OFFSETOF], [1], 804 [Define if the compiler supports offsetof .]) 805fi 806 807# Check for GNU C's inline asm with modern syntax. 808AC_CACHE_CHECK([for GNU C inline asm with modern syntax], 809 [ac_cv_have_gnu_c_inline_asm], 810 [AC_COMPILE_IFELSE( 811 [AC_LANG_PROGRAM( 812 [], 813 [[int to, from = 42; 814 asm ("/* Pretend to set %[the_to] reading from %[the_from] . */" 815 : [the_to] "=r" (to) 816 : [the_from] "r" (from)); 817 return to;]])], 818 [ac_cv_have_gnu_c_inline_asm=yes], 819 [ac_cv_have_gnu_c_inline_asm=no])]) 820if test "x$ac_cv_have_gnu_c_inline_asm" = "xyes"; then 821 AC_DEFINE([JITTER_HAVE_GNU_C_INLINE_ASM], [1], 822 [Define if the compiler supports GNU C's asm goto .]) 823fi 824 825# Check for GNU C's "inline" qualifier for inline asm. 826AC_CACHE_CHECK([for GNU C "inline" qualifier for inline asm], 827 [ac_cv_have_gnu_c_asm_inline], 828 [AC_COMPILE_IFELSE( 829 [AC_LANG_PROGRAM( 830 [], 831 [[int to, from = 42; 832 asm inline ("/* Pretend to set %[the_to] reading from %[the_from] . */" 833 : [the_to] "=r" (to) 834 : [the_from] "r" (from)); 835 return to;]])], 836 [ac_cv_have_gnu_c_asm_inline=yes], 837 [ac_cv_have_gnu_c_asm_inline=no])]) 838if test "x$ac_cv_have_gnu_c_asm_inline" = "xyes"; then 839 AC_DEFINE([JITTER_HAVE_GNU_C_ASM_INLINE], [1], 840 [Define if the compiler supports GNU C's asm "inline" qualfiier.]) 841fi 842 843# Check for GNU C's asm goto. 844AC_CACHE_CHECK([for GNU C asm goto], [ac_cv_have_gnu_c_asm_goto], 845 [AC_COMPILE_IFELSE( 846 [AC_LANG_PROGRAM( 847 [], 848 [[here: 849 asm goto ("/* Pretend to do something. */" 850 : : : : here, there); 851 return 1; 852 there: 853 return 12;]])], 854 [ac_cv_have_gnu_c_asm_goto=yes], 855 [ac_cv_have_gnu_c_asm_goto=no])]) 856if test "x$ac_cv_have_gnu_c_asm_goto" = "xyes"; then 857 AC_DEFINE([JITTER_HAVE_GNU_C_ASM_GOTO], [1], 858 [Define if the compiler supports GNU C's asm goto .]) 859fi 860 861 862# Check for GCC attributes. 863################################################################ 864 865# Check if the GNU C attribute syntax is recognized at all. 866AC_CACHE_CHECK([for GNU C attributes], [ac_cv_have_gnu_c_attribute], 867 [AC_COMPILE_IFELSE( 868 [AC_LANG_PROGRAM( 869 [[__attribute__ (()) 870 int 871 f (int x) 872 { 873 return x; 874 }]], 875 [[return f (0);]])], 876 [ac_cv_have_gnu_c_attribute=yes], 877 [ac_cv_have_gnu_c_attribute=no])]) 878if test "x$ac_cv_have_gnu_c_attribute" = "xyes"; then 879 AC_DEFINE([JITTER_HAVE_GNU_C_ATTRIBUTE], [1], 880 [Define if the compiler supports __attribute__.]) 881fi 882 883# Check for specific attributes not supported by older versions of GCC; 884# and possibly by other compilers. Notice that we have to temporarily 885# change CFLAGS (in a subshell, so as not to affect the rest of this 886# script) to force -Werror. If -Werror is not supported than the tests 887# will all fail, which is the correct conservative behavior. 888 889# Check for attribute returns_nonnull . 890(CFLAGS="$CFLAGS -Werror"; export CFLAGS 891AC_CACHE_CHECK([for the returns_nonnull attribute], 892 [ac_cv_have_returns_nonnull], 893 [AC_COMPILE_IFELSE( 894 [AC_LANG_PROGRAM( 895 [[long n = 7; 896 __attribute__ ((returns_nonnull)) 897 long * 898 f (void) 899 { 900 return & n; 901 }]], 902 [[return * f () != 0;]])], 903 [ac_cv_have_returns_nonnull=yes], 904 [ac_cv_have_returns_nonnull=no])]) 905if test "x$ac_cv_have_returns_nonnull" = "xyes"; then 906 AC_DEFINE([JITTER_HAVE_ATTRIBUTE_RETURNS_NONNULL], [1], 907 [Define if the returns_nonnull attribute works]) 908fi) 909 910 911# Many people like to compile with -Werror. This is a way of redefining 912# attributes not supported by the compiler so that they expand to nothing. 913 914 915 916# Check for GCC builtins. 917################################################################ 918 919# Checking for builtins with AC_CHECK_FUNCS does not work for me, which is 920# reasonable since they are not usually implemented as C functions. 921 922# Overflow-checking builtins are fairly recent, and it is better to check their 923# presence rather than assuming that they are always available with GCC. 924AC_CACHE_CHECK([for GCC overflow-checking builtins], [ac_cv_have_gcc_overflow], 925 [AC_LINK_IFELSE( 926 [AC_LANG_PROGRAM( 927 [[#include <stdio.h>]], 928 [[int foo = __builtin_add_overflow_p (1, 2, 42); 929 printf ("%i\n", foo); /* -Werror: avoid unused variable warnings. */ 930 ]])], 931 [ac_cv_have_gcc_overflow=yes], 932 [ac_cv_have_gcc_overflow=no])]) 933if test "x$ac_cv_have_gcc_overflow" = "xyes"; then 934 AC_DEFINE([JITTER_HAVE_GCC_OVERFLOW_CHECKING], [1], 935 [Define if __builtin_add_overflow_p and friends are usable.]) 936fi 937 938# Very old GCCs or non-GCC compilers will not have __builtin_constant_p. 939AC_CACHE_CHECK([for GCC __builtin_constant_p], 940 [ac_cv_have_gcc_builtin_constant_p], 941 [AC_LINK_IFELSE( 942 [AC_LANG_PROGRAM( 943 [[]], 944 [[const int x = __builtin_constant_p (2 + 2); return x; 945 ]])], 946 [ac_cv_have_gcc_builtin_constant_p=yes], 947 [ac_cv_have_gcc_builtin_constant_p=no])]) 948if test "x$ac_cv_have_gcc_builtin_constant_p" = "xyes"; then 949 AC_DEFINE([JITTER_HAVE_GCC_BUILTIN_CONSTANT_P], [1], 950 [Define if __builtin_constant_p exists.]) 951fi 952 953# Very old GCCs or non-GCC compilers will not have __builtin_expect. 954AC_CACHE_CHECK([for GCC __builtin_expect], 955 [ac_cv_have_gcc_builtin_expect], 956 [AC_LINK_IFELSE( 957 [AC_LANG_PROGRAM( 958 [[]], 959 [[volatile int foo = 10; 960 return __builtin_expect (foo, 10); 961 ]])], 962 [ac_cv_have_gcc_builtin_expect=yes], 963 [ac_cv_have_gcc_builtin_expect=no])]) 964if test "x$ac_cv_have_gcc_builtin_expect" = "xyes"; then 965 AC_DEFINE([JITTER_HAVE_GCC_BUILTIN_EXPECT], [1], 966 [Define if __builtin_expect exists.]) 967fi 968 969# Very old GCCs or non-GCC compilers will not have __builtin_unreachable. 970AC_CACHE_CHECK([for GCC __builtin_unreachable], 971 [ac_cv_have_gcc_builtin_unreachable], 972 [AC_LINK_IFELSE( 973 [AC_LANG_PROGRAM( 974 [[]], 975 [[volatile int foo = 0; 976 if (foo) 977 __builtin_unreachable (); 978 ]])], 979 [ac_cv_have_gcc_builtin_unreachable=yes], 980 [ac_cv_have_gcc_builtin_unreachable=no])]) 981if test "x$ac_cv_have_gcc_builtin_unreachable" = "xyes"; then 982 AC_DEFINE([JITTER_HAVE_GCC_BUILTIN_UNREACHABLE], [1], 983 [Define if __builtin_unreachable exists.]) 984fi 985 986 987# Check for inline assembly or binary format features. 988################################################################ 989 990# Check whether the assembler understands ".section .note.GNU-stack", which 991# is needed on some platforms relying on executable stack support. 992AC_CACHE_CHECK([for .note-GNU-stack section support], 993 [ac_cv_have_section_note_gnu_stack], 994 [AC_LINK_IFELSE( 995 [AC_LANG_PROGRAM( 996 [[]], 997 [[asm volatile (".section .note.GNU-stack, \"\", @progbits\n" 998 ".previous"); 999 ]])], 1000 [ac_cv_have_section_note_gnu_stack=yes], 1001 [ac_cv_have_section_note_gnu_stack=no])]) 1002if test "x$ac_cv_have_section_note_gnu_stack" = "xyes"; then 1003 AC_DEFINE([JITTER_HAVE_SECTION_NOTE_GNU_STACK], [1], 1004 [Define if the platform supports a .note.GNU-stack section.]) 1005fi 1006 1007 1008# Check for specific functions or "declarations" in the C library. 1009################################################################## 1010 1011# Check for functions letting me know the page size and other system 1012# parameters. 1013AC_CHECK_FUNCS([sysconf getpagesize]) 1014 1015# Check for possible arguments to sysconf. This defines, for every SYMBOL which 1016# is "declared", a shell variable named ac_cv_have_decl_SYMBOL to "yes", where 1017# SYMBOL is adapted by capitalizing lower-case letters and replacing each 1018# non-alphanumeric character with an underscore. 1019AC_CHECK_DECLS([_SC_PAGESIZE, 1020 _SC_PHYS_PAGES, _SC_AVPHYS_PAGES, 1021 _SC_NPROCESSORS_CONF, _SC_NPROCESSORS_ONLN, 1022 _SC_LEVEL1_ICACHE_SIZE, _SC_LEVEL1_DCACHE_SIZE, 1023 _SC_LEVEL2_CACHE_SIZE, 1024 _SC_LEVEL3_CACHE_SIZE, 1025 _SC_LEVEL4_CACHE_SIZE],,, 1026 [[#include <unistd.h>]]) 1027 1028# Check for functions letting me allocate executable space. 1029AC_CHECK_FUNCS([mmap64 mmap mremap munmap]) 1030 1031# Check for libc functions to allocate aligned blocks which can actually be 1032# freed. On inferior systems when none of these is available I have to resort 1033# to my own inefficient wrapper around malloc. 1034# Notice that memalign and valloc do not qualify, as there is no way to free 1035# the buffer they allocate. 1036AC_CHECK_FUNCS([aligned_alloc posix_memalign]) 1037 1038# Check for functions letting me set permissions on memory pages. 1039AC_CHECK_FUNCS([mprotect]) 1040 1041# Check for getrlimit/setrlimit and alarm. 1042AC_CHECK_FUNCS([getrlimit setrlimit alarm]) 1043 1044# Check for pipes. These are currently used for disassembling by 1045# communicating with an objdump process. 1046AC_CHECK_FUNCS([popen pclose]) 1047 1048# Check for a sane signal-handling API. 1049AC_CHECK_FUNCS([sigaction]) 1050 1051# Check for optional high-resolution timing functions. 1052AC_CHECK_FUNCS([clock_gettime]) 1053 1054# Check for timer functions needed for profiling. 1055AC_CHECK_FUNCS([setitimer]) 1056 1057 1058# System-dependent configuration. 1059################################################################ 1060 1061# Define a few macros describing the host and the build systems. 1062AC_DEFINE_UNQUOTED([JITTER_HOST_CPU], ["$host_cpu"], 1063 [The host CPU architecture, as per the GNU convention.]) 1064AC_DEFINE_UNQUOTED([JITTER_HOST_VENDOR], ["$host_vendor"], 1065 [The host vendor, as per the GNU convention.]) 1066AC_DEFINE_UNQUOTED([JITTER_HOST_OS], ["$host_os"], 1067 [The host operating system, as per the GNU convention.]) 1068AC_DEFINE_UNQUOTED([JITTER_HOST_TRIPLET], ["$host"], 1069 [The host system triplet, as per the GNU convention.]) 1070AC_DEFINE_UNQUOTED([JITTER_BUILD_CPU], ["$build_cpu"], 1071 [The build CPU architecture, as per the GNU convention.]) 1072AC_DEFINE_UNQUOTED([JITTER_BUILD_VENDOR], ["$build_vendor"], 1073 [The build vendor, as per the GNU convention.]) 1074AC_DEFINE_UNQUOTED([JITTER_BUILD_OS], ["$build_os"], 1075 [The build operating system, as per the GNU convention.]) 1076AC_DEFINE_UNQUOTED([JITTER_BUILD_TRIPLET], ["$build"], 1077 [The build system triplet, as per the GNU convention.]) 1078 1079# Define a feature macro if the host system is GNU. This is useful for 1080# conditionalizing on GNU libc features. 1081if echo "$host_os" | grep gnu > /dev/null; then 1082 AC_DEFINE_UNQUOTED([JITTER_HOST_OS_IS_GNU], [1], 1083 [Is the host operating system GNU?]) 1084fi 1085 1086# Check endianness. 1087AC_C_BIGENDIAN 1088 1089# Use a command-line option to explicitly disable assembly support. I've needed 1090# this for a version of FreeBSD, which shipped with a very old Gas. 1091# This is used to compute $jitter_enable_host_assembly ; a check below 1092# will decide if support for the host machine is actually available. 1093AC_MSG_CHECKING([if assembly support is (potentially) enabled]) 1094AC_ARG_ENABLE([assembly], 1095 AS_HELP_STRING([--enable-assembly@<:@=CPU@:>@], 1096 [force the use of the named assembly (as in the first part of 1097a GNU-style target triplet), even if not detected. 1098With --disable-assembly or --enable-assembly=no, disable assembly support even 1099if available for the host machine. 1100With --enable-assembly or --enable-assembly=auto, enable assembly support if 1101automatically found. (default: auto)]), 1102 jitter_enable_host_assembly="$enableval", 1103 jitter_enable_host_assembly="auto") 1104AC_MSG_RESULT([$jitter_enable_host_assembly]) 1105 1106# Check whether we have assembly support for the host architecture, and an 1107# actual GCC to compile it. 1108# 1109# For the architectures we know, also define sensible options for objdump -- 1110# some of these are necessary, others a matter of preference. When the 1111# architecture is unknown some default is guessed. 1112# 1113# At this point jitter_enable_host_assembly is defined to one of "no", "auto", 1114# or an architecture name. If assembly support is not found "auto" will turn 1115# into "no" after this check, but "no" will not turn into "auto": the option 1116# above is conceived to *disable* assembly support when available. 1117# 1118# An architecture name given by the user will be used in place of the 1119# detected $host_cpu . 1120# At the end of the case statement jitter_has_host_assembly will be defined. 1121if test "x$jitter_enable_host_assembly" = 'xno' \ 1122 || test "x$JITTER_HAVE_ACTUAL_GCC" = 'xno'; then \ 1123 default_host_cpu="no-assembly" 1124elif test "x$jitter_enable_host_assembly" = "xauto"; then 1125 default_host_cpu="$host_cpu" 1126else 1127 default_host_cpu="$jitter_enable_host_assembly" 1128fi 1129AC_MSG_CHECKING([if we have assembly support for \"$default_host_cpu\"]) 1130AS_CASE([$default_host_cpu], 1131 [aarch64*], [AC_DEFINE_UNQUOTED([JITTER_HOST_CPU_IS_AARCH64], [1], [] 1132 ) # No ";": see the Autoconf manual 1133 # near the end of "Defining C 1134 # Preprocessor Symbols". 1135 #JITTER_ASSEMBLY_SUBDIRECTORY=aarch64 1136 jitter_has_host_assembly=no; 1137 jitter_objdump_options="--architecture=aarch64 --disassembler-options=reg-names-raw"], 1138 [alpha*], [AC_DEFINE_UNQUOTED([JITTER_HOST_CPU_IS_ALPHA], [1], [] 1139 ) # No ";": see the Autoconf manual. 1140 #JITTER_ASSEMBLY_SUBDIRECTORY=alpha 1141 jitter_has_host_assembly=no; 1142 # FIXME: test with a cross-objdump and see what options I like. 1143 jitter_objdump_options="--architecture= --disassembler-options=no-aliases"], 1144 [arm*], [AC_DEFINE_UNQUOTED([JITTER_HOST_CPU_IS_ARM], [1], [] 1145 ) # No ";": see the Autoconf manual. 1146 #JITTER_ASSEMBLY_SUBDIRECTORY=arm 1147 jitter_has_host_assembly=no; 1148 jitter_objdump_options="--architecture=arm --disassembler-options=reg-names-raw"], 1149 [i?86], [AC_DEFINE_UNQUOTED([JITTER_HOST_CPU_IS_I386], [1], [] 1150 ) # No ";": see the Autoconf manual. 1151 #JITTER_ASSEMBLY_SUBDIRECTORY=i386 1152 jitter_has_host_assembly=no; 1153 jitter_objdump_options="--architecture=i386 --disassembler-options=att,suffix"], 1154 [m68k*], [AC_DEFINE_UNQUOTED([JITTER_HOST_CPU_IS_M68K], [1], [] 1155 ) # No ";": see the Autoconf manual. 1156 JITTER_ASSEMBLY_SUBDIRECTORY=m68k; 1157 jitter_has_host_assembly=yes; 1158 jitter_objdump_options="--architecture= --disassembler-options=no-aliases"], 1159 [mips|mipsel], [AC_DEFINE_UNQUOTED([JITTER_HOST_CPU_IS_MIPS], [1], [] 1160 ) # No ";": see the Autoconf manual. 1161 JITTER_ASSEMBLY_SUBDIRECTORY=mips; 1162 jitter_has_host_assembly=yes; 1163 # Check for the nice but incompatible MIPS release 6 (or 1164 # later); in particular objdump needs an option to be 1165 # able to recognize some instructions whose encoding 1166 # changed. 1167 if echo $default_host_cpu | grep 64 > /dev/null; then 1168 jitter_bitness=64; 1169 else 1170 jitter_bitness=32; 1171 fi; 1172 if test "x$JITTER_HAVE_ACTUAL_GCC" = 'xyes'; then 1173 jitter_mips_release=$(jitter_gcc_print_cpp_macro \ 1174 __mips_isa_rev); 1175 fi; 1176 if test "x$jitter_mips_release" = 'x'; then 1177 jitter_mips_release=0; 1178 fi; 1179 if test "$jitter_mips_release" -ge 6; then 1180 jitter_mips_architecture=mips:isa${jitter_bitness}r6; 1181 AC_DEFINE_UNQUOTED([JITTER_HOST_CPU_IS_MIPS_R6_OR_LATER], 1182 [1], [] 1183 ) # No ";": see the Autoconf manual. 1184 else 1185 jitter_mips_architecture=mips:isa${jitter_bitness}; 1186 fi; 1187 jitter_objdump_options="--architecture=$jitter_mips_architecture --disassembler-options=no-aliases,reg-names=numeric"], 1188 [mips64|mips64el], 1189 [AC_DEFINE_UNQUOTED([JITTER_HOST_CPU_IS_MIPS], [1], [] 1190 ) # No ";": see the Autoconf manual. 1191 #JITTER_ASSEMBLY_SUBDIRECTORY=mips; 1192 jitter_has_host_assembly=no; 1193 jitter_objdump_options="--architecture= --disassembler-options=no-aliases,reg-names=numeric"], 1194 [parisc*], [AC_DEFINE_UNQUOTED([JITTER_HOST_CPU_IS_PARISC], [1], [] 1195 ) # No ";": see the Autoconf manual. 1196 jitter_has_host_assembly=no; 1197 jitter_objdump_options="--architecture= --disassembler-options=no-aliases"], 1198 [powerpc64|powerpc64le], 1199 [AC_DEFINE_UNQUOTED([JITTER_HOST_CPU_IS_POWERPC], [1], [] 1200 ) # No ";": see the Autoconf manual. 1201 #JITTER_ASSEMBLY_SUBDIRECTORY=powerpc 1202 jitter_has_host_assembly=no; 1203 jitter_objdump_options="--architecture=powerpc:common64"], 1204 [ppc|powerpc|powerpcle], 1205 [AC_DEFINE_UNQUOTED([JITTER_HOST_CPU_IS_POWERPC], [1], [] 1206 ) # No ";": see the Autoconf manual. 1207 jitter_has_host_assembly=yes; 1208 JITTER_ASSEMBLY_SUBDIRECTORY=powerpc], 1209 [riscv*], [AC_DEFINE_UNQUOTED([JITTER_HOST_CPU_IS_RISCV], [1], [] 1210 ) # No ";": see the Autoconf manual. 1211 JITTER_ASSEMBLY_SUBDIRECTORY=riscv; 1212 jitter_has_host_assembly=yes; 1213 jitter_objdump_options="--architecture=riscv:rv64 --disassembler-options=no-aliases,numeric"], 1214 [s390*], [AC_DEFINE_UNQUOTED([JITTER_HOST_CPU_IS_S390], [1], [] 1215 ) # No ";": see the Autoconf manual. 1216 jitter_has_host_assembly=no; 1217 jitter_objdump_options="--architecture= --disassembler-options=no-aliases"], 1218 [sh4*], [AC_DEFINE_UNQUOTED([JITTER_HOST_CPU_IS_SH], [1], [] 1219 ) # No ";": see the Autoconf manual. 1220 JITTER_ASSEMBLY_SUBDIRECTORY=sh 1221 jitter_has_host_assembly=yes; 1222 jitter_objdump_options="--architecture=sh4a --disassembler-options=no-aliases"], 1223 [sparc*], [AC_DEFINE_UNQUOTED([JITTER_HOST_CPU_IS_SPARC], [1], [] 1224 ) # No ";": see the Autoconf manual. 1225 JITTER_ASSEMBLY_SUBDIRECTORY=sparc 1226 jitter_has_host_assembly=yes; 1227 jitter_objdump_options="--architecture=sparc:v9b --disassembler-options=no-aliases"], 1228 [x86_64], [AC_DEFINE_UNQUOTED([JITTER_HOST_CPU_IS_X86_64], [1], [] 1229 ) # No ";": see the Autoconf manual. 1230 JITTER_ASSEMBLY_SUBDIRECTORY=x86_64; 1231 jitter_has_host_assembly=yes; 1232 jitter_objdump_options="--architecture=i386:x86-64 --disassembler-options=x86-64,att,suffix"], 1233 # Default case. Notice that, as a fallback case, we call 1234 # objdump with "--architecture=" , without actually 1235 # specifying an architecture name. 1236 # Using a default architecture might not be completely 1237 # reliable in the case of ISA extensions, but appears to 1238 # work well in practice; in any case this is a fallback 1239 # case: it is easy to provide a sensible default for 1240 # supported architectures by adding cases above. 1241 # There is no need for objdump to guess endianness, as 1242 # the information is always provided as a separate option 1243 # by the Jittery program, which knows the correct value 1244 # from configure. 1245 [jitter_has_host_assembly=no; 1246 jitter_objdump_options="--architecture= --disassembler-options=no-aliases"]) 1247if test "x$jitter_objdump_options" = "x"; then 1248 jitter_objdump_options="--architecture=$host_cpu" 1249fi 1250 1251# Define objdump options unconditionally, even if the user disabled host 1252# assembly. This is harmless enough, as the code is defensive and will 1253# revert to a sensible fallback solution when objdump fails. 1254AC_DEFINE_UNQUOTED([JITTER_OBJDUMP_OPTIONS], 1255 ["$jitter_objdump_options"], 1256 [architecture-specific options for objdump]) 1257if test "x$jitter_has_host_assembly" = "xno"; then 1258 AC_MSG_RESULT([no]) 1259else 1260 AC_MSG_RESULT([yes: $JITTER_ASSEMBLY_SUBDIRECTORY]) 1261fi 1262 1263# If the user explicitly requested support for an architecture but that 1264# was not found, fail. 1265if test "x$jitter_enable_host_assembly" != "xno" \ 1266 && test "x$jitter_enable_host_assembly" != "xauto" \ 1267 && test "x$JITTER_ASSEMBLY_SUBDIRECTORY" = "x"; then 1268 AC_MSG_ERROR([could not find assembly for $jitter_enable_host_assembly]) 1269fi 1270 1271 1272# Check if assembly support exists for the host machine. 1273################################################################ 1274 1275# The CPP feature macro JITTER_HAVE_ASSEMBLY will be defined iff there is 1276# support for the host machine. If so JITTER_ASSEMBLY_SUBDIRECTORY will be 1277# AC_SUBST'ed to be the subdirectory holding configuration-specific files. 1278if test "x$jitter_has_host_assembly" = "xyes"; then 1279 AC_SUBST([JITTER_ASSEMBLY_SUBDIRECTORY]) 1280 AC_DEFINE_UNQUOTED([JITTER_HAVE_ASSEMBLY], [1], 1281 [Define if we have assembly for the host architecture.]) 1282 AC_DEFINE_UNQUOTED([JITTER_ASSEMBLY_SUBDIRECTORY], ["$JITTER_ASSEMBLY_SUBDIRECTORY"], 1283 [the subdirectory containing assembly files.]) 1284else 1285 # Having an existing assembly subdirectory as the value of the substitution, 1286 # even if the source files it contains are useless, helps with the dist make 1287 # target. 1288 # Thanks to this trick I can use variables inside pathnames within 1289 # Makefile.am , which makes the code a lot simpler. Notice that in this case 1290 # the CPP feature macro definition JITTER_HAVE_ASSEMBLY remains undefined, 1291 # and the Automake conditional JITTER_ENABLE_ASSEMBLY remains false. 1292 AC_SUBST([JITTER_ASSEMBLY_SUBDIRECTORY], [dummy]) 1293fi 1294 1295 1296# Configuration-dependent features not directly relying on assembly support. 1297############################################################################ 1298 1299# According to the architecture some operations (defined in C, and still 1300# portable to any archtiecture) may be faster or slower. Jitter contains 1301# conditional code to support different solutions. 1302# 1303# This is independent from architecture-specific assembly support. 1304 1305# Some architectures support a good way of computing a conditional expression 1306# based on the negative sign of a disciminand without using branches; other 1307# architectures do not. 1308AC_MSG_CHECKING([if straight-line negativity tests are fast]) 1309# By default, let us say that the straight-line version is better. 1310jitter_have_fast_straight_line_negativity=yes 1311AS_CASE([$default_host_cpu], 1312 # Only on these few archtiectures my hand-optimized straight-line 1313 # version is slower than the naïve alternative. 1314 [x86_64|i?86|sh4*], 1315 [jitter_have_fast_straight_line_negativity=no]) 1316AC_MSG_RESULT([$jitter_have_fast_straight_line_negativity]) 1317if test "x$jitter_have_fast_straight_line_negativity" = "xyes"; then 1318 AC_DEFINE_UNQUOTED([JITTER_HAVE_FAST_STRAIGHT_LINE_NEGATIVITY], [1], 1319 [Define to 1 iff negativity tests are faster straight-line]) 1320fi 1321 1322# On some architectures it is efficient to "mask off" a tag in the low-order 1323# bits, in the sense of bitwise and-ing with a literal constant having zeroes 1324# only in the significant bits. This in practice require an and instruction 1325# with a sign-extended immediate, large immediate operands, an and instruction 1326# with a negated zero-extended immedate, or something equivalent. 1327AC_MSG_CHECKING([if and-ing with a sign-extended negative immediate is fast]) 1328# By default, let us say that the operation is efficient. 1329jitter_have_fast_mask_off=yes 1330AS_CASE([$default_host_cpu], 1331 # On these archtiectures the "masking off" operation has a faster 1332 # alternative, because the bitwise and instruction with an immediate 1333 # zero-extends its argument instead of sign-extending it, or there is 1334 # no immediate version at all working on an arbitrary register, or 1335 # because of some other restriction. 1336 # 1337 # Notes on specific architectures: 1338 # SH, while not ideal in this sense, has particularly limited shifting 1339 # instructions, making the mask alternative better even if it requires 1340 # a separate instruction to load an immediate into a temporary before 1341 # and-ing; the immediate, at least, is sign-extended. 1342 [mips*], 1343 [jitter_have_fast_mask_off=no]) 1344AC_MSG_RESULT([$jitter_have_fast_mask_off]) 1345if test "x$jitter_have_fast_mask_off" = "xyes"; then 1346 AC_DEFINE_UNQUOTED([JITTER_HAVE_FAST_MASK_OFF], [1], 1347 [Define to 1 iff masking off low-order bits is efficient]) 1348fi 1349 1350 1351# Binary format. 1352################################################################ 1353 1354# Determine whether the host OS uses the ELF binary format. 1355 1356# This is crude in many cases but probably sufficient for most configurations. 1357AC_MSG_CHECKING([if the host OS uses the ELF binary format]) 1358AS_CASE([$host_os], 1359 # We know that some systems are not ELF... 1360 [*aout*|*coff*], 1361 [jitter_host_os_is_elf=no], 1362 # ...Others, with "ELF" in the system name, definitely are. 1363 [*elf*], 1364 [jitter_host_os_is_elf=yes], 1365 # Specific known-ELF systems. 1366 # Do not add GNU systems as a special case: very old GNU/Linux systems 1367 # use non-ELF formats, and GNU is covered by the fallback case below in 1368 # any case. 1369 [*uclibc*], 1370 [jitter_host_os_is_elf=yes], 1371 # Fallback: check for the __ELF__ macro suppored by GCC's preprocessor 1372 # and by other preprocessors trying to be compatible with it. When the 1373 # macro use survives preprocessing we deduce the macro is *not* defined. 1374 [jitter_host_os_is_elf=$( (echo __ELF__ | jitter_cpp_preprocess \ 1375 | grep __ELF__ > /dev/null) \ 1376 && echo no \ 1377 || echo yes)]) 1378AC_MSG_RESULT([$jitter_host_os_is_elf]) 1379 1380# In case we found the ELF format, compile a little snippet to make sure that 1381# the GNU Assembler section stack machinery works, including subsection numbers 1382# after section names. This is not supported by old binutils, and we 1383# critically depend on it for advanced dispatches on ELF systems. 1384if test "x$jitter_host_os_is_elf" = 'xyes' \ 1385 && test "x$JITTER_GNU_ASSEMBLER" != 'xno'; then 1386 AC_CACHE_CHECK([if the assembler recognizes .pushsection with a subsection], 1387 [ac_cv_jitter_elf_subsection_stack], 1388 [AC_LINK_IFELSE( 1389 [AC_LANG_PROGRAM( 1390 [[]], 1391 [[asm volatile (".pushsection .text, 10"); 1392 asm volatile (".byte 1, 2, 3, 4"); 1393 asm volatile (".popsection");]])], 1394 [ac_cv_jitter_elf_subsection_stack=yes], 1395 [ac_cv_jitter_elf_subsection_stack=no])]) 1396 # Change jitter_host_os_is_elf: what we just discovered determines if 1397 # we can actually use ELF, or if the support is not adequate. 1398 jitter_host_os_is_elf="$ac_cv_jitter_elf_subsection_stack" 1399 if test "x$jitter_host_os_is_elf" = 'xyes'; then 1400 AC_MSG_NOTICE([We can actually use ELF: good.]) 1401 else 1402 AC_MSG_WARN([We cannot really use ELF on this platform]) 1403 fi 1404fi 1405 1406# Determine whether the host OS uses the COFF binary format. 1407# Again, this is crude but should suffice. 1408AC_MSG_CHECKING([if the host OS uses the COFF binary format]) 1409AS_CASE([$host_os], 1410 [*coff*], 1411 [jitter_host_os_is_coff=yes], 1412 [*mingw*], 1413 [jitter_host_os_is_coff=yes], 1414 [jitter_host_os_is_coff=no]) 1415AC_MSG_RESULT([$jitter_host_os_is_coff]) 1416 1417# Determine whether the host OS uses the Mach-O binary format. 1418# Once more, this is crude but enough for the common case. 1419AC_MSG_CHECKING([if the host OS uses the Mach-O binary format]) 1420AS_CASE([$host_os], 1421 [*darwin*], 1422 [jitter_host_os_is_macho=yes], 1423 [jitter_host_os_is_macho=no]) 1424AC_MSG_RESULT([$jitter_host_os_is_macho]) 1425 1426# Define C feature macros telling whether we can rely on the binary format 1427# being one of the supported ones. 1428if test "x$jitter_host_os_is_elf" = "xyes"; then 1429 AC_DEFINE_UNQUOTED([JITTER_HOST_OS_IS_ELF], [1], 1430 [Define to 1 iff the host OS uses the ELF format]) 1431fi 1432if test "x$jitter_host_os_is_coff" = "xyes"; then 1433 AC_DEFINE_UNQUOTED([JITTER_HOST_OS_IS_COFF], [1], 1434 [Define to 1 iff the host OS uses the COFF format]) 1435fi 1436if test "x$jitter_host_os_is_macho" = "xyes"; then 1437 AC_DEFINE_UNQUOTED([JITTER_HOST_OS_IS_MACHO], [1], 1438 [Define to 1 iff the host OS uses the MACHO format]) 1439fi 1440AC_MSG_CHECKING([if the host OS uses a known binary format]) 1441if test "x$jitter_host_os_is_elf" = "xyes" \ 1442 || test "x$jitter_host_os_is_coff" = "xyes"; then 1443 jitter_have_known_binary_format='yes' 1444 # FIXME: If I ever add support for Mach-O sections I will need another 1445 # clause in the condition above. 1446 AC_DEFINE_UNQUOTED([JITTER_HAVE_KNOWN_BINARY_FORMAT], [1], 1447 [Define to 1 iff we can handle globals/sections in asm]) 1448else 1449 jitter_have_known_binary_format='no' 1450fi 1451AC_MSG_RESULT([$jitter_have_known_binary_format]) 1452 1453 1454# ELF symbol visibility. 1455################################################################ 1456 1457# This is an experimental feature requested by the poke people. The API may 1458# change in the future. 1459 1460# If the option is passed, compile with -fvisibility=hidden. This is the 1461# default only on ELF systems, with either GCC version 4 or later or clang 1462# version 2 or later, in sub-package mode. 1463if test "x$jitter_host_os_is_elf" = "xyes" \ 1464 && ( (test "x$JITTER_HAVE_ACTUAL_GCC" = "xyes" \ 1465 && test "$JITTER_GCC_MAJOR_VERSION" -ge 4) \ 1466 || (test "x$JITTER_HAVE_CLANG" = "xyes" \ 1467 && test "$JITTER_CLANG_MAJOR_VERSION" -ge 2)) \ 1468 && test "x$JITTER_SUBPACKAGE" != 'x'; then 1469 jitter_enable_visibility_hidden_default=yes 1470else 1471 jitter_enable_visibility_hidden_default=no 1472fi 1473AC_MSG_CHECKING([if libraries should be compiled with -fvisibility=hidden]) 1474AC_ARG_ENABLE([visibility-hidden], 1475 AS_HELP_STRING([--enable-visibility-hidden], 1476 [experimental: compile passing the GCC option 1477 -fvisibility=hidden. Default: yes on ELF systems using GCC 4 1478 or later in sub-package mode; no elsewhere.]), 1479 jitter_enable_visibility_hidden="$enableval", 1480 jitter_enable_visibility_hidden="$jitter_enable_visibility_hidden_default") 1481AC_MSG_RESULT([$jitter_enable_visibility_hidden]) 1482AM_CONDITIONAL([JITTER_ENABLE_VISIBILITY_HIDDEN], 1483 [test "x$jitter_enable_visibility_hidden" = "xyes"]) 1484 1485# Recognize specific operating systems. 1486################################################################ 1487 1488# Recognize specific operating systems or kernels by library features, without 1489# trusting the triplet... 1490AC_CHECK_FUNCS([VirtualAlloc VirtualProtect]) 1491if test "x$ac_cv_func_VirtualAlloc" = "xyes" \ 1492 && test "x$ac_cv_func_VirtualProtect" = "xyes"; then 1493 AC_DEFINE_UNQUOTED([JITTER_HOST_OS_IS_WINDOWS], [1], 1494 [Define to 1 iff the host system is windows]) 1495fi 1496 1497# ...and some other systems that are more difficult to match by the triplet. 1498jitter_host_os_is_freebsd='no' 1499jitter_host_os_is_openbsd='no' 1500jitter_host_os_is_netbsd='no' 1501AS_CASE([$host_os], 1502 [*freebsd*], [jitter_host_os_is_freebsd='yes'], 1503 [*netbsd*], [jitter_host_os_is_netbsd='yes'], 1504 [*openbsd*], [jitter_host_os_is_openbsd='yes']) 1505if test "x$jitter_host_os_is_freebsd" = 'xyes'; then 1506 AC_DEFINE_UNQUOTED([JITTER_HOST_OS_IS_FREEBSD], [1], 1507 [Define to 1 iff the host system is FreeBSD]) 1508fi 1509if test "x$jitter_host_os_is_netbsd" = 'xyes'; then 1510 AC_DEFINE_UNQUOTED([JITTER_HOST_OS_IS_NETBSD], [1], 1511 [Define to 1 iff the host system is NetBSD]) 1512fi 1513if test "x$jitter_host_os_is_openbsd" = 'xyes'; then 1514 AC_DEFINE_UNQUOTED([JITTER_HOST_OS_IS_OPENBSD], [1], 1515 [Define to 1 iff the host system is OpenBSD]) 1516fi 1517 1518 1519# M4sh machinery. 1520################################################################ 1521 1522# For portability and for better factoring I generate shell scripts with M4sh. 1523# The actual source files are ".m4sh.in" scripts, to be preprocessed by autom4te 1524# into ".in" scripts, for aclocal to perform @-substitutions into ordinary 1525# scripts (no file extension). 1526# The first step of this double translation relies on autom4te, which is not 1527# required on the user's machine; therefore I distribute ".in" scripts, but 1528# the user needs autom4te if she wants to regenerate them. 1529AC_CHECK_PROG(HAS_AUTOM4TE, autom4te, yes, no) 1530if test "x$HAS_AUTOM4TE" != "xyes"; then 1531 AC_MSG_WARN([You need autom4te, coming from GNU Autoconf, if you want to 1532 rebuild scripts from their M4sh source]) 1533fi 1534AM_MISSING_PROG(AUTOM4TE, autom4te) 1535AM_CONDITIONAL([JITTER_HAVE_AUTOM4TE], 1536 [test "x$HAS_AUTOM4TE" = "xyes"]) 1537 1538 1539# Emulator support for running cross-compilied binaries. 1540################################################################ 1541 1542# We optionally support qemu-user emulation for running cross-compiled binaries 1543# for the host on the build system; other user binary emulators might work as 1544# well. 1545# This is particularly useful for running the test suite when cross-compiling. 1546# The option argument is the emulator command line included options, to be 1547# followed by the emulated program with its own options: for example 1548# "qemu-ppc -L /my-cross-path/powerpc-unknown-linux-gnu/sysroot" . 1549AC_MSG_CHECKING([if host emulator support is used]) 1550AC_ARG_WITH([emulator], 1551 AS_HELP_STRING([--with-emulator="EMULATOR WITH OPTIONS"], 1552 [use an emulator running cross-compiled binaries, 1553 including the test suite, on the build platform: default no]), 1554 jitter_with_emulator="$withval", 1555 jitter_with_emulator="") 1556if test "x$jitter_with_emulator" = "x" \ 1557 || test "x$jitter_with_emulator" = "xno"; then 1558 jitter_with_emulator="" 1559 AC_MSG_RESULT([no]) 1560else 1561 AC_MSG_RESULT([yes, $jitter_with_emulator]) 1562fi 1563AC_SUBST([JITTER_EMULATOR], $jitter_with_emulator) 1564 1565 1566# Can we actually rebuild man pages? 1567################################################################ 1568 1569# GNU help2man could be made to work even when cross-compiling, as long as there 1570# is a usable emulator. Still, there is very little gain in doing this and lots 1571# of gratuitous headaches when using the missing script with an emulator. I 1572# will keep things simple for now. 1573# For the same reason, and to reduce wasted time, do not bother bulding man 1574# pages in sub-package mode. 1575AC_MSG_CHECKING([if we should use help2man to rebuild man pages]) 1576if test "x$jitter_cross_compiling" != "xyes" \ 1577 && test "x$jitter_has_help2man" = "xyes" \ 1578 && test "x$JITTER_SUBPACKAGE" = 'x'; then 1579 jitter_can_rebuild_man_pages="yes" 1580 AC_MSG_RESULT([yes]) 1581else 1582 jitter_can_rebuild_man_pages="no" 1583 AC_MSG_RESULT([no (cross-compiling, or no help2man, or sub-package mode)]) 1584fi 1585AM_CONDITIONAL([JITTER_CAN_REBUILD_MAN_PAGES], 1586 [test "x$jitter_can_rebuild_man_pages" = "xyes"]) 1587 1588 1589# Valgrind support. 1590################################################################ 1591 1592# We optionally support valgrind in the test suite. First use a configure 1593# option to override the default. 1594AC_MSG_CHECKING([if Valgrind is supported]) 1595AC_ARG_WITH([valgrind], 1596 AS_HELP_STRING([--with-valgrind@<:@=VALGRINDNAME@:>@], 1597 [use Valgrind for the test suite (default: 1598 detected)]), 1599 jitter_with_valgrind="$withval", 1600 jitter_with_valgrind="detect") 1601# At this point $jitter_with_valgrind may be defined as "yes" , "no" , 1602# "detect" , or the program name. 1603 1604# Decide whether to actually enable valgrind. Right now we disable 1605# valgrind when cross-compilation or an emulator is enabled at the 1606# same time. 1607if test "x$jitter_cross_compiling" = "xyes"; then 1608 AC_MSG_RESULT([no, disabled because we are cross-compiling]) 1609 AC_SUBST([JITTER_VALGRIND], []) 1610elif ! test "x$JITTER_EMULATOR" = "x"; then 1611 AC_MSG_RESULT([no, disabled because an emulator is also used]) 1612 AC_SUBST([JITTER_VALGRIND], []) 1613elif test "x$jitter_with_valgrind" = "xno"; then 1614 AC_MSG_RESULT([no, disabled by configure option]) 1615 AC_SUBST([JITTER_VALGRIND], []) 1616elif test "x$jitter_with_valgrind" = "xdetect" \ 1617 || test "x$jitter_with_valgrind" = "xyes"; then 1618 AC_PATH_PROG([JITTER_VALGRIND], [valgrind]) 1619 if test "x$JITTER_VALGRIND" = "x"; then 1620 AC_MSG_RESULT([no, not found]) 1621 if test "x$jitter_with_valgrind" = "xyes"; then 1622 AC_MSG_ERROR([Valgrind requested but not found]) 1623 fi 1624 else 1625 AC_MSG_RESULT([yes, found as $JITTER_VALGRIND]) 1626 fi 1627else 1628 AC_MSG_RESULT([yes, defined by configure option as $jitter_with_valgrind]) 1629 AC_SUBST([JITTER_VALGRIND], [$jitter_with_valgrind]) 1630fi 1631 1632 1633# Test suite support. 1634################################################################ 1635 1636# Decide whether we should enable the test suite... 1637AC_MSG_CHECKING([if we should enable the test suite]) 1638# By default we can run the test suite if we have all the needed utilites 1639# *and* either we are not cross-compiling, or if an emulator is enabled, 1640# *and* we are not in sub-package mode... 1641if test "x$jitter_test_suite_missing_progs" = "x" \ 1642 && ( test "x$jitter_cross_compiling" = "xno" \ 1643 || ! test "x$JITTER_EMULATOR" = "x") \ 1644 && test "x$JITTER_SUBPACKAGE" = 'x'; then 1645 default=yes 1646else 1647 default=no 1648fi 1649# ... But this default can be overridden with a configure option. 1650AC_ARG_ENABLE([jitter-test-suite], 1651 AS_HELP_STRING([--enable-jitter-test-suite], 1652 [enable the test suite (default: automatically 1653 detected in non-sub-package mode; no in 1654 sub-package mode). The name includes "jitter" 1655 to prevent collisions with configure options 1656 in a super-package]), 1657 jitter_enable_test_suite="$enableval", 1658 jitter_enable_test_suite="$default") 1659if ! test "x$jitter_enable_test_suite" = "xyes" \ 1660 && ! test "x$jitter_enable_test_suite" = "xno"; then 1661 AC_MSG_ERROR([invalid option argument for --enable-test-suite]) 1662fi 1663 1664# Now we know if the test suite is enabled or not. Define a substitution and 1665# an Automake conditional about it. 1666AC_SUBST([JITTER_ENABLE_TEST_SUITE], [$jitter_enable_test_suite]) 1667AC_MSG_RESULT([$JITTER_ENABLE_TEST_SUITE]) 1668AM_CONDITIONAL([JITTER_ENABLE_TEST_SUITE], 1669 [test "x$JITTER_ENABLE_TEST_SUITE" = "xyes"]) 1670 1671# If the test suite was enabled despite a missing dependency, print a warning. 1672if test "x$jitter_enable_test_suite" = "xyes" \ 1673 && ! test "x$jitter_test_suite_missing_progs" = "x"; then 1674 AC_MSG_WARN([enabling the test suite despite missing programs, as \ 1675requested. You can expect some spurious failures]) 1676fi 1677 1678# Print a warning about skipped test cases if we can run the test suite but 1679# Valgrind is disabled. 1680if test "x$JITTER_CAN_RUN_TESTSUITE" = "xyes" \ 1681 && test "x$JITTER_VALGRIND" = "x"; then 1682 AC_MSG_WARN([the test suite will skip Valgrind test cases]) 1683fi 1684 1685# In sub-package mode when the test suite is disabled, running it anyway (as it 1686# may well happen because of recursion from the super-package) should be 1687# successful but also as silent as possible. 1688# A good way of ensuring this is redefining TEST_SUITE_LOG to have an empty 1689# value instead of the default test-suite.log: this will take precedence 1690# over any setting of the same variable by Automake. 1691# Explicitly defining TEST_SUITE_LOG in Makefile.am would also work, but at 1692# the cost of generating a warning when Automake is run. 1693# This way of using AC_SUBST to override Automake default behavior is in fact 1694# supported and documented in the Automake manual (§"Extending Automake Rules"). 1695if test "x$JITTER_SUBPACKAGE" != 'x' \ 1696 && test "x$jitter_enable_test_suite" = 'xno'; then 1697 jitter_test_suite_log_value='' 1698else 1699 jitter_test_suite_log_value='test-suite.log' 1700fi 1701AC_SUBST([TEST_SUITE_LOG], [$jitter_test_suite_log_value]) 1702 1703 1704# Dispatching models to be enabled. 1705################################################################ 1706 1707# Check whether each dispatching model is available and enabled, in order of 1708# increasing preference. The last found to be enabled is also considered the 1709# best. 1710jitter_enabled_dispatch_models="" 1711jitter_best_dispatch_model="" 1712 1713# Define a disclaimer to be printed to the user when checking which dispatches 1714# are enabled, showing that the decision is not final in sub-package mode. 1715if test "x$JITTER_SUBPACKAGE" != 'x'; then 1716 jitter_subpackage_disclaimer=', provisionally (sub-package mode)' 1717else 1718 jitter_subpackage_disclaimer='' 1719fi 1720 1721# Is the switch dispatch enabled? Check the default and the configure 1722# command-line option. 1723AC_MSG_CHECKING([if switch dispatching is enabled]) 1724default=yes 1725AC_ARG_ENABLE([dispatch-switch], 1726 AS_HELP_STRING([--enable-dispatch-switch], 1727 [enable switch dispatching (default: yes)]), 1728 jitter_enable_dispatch_switch="$enableval", 1729 jitter_enable_dispatch_switch="$default") 1730if test "x$jitter_enable_dispatch_switch" = "xyes"; then 1731 jitter_best_dispatch_model="switch" 1732 jitter_enabled_dispatch_models="$jitter_enabled_dispatch_models switch" 1733fi 1734AC_MSG_RESULT([$jitter_enable_dispatch_switch$jitter_subpackage_disclaimer]) 1735 1736# Is the direct-threading dispatch enabled? Check the default and the configure 1737# command-line option. 1738AC_MSG_CHECKING([if direct-threading dispatch is enabled]) 1739default=$(test "x$ac_cv_have_gnu_c_computed_goto" = 'xyes' \ 1740 && test "x$ac_cv_have_gnu_c_constant_label_difference" = 'xyes' \ 1741 && echo yes || echo no) 1742AC_ARG_ENABLE([dispatch-direct-threading], 1743 AS_HELP_STRING([--enable-dispatch-direct-threading], 1744 [enable direct-threading dispatch: default yes if and 1745only if the compiler supports GNU C computed goto and (same-function) label 1746address differences are constant expressions]), 1747 jitter_enable_dispatch_direct_threading="$enableval", 1748 jitter_enable_dispatch_direct_threading="$default") 1749if test "x$jitter_enable_dispatch_direct_threading" = "xyes"; then 1750 jitter_best_dispatch_model="direct-threading" 1751 jitter_enabled_dispatch_models="$jitter_enabled_dispatch_models direct-threading" 1752fi 1753AC_MSG_RESULT([$jitter_enable_dispatch_direct_threading$jitter_subpackage_disclaimer]) 1754 1755# Is the minimal-threading dispatch enabled? Check the default and the 1756# configure command-line option. 1757AC_MSG_CHECKING([if minimal-threading dispatch is enabled]) 1758# FIXME: reenable this when I make defect handling reliable. 1759#default=$(test "x$JITTER_HAVE_ACTUAL_GCC" = "xyes" && echo yes || echo no) 1760default=no 1761AC_ARG_ENABLE([dispatch-minimal-threading], 1762 AS_HELP_STRING([--enable-dispatch-minimal-threading], 1763 [enable minimal threading dispatch: default yes if and 1764only if GCC (not an imitation) is used]), 1765 jitter_enable_dispatch_minimal_threading="$enableval", 1766 jitter_enable_dispatch_minimal_threading="$default") 1767if test "x$jitter_enable_dispatch_minimal_threading" = "xyes"; then 1768 jitter_best_dispatch_model="minimal-threading" 1769 jitter_enabled_dispatch_models="$jitter_enabled_dispatch_models minimal-threading" 1770fi 1771AC_MSG_RESULT([$jitter_enable_dispatch_minimal_threading$jitter_subpackage_disclaimer]) 1772# FIXME: remove this warning message when I make defect handling reliable. 1773if test "x$jitter_enable_dispatch_minimal_threading" = "xyes"; then 1774 AC_MSG_WARN([minimal-threading dispatch is currently unreliable, and should 1775 not be used in production until defective instruction replacement is fully 1776 implemented]) 1777fi 1778 1779# Is the no-threading dispatch enabled? Check the default and the configure 1780# command-line option. 1781AC_MSG_CHECKING([if no-threading dispatch is enabled]) 1782if test "x$JITTER_HAVE_ACTUAL_GCC" = "xyes" \ 1783 && test "x$jitter_has_host_assembly" = "xyes" \ 1784 && test "x$jitter_host_os_is_elf" = "xyes"; then 1785 # FIXME: reenable this when I make defect handling reliable. 1786 #default=yes 1787 default=no 1788else 1789 default=no 1790fi 1791AC_ARG_ENABLE([dispatch-no-threading], 1792 AS_HELP_STRING([--enable-dispatch-no-threading], 1793 [enable no-threading dispatch: default yes if and 1794only if GCC (not an imitation) is used, the host 1795architecture has assembly support, and the binary format is ELF]), 1796 jitter_enable_dispatch_no_threading="$enableval", 1797 jitter_enable_dispatch_no_threading="$default") 1798if test "x$jitter_enable_dispatch_no_threading" = "xyes"; then 1799 jitter_best_dispatch_model="no-threading" 1800 jitter_enabled_dispatch_models="$jitter_enabled_dispatch_models no-threading" 1801fi 1802AC_MSG_RESULT([$jitter_enable_dispatch_no_threading$jitter_subpackage_disclaimer]) 1803# Fail if no-threading dispatch was enabled without assembly support. 1804if test "x$jitter_has_host_assembly" = "xno" \ 1805 && test "x$jitter_enable_dispatch_no_threading" = "xyes"; then 1806 AC_MSG_ERROR([no-threading dispatch requires assembly support]) 1807fi 1808# FIXME: remove this warning message when I make defect handling reliable. 1809if test "x$jitter_enable_dispatch_no_threading" = "xyes"; then 1810 AC_MSG_WARN([no-threading dispatch is currently unreliable, and should not be 1811 used in production until defective instruction replacement is fully 1812 implemented]) 1813fi 1814 1815# Fail if there is no best dispatch: this means that none was enabled. 1816if test "x$jitter_best_dispatch_model" = 'x'; then 1817 AC_MSG_ERROR([no dispatch was enabled, but you need at least one]) 1818fi 1819 1820# In sub-package mode disable every dispatch except for the best one, in order 1821# to speed up compilation and testing. 1822if test "x$JITTER_SUBPACKAGE" != 'x'; then 1823 AC_MSG_NOTICE([sub-package mode: disabling every dispatch except] 1824[$jitter_best_dispatch_model]) 1825 AC_MSG_NOTICE([ (the following dispatches could have been enabled:] 1826[ $jitter_enabled_dispatch_models)]) 1827 jitter_enabled_dispatch_models=" $jitter_best_dispatch_model" 1828 jitter_enable_dispatch_switch=no 1829 jitter_enable_dispatch_direct_threading=no 1830 jitter_enable_dispatch_minimal_threading=no 1831 jitter_enable_dispatch_no_threading=no 1832 case "$jitter_best_dispatch_model" in 1833 switch) 1834 jitter_enable_dispatch_switch=yes;; 1835 direct-threading) 1836 jitter_enable_dispatch_direct_threading=yes;; 1837 minimal-threading) 1838 jitter_enable_dispatch_minimal_threading=yes;; 1839 no-threading) 1840 jitter_enable_dispatch_no_threading=yes;; 1841 *) AC_MSG_ERROR([this should never happen]);; 1842 esac 1843fi 1844 1845# Now that we have finally decided which dispatches will be enabled, define a 1846# substitution, a CPP feature macro and an Automake conditional for each of them. 1847AC_SUBST([JITTER_ENABLE_DISPATCH_SWITCH], 1848 [$(test "x$jitter_enable_dispatch_switch" = 'xyes' && echo '1')]) 1849AC_SUBST([JITTER_ENABLE_DISPATCH_DIRECT_THREADING], 1850 [$(test "x$jitter_enable_dispatch_direct_threading" = 'xyes' && echo '1')]) 1851AC_SUBST([JITTER_ENABLE_DISPATCH_MINIMAL_THREADING], 1852 [$(test "x$jitter_enable_dispatch_minimal_threading" = 'xyes' && echo '1')]) 1853AC_SUBST([JITTER_ENABLE_DISPATCH_NO_THREADING], 1854 [$(test "x$jitter_enable_dispatch_no_threading" = 'xyes' && echo '1')]) 1855if test "x$jitter_enable_dispatch_switch" = 'xyes'; then 1856 AC_DEFINE_UNQUOTED([JITTER_ENABLE_DISPATCH_SWITCH], [1], 1857 [enable switch dispatch]) 1858fi 1859if test "x$jitter_enable_dispatch_direct_threading" = 'xyes'; then 1860 AC_DEFINE_UNQUOTED([JITTER_ENABLE_DISPATCH_DIRECT_THREADING], [1], 1861 [enable direct-threading dispatch]) 1862fi 1863if test "x$jitter_enable_dispatch_minimal_threading" = 'xyes'; then 1864 AC_DEFINE_UNQUOTED([JITTER_ENABLE_DISPATCH_MINIMAL_THREADING], [1], 1865 [enable minimal-threading dispatch]) 1866fi 1867if test "x$jitter_enable_dispatch_no_threading" = 'xyes'; then 1868 AC_DEFINE_UNQUOTED([JITTER_ENABLE_DISPATCH_NO_THREADING], [1], 1869 [enable no-threading dispatch]) 1870fi 1871AM_CONDITIONAL([JITTER_ENABLE_DISPATCH_SWITCH], 1872 [test "x$jitter_enable_dispatch_switch" = 'xyes']) 1873AM_CONDITIONAL([JITTER_ENABLE_DISPATCH_DIRECT_THREADING], 1874 [test "x$jitter_enable_dispatch_direct_threading" = 'xyes']) 1875AM_CONDITIONAL([JITTER_ENABLE_DISPATCH_MINIMAL_THREADING], 1876 [test "x$jitter_enable_dispatch_minimal_threading" = 'xyes']) 1877AM_CONDITIONAL([JITTER_ENABLE_DISPATCH_NO_THREADING], 1878 [test "x$jitter_enable_dispatch_no_threading" = 'xyes']) 1879 1880 1881# AC_SUBST the list of all the enabled dispatching models, and the best one; 1882# these don't use quotes as they are meant for jitter-config and shell scripts, 1883# not for C code. 1884AC_SUBST([JITTER_ENABLED_DISPATCHES], 1885 [$jitter_enabled_dispatch_models]) 1886AC_SUBST([JITTER_BEST_DISPATCH], 1887 [$jitter_best_dispatch_model]) 1888 1889# Define a substitution holding the best dispatching model name, and a a CPP 1890# feature macro named after the best dispatching model. 1891# We also need an Autoheader template for every possible CPP "best-distpatching" 1892# macro name, as the actual name is computed with a shell expansion and 1893# autoheader cannot discover every possibility. 1894AH_TEMPLATE([JITTER_BEST_DISPATCHING_MODEL_IS_SWITCH], 1895 [Defined if switch is the best enabled dispatch.]) 1896AH_TEMPLATE([JITTER_BEST_DISPATCHING_MODEL_IS_DIRECT_THREADING], 1897 [Defined if direct-threading is the best enabled dispatch.]) 1898AH_TEMPLATE([JITTER_BEST_DISPATCHING_MODEL_IS_MINIMAL_THREADING], 1899 [Defined if minimal-threading is the best enabled dispatch.]) 1900AH_TEMPLATE([JITTER_BEST_DISPATCHING_MODEL_IS_NO_THREADING], 1901 [Defined if no-threading is the best enabled dispatch.]) 1902if test "x$jitter_best_dispatch_model" = "x"; then 1903 AC_MSG_ERROR([no dispatchnig model is enabled]) 1904else 1905 AC_MSG_NOTICE([enabled dispatching models are:] 1906[ $jitter_enabled_dispatch_models]) 1907 AC_MSG_NOTICE([the best enabled dispatching model is:] 1908[ $jitter_best_dispatch_model]) 1909 AC_SUBST([JITTER_BEST_DISPATCHING_MODEL], [$jitter_best_dispatch_model]) 1910 JITTER_BEST_DISPATCH_MODEL=$(echo $jitter_best_dispatch_model | jitter_to_upper) 1911 AC_DEFINE_UNQUOTED([JITTER_BEST_DISPATCHING_MODEL_NAME_LOWER], 1912 ["$jitter_best_dispatch_model"], 1913 [The name of the best dispatching model, lower-case.]) 1914 AC_DEFINE_UNQUOTED([JITTER_BEST_DISPATCHING_MODEL_NAME_UPPER], 1915 ["$JITTER_BEST_DISPATCH_MODEL"], 1916 [The name of the best dispatching model, upper-case with 1917 '-' replaced by '_'.]) 1918 AC_DEFINE_UNQUOTED([JITTER_BEST_DISPATCHING_MODEL_IS_$JITTER_BEST_DISPATCH_MODEL], 1919 [1], 1920 [Defined if $jitter_best_dispatch_model is the best 1921 enabled dispatching model.]) 1922fi 1923 1924 1925# Automake conditional enabling assembly. 1926############################################################################ 1927 1928# Define an Automake conditional stating whether the assembly support, which may 1929# be present or not, is to be used. This is particularly important for 1930# combinations of supported architectures and unsupported binary formats. 1931AC_MSG_CHECKING([if we are actually using any assembly support]) 1932if test "x$jitter_has_host_assembly" = "xyes" \ 1933 && test "x$jitter_have_known_binary_format" = 'xyes' \ 1934 && (test "x$jitter_enable_dispatch_minimal_threading" = 'xyes' \ 1935 || test "x$jitter_enable_dispatch_no_threading" = 'xyes'); then 1936 jitter_enable_assembly=yes 1937 AC_DEFINE_UNQUOTED([JITTER_ENABLE_ASSEMBLY], [1], 1938 [Define iff assembly support is to be actually used]) 1939else 1940 jitter_enable_assembly=no 1941fi 1942AM_CONDITIONAL([JITTER_ENABLE_ASSEMBLY], 1943 [test "x$jitter_enable_assembly" = 'xyes']) 1944AC_MSG_RESULT([$jitter_enable_assembly]) 1945 1946 1947# Installation paths, relative to installation prefixes. 1948################################################################ 1949 1950# According to the GNU Coding Standards installation prefixes can be decided 1951# very late, at make time; therefore there are no AC_SUBST or AC_DEFINE calls 1952# fixing complete paths here. However we can establish once and for all some 1953# subdirectories, relative to prefixes we don't know yet. 1954AC_SUBST([JITTER_FLAG_SUBDIRECTORY], 1955 [lib/$PACKAGE_TARNAME/$PACKAGE_VERSION/flags]) 1956AC_SUBST([JITTER_TEMPLATE_SUBDIRECTORY], 1957 [$PACKAGE_TARNAME/$PACKAGE_VERSION/templates]) 1958 1959 1960# Flags. 1961################################################################ 1962 1963# Some flags such as -fno-reorder-blocks are useful with switch and 1964# direct-threading dispatches only to make disassembly of VM instructions 1965# possible, by reading the assembly code starting from a given point up to 1966# another given point; they actually make performance worse, so they are not 1967# enabled by default. 1968AC_MSG_CHECKING([if disassemble-friendly CFLAGS should be enabled]) 1969AC_ARG_ENABLE([disassemble-friendly-cflags], 1970 AS_HELP_STRING([--enable-disassemble-friendly-cflags], 1971 [Compile VM code with some GCC options which make disassembly 1972 possible, even if they make performance worse. This is only 1973 relevant to switch and direct-threading dispatches. 1974 (default: no)]), 1975 jitter_enable_disassemble_friendly_cflags="$enableval", 1976 jitter_enable_disassemble_friendly_cflags="no") 1977AC_MSG_RESULT([$jitter_enable_disassemble_friendly_cflags]) 1978 1979# Generate flag files in $builddir/flags/$dispatch_model , for every enabled 1980# dispatch_model . Cleanup at the beginning, cd back to $builddir at the end. 1981rm -rf flags 1982mkdir flags 1983for dispatch_model in $jitter_enabled_dispatch_models; do 1984 DISPATCH_MODEL="$(echo $dispatch_model | jitter_to_upper)" 1985 1986 # Generate flags for $dispatch_model 1987 mkdir "flags/$dispatch_model" 1988 AC_MSG_NOTICE([generating flags for dispatching model \"$dispatch_model\"...]) 1989 JITTER_FLAGS_CFLAGS="" 1990 1991 # We always want these options. See the comment below about why 1992 # -fno-reorder-functions is not desirable. 1993 jitter_check_cc_options JITTER_FLAGS_CFLAGS -O2 -fomit-frame-pointer 1994 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-reorder-functions 1995 1996 # We want ELF visibility flags when enabled, independently from the dispatch. 1997 if test "x$jitter_enable_visibility_hidden" = 'xyes'; then 1998 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fvisibility=hidden 1999 jitter_check_cc_options JITTER_FLAGS_LDFLAGS -fvisibility=hidden 2000 fi 2001 2002 # Use disassemble-friendly flags for simple dispatches, if the user requested 2003 # them. 2004 case "$dispatch_model" in 2005 switch|direct-threading) 2006 if test "x$jitter_enable_disassemble_friendly_cflags" != 'xno'; then 2007 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-reorder-blocks 2008 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-reorder-blocks-and-partition 2009 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-crossjumping 2010 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-thread-jumps 2011 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-tree-tail-merge 2012 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-isolate-erroneous-paths-dereference 2013 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-split-paths 2014 fi;; 2015 esac 2016 2017 # LTO, impressive as it is in general, is a bad match for Jitter, for 2018 # correctness reasons on complex dispatches and for performance reasons with 2019 # switch and direct-threading dispatches. 2020 if test "x$jitter_host_os_is_netbsd" != 'xyes'; then 2021 # NetBSD, at least version 9, has a problem with this option, as the 2022 # compiler (a custom variant of GCC 7.4.0) accepts the option but then fails 2023 # at link time. I noticed this with NetBSD version 9. I may want to 2024 # conditionalize differently in the future if other versions actually 2025 # supporting LTO come out. 2026 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-lto 2027 fi 2028 2029 # Experimental: disable debugging options which appear to be expensive at 2030 # compile time. 2031 jitter_check_cc_options JITTER_FLAGS_CFLAGS -g0 2032 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-var-tracking 2033 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-var-tracking-assignments 2034 2035 # I like register names to be visually distinct from numeric immediates -- 2036 # this is particularly important for data locations, which are text strings 2037 # visible to the user containing assembly operands in the syntax generated by 2038 # GCC. I know this option to exist on PowerPC, but it does no harm to try it 2039 # on other architectures as well. 2040 jitter_check_cc_options JITTER_FLAGS_CFLAGS -mregnames 2041 2042 # In C division and remainder by zero have undefined semantics; however GCC 2043 # defaults to generate a conditional trap or break instruction on MIPS, which 2044 # has a cost. Avoid it. 2045 # Safe languages compiled to the VM will need to add their own check anyway, 2046 # which will just add to the cost. This is not the place for being friendly 2047 # to the human debugger at the cost of performance. 2048 case "$host_cpu" in 2049 mips*) 2050 jitter_check_cc_options JITTER_FLAGS_CFLAGS -mno-check-zero-division 2051 ;; 2052 esac 2053 2054 if test "x$jitter_host_os_is_elf" != "xyes" \ 2055 && test "x$JITTER_GNU_ASSEMBLER" != "xno"; then 2056 # Jitter's section-changing mechanism on non-ELF systems relies on changing 2057 # subsections using Gas ".text SUBSECTION" directives, which don't play well 2058 # with CFI directives. In this case we also need all the code to be 2059 # generated in .text, and not in ".text.hot" or ".text.unlikely", as 2060 # -freorder-functions does. 2061 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-dwarf2-cfi-asm 2062 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-reorder-functions 2063 fi 2064 2065# jitter_check_cc_options JITTER_FLAGS_CFLAGS -frename-registers 2066# jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-plt 2067 2068 # The GCC manual recommends -fno-gcse for code relying heavily on computed 2069 # goto. Jittery VMs would qualify at least with direct-threading and 2070 # minimal-threading dispatches (the situation with no-threading is less 2071 # clear since the inline asm goto code systematically lies to the compiler 2072 # about branch destinations but there are few reachable computed goto 2073 # statements); however in my tests -fno-gcse appears to only have a little 2074 # *negative* effect on performance. 2075 # Disabling it for the time being. 2076 # if test "$dispatch_model" != "switch"; then 2077 # jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-gcse 2078 # fi 2079 case "$dispatch_model" in 2080 minimal-threading|no-threading) 2081 # The same options which were just disassemble-friendly with switch and 2082 # direct-threading are important for correctness here. 2083 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-reorder-blocks 2084 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-reorder-blocks-and-partition 2085 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-crossjumping 2086 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-thread-jumps 2087 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-tree-tail-merge 2088 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-isolate-erroneous-paths-dereference 2089 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-split-paths 2090 2091 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fPIC 2092 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-align-loops 2093 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-align-jumps 2094 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-align-labels 2095 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-jump-tables 2096 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-tree-switch-conversion 2097 jitter_check_cc_options JITTER_FLAGS_CFLAGS -flive-range-shrinkage 2098# jitter_check_cc_options JITTER_FLAGS_CFLAGS -fsched-pressure 2099 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-ipa-icf 2100 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-ipa-cp 2101 jitter_check_cc_options JITTER_FLAGS_CFLAGS -fno-ipa-cp-clone 2102 ;; 2103 esac 2104 case "$host_cpu" in 2105 x86_64) 2106 if test "$dispatch_model" = "minimal-threading" \ 2107 || test "$dispatch_model" = "no-threading" ; then 2108 jitter_check_cc_options JITTER_FLAGS_CFLAGS -mcmodel=large 2109 fi 2110 ;; 2111 *) 2112 case "$dispatch_model" in 2113 minimal-threading|no-threading) 2114 # GCC generates calls to intrinsics/libc functions such as memcpy to 2115 # pass parameters. At least on PowerPC GNU/Linux these resolve to 2116 # calls via the GOT or PLT which then get optimized into PC-relative 2117 # branch-and-link instructions, I suppose by ld.so . That is all very 2118 # good in normal circumastances, but the last optimization breaks my 2119 # relocatable code. Generate inline code for such calls instead, for 2120 # the kind of smallish buffer lengths one might find in VM 2121 # instructions. 2122 jitter_check_cc_options JITTER_FLAGS_CFLAGS \ 2123 -mblock-move-inline-limit=8192 2124 ;; 2125 esac 2126 ;; 2127 esac 2128 2129 JITTER_FLAGS_CPPFLAGS="-DJITTER_DISPATCH_$DISPATCH_MODEL=1" 2130 2131 # In sub-package mode Jitter's C headers are not installed in any particular 2132 # include path, so I need to let the compiler find them via -I options in the 2133 # source directory and, for files generated by config.status , in the build 2134 # directory as well. 2135 # This holds for two kinds of headers: 2136 # * headers following the pattern 2137 # jitter/FILE.h 2138 # , included in C as <jitter/FILE.h>; 2139 # * (where assembly support exists) headers following the more complex pattern 2140 # machine/${JITTER_ASSEMBLY_SUBDIRECTORY}/jitter/machine/FILE.h 2141 # , included in C as <jitter/machine/FILE.h> . 2142 # Makefile.am (see section "Native-code libjitter sources for supported 2143 # architectures") uses this same trick to compile examples when Jitter may not 2144 # be installed. 2145 if test "x$JITTER_SUBPACKAGE" != 'x'; then 2146 JITTER_FLAGS_CPPFLAGS="$JITTER_FLAGS_CPPFLAGS -I ${jitter_abs_top_srcdir}" 2147 JITTER_FLAGS_CPPFLAGS="$JITTER_FLAGS_CPPFLAGS -I ${jitter_abs_top_builddir}" 2148 if test "x$JITTER_ASSEMBLY_SUBDIRECTORY" != 'x'; then 2149 JITTER_FLAGS_CPPFLAGS="$JITTER_FLAGS_CPPFLAGS -I ${jitter_abs_top_srcdir}/machine/${JITTER_ASSEMBLY_SUBDIRECTORY}" 2150 fi 2151 fi 2152 2153 JITTER_FLAGS_LDADD="-ljitter--$dispatch_model" 2154 2155 if test "x$JITTER_SUBPACKAGE" != 'x'; then 2156 JITTER_FLAGS_LIBADD="${jitter_abs_top_builddir}/lib/libjitter--$dispatch_model.la" 2157 else 2158 # If the library is installed we can avoid specifying an explicit directory 2159 # for the convenience library (it would be ${libdir}) and instead rely on 2160 # JITTER_FLAGS_LDFLAGS containing the correct -L option. This prevents 2161 # problems with non-installed libararies in non-sub-package mode. 2162 JITTER_FLAGS_LIBADD="libjitter--$dispatch_model.la" 2163 fi 2164 2165 # Search for Jitter runtime libraries in the right place. 2166 if test "x$JITTER_SUBPACKAGE" != 'x'; then 2167 # See the comment above for sub-package mode and include paths. This case 2168 # is simpler. 2169 JITTER_FLAGS_LDFLAGS="-L${jitter_abs_top_builddir}/lib" 2170 else 2171 JITTER_FLAGS_LDFLAGS="-L${libdir}" 2172 fi 2173 export JITTER_FLAGS_LDFLAGS 2174 2175 echo "$CC" > flags/$dispatch_model/CC 2176 echo "$JITTER_FLAGS_CPPFLAGS" > flags/$dispatch_model/CPPFLAGS 2177 echo "$JITTER_FLAGS_CFLAGS" > flags/$dispatch_model/CFLAGS 2178 echo "$JITTER_FLAGS_LDADD" > flags/$dispatch_model/LDADD 2179 echo "$JITTER_FLAGS_LDFLAGS" > flags/$dispatch_model/LDFLAGS 2180 echo "$JITTER_FLAGS_LIBADD" > flags/$dispatch_model/LIBADD 2181 2182 # Also AC_SUBST flag variables for the best dispatching model, if the best 2183 # happens to be the one we're handling now. 2184 if test "x$jitter_best_dispatch_model" = "x$dispatch_model"; then 2185 AC_SUBST([JITTER_CFLAGS], 2186 [$(cat flags/$dispatch_model/CFLAGS)]) 2187 AC_SUBST([JITTER_CPPFLAGS], 2188 [$(cat flags/$dispatch_model/CPPFLAGS)]) 2189 AC_SUBST([JITTER_LDADD], 2190 [$(cat flags/$dispatch_model/LDADD)]) 2191 AC_SUBST([JITTER_LDFLAGS], 2192 [$(cat flags/$dispatch_model/LDFLAGS)]) 2193 AC_SUBST([JITTER_LIBADD], 2194 [$(cat flags/$dispatch_model/LIBADD)]) 2195# AC_SUBST([JITTER_MAKE_FLAGS], 2196# '$(MAKEFLAGS) CFLAGS="$(AM_CFLAGS) $(JITTER_CFLAGS)" CPPFLAGS="$(AM_CPPFLAGS) $(JITTER_CPPFLAGS)" LDFLAGS="$(AM_LDFLAGS) $(JITTER_LDFLAGS)" LDADD="$(JITTER_LDADD)"') # There is no AM_LDADD 2197 fi 2198done 2199 2200# AC_SUBST flag variables for every dispatching model. FIXME: the first 2201# argument of AC_SUBST must be literal , therefore a shell loop doesn't work 2202# here, but it shouldn't be hard with m4 macros. 2203if test "x$jitter_enable_dispatch_switch" = "xyes"; then 2204 AC_SUBST([JITTER_SWITCH_CFLAGS], 2205 [$(cat flags/switch/CFLAGS)]) 2206 AC_SUBST([JITTER_SWITCH_CPPFLAGS], 2207 [$(cat flags/switch/CPPFLAGS)]) 2208 AC_SUBST([JITTER_SWITCH_LDADD], 2209 [$(cat flags/switch/LDADD)]) 2210 AC_SUBST([JITTER_SWITCH_LDFLAGS], 2211 [$(cat flags/switch/LDFLAGS)]) 2212 AC_SUBST([JITTER_SWITCH_LIBADD], 2213 [$(cat flags/switch/LIBADD)]) 2214# AC_SUBST([JITTER_SWITCH_MAKE_FLAGS], 2215# '$(MAKEFLAGS) CFLAGS="$(AM_CFLAGS) $(JITTER_SWITCH_CFLAGS)" CPPFLAGS="$(AM_CPPFLAGS) $(JITTER_SWITCH_CPPFLAGS)" LDFLAGS="$(AM_LDFLAGS) $(JITTER_SWITCH_LDFLAGS)" LDADD="$(JITTER_SWITCH_LDADD)"') # There is no AM_LDADD 2216fi 2217if test "x$jitter_enable_dispatch_direct_threading" = "xyes"; then 2218 AC_SUBST([JITTER_DIRECT_THREADING_CFLAGS], 2219 [$(cat flags/direct-threading/CFLAGS)]) 2220 AC_SUBST([JITTER_DIRECT_THREADING_CPPFLAGS], 2221 [$(cat flags/direct-threading/CPPFLAGS)]) 2222 AC_SUBST([JITTER_DIRECT_THREADING_LDADD], 2223 [$(cat flags/direct-threading/LDADD)]) 2224 AC_SUBST([JITTER_DIRECT_THREADING_LDFLAGS], 2225 [$(cat flags/direct-threading/LDFLAGS)]) 2226 AC_SUBST([JITTER_DIRECT_THREADING_LIBADD], 2227 [$(cat flags/direct-threading/LIBADD)]) 2228# AC_SUBST([JITTER_DIRECT_THREADING_MAKE_FLAGS], 2229# '$(MAKEFLAGS) CFLAGS="$(AM_CFLAGS) $(JITTER_DIRECT_THREADING_CFLAGS)" CPPFLAGS="$(AM_CPPFLAGS) $(JITTER_DIRECT_THREADING_CPPFLAGS)" LDFLAGS="$(AM_LDFLAGS) $(JITTER_DIRECT_THREADING_LDFLAGS)" LDADD="$(JITTER_DIRECT_THREADING_LDADD)"') # There is no AM_LDADD 2230fi 2231if test "x$jitter_enable_dispatch_minimal_threading" = "xyes"; then 2232 AC_SUBST([JITTER_MINIMAL_THREADING_CFLAGS], 2233 [$(cat flags/minimal-threading/CFLAGS)]) 2234 AC_SUBST([JITTER_MINIMAL_THREADING_CPPFLAGS], 2235 [$(cat flags/minimal-threading/CPPFLAGS)]) 2236 AC_SUBST([JITTER_MINIMAL_THREADING_LDADD], 2237 [$(cat flags/minimal-threading/LDADD)]) 2238 AC_SUBST([JITTER_MINIMAL_THREADING_LDFLAGS], 2239 [$(cat flags/minimal-threading/LDFLAGS)]) 2240 AC_SUBST([JITTER_MINIMAL_THREADING_LIBADD], 2241 [$(cat flags/minimal-threading/LIBADD)]) 2242# AC_SUBST([JITTER_MINIMAL_THREADING_MAKE_FLAGS], 2243# '$(MAKEFLAGS) CFLAGS="$(AM_CFLAGS) $(JITTER_MINIMAL_THREADING_CFLAGS)" CPPFLAGS="$(AM_CPPFLAGS) $(JITTER_MINIMAL_THREADING_CPPFLAGS)" LDFLAGS="$(AM_LDFLAGS) $(JITTER_MINIMAL_THREADING_LDFLAGS)" LDADD="$(JITTER_MINIMAL_THREADING_LDADD)"') # There is no AM_LDADD 2244fi 2245if test "x$jitter_enable_dispatch_no_threading" = "xyes"; then 2246 AC_SUBST([JITTER_NO_THREADING_CFLAGS], 2247 [$(cat flags/no-threading/CFLAGS)]) 2248 AC_SUBST([JITTER_NO_THREADING_CPPFLAGS], 2249 [$(cat flags/no-threading/CPPFLAGS)]) 2250 AC_SUBST([JITTER_NO_THREADING_LDADD], 2251 [$(cat flags/no-threading/LDADD)]) 2252 AC_SUBST([JITTER_NO_THREADING_LDFLAGS], 2253 [$(cat flags/no-threading/LDFLAGS)]) 2254 AC_SUBST([JITTER_NO_THREADING_LIBADD], 2255 [$(cat flags/no-threading/LIBADD)]) 2256# AC_SUBST([JITTER_NO_THREADING_MAKE_FLAGS], 2257# '$(MAKEFLAGS) CFLAGS="$(AM_CFLAGS) $(JITTER_NO_THREADING_CFLAGS)" CPPFLAGS="$(AM_CPPFLAGS) $(JITTER_NO_THREADING_CPPFLAGS)" LDFLAGS="$(AM_LDFLAGS) $(JITTER_NO_THREADING_LDFLAGS)" LDADD="$(JITTER_NO_THREADING_LDADD)"') # There is no AM_LDADD 2258fi 2259 2260# AC_SUBST a set of LDFLAGS to be prepended to the ordinary ones, only useful 2261# for linking from an non-installed build directory. 2262# @JITTER_NON_INSTALLED_LDFLAGS@ must always come before other *_LDFLAGS 2263# variables, since the first -L option takes precedence. 2264AC_SUBST([JITTER_NON_INSTALLED_LDFLAGS], 2265 [-L$jitter_abs_top_builddir/non-convenience-lib]) 2266 2267 2268# Debugging support. 2269################################################################ 2270 2271# We generate readable assembly files for debugging; on some architectures I 2272# prefer an alternative non-default format, which I find more readable. These 2273# options are passed to the compiler only when generating textual assembly as 2274# a make target. 2275case "$host_cpu" in 2276 powerpc*|ppc*) 2277 # I like register names to be visually distinct from numeric immediates. 2278 AC_SUBST([JITTER_MACHINE_SPECIFIC_READABLE_ASSEMBLY_FLAGS], [-mregnames]);; 2279esac 2280 2281# Look for the indent utility, and remember whether it is available in an 2282# Automake conditional. This is only used for debugging targets. 2283AC_PATH_PROG([JITTER_INDENT], [indent]) 2284if test "x$JITTER_INDENT" = "x"; then 2285 AC_MSG_WARN([no indent utility found. \ 2286You will not be able to build nice-looking preprocessed C files for \ 2287debugging. You can still generate preprocessed files, but they will \ 2288not look as nice]) 2289fi 2290# FIXME: use AC_PATH_PROGS_FEATURE_CHECK to check for indent command line 2291# argument support. 2292AM_CONDITIONAL([JITTER_HAVE_INDENT], ! test "x$JITTER_INDENT" = "x") 2293 2294 2295# Test suite. 2296################################################################ 2297 2298# Use the TAP interface to exchange data with tests. This requires a script, 2299# distributed with Automake. 2300AC_REQUIRE_AUX_FILE([tap-driver.sh]) 2301 2302 2303# Select files generated by config.status. 2304################################################################ 2305 2306# Generate test suite scripts. 2307AC_CONFIG_FILES([tests/utility]) # This should not be made executable. 2308AC_CONFIG_FILES([tests/elementary/init-fini.test], 2309 [chmod +x tests/elementary/init-fini.test]) 2310AC_CONFIG_FILES([tests/uninspired/fundamental.test], 2311 [chmod +x tests/uninspired/fundamental.test]) 2312AC_CONFIG_FILES([tests/uninspired/programs.test], 2313 [chmod +x tests/uninspired/programs.test]) 2314AC_CONFIG_FILES([tests/structured/programs.test], 2315 [chmod +x tests/structured/programs.test]) 2316AC_CONFIG_FILES([tests/jitterlisp/jitterlisp.test], 2317 [chmod +x tests/jitterlisp/jitterlisp.test]) 2318 2319# Generate convenience emulator script. 2320AC_CONFIG_FILES([scripts/emulator], 2321 [chmod +x scripts/emulator]) 2322 2323# Generate convenience disassembly highlighter for ANSI terminals. 2324AC_CONFIG_FILES([scripts/highlight-disassembly], 2325 [chmod +x scripts/highlight-disassembly]) 2326 2327# Generate the jitter-config script. 2328AC_CONFIG_FILES([bin/jitter-config], 2329 [chmod +x bin/jitter-config]) 2330 2331# Generate the shell script generating high-level fast-branch macros. 2332AC_CONFIG_FILES([scripts/generate-fast-branches], 2333 [chmod +x scripts/generate-fast-branches]) 2334 2335 2336# Library wrappers/replacements, not part of libjitter. 2337################################################################ 2338 2339# Check for GNU libtextstyle, unless it is explicitly disabled by an option. 2340# Define a feature macro and an Automake conditional. 2341AC_ARG_WITH([libtextstyle], 2342 AS_HELP_STRING([--with-libtextstyle], 2343 [use GNU Libtextstyle if available and build 2344 the separate libjitter-libtextstyle wrapper 2345 library (default: detected)]), 2346 jitter_check_libtextstyle="$withval", 2347 jitter_check_libtextstyle="yes") 2348if test "x$jitter_check_libtextstyle" = 'xyes'; then 2349 # Save the current value for LIBS before temporary changing it. 2350 jitter_backup_LIBS="$LIBS" 2351 2352 # Check for possible dependencies of Libtextstyle. Do not use any library 2353 # other than the ones I am mentioning here. 2354 # FIXME: shall I use AC_LIB_LINKFLAGS or AC_LIB_HAVE_LINKFLAGS from Gnulib 2355 # instead? 2356 # https://www.gnu.org/software/gnulib/manual/html_node/Searching-for-Libraries.html 2357 AC_MSG_NOTICE([checking for libraries GNU Libtextstyle may possibly depend on]) 2358 LIBS='' 2359 AC_SEARCH_LIBS([sin], [m]) 2360 AC_SEARCH_LIBS([tputs], [termcap]) 2361 AC_SEARCH_LIBS([initscr], [ncurses]) 2362 AC_SEARCH_LIBS([initscr], [xcurses]) 2363 AC_SEARCH_LIBS([initscr], [curses]) 2364 AC_SEARCH_LIBS([iconv], [iconv]) 2365 # Remove unsightly duplicates from $LIBS , without changing the order of 2366 # its elements. 2367 LIBS=$(echo $(for x in $LIBS; do echo $x; done | uniq))' ' 2368 2369 # Check for Libtextstyle itself using the dependencies. This may mention 2370 # more library than are needed in the command line, but should be enough. 2371 AC_SEARCH_LIBS([ostream_flush], [textstyle]) 2372 AC_CHECK_HEADERS([textstyle.h], [jitter_have_libtextstyle_header=yes]) 2373 AC_MSG_CHECKING([if GNU Libtextstyle is usable]) 2374 if test "x$ac_cv_search_ostream_flush" != 'xno' \ 2375 && test "x$jitter_have_libtextstyle_header" = 'xyes'; then 2376 jitter_have_libtextstyle=yes 2377 AC_DEFINE_UNQUOTED([JITTER_HAVE_LIBTEXTSTYLE], [1], 2378 [Define iff GNU Libtextstyle is usable and enabled]) 2379 AC_SUBST([JITTER_LIBTEXTSTYLE_CPPFLAGS], 2380 [-DJITTER_WITH_LIBTEXTSTYLE=1]) 2381 AC_SUBST([JITTER_LIBTEXTSTYLE_LDADD], 2382 ["-ljitter-libtextstyle $LIBS"]) 2383 AC_SUBST([JITTER_LIBTEXTSTYLE_LIBADD], 2384 ["$jitter_abs_top_builddir/non-convenience-lib/libjitter-libtextstyle.la $LIBS"]) 2385 # Forget about the libraries found by the check for libtextstlye and its 2386 # dependencies: they should not be linked by default. 2387 LIBS="$jitter_backup_LIBS" 2388 else 2389 jitter_have_libtextstyle=no 2390 fi 2391 AC_MSG_RESULT([$jitter_have_libtextstyle]) 2392else 2393 AC_MSG_NOTICE([not checking for GNU Libtextstyle: disabled by configure option]) 2394fi 2395AM_CONDITIONAL([JITTER_HAVE_LIBTEXTSTYLE], 2396 [test "x$jitter_have_libtextstyle" = 'xyes']) 2397# Notice that JITTER_WITH_LIBTEXTSTYLE is not automatically defined. See 2398# the comment in jitter/jitter-config.h.in . 2399 2400 2401# Check for libraries: GNU Readline 2402################################################################ 2403 2404# Jitter comes with a separate library called libjitter-readline.la , which 2405# is always built but is not part of the Jitter runtime. The library may 2406# either actually use GNU Readline, and therefore depend on it, or implement 2407# a compatible but crude replacement which performs no line editing. 2408# 2409# Anyway, do not check for Readline and refuse to use it if we got 2410# --without-readline or --with-readline=no as a configure option. 2411AC_ARG_WITH([readline], 2412 AS_HELP_STRING([--with-readline], 2413 [actually use GNU Readline in the separate 2414 library libjitter-readline, which is always 2415 built (default: detected)]), 2416 jitter_check_readline="$withval", 2417 jitter_check_readline="yes") 2418if test "x$jitter_check_readline" = 'xyes'; then 2419 # Save the current value for LIBS before temporary changing it. 2420 jitter_backup_LIBS="$LIBS" 2421 2422 # Check for possible dependencies of Readline. Do not use any library 2423 # other than the ones I am mentioning here. 2424 # FIXME: shall I use AC_LIB_LINKFLAGS or AC_LIB_HAVE_LINKFLAGS from Gnulib 2425 # instead? 2426 # https://www.gnu.org/software/gnulib/manual/html_node/Searching-for-Libraries.html 2427 AC_MSG_NOTICE([checking for libraries GNU Readline may possibly depend on]) 2428 LIBS='' 2429 AC_SEARCH_LIBS([tputs], [termcap]) 2430 AC_SEARCH_LIBS([tinfo], [setupterm]) 2431 AC_SEARCH_LIBS([initscr], [ncurses]) 2432 AC_SEARCH_LIBS([initscr], [xcurses]) 2433 AC_SEARCH_LIBS([initscr], [curses]) 2434 # Remove unsightly duplicates from $LIBS , without changing the order of 2435 # its elements. 2436 LIBS=$(echo $(for x in $LIBS; do echo $x; done | uniq))' ' 2437 2438 # Check for Readline itself using the dependencies. This may mention 2439 # more library than are needed in the command line, but should be enough. 2440 AC_SEARCH_LIBS([readline], [readline]) 2441 AC_CHECK_HEADERS([readline/readline.h], [jitter_have_readline_header=yes]) 2442 AC_MSG_CHECKING([if GNU readline is usable]) 2443 if test "x$ac_cv_search_readline" != 'xno' \ 2444 && test "x$jitter_have_readline_header" = 'xyes'; then 2445 jitter_have_readline=yes 2446 AC_DEFINE_UNQUOTED([JITTER_HAVE_READLINE], [1], 2447 [Define iff GNU Readline is usable and enabled]) 2448 AC_SUBST([JITTER_READLINE_LDADD], 2449 ["-ljitter-readline $LIBS"]) 2450 AC_SUBST([JITTER_READLINE_LIBADD], 2451 ["$jitter_abs_top_builddir/non-convenience-lib/libjitter-readline.la $LIBS"]) 2452 # Forget about the libraries found by the check for libtextstlye and its 2453 # dependencies: they should not be linked by default. 2454 LIBS="$jitter_backup_LIBS" 2455 else 2456 jitter_have_readline=no 2457 fi 2458 AC_MSG_RESULT([$jitter_have_readline]) 2459else 2460 AC_MSG_NOTICE([not checking for GNU Readline: disabled by configure option]) 2461fi # if test "x$jitter_check_readline" = "xyes" 2462if test "x$jitter_have_readline" != "xyes"; then 2463 # Define substitutions for using libjitter-readline without not linking the 2464 # actual GNU Readline. 2465 AC_SUBST([JITTER_READLINE_LDADD], ["-ljitter-readline"]) 2466 AC_SUBST([JITTER_READLINE_LIBADD], 2467 ["$jitter_abs_top_builddir/non-convenience-lib/libjitter-readline.la"]) 2468fi 2469AM_CONDITIONAL([JITTER_HAVE_READLINE], 2470 [test "x$jitter_have_readline" = 'xyes']) 2471 2472 2473# Optional dependencies, for examples only. 2474################################################################ 2475 2476# JitterLisp can optionally use Boehm's garbage collector. I use AC_CHECK_LIB 2477# with an explicit ACTION-IF-FOUND rather than AC_SEARCH_LIBS , because I don't 2478# want to modify the LIBS variable. This is specific to some examples. 2479AC_CHECK_LIB([gc], [GC_malloc], [JITTER_HAVE_BOEHM_GC_LIBRARY=yes]) 2480AC_CHECK_HEADERS([gc/gc.h], [JITTER_HAVE_BOEHM_GC_HEADER=yes]) 2481if test "x$JITTER_HAVE_BOEHM_GC_LIBRARY" = "xyes" \ 2482 && test "x$JITTER_HAVE_BOEHM_GC_HEADER" = "xyes"; then 2483 JITTER_HAVE_BOEHM_GC=yes 2484else 2485 JITTER_HAVE_BOEHM_GC=no 2486fi 2487AC_MSG_CHECKING([if Boehm's GC is usable for JitterLisp]) 2488AC_MSG_RESULT([$JITTER_HAVE_BOEHM_GC]) 2489AM_CONDITIONAL([JITTER_HAVE_BOEHM_GC], 2490 [test "x$JITTER_HAVE_BOEHM_GC" = "xyes"]) 2491 2492# Also set a substitution telling whether Boehm's GC is used, which is useful 2493# to check from the test suite. 2494if test "x$JITTER_HAVE_BOEHM_GC" = "xyes"; then 2495 AC_SUBST([JITTER_HAVE_BOEHM_GC_SUBST], [1]) 2496else 2497 AC_SUBST([JITTER_HAVE_BOEHM_GC_SUBST], []) 2498 true 2499fi 2500 2501 2502# ChangeLog generation. 2503################################################################ 2504 2505# Define an Automake conditional telling whether we're building from git. 2506# This is useful to decide whether to rebuild the ChangeLog file on dist. 2507# Notice that when a sub-package Jitter exists in a subdirectory of a 2508# super-package as a git submodule the $srcdir/.git object exists but is a 2509# *file* instead of a directory. 2510AM_CONDITIONAL([JITTER_BUILDING_FROM_GIT], 2511 [test -d "$srcdir/.git" || test -f "$srcdir/.git"]) 2512 2513 2514# Define non-colliding alternatives to Autoconf feature macros. 2515################################################################ 2516 2517# See the comment above in "Generated C headers": define CPP feature macros with 2518# the same name as the ones defined by predefined Autoconf tests, by Gnulib 2519# tests or by my own, with a JITTER_ prefix preventing collisions. These will 2520# end up in jitter/jitter-config.h , which is installed and included by user 2521# code. 2522 2523# Define prefixed alternatives for some macros which are not meant to be used 2524# with #ifdef , but rather have a meaningful non-Boolean value. 2525# It is harmless to use this even for macros which are meant to be conditionally 2526# defined, as long as user code checks for the associated feature macro as well 2527# -- which it needs to anyway. 2528# 2529# Arguments: 2530# * shell variable; 2531# * unprefixed feature macro name. 2532m4_define([jitter_define_prefixed_macro], 2533 [AC_DEFINE([JITTER_$2], 2534 [@S|@$1], 2535 [Same as $2 with a JITTER_ prefix suitable for an 2536 installed header.]) 2537 AC_MSG_NOTICE([defining prefixed macro JITTER_$2 as @S|@$1])]) 2538jitter_define_prefixed_macro([ac_cv_sizeof_void_p], [SIZEOF_VOID_P]) 2539jitter_define_prefixed_macro([ac_cv_sizeof_short], [SIZEOF_SHORT]) 2540jitter_define_prefixed_macro([ac_cv_sizeof_int], [SIZEOF_INT]) 2541jitter_define_prefixed_macro([ac_cv_sizeof_long], [SIZEOF_LONG]) 2542jitter_define_prefixed_macro([ac_cv_sizeof_long_long], [SIZEOF_LONG_LONG]) 2543jitter_define_prefixed_macro([ac_cv_sizeof_float], [SIZEOF_FLOAT]) 2544jitter_define_prefixed_macro([ac_cv_sizeof_double], [SIZEOF_DOUBLE]) 2545jitter_define_prefixed_macro([ac_cv_sizeof_long_double], [SIZEOF_LONG_DOUBLE]) 2546 2547jitter_define_prefixed_macro([ac_cv_alignof_void_p], [ALIGNOF_VOID_P]) 2548jitter_define_prefixed_macro([ac_cv_alignof_void_p_p], [ALIGNOF_VOID_P_P]) 2549jitter_define_prefixed_macro([ac_cv_alignof_short], [ALIGNOF_SHORT]) 2550jitter_define_prefixed_macro([ac_cv_alignof_int], [ALIGNOF_INT]) 2551jitter_define_prefixed_macro([ac_cv_alignof_long], [ALIGNOF_LONG]) 2552jitter_define_prefixed_macro([ac_cv_alignof_long_long], [ALIGNOF_LONG_LONG]) 2553jitter_define_prefixed_macro([ac_cv_alignof_float], [ALIGNOF_FLOAT]) 2554jitter_define_prefixed_macro([ac_cv_alignof_double], [ALIGNOF_DOUBLE]) 2555jitter_define_prefixed_macro([ac_cv_alignof_long_double], [ALIGNOF_LONG_DOUBLE]) 2556 2557 2558# Define prefixed alternatives for macros expanding to string literals in C, 2559# or actually for any shell variable meant to be used in this way. 2560# 2561# This is like jitter_define_prefixed_macro, but defines CPP macros to have 2562# the shell variable value *within double quotes* as their value. 2563# Arguments: 2564# * shell variable; 2565# * unprefixed feature macro name. 2566m4_define([jitter_define_prefixed_macro_string], 2567 [AC_DEFINE([JITTER_$2], 2568 ["@S|@$1"], 2569 [The value of the shell variable $1 as found by the 2570 configure script, with a JITTER_ prefix suitable for 2571 an installed header.]) 2572 AC_MSG_NOTICE([defining prefixed macro JITTER_$2 as "@S|@$1"])]) 2573jitter_define_prefixed_macro_string([PACKAGE_NAME], [PACKAGE_NAME]) 2574jitter_define_prefixed_macro_string([PACKAGE_VERSION], [PACKAGE_VERSION]) 2575jitter_define_prefixed_macro_string([PACKAGE_BUGREPORT], [PACKAGE_BUGREPORT]) 2576 2577# Define prefixed versions of conditionally-defined feature macros. 2578# Arguments: 2579# * shell variable; 2580# * shell value for yes; 2581# * unprefixed feature macro name. 2582m4_define([jitter_define_prefixed_feature_macro], 2583 [if test "x@S|@$1" = 'x$2'; then 2584 AC_DEFINE([JITTER_$3], 2585 [1], 2586 [Same as $3 with a JITTER_ prefix suitable for an 2587 installed header.]) 2588 AC_MSG_NOTICE([defining prefixed feature macro JITTER_$3]) 2589 else 2590 AC_MSG_NOTICE([not defining prefixed feature macro JITTER_$3]) 2591 fi]) 2592jitter_define_prefixed_feature_macro([ac_cv_c_bigendian], [yes], 2593 [WORDS_BIGENDIAN]) 2594jitter_define_prefixed_feature_macro([ac_cv_type_long_long_int], [yes], 2595 [HAVE_LONG_LONG_INT]) 2596jitter_define_prefixed_feature_macro([ac_cv_type_unsigned_long_long_int], [yes], 2597 [HAVE_UNSIGNED_LONG_LONG_INT]) 2598jitter_define_prefixed_feature_macro([ac_cv_type_long_double], [yes], 2599 [HAVE_LONG_DOUBLE]) 2600jitter_define_prefixed_feature_macro([ac_cv_func_alarm], [yes], [HAVE_ALARM]) 2601jitter_define_prefixed_feature_macro([ac_cv_func_aligned_alloc], [yes], 2602 [HAVE_ALIGNED_ALLOC]) 2603jitter_define_prefixed_feature_macro([ac_cv_func_posix_memalign], [yes], 2604 [HAVE_POSIX_MEMALIGN]) 2605jitter_define_prefixed_feature_macro([gl_have_mmap_anonymous], [yes], 2606 [HAVE_MMAP_ANONYMOUS]) 2607jitter_define_prefixed_feature_macro([ac_cv_func_mprotect], [yes], 2608 [HAVE_MPROTECT]) 2609jitter_define_prefixed_feature_macro([ac_cv_func_setrlimit], [yes], 2610 [HAVE_SETRLIMIT]) 2611jitter_define_prefixed_feature_macro([ac_cv_func_flockfile], [yes], 2612 [HAVE_FLOCKFILE]) 2613jitter_define_prefixed_feature_macro([ac_cv_func_popen], [yes], 2614 [HAVE_POPEN]) 2615jitter_define_prefixed_feature_macro([ac_cv_func_sigaction], [yes], 2616 [HAVE_SIGACTION]) 2617jitter_define_prefixed_feature_macro([ac_cv_func_sysconf], [yes], 2618 [HAVE_SYSCONF]) 2619jitter_define_prefixed_feature_macro([ac_cv_func_getpagesize], [yes], 2620 [HAVE_GETPAGESIZE]) 2621jitter_define_prefixed_feature_macro([ac_cv_func_clock_gettime], [yes], 2622 [HAVE_CLOCK_GETTIME]) 2623jitter_define_prefixed_feature_macro([ac_cv_func_setitimer], [yes], 2624 [HAVE_SETITIMER]) 2625jitter_define_prefixed_feature_macro([ac_cv_have_decl__SC_PAGESIZE], [yes], 2626 [HAVE__SC_PAGESIZE]) 2627jitter_define_prefixed_feature_macro([ac_cv_have_decl__SC_PHYS_PAGES], [yes], 2628 [HAVE__SC_PHYS_PAGES]) 2629jitter_define_prefixed_feature_macro([ac_cv_have_decl__SC_AVPHYS_PAGES], [yes], 2630 [HAVE__SC_AVPHYS_PAGES]) 2631jitter_define_prefixed_feature_macro([ac_cv_have_decl__SC_NPROCESSORS_CONF], [yes], 2632 [HAVE__SC_NPROCESSORS_CONF]) 2633jitter_define_prefixed_feature_macro([ac_cv_have_decl__SC_NPROCESSORS_ONLN], [yes], 2634 [HAVE__SC_NPROCESSORS_ONLN]) 2635jitter_define_prefixed_feature_macro([ac_cv_have_decl__SC_LEVEL1_ICACHE_SIZE], [yes], 2636 [HAVE__SC_LEVEL1_ICACHE_SIZE]) 2637jitter_define_prefixed_feature_macro([ac_cv_have_decl__SC_LEVEL1_DCACHE_SIZE], [yes], 2638 [HAVE__SC_LEVEL1_DCACHE_SIZE]) 2639jitter_define_prefixed_feature_macro([ac_cv_have_decl__SC_LEVEL2_CACHE_SIZE], [yes], 2640 [HAVE__SC_LEVEL2_CACHE_SIZE]) 2641jitter_define_prefixed_feature_macro([ac_cv_have_decl__SC_LEVEL3_CACHE_SIZE], [yes], 2642 [HAVE__SC_LEVEL3_CACHE_SIZE]) 2643jitter_define_prefixed_feature_macro([ac_cv_have_decl__SC_LEVEL4_CACHE_SIZE], [yes], 2644 [HAVE__SC_LEVEL4_CACHE_SIZE]) 2645 2646 2647# Output. 2648################################################################ 2649 2650AC_CONFIG_FILES([Makefile]) 2651AC_CONFIG_FILES([gnulib-local/Makefile]) 2652 2653AC_OUTPUT 2654