1 dnl Copyright (C) 2005, 2006, 2007, 2009, 2014, 2015, 2021 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
8 dnl Summarize all the missing prerequisites at the end of the run to
9 dnl increase user-friendliness.
10 AC_DEFUN([PSPP_REQUIRED_PREREQ],
11 [AC_MSG_WARN([You must install $1 before building PSPP.])
12 pspp_required_prereqs="$pspp_required_prereqs
14 AC_DEFUN([PSPP_OPTIONAL_PREREQ], [pspp_optional_prereqs="$pspp_optional_prereqs
16 AC_DEFUN([PSPP_CHECK_PREREQS],
18 if test "$pspp_optional_prereqs" != ""; then
19 AC_MSG_WARN([The following optional packages are not installed.
20 You may wish to install them to obtain additional functionality:$pspp_optional_prereqs])
22 if test "$pspp_required_prereqs" != ""; then
23 AC_MSG_ERROR([The following required packages are not installed.
24 You must install them before PSPP can be built:$pspp_required_prereqs])
29 dnl Check that a new enough version of Perl is available.
32 AC_PATH_PROG([PERL], perl, no)
34 if test "$PERL" != no && $PERL -e 'require 5.005_03;'; then :; else
35 PSPP_REQUIRED_PREREQ([Perl 5.005_03 (or later)])
38 # The PSPP autobuilder appends a build number to the PSPP version number,
39 # e.g. "0.7.2-build40". But Perl won't parse version numbers that contain
40 # anything other than digits and periods, so "-build" causes an error. So we
41 # define $(VERSION_FOR_PERL) that drops everything from the hyphen onward.
42 VERSION_FOR_PERL=`echo "$VERSION" | sed 's/-.*//'`
43 AC_SUBST([VERSION_FOR_PERL])
46 dnl Check that Python 3 is available.
47 AC_DEFUN([PSPP_PYTHON3],
48 [AC_ARG_VAR([PYTHON3], [Python 3 interpreter])
49 AC_CHECK_PROGS([PYTHON3], [python3 python], [none])
50 if test "$PYTHON3" != no && $PYTHON3 -c '
52 sys.exit(0 if sys.version_info >= (3,4) else 1)
54 PSPP_REQUIRED_PREREQ([Python 3.4 (or later)])
58 dnl PSPP_CHECK_CC_OPTION([OPTION], [ACTION-IF-ACCEPTED], [ACTION-IF-REJECTED])
59 dnl Check whether the given C compiler OPTION is accepted.
60 dnl If so, execute ACTION-IF-ACCEPTED, otherwise ACTION-IF-REJECTED.
61 AC_DEFUN([PSPP_CHECK_CC_OPTION],
63 m4_define([pspp_cv_name], [pspp_cv_[]m4_translit([$1], [-], [_])])dnl
64 AC_CACHE_CHECK([whether $CC accepts $1], [pspp_cv_name],
65 [pspp_save_CFLAGS="$CFLAGS"
67 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,)], [pspp_cv_name[]=yes], [pspp_cv_name[]=no])
68 CFLAGS="$pspp_save_CFLAGS"])
69 if test $pspp_cv_name = yes; then
70 m4_if([$2], [], [;], [$2])
72 m4_if([$3], [], [:], [$3])
76 # PSPP_ENABLE_OPTION comes from Open vSwitch:
77 # ----------------------------------------------------------------------
78 # Copyright (c) 2007-2017 Nicira, Inc.
80 # Licensed under the Apache License, Version 2.0 (the "License");
81 # you may not use this file except in compliance with the License.
82 # You may obtain a copy of the License at:
84 # http://www.apache.org/licenses/LICENSE-2.0
86 # Unless required by applicable law or agreed to in writing, software
87 # distributed under the License is distributed on an "AS IS" BASIS,
88 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
89 # See the License for the specific language governing permissions and
90 # limitations under the License.
91 dnl PSPP_ENABLE_OPTION([OPTION])
92 dnl Check whether the given C compiler OPTION is accepted.
93 dnl If so, add it to WARNING_FLAGS.
94 dnl Example: PSPP_ENABLE_OPTION([-Wdeclaration-after-statement])
95 AC_DEFUN([PSPP_ENABLE_OPTION],
96 [PSPP_CHECK_CC_OPTION([$1], [WARNING_FLAGS="$WARNING_FLAGS $1"])
97 AC_SUBST([WARNING_FLAGS])])
98 # ----------------------------------------------------------------------
100 dnl Check for readline and history libraries.
102 dnl Modified for PSPP, based on readline.m4 serial 3 from
103 dnl gnulib, which was written by Simon Josefsson, with help from Bruno
104 dnl Haible and Oskar Liljeblad.
106 AC_DEFUN([PSPP_READLINE],
108 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
109 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
110 AC_REQUIRE([AC_LIB_RPATH])
112 dnl Search for libreadline and define LIBREADLINE, LTLIBREADLINE and
113 dnl INCREADLINE accordingly.
114 AC_LIB_LINKFLAGS_BODY([readline])
115 AC_LIB_LINKFLAGS_BODY([history])
117 dnl Add $INCREADLINE to CPPFLAGS before performing the following checks,
118 dnl because if the user has installed libreadline and not disabled its use
119 dnl via --without-libreadline-prefix, he wants to use it. The AC_LINK_IFELSE
120 dnl will then succeed.
121 am_save_CPPFLAGS="$CPPFLAGS"
122 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCREADLINE $INCHISTORY])
124 AC_CACHE_CHECK(for readline, gl_cv_lib_readline, [
125 gl_cv_lib_readline=no
127 dnl On some systems, -lreadline doesn't link without an additional
128 dnl -lncurses or -ltermcap.
129 dnl Try -lncurses before -ltermcap, because libtermcap is unsecure
130 dnl by design and obsolete since 1994. Try -lcurses last, because
131 dnl libcurses is unusable on some old Unices.
132 for extra_lib in "" ncurses termcap curses; do
133 LIBS="$am_save_LIBS $LIBREADLINE $LIBHISTORY"
134 if test -n "$extra_lib"; then
135 LIBS="$LIBS -l$extra_lib"
137 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
138 #include <readline/readline.h>
139 #include <readline/history.h>]], [[readline((char*)0); add_history((char*)0);]])],[gl_cv_lib_readline=yes],[])
140 if test "$gl_cv_lib_readline" = yes; then
141 if test -n "$extra_lib"; then
142 LIBREADLINE="$LIBREADLINE $LIBHISTORY -l$extra_lib"
143 LTLIBREADLINE="$LTLIBREADLINE $LTLIBHISTORY -l$extra_lib"
151 if test "$gl_cv_lib_readline" = yes; then
152 AC_DEFINE([HAVE_READLINE], 1, [Define if you have the readline library.])
153 AC_MSG_CHECKING([how to link with libreadline])
154 AC_MSG_RESULT([$LIBREADLINE])
155 AC_SEARCH_LIBS([rl_echo_signal_char], [readline],
156 AC_DEFINE([HAVE_RL_ECHO_SIGNAL_CHAR], 1, [Define if the readline library provides rl_echo_signal_char.]),[],[$LIBREADLINE])
157 AC_SEARCH_LIBS([rl_outstream], [readline],
158 AC_DEFINE([HAVE_RL_OUTSTREAM], 1, [Define if the readline library provides rl_outstream.]),[],[$LIBREADLINE])
160 dnl If $LIBREADLINE didn't lead to a usable library, we don't
161 dnl need $INCREADLINE either.
162 CPPFLAGS="$am_save_CPPFLAGS"
167 PSPP_OPTIONAL_PREREQ([libreadline (which may itself require libncurses or libtermcap)])
169 AC_SUBST(LIBREADLINE)
170 AC_SUBST(LTLIBREADLINE)
173 dnl Check for LC_PAPER, _NL_PAPER_WIDTH, _NL_PAPER_HEIGHT.
174 AC_DEFUN([PSPP_LC_PAPER],
175 [AC_CACHE_CHECK(for LC_PAPER, pspp_cv_lc_paper, [
180 #include <langinfo.h>
182 [(void) LC_PAPER; (void) _NL_PAPER_WIDTH; (void) _NL_PAPER_HEIGHT])],
183 [pspp_cv_lc_paper=yes])
185 if test "$pspp_cv_lc_paper" = yes; then
186 AC_DEFINE([HAVE_LC_PAPER], 1, [Define if you have LC_PAPER.])
191 # PSPP_LINK2_IFELSE(SOURCE1, SOURCE2, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
192 # -------------------------------------------------------------
193 # Based on AC_LINK_IFELSE, but tries to link both SOURCE1 and SOURCE2
196 # Test that resulting file is executable; see the problem reported by mwoehlke
197 # in <http://lists.gnu.org/archive/html/bug-coreutils/2006-10/msg00048.html>.
198 # But skip the test when cross-compiling, to prevent problems like the one
199 # reported by Chris Johns in
200 # <http://lists.gnu.org/archive/html/autoconf/2007-03/msg00085.html>.
202 m4_define([PSPP_LINK2_IFELSE],
203 [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
204 mv conftest.$ac_ext conftest1.$ac_ext
205 m4_ifvaln([$2], [AC_LANG_CONFTEST([$2])])dnl
206 mv conftest.$ac_ext conftest2.$ac_ext
207 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext
208 pspp_link2='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest1.$ac_ext conftest2.$ac_ext $LIBS >&5'
209 AS_IF([_AC_DO_STDERR($pspp_link2) && {
210 test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" ||
211 test ! -s conftest.err
212 } && test -s conftest$ac_exeext && {
213 test "$cross_compiling" = yes ||
214 AS_TEST_X([conftest$ac_exeext])
217 [echo "$as_me: failed source file 1 of 2 was:" >&5
218 sed 's/^/| /' conftest1.$ac_ext >&5
219 echo "$as_me: failed source file 2 of 2 was:" >&5
220 sed 's/^/| /' conftest2.$ac_ext >&5
222 dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization)
223 dnl information created by the PGI compiler (conftest_ipa8_conftest.oo),
224 dnl as it would interfere with the next link command.
225 rm -rf conftest.dSYM conftest1.dSYM conftest2.dSYM
226 rm -f core conftest.err conftest1.err conftest2.err
227 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest*_ipa8_conftest*.oo
228 rm -f conftest$ac_exeext
229 rm -f m4_ifval([$1], [conftest1.$ac_ext]) m4_ifval([$2], [conftest1.$ac_ext])[]dnl
230 ])# PSPP_LINK2_IFELSE
232 # GSL uses "extern inline" without determining whether the compiler uses
233 # GCC inline rules or C99 inline rules. If it uses the latter then GSL
234 # will be broken without passing -fgnu89-inline to GCC.
235 AC_DEFUN([PSPP_GSL_NEEDS_FGNU89_INLINE],
236 [# GSL only uses "inline" at all if HAVE_INLINE is defined as a macro.
237 # In turn, gnulib's gl_INLINE is one macro that does that. We need to
238 # make sure that it has run by the time we run this test, otherwise we'll
239 # get a false result.
240 AC_REQUIRE([gl_INLINE])
241 PSPP_CHECK_CC_OPTION(
243 [AC_CACHE_CHECK([whether GSL needs -fgnu89-inline to link],
244 pspp_cv_gsl_needs_fgnu89_inline, [
246 [AC_LANG_PROGRAM([#include <gsl/gsl_math.h>
247 ], [GSL_MAX_INT(1,2);])],
248 [AC_LANG_SOURCE([#include <gsl/gsl_math.h>
250 [pspp_cv_gsl_needs_fgnu89_inline=no],
251 [pspp_cv_gsl_needs_fgnu89_inline=yes])])
252 if test "$pspp_cv_gsl_needs_fgnu89_inline" = "yes"; then
253 CFLAGS="$CFLAGS -fgnu89-inline"
257 AC_DEFUN([PSPP_CHECK_CLICKSEQUENCE],
258 [AC_REQUIRE([AM_INIT_AUTOMAKE]) # Defines MAKEINFO
259 AC_CACHE_CHECK([whether makeinfo supports @clicksequence],
260 [pspp_cv_have_clicksequence],
261 [cat > conftest.texi <<EOF
262 @setfilename conftest.info
263 @clicksequence{File @click{} Open}
265 echo "configure:__oline__: running $MAKEINFO conftest.texi >&AS_MESSAGE_LOG_FD" >&AS_MESSAGE_LOG_FD
266 eval "$MAKEINFO conftest.texi >&AS_MESSAGE_LOG_FD 2>&1"
268 echo "configure:__oline__: \$? = $retval" >&AS_MESSAGE_LOG_FD
269 if test $retval = 0; then
270 pspp_cv_have_clicksequence=yes
272 pspp_cv_have_clicksequence=no
274 rm -f conftest.texi conftest.info])
275 if test $pspp_cv_have_clicksequence = no; then
276 AC_MSG_ERROR([$MAKEINFO does not support @clicksequence.
277 Please install a newer or working version, or point the MAKEINFO variable
278 to one that is already installed.])
281 dnl Texinfo 4.13 generates broken DocBook XML. Probably other old
282 dnl versions do too, but that's the one that causes problems.
283 AC_DEFUN([PSPP_CHECK_MAKEINFO_DOCBOOK_XML],
284 [AC_REQUIRE([AM_INIT_AUTOMAKE]) # Defines MAKEINFO
286 [whether makeinfo generates broken DocBook XML],
287 [pspp_cv_broken_docbook_xml],
289 [$(eval "$MAKEINFO --version | head -1")],
290 [*texinfo*4.13*], [pspp_cv_broken_docbook_xml=yes],
291 [*texinfo*], [pspp_cv_broken_docbook_xml=no],
292 [*], [pspp_cv_broken_docbook_xml=yes])])
294 [BROKEN_DOCBOOK_XML], [test "$pspp_cv_broken_docbook_xml" = yes])])
296 # The following comes from Open vSwitch:
297 # ----------------------------------------------------------------------
298 # Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
300 # Licensed under the Apache License, Version 2.0 (the "License");
301 # you may not use this file except in compliance with the License.
302 # You may obtain a copy of the License at:
304 # http://www.apache.org/licenses/LICENSE-2.0
306 # Unless required by applicable law or agreed to in writing, software
307 # distributed under the License is distributed on an "AS IS" BASIS,
308 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
309 # See the License for the specific language governing permissions and
310 # limitations under the License.
312 dnl PSPP_ENABLE_WERROR
313 AC_DEFUN([PSPP_ENABLE_WERROR],
316 [AC_HELP_STRING([--enable-Werror], [Add -Werror to CFLAGS])],
317 [], [enable_Werror=no])
318 AC_CONFIG_COMMANDS_PRE(
319 [if test "X$enable_Werror" = Xyes; then
320 CFLAGS="$CFLAGS -Werror -Wno-error=deprecated-declarations"
321 # gnulib needs this, for now:
322 CFLAGS="$CFLAGS -Wno-error=attributes"
325 # The following comes from Open vSwitch:
326 # ----------------------------------------------------------------------
327 # Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
329 # Licensed under the Apache License, Version 2.0 (the "License");
330 # you may not use this file except in compliance with the License.
331 # You may obtain a copy of the License at:
333 # http://www.apache.org/licenses/LICENSE-2.0
335 # Unless required by applicable law or agreed to in writing, software
336 # distributed under the License is distributed on an "AS IS" BASIS,
337 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
338 # See the License for the specific language governing permissions and
339 # limitations under the License.
342 AC_DEFUN([PSPP_CHECK_DOT],
346 [dnl "dot" writes -V output to stderr:
347 if (dot -V) 2>&1 | grep '^dot - [[gG]]raphviz version' >/dev/null 2>&1; then
352 AM_CONDITIONAL([HAVE_DOT], [test "$pspp_cv_dot" = yes])])
355 dnl Check that xgettext is sufficiently recent
356 dnl Before calling this macro, AC_CHECK_PROGS([XGETTEXT], [xgettext]) should have been called,
357 dnl which sets the ac_cv_prog_XGETTEXT cache variable.
358 AC_DEFUN([PSPP_CHECK_XGETTEXT],
359 [AC_CACHE_CHECK([whether gettext is sufficiently recent],
360 [pspp_cv_progrecent_xgettext],
361 [pspp_cv_progrecent_xgettext=maybe
362 ver=`$ac_cv_prog_XGETTEXT --version | sed -n -e '/xgettext/s/[[^0-9]]*\([[0-9\.]][[0-9\.]]*\).*/\1/p'`
367 majmin=`echo $ver | sed -e 's/\.[[0-9]]*$//'`
368 major=`echo $majmin | sed -e 's/\.[[0-9]]*$//'`
369 minor=`echo $majmin | sed -e 's/^[[0-9]]*\.//'`
370 if test "$major" -lt 0; then
371 pspp_cv_progrecent_xgettext=no;
372 elif test "$minor" -lt 20; then
373 pspp_cv_progrecent_xgettext=no
375 pspp_cv_progrecent_xgettext=yes