1 dnl Copyright (C) 2005, 2006, 2007, 2009, 2014, 2015 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 prerequisites 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 prerequisites 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 2 or 3 is available.
47 AC_DEFUN([PSPP_PYTHON],
48 [AC_ARG_VAR([PYTHON], [Python 2 or 3 interpreter])
49 AC_CHECK_PROGS([PYTHON], [python python2 python3], [none])])
51 dnl PSPP_CHECK_CC_OPTION([OPTION], [ACTION-IF-ACCEPTED], [ACTION-IF-REJECTED])
52 dnl Check whether the given C compiler OPTION is accepted.
53 dnl If so, execute ACTION-IF-ACCEPTED, otherwise ACTION-IF-REJECTED.
54 AC_DEFUN([PSPP_CHECK_CC_OPTION],
56 m4_define([pspp_cv_name], [pspp_cv_[]m4_translit([$1], [-], [_])])dnl
57 AC_CACHE_CHECK([whether $CC accepts $1], [pspp_cv_name],
58 [pspp_save_CFLAGS="$CFLAGS"
60 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,)], [pspp_cv_name[]=yes], [pspp_cv_name[]=no])
61 CFLAGS="$pspp_save_CFLAGS"])
62 if test $pspp_cv_name = yes; then
63 m4_if([$2], [], [;], [$2])
65 m4_if([$3], [], [:], [$3])
69 dnl Check for readline and history libraries.
71 dnl Modified for PSPP, based on readline.m4 serial 3 from
72 dnl gnulib, which was written by Simon Josefsson, with help from Bruno
73 dnl Haible and Oskar Liljeblad.
75 AC_DEFUN([PSPP_READLINE],
77 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
78 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
79 AC_REQUIRE([AC_LIB_RPATH])
81 dnl Search for libreadline and define LIBREADLINE, LTLIBREADLINE and
82 dnl INCREADLINE accordingly.
83 AC_LIB_LINKFLAGS_BODY([readline])
84 AC_LIB_LINKFLAGS_BODY([history])
86 dnl Add $INCREADLINE to CPPFLAGS before performing the following checks,
87 dnl because if the user has installed libreadline and not disabled its use
88 dnl via --without-libreadline-prefix, he wants to use it. The AC_LINK_IFELSE
89 dnl will then succeed.
90 am_save_CPPFLAGS="$CPPFLAGS"
91 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCREADLINE $INCHISTORY])
93 AC_CACHE_CHECK(for readline, gl_cv_lib_readline, [
96 dnl On some systems, -lreadline doesn't link without an additional
97 dnl -lncurses or -ltermcap.
98 dnl Try -lncurses before -ltermcap, because libtermcap is unsecure
99 dnl by design and obsolete since 1994. Try -lcurses last, because
100 dnl libcurses is unusable on some old Unices.
101 for extra_lib in "" ncurses termcap curses; do
102 LIBS="$am_save_LIBS $LIBREADLINE $LIBHISTORY"
103 if test -n "$extra_lib"; then
104 LIBS="$LIBS -l$extra_lib"
106 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
107 #include <readline/readline.h>
108 #include <readline/history.h>]], [[readline((char*)0); add_history((char*)0);]])],[gl_cv_lib_readline=yes],[])
109 if test "$gl_cv_lib_readline" = yes; then
110 if test -n "$extra_lib"; then
111 LIBREADLINE="$LIBREADLINE $LIBHISTORY -l$extra_lib"
112 LTLIBREADLINE="$LTLIBREADLINE $LTLIBHISTORY -l$extra_lib"
120 if test "$gl_cv_lib_readline" = yes; then
121 AC_DEFINE(HAVE_READLINE, 1, [Define if you have the readline library.])
122 AC_MSG_CHECKING([how to link with libreadline])
123 AC_MSG_RESULT([$LIBREADLINE])
124 AC_SEARCH_LIBS([rl_echo_signal_char], [readline],
125 AC_DEFINE(HAVE_RL_ECHO_SIGNAL_CHAR, 1, [Define if the readline library provides rl_echo_signal_char.]),[],[$LIBREADLINE])
126 AC_SEARCH_LIBS([rl_outstream], [readline],
127 AC_DEFINE(HAVE_RL_OUTSTREAM, 1, [Define if the readline library provides rl_outstream.]),[],[$LIBREADLINE])
129 dnl If $LIBREADLINE didn't lead to a usable library, we don't
130 dnl need $INCREADLINE either.
131 CPPFLAGS="$am_save_CPPFLAGS"
136 PSPP_OPTIONAL_PREREQ([libreadline (which may itself require libncurses or libtermcap)])
138 AC_SUBST(LIBREADLINE)
139 AC_SUBST(LTLIBREADLINE)
142 dnl Check for build tools. Adapted from bfd library.
144 AC_DEFUN([PSPP_CC_FOR_BUILD],
145 [# Put a plausible default for CC_FOR_BUILD in Makefile.
146 if test -z "$CC_FOR_BUILD"; then
147 if test "x$cross_compiling" = "xno"; then
153 AC_SUBST(CC_FOR_BUILD)
154 # Also set EXEEXT_FOR_BUILD.
155 if test "x$cross_compiling" = "xno"; then
156 EXEEXT_FOR_BUILD='$(EXEEXT)'
158 AC_CACHE_CHECK([for build system executable suffix], pspp_cv_build_exeext,
160 echo 'int main () { return 0; }' > conftest.c
161 pspp_cv_build_exeext=
162 ${CC_FOR_BUILD} -o conftest conftest.c 1>&5 2>&5
163 for file in conftest.*; do
165 *.c | *.o | *.obj | *.ilk | *.pdb) ;; # (
166 *) pspp_cv_build_exeext=`echo $file | sed -e s/conftest//` ;;
170 test x"${pspp_cv_build_exeext}" = x && pspp_cv_build_exeext=no])
172 test x"${pspp_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${pspp_cv_build_exeex
175 AC_SUBST(EXEEXT_FOR_BUILD)])
177 dnl Check for LC_PAPER, _NL_PAPER_WIDTH, _NL_PAPER_HEIGHT.
178 AC_DEFUN([PSPP_LC_PAPER],
179 [AC_CACHE_CHECK(for LC_PAPER, pspp_cv_lc_paper, [
184 #include <langinfo.h>
186 [(void) LC_PAPER; (void) _NL_PAPER_WIDTH; (void) _NL_PAPER_HEIGHT])],
187 [pspp_cv_lc_paper=yes])
189 if test "$pspp_cv_lc_paper" = yes; then
190 AC_DEFINE(HAVE_LC_PAPER, 1, [Define if you have LC_PAPER.])
195 # PSPP_LINK2_IFELSE(SOURCE1, SOURCE2, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
196 # -------------------------------------------------------------
197 # Based on AC_LINK_IFELSE, but tries to link both SOURCE1 and SOURCE2
200 # Test that resulting file is executable; see the problem reported by mwoehlke
201 # in <http://lists.gnu.org/archive/html/bug-coreutils/2006-10/msg00048.html>.
202 # But skip the test when cross-compiling, to prevent problems like the one
203 # reported by Chris Johns in
204 # <http://lists.gnu.org/archive/html/autoconf/2007-03/msg00085.html>.
206 m4_define([PSPP_LINK2_IFELSE],
207 [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
208 mv conftest.$ac_ext conftest1.$ac_ext
209 m4_ifvaln([$2], [AC_LANG_CONFTEST([$2])])dnl
210 mv conftest.$ac_ext conftest2.$ac_ext
211 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext
212 pspp_link2='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest1.$ac_ext conftest2.$ac_ext $LIBS >&5'
213 AS_IF([_AC_DO_STDERR($pspp_link2) && {
214 test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" ||
215 test ! -s conftest.err
216 } && test -s conftest$ac_exeext && {
217 test "$cross_compiling" = yes ||
218 AS_TEST_X([conftest$ac_exeext])
221 [echo "$as_me: failed source file 1 of 2 was:" >&5
222 sed 's/^/| /' conftest1.$ac_ext >&5
223 echo "$as_me: failed source file 2 of 2 was:" >&5
224 sed 's/^/| /' conftest2.$ac_ext >&5
226 dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization)
227 dnl information created by the PGI compiler (conftest_ipa8_conftest.oo),
228 dnl as it would interfere with the next link command.
229 rm -rf conftest.dSYM conftest1.dSYM conftest2.dSYM
230 rm -f core conftest.err conftest1.err conftest2.err
231 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest*_ipa8_conftest*.oo
232 rm -f conftest$ac_exeext
233 rm -f m4_ifval([$1], [conftest1.$ac_ext]) m4_ifval([$2], [conftest1.$ac_ext])[]dnl
234 ])# PSPP_LINK2_IFELSE
236 # GSL uses "extern inline" without determining whether the compiler uses
237 # GCC inline rules or C99 inline rules. If it uses the latter then GSL
238 # will be broken without passing -fgnu89-inline to GCC.
239 AC_DEFUN([PSPP_GSL_NEEDS_FGNU89_INLINE],
240 [# GSL only uses "inline" at all if HAVE_INLINE is defined as a macro.
241 # In turn, gnulib's gl_INLINE is one macro that does that. We need to
242 # make sure that it has run by the time we run this test, otherwise we'll
243 # get a false result.
244 AC_REQUIRE([gl_INLINE])
245 PSPP_CHECK_CC_OPTION(
247 [AC_CACHE_CHECK([whether GSL needs -fgnu89-inline to link],
248 pspp_cv_gsl_needs_fgnu89_inline, [
250 [AC_LANG_PROGRAM([#include <gsl/gsl_math.h>
251 ], [GSL_MAX_INT(1,2);])],
252 [AC_LANG_SOURCE([#include <gsl/gsl_math.h>
254 [pspp_cv_gsl_needs_fgnu89_inline=no],
255 [pspp_cv_gsl_needs_fgnu89_inline=yes])])
256 if test "$pspp_cv_gsl_needs_fgnu89_inline" = "yes"; then
257 CFLAGS="$CFLAGS -fgnu89-inline"
261 AC_DEFUN([PSPP_CHECK_CLICKSEQUENCE],
262 [AC_REQUIRE([AM_INIT_AUTOMAKE]) # Defines MAKEINFO
263 AC_CACHE_CHECK([whether makeinfo supports @clicksequence],
264 [pspp_cv_have_clicksequence],
265 [cat > conftest.texi <<EOF
266 @setfilename conftest.info
267 @clicksequence{File @click{} Open}
269 echo "configure:__oline__: running $MAKEINFO conftest.texi >&AS_MESSAGE_LOG_FD" >&AS_MESSAGE_LOG_FD
270 eval "$MAKEINFO conftest.texi >&AS_MESSAGE_LOG_FD 2>&1"
272 echo "configure:__oline__: \$? = $retval" >&AS_MESSAGE_LOG_FD
273 if test $retval = 0; then
274 pspp_cv_have_clicksequence=yes
276 pspp_cv_have_clicksequence=no
278 rm -f conftest.texi conftest.info])
279 if test $pspp_cv_have_clicksequence = no; then
280 AM_MAKEINFOFLAGS="$AM_MAKEINFOFLAGS -DMISSING_CLICKSEQUENCE"
281 AC_SUBST([AM_MAKEINFOFLAGS])
284 dnl Texinfo 4.13 generates broken DocBook XML. Probably other old
285 dnl versions do too, but that's the one that causes problems.
286 AC_DEFUN([PSPP_CHECK_MAKEINFO_DOCBOOK_XML],
287 [AC_REQUIRE([AM_INIT_AUTOMAKE]) # Defines MAKEINFO
289 [whether makeinfo generates broken DocBook XML],
290 [pspp_cv_broken_docbook_xml],
292 [$(eval "$MAKEINFO --version | head -1")],
293 [*texinfo*4.13*], [pspp_cv_broken_docbook_xml=yes],
294 [*texinfo*], [pspp_cv_broken_docbook_xml=no],
295 [*], [pspp_cv_broken_docbook_xml=yes])])
297 [BROKEN_DOCBOOK_XML], [test "$pspp_cv_broken_docbook_xml" = yes])])
299 # The following comes from Open vSwitch:
300 # ----------------------------------------------------------------------
301 # Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
303 # Licensed under the Apache License, Version 2.0 (the "License");
304 # you may not use this file except in compliance with the License.
305 # You may obtain a copy of the License at:
307 # http://www.apache.org/licenses/LICENSE-2.0
309 # Unless required by applicable law or agreed to in writing, software
310 # distributed under the License is distributed on an "AS IS" BASIS,
311 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
312 # See the License for the specific language governing permissions and
313 # limitations under the License.
315 dnl PSPP_ENABLE_WERROR
316 AC_DEFUN([PSPP_ENABLE_WERROR],
319 [AC_HELP_STRING([--enable-Werror], [Add -Werror to CFLAGS])],
320 [], [enable_Werror=no])
321 AC_CONFIG_COMMANDS_PRE(
322 [if test "X$enable_Werror" = Xyes; then
323 CFLAGS="$CFLAGS -Werror -Wno-error=deprecated-declarations"
326 # The following comes from Open vSwitch:
327 # ----------------------------------------------------------------------
328 # Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
330 # Licensed under the Apache License, Version 2.0 (the "License");
331 # you may not use this file except in compliance with the License.
332 # You may obtain a copy of the License at:
334 # http://www.apache.org/licenses/LICENSE-2.0
336 # Unless required by applicable law or agreed to in writing, software
337 # distributed under the License is distributed on an "AS IS" BASIS,
338 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
339 # See the License for the specific language governing permissions and
340 # limitations under the License.
343 AC_DEFUN([PSPP_CHECK_DOT],
347 [dnl "dot" writes -V output to stderr:
348 if (dot -V) 2>&1 | grep '^dot - [[gG]]raphviz version' >/dev/null 2>&1; then
353 AM_CONDITIONAL([HAVE_DOT], [test "$pspp_cv_dot" = yes])])