]> git.draconx.ca Git - cdecl99.git/blob - configure.ac
Port to use getline.h from dxcommon.
[cdecl99.git] / configure.ac
1 AC_COPYRIGHT([Copyright (C) 2011-2013, 2020-2024 Nick Bowler
2 License GPLv3+: GNU General Public License version 3 or any later version.
3 This is free software: you are free to change and redistribute it.
4 There is NO WARRANTY, to the extent permitted by law.])
5
6 DX_PATCH_GNULIB
7
8 AC_PREREQ([2.68])
9 AC_INIT([cdecl99], [1.3a], [nbowler@draconx.ca])
10 AC_CONFIG_HEADERS([config.h])
11
12 AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign subdir-objects])
13 AM_SILENT_RULES([yes])
14 DX_AUTOMAKE_COMPAT
15
16 AC_ARG_WITH([readline],
17   [AS_HELP_STRING([--with-readline],
18     [use GNU readline for line-editing functionality (default: auto)])],
19   [], [with_readline=auto])
20 AS_CASE([$with_readline],
21   [no], [gl_cv_lib_readline=no],
22   [yes|auto], [:],
23   [*], [AC_MSG_ERROR([invalid option --with-readline=$with_readline])])
24
25 AC_PROG_CC_C99
26 AM_PROG_CC_C_O
27 gl_EARLY
28
29 AC_HEADER_ASSERT
30 AC_TYPE_UNSIGNED_LONG_LONG_INT
31 AC_CHECK_TYPES([unsigned __int64], [], [],
32   [unsigned __int64 foo = -1; /* avoid false positive result on VAX C */])
33 AC_C_FLEXIBLE_ARRAY_MEMBER
34 AC_C_INLINE
35 DX_C_FOR_DECLARATIONS
36 DX_C_ALIGNAS
37 AM_PROG_AR
38
39 LT_INIT
40 gl_INIT
41
42 # As the mbrtowc replacement module is not used by the library, there is
43 # no need for multithreaded mbrtowc (all programs are single threaded).
44 AC_DEFINE([GNULIB_MBRTOWC_SINGLE_THREAD], [1], [Define to 1.])
45
46 # As the wcwidth replacement module is not used by the library, there is
47 # no need to support varying locales (programs set locale once at startup).
48 AC_DEFINE([GNULIB_WCHAR_SINGLE_LOCALE], [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 AM_CONDITIONAL([USE_NLS], [test x"$USE_NLS" = x"yes"])
79
80 DX_PROG_FLEX([], [have_flex=yes], [have_flex=no])
81 AM_CONDITIONAL([HAVE_FLEX], [test x"$have_flex" = x"yes"])
82
83 DX_PROG_BISON([], [have_bison=yes], [have_bison=no])
84 AM_CONDITIONAL([HAVE_BISON], [test x"$have_bison" = x"yes"])
85
86 DX_BISON_COMPAT
87 BISON_I18N
88
89 BISON_COMPAT=
90 AS_IF([test x"$dx_cv_bison_api_header_include" = x"yes"],
91   [BISON_COMPAT="'--define=api.header.include={\"\$(*F).h\"}'"])
92 AS_IF([test x"$dx_cv_bison_warn_no_deprecated" = x"yes"],
93   [AS_VAR_APPEND([BISON_COMPAT], ["${BISON_COMPAT:+ }-Wno-deprecated"])])
94 AC_SUBST([BISON_COMPAT])
95
96 AS_CASE([$dx_cv_bison_define_cmdline], [yes],
97 [AC_CACHE_CHECK([whether $BISON supports api.token.raw],
98   [dx_cv_bison_api_token_raw], [dx_cv_bison_api_token_raw=no
99 cat >conftest.y <<'EOF'
100 %token T_TEST
101 %{
102 int yylex(void) { return 0; }
103 void yyerror(const char *msg) { }
104 %}
105 %%
106 input:
107 EOF
108 AS_IF([$BISON --define api.token.raw conftest.y >&AS_MESSAGE_LOG_FD 2>&1],
109 [AC_COMPUTE_INT([testval], [T_TEST], [#include "conftest.tab.c"
110 ])
111 AS_IF([test "$testval" -lt 256], [dx_cv_bison_api_token_raw=yes])])])
112 AS_CASE([$dx_cv_bison_api_token_raw], [yes],
113   [AS_VAR_APPEND([BISON_COMPAT], [" --define api.token.raw"])])])
114
115 AH_TOP([#include <conf_pre.h>])
116 AH_BOTTOM([#include <conf_post.h>])
117
118 AC_CONFIG_TESTDIR([.], [t:.])
119 DX_PROG_AUTOTEST_AM
120
121 DX_CHECK_GETLINE
122
123 AC_CONFIG_FILES([Makefile])
124 AC_OUTPUT