1dnl configure.ac for GNU poke
2dnl
3dnl Please process this file with autoconf to get a 'configure'
4dnl script.
5
6dnl Copyright (C) 2019, 2020, 2021 Jose E. Marchesi
7
8dnl This program is free software: you can redistribute it and/or modify
9dnl it under the terms of the GNU General Public License as published by
10dnl the Free Software Foundation, either version 3 of the License, or
11dnl (at your option) any later version.
12dnl
13dnl This program is distributed in the hope that it will be useful,
14dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
15dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16dnl GNU General Public License for more details.
17dnl
18dnl You should have received a copy of the GNU General Public License
19dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
21AC_INIT([GNU poke], [1.0], [poke-devel@gnu.org], [poke],
22        [http://www.jemarch.net/poke.html])
23
24AC_CONFIG_AUX_DIR([build-aux])
25dnl In order to have a custom INSTALL file, we need Automake option 'foreign'.
26AM_INIT_AUTOMAKE([foreign])
27AC_CONFIG_HEADERS(poke/config.h)
28AC_CONFIG_MACRO_DIRS([m4])
29
30# Include the Autoconf macros from Jitter.
31m4_include([m4/jitter.m4])
32
33
34dnl Autobuild
35dnl AB_INIT
36
37AC_DEFINE([PACKAGE_BUGZILLA],["https://sourceware.org/bugzilla/describecomponents.cgi?product=poke"],[URL for entering bugs in the project's bugzilla])
38
39AC_PROG_CC
40gl_EARLY
41libpoke_EARLY
42gui_EARLY
43
44LT_INIT
45AC_PROG_CC_C99
46AM_PROG_CC_C_O
47
48AC_ARG_VAR([LEX], [The flex implementation to use.])
49if test -n "$LEX"; then
50  AC_MSG_CHECKING([for flex])
51  AC_MSG_RESULT([$LEX])
52else
53  AC_PATH_PROG([LEX], [flex], [:])
54fi
55
56gl_PROG_BISON([POKE_BISON],[3.6])
57
58dnl System
59AC_CANONICAL_HOST
60canonical=$host
61
62gl_INIT
63libpoke_INIT
64gui_INIT
65
66# Try to find a libtextstyle with hyperlinks support.
67gl_LIBTEXTSTYLE_OPTIONAL([0.20.5])
68
69# GNU help2man creates man pages from --help output; in many cases, this
70# is sufficient, and obviates the need to maintain man pages separately.
71# However, this means invoking executables, which we generally cannot do
72# when cross-compiling, so we test to avoid that (the variable
73# "cross_compiling" is set by AC_PROG_CC).
74if test $cross_compiling = no; then
75  AM_MISSING_PROG(HELP2MAN, help2man)
76else
77  HELP2MAN=:
78fi
79
80dnl i18n with gettext
81AM_GNU_GETTEXT_VERSION([0.19.8])
82AM_GNU_GETTEXT([external])
83
84dnl RAS requires a version of awk that supports gensub().  However,
85dnl since we are including the RAS-generated .pkc files in the
86dnl tarball, this should not be a hard dependency here: people
87dnl building poke from released tarballs are not required to have any
88dnl particular version of awk installed.  We therefore set RAS_AWK
89dnl here, using the value ':' for when no suitable awk is found.  Then
90dnl in the `.pkc : .pks' rule in Makefile.am an error message is
91dnl emitted in case no proper AWK is present.
92
93AX_CHECK_AWK_GENSUB([RAS_AWK=$AWK], [RAS_AWK=:])
94AC_SUBST([RAS_AWK])
95
96dnl The Boehm-Weiser garbage collector
97
98PKG_PROG_PKG_CONFIG
99PKG_CHECK_MODULES(BDW_GC,[bdw-gc],[have_gc=yes],[have_gc=no])
100
101dnl The JSON-C library for the machine-interface
102
103AC_ARG_ENABLE([mi],
104              AS_HELP_STRING([--enable-mi],
105                             [Enable the poke Machine-Interface (default is YES)]),
106              [mi_enabled=$enableval], [mi_enabled=yes])
107
108if test "x$mi_enabled" = "xyes"; then
109  PKG_CHECK_MODULES(JSON_C,[json-c],[],[mi_enabled=no])
110fi
111
112AM_CONDITIONAL([POKE_MI], [test "x$mi_enabled" = "xyes"])
113if test "x$mi_enabled" = "xyes"; then
114  AC_DEFINE([POKE_MI], 1,
115            [Defined if building poke with the machine-interface enabled])
116fi
117
118dnl Jitter
119
120AC_JITTER_SUBPACKAGE([jitter])
121
122dnl Profiling in the PVM
123
124AC_ARG_ENABLE([pvm-profiling],
125              AS_HELP_STRING([--enable-pvm-profiling],
126                             [Enable profiling in the PVM (default is NO)]),
127              [profiling_enabled=$enableval], [profiling_enabled=no])
128
129if test "x$profiling_enabled" = "xyes"; then
130  AC_DEFINE([JITTER_PROFILE_COUNT], [1], [use count-based profiling in the PVM])
131  AC_DEFINE([JITTER_PROFILE_SAMPLE], [1], [use sample-based profiling in the PVM])
132fi
133
134dnl libnbd for nbd:// io spaces (optional). Testing it also requires
135dnl nbdkit
136
137AC_ARG_ENABLE([libnbd],
138              AS_HELP_STRING([--enable-libnbd],
139                             [Enable building with NBD support (default is YES)]),
140              [libnbd_enabled=$enableval], [libnbd_enabled=yes])
141if test "x$libnbd_enabled" = "xyes"; then
142  PKG_CHECK_MODULES([LIBNBD], [libnbd], [
143    AC_SUBST([LIBNBD_CFLAGS])
144    AC_SUBST([LIBNBD_LIBS])
145    AC_DEFINE([HAVE_LIBNBD], [1], [libnbd found at compile time])
146    AC_PATH_PROGS([NBDKIT], [nbdkit], [no], [$PATH:/usr/local/sbin:/usr/sbin])
147  ], [libnbd_enabled=no NBDKIT=no])
148fi
149AM_CONDITIONAL([NBD], [test "x$libnbd_enabled" = "xyes"])
150
151dnl Used in Makefile.am.  See the note there.
152WITH_JITTER=$with_jitter
153AC_SUBST([WITH_JITTER])
154
155dnl We need to determine the endianness of the host system.  The
156dnl following macro is also supposed to work when cross-compiling.
157
158AC_C_BIGENDIAN
159
160dnl The following M4 macro from gnulib sets HOST_CPU_C_ABI_32BIT to
161dnl 'yes' if the C language ABI is a 32-bit one, to 'no' if it is
162dnl 64-bit, or to 'unknown'.
163dnl
164dnl We set POKE_HOST_32BIT accordingly, and warn if the 32bitness of
165dnl the host cannot be determined.
166
167gl_HOST_CPU_C_ABI_32BIT
168case "$HOST_CPU_C_ABI_32BIT" in
169  yes)
170    AC_DEFINE([POKE_HOST_32BIT],[1],[whether the host C ABI is 32-bit]);;
171  unknown)
172    AC_MSG_WARN([unable to determine whether the host C ABI is 32-bit]);;
173  *) ;;
174esac
175
176dnl Use libtextstyle if available.  Otherwise, use the dummy header
177dnl file provided by gnulib's libtextstyle-optional module.
178
179gl_LIBTEXTSTYLE_OPTIONAL
180AX_LIBTEXTSTYLE_HYPERLINK
181
182if test $HAVE_LIBTEXTSTYLE = yes; then
183    AC_CHECK_LIB([textstyle], [term_styled_ostream_get_destination], [
184      AC_DEFINE([HAVE_TEXTSTYLE_ACCESSORS_SUPPORT], 1,
185                [Defined if libtextstyle has support for terminal hyperlinks])
186    ])
187fi
188
189dnl The hyperlinks server is optional.  It is enabled by default if
190dnl there is a libtextstyle with hyperlinks support available.
191
192AC_ARG_ENABLE([hserver],
193              AS_HELP_STRING([--enable-hserver],
194                             [Enable the terminal hyperlinks server (default is YES)]),
195              [hserver_enabled=$enableval], [hserver_enabled=$has_hyper_support])
196
197if test "x$has_hyper_support" = "xno"; then
198  hserver_enabled=no
199fi
200
201AM_CONDITIONAL([HSERVER], [test "x$hserver_enabled" = "xyes"])
202if test "x$hserver_enabled" = "xyes"; then
203  AC_DEFINE([HAVE_HSERVER], 1,
204            [Defined if the hyperlinks server is available])
205fi
206
207dnl The GUI is optional, and depends on the availability of Tcl and
208dnl Tk.
209
210POKE_TCLTK
211
212AC_ARG_ENABLE([gui],
213              AS_HELP_STRING([--enable-gui],
214                             [Enable the GUI (default is YES)]),
215              [gui_enabled=$enableval], [gui_enabled=$has_tcltk])
216
217AM_CONDITIONAL([GUI], [test "x$gui_enabled" = "xyes"])
218
219dnl The test framework is optional.
220AC_CHECK_HEADERS([dejagnu.h])
221AM_CONDITIONAL([HAVE_DEJAGNU], [test "$ac_cv_header_dejagnu_h" = yes])
222
223dnl Generate output files
224AC_CONFIG_FILES(Makefile
225                gl/Makefile
226                gl-libpoke/Makefile
227                gl-gui/Makefile
228                libpoke/Makefile
229                poke/Makefile
230                gui/Makefile
231                utils/Makefile
232                pickles/Makefile
233                maps/Makefile
234                doc/Makefile
235                man/Makefile
236                po/Makefile.in
237                etc/Makefile
238                testsuite/Makefile
239                testsuite/poke.libpoke/Makefile
240                testsuite/poke.mi-json/Makefile)
241AC_CONFIG_FILES([run],
242                [chmod +x,-w run])
243AC_OUTPUT
244
245dnl Report warnings
246
247if test "x$HAVE_LIBTEXTSTYLE" = "xno"; then
248   AC_MSG_WARN([libtextstyle was not found in the system. Poke's output won't be styled.])
249fi
250
251if test "x$hserver_enabled" = "xno"; then
252   AC_MSG_WARN([building poke without terminal hyperlinks server support.
253     Install a hyperlinks-capable libtextstyle and use --enable-hserver to activate it.])
254fi
255
256if test "x$libnbd_enabled" != "xyes"; then
257   AC_MSG_WARN([building poke without NBD io space support.
258     Install libnbd to use it.])
259fi
260
261if test "x$mi_enabled" = "xno"; then
262   AC_MSG_WARN([building poke without the machine interface support.
263     Install libjson-c and use --enable-mi to activate it.])
264fi
265
266if test "x$gui_enabled" = "xno"; then
267   AC_MSG_WARN([building poke without GUI support.
268     Install tcl-dev and tk-dev and use --enable-gui to activate it.])
269fi
270
271dnl Report errors
272
273if test "x$have_gc" = "xno"; then
274   AC_MSG_ERROR([can't find the Boehm GC library.  Please install it.])
275fi
276
277if test "x$gl_cv_lib_readline" = "xno"; then
278   AC_MSG_ERROR([can't find an usable libreadline.  Please install one.])
279fi
280
281dnl End of configure.ac
282