]> git.draconx.ca Git - cdecl99.git/blob - configure.ac
Avoid the use of for loop declarations.
[cdecl99.git] / configure.ac
1 dnl Copyright © 2011-2013, 2020-2023 Nick Bowler
2 dnl
3 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
4 dnl This is free software: you are free to do what the fuck you want to.
5 dnl There is NO WARRANTY, to the extent permitted by law.
6
7 AC_PREREQ([2.68])
8 AC_INIT([cdecl99], [1.2a], [nbowler@draconx.ca])
9 AC_CONFIG_HEADERS([config.h])
10
11 AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign subdir-objects dist-xz])
12 AM_SILENT_RULES([yes])
13 DX_AUTOMAKE_COMPAT
14
15 AC_ARG_WITH([readline],
16   [AS_HELP_STRING([--with-readline],
17     [use GNU readline for line-editing functionality (default: auto)])],
18   [], [with_readline=auto])
19 AS_CASE([$with_readline],
20   [no], [gl_cv_lib_readline=no],
21   [yes|auto], [:],
22   [*], [AC_MSG_ERROR([invalid option --with-readline=$with_readline])])
23
24 AC_PROG_CC_C99
25 AM_PROG_CC_C_O
26 gl_EARLY
27
28 AC_HEADER_ASSERT
29 AC_C_FLEXIBLE_ARRAY_MEMBER
30 AC_C_INLINE
31 DX_C_FOR_DECLARATIONS
32
33 LT_INIT
34 gl_INIT
35
36 # Work around quoting bug in Gnulib threadlib.m4 which prevents
37 # correct detection on e.g., Solaris 8.  These platforms require
38 # PTHREAD_IN_USE_DETECTION_HARD to be set otherwise cdecl99 will
39 # crash when reporting an error as initialization is not done.
40 #
41 # If this gets fixed in Gnulib, we can remove this.
42 AS_CASE([$host_os],
43   [[solaris2.[1-9] | solaris2.[1-9].*]],
44     [AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD])])
45
46 # As the mbrtowc replacement module is not used by the library, there is
47 # no need for multithreaded mbrtowc (all programs are single threaded).
48 AC_DEFINE([GNULIB_MBRTOWC_SINGLE_THREAD], [1], [Define to 1.])
49
50 AS_IF([test x"$gl_cv_lib_readline" = x"no"],
51   [AS_IF([test x"$with_readline" = x"yes"],
52     [AC_MSG_FAILURE([--with-readline requested but readline was not found])],
53     [dx_cv_rl_add_history=no])])
54 AC_CACHE_CHECK([if readline supports add_history], [dx_cv_rl_add_history], [dnl
55 dx_cv_rl_add_history=no
56 dx_save_libs=$LIBS
57 LIBS="$LIBS $LIBREADLINE"
58 AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
59 #include <stdio.h>
60 #if HAVE_READLINE_HISTORY_H
61 #  include <readline/history.h>
62 #endif
63 ], [dnl
64 (*add_history)("");
65 ])], [dx_cv_rl_add_history=yes], [dx_cv_rl_add_history=no])
66 LIBS=$dx_save_libs
67 ])
68
69 AS_IF([test x"$dx_cv_rl_add_history" = x"yes"],
70   [AC_DEFINE([HAVE_RL_ADD_HISTORY], [1],
71     [Define to 1 if readline supports add_history.])])
72
73 m4_include([lib/gnulib.mk])
74 DX_GLSYM_PREFIX([cdecl__gl_])
75 DX_GNULIB_SYMFILES([lib/symfiles], [s])
76 AM_CONDITIONAL([BUILD_STATIC], [test x"$enable_static" = x"yes"])
77
78 dnl We provide our own makefile rules for gettext.  Disable tracing of
79 dnl AM_GNU_GETTEXT to prevent autoreconf from running autopoint, and to
80 dnl prevent automake from growing gratuitous error conditions.
81 m4_traceoff([AM_GNU_GETTEXT])
82 AM_GNU_GETTEXT([external])
83 DX_LINGUAS
84
85 AM_CONDITIONAL([USE_NLS], [test x"$USE_NLS" = x"yes"])
86
87 DX_PROG_FLEX([], [have_flex=yes], [have_flex=no])
88 AM_CONDITIONAL([HAVE_FLEX], [test x"$have_flex" = x"yes"])
89
90 DX_PROG_BISON([], [have_bison=yes], [have_bison=no])
91 AM_CONDITIONAL([HAVE_BISON], [test x"$have_bison" = x"yes"])
92
93 DX_BISON_COMPAT
94 BISON_I18N
95
96 BISON_COMPAT=
97 AS_IF([test x"$dx_cv_bison_api_header_include" = x"yes"],
98   [BISON_COMPAT="'--define=api.header.include={\"\$(*F).h\"}'"])
99 AS_IF([test x"$dx_cv_bison_warn_no_deprecated" = x"yes"],
100   [AS_VAR_APPEND([BISON_COMPAT], ["${BISON_COMPAT:+ }-Wno-deprecated"])])
101 AC_SUBST([BISON_COMPAT])
102
103 AS_IF([test x"$dx_cv_bison_define_cmdline" != x"yes"],
104   [dx_cv_bison_api_token_raw=no])
105 AC_CACHE_CHECK([whether $BISON supports api.token.raw],
106   [dx_cv_bison_api_token_raw], [dx_cv_bison_api_token_raw=no
107 cat >conftest.y <<'EOF'
108 %token T_TEST
109 %{
110 int yylex(void) { return 0; }
111 void yyerror(const char *msg) { }
112 %}
113 %%
114 input:
115 EOF
116 AS_IF([$BISON --define api.token.raw conftest.y >&AS_MESSAGE_LOG_FD 2>&1],
117 [AC_COMPUTE_INT([testval], [T_TEST], [#include "conftest.tab.c"
118 ])
119 AS_IF([test "$testval" -lt 256], [dx_cv_bison_api_token_raw=yes])])])
120 AS_IF([test x"$dx_cv_bison_api_token_raw" = x"yes"],
121   [AS_VAR_APPEND([BISON_COMPAT], [" --define api.token.raw"])])
122
123 AH_TOP([#include <conf_pre.h>])
124 AH_BOTTOM([#include <conf_post.h>])
125
126 AC_CONFIG_TESTDIR([.], [t:.])
127 DX_PROG_AUTOTEST
128 AM_CONDITIONAL([HAVE_AUTOTEST], [test x"$dx_cv_autotest_works" = x"yes"])
129 AC_CHECK_FUNCS_ONCE([strtoumax strtoull __strtoull])
130
131 AC_CONFIG_FILES([
132         Makefile
133 ])
134 AC_OUTPUT