]> git.draconx.ca Git - cdecl99.git/blob - configure.ac
Don't build locale/wcwidth junk if NLS is disabled.
[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 DX_PATCH_GNULIB
8
9 AC_PREREQ([2.68])
10 AC_INIT([cdecl99], [1.2a], [nbowler@draconx.ca])
11 AC_CONFIG_HEADERS([config.h])
12
13 AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign subdir-objects dist-xz])
14 AM_SILENT_RULES([yes])
15 DX_AUTOMAKE_COMPAT
16
17 AC_ARG_WITH([readline],
18   [AS_HELP_STRING([--with-readline],
19     [use GNU readline for line-editing functionality (default: auto)])],
20   [], [with_readline=auto])
21 AS_CASE([$with_readline],
22   [no], [gl_cv_lib_readline=no],
23   [yes|auto], [:],
24   [*], [AC_MSG_ERROR([invalid option --with-readline=$with_readline])])
25
26 AC_PROG_CC_C99
27 AM_PROG_CC_C_O
28 gl_EARLY
29
30 AC_HEADER_ASSERT
31 AC_C_FLEXIBLE_ARRAY_MEMBER
32 AC_C_INLINE
33 DX_C_FOR_DECLARATIONS
34
35 LT_INIT
36 gl_INIT
37
38 # As the mbrtowc replacement module is not used by the library, there is
39 # no need for multithreaded mbrtowc (all programs are single threaded).
40 AC_DEFINE([GNULIB_MBRTOWC_SINGLE_THREAD], [1], [Define to 1.])
41
42 AS_IF([test x"$gl_cv_lib_readline" = x"no"],
43   [AS_IF([test x"$with_readline" = x"yes"],
44     [AC_MSG_FAILURE([--with-readline requested but readline was not found])],
45     [dx_cv_rl_add_history=no])])
46 AC_CACHE_CHECK([if readline supports add_history], [dx_cv_rl_add_history], [dnl
47 dx_cv_rl_add_history=no
48 dx_save_libs=$LIBS
49 LIBS="$LIBS $LIBREADLINE"
50 AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
51 #include <stdio.h>
52 #if HAVE_READLINE_HISTORY_H
53 #  include <readline/history.h>
54 #endif
55 ], [dnl
56 (*add_history)("");
57 ])], [dx_cv_rl_add_history=yes], [dx_cv_rl_add_history=no])
58 LIBS=$dx_save_libs
59 ])
60
61 AS_IF([test x"$dx_cv_rl_add_history" = x"yes"],
62   [AC_DEFINE([HAVE_RL_ADD_HISTORY], [1],
63     [Define to 1 if readline supports add_history.])])
64
65 m4_include([lib/gnulib.mk])
66 DX_GLSYM_PREFIX([cdecl__gl_])
67 DX_GNULIB_SYMFILES([lib/symfiles], [s])
68 AM_CONDITIONAL([BUILD_STATIC], [test x"$enable_static" = x"yes"])
69
70 AM_CONDITIONAL([USE_NLS], [test x"$USE_NLS" = x"yes"])
71
72 DX_PROG_FLEX([], [have_flex=yes], [have_flex=no])
73 AM_CONDITIONAL([HAVE_FLEX], [test x"$have_flex" = x"yes"])
74
75 DX_PROG_BISON([], [have_bison=yes], [have_bison=no])
76 AM_CONDITIONAL([HAVE_BISON], [test x"$have_bison" = x"yes"])
77
78 DX_BISON_COMPAT
79 BISON_I18N
80
81 BISON_COMPAT=
82 AS_IF([test x"$dx_cv_bison_api_header_include" = x"yes"],
83   [BISON_COMPAT="'--define=api.header.include={\"\$(*F).h\"}'"])
84 AS_IF([test x"$dx_cv_bison_warn_no_deprecated" = x"yes"],
85   [AS_VAR_APPEND([BISON_COMPAT], ["${BISON_COMPAT:+ }-Wno-deprecated"])])
86 AC_SUBST([BISON_COMPAT])
87
88 AS_IF([test x"$dx_cv_bison_define_cmdline" != x"yes"],
89   [dx_cv_bison_api_token_raw=no])
90 AC_CACHE_CHECK([whether $BISON supports api.token.raw],
91   [dx_cv_bison_api_token_raw], [dx_cv_bison_api_token_raw=no
92 cat >conftest.y <<'EOF'
93 %token T_TEST
94 %{
95 int yylex(void) { return 0; }
96 void yyerror(const char *msg) { }
97 %}
98 %%
99 input:
100 EOF
101 AS_IF([$BISON --define api.token.raw conftest.y >&AS_MESSAGE_LOG_FD 2>&1],
102 [AC_COMPUTE_INT([testval], [T_TEST], [#include "conftest.tab.c"
103 ])
104 AS_IF([test "$testval" -lt 256], [dx_cv_bison_api_token_raw=yes])])])
105 AS_IF([test x"$dx_cv_bison_api_token_raw" = x"yes"],
106   [AS_VAR_APPEND([BISON_COMPAT], [" --define api.token.raw"])])
107
108 AH_TOP([#include <conf_pre.h>])
109 AH_BOTTOM([#include <conf_post.h>])
110
111 AC_CONFIG_TESTDIR([.], [t:.])
112 DX_PROG_AUTOTEST
113 AM_CONDITIONAL([HAVE_AUTOTEST], [test x"$dx_cv_autotest_works" = x"yes"])
114 AC_CHECK_FUNCS_ONCE([strtoumax strtoull __strtoull])
115
116 AC_CONFIG_FILES([
117         Makefile
118 ])
119 AC_OUTPUT