dnl Process with `autoconf` to get ./configure dnl dnl This file is part of Beastie dnl SPDX-FileCopyrightText: 2023 Norman Gray dnl SPDX-License-Identifier: BSD-2-Clause dnl The version number here is the _next_ version being targeted, dnl and MUST be major.minor.release (three numbers), dnl possibly followed by, eg, "-bN" dnl dnl When a distribution is made (make dist) on a _tagged_ revision, dnl in a checkout, we check the tag matches this version number. dnl In a distribution tarball based on a tag, the version is the tag dnl (and we warn if this doesn't match the version here). dnl dnl When a distribution is made from a non-tagged revision, dnl the version number is this version suffixed by "-snap.{revision}". dnl These various version number checks are orchestrated in version.sh dnl dnl The release date is generated from the date of the repository snapshot. AC_INIT([Beastie], [0.14.1], [gray@nxg.name], [beastie], [https://purl.org/nxg/dist/beastie]) dnl The REFVERSION is the git tag of the _previous_ release REFVERSION=0.14.0 AC_SUBST(REFVERSION) BEASTIE_COPYRIGHTYEARS=2023-26 AC_SUBST(BEASTIE_COPYRIGHTYEARS) BEASTIE_HOMEREPO=https://codeberg.org/nxg/beastie AC_SUBST(BEASTIE_HOMEREPO) AC_PREFIX_DEFAULT([/usr/local]) AC_CONFIG_HEADERS(config.h) AC_LANG(C) AC_PROG_CC([clang cc gcc]) dnl Slightly annoyingly, autoconf (since 2024?) has started adding dnl -std=gnu23 to the compiler flags at this point. This doesn't dnl break anything, but it feels untidy, since I do deliberately set dnl this in the Makefile, but seem unable to select this behaviour here. AC_PATH_PROG(FLEX, flex, NONE) AC_PATH_PROG(BISON, bison, NONE) if test $FLEX = NONE -o $BISON = NONE; then AC_MSG_ERROR([we require both flex and bison to be available]) fi dnl Check whether Bison is major version 2.x, and prepare to tweak the dnl source files if so. See the corresponding lines in the Makefile.in. AC_MSG_CHECKING([Bison major version]) bison_major_version=`$BISON --version | head -1` # It's v2 if the first digit in the --version output is '2'. if expr "$bison_major_version" : ['[^0-9]*2'] >/dev/null; then BISON="./bison2.sh $BISON" AC_MSG_RESULT(2.x) else AC_MSG_RESULT(3.x) fi AC_PATH_PROG(TAR, tar) dnl if --without-kpse is present, then suppress the test for dnl the kpsewhich command AC_ARG_WITH([kpse], [AS_HELP_STRING([--without-kpse], [use --without-kpse to suppress using kpselib])], [case "$withval" in no) check_kpse=no;; yes) check_kpse=kpsewhich;; *) check_kpse="$withval kpsewhich";; esac], [check_kpse=kpsewhich]) AS_IF([test "$check_kpse" = no], [AC_MSG_NOTICE([suppressing use of kpsewhich])], [AC_PATH_PROGS(KPSEWHICH, [$check_kpse], [""])]) icu_path= icu_ok=false AC_ARG_WITH([icu], [AS_HELP_STRING([--with-icu], [use --with-icu to give a path to the ICU library, if available, or --without-icu to suppress])], [if test -n "$withval"; then icu_path=$withval; fi]) AS_IF([test "$icu_path" = no], [AC_MSG_NOTICE([suppressing use of ICU])], [orig_CPPFLAGS="$CPPFLAGS" orig_LDFLAGS="$LDFLAGS" orig_LIBS="$LIBS" if test -n "$icu_path"; then CPPFLAGS="$CPPFLAGS -I$icu_path/include" LDFLAGS="$LDFLAGS -L$icu_path/lib" fi LIBS="$LIBS -licuio -licuuc -licui18n" AC_CHECK_HEADER([unicode/ustdio.h], [AC_DEFINE([HAVE_USTDIO_H], 1, [Define to 1 if you have ])]) AC_MSG_CHECKING([whether icuio is available]) dnl We can't just use AC_CHECK_LIB(icuio, [u_fopen]) here dnl since u_fopen is a macro, defined in ustdio.h, dnl which expands to a version-specific actual function. AC_LINK_IFELSE([AC_LANG_PROGRAM( [[#include ]], [UFILE* f = u_fopen("filename", "r", NULL, NULL);]) ], [AC_MSG_RESULT([yes]) icu_ok=:], [AC_MSG_RESULT([no])])]) if $icu_ok; then AC_DEFINE([HAVE_ICU], 1, [Define as 1 if we have the ICU libraries]) AC_SUBST([HAVE_ICU], [YES]) else CPPFLAGS="$orig_CPPFLAGS" LDFLAGS="$orig_LDFLAGS" LIBS="$orig_LIBS" AC_SUBST([HAVE_ICU], [NO]) fi AC_CHECK_HEADERS_ONCE([linux/limits.h alloca.h sys/utsname.h]) AC_SEARCH_LIBS([log], [m]) AC_SEARCH_LIBS([dlopen], [dl]) AC_CHECK_DECLS([optreset], [], [], [[#include ]]) dnl vasprintf is a GNU- and BSD-defined function which isn't in POSIX-2018. dnl It's part of stdio.h in macOS and FreeBSD, dnl but in RH, it's included in stdio.h only if _GNU_SOURCE is defined. dnl I'm not completely convinced this is the right action here dnl (it feels a bit blunt-instrument), but it seems to work. dnl dnl ...I'm now fairly sure this is _not_ the right way to deal with this, dnl and that suitable defines in source files are better. dnl But I keep changing my mind about this. dnl AC_CHECK_DECL([vasprintf], [], [CFLAGS="$CFLAGS -D_GNU_SOURCE"]) AC_MSG_CHECKING([how to format s7_int]) saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wall -Werror" have_s7int_printf=false for spec in '"%d"' '"%ld"' '"%lld"'; do AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #include "s7.h" #include void f(void) { s7_int i=0; printf($spec, i);}]])], have_s7int_printf=:, ST_SIZE_PRINTF=NO) if "$have_s7int_printf"; then AC_DEFINE_UNQUOTED(S7INT_PRINTF, $spec, [How do we format s7_int]) AC_MSG_RESULT([$spec]) break fi done if ! $have_s7int_printf; then AC_MSG_RESULT([don't know! set it to %zd and hope for the best]) AC_DEFINE(S7INT_PRINTF, "%zd", [How do we format s7_int]) fi dnl clang (versions > 11?) has the -Wno-unused-but-set-variable option dnl to suppress a warning about variables set but unused (from bison); dnl the gcc equivalent is -Wno-unused-variable. dnl There is a [[maybe_unused]] annotation which is defined in C23 (I think), dnl so injecting this into the Bison output may be an alternative approach. AC_PROG_CPP_WERROR dnl AC_MSG_CHECKING([whether the -Wno-unused-but-set-variable flag is available]) AC_MSG_CHECKING([how to suppress set-but-unused compiler warning]) found_flag=false NOUNUSEDCFLAG= for f in '' "-Wno-unused-but-set-variable" "-Wno-unused-variable"; do CFLAGS="$saved_CFLAGS -Wall -Werror $f" AC_COMPILE_IFELSE([AC_LANG_SOURCE([void f() { int i; i=1; }])], [found_flag=:; break]) done if $found_flag; then if test -z "$f"; then AC_MSG_RESULT([none required]) else AC_MSG_RESULT([$f]) fi NOUNUSEDCFLAG="$f" else AC_MSG_RESULT([not found -- no warning-suppression applied]) fi AC_SUBST(NOUNUSEDCFLAG) CFLAGS="$saved_CFLAGS" AC_ARG_ENABLE(s7debugging, AS_HELP_STRING([--enable-s7debugging], [enable s7 internal debugging support]), [S7DEBUGGING=""], [S7DEBUGGING="#"]) AC_SUBST(S7DEBUGGING) BUILD_PLATFORM=`uname -orm` AC_SUBST(BUILD_PLATFORM) AC_ARG_ENABLE(altgcov, AS_HELP_STRING([--enable-alt-gcov], [enable an alternative GCOV build process]), [GCOV1="#"; GCOV2=""], [GCOV1=""; GCOV2="#"]) AC_SUBST(GCOV1) AC_SUBST(GCOV2) dnl If we add files here, consider adding them to the CI artefacts dnl list, too. AC_CONFIG_FILES([Makefile test/Makefile doc/Makefile config.scm version.sh]) AC_OUTPUT