source: trunk/configure.ac

Last change on this file was 1676, checked in by Peter Johansson, 4 weeks ago

specify that yat 0.12 is required

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 17.4 KB
Line 
1## Process this file with autoconf to produce a configure script.
2##
3## $Id: configure.ac 1676 2023-08-29 04:58:22Z peter $
4##
5## If you grabbed the source from subversion you should, at top-level,
6## execute:
7##          ./bootstrap
8## To push subsequent changes of this file into the build scripts you
9## must issue:
10##          autoreconf
11
12# Copyright (C) 2005 Jari Häkkinen, Peter Johansson
13# Copyright (C) 2006 Jari Häkkinen
14# Copyright (C) 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
15# Copyright (C) 2010, 2011, 2012 Peter Johansson
16# Copyright (C) 2015 Jari Häkkinen
17# Copyright (C) 2023 Peter Johansson
18#
19# This file is part of svndigest, http://dev.thep.lu.se/svndigest
20#
21# svndigest is free software; you can redistribute it and/or modify it
22# under the terms of the GNU General Public License as published by
23# the Free Software Foundation; either version 3 of the License, or
24# (at your option) any later version.
25#
26# svndigest is distributed in the hope that it will be useful, but
27# WITHOUT ANY WARRANTY; without even the implied warranty of
28# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29# General Public License for more details.
30#
31# You should have received a copy of the GNU General Public License
32# along with svndigest. If not, see <http://www.gnu.org/licenses/>.
33
34AC_PREREQ([2.63])
35
36m4_include([m4/version.m4])
37AC_INIT([svndigest], m4_defn([my_VERSION]),
38        [svndigest-users@lists.sourceforge.net],,
39        [https://dev.thep.lu.se/svndigest])
40AC_CONFIG_SRCDIR([lib/File.h])
41AC_CONFIG_AUX_DIR([autotools])
42dnl arg below should be the same as in Makefile.am
43AC_CONFIG_MACRO_DIR([m4])
44AC_PREFIX_DEFAULT([/usr/local])
45
46dnl FIXME remove when we assume autoconf 2.64
47m4_ifndef([AC_PACKAGE_URL],
48          [AC_DEFINE([PACKAGE_URL], ["https://dev.thep.lu.se/svndigest"],
49                     [Define to home page for this package])
50           AC_SUBST([PACKAGE_URL], ["https://dev.thep.lu.se/svndigest"])])
51
52MY_VERSION
53AC_CONFIG_HEADERS([config.h])
54AM_INIT_AUTOMAKE([1.11 color-tests std-options parallel-tests
55                  silent-rules subdir-objects])
56
57# Set default programming language
58AC_LANG([C++])
59
60# propagate selected configure variables to DISTCHECK_CONFIGURE_FLAGS
61for var in CPPFLAGS CXX CXXFLAGS CXXCPP LDFLAGS LIBS; do
62  eval isset=\${$var+set}
63  if test "$isset" = 'set' ; then
64    eval val=$`echo $var`
65    DISTCHECK_CONFIGURE_FLAGS="${DISTCHECK_CONFIGURE_FLAGS}'${var}=${val}' "
66  fi
67done
68AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
69
70# record if CXXFLAGS was set by user for further use below
71AS_IF([test "${CXXFLAGS+set}" = set], [
72  CXXFLAGS_set_by_user=yes
73],[
74  CXXFLAGS_set_by_user=no
75  # set CXXFLAGS to avoid expansion in AC_PROG_CXX
76  CXXFLAGS=
77])
78
79# Checks for programs.
80AC_PROG_CXXCPP
81AC_PROG_CXX
82AC_PROG_RANLIB
83AC_PROG_SED
84
85AC_ARG_VAR([HELP2MAN], [help2man])
86AC_CHECK_PROG([HELP2MAN], [help2man], [help2man], [false])
87
88# look for pkg-config
89PKG_PROG_PKG_CONFIG([0.23])
90
91# Save FLAGS
92APR_SAVE_THE_ENVIRONMENT(CPPFLAGS)
93APR_SAVE_THE_ENVIRONMENT(CXXFLAGS)
94
95YAT_CXX11([yes], [], [AC_MSG_FAILURE([$CXX is not a C++11 compiler])])
96AC_TYPE_LONG_LONG_INT
97AS_IF([test x$ac_cv_type_long_long_int = xno],
98      [AC_MSG_ERROR([compiler does not support long long int])]
99     )
100
101AC_ARG_ENABLE([debug],
102  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])],
103  [], [enable_debug=no])
104
105# Set CXXFLAGS depending on whether CXXFLAGS was provided by user and
106# whether we are in debug mode
107AS_IF([test x$enable_debug = xyes], [
108  # in debug we alsways add flags below i.e. we turn on warnings,
109  # debug symbols, and low level of optimisation.
110
111  # -Wno-long-long is needed to suppress compiler diagnostics regarding
112  # using extension beyond the C++ standard (usage of non C++ standard
113  # 'long long' types).
114  YAT_CXX_ADD_FLAG([CXXFLAGS],[-pedantic -Wall -g -O])
115],[
116  # in standard mode we set to CXXFLAGS default to '-O3', but only if
117  # CXXFLAGS was not proved by user. If user provided a VALUE FOR
118  # CXXFLAGS we listen to that and leave as is.
119  AS_IF([test x$CXXFLAGS_set_by_user != xyes], [
120    YAT_CXX_ADD_FLAG([CXXFLAGS],[-O3])
121  ])
122])
123
124AC_ARG_ENABLE([assert],
125  [AS_HELP_STRING([--enable-assert], [turn on assertions])])
126
127# if assert not enabled/disabled explicitly, default behaviour is to
128# enable assert in debug mode and disable otherwise
129test "${enable_assert+set}" = set || enable_assert=$enable_debug
130
131# FIXME perhaps we should AC_DEFINE NDEBUG instead but then we need to
132# include config.h in all source files.
133#
134# propagate enable_assert to CPPFLAGS
135AS_IF([test x$enable_assert != xyes],[YAT_CPP_ADD_FLAG([CPPFLAGS],[-DNDEBUG])])
136
137AC_MSG_CHECKING([g++ deprecation attribute])
138AC_COMPILE_IFELSE(
139  [AC_LANG_PROGRAM([[void f() __attribute__ ((deprecated));]],)],
140  [AC_DEFINE([YAT_HAVE_GCC_DEPRECATED], [1],
141             [Define if compiler supports deprecated attribute, as in g++ 4.0])
142   AC_MSG_RESULT([yes])],
143  [AC_MSG_RESULT([no])] )
144
145# Apache Portable Runtime (APR) API checks
146APR_FIND_APR(,,[1],[1 0])
147AS_IF([test "${with_apr+set}" = set],
148    [DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-apr=$with_apr"]
149)
150if test "$apr_found" = "yes" ; then
151  APR_LIBS="`$apr_config --libs`"
152  apr_link_ld="`$apr_config --link-ld`"
153  for i in $apr_link_ld; do
154    AS_IF([AS_ECHO([$i]) | grep '^-l' > /dev/null],
155          [APR_LIBS="$i $APR_LIBS"],
156          [YAT_LD_ADD_FLAG([LDFLAGS], [$i])])
157  done
158  YAT_CPP_ADD_FLAG([CPPFLAGS],[`$apr_config --includes --cppflags`])
159  AC_CHECK_HEADER([apr_allocator.h],,[apr_found="no"])
160fi
161AC_SUBST([APR_LIBS])
162
163# Subversion API checks
164svn_found="yes"
165AC_ARG_WITH([svn],
166  [AS_HELP_STRING([--with-svn=DIR],
167                  [prefix for svn developer files])],
168  [ AS_CASE([$withval], [yes|no],
169            [AC_MSG_ERROR([--with-svn requires a directory to be provided])])
170    AS_IF([test -d $with_svn], [],
171          [AC_MSG_ERROR([$with_svn: no such directory])])
172    # transform argument to absolute path
173    with_svn=`cd $with_svn && pwd`
174    DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-svn=$with_svn"
175    YAT_LD_ADD_FLAG([LDFLAGS], [-L$with_svn/lib])
176    YAT_CPP_ADD_FLAG([CPPFLAGS], [-I$with_svn/include])
177  ])
178# svn needs needs apr headers
179AC_CHECK_HEADER([subversion-1/svn_types.h],,[svn_found="no"])
180
181# In some versions, such as 1.7, of Subversion header file `svn_wc.h'
182# does not conform to C++98 and therefore compiling with -pedantic
183# fails. As -pedantic is automatically turned on in --enable-debug
184# mode we need to turn it off -pedantic to allow building with
185# --enable-debug (see ticket #506)
186AS_IF([test x$enable_debug = xyes],
187  [AC_MSG_CHECKING([subversion-1/svn_wc.h usability with -pedantic])
188   AC_COMPILE_IFELSE(
189    [AC_LANG_PROGRAM([@%:@include <subversion-1/svn_wc.h>])],
190    [AC_MSG_RESULT([yes])],
191    [AC_MSG_RESULT([no])
192     CXXFLAGS=`AS_ECHO(["$CXXFLAGS"]) | $SED 's|-pedantic||'`
193     AC_MSG_NOTICE([remove -pedantic from \$CXXFLAGS])
194    ]
195   )
196  ])
197
198save_LIBS=$LIBS
199tmp_LIBS="$APR_LIBS $save_LIBS"
200LIBS=""
201AC_SEARCH_LIBS([svn_cmdline_setup_auth_baton],[svn_subr-1],
202               [], [svn_found="no"], [$tmp_LIBS])
203AC_SEARCH_LIBS([svn_ra_initialize],[svn_ra-1], [], [svn_found="no"],[$tmp_LIBS])
204AC_SEARCH_LIBS([svn_wc_adm_open3],[svn_wc-1], [], [svn_found="no"], [$tmp_LIBS])
205AC_SEARCH_LIBS([svn_diff_file_options_create],[svn_diff-1],[],
206               [svn_found="no"], [$tmp_LIBS])
207AC_SEARCH_LIBS([svn_client_log3],[svn_client-1],,[svn_found="no"], [$tmp_LIBS])
208SVN_LIBS=$LIBS
209LIBS=$save_LIBS
210AC_SUBST([SVN_LIBS])
211
212YAT_CHECK_YAT([0.12], [], [AC_MSG_ERROR([yat not found])])
213YAT_CPP_ADD_FLAG([CPPFLAGS], [$YAT_CPPFLAGS])
214YAT_CXX_ADD_FLAG([CXXFLAGS], [$YAT_CXXFLAGS])
215YAT_LD_ADD_FLAG([LDFLAGS], [$YAT_LDFLAGS])
216
217# PLplot API checks
218# plplot_found can get values: skip, noheader, old, or nolib if an
219# error is detected.
220plplot_found="yes"
221plplot_version=5.10.0
222save_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
223AC_ARG_WITH([plplot],
224  [AS_HELP_STRING([--with-plplot=DIR],[prefix for plplot developer files])],
225  [DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-plplot=$withval"
226   AS_IF([test "x$withval" = "xno"], [ dnl
227     plplot_found=skip;
228   ], [ dnl
229     AS_IF([test -d $with_plplot], [],
230           [AC_MSG_ERROR([$with_plplot: no such directory])])
231     with_plplot=`cd $with_plplot && pwd`
232     # help pkg-config find .pc file
233     PKG_CONFIG_PATH=$with_plplot/lib/pkgconfig$PATH_SEPARATOR$PKG_CONFIG_PATH
234     export PKG_CONFIG_PATH
235   ])
236  ])
237
238# PLPLOT_USE_D is set to character 'd' for plplot versions prior to
239# 5.11 since library names changed in plplot 5.11, i.e., the 'd' to
240# indicate double floating number precision was removed from library
241# names.
242PLPLOT_USE_D=
243use_plplot_pc="no"
244AS_IF([test "x$plplot_found" = "xyes" && test -n "$PKG_CONFIG"], [
245  # check for plplot 5.11 or later first
246  AC_MSG_CHECKING([for plplot-c++.pc])
247  AS_IF([$PKG_CONFIG --exists plplot-c++], [
248    AC_MSG_RESULT([yes])
249    use_plplot_pc="yes"
250  ],[
251    # fall back to check for plplot prior to version 5.11
252    AC_MSG_CHECKING([for plplotd-c++.pc])
253    AS_IF([$PKG_CONFIG --exists plplotd-c++], [
254      AC_MSG_RESULT([yes])
255      use_plplot_pc="yes"
256      # plplot prior to 5.11 found, use 'd'
257      PLPLOT_USE_D=d
258    ],[
259      AC_MSG_RESULT([no])
260      AC_MSG_WARN([cannot find plplotd-c++ nor plplot-c++;
261        please use --with-plplot with appropriate argument to get more accurate
262        configuration.])
263    ])
264  ])
265])
266
267AS_IF([test "x$plplot_found" = "xyes"], [
268  # copy flags if we have found pc file
269  AS_IF([test "$use_plplot_pc" = "yes"], [
270    # plplot typically returns <prefix>/include/plplot because plplot
271    # people assumes users include header files as <foo.h>. We prefer
272    # including files as <plplot/foo.h> and therefore need to trim off
273    # trailing '/plplot'. Space is included in sed expression to avoid
274    # substituting potential '/plplot' in PREFIX.
275    YAT_CPP_ADD_FLAG([CPPFLAGS],
276             [`$PKG_CONFIG plplot$PLPLOT_USE_D-c++ --cflags-only-I | sed 's|/plplot | |g'`])
277    YAT_LD_ADD_FLAG([LDFLAGS], [`$PKG_CONFIG plplot$PLPLOT_USE_D-c++ --libs-only-L`])
278    PLPLOT_LIBS="`$PKG_CONFIG plplot$PLPLOT_USE_D-c++ --libs-only-l --libs-only-other`"
279  ],[
280    # otherwise guess
281    PLPLOT_LIBS="-lplplotcxx -lplplot";
282    AS_IF([test -n "$with_plplot" && test "x$with_plplot" != "xyes"], [
283      YAT_LD_ADD_FLAG([LDFLAGS], [-L$with_plplot/lib])
284      YAT_CPP_ADD_FLAG([CPPFLAGS], [-I$with_plplot/include])
285    ])
286  ])
287])
288
289AS_IF([test "x$plplot_found" = "xyes"], [
290  AC_CHECK_HEADER([plplot/plstream.h], [], [plplot_found="noheader"])
291])
292
293AS_IF([test "x$plplot_found" = "xyes" && test -n "$PKG_CONFIG"], [
294  AC_MSG_CHECKING([plplot version >= $plplot_version])
295  AS_IF([$PKG_CONFIG --atleast-version=$plplot_version plplot$PLPLOT_USE_D-c++], [
296    AC_MSG_RESULT([yes])
297  ],[
298    have_plplot_version=`$PKG_CONFIG --modversion plplot$PLPLOT_USE_D-c++`
299    AC_MSG_RESULT([$have_plplot_version])
300    plplot_found="old"
301  ])
302])
303
304AS_IF([test "x$plplot_found" = "xyes"], [
305  save_LIBS=$LIBS
306  LIBS="$PLPLOT_LIBS $LIBS"
307  AC_MSG_CHECKING([for library containing plstream])
308  AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@include <plplot/plstream.h>],
309                                  [plstream pls(1,1,"svg", "conftest.svg");
310                                   pls.scolbga(255, 255, 255, 0);
311                                  ])],
312                 [AC_MSG_RESULT([yes]);
313                  AC_DEFINE([HAVE_PLPLOT], [1],
314                            [Define to 1 if you have plplot])],
315                 [AC_MSG_RESULT([no])
316                  plplot_found=nolib;])
317  LIBS=$save_LIBS
318])
319# restore variable
320export PKG_CONFIG_PATH=$save_PKG_CONFIG_PATH
321AC_SUBST(PLPLOT_LIBS)
322
323# checking if we have test repo
324test_repo_filename=$srcdir/test/repo;
325AS_IF([test -r $test_repo_filename],
326              [AC_DEFINE([HAVE_TEST_REPO],[1],[define if test repo is available])
327               test_repo_found="yes"],
328              [test_repo_found="no"])
329AC_SUBST([test_repo_found])
330AS_IF([test "x$test_repo_found" = xyes],
331      [abs_test_repo=`cd $test_repo_filename && pwd`;
332       AC_SUBST(abs_test_repo)]
333     )
334AC_CONFIG_FILES([test/init.sh])
335AC_CONFIG_FILES([test/svn_update.sh], [chmod +x test/svn_update.sh])
336
337# prefer in-tree versions rather than installed (detected in
338# YAT_SVN_RELEASE below
339: ${SVNDIGEST_COPY_CACHE=bin/svndigest-copy-cache}
340: ${SVNCOPYRIGHT=bin/svncopyright}
341
342YAT_AM_LOCAL
343YAT_SVN_REVISION
344YAT_REVISION_HEADER
345YAT_SVN_RELEASE_YEAR
346YAT_SVN_TIMESTAMP
347
348# look for git program needed while doing a release
349AC_CHECK_PROG([GIT], [git], [git], [false])
350AC_ARG_VAR([GIT], [git command])
351
352dnl maintainer make rules from yat project
353YAT_SVN_RELEASE([],
354  [$(SVNDIGEST_MAJOR_VERSION).$(SVNDIGEST_MINOR_VERSION)],
355  [svndigest@frs.sourceforge.net:/home/frs/project/s/sv/svndigest],
356  [https://sourceforge.net/projects/svndigest/files/$(distdir).tar.gz/files],
357  [https://dev.thep.lu.se/svndigest/browser/tags/$(VERSION)/NEWS])
358
359# Restore FLAGS
360APR_RESTORE_THE_ENVIRONMENT([CPPFLAGS], [SVNDIGEST_])
361APR_RESTORE_THE_ENVIRONMENT([CXXFLAGS], [SVNDIGEST_])
362APR_RESTORE_THE_ENVIRONMENT([LDFLAGS], [SVNDIGEST_])
363
364AC_CONFIG_FILES([Makefile test/environment.h])
365
366AC_CONFIG_FILES([build_support/tag_and_release.sh],
367                [chmod +x-w build_support/tag_and_release.sh])
368AC_CONFIG_FILES([build_support/dummy_help2man.sh],
369                [chmod +x-w build_support/dummy_help2man.sh])
370
371# Print failure status information about selected items, and exit if
372# fatal errors were encountered. No output will be created if
373# configure is halted prematurely.
374
375# used to trigger exit before creation of output
376all_reqs_ok="true"
377
378# checking for help2man, missing help2man is non-fatal but subsequent
379# use of `make dist` and `make distcheck` is constructed to fail.
380AC_MSG_CHECKING([whether to use help2man])
381# avoid running help2man when cross-compiling (as it involves invoking binaries)
382AS_IF([test x$cross_compiling = x"yes"], [have_help2man=cross_compiling],
383      [test x"$HELP2MAN" = x"false"], [have_help2man=no],
384      [have_help2man=yes])
385AM_CONDITIONAL([HAVE_HELP2MAN], [test "x$have_help2man" = "xyes"])
386AC_MSG_RESULT([$have_help2man])
387
388# if we work in an svn wc we should have a test repository and warn if
389# help2man missing
390AS_VAR_IF([have_svn_wc], [yes], [
391   if (test "$test_repo_found" = "no"); then
392      all_reqs_ok="false";
393      AC_MSG_WARN(m4_text_wrap(m4_normalize([
394         Cannot find test repository (test/repo), which should be
395   available when building from a subversion working copy.
396   Try svn update in top directory.
397   ]),
398   [                   ],[                             ],79))
399   fi
400   if (test "$have_help2man" = "no"); then
401       # non-fatal, only issue warning
402       AC_MSG_WARN(m4_text_wrap(m4_normalize([
403          `help2man' is missing on your system. You will not be
404    able to create the man page. A sound man page should be
405    included in a distribution, and since you will not able
406    to create a complete distribution `make dist' will fail.
407    You may want to install the GNU Help2man package:
408    <https://www.gnu.org/software/help2man/>
409    ]),
410    [                   ],[                             ],79))
411   fi
412])
413
414# Non-existing APR is fatal -- sub-sequent compilation will fail.
415if (test "$apr_found" = "no") ; then
416  AC_MSG_WARN([APR not found. The Apache Portable Runtime
417  (APR) library cannot be found. Please make sure APR is installed
418  and supply the appropriate --with-apr option to 'configure'.])
419  all_reqs_ok="false"
420fi
421
422# Non-existing subversion API is fatal -- sub-sequent compilation will fail.
423if (test "$svn_found" = "no") ; then
424  svn_msg="Subversion API not found. Subversion API libraries cannot
425  be found. Make sure the APIs are installed and supply the
426  appropriate --with-svn option to 'configure'."
427  if (test "$apr_found" = "no") ; then
428    svn_msg="$svn_msg
429    Note, APR was not found. Failure to locate APR affects the search
430    of the subversion API. Please fix the APR problem before trying
431    to resolve the subversion related issues."
432  fi
433  AC_MSG_WARN([$svn_msg])
434  all_reqs_ok="false"
435fi
436
437# Non-existing PLplot API is fatal -- sub-sequent compilation will fail.
438AS_CASE([$plplot_found],
439  [noheader],
440    [AC_MSG_WARN([
441    PLplot developer files cannot be found. Make sure PLplot is installed.])
442    all_reqs_ok="false"],
443  [old],
444    [AC_MSG_WARN([
445    PLplot developer files found but not required API version.
446    Version at least $plplot_version is required. Please upgrade PLplot.])
447    all_reqs_ok="false"],
448  [nolib],
449    [AC_MSG_WARN([
450    PLplot developer files found but linking against plplot library failed.])
451    all_reqs_ok="false"])
452
453if test $ac_cv_type_long_long_int != yes ; then
454  AC_MSG_WARN([Compiler $CXX does not support `long long'.
455  svndigest must be compiled with a compiler that supports `long long'.])
456  all_reqs_ok="false"
457fi
458
459if (test "$all_reqs_ok" = "false") ; then
460  AC_MSG_ERROR([Some pre-requisites were not fulfilled, aborting
461  configure. Please consult the 'README' file for more information
462  about what is needed to compile svndigest and refer to above
463  warning messages. Needed files were NOT created.])
464fi
465
466# Create output.
467AC_OUTPUT
468
469# Some more messages.
470AC_MSG_NOTICE([
471Ready to compile the executables of svndigest $VERSION
472The following flags and libs will be used:
473+++++++++++++++++++++++++++++++++++++++++++++++
474  Compiler:           $CXX
475  Preprocessor flags:
476    CPPFLAGS:           $CPPFLAGS
477    SVNDIGEST_CPPFLAGS: $SVNDIGEST_CPPFLAGS
478  C++ flags:
479    CXXFLAGS:           $CXXFLAGS
480    SVNDIGEST_CXXFLAGS: $SVNDIGEST_CXXFLAGS
481  Linker flags:
482    LDFLAGS:            $LDFLAGS
483    SVNDIGEST_LDFLAGS:  $SVNDIGEST_LDFLAGS
484  Libraries:
485    LIBS                $LIBS
486    APR_LIBS            $APR_LIBS
487    SVN_LIBS            $SVN_LIBS
488    PLPLOT_LIBS         $PLPLOT_LIBS
489+++++++++++++++++++++++++++++++++++++++++++++++]dnl
490)
491
492AC_MSG_NOTICE([Now type 'make all check'.])
Note: See TracBrowser for help on using the repository browser.