]> git.draconx.ca Git - cdecl99.git/blob - configure.ac
297469d558fa4e1e31f819ff25db73955417fcab
[cdecl99.git] / configure.ac
1 dnl Copyright © 2011-2013, 2020-2024 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])
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_TYPE_UNSIGNED_LONG_LONG_INT
32 AC_CHECK_TYPES([unsigned __int64], [], [],
33   [unsigned __int64 foo = -1; /* avoid false positive result on VAX C */])
34 AC_C_FLEXIBLE_ARRAY_MEMBER
35 AC_C_INLINE
36 DX_C_FOR_DECLARATIONS
37 DX_C_ALIGNAS
38 AM_PROG_AR
39
40 LT_INIT
41 gl_INIT
42
43 # As the mbrtowc replacement module is not used by the library, there is
44 # no need for multithreaded mbrtowc (all programs are single threaded).
45 AC_DEFINE([GNULIB_MBRTOWC_SINGLE_THREAD], [1], [Define to 1.])
46
47 # As the wcwidth replacement module is not used by the library, there is
48 # no need to support varying locales (programs set locale once at startup).
49 AC_DEFINE([GNULIB_WCHAR_SINGLE_LOCALE], [1], [Define to 1.])
50
51 AS_IF([test x"$gl_cv_lib_readline" = x"no"],
52   [AS_IF([test x"$with_readline" = x"yes"],
53     [AC_MSG_FAILURE([--with-readline requested but readline was not found])],
54     [dx_cv_rl_add_history=no])])
55 AC_CACHE_CHECK([if readline supports add_history], [dx_cv_rl_add_history], [dnl
56 dx_cv_rl_add_history=no
57 dx_save_libs=$LIBS
58 LIBS="$LIBS $LIBREADLINE"
59 AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
60 #include <stdio.h>
61 #if HAVE_READLINE_HISTORY_H
62 #  include <readline/history.h>
63 #endif
64 ], [dnl
65 (*add_history)("");
66 ])], [dx_cv_rl_add_history=yes], [dx_cv_rl_add_history=no])
67 LIBS=$dx_save_libs
68 ])
69
70 AS_IF([test x"$dx_cv_rl_add_history" = x"yes"],
71   [AC_DEFINE([HAVE_RL_ADD_HISTORY], [1],
72     [Define to 1 if readline supports add_history.])])
73
74 m4_include([lib/gnulib.mk])
75 DX_GLSYM_PREFIX([cdecl__gl_])
76 DX_GNULIB_SYMFILES([lib/symfiles], [s])
77 AM_CONDITIONAL([BUILD_STATIC], [test x"$enable_static" = x"yes"])
78
79 AM_CONDITIONAL([USE_NLS], [test x"$USE_NLS" = x"yes"])
80
81 DX_PROG_FLEX([], [have_flex=yes], [have_flex=no])
82 AM_CONDITIONAL([HAVE_FLEX], [test x"$have_flex" = x"yes"])
83
84 DX_PROG_BISON([], [have_bison=yes], [have_bison=no])
85 AM_CONDITIONAL([HAVE_BISON], [test x"$have_bison" = x"yes"])
86
87 DX_BISON_COMPAT
88 BISON_I18N
89
90 BISON_COMPAT=
91 AS_IF([test x"$dx_cv_bison_api_header_include" = x"yes"],
92   [BISON_COMPAT="'--define=api.header.include={\"\$(*F).h\"}'"])
93 AS_IF([test x"$dx_cv_bison_warn_no_deprecated" = x"yes"],
94   [AS_VAR_APPEND([BISON_COMPAT], ["${BISON_COMPAT:+ }-Wno-deprecated"])])
95 AC_SUBST([BISON_COMPAT])
96
97 AS_CASE([$dx_cv_bison_define_cmdline], [yes],
98 [AC_CACHE_CHECK([whether $BISON supports api.token.raw],
99   [dx_cv_bison_api_token_raw], [dx_cv_bison_api_token_raw=no
100 cat >conftest.y <<'EOF'
101 %token T_TEST
102 %{
103 int yylex(void) { return 0; }
104 void yyerror(const char *msg) { }
105 %}
106 %%
107 input:
108 EOF
109 AS_IF([$BISON --define api.token.raw conftest.y >&AS_MESSAGE_LOG_FD 2>&1],
110 [AC_COMPUTE_INT([testval], [T_TEST], [#include "conftest.tab.c"
111 ])
112 AS_IF([test "$testval" -lt 256], [dx_cv_bison_api_token_raw=yes])])])
113 AS_CASE([$dx_cv_bison_api_token_raw], [yes],
114   [AS_VAR_APPEND([BISON_COMPAT], [" --define api.token.raw"])])])
115
116 AH_TOP([#include <conf_pre.h>])
117 AH_BOTTOM([#include <conf_post.h>])
118
119 AC_CONFIG_TESTDIR([.], [t:.])
120 DX_PROG_AUTOTEST_AM
121
122 AC_CACHE_CHECK([for getline], [dx_cv_have_getline],
123   [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>
124 ], [ssize_t (*x)() = getline;
125 char *p = 0;
126 size_t n = 0;
127 return getline(&p, &n, stdin);
128 ])], [dx_cv_have_getline=yes], [dx_cv_have_getline=no])])
129 AS_CASE([$dx_cv_have_getline], [yes],
130   [AC_DEFINE([HAVE_GETLINE], [1],
131     [Define to 1 if the getline function is available.])])
132
133 AC_CONFIG_FILES([Makefile])
134 AC_OUTPUT