source: trunk/configure.ac

Last change on this file was 1598, checked in by Jari Häkkinen, 5 years ago

Merged release 0.10.3 to the trunk.

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