Add half-hearted support for Clang, because its `blocks' are deficient.
[finally] / configure.ac
CommitLineData
d58b8198
MW
1dnl -*-autoconf-*-
2dnl
3dnl Configuration script for `finally'
4dnl
5dnl (c) 2023 Mark Wooding
6dnl
7
8dnl----- Licensing notice ---------------------------------------------------
9dnl
10dnl This file is part of the `Finally' package.
11dnl
12dnl Finally is free software: you can redistribute it and/or modify it
13dnl under the terms of the GNU Library General Public License as published
14dnl by the Free Software Foundation; either version 2 of the License, or
15dnl (at your option) any later version.
16dnl
17dnl Finally is distributed in the hope that it will be useful, but WITHOUT
18dnl ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19dnl FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20dnl License for more details.
21dnl
22dnl You should have received a copy of the GNU Library General Public
23dnl License along with Finally. If not, write to the Free Software
24dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
25dnl USA.
26
27dnl--------------------------------------------------------------------------
28dnl Initialization.
29
30AC_INIT([finally], [0.9], [mdw@distorted.org.uk])
31AC_CONFIG_SRCDIR([finally.h])
32AC_CONFIG_AUX_DIR([config])
33AC_CONFIG_MACRO_DIR([m4])
34AM_INIT_AUTOMAKE([foreign])
35AC_REQUIRE_AUX_FILE([tap-driver.sh])
36AM_SILENT_RULES([yes])
37
38dnl--------------------------------------------------------------------------
39dnl C programming environment.
40
41AC_PROG_CC
42AM_PROG_CC_C_O
43AC_SUBST(AM_CFLAGS)
44
45case $GCC in
46 yes)
47 AM_CFLAGS="$AM_CFLAGS -std=c89 -pedantic -Wall -Wextra -Werror"
48 ;;
49esac
50
51dnl--------------------------------------------------------------------------
52dnl C++ programming environment.
53
54AC_PROG_CXX
55AC_SUBST(AM_CXXFLAGS)
56
57case $GXX in
58 yes)
59 AM_CXXFLAGS="$AM_CXXFLAGS -std=c++11 -pedantic -Wall -Wextra -Werror"
60 ;;
61esac
62
63AC_DEFUN([FINALLY_CXX14_PROGRAM], [AC_LANG_PROGRAM([], [
64#if !defined(__cplusplus) || __cplusplus < 201103
65 choke me
66#endif
67])])
68
69AC_CACHE_CHECK([whether $CXX works at all], [finally_cv_cxx_works_p], [
70 AC_LANG_PUSH([C++])
71 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
72 [finally_cv_cxx_works_p=yes],
73 [finally_cv_cxx_works_p=no])
74 AC_LANG_POP([C++])])
75
76case $finally_cv_cxx_works_p in
77 yes)
78 AC_CACHE_CHECK([whether $CC accepts \`-fexceptions'],
79 [finally_cv_gcc_fexceptions_p], [
80 AC_LANG_PUSH([C])
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
87 AC_LANG_POP([C])])
88 ;;
89 no)
90 finally_cv_gcc_fexceptions_p=no
91 ;;
92esac
93
94case $finally_cv_cxx_works_p in
95 yes)
96 AC_CACHE_CHECK([whether $CXX supports C++11], [finally_cv_cxx14_p], [
97 AC_LANG_PUSH([C++])
98 AC_COMPILE_IFELSE([FINALLY_CXX14_PROGRAM],
99 [finally_cv_cxx14_p=yes],
100 [finally_cv_cxx14_p=no])
101 AC_LANG_POP([C++])])
102 ;;
103 *)
104 finally_cv_cxx14_p=no
105 CXX=\${CC}
106 ;;
107esac
108
109dnl--------------------------------------------------------------------------
110dnl Other tools.
111
112AC_CHECK_PROGS([autom4te])
113AC_PROG_RANLIB
114
115dnl--------------------------------------------------------------------------
116dnl Test configuration.
117
118finally_test_original_CFLAGS=$CFLAGS
119CFLAGS="$CFLAGS $AM_CFLAGS"
120case $finally_cv_gcc_fexceptions_p in
121 yes) CFLAGS="$CFLAGS -fexceptions" ;;
122esac
123FINALLY_CHECK
124CFLAGS=$finally_test_original_CFLAGS
125AM_CFLAGS="$AM_CFLAGS $FINALLY_CFLAGS"
126AM_CONDITIONAL([C], [test $finally_flavour != NIL])
127AM_CONDITIONAL([CXX], [test $finally_cv_cxx_works_p = yes])
128AM_CONDITIONAL([CXX14], [test $finally_cv_cxx14_p = yes])
129
130case $finally_flavour,$finally_cv_cxx14_p in
131 NIL,no)
132 AC_MSG_ERROR([no suitable C or C++ compiler found: not going to space today])
133 ;;
134esac
135
136case $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 ;;
140esac
141case $finally_fexceptions_p in
142 yes) AC_DEFINE([HAVE_FEXCEPTIONS], [1]) ;;
143esac
144AM_CONDITIONAL([FEXCEPTIONS], [test $finally_fexceptions_p = yes])
145
146dnl--------------------------------------------------------------------------
147dnl Output.
148
149AC_CONFIG_FILES([Makefile])
150AC_OUTPUT
151
152dnl----- That's all, folks --------------------------------------------------