3 dnl Configuration script for `finally'
5 dnl (c) 2023 Mark Wooding
8 dnl----- Licensing notice ---------------------------------------------------
10 dnl This file is part of the `Finally' package.
12 dnl Finally is free software: you can redistribute it and/or modify it
13 dnl under the terms of the GNU Library General Public License as published
14 dnl by the Free Software Foundation; either version 2 of the License, or
15 dnl (at your option) any later version.
17 dnl Finally is distributed in the hope that it will be useful, but WITHOUT
18 dnl ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 dnl FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20 dnl License for more details.
22 dnl You should have received a copy of the GNU Library General Public
23 dnl License along with Finally. If not, write to the Free Software
24 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
27 dnl--------------------------------------------------------------------------
30 AC_INIT([finally], [0.9], [mdw@distorted.org.uk])
31 AC_CONFIG_SRCDIR([finally.h])
32 AC_CONFIG_AUX_DIR([config])
33 AC_CONFIG_MACRO_DIR([m4])
34 AM_INIT_AUTOMAKE([foreign])
35 AC_REQUIRE_AUX_FILE([tap-driver.sh])
36 AM_SILENT_RULES([yes])
38 dnl--------------------------------------------------------------------------
39 dnl C programming environment.
47 AM_CFLAGS="$AM_CFLAGS -std=c89 -pedantic -Wall -Wextra -Werror"
51 dnl--------------------------------------------------------------------------
52 dnl C++ programming environment.
59 AM_CXXFLAGS="$AM_CXXFLAGS -std=c++11 -pedantic -Wall -Wextra -Werror"
63 AC_DEFUN([FINALLY_CXX14_PROGRAM], [AC_LANG_PROGRAM([], [
64 #if !defined(__cplusplus) || __cplusplus < 201103
69 AC_CACHE_CHECK([whether $CXX works at all], [finally_cv_cxx_works_p], [
71 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
72 [finally_cv_cxx_works_p=yes],
73 [finally_cv_cxx_works_p=no])
76 case $finally_cv_cxx_works_p in
78 AC_CACHE_CHECK([whether $CC accepts \`-fexceptions'],
79 [finally_cv_gcc_fexceptions_p], [
81 finally_test_original_CFLAGS=$CFLAGS
82 CFLAGS="$CFLAGS -fexceptions"
83 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
84 [finally_cv_gcc_fexceptions_p=yes],
85 [finally_cv_gcc_fexceptions_p=no])
86 CFLAGS=$finally_test_original_CFLAGS
90 finally_cv_gcc_fexceptions_p=no
94 case $finally_cv_cxx_works_p in
96 AC_CACHE_CHECK([whether $CXX supports C++11], [finally_cv_cxx14_p], [
98 AC_COMPILE_IFELSE([FINALLY_CXX14_PROGRAM],
99 [finally_cv_cxx14_p=yes],
100 [finally_cv_cxx14_p=no])
104 finally_cv_cxx14_p=no
109 dnl--------------------------------------------------------------------------
112 AC_CHECK_PROGS([autom4te])
115 dnl--------------------------------------------------------------------------
116 dnl Test configuration.
118 finally_test_original_CFLAGS=$CFLAGS
119 CFLAGS="$CFLAGS $AM_CFLAGS"
120 case $finally_cv_gcc_fexceptions_p in
121 yes) CFLAGS="$CFLAGS -fexceptions" ;;
124 CFLAGS=$finally_test_original_CFLAGS
125 AM_CFLAGS="$AM_CFLAGS $FINALLY_CFLAGS"
126 AM_CONDITIONAL([C], [test $finally_flavour != NIL])
127 AM_CONDITIONAL([CXX], [test $finally_cv_cxx_works_p = yes])
128 AM_CONDITIONAL([CXX14], [test $finally_cv_cxx14_p = yes])
130 case $finally_flavour,$finally_cv_cxx14_p in
132 AC_MSG_ERROR([no suitable C or C++ compiler found: not going to space today])
136 case $finally_flavour,$finally_cv_gcc_fexceptions_p,$finally_cv_cxx_works_p in
137 NIL,*,no) finally_fexceptions_p=no ;;
138 *,yes,*) AM_CFLAGS="$AM_CFLAGS -fexceptions"; finally_fexceptions_p=yes ;;
139 *,yes) finally_fexceptions_p=yes ;;
141 case $finally_fexceptions_p in
142 yes) AC_DEFINE([HAVE_FEXCEPTIONS], [1]) ;;
144 AM_CONDITIONAL([FEXCEPTIONS], [test $finally_fexceptions_p = yes])
146 dnl--------------------------------------------------------------------------
149 AC_CONFIG_FILES([Makefile])
152 dnl----- That's all, folks --------------------------------------------------